Query editor
-- Multi-chain daily cumulative supply for TwinFinance tokens (Base + Arbitrum + Polygon)-- token_map keys on (blockchain, contract_address) because the same hex address can be-- a different token on different chains (e.g. 0x59863989... = MEXt on Base, ARGt on Arbitrum, BRAt on Polygon).WITH token_map AS (SELECT 'base' AS blockchain, 0xf016413834e6d1a14f3d628b11d6ef725a6bdbdd AS contract_address, 'ARGt' AS symbol UNION ALLSELECT 'base', 0x1d2e8c1fe82ab2ad8dc43ed98a2f507dfb5b4995, 'BOLt' UNION ALLSELECT 'base', 0xfee29845569570f8e0119291dff77b7b93283aab, 'BRAt' UNION ALLSELECT 'base', 0x95ef2370166b250e7ce3b8f236c7e7e9fed12c2e, 'CHLt' UNION ALLSELECT 'base', 0xd70ad085684b2a9f4b5d54d7bdb2eca37a273216, 'COLt' UNION ALLSELECT 'base', 0x59863989d080b22476db95656d0c3cc18be92214, 'MEXt' UNION ALLSELECT 'base', 0xd09aba2969b822d66dc4bc3bb58ee520bcf9f0c3, 'PERt' UNION ALLSELECT 'base', 0x9d5855c52e2c3d07dc5120789f484e6d1d32a985, 'PRYt' UNION ALLSELECT 'base', 0xc5f7edbedb4c61bc351dbb69d12077af491270cb, 'URYt' UNION ALLSELECT 'base', 0xa1685112cb61210ab2a929c9ce370a4fd381d8be, 'VENt' UNION ALLSELECT 'arbitrum', 0x59863989d080b22476db95656d0c3cc18be92214, 'ARGt' UNION ALLSELECT 'arbitrum', 0x1edf5e61b6a4fe19fef3a695328f61aaa07728ea, 'BOLt' UNION ALLSELECT 'arbitrum', 0xc4ed6aba5373d78e160f4df39e011f078be54df8, 'BRAt' UNION ALLSELECT 'arbitrum', 0xe8dbc4680235ccaeff48e4c0b0eaceebb89e5e17, 'CHLt' UNION ALLSELECT 'arbitrum', 0xa16d5db80a45157e0e451750b81ff0cc0b61d558, 'COLt' UNION ALLSELECT 'arbitrum', 0xb96aa6babccd738d6644add4912fe5efbebf5a25, 'MEXt' UNION ALLSELECT 'arbitrum', 0x899438713f62b04d6cd8e8709986f7256fb6e3d9, 'PERt' UNION ALLSELECT 'arbitrum', 0x6bb883b61d58f3531cd2e15563f2cdd0e9b24e32, 'PRYt' UNION ALLSELECT 'arbitrum', 0x2ecc8c60c881436d43b9ae8eec7bc226d5404e71, 'URYt' UNION ALLSELECT 'arbitrum', 0x8c4106bee19cb995abab20f3de6ba9df9cf9a17f, 'VENt' UNION ALLSELECT 'polygon', 0x50464be58912745447e24eb3bbdedcee10d3e056, 'ARGt' UNION ALLSELECT 'polygon', 0x20eca820d3cd00ed9c9f2861cdf6429bacd8ed55, 'BOLt' UNION ALLSELECT 'polygon', 0x59863989d080b22476db95656d0c3cc18be92214, 'BRAt' UNION ALLSELECT 'polygon', 0xfa658f62ca6cacaa769035adbcbed9bf75f9f72d, 'CHLt' UNION ALLSELECT 'polygon', 0x1ea02ba45fc146f534b371c49fbb2a4c86dce93d, 'COLt' UNION ALLSELECT 'polygon', 0xb9a848a8e1aff1a16a27f1ad3b66d873d5c38d62, 'MEXt' UNION ALLSELECT 'polygon', 0x53bd6e8af3da05781afc98729378424f66c9da52, 'PERt' UNION ALLSELECT 'polygon', 0x5884ffd7597e05493f83ff44e96befd4f0fe474d, 'PRYt' UNION ALLSELECT 'polygon', 0xaef12aff8054128d5d3dd848f6d645854e0cd426, 'URYt' UNION ALLSELECT 'polygon', 0x0b60fafc79761a28db657707baebb34fc6589b73, 'VENt'),daily_net AS (SELECTt.block_date,m.symbol,SUM(CASEWHEN t."from" = 0x0000000000000000000000000000000000000000 THEN t.amount_raw / 1e18WHEN t."to" = 0x0000000000000000000000000000000000000000 THEN -t.amount_raw / 1e18ELSE 0END) AS net_supply_changeFROM tokens.transfers tINNER JOIN token_map m ON t.blockchain = m.blockchain AND t.contract_address = m.contract_addressWHERE t.blockchain IN ('base', 'arbitrum', 'polygon')AND (t."from" = 0x0000000000000000000000000000000000000000OR t."to" = 0x0000000000000000000000000000000000000000)GROUP BY 1, 2)SELECTblock_date,symbol,SUM(net_supply_change) OVER (PARTITION BY symbol ORDER BY block_date) AS cumulative_supplyFROM daily_netORDER BY block_date, symbol