Skip to content

Commit

Permalink
Merge branch 'main' of github.com:duneanalytics/spellbook into fix-pa…
Browse files Browse the repository at this point in the history
…raswap-ethereum-trades
  • Loading branch information
PablloZz committed Aug 23, 2024
2 parents 94a9226 + e321176 commit 53a09a3
Show file tree
Hide file tree
Showing 509 changed files with 19,781 additions and 13,721 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,6 @@ models:
error_after: { count: 24, period: hour }
tables:
- name: traces
loaded_at_field: block_time
```
See links to more docs on dbt below.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ SELECT 'ethereum' AS blockchain
, t.evt_block_number AS block_number
, 'x2y2' AS project
, 1 AS airdrop_number
, t.to AS recipient
, t.receiver AS recipient
, t.contract_address
, t.evt_tx_hash AS tx_hash
, t.value AS amount_raw
, CAST(t.value/POWER(10, 18) AS double) AS amount_original
, CASE WHEN t.evt_block_time >= (SELECT minute FROM early_price) THEN CAST(pu.price*t.value/POWER(10, 18) AS double)
ELSE CAST((SELECT price FROM early_price)*t.value/POWER(10, 18) AS double)
, t.amount AS amount_raw
, CAST(t.amount/POWER(10, 18) AS double) AS amount_original
, CASE WHEN t.evt_block_time >= (SELECT minute FROM early_price) THEN CAST(pu.price*t.amount/POWER(10, 18) AS double)
ELSE CAST((SELECT price FROM early_price)*t.amount/POWER(10, 18) AS double)
END AS amount_usd
, {{xtyt_token_address}} AS token_address
, 'X2Y2' AS token_symbol
, t.evt_index
FROM {{ source('erc20_ethereum', 'evt_transfer') }} t
LEFT JOIN {{ source('prices','usd_forward_fill') }} pu ON pu.blockchain = 'ethereum'
FROM {{ source('x2y2_ethereum', 'X2Y2Drop_evt_Airdrop') }} t
LEFT JOIN {{ source('prices', 'usd_forward_fill') }} pu ON pu.blockchain = 'ethereum'
AND pu.contract_address= {{xtyt_token_address}}
AND pu.minute=date_trunc('minute', t.evt_block_time)
WHERE t.evt_block_time BETWEEN timestamp '2022-02-15' AND timestamp '2022-03-31'
AND t.contract_address = {{xtyt_token_address}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(
alias = 'first_funded_by',
schema = 'addresses_events',
post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "bnb", "ethereum", "fantom", "gnosis", "optimism", "polygon", "celo", "zksync", "zora", "base", "scroll"]\',
post_hook='{{ expose_spells(\'["arbitrum", "avalanche_c", "bnb", "ethereum", "fantom", "gnosis", "optimism", "polygon", "celo", "zksync", "zora", "base", "scroll", "mantle", "blast"]\',
"sector",
"addresses_events",
\'["hildobby", "Henrystats"]\') }}'
Expand All @@ -25,6 +25,8 @@ ref('addresses_events_arbitrum_first_funded_by')
, ref('addresses_events_scroll_first_funded_by')
, ref('addresses_events_zkevm_first_funded_by')
, ref('addresses_events_linea_first_funded_by')
, ref('addresses_events_mantle_first_funded_by')
, ref('addresses_events_blast_first_funded_by')
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
, ('avalanche_c', source('erc1155_avalanche_c', 'evt_transferbatch'))
, ('gnosis', source('erc1155_gnosis', 'evt_transferbatch'))
, ('fantom', source('erc1155_fantom', 'evt_transferbatch'))
, ('optimism', source('erc1155_optimism', 'evt_transferbatch'))
, ('optimism', source('erc1155_optimism', 'evt_TransferBatch'))
, ('arbitrum', source('erc1155_arbitrum', 'evt_transferbatch'))
, ('celo', source('erc1155_celo', 'evt_transferbatch'))
, ('base', source('erc1155_base', 'evt_transferbatch'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
, ('avalanche_c', source('erc1155_avalanche_c', 'evt_transfersingle'))
, ('gnosis', source('erc1155_gnosis', 'evt_transfersingle'))
, ('fantom', source('erc1155_fantom', 'evt_transfersingle'))
, ('optimism', source('erc1155_optimism', 'evt_transfersingle'))
, ('optimism', source('erc1155_optimism', 'evt_TransferSingle'))
, ('arbitrum', source('erc1155_arbitrum', 'evt_transfersingle'))
, ('celo', source('erc1155_celo', 'evt_transfersingle'))
, ('base', source('erc1155_base', 'evt_transfersingle'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
, ('avalanche_c', source('erc721_avalanche_c', 'evt_transfer'))
, ('gnosis', source('erc721_gnosis', 'evt_transfer'))
, ('fantom', source('erc721_fantom', 'evt_transfer'))
, ('optimism', source('erc721_optimism', 'evt_transfer'))
, ('optimism', source('erc721_optimism', 'evt_Transfer'))
, ('arbitrum', source('erc721_arbitrum', 'evt_transfer'))
, ('celo', source('erc721_celo', 'evt_transfer'))
, ('base', source('erc721_base', 'evt_transfer'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SELECT

FROM
{{source('optimism','transactions')}} t
INNER JOIN {{source('erc721_optimism','evt_transfer')}} tfer
INNER JOIN {{source('erc721_optimism','evt_Transfer')}} tfer
ON t.hash = tfer.evt_tx_hash
AND t.block_number = tfer.evt_block_number
AND tfer."from" = 0x0000000000000000000000000000000000000000 --mint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@

{% set balancer_models = [
ref('balancer_v1_ethereum_trades'),
ref('balancer_v2_ethereum_trades')
ref('balancer_v2_ethereum_trades'),
ref('balancer_cowswap_amm_ethereum_trades')
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@


{% set balancer_models = [
ref('balancer_v2_gnosis_trades')
ref('balancer_v2_gnosis_trades'),
ref('balancer_cowswap_amm_gnosis_trades')
] %}

SELECT *
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,31 +87,6 @@ models:
- name: pool_symbol
- name: swap_fee

- name: balancer_cowswap_amm_balances
meta:
blockchain: ethereum, gnosis
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['ethereum', 'gnosis', 'balancer', 'balances']
description: >
ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform.
columns:
- &day
name: day
description: "UTC event block time truncated to the day mark"
tests:
- not_null
- &pool_address
name: pool_address
description: "Balancer CoWSwap AMM pool contract address"
- &token_address
name: token_address
description: "Token contract address"
- &token_balance_raw
name: token_balance_raw
description: "Balance of a token"

- name: labels_balancer_cowswap_amm_pools
meta:
blockchain: ethereum, gnosis
Expand Down Expand Up @@ -149,36 +124,4 @@ models:
description: "Name of the label model sourced from"
- &label_type
name: label_type
description: "Type of label (see labels overall readme)"

- name: balancer_cowswap_amm_liquidity
meta:
blockchain: ethereum, gnosis
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['ethereum', 'gnosis', 'balancer', 'pools', 'liquidity']
description: >
Balancer CoWSwap AMM pools liquidity by token in Ethereum.
columns:
- *day
- name: pool_id
- *pool_address
- name: pool_symbol
- *version
- *blockchain
- name: pool_type
- *token_address
- &token_symbol
name: token_symbol
description: "Token symbol"
- *token_balance_raw
- &token_balance
name: token_balance
description: "Balance of the token in the pool"
- &protocol_liquidity_usd
name: protocol_liquidity_usd
description: "Protocol liquidity in USD"
- &protocol_liquidity_eth
name: protocol_liquidity_eth
description: "Protocol liquidity in ETH"
description: "Type of label (see labels overall readme)"
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ FROM (
, taker
, maker
, project_contract_address
, pool_id
, tx_hash
, tx_from
, tx_to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,6 @@ models:
- name: pool_symbol
- name: swap_fee

- name: balancer_cowswap_amm_ethereum_balances
meta:
blockchain: ethereum
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['ethereum', 'balancer', 'balances']
description: >
ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- day
- pool_address
- token_address
columns:
- &day
name: day
description: "UTC event block time truncated to the day mark"
tests:
- not_null
- &pool_address
name: pool_address
description: "Balancer CoWSwap AMM pool contract address"
- &token_address
name: token_address
description: "Token contract address"
- &token_balance_raw
name: token_balance_raw
description: "Balance of a token"

- name: labels_balancer_cowswap_amm_pools_ethereum
meta:
blockchain: ethereum
Expand Down Expand Up @@ -165,42 +134,4 @@ models:
description: "Name of the label model sourced from"
- &label_type
name: label_type
description: "Type of label (see labels overall readme)"

- name: balancer_cowswap_amm_ethereum_liquidity
meta:
blockchain: ethereum
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['ethereum', 'balancer', 'pools', 'liquidity']
description: >
Balancer CoWSwap AMM pools liquidity by token in Ethereum.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- day
- pool_id
- token_address
columns:
- *day
- name: pool_id
- *pool_address
- name: pool_symbol
- *version
- *blockchain
- name: pool_type
- *token_address
- &token_symbol
name: token_symbol
description: "Token symbol"
- *token_balance_raw
- &token_balance
name: token_balance
description: "Balance of the token in the pool"
- &protocol_liquidity_usd
name: protocol_liquidity_usd
description: "Protocol liquidity in USD"
- &protocol_liquidity_eth
name: protocol_liquidity_eth
description: "Protocol liquidity in ETH"
description: "Type of label (see labels overall readme)"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

SELECT
'{{blockchain}}' AS blockchain
, 'balancer_cowswap_amm' AS project
, 'balancer' AS project
, '1' AS version
, CAST(date_trunc('month', trade.evt_block_time) AS DATE) AS block_month
, CAST(date_trunc('day', trade.evt_block_time) AS DATE) AS block_date
Expand All @@ -34,6 +34,7 @@
,trade.sellToken AS token_sold_address
,CAST(NULL AS VARBINARY) AS taker
,CAST(NULL AS VARBINARY) AS maker
, pool.bPool AS pool_id
, pool.bPool AS project_contract_address
, trade.evt_tx_hash AS tx_hash
, settlement.solver AS tx_from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,37 +92,6 @@ models:
- name: pool_symbol
- name: swap_fee

- name: balancer_cowswap_amm_gnosis_balances
meta:
blockchain: gnosis
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['gnosis', 'balancer', 'balances']
description: >
ERC20 token rolling sum balances on Balancer, an automated portfolio manager and trading platform.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- day
- pool_address
- token_address
columns:
- &day
name: day
description: "UTC event block time truncated to the day mark"
tests:
- not_null
- &pool_address
name: pool_address
description: "Balancer CoWSwap AMM pool contract address"
- &token_address
name: token_address
description: "Token contract address"
- &token_balance_raw
name: token_balance_raw
description: "Balance of a token"

- name: labels_balancer_cowswap_amm_pools_gnosis
meta:
blockchain: gnosis
Expand Down Expand Up @@ -165,42 +134,4 @@ models:
description: "Name of the label model sourced from"
- &label_type
name: label_type
description: "Type of label (see labels overall readme)"

- name: balancer_cowswap_amm_gnosis_liquidity
meta:
blockchain: gnosis
project: balancer_cowswap_amm
contributors: viniabussafi
config:
tags: ['gnosis', 'balancer', 'pools', 'liquidity']
description: >
Balancer CoWSwap AMM pools liquidity by token in gnosis.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- day
- pool_id
- token_address
columns:
- *day
- name: pool_id
- *pool_address
- name: pool_symbol
- *version
- *blockchain
- name: pool_type
- *token_address
- &token_symbol
name: token_symbol
description: "Token symbol"
- *token_balance_raw
- &token_balance
name: token_balance
description: "Balance of the token in the pool"
- &protocol_liquidity_usd
name: protocol_liquidity_usd
description: "Protocol liquidity in USD"
- &protocol_liquidity_eth
name: protocol_liquidity_eth
description: "Protocol liquidity in ETH"
description: "Type of label (see labels overall readme)"
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

SELECT
'{{blockchain}}' AS blockchain
, 'balancer_cowswap_amm' AS project
, 'balancer' AS project
, '1' AS version
, CAST(date_trunc('month', trade.evt_block_time) AS DATE) AS block_month
, CAST(date_trunc('day', trade.evt_block_time) AS DATE) AS block_date
Expand All @@ -35,6 +35,7 @@
,CAST(NULL AS VARBINARY) AS taker
,CAST(NULL AS VARBINARY) AS maker
, pool.bPool AS project_contract_address
, pool.bPool AS pool_id
, trade.evt_tx_hash AS tx_hash
, settlement.solver AS tx_from
, trade.contract_address AS tx_to
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{config(
schema = 'labels',
alias = 'balancer_cowswap_amm_pool',
alias = 'balancer_cowswap_amm_pools',
materialized = 'view'
)
}}
Expand Down
Loading

0 comments on commit 53a09a3

Please sign in to comment.