Skip to content

Commit

Permalink
Merge branch 'duneanalytics:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpartida authored Sep 20, 2024
2 parents e5c90a1 + 14d8eef commit d1e5f14
Show file tree
Hide file tree
Showing 23 changed files with 67 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ factories as (
, substr(input, 4 + 32*4 + 12 + 1, 20) as token
, bytearray_to_uint256(substr(input, 4 + 32*5 + 1, 32)) as amount
, bytearray_to_uint256(substr(input, 4 + 32*6 + 1, 32)) as safety_deposit
, substr(input, 4 + 32*7 + 12 + 1, 32) as timelocks
, substr(input, 4 + 32*7 + 1, 32) as timelocks
, success as call_success
from {{ source(blockchain, 'traces') }}
where
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
'tx_hash',
'call_trace_address',
'dst_blockchain',
'hashlock',
]
%}

Expand Down Expand Up @@ -52,7 +53,6 @@ meta as (
, block_time as result_block_time
, tx_hash as result_tx_hash
, call_trace_address as result_trace_address
, cast(null as varbinary) as hashlock
, cast(null as varbinary) as result_escrow
, null as result_method
, null as result_amount
Expand All @@ -71,11 +71,10 @@ meta as (
, result_block_time
, result_tx_hash
, result_trace_address
, hashlock
, result_escrow
, result_method
, result_amount
from ({{ oneinch_calls_macro(blockchain) }})
from (select * from ({{ oneinch_calls_macro(blockchain) }}) where hashlock is not null)
join results using(hashlock) -- escrow results only
where
tx_success
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
10 changes: 9 additions & 1 deletion dbt_subprojects/dex/models/_projects/oneinch/oneinch_swaps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,21 @@ tokens as (
, contract_address
, minute
, price
, decimals
, symbol
from {{ source('prices', 'usd') }}
{% if is_incremental() %}
where {{ incremental_predicate('minute') }}
{% endif %}
)

, decimals_cte as (
select
blockchain as transfer_blockchain
, contract_address
, decimals
from {{ source('tokens', 'erc20') }}
)

, calls as (
select
*
Expand Down Expand Up @@ -206,6 +213,7 @@ tokens as (
{% endif %}
) using(blockchain, block_number, tx_hash, call_trace_address) -- block_number is needed for performance
left join prices using(transfer_blockchain, contract_address, minute)
left join decimals_cte using(transfer_blockchain, contract_address)
left join tokens using(transfer_blockchain, contract_address)
group by 1, 2, 3, 4, 5
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
incremental_strategy = 'merge',
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')],
unique_key = ['tx_hash', 'call_trace_address', 'transfer_blockchain', 'transfer_tx_hash', 'transfer_trace_address', 'transfer_native'],
pre_hook='{{ enforce_join_distribution("PARTITIONED") }}'
)
}}

Expand Down
12 changes: 1 addition & 11 deletions dbt_subprojects/tokens/models/prices/_schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,4 @@ models:
contributors: hosuke, jeff-dude
config:
tags: [ 'prices', 'stability' ]
description: "List of trusted tokens across blockchains"
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- blockchain
- contract_address
columns:
- *blockchain
- *contract_address
- *symbol
- *decimals
description: "List of trusted tokens across blockchains"
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,6 @@ FROM
('tap-taptoken', 'arbitrum', 'TAP', 0x2c650dab03a59332e2e0c0c4a7f726913e5028c1, 18),
('shibai-aishiba', 'arbitrum', 'SHIBAI', 0xfa296fca3c7dba4a92a42ec0b5e2138da3b29050, 6),
('usdm-mountain-protocol-usd', 'arbitrum', 'USDM', 0x59d9356e565ab3a36dd77763fc0d87feaf85508c, 18),
('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18)
('usdz-anzen-usdz', 'arbitrum', 'USDZ', 0x5018609ab477cc502e170a5accf5312b86a4b94f, 18),
('trb-tellor', 'arbitrum', 'TRB', 0xd58d345fd9c82262e087d2d0607624b410d88242, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
Original file line number Diff line number Diff line change
Expand Up @@ -167,5 +167,6 @@ FROM
('albert-albert-the-alien','base','ALBERT',0x0c067fc190cde145b0c537765a78d4e19873a5cc, 18),
('tn100x-tn100x','base','TN100X',0x5b5dee44552546ecea05edea01dcd7be7aa6144a, 18),
('rdat-rdatadao','base','RDAT',0x4498cd8ba045e00673402353f5a4347562707e7d, 18),
('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18)
('usdz-anzen-usdz', 'base', 'USDZ',0x04d5ddf5f3a8939889f11e97f8c4bb48317f1938, 18),
('moxie-moxie', 'base', 'MOXIE',0x8C9037D1Ef5c6D1f6816278C7AAF5491d24CD527, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,9 @@ FROM
('lovely-lovely-inu-finance', 'bnb', 'LOVELY', 0x9e24415d1e549ebc626a13a482bb117a2b43e9cf, 8),
--('pvc-pvc-meta','bnb','PVC',0x75ca521892de7f2ecfb070cab545c250d0ceb7e3, 9), --token_id not found
('bvsd-bvsd','bnb','BVSD',0x7f9ad7a5854658d984924e868187b2135514fb88, 18),
('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18)
('coco-coco-coin', 'bnb', 'COCO', 0xf563e86e461de100cfcfd8b65daa542d3d4b0550, 18),
('zeta-zetachain', 'bnb', 'ZETA', 0x0000028a2eb8346cd5c0267856ab7594b7a55308, 18),
('euri-eurite', 'bnb', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
where contract_address not in (
0x2ab0e9e4ee70fff1fb9d67031e44f6410170d00e -- bXEN has bad price feed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1837,7 +1837,11 @@ FROM
('synt-synternet','ethereum','SYNT',0xda987c655ebc38c801db64a8608bc1aa56cd9a31, 18),
('babydoge-baby-doge-coin', 'ethereum', 'BABYDOGE', 0xac57de9c1a09fec648e93eb98875b212db0d460b, 9),
('usdz-anzen-usdz', 'ethereum', 'USDZ', 0xa469b7ee9ee773642b3e93e842e5d9b5baa10067, 18),
('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8)
('lbtc-lombard-staked-btc', 'ethereum', 'LBTC', 0x8236a87084f8b84306f72007f36f2618a5634494, 8),
('msn-mesonnetwork', 'ethereum', 'MSN', 0xaa247c0d81b83812e1abf8bab078e4540d87e3fb, 18),
('bubble-imaginary-ones', 'ethereum', 'BUBBLE', 0xe9689028ede16c2fdfe3d11855d28f8e3fc452a3, 18),
('zeta-zetachain', 'ethereum', 'ZETA', 0xf091867ec603a6628ed83d274e835539d82e9cc8, 18),
('euri-eurite', 'ethereum', 'EURI', 0x9d1a7a3191102e9f900faa10540837ba84dcbae7, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
where contract_address not in (
-- bad price feeds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,6 @@ FROM
('rseth-rseth', 'rsETH', 0x4186bfc76e2e237523cbc30fd220fe055156b41f, 18),
('dola-dola', 'DOLA',0x8ae125e8653821e851f12a49f7765db9a9ce7384, 18),
('wld-worldcoin', 'WLD',0xdc6ff44d5d932cbd77b52e5612ba0529dc6226f1, 18),
('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18)
('pendle-pendle', 'PENDLE',0xbc7b1ff1c6989f006a1185318ed4e7b5796e66e1, 18),
('trb-tellor', 'TRB', 0xaf8ca653fa2772d58f4368b0a71980e9e3ceb888, 18)
) as temp (token_id, symbol, contract_address, decimals)
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ FROM
('zro-layerzero', 'polygon', 'ZRO', 0x6985884c4392d348587b19cb9eaaf157f13271cd, 18),
('next-connext-eth', 'polygon', 'NEXT', 0x58b9cb810a68a7f3e1e4f8cb45d1b9b3c79705e8, 18),
('usdm-mountain-protocol-usd', 'polygon', 'USDM', 0x57f5e098cad7a3d1eed53991d4d66c45c9af7812, 18),
('crowd-crowdswap', 'polygon', 'CROWD', 0x483dd3425278c1f79f377f1034d9d2cae55648b6, 18)
('crowd-crowdswap', 'polygon', 'CROWD', 0x483dd3425278c1f79f377f1034d9d2cae55648b6, 18),
('trb-tellor', 'polygon', 'TRB', 0xe3322702bedaaed36cddab233360b939775ae5f1, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
where contract_address not in (
0xef938b6da8576a896f6e0321ef80996f4890f9c4 -- DG, bad price feed
Expand Down
42 changes: 32 additions & 10 deletions dbt_subprojects/tokens/models/prices/prices_trusted_tokens.sql
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,38 @@ WITH trusted_tokens AS (
, ('zksync', 0xbbeb516fb02a01611cbbe0453fe3c580d7281011)
, ('zora', 0x4200000000000000000000000000000000000006)
) AS t (blockchain, contract_address)
), erc20 as (
SELECT
p.token_id
, p.blockchain
, p.contract_address
, p.symbol
, p.decimals
FROM
{{ ref('prices_tokens') }} AS p
INNER JOIN
trusted_tokens AS tt
ON p.blockchain = tt.blockchain
AND p.contract_address = tt.contract_address
), native_tokens AS (
SELECT
p.token_id
, evm.blockchain
, {{ var('ETH_ERC20_ADDRESS') }} as contract_address -- 0x00..00
, p.symbol
, 18 as decimals
FROM
{{ source('evms','info') }} evm
INNER JOIN
{{ ref('prices_native_tokens') }} p
on evm.native_token_symbol = p.symbol
)
SELECT
p.token_id
, p.blockchain
, p.contract_address
, p.symbol
, p.decimals
*
FROM
erc20
UNION ALL
SELECT
*
FROM
{{ ref('prices_tokens') }} AS p
INNER JOIN
trusted_tokens AS tt
ON p.blockchain = tt.blockchain
AND p.contract_address = tt.contract_address
native_tokens
Original file line number Diff line number Diff line change
Expand Up @@ -700,5 +700,6 @@ FROM
('mumu1-mumu-the-bull', 'solana', 'MUMU', '5LafQUrVco6o7KMz42eqVEJ9LW31StPyGjeeu5sKoMtA', 6),
('nub-nubcat','solana', 'NUB', 'GtDZKAqvMZMnti46ZewMiXCa4oXF4bZxwQPoKzXPFxZn', 9),
('bunk-bunkee', 'solana', 'BUNK', '2nhjjqSkA8FYCUdJvQhYjbtZdPjZbNo8VtNKTkJ3hncb', 6),
('maneki-maneki', 'solana', 'MANEKI', '25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ', 5)
('maneki-maneki', 'solana', 'MANEKI', '25hAyBQfoDhfWx9ay6rarbgvWGwDdNqcHsXS3jQ3mTDJ', 5),
('scat-simon39s-baby-cat', 'solana', 'SCAT', '2NNkCSrbQtrc9tgEJHt4MQUH3ySaxTRAAXt9cUgCkycB', 9)
) as temp (token_id, blockchain, symbol, contract_address, decimals)
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ FROM
('kat-karat', 'zksync', 'KAT', 0xCDb7D260c107499C80B4b748e8331c64595972a1, 18),
('zkid-zksync-id', 'zksync', 'ZKID', 0x2141d7fe06A1d69c016fC638bA75b6Ef92Fa1435, 18),
('zk-zksync', 'zksync', 'ZK', 0x5A7d6b2F92C77FAD6CCaBd7EE0624E64907Eaf3E, 18),
('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18)

('weeth-wrapped-eeth', 'zksync', 'weETH', 0xc1fa6e2e8667d9be0ca938a54c7e0285e9df924a, 18),
('koi4-koi', 'zksync', 'KOI4', 0xa995ad25ce5eb76972ab356168f5e1d9257e4d05, 18),
('mvx-metavault-trade', 'zksync', 'MVX', 0xc8ac6191cdc9c7bf846ad6b52aaaa7a0757ee305, 18),
('zf-zkswap-finance', 'zksync', 'ZF', 0x31c2c031fdc9d33e974f327ab0d9883eae06ca4a, 18)
) as temp (token_id, blockchain, symbol, contract_address, decimals)

0 comments on commit d1e5f14

Please sign in to comment.