-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add clipper to
dex.trades_beta
(#5043)
* macro and first test * more chains * update dex_ethereum_base_trades --------- Co-authored-by: Huang Geyang <Sukebeta@outlook.com> Co-authored-by: jeff-dude <102681548+jeff-dude@users.noreply.github.com>
- Loading branch information
1 parent
16d10f9
commit c4a200e
Showing
21 changed files
with
279 additions
and
65 deletions.
There are no files selected for viewing
This file contains 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,52 @@ | ||
{% macro clipper_compatible_trades( | ||
blockchain = null, | ||
project = null, | ||
sources = [] | ||
) | ||
%} | ||
|
||
WITH dexs AS ( | ||
{% for src in sources %} | ||
SELECT | ||
'{{ src["version"] }}' as version, | ||
t.evt_block_number AS block_number, | ||
t.evt_block_time AS block_time, | ||
t.recipient as taker, | ||
CAST(NULL AS VARBINARY) AS maker, | ||
t.inAmount as token_sold_amount_raw, | ||
t.outAmount as token_bought_amount_raw, | ||
t.inAsset as token_sold_address, | ||
t.outAsset as token_bought_address, | ||
t.contract_address AS project_contract_address, | ||
t.evt_tx_hash AS tx_hash, | ||
t.evt_index | ||
FROM {{ source('clipper_' ~ blockchain, src["source"] )}} t | ||
{% if is_incremental() %} | ||
WHERE {{ incremental_predicate('evt_block_time') }} | ||
{% endif %} | ||
{% if not loop.last %} | ||
UNION ALL | ||
{% endif %} | ||
{% endfor %} | ||
) | ||
|
||
SELECT | ||
'{{ blockchain }}' AS blockchain, | ||
'{{ project }}' AS project, | ||
dexs.version, | ||
CAST(date_trunc('month', dexs.block_time) AS date) AS block_month, | ||
CAST(date_trunc('day', dexs.block_time) AS date) AS block_date, | ||
dexs.block_time, | ||
dexs.block_number, | ||
dexs.token_bought_amount_raw, | ||
dexs.token_sold_amount_raw, | ||
dexs.token_bought_address, | ||
dexs.token_sold_address, | ||
dexs.taker, | ||
dexs.maker, | ||
dexs.project_contract_address, | ||
dexs.tx_hash, | ||
dexs.evt_index | ||
FROM dexs | ||
|
||
{% endmacro %} |
This file contains 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
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
models/_sector/dex/trades/arbitrum/platforms/clipper_arbitrum_base_trades.sql
This file contains 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,28 @@ | ||
{{ | ||
config( | ||
schema = 'clipper_arbitrum', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{% | ||
set config_sources = [ | ||
{'version': 'coves1', 'source': 'ClipperCove_evt_CoveSwapped'}, | ||
{'version': 'coves2', 'source': 'ClipperCove_v2_evt_CoveSwapped'}, | ||
{'version': '1', 'source': 'ClipperPackedVerifiedExchange_evt_Swapped'}, | ||
{'version': '2', 'source': 'ClipperPackedVerifiedExchange_v2_evt_Swapped'}, | ||
] | ||
%} | ||
|
||
{{ | ||
clipper_compatible_trades( | ||
blockchain = 'arbitrum', | ||
project = 'clipper', | ||
sources = config_sources | ||
) | ||
}} |
This file contains 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
This file contains 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
This file contains 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
28 changes: 28 additions & 0 deletions
28
models/_sector/dex/trades/ethereum/platforms/clipper_ethereum_base_trades.sql
This file contains 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,28 @@ | ||
{{ | ||
config( | ||
schema = 'clipper_ethereum', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{% | ||
set config_sources = [ | ||
{'version': '1', 'source': 'ClipperExchangeInterface_evt_Swapped'}, | ||
{'version': '2', 'source': 'ClipperCaravelExchange_evt_Swapped'}, | ||
{'version': '3', 'source': 'ClipperVerifiedCaravelExchange_evt_Swapped'}, | ||
{'version': '4', 'source': 'ClipperApproximateCaravelExchange_evt_Swapped'}, | ||
] | ||
%} | ||
|
||
{{ | ||
clipper_compatible_trades( | ||
blockchain = 'ethereum', | ||
project = 'clipper', | ||
sources = config_sources | ||
) | ||
}} |
This file contains 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
This file contains 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
This file contains 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
27 changes: 27 additions & 0 deletions
27
models/_sector/dex/trades/optimism/platforms/clipper_optimism_base_trades.sql
This file contains 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,27 @@ | ||
{{ | ||
config( | ||
schema = 'clipper_optimism', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{% | ||
set config_sources = [ | ||
{'version': 'coves1', 'source': 'ClipperCove_evt_CoveSwapped'}, | ||
{'version': '1', 'source': 'ClipperPackedExchange_evt_Swapped'}, | ||
{'version': '2', 'source': 'ClipperPackedVerifiedExchange_evt_Swapped'}, | ||
] | ||
%} | ||
|
||
{{ | ||
clipper_compatible_trades( | ||
blockchain = 'optimism', | ||
project = 'clipper', | ||
sources = config_sources | ||
) | ||
}} |
This file contains 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
This file contains 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
This file contains 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
27 changes: 27 additions & 0 deletions
27
models/_sector/dex/trades/polygon/platforms/clipper_polygon_base_trades.sql
This file contains 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,27 @@ | ||
{{ | ||
config( | ||
schema = 'clipper_polygon', | ||
alias = 'base_trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
{% | ||
set config_sources = [ | ||
{'version': 'coves1', 'source': 'ClipperCove_evt_CoveSwapped'}, | ||
{'version': '1', 'source': 'ClipperDirectExchange_evt_Swapped'}, | ||
{'version': '2', 'source': 'ClipperVerifiedExchange_evt_Swapped'}, | ||
] | ||
%} | ||
|
||
{{ | ||
clipper_compatible_trades( | ||
blockchain = 'polygon', | ||
project = 'clipper', | ||
sources = config_sources | ||
) | ||
}} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.