Query editor
WITH-- Token Flows (from and to the curve pool tETH/WETH)token_flows AS (SELECTevt_block_time AS date,contract_address,CAST(value AS DOUBLE) / 1e18 AS valueFROM erc20_ethereum.evt_TransferWHERE "to" = 0xa10d15538e09479186b4d3278ba5c979110dddb1 -- curve pool tETH/WETHAND contract_address IN (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0, 0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8) -- wstETH, tETHUNION ALLSELECTevt_block_time AS date,contract_address,-1 * CAST(value AS DOUBLE) / 1e18 AS valueFROM erc20_ethereum.evt_TransferWHERE "from" = 0xa10d15538e09479186b4d3278ba5c979110dddb1 -- curve pool tETH/WETHAND contract_address IN (0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0, 0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8) -- WETH, tETH),-- Pool Balancepool_balance AS (SELECTdate,contract_address,amountFROM (SELECTdate,contract_address,SUM(value) OVER (PARTITION BY contract_address ORDER BY date) AS amount,ROW_NUMBER() OVER (PARTITION BY contract_address ORDER BY date DESC) AS rnFROM token_flowsORDER BY 1 DESC) xWHERE contract_address = 0xD11c452fc99cF405034ee446803b6F6c1F6d5ED8 -- tETHAND rn = 1),-- Pool Token Flowspool_token_flows AS (SELECT"to" AS user,CAST(value AS DOUBLE) / 1e18 AS amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xa10d15538e09479186b4d3278ba5c979110dddb1 -- curve pool tETH/WETHAND "to" NOT IN (0x0000000000000000000000000000000000000000)UNION ALLSELECT"from" AS user,-1 * CAST(value AS DOUBLE) / 1e18 AS amountFROM erc20_ethereum.evt_TransferWHERE contract_address = 0xa10d15538e09479186b4d3278ba5c979110dddb1 -- curve pool tETH/WETHAND "from" NOT IN (0x0000000000000000000000000000000000000000)),