Query editor
WITH base AS (SELECT *,(amount / 1e18) * (duration / 86400) AS weighted_durationFROM TABLE (decode_evm_event (abi => '{"anonymous": false,"inputs": [{"indexed": true,"internalType": "address","name": "owner","type": "address"},{"indexed": false,"internalType": "uint256","name": "lockStart","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "amount","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "duration","type": "uint256"}],"name": "DepositWithDuration","type": "event"}',input => TABLE (SELECT * FROM mantle.logsWHERE 1=1AND contract_address = 0xed884f0460a634c69dbb7def54858465808aacefAND topic0 = 0x71a810dd86885cd9fea6e9b97fe8287ec71dd6475db601e9b925679c9f3ec3d1))))SELECTSUM(weighted_duration) / SUM(amount) * 1e18 AS weighted_average_durationFROM base;