Query editor
/*** Query Description:* Manager Fee is cumultaive sum of the fee from the event ManagerFeeMinted for each fund** For each fund, we get all the events of the type ManagerFeeMinted.* To do this, we first find out the event topic using ethers.js library* Next for each event, extract the manager fee in bytes* Convert the bytes to numeric using dune's abstractions bytea2numeric()**/WITHdhedge_v2_pools AS (SELECTDISTINCT CASE WHEN output_0 is not nullTHEN output_0ELSE output_fundEND AS fund_address,e."_fundName" AS fund_nameFROMdhedge_v2_polygon."PoolFactory_call_createFund" eWHEREcall_success = true),pool_manager_fees AS (SELECTDISTINCT dhedge_v2_pools.fund_name as fund_name,( cast(bytearray_to_uint256(bytearray_substring(data, 129, 32))as double)) as fee,tx_hash,block_time as dateFROMpolygon.logs,dhedge_v2_poolsWHEREcontract_address = dhedge_v2_pools.fund_addressAND topic0 = 0x755a8059d66d8d243bc9f6913f429a811f154599d0538bb0b6a2ac23f23d2ccd -- ManagerFeeMinted event topic),pool_deposits_withdrawals as (SELECTcontract_address,(cast(bytearray_to_uint256(bytearray_substring(data, 129, 32)) as double) * 1e18) /(cast(bytearray_to_uint256(bytearray_substring(data, 161, 32)) as double) ) as fund_price,block_time as date,tx_hashFROMpolygon.logs,dhedge_v2_poolsWHEREcontract_address = dhedge_v2_pools.fund_addressAND topic0 = 0x97e6c213c123075e233a6f2323f33d8319141b993ab05e9e2f7eb2eda08cb944 -- Deposit event topicUNIONSELECTcontract_address,(cast(bytearray_to_uint256(bytearray_substring(data, 65, 32)) as double) * 1e18) /(cast(bytearray_to_uint256(bytearray_substring(data, 97, 32)) as double) ) as fund_price,block_time as date,