Query editor
/* Query DescriptionPoolLogic.sol emits two events: Deposit, Withdrawal.Both these events have the fund value in USD(scaled by a factor of 1e18).For a given pool, we get the last event of each type(Deposit, Withdrawal).We then compare the blocknumber and index, to find out which of these two event types has the updated fund value.For parsing the deposit and withdraw events, the bytes data indicating TVL is extracted first.It is then converted to numeric using the Dune Analytic's abstraction.Ref: https://github.com/sambacha/dune-snippets/blob/ba65246531965b08dcde741b34db2a8b89b77679/dune/abstractions/public/bytea2numeric.sqlEXPLANATION FOR EVENT DECODING:1. Deposit event - In the deposit event the fund value is the 32 byte substring starting from 7*32+17 * 32 + 1 => 1 byte for the /x at the start7 * 32 for the 32 bytes each of address fundAddress,address investor,address assetDeposited,uint256 amountDeposited,uint256 valueDeposited,uint256 fundTokensReceived,uint256 totalInvestorFundTokens2. Withdraw event - In the withdraw event the fund value is the 32 byte substring starting from 5*32+1*/WITH dhedge_v2_pools AS (-- get dhedge toros pool v2 addressesselect * from (values(0x49bf093277bf4dde49c48c6aa55a3bda3eedef68, 'USD Market Neutral Yield'),(0x1ec50880101022c11530a069690f5446d1464592, 'Stablecoin Yield'),(0xb2cfb909e8657c0ec44d3dd898c1053b87804755, 'Ethereum Yield'),(0x59babc14dd73761e38e5bda171b2298dc14da92d, 'SNX Debt Mirror'),(0xb9243c495117343981ec9f8aa2abffee54396fc0, 'Perpetual Delta Neutral Yield'),(0x83d1fa384ec44c2769a3562ede372484f26e141b, 'Bitcoin Bear 1X'),(0x32ad28356ef70adc3ec051d8aacdeeaa10135296, 'Bitcoin Bull 2X'),(0xb03818de4992388260b62259361778cf98485dfe, 'Bitcoin Bull 3X'),(0x11b55966527ff030ca9c7b1c548b4be5e7eaee6d, 'Bitcoin Bull 4X'),(0xcacb5a722a36cff6baeb359e21c098a4acbffdfa, 'Ethereum Bear 1X'),(0x9573c7b691cdcebbfa9d655181f291799dfb7cf5, 'Ethereum Bull 2X'),(0x32b1d1bfd4b3b0cb9ff2dcd9dac757aa64d4cb69, 'Ethereum Bull 3X'),(0xcc7d6ed524760539311ed0cdb41d0852b4eb77eb, 'Solana Bull 3X'),(0x7d3c9c6566375d7ad6e89169ca5c01b5edc15364, 'Solana Bull 2X')) as p (fund_address, fund_name)),pool_deposits AS (SELECTfund_name,contract_address,fund_value,block_number,indexFROM(SELECTDISTINCT dhedge_v2_pools.fund_name as fund_name,