Query editor
withK (contract,protocol) as (values(0x0000000000000000000000000000000000000000 , 'mint'),(0xD166337499E176bbC38a1FBd113Ab144e5bd2Df7 , 'sUSDat'),(0x7a7dE491e1BE5287874904e2b7c8488249A4D0a9 , 'Pendle'),(0xF4d0CF32908b2C7f1021339c43Df0F77f06896d7 , 'Curve'),(0xbbbbbbbbbb9cc5e90e3b3af64bdaf62c37eeffcb , 'Morpho'),(0xa0de671eb84de9dee1d311d996d25c41f63a0d86 , 'BNB Chain')),L (ua,symbol,contract,deci,name,price) as (values('1. USDat','Underlying', 0x23238f20b894f29041f48d88ee91131c395aaa71, 1e6 , 'USDat', 1),('1. USDat','Curve LP', 0xf4d0cf32908b2c7f1021339c43df0f77f06896d7, 1e18 , 'Curve LP-USDat', 1),('1. USDat','Pendle PT', 0x1d69402390657308c91179aa184bf992908c1e08, 1e6 , 'PT-USDat', 1),('1. USDat','Pendle YT', 0x076a3ea71e83ca09319b161e40f5fb3bb943d3c6, 1e6 , 'YT-USDat', 0.0125),('1. USDat','Pendle LP', 0x9afe7a057a09cf5da748d952078c9c99938b4329, 1e18 , 'LP-USDat', 2.15e12),('2. sUSDat','Underlying', 0xd166337499e176bbc38a1fbd113ab144e5bd2df7, 1e18 , 'sUSDat', 1),('2. sUSDat','Curve LP', 0x6206ca315c2fcdd2a857b47efb285aa12c529a7a, 1e18 , 'Curve LP-sUSDat', 1),('2. sUSDat','Pendle PT', 0xc689f76f90fe1762fac55983ff25ae71033a84f7, 1e6 , 'PT-sUSDat', 1),('2. sUSDat','Pendle YT', 0x7956bb9504b8a1f515f2890e309cee398198d3bd, 1e6 , 'YT-sUSDat', 0.0175),('2. sUSDat','Pendle LP', 0x91bc86899c8391b6caaf26535b9cd82efe49a189, 1e18 , 'LP-sUSDat', 2.15e6),('3. srUSDat','Underlying', 0xfaa9a0e1db9e22ae3a20b2b58a68dc24d053d066, 1e18 , 'srUSDat', 1),('3. srUSDat','Pendle PT', 0x2d433b943fb8c015ae409444b7f960ed288082b4, 1e6 , 'PT-srUSDat', 1),('3. srUSDat','Pendle YT', 0xe4ef2a128226bf026493ef40a189865acd1f0cd8, 1e6 , 'YT-srUSDat', 0.0194),('3. srUSDat','Pendle LP', 0x4237a8acbd0b5a2dec4aa83b1fd83f20162d02b8, 1e18 , 'LP-srUSDat', 2.15e6),('4. jrUSDat','Underlying', 0x011e55d2b28306458e37ca7e997c879bb25a455d, 1e18 , 'jrUSDat', 1),('4. jrUSDat','Pendle PT', 0x906ac88054b40eaf5eabac0a92f83022f52c0032, 1e6 , 'PT-jrUSDat', 1),('4. jrUSDat','Pendle YT', 0xee7280386b4d829b7b44cc85d559917f69dd9075, 1e6 , 'YT-jrUSDat', 0.0285),('4. jrUSDat','Pendle LP', 0x8cef2919a8cb98ad74e1e12392bc9f9fc4e3270a, 1e18 , 'LP-jrUSDat', 2.15e6)),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_ethereum.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_ethereum.evt_transfer ),A as(select evt_block_time as time, ua, symbol, pool as userfrom X as ajoin L as b on a.contract_address = b.contract ),B as(select 'Pendle' as tag, date_trunc('week',time) as time, count(distinct user) as user from A where symbol like '%Pendle%' group by 1,2union all select 'Curve' as tag, date_trunc('week',time) as time, count(distinct user) as user from A where symbol like '%Curve%' group by 1,2union all select 'Strata' as tag, date_trunc('week',time) as time, count(distinct user) as user from A where ua like '%srUSDat%' or ua like '%jrUSDat%' group by 1,2-- union all select 'Morpho' as tag, * from AM)select time, tag, user as active_userfrom Border by 1 desc, tag