Query editor
withK (contract,name) as (values(0x0000000000000000000000000000000000000000 , 'mint'),(0x81a77Db87618d51bc12c9EAbe08cC298764B8277 , 'Pendle'),(0x68930887e1318ef30653a4b7942ab07544ebed4d , 'Pendle'),(0xF80Ab3Cc041d8Ccc1c51AcC295AFdba26AD70Aa9 , 'Pancake'),(0xf3396a9a79257D89f98143d8AB73da1dFF4e0e81 , 'Pancake')),L (ua,symbol,contract,deci,name,price) as (values('1. USDat','Underlying', 0x0bb150dfa86ea5d7742f07fefcd8e8eda81d64ef, 1e6 , 'USDat', 1),('1. USDat','Pendle PT', 0x3519f72144daae5ae933fac1bf91f8da57664d24, 1e6 , 'PT-USDat', 1),('1. USDat','Pendle YT', 0xb977399b1e25d5885831af34769ff47f94d391a6, 1e6 , 'YT-USDat', 0.015),('1. USDat','Pendle LP', 0x9757834d0b31aa820b85f68705117691207152d9, 1e18 , 'LP-USDat', 2.15e12),('2. sUSDat','Underlying', 0x9cd57d3685e6868cacaa8bdcaaf52cbdebf4fa25, 1e18 , 'sUSDat', 1),('2. sUSDat','Pendle PT', 0x23f9a497a5d4d54eaf5e03d94774f17dc1219745, 1e6 , 'PT-sUSDat', 1),('2. sUSDat','Pendle YT', 0x11550114dc4c572e6c1eddfbcdbed9480f4847da, 1e6 , 'YT-sUSDat', 0.0175),('2. sUSDat','Pendle LP', 0x1017E73CE9C219164cE841a980136eB023c55387, 1e18 , 'LP-sUSDat', 2e6)),X as(select evt_block_time, "from" as user, "to" as pool, 0+value/1e0 as amount, evt_tx_hash as hash, contract_address from erc20_bnb.evt_transfer union allselect evt_block_time, "to" as user, "from" as pool, 0-value/1e0 as amount, evt_tx_hash as hash, contract_address from erc20_bnb.evt_transfer ),A as(select ua, symbol, pool as user, price, sum(amount/deci) as balancefrom X as ajoin L as b on a.contract_address = b.contractgroup by 1,2,3,4 ),B as(select ua, symbol, user, balance, price*balance as valuefrom Awhere user not in (select contract from K) ),-- naked_assetC as(select count(distinct user) as userfrom ( select user, sum(value) as value,sum(case when symbol = 'Underlying' then value else 0 end) as underlying,sum(case when symbol != 'Underlying' then value else 0 end) as defifrom Bgroup by 1)where defi <= 10 and underlying > 1),-- defiD as(select tag, total_user as user from query_7809606 where rank = 1),E as(select '1. Naked asset' as tag,'USDat / sUSDat' as note, user from Cunion all select '2. Pendle' as tag, 'PT / LP / YT' as note, user from D where tag = 'Pendle'-- union all select '3. Curve' as tag, 'LP position' as note, user from D where tag = 'Curve'-- union all select '4. Strata' as tag, 'sr + jr' as note, user from D where tag = 'Strata'-- union all select '5. Morpho' as tag, 'Collateral' as note, user from D where tag = 'Morpho')select tag, user, note from E