neo_nguyenPendle other (bsc)
    Updated 2025-02-02
    with

    pendle_oracle as( select * from $query('d218c554-fd11-4566-9aa6-547351b9a6f6') ),

    pendle_data as(
    select to_address as pool, case when amount is null then raw_amount/1e18 else amount end amount, contract_address, block_timestamp from bsc.core.ez_token_transfers union all
    select from_address as pool, case when amount is null then 0-raw_amount/1e18 else 0-amount end amount, contract_address, block_timestamp from bsc.core.ez_token_transfers
    ),

    pendle_other as(
    select chain, protocol, symbol, mk, asset, price,
    sum(case when tb1.contract_address = tb2.sy and tb1.pool = tb2.mk then amount end) sy_liquid,
    sum(case when tb1.contract_address = tb2.pt and tb1.pool = tb2.mk then amount end) pt_liquid,
    sum(case when tb1.contract_address = tb2.pt and tb1.pool = '0x0000000000000000000000000000000000000000' then 0-amount end) pt_supply
    from pendle_data tb1
    join pendle_oracle tb2 on (tb1.pool = tb2.mk or tb1.pool = '0x0000000000000000000000000000000000000000') and (tb1.contract_address = tb2.sy or tb1.contract_address = tb2.pt)
    where chain = 'Bsc'
    group by 1,2,3,4,5,6)

    select chain, 'other' category, protocol, symbol, (sy_liquid+pt_liquid) liquid, (sy_liquid+pt_supply) tvl, liquid*price liquidity_usd, tvl*price tvl_usd, mk
    from pendle_other
    order by tvl_usd desc




    Auto-refreshes every 24 hours
    QueryRunArchived: QueryRun has been archived