Query editor
with incoming as (select sum(value) / 1e18 as value, "to" as accountfrom erc20_arbitrum.evt_Transferwhere "from" = 0x0000000000000000000000000000000000000000and contract_address = 0x494203AA41AC067bEb684912ad546d113925a13Bgroup by 2), outgoing as (select sum(value) / 1e18 as value, "from" as accountfrom erc20_arbitrum.evt_Transferwhere "to" = 0x0000000000000000000000000000000000000000and contract_address = 0x494203AA41AC067bEb684912ad546d113925a13Bgroup by 2), total as (selectincoming.account,(incoming.value - coalesce(outgoing.value, 0)) as balancefromincomingleft joinoutgoing on (incoming.account = outgoing.account)), incoming_arx as (select sum(value) / 1e18 * 0.99 as valuefrom erc20_arbitrum.evt_Transferwhere "from" = 0x5BFB6A5c42cc12fde7F846d133bdE8E58DB8aa24and "to" = 0x907E5d334F27a769EF779358089fE5fdAA6cf2Bband contract_address = 0xD5954c3084a1cCd70B4dA011E67760B8e78aeE84), outgoing_arx as (select sum(value) / 1e18 as valuefrom erc20_arbitrum.evt_Transferwhere "from" = 0x907E5d334F27a769EF779358089fE5fdAA6cf2Bband "to" = 0x5BFB6A5c42cc12fde7F846d133bdE8E58DB8aa24and contract_address = 0xD5954c3084a1cCd70B4dA011E67760B8e78aeE84), total_arx as (select (coalesce(incoming_arx.value, 0) - coalesce(outgoing_arx.value, 0)) as totalfrom incoming_arx cross join outgoing_arx), ac_total as (select sum(balance) as balance from total)-- Adding total staked amount as the first rowselect 0x0000000000000000000000000000000000000000 as account, sum(balance) as balance, 100 as ratio, total_arx.total as arx from total cross join total_arxwherebalance > 0group by total_arx.totalUNION ALL-- Individual balancesselect total.account, total.balance, (total.balance / ac_total.balance * 100) as ratio, (total.balance / ac_total.balance) * total_arx.total as arx from total cross join ac_total cross join total_arxwheretotal.balance > 0order by balance desc;