Query editor
/*-- @title: ENS - EnDAOment - Curve STETH Strategy-- @description: Calculates accounting entries (deposits, withdrawals, instant P&L, accruals, and mark-to-market adjustments) for Curve stETH pool-- @author: Steakhouse Financial-- @notes: First transfer was on 2023-01-30; applying filter from 2023-01-01-- @version:- 2.0 - 2024-03-08 - Added comment header, replaced some date casts with simpler syntax- 1.0 - 2023-07-26 - Initial release*/WITHcurvesteth_wallet_list AS (SELECT0x4f2083f5fbede34c2714affb3105539775f7fe64 AS wallet),curvesteth_prices AS (SELECTDATE_TRUNC('DAY', minute) AS period,contract_address,priceFROMprices.usdWHEREblockchain = 'ethereum'AND minute > date '2023-01-01'AND EXTRACT(HOUR FROM minute) = 23AND EXTRACT(MINUTE FROM minute) = 59AND contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2),curvesteth_curve_deposits_withdrawals_1 AS (SELECTevt.evt_block_time AS ts,evt.evt_tx_hash AS hash,evt.provider AS wallet,call.output_0 / 1e18 AS curve_deposit_amount,(CAST(ELEMENT_AT(token_amounts, 1) AS DOUBLE) + CAST(ELEMENT_AT(token_amounts, 2) AS DOUBLE)) / 1e18 AS weth_deposit_amount_combined,CAST(ELEMENT_AT(token_amounts, 1) AS DOUBLE) / 1e18 AS weth_deposit_amount_weth,CAST(ELEMENT_AT(token_amounts, 2) AS DOUBLE) / 1e18 AS weth_deposit_amount_stethFROMcurvefi_ethereum.steth_swap_evt_AddLiquidity AS evtJOIN curvefi_ethereum.steth_swap_call_add_liquidity AS callON evt.evt_tx_hash = call.call_tx_hashAND evt.token_amounts = call.amountsJOIN curvesteth_wallet_listON evt.provider = curvesteth_wallet_list.walletWHEREcall.call_successUNION ALLSELECTevt.evt_block_time AS ts,evt.evt_tx_hash AS hash,evt.provider AS wallet,- CAST(_amount AS DOUBLE) / 1e18 AS curve_deposit_amount,- (CAST(ELEMENT_AT(token_amounts, 1) AS DOUBLE) + CAST(ELEMENT_AT(token_amounts, 2) AS DOUBLE)) / 1e18 AS weth_deposit_amount_combined,- CAST(ELEMENT_AT(token_amounts, 1) AS DOUBLE) / 1e18 AS weth_deposit_amount_weth,- CAST(ELEMENT_AT(token_amounts, 2) AS DOUBLE) / 1e18 AS weth_deposit_amount_stethFROMcurvefi_ethereum.steth_swap_evt_RemoveLiquidity AS evtJOIN curvefi_ethereum.steth_swap_call_remove_liquidity AS callON evt.evt_tx_hash = call.call_tx_hash