vendetta02 BENQI - Reay copy
    Updated 2024-09-01
    with benqi_tokens as
    (select
    address,
    case
    when address = '0x7ee65fdc1c534a6b4f9ea2cc3ca9ac8d6c602abd' then 'veQI'
    when address = '0x872670ccae8c19557cc9443eff587d7086b8043a' then 'bUSD'
    when address = '0x5c0401e81bc07ca70fad469b451682c0d747ef1c' then 'AVAX'
    when address = '0xf362fea9659cf036792c9cb02f8ff8198e21b4cb' then 'sAVAX'
    when address = '0x35bd6aeda81a7e5fc7a7832490e71f757b0cd9ce' then 'QI'
    when address = '0x89a415b3d20098e6a6c8f7a59001c67bd3129821' then 'BTC.b'
    when address = '0xe194c4c5ac32a3c9ffdb358d9bfd523a0b6d1568' then 'WBTC.e'
    when address = '0x334ad834cd4481bb02d09615e7c11a00579a7909' then 'WETH.e'
    when address = '0x4e9f683a27a6bdad3fc2764003759277e93696e6' then 'Link.e'
    when address = '0xd8fcda6ec4bdc547c0827b8804e89acd817d56ef' then 'USDt'
    when address = '0xc9e5999b8e75c3feb117f6f73e664b9f3c8ca65c' then 'USDT.e'
    when address = '0xb715808a78f6041e46d61cb123c9b4a27056ae9c' then 'USDC'
    when address = '0xbeb5d47a3f720ec0a390d04b4d41ed7d9688bc7f' then 'USDC.e'
    when address = '0x835866d37afb8cb8f8334dccdaf66cf01832ff5d' then 'DAI.e'
    end as token,
    case when token in ('AVAX', 'sAVAX', 'QI', 'WETH.e', 'Link.e', 'DAI.e' , 'veQI') then 18
    when token in ('BTC.b', 'WBTC.e','bUSD') then 8
    when token in ('USDt', 'USDT.e', 'USDC', 'USDC.e') then 6
    end as decimals
    from avalanche.core.dim_labels
    where project_name = 'benqi finance'
    and LABEL_SUBTYPE = 'token_contract'
    )
    ,
    logs as
    (select l.*,token,decimals from
    avalanche.core.ez_decoded_event_logs l inner join benqi_tokens t on t.address=l.contract_address
    where block_timestamp::date <current_date
    and tx_status = 'SUCCESS'
    and contract_address = origin_to_address
    and event_name in ('Mint', 'Borrow', 'RepayBorrow', 'Redeem')
    and token not in ('veQI', 'bUSD')
    Last run: about 2 months ago
    Timestamp
    Token
    Transactions
    Active Wallets
    Volume
    Cum volume
    1
    2023-01-01 00:00:00.000AVAX635150376692.843430401376692.843430401
    2
    2023-01-01 00:00:00.000Link.e127197.608553849197.608553849
    3
    2023-01-01 00:00:00.000USDC.e70306161306.5523136161306.552313
    4
    2023-01-01 00:00:00.000sAVAX10451227473.93315072227473.93315072
    5
    2023-01-01 00:00:00.000USDC5711816851967.2702496851967.270249
    6
    2023-01-01 00:00:00.000DAI.e78303068204.6689863068204.668986
    7
    2023-01-01 00:00:00.000USDT.e76311288422.4355621288422.435562
    8
    2023-01-01 00:00:00.000WBTC.e4720149.34834631149.34834631
    9
    2023-01-01 00:00:00.000WETH.e5125772.445279348772.445279348
    10
    2023-01-01 00:00:00.000USDt165763903327.3212893903327.321289
    11
    2023-01-01 00:00:00.000BTC.b26120.875231490.87523149
    12
    2023-02-01 00:00:00.000WBTC.e7611586.1213331735.46967941
    13
    2023-02-01 00:00:00.000Link.e44181.028967876378.637521725
    14
    2023-02-01 00:00:00.000sAVAX1194938161.080067293265635.013218013
    15
    2023-02-01 00:00:00.000USDt2428117693278.56467721596605.885966
    16
    2023-02-01 00:00:00.000BTC.b481542.0669497142.9421812
    17
    2023-02-01 00:00:00.000AVAX627128239766.136450971616458.979881372
    18
    2023-02-01 00:00:00.000WETH.e1062612326.19146191113098.636741259
    19
    2023-02-01 00:00:00.000USDC.e68284258968.53226110420275.084574
    20
    2023-02-01 00:00:00.000USDT.e1172215505513.14637416793935.581936
    ...
    278
    20KB
    25s