-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat(dex): wire 1inch-LOP aggregator trades into dex_aggregator.trades (CUR2-2693, 2/2) #9759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
52bbf88
Reapply "fix(dex): stop double counting venue-settled 1inch-LOP fills…
thevaizman d840d98
fix(oneinch): serve LOP aggregator trades as-is; decouple from dex_ag…
thevaizman e2bec45
feat(dex): wire 1inch-LOP aggregator trades into dex_aggregator.trade…
thevaizman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
dbt_subprojects/dex/macros/models/_project/oneinch/LO/oneinch_lop_evt_index_macro.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| -- evt_index for 1inch LOP fills: numbered over ALL limits fills of a tx, BEFORE any | ||
| -- exclusion, so kept rows retain their dex_<blockchain>_trades merge keys when fills | ||
| -- are reclassified (merge can only upsert, never delete). | ||
| -- Both sides of the dex.trades / dex_aggregator.trades split must agree on this | ||
| -- numbering: oneinch_lop_own_trades computes it at query time, while | ||
| -- oneinch_lop_venue_settled_fills persists it for oneinch_lop_aggregator_trades. | ||
|
|
||
| {% macro oneinch_lop_evt_index() -%} | ||
| row_number() over(partition by tx_hash order by call_trace_address) | ||
| {%- endmacro %} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
dbt_subprojects/dex/models/_projects/oneinch/outside/oneinch_lop_aggregator_trades.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| {{ | ||
| config( | ||
| schema = 'oneinch', | ||
| alias = 'lop_aggregator_trades', | ||
| materialized = 'view', | ||
| unique_key = ['blockchain', 'block_month', 'tx_hash', 'trace_address', 'evt_index'], | ||
| ) | ||
| }} | ||
|
|
||
| {% set src_symbol = "coalesce(src_executed_symbol, '')" %} | ||
| {% set dst_symbol = "coalesce(dst_executed_symbol, '')" %} | ||
|
|
||
|
|
||
|
|
||
| -- venue-settled LOP fills: the underlying venue's own row stays in dex.trades, so the | ||
| -- intent-layer fill is recorded here instead (user perspective, like oneinch_ar_trades). | ||
| -- evt_index comes persisted from oneinch_lop_venue_settled_fills (same numbering as | ||
| -- oneinch_lop_own_trades via oneinch_lop_evt_index()); keeping this view window-free | ||
| -- lets consumers' block_time predicates push down into the oneinch_swaps scan | ||
| select | ||
| f.blockchain | ||
| , '1inch-LOP' as project | ||
| , cast(f.protocol_version as varchar) as version | ||
| , f.block_date | ||
| , f.block_month | ||
| , f.block_time | ||
| , {{ dst_symbol }} as token_bought_symbol | ||
| , {{ src_symbol }} as token_sold_symbol | ||
| , case | ||
| when lower({{ src_symbol }}) > lower({{ dst_symbol }}) then concat({{ dst_symbol }}, '-', {{ src_symbol }}) | ||
| else concat({{ src_symbol }}, '-', {{ dst_symbol }}) | ||
| end as token_pair | ||
| , cast(f.dst_executed_amount as double) / pow(10, cast(element_at(f.complement, 'dst_decimals') as bigint)) as token_bought_amount | ||
| , cast(f.src_executed_amount as double) / pow(10, cast(element_at(f.complement, 'src_decimals') as bigint)) as token_sold_amount | ||
| , f.dst_executed_amount as token_bought_amount_raw | ||
| , f.src_executed_amount as token_sold_amount_raw | ||
| , f.amount_usd | ||
| , f.dst_token_address as token_bought_address | ||
| , f.src_token_address as token_sold_address | ||
| , f.user as taker | ||
| , cast(null as varbinary) as maker | ||
| , f.call_to as project_contract_address | ||
| , f.tx_hash | ||
| , f.tx_from | ||
| , f.tx_to | ||
| , f.call_trace_address as trace_address | ||
| , v.evt_index | ||
| from {{ ref('oneinch_swaps') }} as f | ||
| join {{ ref('oneinch_lop_venue_settled_fills') }} as v | ||
| on v.blockchain = f.blockchain | ||
| and v.block_month = f.block_month | ||
| and v.execution_id = f.execution_id | ||
| where true | ||
| and f.mode = 'limits' | ||
| and f.tx_success | ||
| and f.call_success |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.