Query editor
/*MIT LicenseCopyright (c) 2025 Berry_BearPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in allcopies or substantial portions of the Software.Follow me on X: https://x.com/DeFi_Berry_Bear*/WITH staked AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value / 1e18) AS staked_amountFROMerc20_mantle.evt_transferWHERE"to" = 0xb3938E6ee233E7847a5F17bb843E9bD0Aa07e116AND evt_block_time >= CURRENT_DATE - INTERVAL '90' DAYGROUP BY1),unstaked AS (SELECTDATE_TRUNC('day', evt_block_time) AS day,SUM(value / 1e18) * -1 AS unstaked_amountFROMerc20_mantle.evt_transferWHERE"from" = 0xb3938E6ee233E7847a5F17bb843E9bD0Aa07e116AND evt_block_time >= CURRENT_DATE - INTERVAL '90' DAYGROUP BY1)SELECTCOALESCE(staked.day, unstaked.day) AS day,COALESCE(staked.staked_amount, 0) AS staked_amount,COALESCE(unstaked.unstaked_amount, 0) AS unstaked_amount,SUM(COALESCE(staked.staked_amount, 0)+ COALESCE(unstaked.unstaked_amount, 0)) OVER (ORDER BY COALESCE(staked.day, unstaked.day)) AS cumulative_balanceFROMstakedFULL OUTER JOINunstakedONstaked.day = unstaked.dayORDER BYday;