Skip to content

Commit

Permalink
update enrich_balancer_v3_dex_trades (#7489)
Browse files Browse the repository at this point in the history
* update enrich_balancer_v3_dex_trades

* fix group by

* fix

* fix dataype

* improvements after testing

---------

Co-authored-by: Huang Geyang <[email protected]>
  • Loading branch information
viniabussafi and Hosuke authored Jan 22, 2025
1 parent b0d7614 commit 83370f8
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ WITH base_trades as (
minute,
blockchain,
wrapped_token,
underlying_token,
underlying_token_symbol,
decimals,
APPROX_PERCENTILE(median_price, 0.5) AS price,
LEAD(minute, 1, NOW()) OVER (PARTITION BY wrapped_token ORDER BY minute) AS time_of_next_change
FROM {{ source('balancer_v3', 'erc4626_token_prices') }}
GROUP BY 1, 2, 3, 4
GROUP BY 1, 2, 3, 4, 5, 6
)

SELECT
Expand All @@ -85,9 +87,12 @@ SELECT
, block_date
, block_time
, block_number
, token_bought_symbol
, token_sold_symbol
, token_pair
, COALESCE(erc4626a.underlying_token_symbol,
token_bought_symbol) AS token_bought_symbol
, COALESCE(erc4626b.underlying_token_symbol,
token_sold_symbol) AS token_sold_symbol
, CONCAT(COALESCE(erc4626a.underlying_token_symbol, token_bought_symbol), '-',
COALESCE(erc4626b.underlying_token_symbol, token_sold_symbol)) AS token_pair
, token_bought_amount
, token_sold_amount
, token_bought_amount_raw
Expand All @@ -97,8 +102,10 @@ SELECT
dexs.token_bought_amount * erc4626a.price,
dexs.token_sold_amount * erc4626a.price
) AS amount_usd
, token_bought_address
, token_sold_address
, COALESCE(erc4626a.underlying_token,
token_bought_address) AS token_bought_address
, COALESCE(erc4626b.underlying_token,
token_sold_address) AS token_sold_address
, taker
, maker
, project_contract_address
Expand Down

0 comments on commit 83370f8

Please sign in to comment.