diff --git a/abi/agni_pool.json b/abi/agni_pool.json new file mode 100644 index 0000000..8cf56a3 --- /dev/null +++ b/abi/agni_pool.json @@ -0,0 +1 @@ +[{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "int24", "name": "tickLower", "type": "int24" }, { "indexed": true, "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "indexed": false, "internalType": "uint128", "name": "amount", "type": "uint128" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }], "name": "Burn", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": false, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": true, "internalType": "int24", "name": "tickLower", "type": "int24" }, { "indexed": true, "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "indexed": false, "internalType": "uint128", "name": "amount0", "type": "uint128" }, { "indexed": false, "internalType": "uint128", "name": "amount1", "type": "uint128" }], "name": "Collect", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint128", "name": "amount0", "type": "uint128" }, { "indexed": false, "internalType": "uint128", "name": "amount1", "type": "uint128" }], "name": "CollectProtocol", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "paid0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "paid1", "type": "uint256" }], "name": "Flash", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint16", "name": "observationCardinalityNextOld", "type": "uint16" }, { "indexed": false, "internalType": "uint16", "name": "observationCardinalityNextNew", "type": "uint16" }], "name": "IncreaseObservationCardinalityNext", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" }, { "indexed": false, "internalType": "int24", "name": "tick", "type": "int24" }], "name": "Initialize", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "int24", "name": "tickLower", "type": "int24" }, { "indexed": true, "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "indexed": false, "internalType": "uint128", "name": "amount", "type": "uint128" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }], "name": "Mint", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint32", "name": "feeProtocol0Old", "type": "uint32" }, { "indexed": false, "internalType": "uint32", "name": "feeProtocol1Old", "type": "uint32" }, { "indexed": false, "internalType": "uint32", "name": "feeProtocol0New", "type": "uint32" }, { "indexed": false, "internalType": "uint32", "name": "feeProtocol1New", "type": "uint32" }], "name": "SetFeeProtocol", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, { "indexed": true, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "int256", "name": "amount0", "type": "int256" }, { "indexed": false, "internalType": "int256", "name": "amount1", "type": "int256" }, { "indexed": false, "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" }, { "indexed": false, "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "indexed": false, "internalType": "int24", "name": "tick", "type": "int24" }, { "indexed": false, "internalType": "uint128", "name": "protocolFeesToken0", "type": "uint128" }, { "indexed": false, "internalType": "uint128", "name": "protocolFeesToken1", "type": "uint128" }], "name": "Swap", "type": "event" }, { "inputs": [{ "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "internalType": "uint128", "name": "amount", "type": "uint128" }], "name": "burn", "outputs": [{ "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "internalType": "uint128", "name": "amount0Requested", "type": "uint128" }, { "internalType": "uint128", "name": "amount1Requested", "type": "uint128" }], "name": "collect", "outputs": [{ "internalType": "uint128", "name": "amount0", "type": "uint128" }, { "internalType": "uint128", "name": "amount1", "type": "uint128" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint128", "name": "amount0Requested", "type": "uint128" }, { "internalType": "uint128", "name": "amount1Requested", "type": "uint128" }], "name": "collectProtocol", "outputs": [{ "internalType": "uint128", "name": "amount0", "type": "uint128" }, { "internalType": "uint128", "name": "amount1", "type": "uint128" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "factory", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "fee", "outputs": [{ "internalType": "uint24", "name": "", "type": "uint24" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "feeGrowthGlobal0X128", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "feeGrowthGlobal1X128", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "flash", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint16", "name": "observationCardinalityNext", "type": "uint16" }], "name": "increaseObservationCardinalityNext", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" }], "name": "initialize", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "liquidity", "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "maxLiquidityPerTick", "outputs": [{ "internalType": "uint128", "name": "", "type": "uint128" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "internalType": "uint128", "name": "amount", "type": "uint128" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "mint", "outputs": [{ "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "index", "type": "uint256" }], "name": "observations", "outputs": [{ "internalType": "uint32", "name": "blockTimestamp", "type": "uint32" }, { "internalType": "int56", "name": "tickCumulative", "type": "int56" }, { "internalType": "uint160", "name": "secondsPerLiquidityCumulativeX128", "type": "uint160" }, { "internalType": "bool", "name": "initialized", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint32[]", "name": "secondsAgos", "type": "uint32[]" }], "name": "observe", "outputs": [{ "internalType": "int56[]", "name": "tickCumulatives", "type": "int56[]" }, { "internalType": "uint160[]", "name": "secondsPerLiquidityCumulativeX128s", "type": "uint160[]" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32", "name": "key", "type": "bytes32" }], "name": "positions", "outputs": [{ "internalType": "uint128", "name": "_liquidity", "type": "uint128" }, { "internalType": "uint256", "name": "feeGrowthInside0LastX128", "type": "uint256" }, { "internalType": "uint256", "name": "feeGrowthInside1LastX128", "type": "uint256" }, { "internalType": "uint128", "name": "tokensOwed0", "type": "uint128" }, { "internalType": "uint128", "name": "tokensOwed1", "type": "uint128" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "protocolFees", "outputs": [{ "internalType": "uint128", "name": "token0", "type": "uint128" }, { "internalType": "uint128", "name": "token1", "type": "uint128" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint32", "name": "feeProtocol0", "type": "uint32" }, { "internalType": "uint32", "name": "feeProtocol1", "type": "uint32" }], "name": "setFeeProtocol", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "lmPool", "type": "address" }], "name": "setLmPool", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "slot0", "outputs": [{ "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" }, { "internalType": "int24", "name": "tick", "type": "int24" }, { "internalType": "uint16", "name": "observationIndex", "type": "uint16" }, { "internalType": "uint16", "name": "observationCardinality", "type": "uint16" }, { "internalType": "uint16", "name": "observationCardinalityNext", "type": "uint16" }, { "internalType": "uint32", "name": "feeProtocol", "type": "uint32" }, { "internalType": "bool", "name": "unlocked", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }], "name": "snapshotCumulativesInside", "outputs": [{ "internalType": "int56", "name": "tickCumulativeInside", "type": "int56" }, { "internalType": "uint160", "name": "secondsPerLiquidityInsideX128", "type": "uint160" }, { "internalType": "uint32", "name": "secondsInside", "type": "uint32" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "bool", "name": "zeroForOne", "type": "bool" }, { "internalType": "int256", "name": "amountSpecified", "type": "int256" }, { "internalType": "uint160", "name": "sqrtPriceLimitX96", "type": "uint160" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "swap", "outputs": [{ "internalType": "int256", "name": "amount0", "type": "int256" }, { "internalType": "int256", "name": "amount1", "type": "int256" }], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "int16", "name": "wordPosition", "type": "int16" }], "name": "tickBitmap", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "tickSpacing", "outputs": [{ "internalType": "int24", "name": "", "type": "int24" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "int24", "name": "tick", "type": "int24" }], "name": "ticks", "outputs": [{ "internalType": "uint128", "name": "liquidityGross", "type": "uint128" }, { "internalType": "int128", "name": "liquidityNet", "type": "int128" }, { "internalType": "uint256", "name": "feeGrowthOutside0X128", "type": "uint256" }, { "internalType": "uint256", "name": "feeGrowthOutside1X128", "type": "uint256" }, { "internalType": "int56", "name": "tickCumulativeOutside", "type": "int56" }, { "internalType": "uint160", "name": "secondsPerLiquidityOutsideX128", "type": "uint160" }, { "internalType": "uint32", "name": "secondsOutside", "type": "uint32" }, { "internalType": "bool", "name": "initialized", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "token0", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "token1", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }] diff --git a/abi/agni_position_manager.json b/abi/agni_position_manager.json new file mode 100644 index 0000000..71338a9 --- /dev/null +++ b/abi/agni_position_manager.json @@ -0,0 +1 @@ +[{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "approved", "type": "address" }, { "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "Approval", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "operator", "type": "address" }, { "indexed": false, "internalType": "bool", "name": "approved", "type": "bool" }], "name": "ApprovalForAll", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "indexed": false, "internalType": "address", "name": "recipient", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }], "name": "Collect", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "indexed": false, "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }], "name": "DecreaseLiquidity", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "indexed": false, "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "indexed": false, "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "indexed": false, "internalType": "uint256", "name": "amount1", "type": "uint256" }], "name": "IncreaseLiquidity", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "from", "type": "address" }, { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, { "indexed": true, "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "Transfer", "type": "event" }, { "inputs": [], "name": "DOMAIN_SEPARATOR", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "PERMIT_TYPEHASH", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "pure", "type": "function" }, { "inputs": [], "name": "WMNT", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "approve", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "balance", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "burn", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint128", "name": "amount0Max", "type": "uint128" }, { "internalType": "uint128", "name": "amount1Max", "type": "uint128" }], "internalType": "struct INonfungiblePositionManager.CollectParams", "name": "params", "type": "tuple" }], "name": "collect", "outputs": [{ "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "token0", "type": "address" }, { "internalType": "address", "name": "token1", "type": "address" }, { "internalType": "uint24", "name": "fee", "type": "uint24" }, { "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" }], "name": "createAndInitializePoolIfNecessary", "outputs": [{ "internalType": "address", "name": "pool", "type": "address" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "internalType": "uint256", "name": "amount0Min", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Min", "type": "uint256" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }], "internalType": "struct INonfungiblePositionManager.DecreaseLiquidityParams", "name": "params", "type": "tuple" }], "name": "decreaseLiquidity", "outputs": [{ "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [], "name": "deployer", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "factory", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "getApproved", "outputs": [{ "internalType": "address", "name": "operator", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "uint256", "name": "amount0Desired", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Desired", "type": "uint256" }, { "internalType": "uint256", "name": "amount0Min", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Min", "type": "uint256" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }], "internalType": "struct INonfungiblePositionManager.IncreaseLiquidityParams", "name": "params", "type": "tuple" }], "name": "increaseLiquidity", "outputs": [{ "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "address", "name": "operator", "type": "address" }], "name": "isApprovedForAll", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "components": [{ "internalType": "address", "name": "token0", "type": "address" }, { "internalType": "address", "name": "token1", "type": "address" }, { "internalType": "uint24", "name": "fee", "type": "uint24" }, { "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "internalType": "uint256", "name": "amount0Desired", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Desired", "type": "uint256" }, { "internalType": "uint256", "name": "amount0Min", "type": "uint256" }, { "internalType": "uint256", "name": "amount1Min", "type": "uint256" }, { "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }], "internalType": "struct INonfungiblePositionManager.MintParams", "name": "params", "type": "tuple" }], "name": "mint", "outputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "internalType": "uint256", "name": "amount0", "type": "uint256" }, { "internalType": "uint256", "name": "amount1", "type": "uint256" }], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "bytes[]", "name": "data", "type": "bytes[]" }], "name": "multicall", "outputs": [{ "internalType": "bytes[]", "name": "results", "type": "bytes[]" }], "stateMutability": "payable", "type": "function" }, { "inputs": [], "name": "name", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "ownerOf", "outputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "spender", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "uint256", "name": "deadline", "type": "uint256" }, { "internalType": "uint8", "name": "v", "type": "uint8" }, { "internalType": "bytes32", "name": "r", "type": "bytes32" }, { "internalType": "bytes32", "name": "s", "type": "bytes32" }], "name": "permit", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "positions", "outputs": [{ "internalType": "uint96", "name": "nonce", "type": "uint96" }, { "internalType": "address", "name": "operator", "type": "address" }, { "internalType": "address", "name": "token0", "type": "address" }, { "internalType": "address", "name": "token1", "type": "address" }, { "internalType": "uint24", "name": "fee", "type": "uint24" }, { "internalType": "int24", "name": "tickLower", "type": "int24" }, { "internalType": "int24", "name": "tickUpper", "type": "int24" }, { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, { "internalType": "uint256", "name": "feeGrowthInside0LastX128", "type": "uint256" }, { "internalType": "uint256", "name": "feeGrowthInside1LastX128", "type": "uint256" }, { "internalType": "uint128", "name": "tokensOwed0", "type": "uint128" }, { "internalType": "uint128", "name": "tokensOwed1", "type": "uint128" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "refundMNT", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "safeTransferFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, { "internalType": "bytes", "name": "data", "type": "bytes" }], "name": "safeTransferFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "operator", "type": "address" }, { "internalType": "bool", "name": "_approved", "type": "bool" }], "name": "setApprovalForAll", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], "name": "supportsInterface", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "token", "type": "address" }, { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, { "internalType": "address", "name": "recipient", "type": "address" }], "name": "sweepToken", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [], "name": "symbol", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "index", "type": "uint256" }], "name": "tokenByIndex", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }, { "internalType": "uint256", "name": "index", "type": "uint256" }], "name": "tokenOfOwnerByIndex", "outputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "tokenURI", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalSupply", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "from", "type": "address" }, { "internalType": "address", "name": "to", "type": "address" }, { "internalType": "uint256", "name": "tokenId", "type": "uint256" }], "name": "transferFrom", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, { "internalType": "address", "name": "recipient", "type": "address" }], "name": "unwrapWMNT", "outputs": [], "stateMutability": "payable", "type": "function" }] diff --git a/constants/agni.py b/constants/agni.py new file mode 100644 index 0000000..f4f88c3 --- /dev/null +++ b/constants/agni.py @@ -0,0 +1,86 @@ + +# USDe - cmETH 0.25%: https://agni.finance/info/v3/pairs/0x95d39c45668d59141dc5bcc940e6c191f1ebb98c + +# USDT - USDe 0.01%: https://agni.finance/info/v3/pairs/0x36a7aff497eef6a9cd7d0e7bc243793fcb3e57e2 + +# sUSDe - USDe 0.05%: https://agni.finance/info/v3/pairs/0x07277f7c1567b5324aa50a3d2f1f003e2287fbfc + +# USDC - USDe 0.01%: https://agni.finance/info/v3/pairs/0xbcf99c834e65e8a58090e20edc058279317865bd + +from web3 import Web3 +from eth_abi import encode +from eth_account.messages import encode_defunct +from eth_utils import keccak, to_bytes, to_hex + + +import json +from utils.web3_utils import ( + w3_mantle, +) + + +MAX_TICK_RANGE=887272 +START_BLOCK=72629606 + +usde_cmeth_025 = "0x95D39c45668D59141dc5bCC940e6C191f1ebB98c" +usde_usdt_001 = "0x36A7aff497eeF6a9cd7d0e7bc243793fcb3E57E2" +susde_usde_005 = "0x07277F7c1567b5324aA50a3d2F1F003E2287fBfc" +usdc_usde_001 = "0xBCf99c834E65E8a58090E20eDc058279317865BD" +agni_position_manager = "0x218bf598D1453383e2F4AA7b14fFB9BfB102D637" +usde_address = '0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34' + + + + +with open("abi/agni_pool.json") as j: + pool_abi = json.load(j) + +with open("abi/agni_position_manager.json") as j: + position_abi = json.load(j) + + +usde_cmeth_025_contract = w3_mantle.eth.contract(address=usde_cmeth_025, abi=pool_abi) +usde_usdt_001_contract = w3_mantle.eth.contract(address=usde_usdt_001, abi=pool_abi) +susde_usde_005_contract = w3_mantle.eth.contract(address=susde_usde_005, abi=pool_abi) +usdc_usde_001_contract = w3_mantle.eth.contract(address=usdc_usde_001, abi=pool_abi) +position_manager_contract = w3_mantle.eth.contract(address=agni_position_manager, abi=position_abi) + + + + +def compute_pool_address(token_a, token_b, fee): + + if token_a < token_b: + token0, token1 = token_a, token_b + else: + token0, token1 = token_b, token_a + + pool_init_code_hash = "0xaf9bd540c3449b723624376f906d8d3a0e6441ff18b847f05f4f85789ab64d9a" + agni_pool_deployer = "0xe9827B4EBeB9AE41FC57efDdDd79EDddC2EA4d03" + + encoded_params = encode( + ['address', 'address', 'uint24'], + [token0, token1, fee], + ) + + salt = to_hex(keccak(encoded_params)) + + return get_create2_address( + agni_pool_deployer, + salt, + pool_init_code_hash, + ) + + +def get_create2_address(deployer_address, salt, init_code_hash): + deployer_address_bytes = to_bytes(hexstr=deployer_address) + salt_bytes = to_bytes(hexstr=salt) + init_code_hash_bytes = to_bytes(hexstr=init_code_hash) + + return Web3.to_checksum_address( + keccak(b'\xff' + deployer_address_bytes + salt_bytes + init_code_hash_bytes)[12:].hex() + ) + + +if __name__ == '__main__': + print(compute_pool_address('0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34', '0xE6829d9a7eE3040e1276Fa75293Bde931859e8fA', 2500)) \ No newline at end of file diff --git a/constants/summary_columns.py b/constants/summary_columns.py index e0c35b4..19cd5f9 100644 --- a/constants/summary_columns.py +++ b/constants/summary_columns.py @@ -38,6 +38,10 @@ class SummaryColumn(Enum): "beefy_cached_balance_example", SummaryColumnType.ETHENA_PTS, ) + AGNI_SATS = ( + "agni_sats", + SummaryColumnType.ETHENA_PTS, + ) def __init__(self, column_name: str, col_type: SummaryColumnType): self.column_name = column_name diff --git a/integrations/agni_integration.py b/integrations/agni_integration.py new file mode 100644 index 0000000..2d2d2c2 --- /dev/null +++ b/integrations/agni_integration.py @@ -0,0 +1,80 @@ +from typing import Dict, List, Optional, Set + +from eth_typing import ChecksumAddress + +from constants.agni import ( + usde_cmeth_025, + usde_usdt_001, + susde_usde_005, + usdc_usde_001, +) +from constants.chains import Chain +from constants.summary_columns import SummaryColumn +from integrations.integration import Integration +from integrations.integration_ids import IntegrationID +from utils.agni import ( + get_agni_pool_info_list, + get_agni_all_user_balance +) + + +class AgniIntegration( + Integration +): # TODO: Change ProtocolNameIntegration to the name of the protocol + def __init__( + self, + integration_id: IntegrationID, + start_block: int, + reward_multiplier: int = 1, + balance_multiplier: int = 1, + excluded_addresses: Optional[Set[ChecksumAddress]] = None + ): + super().__init__( + integration_id, + start_block, + Chain.MANTLE, + None, + reward_multiplier, + balance_multiplier, + excluded_addresses, + ) + + def get_block_balances( + self, cached_data: Dict[int, Dict[ChecksumAddress, float]], blocks: List[int] + ) -> Dict[int, Dict[ChecksumAddress, float]]: + + start_block = self.start_block + # last_block_cache_data = {} + # if len(cached_data) > 0: + # start_block = max(cached_data.keys()) + # last_block_cache_data = cached_data[start_block] + + end_block = max(blocks) + pool_info_list = get_agni_pool_info_list( + {usde_cmeth_025, usde_usdt_001, susde_usde_005, usdc_usde_001}, + start_block, + end_block + ) + + block_data: Dict[int, Dict[ChecksumAddress, float]] = {} + for block in blocks: + user_data = {} + for pool_info in pool_info_list: + pool_user_balance = get_agni_all_user_balance(pool_info, pool_info_list[pool_info], block) + for user in pool_user_balance: + if user not in user_data: + user_data[user] = 0 + user_data[user] = pool_user_balance[user] + user_data[user] + block_data[block] = user_data + return block_data + + +if __name__ == "__main__": + example_integration = AgniIntegration(IntegrationID.AGNI, 72671947) + print( + example_integration.get_block_balances( + cached_data={}, blocks=[72671949] + ) + ) + # Example output: + # {72671949: {'0x71Fb53Afc7E36C3f11BC1bdBBAB7B6FC3E552eb6': 1523973.12}} diff --git a/integrations/integration_ids.py b/integrations/integration_ids.py index aa89852..d30f498 100644 --- a/integrations/integration_ids.py +++ b/integrations/integration_ids.py @@ -394,6 +394,14 @@ class IntegrationID(Enum): Token.USDE, ) + # agni + AGNI = ( + "agni", + "Agni", + Token.USDE, + ) + + def __init__(self, column_name: str, description: str, token: Token = Token.USDE): self.column_name = column_name self.description = description diff --git a/utils/agni.py b/utils/agni.py new file mode 100644 index 0000000..dc8400d --- /dev/null +++ b/utils/agni.py @@ -0,0 +1,175 @@ +import math +from typing import Dict, Set + +from eth_typing import ChecksumAddress +from web3 import Web3 + +from utils.web3_utils import call_with_retry, fetch_events_logs_with_retry +from utils.web3_utils import w3_mantle + +from constants.agni import ( + usde_cmeth_025, + usde_usdt_001, + susde_usde_005, + usdc_usde_001, + + usde_cmeth_025_contract, + usde_usdt_001_contract, + susde_usde_005_contract, + usdc_usde_001_contract, + position_manager_contract, + MAX_TICK_RANGE, + START_BLOCK, + compute_pool_address, usde_address +) + + +def get_agni_pool_info_list( + pools, + start=START_BLOCK, + end=w3_mantle.eth.get_block_number(), +) -> Dict[ChecksumAddress, Dict[ChecksumAddress, Set[int]]]: + pools = {Web3.to_checksum_address(pool) for pool in pools} + pool_info_list: Dict[ChecksumAddress, Dict[ChecksumAddress, Set[int]]] = {} + + for pool in pools: + pool_info_list[pool] = {} + + while start < end: + to_block = start + 1900 + if to_block > end: + to_block = end + + deposits = fetch_events_logs_with_retry( + "Agni users", + position_manager_contract.events.IncreaseLiquidity(), + start, + to_block, + ) + print(start, to_block, len(deposits), "getting deposits for agni") + for deposit in deposits: + try: + token_id = deposit["args"]["tokenId"] + position = position_manager_contract.functions.positions(token_id).call( + block_identifier=end + ) + pool_address = Web3.to_checksum_address(compute_pool_address(position[2], position[3], position[4])) + if pool_address not in pools: + continue + owner = position_manager_contract.functions.ownerOf(token_id).call( + block_identifier=end + ) + owner = Web3.to_checksum_address(owner) + users = pool_info_list[pool_address] + if owner not in users: + users[owner] = {deposit["args"]["tokenId"]} + else: + users[owner].add(deposit["args"]["tokenId"]) + except Exception: + # nft does not exist at current block + continue + + if to_block == end: + break + + start += 1900 + return pool_info_list + + +def get_pool_price( + contract, block=w3_mantle.eth.get_block_number() - 100 +): # assumes both tokens are using same number of decimals + slot0 = call_with_retry(contract.functions.slot0(), block) + return int(slot0[0]) + + +def get_pool_tick(contract, block=w3_mantle.eth.get_block_number() - 100): + return math.log( + ((call_with_retry(contract.functions.slot0(), block)[0]) / (2 ** 96)) ** 2 + ) / math.log(1.0001) + + +def get_agnis_position_balance(token_id, block, tick, sqrt_ratio_x96): + try: + [_, _, token0, token1, _, tick_lower, tick_upper, liquidity, _, _, _, _] = ( + call_with_retry(position_manager_contract.functions.positions(token_id), block) + ) + except Exception: + print(token_id, "not yet created at", block) + return [None, None, 0, 0] + result = calculate_agni_tokens( + tick, tick_lower, tick_upper, sqrt_ratio_x96, liquidity + ) + return [token0, token1, result[0], result[1]] + + +def calculate_agni_tokens(tick, tick_lower, tick_upper, sqrt_ratio_x96, liquidity): + if liquidity == 0: + return [0, 0] + if abs(tick_lower) > MAX_TICK_RANGE or abs(tick_upper) > MAX_TICK_RANGE: + return [0, 0] + t0 = 0 + t1 = 0 + sqrt_ratio_l = int(math.sqrt(1.0001) ** tick_upper * (2 ** 96)) + sqrt_ratio_u = int(math.sqrt(1.0001) ** tick_lower * (2 ** 96)) + liquidity_96 = liquidity << 96 + if tick_lower < tick < tick_upper: + t0 = liquidity_96 * abs((sqrt_ratio_l - sqrt_ratio_x96)) / (sqrt_ratio_x96 * sqrt_ratio_l) + t1 = liquidity * abs(sqrt_ratio_x96 - sqrt_ratio_u) / (2 ** 96) + elif tick >= tick_upper: + t1 = liquidity * abs(sqrt_ratio_u - sqrt_ratio_l) / (2 ** 96) + else: + t0 = liquidity_96 * abs(sqrt_ratio_u - sqrt_ratio_l) / (sqrt_ratio_u * sqrt_ratio_l) + return [abs(t0 / 10 ** 18), abs(t1 / 10 ** 18)] + + +def get_agni_all_user_balance(pool: ChecksumAddress, users: Dict[ChecksumAddress, Set[int]], + block=w3_mantle.eth.get_block_number()): + try: + if block < START_BLOCK: + return {} + if pool == Web3.to_checksum_address(usde_cmeth_025): + contract = usde_cmeth_025_contract + elif pool == Web3.to_checksum_address(usde_usdt_001): + contract = usde_usdt_001_contract + elif pool == Web3.to_checksum_address(susde_usde_005): + contract = susde_usde_005_contract + elif pool == Web3.to_checksum_address(usdc_usde_001): + contract = usdc_usde_001_contract + else: + raise Exception("Unknown pool") + + print(users) + all_user_total_balances = {} + + if len(users) == 0: + return all_user_total_balances + + sqrt_ratio_x96 = get_pool_price(contract, block) + tick = get_pool_tick(contract, block) + print(sqrt_ratio_x96, tick) + + for user in users: + token_ids = users[user] + usde = 0 + for token_id in token_ids: + [token0, token1, t0, t1] = get_agnis_position_balance(token_id, block, tick, sqrt_ratio_x96) + if token0 is None or token1 is None: + continue + if token0 == usde_address: + usde += t0 + elif token1 == usde_address: + usde += t1 + all_user_total_balances[user] = round(usde, 2) + print(user, usde, len(token_ids)) + return all_user_total_balances + except Exception : + return {} + + +if __name__ == "__main__": + pool_infos = get_agni_pool_info_list({usde_cmeth_025}, 72671947, 72671949) + print(pool_infos) + + user_balance = get_agni_all_user_balance(usde_cmeth_025,pool_infos[usde_cmeth_025],72671947) + print(user_balance)