Query editor
WITH base AS (SELECT *,CASEWHEN duration / 86400 = 0 THEN (amount / 1e18) * 1WHEN duration / 86400 > 0 AND duration / 86400 <= 50 THEN (amount / 1e18) * 1.3WHEN duration / 86400 > 50 AND duration / 86400 <= 100 THEN (amount / 1e18) * 1.5WHEN duration / 86400 > 100 AND duration / 86400 <= 200 THEN (amount / 1e18) * 2WHEN duration / 86400 > 200 THEN (amount / 1e18) * 3END AS weighted_amountFROM 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_amount) AS total_MPFROM base;