Query editor
with wcc_balance as (selectcoalesce(sum(casewhen "to" = 0x02d63d1339cea5829ccb7342755db4ed57398321 then amountwhen "from" = 0x02d63d1339cea5829ccb7342755db4ed57398321 then -amountelse 0end), 0) as wcc_balancefrom tokens.transferswhere blockchain = 'bnb'and contract_address = 0x6050d829f5a5e0ea758d8357ddcdec1381699248and ("to" = 0x02d63d1339cea5829ccb7342755db4ed57398321or "from" = 0x02d63d1339cea5829ccb7342755db4ed57398321)),usdt_balance as (selectcoalesce(sum(casewhen "to" = 0x02d63d1339cea5829ccb7342755db4ed57398321 then amountwhen "from" = 0x02d63d1339cea5829ccb7342755db4ed57398321 then -amountelse 0end), 0) as usdt_balancefrom tokens.transferswhere blockchain = 'bnb'and contract_address = 0x55d398326f99059ff775485246999027b3197955and ("to" = 0x02d63d1339cea5829ccb7342755db4ed57398321or "from" = 0x02d63d1339cea5829ccb7342755db4ed57398321)),latest_price as (select price_usdtfrom (selectblock_time,casewhen token_bought_address = 0x6050d829f5a5e0ea758d8357ddcdec1381699248and token_sold_address = 0x55d398326f99059ff775485246999027b3197955and cast(token_bought_amount as double) > 0then cast(token_sold_amount as double) / cast(token_bought_amount as double)when token_sold_address = 0x6050d829f5a5e0ea758d8357ddcdec1381699248and token_bought_address = 0x55d398326f99059ff775485246999027b3197955and cast(token_sold_amount as double) > 0then cast(token_bought_amount as double) / cast(token_sold_amount as double)else nullend as price_usdtfrom dex.tradeswhere blockchain = 'bnb'and ((token_bought_address = 0x6050d829f5a5e0ea758d8357ddcdec1381699248and token_sold_address = 0x55d398326f99059ff775485246999027b3197955)or (token_sold_address = 0x6050d829f5a5e0ea758d8357ddcdec1381699248and token_bought_address = 0x55d398326f99059ff775485246999027b3197955))) twhere price_usdt is not null