Skip to content
Dune Analytics

@ashachaf / Fork of (#7516) Bancor v2 APR (w)

Fork of (#7516) Bancor v2 APR (w)

Loading
 

About queries and results

Dune Analytics lets you explore, create, and share Ethereum analytics. You can find an endless amount of great queries and dashboards on Dune.

We have decoded Ethereum smart contract data so you can do powerful analysis with simple SQL queries and visualise the query results into beautiful graphs.

Dune Analytics is free for everyone forever. If you want extra features like private queries, export your results and more check out our Pro plan.

SQL query results

Loading
 

SQL query

1with token_rate_update as (
2    select "_token1" as pool_token, 
3          "_token2" as reserve_token, 
4          "_rateN" as staked_balance,
5          "_rateD" as pool_token_supply,
6          rate.contract_address,
7          rate.evt_index as index,
8          rate.evt_block_time as block_time,
9          date_trunc('week', rate.evt_block_time) as time_period,
10          rate.evt_block_number as block_number 
11    from bancornetwork."TokenRateUpdate_evt_TokenRateUpdate" rate
12    left join bancornetwork."Activation_evt_Activation" activation
13        on rate.contract_address = activation.contract_address
14    where activation."_type" = 2
15        and "_token1" not in (select contract_address from erc20.tokens)
16),
17-- calculate price
18tru as (
19    select *,
20           (staked_balance / 10 ^ t.decimals ) / (pool_token_supply / 10 ^ 18) as price
21    from token_rate_update s
22    left join erc20.tokens t 
23        on s.reserve_token = t.contract_address
24),
25tru_rn as (...