forked from duneanalytics/spellbook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add Avalanche-C models to Gyroscope (duneanalytics#6804)
* fix typo * add Avalanche-C models to Gyroscope * again * update cross-chain trades model * update contributors
- Loading branch information
1 parent
9484d1b
commit 7f6532b
Showing
7 changed files
with
221 additions
and
6 deletions.
There are no files selected for viewing
94 changes: 94 additions & 0 deletions
94
...subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_schema.yml
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,94 @@ | ||
version: 2 | ||
|
||
models: | ||
|
||
- name: gyroscope_avalanche_c_trades | ||
|
||
meta: | ||
|
||
blockchain: avalanche_c | ||
project: gyroscope | ||
contributors: viniabussafi | ||
|
||
config: | ||
|
||
tags: ["avalanche_c", "gyroscope", "trades"] | ||
|
||
description: trades on gyroscope E-CLP pools on avalanche_c | ||
tests: | ||
- dbt_utils.unique_combination_of_columns: | ||
combination_of_columns: | ||
- block_time | ||
- blockchain | ||
- tx_hash | ||
- evt_index | ||
columns: | ||
- &blockchain | ||
name: blockchain | ||
description: "blockchain name(avalanche_c)" | ||
- &project | ||
name: project | ||
description: "gyroscope as project" | ||
- &block_date | ||
name: block_date | ||
description: "UTC event block date" | ||
- &block_month | ||
name: block_month | ||
description: "UTC event block month" | ||
- &block_time | ||
name: block_time | ||
description: "UTC event block time" | ||
- &token_bought_symbol | ||
name: token_bought_symbol | ||
description: "Token symbol for token bought in the trade" | ||
- &token_sold_symbol | ||
name: token_sold_symbol | ||
description: "Token symbol for token sold in the trade" | ||
- &token_pair | ||
name: token_pair | ||
description: "Token symbol pair for each token involved in the trade" | ||
- &token_bought_amount | ||
name: token_bought_amount | ||
description: "Value of the token bought at time of execution in the original currency" | ||
- &token_sold_amount | ||
name: token_sold_amount | ||
description: "Value of the token sold at time of execution in the original currency" | ||
- &token_bought_amount_raw | ||
name: token_bought_amount_raw | ||
description: "Raw value of the token bought at time of execution in the original currency" | ||
- &token_sold_amount_raw | ||
name: token_sold_amount_raw | ||
description: "Raw value of the token sold at time of execution in the original currency" | ||
- &amount_usd | ||
name: amount_usd | ||
description: "USD value of the trade at time of execution" | ||
- &token_bought_address | ||
name: token_bought_address | ||
description: "Contract address of the token bought" | ||
- &token_sold_address | ||
name: token_sold_address | ||
description: "Contract address of the token sold" | ||
- &taker | ||
name: taker | ||
description: "Address of trader who purchased a token" | ||
- &project_contract_address | ||
name: project_contract_address | ||
description: "Ethereum address for the liquidity pool used in transaction" | ||
- &pool_id | ||
name: pool_id | ||
description: "Unique encoded identifier that refers to each pool" | ||
- &swap_fee | ||
name: swap_fee | ||
description: 'Swap fee' | ||
- &tx_hash | ||
name: tx_hash | ||
description: "Transaction hash" | ||
- &tx_from | ||
name: tx_from | ||
description: "transaction.from" | ||
- &tx_to | ||
name: tx_to | ||
description: "transaction.to" | ||
- &evt_index | ||
name: evt_index | ||
description: "Event index" |
56 changes: 56 additions & 0 deletions
56
...subprojects/daily_spellbook/models/gyroscope/avalanche_c/gyroscope_avalanche_c_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,56 @@ | ||
{{ config( | ||
schema = 'gyroscope_avalanche_c', | ||
alias = 'trades', | ||
materialized = 'incremental', | ||
file_format = 'delta', | ||
incremental_strategy = 'merge', | ||
unique_key = ['block_time', 'blockchain', 'tx_hash', 'evt_index'], | ||
incremental_predicates = [incremental_predicate('DBT_INTERNAL_DEST.block_time')] | ||
) | ||
}} | ||
|
||
with E_CLPs AS ( | ||
SELECT | ||
x.pool | ||
, y.min_block_time | ||
FROM {{ source('gyroscope_avalanche_c','GyroECLPPoolFactory_evt_PoolCreated') }} x | ||
LEFT JOIN ( | ||
SELECT min(evt_block_time) AS min_block_time | ||
FROM {{ source('gyroscope_avalanche_c','GyroECLPPoolFactory_evt_PoolCreated') }} | ||
) y | ||
on x.pool is not null | ||
) | ||
|
||
SELECT | ||
blockchain, | ||
'gyroscope' AS project, | ||
block_date, | ||
block_month, | ||
block_time, | ||
token_bought_symbol, | ||
token_sold_symbol, | ||
token_pair, | ||
token_bought_amount, | ||
token_sold_amount, | ||
token_bought_amount_raw, | ||
token_sold_amount_raw, | ||
amount_usd, | ||
token_bought_address, | ||
token_sold_address, | ||
taker, | ||
maker, | ||
project_contract_address, | ||
pool_id, | ||
swap_fee, | ||
tx_hash, | ||
tx_from, | ||
tx_to, | ||
evt_index | ||
FROM {{ source('balancer_v2_avalanche_c', 'trades') }} x | ||
inner join E_CLPs y | ||
on x.block_time >= y.min_block_time | ||
and x.project_contract_address = y.pool | ||
{% if is_incremental() %} | ||
WHERE | ||
{{incremental_predicate('x.block_time')}} | ||
{% endif %} |
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
23 changes: 23 additions & 0 deletions
23
sources/gyroscope/avalanche_c/gyroscope_avalanche_c_sources.yml
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,23 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: gyroscope_avalanche_c | ||
description: > | ||
Decoded tables related to gyroscope E-CLP pools on avalanche_c. | ||
tables: | ||
- name: GyroECLPPoolFactory_evt_PoolCreated | ||
description: > | ||
Decoded table of gyroscope pool created | ||
columns: | ||
- name: contract_address | ||
description: 'creator address' | ||
- name: evt_tx_hash | ||
description: 'Primary key of the transaction' | ||
- name: evt_index | ||
description: 'Index value of the transaction' | ||
- name: evt_block_time | ||
description: 'Timestamp for block event time in UTC' | ||
- name: evt_block_number | ||
description: 'Block number which processed the unique transaction hash' | ||
- name: pool | ||
description: 'created ECLP pool address' |
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