Query editor
/*-- @title: ENS - EnDAOment - aEthWETH Strategy-- @description: Calculates accounting entries (deposits, withdrawals, rebase accruals, and mark-to-market adjustments) for aEthWETH positions held-- @author: Steakhouse Financial-- @notes: N/A-- @version:- 2.0 - 2024-03-08 - Improving performance & adding comments- 1.0 - 2024-01-08 - Initial release*/WITHaethweth_wallets AS (SELECT 0x4f2083f5fbede34c2714affb3105539775f7fe64 AS wallet,'ENS: EnDAOment' AS nameUNION ALLSELECT0xfe89cc7abb2c4183683ab71653c4cdc9b02d44b7 AS wallet,'DAO Wallet' AS nameUNION ALLSELECT0xcf60916b6cb4753f58533808fa610fcbd4098ec0 AS wallet,'ENS: Gnosis Safe' AS name),aethweth_prices AS (SELECTDATE_TRUNC('day', minute) AS period,contract_address,priceFROMprices.usdWHEREblockchain = 'ethereum'AND minute > date '2023-01-01'AND contract_address = 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2AND EXTRACT(hour FROM minute) = 23AND EXTRACT(minute FROM minute) = 59),aethweth_tokenflows AS (SELECTevt_block_time AS ts,evt_tx_hash AS hash,wallet,"to" AS counterparty,contract_address,- CAST(value AS DOUBLE) AS qty,CAST(NULL AS DOUBLE) AS eth_qtyFROMerc20_ethereum.evt_TransferINNER JOIN aethweth_wallets ON "from" = walletWHEREevt_block_time > date '2023-01-01'AND contract_address = 0x4d5f47fa6a74757f35c14fd3a6ef8e3c9bc514e8 -- aEthWETHUNION ALLSELECTevt_block_time AS ts,evt_tx_hash AS hash,wallet,"from" AS counterparty,contract_address,CAST(value AS DOUBLE) AS qty,