Query editor
select coalesce(a.address, 0xffffffffffffffffffffffffffffffffffffffff) as address,case when a.address is not null then sum(a.amount - b.amount)else 500000000 - sum(a.amount - b.amount)end as stable_2nd_amount,case when a.address is not null then max(b.tx_hash)else 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffend as tx_hashfrom (select address,sum(amount) as amountfrom (select to as address,value/power(10,6) as amountfrom erc20_ethereum.evt_Transfer awhere contract_address = 0xd9b2cb2fbad204fc548787ef56b918c845fcce40 -- Pre-iUSDTand evt_block_date >= date '2025-10-01'union allselect "from" as address,-value/power(10,6) as amountfrom erc20_ethereum.evt_Transfer awhere contract_address = 0xd9b2cb2fbad204fc548787ef56b918c845fcce40 -- Pre-iUSDTand evt_block_date >= date '2025-10-01') awhere address != 0x0000000000000000000000000000000000000000group by 1) aleft join (select to as address,sum(value/power(10,6)) as amount,min_by(evt_tx_hash, evt_block_time) as tx_hashfrom erc20_ethereum.evt_Transfer awhere contract_address = 0xfb48aAf5c2D5F1722C6A7910115811e7C094C9B3 -- I dont knowand "from" = 0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae -- Angle Protocol: Distributorand evt_block_date >= date '2025-10-01'group by 1) b on b.address = a.addresswhere b.amount > 0group by rollup(a.address)order by 2 desc