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 Aug 6, 2024
2 parents dd864c4 + c2a9c31 commit f11a6c6
Show file tree
Hide file tree
Showing 50 changed files with 2,853 additions and 103 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% macro carbon_defi_compatible_trades(
blockchain = null,
project = null,
CarbonController_evt_TokensTraded = null,
wrapped_native_token = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
)
%}

WITH dexs AS (
SELECT
t.evt_block_number AS block_number,
t.evt_block_time AS block_time,
t.trader AS taker,
CAST(NULL as VARBINARY) as maker,
t.targetAmount AS token_bought_amount_raw,
t.sourceAmount AS token_sold_amount_raw,
CASE
WHEN t.targetToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN {{ wrapped_native_token }}
ELSE t.targetToken
END AS token_bought_address, --Using WETH for easier joining with USD price table
CASE
WHEN t.sourceToken = 0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee THEN {{ wrapped_native_token }}
ELSE t.sourceToken
END AS token_sold_address, --Using WETH for easier joining with USD price table
t.contract_address AS project_contract_address,
t.evt_tx_hash AS tx_hash,
t.evt_index
FROM {{ CarbonController_evt_TokensTraded }} t
{% if is_incremental() %}
WHERE {{incremental_predicate('t.evt_block_time')}}
{% endif %}
)

SELECT
'{{ blockchain }}' AS blockchain,
'{{ project }}' AS project,
'1' AS 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 %}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
{% set trade_event_tables = [
source('paraswap_base', 'AugustusSwapper_evt_BoughtV3')
,source('paraswap_base', 'AugustusSwapper_evt_SwappedV3')
,source('paraswap_base', 'AugustusSwapper_evt_SwappedDirect')
] %}

WITH dexs AS (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ AS
)
SELECT a.blockchain
, '0x API' as project
, cast(null as varchar) as version
, cast('1' as varchar) as version

, a.block_date
, a.block_month
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ models:
config:
tags: ['arbitrum','0x','dex_aggregator','dex','aggregator']
description: >
0x API erc20 swaps raw fills (including multihops) and also native swaps thru 0x exchange contracts (without using 0x API) on Ethereum
0x API erc20 swaps raw fills (including multihops) and also native swaps thru 0x exchange contracts (without using 0x API) on arbitrum
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
Expand Down Expand Up @@ -204,4 +204,55 @@ models:
- *matcha_limit_order_flag
- &protocol_fee_paid_eth
name: protocol_fee_paid_eth
description: "The protocol fee paid in ETH"
description: "The protocol fee paid in ETH"

- name: zeroex_arbitrum_settler_trades
meta:
blockchain: arbitrum
project: zeroex
contributors: rantum
config:
tags: ['arbitrum','0x','dex_aggregator','dex','aggregator']
description: >
0x API erc20 trades through 0x Settler contracts. No fills, only deduped transactions.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- block_month
- block_date
- tx_hash
- evt_index
- check_seed:
seed_file: ref('zeroex_arbitrum_settler_trades_sample')
match_columns:
- tx_hash
check_columns:
- taker
- maker_token
- taker_token
columns:
- *blockchain
- *block_date
- *block_month
- *block_time
- *taker_symbol
- *maker_symbol
- *token_pair
- *taker_token_amount
- *maker_token_amount
- *taker_token_amount_raw
- *maker_token_amount_raw
- *volume_usd
- *taker_token
- *maker_token
- *taker
- *maker
- *affiliate_address
- *tx_hash
- *tx_from
- *tx_to
- *evt_index
- *type
- *swap_flag
- *contract_address
- *fills_within
Loading

0 comments on commit f11a6c6

Please sign in to comment.