From 68757c23c7659d0ddd7fa894f542df105b0b586d Mon Sep 17 00:00:00 2001 From: damnnou Date: Tue, 9 Apr 2024 15:16:20 +0300 Subject: [PATCH 1/9] update: holesky contracts, add algebraVirtualPool --- .env | 4 +- codegen.ts | 4 +- package.json | 2 +- src/abis/algebraVirtualPool.ts | 453 +++++ src/abis/farming/algebraEternalFarming.ts | 2224 +++++++++++---------- src/abis/index.ts | 2 +- src/constants/addresses.ts | 16 +- wagmi.config.ts | 7 +- yarn.lock | 8 +- 9 files changed, 1664 insertions(+), 1056 deletions(-) create mode 100644 src/abis/algebraVirtualPool.ts diff --git a/.env b/.env index 4907c8a2..71834b37 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ -VITE_INFO_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core +VITE_INFO_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/info-test VITE_LIMIT_ORDERS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-limit-order VITE_BLOCKS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks -VITE_FARMING_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test +VITE_FARMING_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/algebra-farming-t VITE_INFURA_RPC=https://ethereum-holesky-rpc.publicnode.com VITE_WALLETCONNECT_PROJECT_ID=79c313a96c99edbc26d06cd97bff1126 \ No newline at end of file diff --git a/codegen.ts b/codegen.ts index a6ff6e8d..bc6bbea8 100644 --- a/codegen.ts +++ b/codegen.ts @@ -3,9 +3,9 @@ import type { CodegenConfig } from '@graphql-codegen/cli'; const config: CodegenConfig = { overwrite: true, schema: [ - 'https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core', + 'https://api.thegraph.com/subgraphs/name/iliaazhel/info-test', 'https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks', - 'https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test', + 'https://api.thegraph.com/subgraphs/name/iliaazhel/algebra-farming-t', ], documents: 'src/graphql/queries/!(*.d).{ts,tsx}', generates: { diff --git a/package.json b/package.json index 482aa8b7..1f653215 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@apollo/client": "^3.8.4", - "@cryptoalgebra/integral-sdk": "^0.11.22", + "@cryptoalgebra/integral-sdk": "^0.12.5", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-hover-card": "^1.0.7", diff --git a/src/abis/algebraVirtualPool.ts b/src/abis/algebraVirtualPool.ts new file mode 100644 index 00000000..e18ca8a8 --- /dev/null +++ b/src/abis/algebraVirtualPool.ts @@ -0,0 +1,453 @@ +export const algebraVirtualPoolABI = [ + { + "inputs": [ + { + "internalType": "address", + "name": "_farmingAddress", + "type": "address" + }, + { + "internalType": "address", + "name": "_plugin", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "liquidityAdd", + "type": "error" + }, + { + "inputs": [], + "name": "liquidityOverflow", + "type": "error" + }, + { + "inputs": [], + "name": "liquiditySub", + "type": "error" + }, + { + "inputs": [], + "name": "onlyFarming", + "type": "error" + }, + { + "inputs": [], + "name": "onlyPlugin", + "type": "error" + }, + { + "inputs": [], + "name": "tickInvalidLinks", + "type": "error" + }, + { + "inputs": [], + "name": "tickIsNotInitialized", + "type": "error" + }, + { + "inputs": [], + "name": "FEE_WEIGHT_DENOMINATOR", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "RATE_CHANGE_FREQUENCY", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "token0Amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "token1Amount", + "type": "uint128" + } + ], + "name": "addRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "bottomTick", + "type": "int24" + }, + { + "internalType": "int24", + "name": "topTick", + "type": "int24" + }, + { + "internalType": "int128", + "name": "liquidityDelta", + "type": "int128" + }, + { + "internalType": "int24", + "name": "currentTick", + "type": "int24" + } + ], + "name": "applyLiquidityDeltaToPosition", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "targetTick", + "type": "int24" + }, + { + "internalType": "bool", + "name": "zeroToOne", + "type": "bool" + }, + { + "internalType": "uint128", + "name": "feeAmount", + "type": "uint128" + } + ], + "name": "crossTo", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "currentLiquidity", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "deactivate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "deactivated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "token0Amount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "token1Amount", + "type": "uint128" + } + ], + "name": "decreaseRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "distributeRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "dynamicRateActivated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "farmingAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "bottomTick", + "type": "int24" + }, + { + "internalType": "int24", + "name": "topTick", + "type": "int24" + } + ], + "name": "getInnerRewardsGrowth", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardGrowthInside0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardGrowthInside1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "globalTick", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "plugin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "prevTimestamp", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardRates", + "outputs": [ + { + "internalType": "uint128", + "name": "rate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "rate1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rewardReserves", + "outputs": [ + { + "internalType": "uint128", + "name": "reserve0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "reserve1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "rate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "rate1", + "type": "uint128" + } + ], + "name": "setRates", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "name": "setWeights", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "name": "switchDynamicRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickId", + "type": "int24" + } + ], + "name": "ticks", + "outputs": [ + { + "internalType": "uint256", + "name": "liquidityTotal", + "type": "uint256" + }, + { + "internalType": "int128", + "name": "liquidityDelta", + "type": "int128" + }, + { + "internalType": "int24", + "name": "prevTick", + "type": "int24" + }, + { + "internalType": "int24", + "name": "nextTick", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "outerFeeGrowth0Token", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outerFeeGrowth1Token", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalRewardGrowth", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardGrowth0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rewardGrowth1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] as const; \ No newline at end of file diff --git a/src/abis/farming/algebraEternalFarming.ts b/src/abis/farming/algebraEternalFarming.ts index 254a855c..9b437723 100644 --- a/src/abis/farming/algebraEternalFarming.ts +++ b/src/abis/farming/algebraEternalFarming.ts @@ -1,1141 +1,1291 @@ export const algebraEternalFarmingABI = [ { - inputs: [ - { - internalType: 'contract IAlgebraPoolDeployer', - name: '_deployer', - type: 'address', - }, - { - internalType: 'contract INonfungiblePositionManager', - name: '_nonfungiblePositionManager', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'constructor', + "inputs": [ + { + "internalType": "contract IAlgebraPoolDeployer", + "name": "_deployer", + "type": "address" + }, + { + "internalType": "contract INonfungiblePositionManager", + "name": "_nonfungiblePositionManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" }, { - inputs: [], - name: 'anotherFarmingIsActive', - type: 'error', + "inputs": [], + "name": "anotherFarmingIsActive", + "type": "error" }, { - inputs: [], - name: 'claimToZeroAddress', - type: 'error', + "inputs": [], + "name": "claimToZeroAddress", + "type": "error" }, { - inputs: [], - name: 'emergencyActivated', - type: 'error', + "inputs": [], + "name": "emergencyActivated", + "type": "error" }, { - inputs: [], - name: 'farmDoesNotExist', - type: 'error', + "inputs": [], + "name": "farmDoesNotExist", + "type": "error" }, { - inputs: [], - name: 'incentiveNotExist', - type: 'error', + "inputs": [], + "name": "incentiveNotExist", + "type": "error" }, { - inputs: [], - name: 'incentiveStopped', - type: 'error', + "inputs": [], + "name": "incentiveStopped", + "type": "error" }, { - inputs: [], - name: 'invalidPool', - type: 'error', + "inputs": [], + "name": "incorrectWeight", + "type": "error" }, { - inputs: [], - name: 'invalidTokenAmount', - type: 'error', + "inputs": [], + "name": "invalidPool", + "type": "error" }, { - inputs: [], - name: 'minimalPositionWidthTooWide', - type: 'error', + "inputs": [], + "name": "invalidTokenAmount", + "type": "error" }, { - inputs: [], - name: 'pluginNotConnected', - type: 'error', + "inputs": [], + "name": "minimalPositionWidthTooWide", + "type": "error" }, { - inputs: [], - name: 'poolReentrancyLock', - type: 'error', + "inputs": [], + "name": "pluginNotConnected", + "type": "error" }, { - inputs: [], - name: 'positionIsTooNarrow', - type: 'error', + "inputs": [], + "name": "poolReentrancyLock", + "type": "error" }, { - inputs: [], - name: 'reentrancyLock', - type: 'error', + "inputs": [], + "name": "positionIsTooNarrow", + "type": "error" }, { - inputs: [], - name: 'tokenAlreadyFarmed', - type: 'error', + "inputs": [], + "name": "reentrancyLock", + "type": "error" }, { - inputs: [], - name: 'zeroLiquidity', - type: 'error', + "inputs": [], + "name": "tokenAlreadyFarmed", + "type": "error" }, { - inputs: [], - name: 'zeroRewardAmount', - type: 'error', + "inputs": [], + "name": "zeroLiquidity", + "type": "error" }, { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'bool', - name: 'newStatus', - type: 'bool', - }, - ], - name: 'EmergencyWithdraw', - type: 'event', + "inputs": [], + "name": "zeroRewardAmount", + "type": "error" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - indexed: true, - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - indexed: true, - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'virtualPool', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'bonusReward', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint24', - name: 'minimalAllowedPositionWidth', - type: 'uint24', - }, - ], - name: 'EternalFarmingCreated', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "newStatus", + "type": "bool" + } + ], + "name": "EmergencyWithdraw", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - { - indexed: true, - internalType: 'address', - name: 'rewardAddress', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'bonusRewardToken', - type: 'address', - }, - { - indexed: false, - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'bonusReward', - type: 'uint256', - }, - ], - name: 'FarmEnded', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "virtualPool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "minimalAllowedPositionWidth", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "name": "EternalFarmingCreated", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - indexed: true, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - { - indexed: false, - internalType: 'uint128', - name: 'liquidity', - type: 'uint128', - }, - ], - name: 'FarmEntered', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "bonusRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "name": "FarmEnded", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'farmingCenter', - type: 'address', - }, - ], - name: 'FarmingCenter', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + } + ], + "name": "FarmEntered", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'IncentiveDeactivated', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "farmingCenter", + "type": "address" + } + ], + "name": "FarmingCenter", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'rewardAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'bonusRewardAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'RewardAmountsDecreased', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "FeesWeightsChanged", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'to', - type: 'address', - }, - { - indexed: false, - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - indexed: true, - internalType: 'address', - name: 'rewardAddress', - type: 'address', - }, - { - indexed: true, - internalType: 'address', - name: 'owner', - type: 'address', - }, - ], - name: 'RewardClaimed', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "IncentiveDeactivated", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'rewardAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'bonusRewardAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'RewardsAdded', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardAmountsDecreased", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - { - indexed: false, - internalType: 'uint256', - name: 'rewardAmount', - type: 'uint256', - }, - { - indexed: false, - internalType: 'uint256', - name: 'bonusRewardAmount', - type: 'uint256', - }, - ], - name: 'RewardsCollected', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "RewardClaimed", + "type": "event" }, { - anonymous: false, - inputs: [ - { - indexed: false, - internalType: 'uint128', - name: 'rewardRate', - type: 'uint128', - }, - { - indexed: false, - internalType: 'uint128', - name: 'bonusRewardRate', - type: 'uint128', - }, - { - indexed: false, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'RewardsRatesChanged', - type: 'event', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardsAdded", + "type": "event" }, { - inputs: [], - name: 'FARMINGS_ADMINISTRATOR_ROLE', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + } + ], + "name": "RewardsCollected", + "type": "event" }, { - inputs: [], - name: 'INCENTIVE_MAKER_ROLE', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, - ], - stateMutability: 'view', - type: 'function', + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardsRatesChanged", + "type": "event" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint128', - name: 'rewardAmount', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusRewardAmount', - type: 'uint128', - }, - ], - name: 'addRewards', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "FARMINGS_ADMINISTRATOR_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amountRequested', - type: 'uint256', - }, - ], - name: 'claimReward', - outputs: [ - { - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - ], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "FEE_WEIGHT_DENOMINATOR", + "outputs": [ + { + "internalType": "uint16", + "name": "", + "type": "uint16" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'address', - name: 'from', - type: 'address', - }, - { - internalType: 'address', - name: 'to', - type: 'address', - }, - { - internalType: 'uint256', - name: 'amountRequested', - type: 'uint256', - }, - ], - name: 'claimRewardFrom', - outputs: [ - { - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - ], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "INCENTIVE_MAKER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_owner', - type: 'address', - }, - ], - name: 'collectRewards', - outputs: [ - { - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'bonusReward', - type: 'uint256', - }, - ], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardAmount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardAmount", + "type": "uint128" + } + ], + "name": "addRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - components: [ - { - internalType: 'uint128', - name: 'reward', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusReward', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'rewardRate', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusRewardRate', - type: 'uint128', - }, - { - internalType: 'uint24', - name: 'minimalPositionWidth', - type: 'uint24', - }, - ], - internalType: 'struct IAlgebraEternalFarming.IncentiveParams', - name: 'params', - type: 'tuple', - }, - { - internalType: 'address', - name: 'plugin', - type: 'address', - }, - ], - name: 'createEternalFarming', - outputs: [ - { - internalType: 'address', - name: 'virtualPool', - type: 'address', - }, - ], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountRequested", + "type": "uint256" + } + ], + "name": "claimReward", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - ], - name: 'deactivateIncentive', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountRequested", + "type": "uint256" + } + ], + "name": "claimRewardFrom", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint128', - name: 'rewardAmount', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusRewardAmount', - type: 'uint128', - }, - ], - name: 'decreaseRewardsAmount', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "collectRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - ], - name: 'enterFarming', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "reward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusReward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + }, + { + "internalType": "uint24", + "name": "minimalPositionWidth", + "type": "uint24" + }, + { + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "internalType": "struct IAlgebraEternalFarming.IncentiveParams", + "name": "params", + "type": "tuple" + }, + { + "internalType": "address", + "name": "plugin", + "type": "address" + } + ], + "name": "createEternalFarming", + "outputs": [ + { + "internalType": "address", + "name": "virtualPool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - internalType: 'address', - name: '_owner', - type: 'address', - }, - ], - name: 'exitFarming', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + } + ], + "name": "deactivateIncentive", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [], - name: 'farmingCenter', - outputs: [ - { - internalType: 'address', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardAmount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardAmount", + "type": "uint128" + } + ], + "name": "decreaseRewardsAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - { - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'farms', - outputs: [ - { - internalType: 'uint128', - name: 'liquidity', - type: 'uint128', - }, - { - internalType: 'int24', - name: 'tickLower', - type: 'int24', - }, - { - internalType: 'int24', - name: 'tickUpper', - type: 'int24', - }, - { - internalType: 'uint256', - name: 'innerRewardGrowth0', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'innerRewardGrowth1', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "enterFarming", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint256', - name: 'tokenId', - type: 'uint256', - }, - ], - name: 'getRewardInfo', - outputs: [ - { - internalType: 'uint256', - name: 'reward', - type: 'uint256', - }, - { - internalType: 'uint256', - name: 'bonusReward', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "exitFarming", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" }, { - inputs: [ - { - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'incentives', - outputs: [ - { - internalType: 'uint128', - name: 'totalReward', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusReward', - type: 'uint128', - }, - { - internalType: 'address', - name: 'virtualPoolAddress', - type: 'address', - }, - { - internalType: 'uint24', - name: 'minimalPositionWidth', - type: 'uint24', - }, - { - internalType: 'bool', - name: 'deactivated', - type: 'bool', - }, - { - internalType: 'address', - name: 'pluginAddress', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [], + "name": "farmingCenter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: 'isEmergencyWithdrawActivated', - outputs: [ - { - internalType: 'bool', - name: '', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "farms", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "innerRewardGrowth0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "innerRewardGrowth1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, - ], - name: 'isIncentiveDeactivated', - outputs: [ - { - internalType: 'bool', - name: 'res', - type: 'bool', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getRewardInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: 'nonfungiblePositionManager', - outputs: [ - { - internalType: 'contract INonfungiblePositionManager', - name: '', - type: 'address', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "incentives", + "outputs": [ + { + "internalType": "uint128", + "name": "totalReward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusReward", + "type": "uint128" + }, + { + "internalType": "address", + "name": "virtualPoolAddress", + "type": "address" + }, + { + "internalType": "uint24", + "name": "minimalPositionWidth", + "type": "uint24" + }, + { + "internalType": "bool", + "name": "deactivated", + "type": "bool" + }, + { + "internalType": "address", + "name": "pluginAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [], - name: 'numOfIncentives', - outputs: [ - { - internalType: 'uint256', - name: '', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [], + "name": "isEmergencyWithdrawActivated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'address', - name: 'owner', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - ], - name: 'rewards', - outputs: [ - { - internalType: 'uint256', - name: 'rewardAmount', - type: 'uint256', - }, - ], - stateMutability: 'view', - type: 'function', + "inputs": [ + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "isIncentiveDeactivated", + "outputs": [ + { + "internalType": "bool", + "name": "res", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'bool', - name: 'newStatus', - type: 'bool', - }, - ], - name: 'setEmergencyWithdrawStatus', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "nonfungiblePositionManager", + "outputs": [ + { + "internalType": "contract INonfungiblePositionManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - internalType: 'address', - name: '_farmingCenter', - type: 'address', - }, - ], - name: 'setFarmingCenterAddress', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [], + "name": "numOfIncentives", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" }, { - inputs: [ - { - components: [ - { - internalType: 'contract IERC20Minimal', - name: 'rewardToken', - type: 'address', - }, - { - internalType: 'contract IERC20Minimal', - name: 'bonusRewardToken', - type: 'address', - }, - { - internalType: 'contract IAlgebraPool', - name: 'pool', - type: 'address', - }, - { - internalType: 'uint256', - name: 'nonce', - type: 'uint256', - }, - ], - internalType: 'struct IncentiveKey', - name: 'key', - type: 'tuple', - }, - { - internalType: 'uint128', - name: 'rewardRate', - type: 'uint128', - }, - { - internalType: 'uint128', - name: 'bonusRewardRate', - type: 'uint128', - }, - ], - name: 'setRates', - outputs: [], - stateMutability: 'nonpayable', - type: 'function', + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + } + ], + "name": "rewards", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" }, + { + "inputs": [ + { + "internalType": "bool", + "name": "newStatus", + "type": "bool" + } + ], + "name": "setEmergencyWithdrawStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_farmingCenter", + "type": "address" + } + ], + "name": "setFarmingCenterAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + } + ], + "name": "setRates", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "name": "setWeights", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "name": "switchDynamicRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] as const; diff --git a/src/abis/index.ts b/src/abis/index.ts index 8cd87492..48c7fbd3 100644 --- a/src/abis/index.ts +++ b/src/abis/index.ts @@ -4,7 +4,7 @@ export * from './algebraPositionManager'; export * from './algebraQuoter'; export * from './algebraQuoterV2'; export * from './algebraRouter'; +export * from './algebraVirtualPool'; export * from './plugins'; export * from './farming'; export * from './tokens' - diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 85d4b343..4db389ad 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -4,25 +4,25 @@ export const POOL_INIT_CODE_HASH: Address = '0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d'; export const ALGEBRA_FACTORY: Address = - '0x6AD6A4f233F1E33613e996CCc17409B93fF8bf5f'; + '0x32f22b73d887dC91334077BC9C4F9C0879319D44'; export const ALGEBRA_POOL_DEPLOYER: Address = - '0x69D57B9D705eaD73a5d2f2476C30c55bD755cc2F'; + '0x23cA0Fb37cbdC80f8317972aBc8ae928866F62a8'; export const ALGEBRA_POSITION_MANAGER: Address = - '0x5AeFBA317BAba46EAF98Fd6f381d07673bcA6467'; + '0x39332453FA5000439D146416b83041b00625A537'; export const ALGEBRA_QUOTER: Address = - '0x38A5C36FA8c8c9E4649b51FCD61810B14e7ce047'; + '0x48d2d05dEfcAC212fAD90085fdeE0f40E3188AaE'; export const ALGEBRA_QUOTER_V2: Address = - '0x83D4a9Ea77a4dbA073cD90b30410Ac9F95F93E7C'; + '0xd14cA1EFb707bfE9cD46aD0F5b80A968358a27d8'; export const ALGEBRA_ROUTER: Address = - '0xEC250E6856e14A494cb1f0abC61d72348c79F418'; + '0x5E491EEF515b802Cf0E40053677Cf61048302513'; export const ALGEBRA_ETERNAL_FARMING: Address = - '0x49a390a3dFd2d01389f799965F3af5961f87d228'; + '0x228fe45081165a2948735c84B9C0648EeE8E84a0'; export const FARMING_CENTER: Address = - '0x37A4950b4ea0C46596404895c5027B088B0e70e7'; + '0x4cFFc4701dF4637f515d068944422212878e4C4d'; diff --git a/wagmi.config.ts b/wagmi.config.ts index acf2a603..915f6a05 100644 --- a/wagmi.config.ts +++ b/wagmi.config.ts @@ -19,7 +19,8 @@ import { algebraQuoterV2ABI, algebraEternalFarmingABI, farmingCenterABI, - wNativeABI + wNativeABI, + algebraVirtualPoolABI } from './src/abis'; const contracts: ContractConfig[] = [ @@ -70,6 +71,10 @@ const contracts: ContractConfig[] = [ abi: wNativeABI, name: 'WrappedNative' }, + { + abi: algebraVirtualPoolABI, + name: 'AlgebraVirtualPool' + } ]; export default defineConfig({ diff --git a/yarn.lock b/yarn.lock index b55feb4c..1bedd71e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -554,10 +554,10 @@ stream-browserify "^3.0.0" util "^0.12.4" -"@cryptoalgebra/integral-sdk@^0.11.22": - version "0.11.22" - resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.11.22.tgz#01b367f05461b279a8bd7d26207ddc05f96b8549" - integrity sha512-JHI3QVX/ybYDaegawhnKS83awWBmMLsp/GqIiMLJkX5XKeyix/bYyt1s86Tui7QC7bLbZPUJb+xCJ7t+DxYmqA== +"@cryptoalgebra/integral-sdk@^0.12.5": + version "0.12.5" + resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.12.5.tgz#3ab56df5794a018231a072ab43c9631b3d8dfd89" + integrity sha512-rq+GMtytxGzLon/C0c0+WyDi+4TYt7FI5pAi71aFnQUjJrN9t/c69fPNHiL3XBup3bSg8/1gIP5/3dCx0/wvPA== dependencies: "@ethersproject/abi" "^5.7.0" "@ethersproject/address" "^5.7.0" From 0a581bb12bb7e5089c5f9f51966a99b73860e4d5 Mon Sep 17 00:00:00 2001 From: damnnou Date: Wed, 10 Apr 2024 11:08:40 +0300 Subject: [PATCH 2/9] update: fetch rates from virtual pool --- src/components/farming/ActiveFarming/index.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 3db4a60a..56ea47a0 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -16,6 +16,7 @@ import Loader from '@/components/common/Loader'; import { ADDRESS_ZERO } from '@cryptoalgebra/integral-sdk'; import { useRewardEarnedUSD } from '@/hooks/farming/useRewardEarnedUSD'; import { useFarmingAPR } from '@/hooks/farming/useFarmingAPR'; +import { useAlgebraVirtualPoolRewardRates } from '@/generated'; interface ActiveFarmingProps { farming: Farming; @@ -78,10 +79,17 @@ const ActiveFarming = ({ const formattedTVL = TVL.toFixed(2); + const {data: rates} = useAlgebraVirtualPoolRewardRates({ + address: farming.farming.virtualPool, + }) + + const rewardRate = rates ? rates[0] : 0n; + const bonusRewardRate = rates ? rates[1] : 0n; + const rewardRatePerDay = Number( formatUnits( - farming.farming.rewardRate, + rewardRate, farming.rewardToken.decimals ) ) * @@ -92,7 +100,7 @@ const ActiveFarming = ({ const bonusRewardRatePerDay = Number( formatUnits( - farming.farming.bonusRewardRate, + bonusRewardRate, farming.bonusRewardToken?.decimals ) ) * From c88d90a569a3d2e0d617d171624303e3a9e71bf3 Mon Sep 17 00:00:00 2001 From: damnnou Date: Wed, 10 Apr 2024 15:52:06 +0300 Subject: [PATCH 3/9] update: farming redeploy --- src/components/farming/ActiveFarming/index.tsx | 2 +- src/constants/addresses.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 56ea47a0..b27128da 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -79,7 +79,7 @@ const ActiveFarming = ({ const formattedTVL = TVL.toFixed(2); - const {data: rates} = useAlgebraVirtualPoolRewardRates({ + const { data: rates } = useAlgebraVirtualPoolRewardRates({ address: farming.farming.virtualPool, }) diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index 4db389ad..d7e32818 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -22,7 +22,7 @@ export const ALGEBRA_ROUTER: Address = '0x5E491EEF515b802Cf0E40053677Cf61048302513'; export const ALGEBRA_ETERNAL_FARMING: Address = - '0x228fe45081165a2948735c84B9C0648EeE8E84a0'; + '0x748DddDfb4780168346ac628593dB1b17cF62dA8'; export const FARMING_CENTER: Address = - '0x4cFFc4701dF4637f515d068944422212878e4C4d'; + '0x754Fd5fB70efBcDe132F76c5F5A5cb1716b9FFa2'; From 342904890346a29c2ec810b1d6cf6bd0d3ed0eea Mon Sep 17 00:00:00 2001 From: damnnou Date: Thu, 11 Apr 2024 12:44:00 +0300 Subject: [PATCH 4/9] chore: fix syntax --- src/components/farming/ActiveFarming/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index b27128da..1503129a 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -83,8 +83,7 @@ const ActiveFarming = ({ address: farming.farming.virtualPool, }) - const rewardRate = rates ? rates[0] : 0n; - const bonusRewardRate = rates ? rates[1] : 0n; + const [rewardRate, bonusRewardRate] = rates || [0n, 0n]; const rewardRatePerDay = Number( From cd917c82de318a68df3224adfc50e6d0e5342901 Mon Sep 17 00:00:00 2001 From: damnnou Date: Wed, 17 Apr 2024 18:30:33 +0300 Subject: [PATCH 5/9] fix: update rewards in farming --- .../farming/ActiveFarming/index.tsx | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 1503129a..3bab1747 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -33,22 +33,22 @@ const ActiveFarming = ({ const [rewardEarned, setRewardEarned] = useState(0n); const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); - + const APR = useFarmingAPR({ farmingId: farming.farming.id }); - + const isSameReward = isSameRewards( farming.farming.rewardToken, farming.farming.bonusRewardToken ); - + const formattedRewardEarned = Number( formatUnits(rewardEarned, farming.rewardToken.decimals) ); - + const formattedBonusRewardEarned = Number( formatUnits(bonusRewardEarned, farming.bonusRewardToken?.decimals) ); - + const rewardEarnedUSD = useRewardEarnedUSD({ token: farming.rewardToken, reward: rewardEarned, @@ -167,7 +167,7 @@ const ActiveFarming = ({ Date: Thu, 18 Apr 2024 12:49:51 +0300 Subject: [PATCH 6/9] refactor: clean up ActiveFarming, add info hooks, add hovercard info on rewards earned --- .../farming/ActiveFarming/index.tsx | 256 ++++-------------- .../modals/SelectPositionFarmModal/index.tsx | 101 ++----- .../position/ActiveFarmingCard/index.tsx | 118 ++++---- .../position/ClosedFarmingCard/index.tsx | 83 +++++- src/hooks/farming/useFarmHarvest.ts | 30 +- src/hooks/farming/useFarmStake.ts | 60 ++-- .../farming/useFarmingDepositRewardsEarned.ts | 72 +++++ src/hooks/farming/useFarmingRewardRates.ts | 41 +++ src/hooks/farming/useFarmingRewardsEarned.ts | 70 +++++ src/hooks/farming/useFarmingUserTVL.ts | 19 ++ src/hooks/farming/useRewardEarnedUSD.ts | 26 +- 11 files changed, 447 insertions(+), 429 deletions(-) create mode 100644 src/hooks/farming/useFarmingDepositRewardsEarned.ts create mode 100644 src/hooks/farming/useFarmingRewardRates.ts create mode 100644 src/hooks/farming/useFarmingRewardsEarned.ts create mode 100644 src/hooks/farming/useFarmingUserTVL.ts diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 3bab1747..5262c2e7 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -1,22 +1,20 @@ -import { useEffect, useState } from 'react'; -import { SelectPositionFarmModal } from '@/components/modals/SelectPositionFarmModal'; -import { isSameRewards } from '@/utils/farming/isSameRewards'; -import { Deposit } from '@/graphql/generated/graphql'; -import { Farming } from '@/types/farming-info'; -import { Button } from '@/components/ui/button'; -import CardInfo from '@/components/common/CardInfo'; -import { formatUnits } from 'viem'; -import { getFarmingRewards } from '@/utils/farming/getFarmingRewards'; -import { FormattedPosition } from '@/types/formatted-position'; -import CurrencyLogo from '@/components/common/CurrencyLogo'; -import { useCurrency } from '@/hooks/common/useCurrency'; -import { useAccount } from 'wagmi'; -import { useFarmHarvestAll } from '@/hooks/farming/useFarmHarvest'; -import Loader from '@/components/common/Loader'; -import { ADDRESS_ZERO } from '@cryptoalgebra/integral-sdk'; -import { useRewardEarnedUSD } from '@/hooks/farming/useRewardEarnedUSD'; -import { useFarmingAPR } from '@/hooks/farming/useFarmingAPR'; -import { useAlgebraVirtualPoolRewardRates } from '@/generated'; +import { useEffect } from "react"; +import { SelectPositionFarmModal } from "@/components/modals/SelectPositionFarmModal"; +import { Deposit } from "@/graphql/generated/graphql"; +import { Farming } from "@/types/farming-info"; +import { Button } from "@/components/ui/button"; +import CardInfo from "@/components/common/CardInfo"; +import { FormattedPosition } from "@/types/formatted-position"; +import CurrencyLogo from "@/components/common/CurrencyLogo"; +import { useCurrency } from "@/hooks/common/useCurrency"; +import { useAccount } from "wagmi"; +import { useFarmHarvestAll } from "@/hooks/farming/useFarmHarvest"; +import Loader from "@/components/common/Loader"; +import { ADDRESS_ZERO } from "@cryptoalgebra/integral-sdk"; +import { useFarmingAPR } from "@/hooks/farming/useFarmingAPR"; +import { useFarmingUserTVL } from "@/hooks/farming/useFarmingUserTVL"; +import { useFarmingRewardRates } from "@/hooks/farming/useFarmingRewardRates"; +import { useFarmingRewardsEarned } from "@/hooks/farming/useFarmingRewardsEarned"; interface ActiveFarmingProps { farming: Farming; @@ -24,88 +22,26 @@ interface ActiveFarmingProps { positionsData: FormattedPosition[]; } -const ActiveFarming = ({ - farming, - deposits, - positionsData, -}: ActiveFarmingProps) => { +const ActiveFarming = ({ farming, deposits, positionsData }: ActiveFarmingProps) => { const { address: account } = useAccount(); - const [rewardEarned, setRewardEarned] = useState(0n); - const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); - const APR = useFarmingAPR({ farmingId: farming.farming.id }); - - const isSameReward = isSameRewards( - farming.farming.rewardToken, - farming.farming.bonusRewardToken - ); - - const formattedRewardEarned = Number( - formatUnits(rewardEarned, farming.rewardToken.decimals) - ); - - const formattedBonusRewardEarned = Number( - formatUnits(bonusRewardEarned, farming.bonusRewardToken?.decimals) - ); - - const rewardEarnedUSD = useRewardEarnedUSD({ - token: farming.rewardToken, - reward: rewardEarned, - }); - const bonusRewardEarnedUSD = useRewardEarnedUSD({ - token: farming.bonusRewardToken, - reward: bonusRewardEarned, - }); - - const farmingRewards = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4); + const userTVL = useFarmingUserTVL({ deposits, positionsData }); - const rewardTokenCurrency = useCurrency(farming.farming.rewardToken); - const bonusRewardTokenCurrency = useCurrency( - farming.farming.bonusRewardToken - ); + const { rewardRatePerDay, bonusRewardRatePerDay } = useFarmingRewardRates(farming); - const TVL = deposits.reduce((acc, deposit) => { - const currentFormattedPosition = positionsData.find( - (position) => Number(position.id) === Number(deposit.id) - ); - if (deposit.eternalFarming !== null && currentFormattedPosition) { - return acc + currentFormattedPosition.liquidityUSD; - } else { - return acc; - } - }, 0); - - const formattedTVL = TVL.toFixed(2); - - const { data: rates } = useAlgebraVirtualPoolRewardRates({ - address: farming.farming.virtualPool, - }) - - const [rewardRate, bonusRewardRate] = rates || [0n, 0n]; + const { rewardEarned, bonusRewardEarned, totalEarned, totalEarnedUSD, refetch } = useFarmingRewardsEarned({ + farming, + deposits, + }); - const rewardRatePerDay = - Number( - formatUnits( - rewardRate, - farming.rewardToken.decimals - ) - ) * - 60 * - 60 * - 24; + const rewardTokenCurrency = useCurrency(farming.farming.rewardToken); + const bonusRewardTokenCurrency = useCurrency(farming.farming.bonusRewardToken); - const bonusRewardRatePerDay = - Number( - formatUnits( - bonusRewardRate, - farming.bonusRewardToken?.decimals - ) - ) * - 60 * - 60 * - 24; + const isSameReward = farming.farming.rewardToken.toLowerCase() === farming.farming.bonusRewardToken.toLowerCase(); + const isSingleReward = + farming.farming.bonusRewardToken.toLowerCase() === ADDRESS_ZERO.toLowerCase() || farming.farming.bonusRewardToken === null; const { isLoading, onHarvestAll, isSuccess } = useFarmHarvestAll( { @@ -124,33 +60,9 @@ const ActiveFarming = ({ }; useEffect(() => { - const promises: Promise<{ - reward: bigint; - bonusReward: bigint; - }>[] = []; - deposits.forEach((deposit) => { - if (deposit.eternalFarming !== null) { - promises.push( - getFarmingRewards({ - rewardToken: farming.farming.rewardToken, - bonusRewardToken: farming.farming.bonusRewardToken, - pool: farming.farming.pool, - nonce: farming.farming.nonce, - tokenId: BigInt(deposit.id), - }) - ); - } - }); - if (promises.length === 0) return; - Promise.all(promises).then((rewards) => { - setRewardEarned(0n); - setBonusRewardEarned(0n); - rewards.forEach((reward) => { - setRewardEarned((prev) => prev + reward.reward); - setBonusRewardEarned((prev) => prev + reward.bonusReward); - }); - }); - }, [deposits, farming, isSuccess]); + if (!isSuccess) return; + refetch(); + }, [isSuccess]); return (
@@ -161,42 +73,24 @@ const ActiveFarming = ({

{APR}%

-

${formattedTVL}

+

${userTVL}

-

${farmingRewards}

+

${totalEarnedUSD}

@@ -205,63 +99,21 @@ const ActiveFarming = ({
{isSameReward ? ( <> - +

- {`${( - rewardRatePerDay + - bonusRewardRatePerDay - ).toFixed(2)} ${ - farming.rewardToken.symbol - } / day`} + {`${Number(rewardRatePerDay) + Number(bonusRewardRatePerDay)} ${farming.rewardToken.symbol} / day`}

) : (
- -

- {`${ - rewardRatePerDay.toFixed(2) === - '0.00' - ? '<0.01' - : rewardRatePerDay.toFixed( - 2 - ) - } ${ - farming.rewardToken.symbol - } / day`} -

+ +

{`${rewardRatePerDay} ${farming.rewardToken.symbol} / day`}

- {bonusRewardRatePerDay > 0 && ( + {!isSingleReward && (
- -

- {`${ - bonusRewardRatePerDay.toFixed( - 2 - ) === '0.00' - ? '<0.01' - : bonusRewardRatePerDay.toFixed( - 2 - ) - } ${ - farming.bonusRewardToken - ?.symbol - } / day`} -

+ +

{`${bonusRewardRatePerDay} ${farming.bonusRewardToken?.symbol} / day`}

)}
@@ -271,16 +123,8 @@ const ActiveFarming = ({
- (); const tokenId = selectedPosition ? BigInt(selectedPosition.id) : 0n; @@ -61,64 +50,42 @@ export function SelectPositionFarmModal({ setSelectedPosition(position); }; - const availablePositions = positions.filter( - (position) => - position.eternalFarming === null && position.liquidity > 0n - ); + const availablePositions = positions.filter((position) => position.eternalFarming === null && position.liquidity > 0n); return ( - - + - - Select Position - + Select Position
    {availablePositions.length > 0 ? ( availablePositions.map((position) => { const currentFormattedPosition = positionsData.find( - (fposition) => - Number(fposition.id) === Number(position.id) + (fposition) => Number(fposition.id) === Number(position.id) ); if (!currentFormattedPosition) return; return ( - handleSelectPosition(position) - } + onClick={() => handleSelectPosition(position)} position={position} - status={ - currentFormattedPosition.outOfRange - ? 'Out of range' - : 'In range' - } + status={currentFormattedPosition.outOfRange ? "Out of range" : "In range"} /> ); }) ) : ( -

    - You don't have available positions for this pool -

    +

    You don't have available positions for this pool

    )}
@@ -128,25 +95,11 @@ export function SelectPositionFarmModal({ ) : selectedPosition && availablePositions.length > 0 ? ( <> - - ) : ( diff --git a/src/components/position/ActiveFarmingCard/index.tsx b/src/components/position/ActiveFarmingCard/index.tsx index ddf725ab..2c6fd1de 100644 --- a/src/components/position/ActiveFarmingCard/index.tsx +++ b/src/components/position/ActiveFarmingCard/index.tsx @@ -1,41 +1,23 @@ -import { useEffect, useState } from 'react'; -import { Farming } from '@/types/farming-info'; -import { ADDRESS_ZERO } from '@cryptoalgebra/integral-sdk'; -import { useFarmHarvest } from '@/hooks/farming/useFarmHarvest'; -import { useFarmUnstake } from '@/hooks/farming/useFarmStake'; -import { useAccount } from 'wagmi'; -import { getFarmingRewards } from '@/utils/farming/getFarmingRewards'; -import { Button } from '@/components/ui/button'; -import Loader from '@/components/common/Loader'; -import { Deposit } from '@/graphql/generated/graphql'; -import { useRewardEarnedUSD } from '@/hooks/farming/useRewardEarnedUSD'; +import { useEffect } from "react"; +import { Farming } from "@/types/farming-info"; +import { ADDRESS_ZERO } from "@cryptoalgebra/integral-sdk"; +import { useFarmHarvest } from "@/hooks/farming/useFarmHarvest"; +import { useFarmUnstake } from "@/hooks/farming/useFarmStake"; +import { useAccount } from "wagmi"; +import { Button } from "@/components/ui/button"; +import Loader from "@/components/common/Loader"; +import { Deposit } from "@/graphql/generated/graphql"; +import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"; +import { useFarmingDepositRewardsEarned } from "@/hooks/farming/useFarmingDepositRewardsEarned"; interface ActiveFarmingCardProps { farming: Farming; selectedPosition: Deposit; } -const ActiveFarmingCard = ({ - farming, - selectedPosition, -}: ActiveFarmingCardProps) => { +const ActiveFarmingCard = ({ farming, selectedPosition }: ActiveFarmingCardProps) => { const { address: account } = useAccount(); - const [rewardEarned, setRewardEarned] = useState(0n); - const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); - - const rewardEarnedUSD = useRewardEarnedUSD({ - token: farming.rewardToken, - reward: rewardEarned, - }); - - const bonusRewardEarnedUSD = useRewardEarnedUSD({ - token: farming.bonusRewardToken, - reward: bonusRewardEarned, - }); - - const farmingRewards = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4); - const farmingArgs = { tokenId: BigInt(selectedPosition.id), rewardToken: farming.farming.rewardToken, @@ -45,11 +27,17 @@ const ActiveFarmingCard = ({ account: account ?? ADDRESS_ZERO, }; - const { - onHarvest, - isLoading: isHarvesting, - isSuccess: isHarvested, - } = useFarmHarvest(farmingArgs); + const { rewardEarned, bonusRewardEarned, rewardEarnedUSD, bonusRewardEarnedUSD, totalEarned, totalEarnedUSD, refetch } = + useFarmingDepositRewardsEarned({ + farming: farming.farming, + positionId: BigInt(selectedPosition.id), + }); + + const isSameReward = farming.farming.rewardToken.toLowerCase() === farming.farming.bonusRewardToken.toLowerCase(); + const isSingleReward = + farming.farming.bonusRewardToken.toLowerCase() === ADDRESS_ZERO.toLowerCase() || farming.farming.bonusRewardToken === null; + + const { onHarvest, isLoading: isHarvesting, isSuccess: isHarvested } = useFarmHarvest(farmingArgs); const { onUnstake, isLoading: isUnstaking } = useFarmUnstake(farmingArgs); @@ -66,37 +54,51 @@ const ActiveFarmingCard = ({ }; useEffect(() => { - if (!account) return; - getFarmingRewards(farmingArgs).then((rewards) => { - setRewardEarned(rewards.reward); - setBonusRewardEarned(rewards.bonusReward); - }); - }, [farming, account, selectedPosition, isHarvested]); + if (!isHarvested) return; + refetch(); + }, [isHarvested]); return (
-
EARNED REWARDS
-
- - ${farmingRewards} - -
+ + +
EARNED REWARDS
+
+ ${totalEarnedUSD} +
+
+ {totalEarned === "0" ? null : ( + + {isSameReward ? ( + + {totalEarned} {farming.rewardToken.symbol} ≈ ${totalEarnedUSD} + + ) : isSingleReward ? ( + + {rewardEarned} {farming.rewardToken.symbol} ≈ ${rewardEarnedUSD} + + ) : ( + <> + + {rewardEarned} {farming.rewardToken.symbol} ≈ ${rewardEarnedUSD} + + + {bonusRewardEarned} {farming.bonusRewardToken?.symbol} ≈ ${bonusRewardEarnedUSD} + + + )} + + )} +
-
-
); diff --git a/src/components/position/ClosedFarmingCard/index.tsx b/src/components/position/ClosedFarmingCard/index.tsx index 0db63809..f1ad7ddb 100644 --- a/src/components/position/ClosedFarmingCard/index.tsx +++ b/src/components/position/ClosedFarmingCard/index.tsx @@ -1,24 +1,27 @@ -import Loader from '@/components/common/Loader'; -import { Button } from '@/components/ui/button'; -import { EternalFarming } from '@/graphql/generated/graphql'; -import { useFarmUnstake } from '@/hooks/farming/useFarmStake'; -import { FormattedPosition } from '@/types/formatted-position'; -import { ADDRESS_ZERO } from '@cryptoalgebra/integral-sdk'; -import { useAccount } from 'wagmi'; +import Loader from "@/components/common/Loader"; +import { Button } from "@/components/ui/button"; +import { HoverCard, HoverCardContent, HoverCardTrigger } from "@/components/ui/hover-card"; +import { EternalFarming } from "@/graphql/generated/graphql"; +import { useCurrency } from "@/hooks/common/useCurrency"; +import { useFarmUnstake } from "@/hooks/farming/useFarmStake"; +import { useFarmingDepositRewardsEarned } from "@/hooks/farming/useFarmingDepositRewardsEarned"; +import { FormattedPosition } from "@/types/formatted-position"; +import { ADDRESS_ZERO } from "@cryptoalgebra/integral-sdk"; +import { useAccount } from "wagmi"; interface ClosedFarmingCardProps { positionInEndedFarming: EternalFarming; selectedPosition: FormattedPosition; } -const ClosedFarmingCard = ({ - positionInEndedFarming, - selectedPosition, -}: ClosedFarmingCardProps) => { +const ClosedFarmingCard = ({ positionInEndedFarming, selectedPosition }: ClosedFarmingCardProps) => { const { address: account } = useAccount(); + const rewardTokenCurrency = useCurrency(positionInEndedFarming.rewardToken, true); + const bonusRewardTokenCurrency = useCurrency(positionInEndedFarming.bonusRewardToken, true); + const farmingArgs = { - tokenId: BigInt(selectedPosition.id ?? 0), + tokenId: BigInt(selectedPosition.id), rewardToken: positionInEndedFarming.rewardToken, bonusRewardToken: positionInEndedFarming.bonusRewardToken, pool: positionInEndedFarming.pool, @@ -26,12 +29,62 @@ const ClosedFarmingCard = ({ account: account ?? ADDRESS_ZERO, }; + const { rewardEarned, bonusRewardEarned, rewardEarnedUSD, bonusRewardEarnedUSD, totalEarned, totalEarnedUSD } = + useFarmingDepositRewardsEarned({ + farming: positionInEndedFarming, + positionId: BigInt(selectedPosition.id), + }); + + const isSameReward = positionInEndedFarming.rewardToken.toLowerCase() === positionInEndedFarming.bonusRewardToken.toLowerCase(); + const isSingleReward = + positionInEndedFarming.bonusRewardToken.toLowerCase() === ADDRESS_ZERO.toLowerCase() || + positionInEndedFarming.bonusRewardToken === null; + const { onUnstake, isLoading: isUnstaking } = useFarmUnstake(farmingArgs); return ( - +
+
+
+ + +
EARNED REWARDS
+
+ ${totalEarnedUSD} +
+
+ {totalEarned === "0" ? null : ( + + {isSameReward ? ( + + {totalEarned} {rewardTokenCurrency?.symbol} ≈ ${totalEarnedUSD} + + ) : isSingleReward ? ( + + {rewardEarned} {rewardTokenCurrency?.symbol} ≈ ${rewardEarnedUSD} + + ) : ( + <> + + {rewardEarned} {rewardTokenCurrency?.symbol} ≈ ${rewardEarnedUSD} + + + {bonusRewardEarned} {bonusRewardTokenCurrency?.symbol} ≈ ${bonusRewardEarnedUSD} + + + )} + + )} +
+
+ +
+ +
); }; diff --git a/src/hooks/farming/useFarmHarvest.ts b/src/hooks/farming/useFarmHarvest.ts index c343e5fe..2b52a5c0 100644 --- a/src/hooks/farming/useFarmHarvest.ts +++ b/src/hooks/farming/useFarmHarvest.ts @@ -1,10 +1,10 @@ -import { FARMING_CENTER } from '@/constants/addresses'; -import { farmingCenterABI } from '@/generated'; -import { getRewardsCalldata } from '@/utils/farming/getRewardsCalldata'; -import { Address, useContractWrite, usePrepareContractWrite } from 'wagmi'; -import { useTransitionAwait } from '../common/useTransactionAwait'; -import { encodeFunctionData } from 'viem'; -import { Deposit } from '@/graphql/generated/graphql'; +import { FARMING_CENTER } from "@/constants/addresses"; +import { farmingCenterABI } from "@/generated"; +import { getRewardsCalldata } from "@/utils/farming/getRewardsCalldata"; +import { Address, useContractWrite, usePrepareContractWrite } from "wagmi"; +import { useTransitionAwait } from "../common/useTransactionAwait"; +import { encodeFunctionData } from "viem"; +import { Deposit } from "@/graphql/generated/graphql"; export function useFarmHarvest({ tokenId, @@ -33,16 +33,13 @@ export function useFarmHarvest({ const { config } = usePrepareContractWrite({ address: account && tokenId ? FARMING_CENTER : undefined, abi: farmingCenterABI, - functionName: 'multicall', + functionName: "multicall", args: [calldata], }); const { data: data, writeAsync: onHarvest } = useContractWrite(config); - const { isLoading, isSuccess } = useTransitionAwait( - data?.hash, - `Harvest Position #${tokenId}` - ); + const { isLoading, isSuccess } = useTransitionAwait(data?.hash, `Harvest Position #${tokenId}`); return { isLoading, @@ -82,7 +79,7 @@ export function useFarmHarvestAll( const calldata = encodeFunctionData({ abi: farmingCenterABI, - functionName: 'multicall', + functionName: "multicall", args: [rewardsCalldata], }); calldatas.push(calldata); @@ -92,16 +89,13 @@ export function useFarmHarvestAll( const { config } = usePrepareContractWrite({ address: FARMING_CENTER, abi: farmingCenterABI, - functionName: 'multicall', + functionName: "multicall", args: [calldatas], }); const { data: data, writeAsync: onHarvestAll } = useContractWrite(config); - const { isLoading, isSuccess } = useTransitionAwait( - data?.hash, - `Harvest All Positions` - ); + const { isLoading, isSuccess } = useTransitionAwait(data?.hash, `Harvest All Positions`); return { isLoading, diff --git a/src/hooks/farming/useFarmStake.ts b/src/hooks/farming/useFarmStake.ts index 4399a104..087e94ed 100644 --- a/src/hooks/farming/useFarmStake.ts +++ b/src/hooks/farming/useFarmStake.ts @@ -1,13 +1,13 @@ -import { FARMING_CENTER } from '@/constants/addresses'; -import { farmingCenterABI } from '@/generated'; -import { Address, useContractWrite, usePrepareContractWrite } from 'wagmi'; -import { useTransitionAwait } from '../common/useTransactionAwait'; -import { encodeFunctionData } from 'viem'; -import { MaxUint128 } from '@cryptoalgebra/integral-sdk'; -import { useFarmCheckApprove } from './useFarmCheckApprove'; -import { useEffect, useState } from 'react'; -import { farmingClient } from '@/graphql/clients'; -import { Deposit } from '@/graphql/generated/graphql'; +import { FARMING_CENTER } from "@/constants/addresses"; +import { farmingCenterABI } from "@/generated"; +import { Address, useContractWrite, usePrepareContractWrite } from "wagmi"; +import { useTransitionAwait } from "../common/useTransactionAwait"; +import { encodeFunctionData } from "viem"; +import { MaxUint128 } from "@cryptoalgebra/integral-sdk"; +import { useFarmCheckApprove } from "./useFarmCheckApprove"; +import { useEffect, useState } from "react"; +import { farmingClient } from "@/graphql/clients"; +import { Deposit } from "@/graphql/generated/graphql"; export function useFarmStake({ tokenId, @@ -31,7 +31,7 @@ export function useFarmStake({ const { config } = usePrepareContractWrite({ address, abi: farmingCenterABI, - functionName: 'enterFarming', + functionName: "enterFarming", args: [ { rewardToken, @@ -45,10 +45,7 @@ export function useFarmStake({ const { data: data, writeAsync: onStake } = useContractWrite(config); - const { isLoading, isSuccess } = useTransitionAwait( - data?.hash, - `Stake Position #${tokenId}` - ); + const { isLoading, isSuccess } = useTransitionAwait(data?.hash, `Stake Position #${tokenId}`); useEffect(() => { if (!isSuccess) return; @@ -57,12 +54,9 @@ export function useFarmStake({ const interval: NodeJS.Timeout = setInterval( () => farmingClient.refetchQueries({ - include: ['Deposits'], + include: ["Deposits"], onQueryUpdated: (query, { result: diff }) => { - const currentPos = diff.deposits.find( - (deposit: Deposit) => - deposit.id.toString() === tokenId.toString() - ); + const currentPos = diff.deposits.find((deposit: Deposit) => deposit.id.toString() === tokenId.toString()); if (!currentPos) return; if (currentPos.eternalFarming !== null) { @@ -107,7 +101,7 @@ export function useFarmUnstake({ const exitFarmingCalldata = encodeFunctionData({ abi: farmingCenterABI, - functionName: 'exitFarming', + functionName: "exitFarming", args: [ { rewardToken, @@ -121,35 +115,28 @@ export function useFarmUnstake({ const rewardClaimCalldata = encodeFunctionData({ abi: farmingCenterABI, - functionName: 'claimReward', + functionName: "claimReward", args: [rewardToken, account, BigInt(MaxUint128)], }); const bonusRewardClaimCalldata = encodeFunctionData({ abi: farmingCenterABI, - functionName: 'claimReward', + functionName: "claimReward", args: [bonusRewardToken, account, BigInt(MaxUint128)], }); - const calldatas = [ - exitFarmingCalldata, - rewardClaimCalldata, - bonusRewardClaimCalldata, - ]; + const calldatas = [exitFarmingCalldata, rewardClaimCalldata, bonusRewardClaimCalldata]; const { config } = usePrepareContractWrite({ address: account && tokenId ? FARMING_CENTER : undefined, abi: farmingCenterABI, - functionName: 'multicall', + functionName: "multicall", args: [calldatas], }); const { data: data, writeAsync: onUnstake } = useContractWrite(config); - const { isLoading, isSuccess } = useTransitionAwait( - data?.hash, - `Unstake Position #${tokenId}` - ); + const { isLoading, isSuccess } = useTransitionAwait(data?.hash, `Unstake Position #${tokenId}`); useEffect(() => { if (!isSuccess) return; @@ -158,12 +145,9 @@ export function useFarmUnstake({ const interval: NodeJS.Timeout = setInterval( () => farmingClient.refetchQueries({ - include: ['Deposits'], + include: ["Deposits"], onQueryUpdated: (query, { result: diff }) => { - const currentPos = diff.deposits.find( - (deposit: Deposit) => - deposit.id.toString() === tokenId.toString() - ); + const currentPos = diff.deposits.find((deposit: Deposit) => deposit.id.toString() === tokenId.toString()); if (!currentPos) return; if (currentPos.eternalFarming === null) { diff --git a/src/hooks/farming/useFarmingDepositRewardsEarned.ts b/src/hooks/farming/useFarmingDepositRewardsEarned.ts new file mode 100644 index 00000000..a25e2698 --- /dev/null +++ b/src/hooks/farming/useFarmingDepositRewardsEarned.ts @@ -0,0 +1,72 @@ +import { getFarmingRewards } from "@/utils/farming/getFarmingRewards"; +import { useCallback, useEffect, useState } from "react"; +import { useRewardEarnedUSD } from "./useRewardEarnedUSD"; +import { formatUnits } from "viem"; +import { EternalFarming, useSingleTokenQuery } from "@/graphql/generated/graphql"; + +export function useFarmingDepositRewardsEarned({ farming, positionId }: { farming: EternalFarming; positionId: bigint }) { + const [rewardEarned, setRewardEarned] = useState(0n); + const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); + + const { data: rewardToken } = useSingleTokenQuery({ + variables: { + tokenId: farming.rewardToken, + }, + }); + + const { data: bonusRewardToken } = useSingleTokenQuery({ + variables: { + tokenId: farming.bonusRewardToken, + }, + }); + + console.log(rewardEarned, bonusRewardEarned); + + const fetchDepositRewards = useCallback(() => { + getFarmingRewards({ + tokenId: positionId, + rewardToken: farming.rewardToken, + bonusRewardToken: farming.bonusRewardToken, + pool: farming.pool, + nonce: farming.nonce, + }).then((rewards) => { + setRewardEarned(rewards.reward); + setBonusRewardEarned(rewards.bonusReward); + }); + }, [farming, positionId]); + + const formattedRewardEarned = rewardToken?.token ? Number(formatUnits(rewardEarned, rewardToken.token.decimals)) : 0; + + const formattedBonusRewardEarned = bonusRewardToken?.token + ? Number(formatUnits(bonusRewardEarned, bonusRewardToken.token.decimals)) + : 0; + + const formattedTotalEarned = formattedRewardEarned + formattedBonusRewardEarned; + + const rewardEarnedUSD = useRewardEarnedUSD({ + token: rewardToken?.token, + reward: rewardEarned, + }); + + const bonusRewardEarnedUSD = useRewardEarnedUSD({ + token: bonusRewardToken?.token, + reward: bonusRewardEarned, + }); + + const totalEarnedUSD = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4); + + useEffect(() => { + fetchDepositRewards(); + }, [fetchDepositRewards]); + + return { + rewardEarned: formattedRewardEarned === 0 ? "0" : formattedRewardEarned < 0.01 ? "<0.01" : formattedRewardEarned.toFixed(2), + bonusRewardEarned: + formattedBonusRewardEarned === 0 ? "0" : formattedBonusRewardEarned < 0.01 ? "<0.01" : formattedBonusRewardEarned.toFixed(2), + rewardEarnedUSD, + bonusRewardEarnedUSD, + totalEarned: formattedTotalEarned === 0 ? "0" : formattedTotalEarned < 0.01 ? "<0.01" : formattedTotalEarned.toFixed(2), + totalEarnedUSD, + refetch: fetchDepositRewards, + }; +} diff --git a/src/hooks/farming/useFarmingRewardRates.ts b/src/hooks/farming/useFarmingRewardRates.ts new file mode 100644 index 00000000..171e90e3 --- /dev/null +++ b/src/hooks/farming/useFarmingRewardRates.ts @@ -0,0 +1,41 @@ +import { useAlgebraVirtualPoolRewardRates } from "@/generated"; +import { Farming } from "@/types/farming-info"; +import { formatUnits } from "viem"; + +export function useFarmingRewardRates(farming: Farming) { + const { data: rates } = useAlgebraVirtualPoolRewardRates({ + address: farming.farming.virtualPool, + }) + + const [rewardRate, bonusRewardRate] = rates || [0n, 0n]; + + const rewardRatePerDay = + Number( + formatUnits( + rewardRate, + farming.rewardToken.decimals + ) + ) * + 60 * + 60 * + 24; + + const bonusRewardRatePerDay = + Number( + formatUnits( + bonusRewardRate, + farming.bonusRewardToken?.decimals + ) + ) * + 60 * + 60 * + 24; + + const formattedRewardRatePerDay = rewardRatePerDay < 0.01 ? '<0.01' : rewardRatePerDay.toFixed(2) + const formattedBonusRewardRatePerDay = bonusRewardRatePerDay < 0.01 ? '<0.01' : bonusRewardRatePerDay.toFixed(2) + + return { + rewardRatePerDay: formattedRewardRatePerDay, + bonusRewardRatePerDay: formattedBonusRewardRatePerDay + } +} \ No newline at end of file diff --git a/src/hooks/farming/useFarmingRewardsEarned.ts b/src/hooks/farming/useFarmingRewardsEarned.ts new file mode 100644 index 00000000..47589dfb --- /dev/null +++ b/src/hooks/farming/useFarmingRewardsEarned.ts @@ -0,0 +1,70 @@ +import { Deposit } from "@/graphql/generated/graphql"; +import { Farming } from "@/types/farming-info"; +import { getFarmingRewards } from "@/utils/farming/getFarmingRewards"; +import { useCallback, useEffect, useState } from "react"; +import { useRewardEarnedUSD } from "./useRewardEarnedUSD"; +import { formatUnits } from "viem"; + +export function useFarmingRewardsEarned({ farming, deposits }: { farming: Farming, deposits: Deposit[] }) { + const [rewardEarned, setRewardEarned] = useState(0n); + const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); + + const fetchAllRewards = useCallback(() => { + const promises: Promise<{ + reward: bigint; + bonusReward: bigint; + }>[] = []; + deposits.forEach((deposit) => { + if (deposit.eternalFarming !== null) { + promises.push( + getFarmingRewards({ + rewardToken: farming.farming.rewardToken, + bonusRewardToken: farming.farming.bonusRewardToken, + pool: farming.farming.pool, + nonce: farming.farming.nonce, + tokenId: BigInt(deposit.id), + }) + ); + } + }); + if (promises.length === 0) return; + Promise.all(promises).then((rewards) => { + setRewardEarned(0n); + setBonusRewardEarned(0n); + rewards.forEach((reward) => { + setRewardEarned((prev) => prev + reward.reward); + setBonusRewardEarned((prev) => prev + reward.bonusReward); + }); + }); + }, [deposits, farming]); + + const formattedRewardEarned = Number(formatUnits(rewardEarned, farming.rewardToken.decimals)); + + const formattedBonusRewardEarned = Number(formatUnits(bonusRewardEarned, farming.bonusRewardToken?.decimals)); + + const formattedTotalEarned = formattedRewardEarned + formattedBonusRewardEarned + + const rewardEarnedUSD = useRewardEarnedUSD({ + token: farming.rewardToken, + reward: rewardEarned, + }); + + const bonusRewardEarnedUSD = useRewardEarnedUSD({ + token: farming.bonusRewardToken, + reward: bonusRewardEarned, + }); + + const totalEarnedUSD = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4); + + useEffect(() => { + fetchAllRewards(); + }, [fetchAllRewards]); + + return { + rewardEarned: formattedRewardEarned === 0 ? '0' : formattedRewardEarned < 0.01 ? '<0.01' : formattedRewardEarned.toFixed(), + bonusRewardEarned: formattedBonusRewardEarned === 0 ? '0' : formattedBonusRewardEarned < 0.01 ? '<0.01' : formattedBonusRewardEarned.toFixed(), + totalEarned: formattedTotalEarned === 0 ? '0' : formattedTotalEarned < 0.01 ? '<0.01' : formattedTotalEarned.toFixed(), + totalEarnedUSD, + refetch: fetchAllRewards, + } +} \ No newline at end of file diff --git a/src/hooks/farming/useFarmingUserTVL.ts b/src/hooks/farming/useFarmingUserTVL.ts new file mode 100644 index 00000000..887585a8 --- /dev/null +++ b/src/hooks/farming/useFarmingUserTVL.ts @@ -0,0 +1,19 @@ +import { Deposit } from "@/graphql/generated/graphql"; +import { FormattedPosition } from "@/types/formatted-position"; + +export function useFarmingUserTVL({deposits, positionsData}: {deposits: Deposit[], positionsData: FormattedPosition[]}) { + const TVL = deposits.reduce((acc, deposit) => { + const currentFormattedPosition = positionsData.find( + (position) => Number(position.id) === Number(deposit.id) + ); + if (deposit.eternalFarming !== null && currentFormattedPosition) { + return acc + currentFormattedPosition.liquidityUSD; + } else { + return acc; + } + }, 0); + + if (TVL >= 100) return TVL.toFixed(); + + if (TVL < 100) return TVL.toFixed(2); +} \ No newline at end of file diff --git a/src/hooks/farming/useRewardEarnedUSD.ts b/src/hooks/farming/useRewardEarnedUSD.ts index 31a820d9..4c1cc9f6 100644 --- a/src/hooks/farming/useRewardEarnedUSD.ts +++ b/src/hooks/farming/useRewardEarnedUSD.ts @@ -1,30 +1,16 @@ -import { - TokenFieldsFragment, - useNativePriceQuery, -} from '@/graphql/generated/graphql'; -import { useMemo } from 'react'; -import { formatUnits } from 'viem'; +import { TokenFieldsFragment, useNativePriceQuery } from "@/graphql/generated/graphql"; +import { useMemo } from "react"; +import { formatUnits } from "viem"; -export function useRewardEarnedUSD({ - token, - reward, -}: { - token: TokenFieldsFragment | null; - reward: bigint; -}): number { +export function useRewardEarnedUSD({ token, reward }: { token: TokenFieldsFragment | null | undefined; reward: bigint }): number { const { data: nativePrice } = useNativePriceQuery(); return useMemo(() => { if (!token || !nativePrice) return 0; - const formattedRewardEarned = Number( - formatUnits(reward, token.decimals) - ); + const formattedRewardEarned = Number(formatUnits(reward, token.decimals)); - const rewardUSD = - token.derivedMatic * - formattedRewardEarned * - nativePrice.bundles[0].maticPriceUSD; + const rewardUSD = token.derivedMatic * formattedRewardEarned * nativePrice.bundles[0].maticPriceUSD; return rewardUSD; }, [nativePrice, token, reward]); From 078291bc711dcf1027b8157e2d98f7d34adc61a8 Mon Sep 17 00:00:00 2001 From: damnnou Date: Wed, 15 May 2024 22:42:11 +0300 Subject: [PATCH 7/9] fix: add formatAmount util --- .../farming/useFarmingDepositRewardsEarned.ts | 10 ++--- src/hooks/farming/useFarmingRewardRates.ts | 38 +++++-------------- src/hooks/farming/useFarmingRewardsEarned.ts | 17 +++++---- src/utils/common/formatAmount.ts | 20 ++++++++++ 4 files changed, 42 insertions(+), 43 deletions(-) create mode 100644 src/utils/common/formatAmount.ts diff --git a/src/hooks/farming/useFarmingDepositRewardsEarned.ts b/src/hooks/farming/useFarmingDepositRewardsEarned.ts index a25e2698..98429d40 100644 --- a/src/hooks/farming/useFarmingDepositRewardsEarned.ts +++ b/src/hooks/farming/useFarmingDepositRewardsEarned.ts @@ -3,6 +3,7 @@ import { useCallback, useEffect, useState } from "react"; import { useRewardEarnedUSD } from "./useRewardEarnedUSD"; import { formatUnits } from "viem"; import { EternalFarming, useSingleTokenQuery } from "@/graphql/generated/graphql"; +import { formatAmount } from "@/utils/common/formatAmount"; export function useFarmingDepositRewardsEarned({ farming, positionId }: { farming: EternalFarming; positionId: bigint }) { const [rewardEarned, setRewardEarned] = useState(0n); @@ -20,8 +21,6 @@ export function useFarmingDepositRewardsEarned({ farming, positionId }: { farmin }, }); - console.log(rewardEarned, bonusRewardEarned); - const fetchDepositRewards = useCallback(() => { getFarmingRewards({ tokenId: positionId, @@ -60,12 +59,11 @@ export function useFarmingDepositRewardsEarned({ farming, positionId }: { farmin }, [fetchDepositRewards]); return { - rewardEarned: formattedRewardEarned === 0 ? "0" : formattedRewardEarned < 0.01 ? "<0.01" : formattedRewardEarned.toFixed(2), - bonusRewardEarned: - formattedBonusRewardEarned === 0 ? "0" : formattedBonusRewardEarned < 0.01 ? "<0.01" : formattedBonusRewardEarned.toFixed(2), + rewardEarned: formatAmount(formattedRewardEarned.toString(), 2), + bonusRewardEarned: formatAmount(formattedBonusRewardEarned.toString(), 2), rewardEarnedUSD, bonusRewardEarnedUSD, - totalEarned: formattedTotalEarned === 0 ? "0" : formattedTotalEarned < 0.01 ? "<0.01" : formattedTotalEarned.toFixed(2), + totalEarned: formatAmount(formattedTotalEarned.toString(), 2), totalEarnedUSD, refetch: fetchDepositRewards, }; diff --git a/src/hooks/farming/useFarmingRewardRates.ts b/src/hooks/farming/useFarmingRewardRates.ts index 171e90e3..875f64c8 100644 --- a/src/hooks/farming/useFarmingRewardRates.ts +++ b/src/hooks/farming/useFarmingRewardRates.ts @@ -1,41 +1,21 @@ import { useAlgebraVirtualPoolRewardRates } from "@/generated"; import { Farming } from "@/types/farming-info"; import { formatUnits } from "viem"; +import { formatAmount } from "@/utils/common/formatAmount"; export function useFarmingRewardRates(farming: Farming) { const { data: rates } = useAlgebraVirtualPoolRewardRates({ address: farming.farming.virtualPool, - }) + }); const [rewardRate, bonusRewardRate] = rates || [0n, 0n]; - const rewardRatePerDay = - Number( - formatUnits( - rewardRate, - farming.rewardToken.decimals - ) - ) * - 60 * - 60 * - 24; + const rewardRatePerDay = Number(formatUnits(rewardRate, farming.rewardToken.decimals)) * 60 * 60 * 24; - const bonusRewardRatePerDay = - Number( - formatUnits( - bonusRewardRate, - farming.bonusRewardToken?.decimals - ) - ) * - 60 * - 60 * - 24; + const bonusRewardRatePerDay = Number(formatUnits(bonusRewardRate, farming.bonusRewardToken?.decimals)) * 60 * 60 * 24; - const formattedRewardRatePerDay = rewardRatePerDay < 0.01 ? '<0.01' : rewardRatePerDay.toFixed(2) - const formattedBonusRewardRatePerDay = bonusRewardRatePerDay < 0.01 ? '<0.01' : bonusRewardRatePerDay.toFixed(2) - - return { - rewardRatePerDay: formattedRewardRatePerDay, - bonusRewardRatePerDay: formattedBonusRewardRatePerDay - } -} \ No newline at end of file + return { + rewardRatePerDay: formatAmount(rewardRatePerDay.toString(), 2), + bonusRewardRatePerDay: formatAmount(bonusRewardRatePerDay.toString(), 2), + }; +} diff --git a/src/hooks/farming/useFarmingRewardsEarned.ts b/src/hooks/farming/useFarmingRewardsEarned.ts index 47589dfb..b1770f9e 100644 --- a/src/hooks/farming/useFarmingRewardsEarned.ts +++ b/src/hooks/farming/useFarmingRewardsEarned.ts @@ -4,8 +4,9 @@ import { getFarmingRewards } from "@/utils/farming/getFarmingRewards"; import { useCallback, useEffect, useState } from "react"; import { useRewardEarnedUSD } from "./useRewardEarnedUSD"; import { formatUnits } from "viem"; +import { formatAmount } from "@/utils/common/formatAmount"; -export function useFarmingRewardsEarned({ farming, deposits }: { farming: Farming, deposits: Deposit[] }) { +export function useFarmingRewardsEarned({ farming, deposits }: { farming: Farming; deposits: Deposit[] }) { const [rewardEarned, setRewardEarned] = useState(0n); const [bonusRewardEarned, setBonusRewardEarned] = useState(0n); @@ -39,10 +40,10 @@ export function useFarmingRewardsEarned({ farming, deposits }: { farming: Farmin }, [deposits, farming]); const formattedRewardEarned = Number(formatUnits(rewardEarned, farming.rewardToken.decimals)); - + const formattedBonusRewardEarned = Number(formatUnits(bonusRewardEarned, farming.bonusRewardToken?.decimals)); - const formattedTotalEarned = formattedRewardEarned + formattedBonusRewardEarned + const formattedTotalEarned = formattedRewardEarned + formattedBonusRewardEarned; const rewardEarnedUSD = useRewardEarnedUSD({ token: farming.rewardToken, @@ -61,10 +62,10 @@ export function useFarmingRewardsEarned({ farming, deposits }: { farming: Farmin }, [fetchAllRewards]); return { - rewardEarned: formattedRewardEarned === 0 ? '0' : formattedRewardEarned < 0.01 ? '<0.01' : formattedRewardEarned.toFixed(), - bonusRewardEarned: formattedBonusRewardEarned === 0 ? '0' : formattedBonusRewardEarned < 0.01 ? '<0.01' : formattedBonusRewardEarned.toFixed(), - totalEarned: formattedTotalEarned === 0 ? '0' : formattedTotalEarned < 0.01 ? '<0.01' : formattedTotalEarned.toFixed(), + rewardEarned: formatAmount(formattedRewardEarned.toString(), 2), + bonusRewardEarned: formatAmount(formattedBonusRewardEarned.toString(), 2), + totalEarned: formatAmount(formattedTotalEarned.toString(), 2), totalEarnedUSD, refetch: fetchAllRewards, - } -} \ No newline at end of file + }; +} diff --git a/src/utils/common/formatAmount.ts b/src/utils/common/formatAmount.ts new file mode 100644 index 00000000..5c907733 --- /dev/null +++ b/src/utils/common/formatAmount.ts @@ -0,0 +1,20 @@ +import { formatCurrency } from "./formatCurrency"; + +export function formatAmount(amount: string, decimals = 3): string { + const amountNum = Number(amount); + const minAmount = 1 / 10 ** (decimals || 3); + + if (amountNum === 0) return "0"; + + if (amountNum < minAmount) return `< ${minAmount}`; + + if (amountNum < 1) return (Math.floor(amountNum / minAmount) * minAmount).toFixed(decimals); + + if (amountNum < 100) return (Math.floor(amountNum * 100) / 100).toString(); + + if (amountNum < 10000) return Math.floor(amountNum).toString(); + + if (amountNum < 1000000000000) return formatCurrency.format(Math.floor(amountNum * 100) / 100); + + return "∞"; +} From cf6d5c7e6f553a85521d7688735dd2bb39873a75 Mon Sep 17 00:00:00 2001 From: damnnou Date: Fri, 17 May 2024 14:08:50 +0300 Subject: [PATCH 8/9] update: farming redeploy --- .env | 4 +- codegen.ts | 18 +- package.json | 2 +- src/abis/algebraVirtualPool.ts | 991 ++++--- src/abis/farming/algebraEternalFarming.ts | 2635 +++++++++-------- .../create-pool/CreatePoolForm/index.tsx | 119 +- src/constants/addresses.ts | 29 +- yarn.lock | 8 +- 8 files changed, 1957 insertions(+), 1849 deletions(-) diff --git a/.env b/.env index 71834b37..4907c8a2 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ -VITE_INFO_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/info-test +VITE_INFO_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core VITE_LIMIT_ORDERS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-limit-order VITE_BLOCKS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks -VITE_FARMING_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/algebra-farming-t +VITE_FARMING_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test VITE_INFURA_RPC=https://ethereum-holesky-rpc.publicnode.com VITE_WALLETCONNECT_PROJECT_ID=79c313a96c99edbc26d06cd97bff1126 \ No newline at end of file diff --git a/codegen.ts b/codegen.ts index bc6bbea8..c7255257 100644 --- a/codegen.ts +++ b/codegen.ts @@ -1,20 +1,16 @@ -import type { CodegenConfig } from '@graphql-codegen/cli'; +import type { CodegenConfig } from "@graphql-codegen/cli"; const config: CodegenConfig = { overwrite: true, schema: [ - 'https://api.thegraph.com/subgraphs/name/iliaazhel/info-test', - 'https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks', - 'https://api.thegraph.com/subgraphs/name/iliaazhel/algebra-farming-t', + "https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core", + "https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks", + "https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test", ], - documents: 'src/graphql/queries/!(*.d).{ts,tsx}', + documents: "src/graphql/queries/!(*.d).{ts,tsx}", generates: { - 'src/graphql/generated/graphql.tsx': { - plugins: [ - 'typescript', - 'typescript-operations', - 'typescript-react-apollo', - ], + "src/graphql/generated/graphql.tsx": { + plugins: ["typescript", "typescript-operations", "typescript-react-apollo"], config: { withHooks: true, withResultType: true, diff --git a/package.json b/package.json index 1f653215..ba3f265a 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@apollo/client": "^3.8.4", - "@cryptoalgebra/integral-sdk": "^0.12.5", + "@cryptoalgebra/integral-sdk": "0.11.22", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-hover-card": "^1.0.7", diff --git a/src/abis/algebraVirtualPool.ts b/src/abis/algebraVirtualPool.ts index e18ca8a8..eb9eba75 100644 --- a/src/abis/algebraVirtualPool.ts +++ b/src/abis/algebraVirtualPool.ts @@ -1,453 +1,542 @@ export const algebraVirtualPoolABI = [ { - "inputs": [ - { - "internalType": "address", - "name": "_farmingAddress", - "type": "address" - }, - { - "internalType": "address", - "name": "_plugin", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "liquidityAdd", - "type": "error" - }, - { - "inputs": [], - "name": "liquidityOverflow", - "type": "error" - }, - { - "inputs": [], - "name": "liquiditySub", - "type": "error" - }, - { - "inputs": [], - "name": "onlyFarming", - "type": "error" - }, - { - "inputs": [], - "name": "onlyPlugin", - "type": "error" - }, - { - "inputs": [], - "name": "tickInvalidLinks", - "type": "error" - }, - { - "inputs": [], - "name": "tickIsNotInitialized", - "type": "error" - }, - { - "inputs": [], - "name": "FEE_WEIGHT_DENOMINATOR", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "RATE_CHANGE_FREQUENCY", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint128", - "name": "token0Amount", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "token1Amount", - "type": "uint128" - } - ], - "name": "addRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int24", - "name": "bottomTick", - "type": "int24" - }, - { - "internalType": "int24", - "name": "topTick", - "type": "int24" - }, - { - "internalType": "int128", - "name": "liquidityDelta", - "type": "int128" - }, - { - "internalType": "int24", - "name": "currentTick", - "type": "int24" - } - ], - "name": "applyLiquidityDeltaToPosition", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int24", - "name": "targetTick", - "type": "int24" - }, - { - "internalType": "bool", - "name": "zeroToOne", - "type": "bool" - }, - { - "internalType": "uint128", - "name": "feeAmount", - "type": "uint128" - } - ], - "name": "crossTo", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "currentLiquidity", - "outputs": [ - { - "internalType": "uint128", - "name": "", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "deactivate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "deactivated", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint128", - "name": "token0Amount", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "token1Amount", - "type": "uint128" - } - ], - "name": "decreaseRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "distributeRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "dynamicRateActivated", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "farmingAddress", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int24", - "name": "bottomTick", - "type": "int24" - }, - { - "internalType": "int24", - "name": "topTick", - "type": "int24" - } - ], - "name": "getInnerRewardsGrowth", - "outputs": [ - { - "internalType": "uint256", - "name": "rewardGrowthInside0", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardGrowthInside1", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "globalTick", - "outputs": [ - { - "internalType": "int24", - "name": "", - "type": "int24" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "plugin", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "prevTimestamp", - "outputs": [ - { - "internalType": "uint32", - "name": "", - "type": "uint32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rewardRates", - "outputs": [ - { - "internalType": "uint128", - "name": "rate0", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "rate1", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "rewardReserves", - "outputs": [ - { - "internalType": "uint128", - "name": "reserve0", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "reserve1", - "type": "uint128" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint128", - "name": "rate0", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "rate1", - "type": "uint128" - } - ], - "name": "setRates", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint16", - "name": "weight0", - "type": "uint16" - }, - { - "internalType": "uint16", - "name": "weight1", - "type": "uint16" - } - ], - "name": "setWeights", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "isActive", - "type": "bool" - } - ], - "name": "switchDynamicRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "int24", - "name": "tickId", - "type": "int24" - } - ], - "name": "ticks", - "outputs": [ - { - "internalType": "uint256", - "name": "liquidityTotal", - "type": "uint256" - }, - { - "internalType": "int128", - "name": "liquidityDelta", - "type": "int128" - }, - { - "internalType": "int24", - "name": "prevTick", - "type": "int24" - }, - { - "internalType": "int24", - "name": "nextTick", - "type": "int24" - }, - { - "internalType": "uint256", - "name": "outerFeeGrowth0Token", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "outerFeeGrowth1Token", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalRewardGrowth", - "outputs": [ - { - "internalType": "uint256", - "name": "rewardGrowth0", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "rewardGrowth1", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - } -] as const; \ No newline at end of file + inputs: [ + { + internalType: "address", + name: "_farmingAddress", + type: "address", + }, + { + internalType: "address", + name: "_plugin", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { + inputs: [], + name: "invalidFeeWeights", + type: "error", + }, + { + inputs: [], + name: "invalidNewMaxRate", + type: "error", + }, + { + inputs: [], + name: "invalidNewMinRate", + type: "error", + }, + { + inputs: [], + name: "liquidityAdd", + type: "error", + }, + { + inputs: [], + name: "liquidityOverflow", + type: "error", + }, + { + inputs: [], + name: "liquiditySub", + type: "error", + }, + { + inputs: [], + name: "onlyFarming", + type: "error", + }, + { + inputs: [], + name: "onlyPlugin", + type: "error", + }, + { + inputs: [], + name: "tickInvalidLinks", + type: "error", + }, + { + inputs: [], + name: "tickIsNotInitialized", + type: "error", + }, + { + inputs: [], + name: "FEE_WEIGHT_DENOMINATOR", + outputs: [ + { + internalType: "uint16", + name: "", + type: "uint16", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "RATE_CHANGE_FREQUENCY", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint128", + name: "token0Amount", + type: "uint128", + }, + { + internalType: "uint128", + name: "token1Amount", + type: "uint128", + }, + ], + name: "addRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "int24", + name: "bottomTick", + type: "int24", + }, + { + internalType: "int24", + name: "topTick", + type: "int24", + }, + { + internalType: "int128", + name: "liquidityDelta", + type: "int128", + }, + { + internalType: "int24", + name: "currentTick", + type: "int24", + }, + ], + name: "applyLiquidityDeltaToPosition", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "int24", + name: "targetTick", + type: "int24", + }, + { + internalType: "bool", + name: "zeroToOne", + type: "bool", + }, + { + internalType: "uint128", + name: "feeAmount", + type: "uint128", + }, + ], + name: "crossTo", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "currentLiquidity", + outputs: [ + { + internalType: "uint128", + name: "", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "deactivate", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "deactivated", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint128", + name: "token0Amount", + type: "uint128", + }, + { + internalType: "uint128", + name: "token1Amount", + type: "uint128", + }, + ], + name: "decreaseRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "distributeRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "dynamicRateActivated", + outputs: [ + { + internalType: "bool", + name: "", + type: "bool", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "farmingAddress", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "feeWeights", + outputs: [ + { + internalType: "uint16", + name: "weight0", + type: "uint16", + }, + { + internalType: "uint16", + name: "weight1", + type: "uint16", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "int24", + name: "bottomTick", + type: "int24", + }, + { + internalType: "int24", + name: "topTick", + type: "int24", + }, + ], + name: "getInnerRewardsGrowth", + outputs: [ + { + internalType: "uint256", + name: "rewardGrowthInside0", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardGrowthInside1", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "globalTick", + outputs: [ + { + internalType: "int24", + name: "", + type: "int24", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "plugin", + outputs: [ + { + internalType: "address", + name: "", + type: "address", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "prevTimestamp", + outputs: [ + { + internalType: "uint32", + name: "", + type: "uint32", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "rateLimits", + outputs: [ + { + internalType: "uint128", + name: "maxRewardRate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "maxRewardRate1", + type: "uint128", + }, + { + internalType: "uint128", + name: "minRewardRate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "minRewardRate1", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "rewardRates", + outputs: [ + { + internalType: "uint128", + name: "rate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "rate1", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "rewardReserves", + outputs: [ + { + internalType: "uint128", + name: "reserve0", + type: "uint128", + }, + { + internalType: "uint128", + name: "reserve1", + type: "uint128", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "uint128", + name: "_maxRate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "_maxRate1", + type: "uint128", + }, + { + internalType: "uint128", + name: "_minRate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "_minRate1", + type: "uint128", + }, + ], + name: "setDynamicRateLimits", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint128", + name: "rate0", + type: "uint128", + }, + { + internalType: "uint128", + name: "rate1", + type: "uint128", + }, + ], + name: "setRates", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint16", + name: "weight0", + type: "uint16", + }, + { + internalType: "uint16", + name: "weight1", + type: "uint16", + }, + ], + name: "setWeights", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "bool", + name: "isActive", + type: "bool", + }, + ], + name: "switchDynamicRate", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "int24", + name: "tickId", + type: "int24", + }, + ], + name: "ticks", + outputs: [ + { + internalType: "uint256", + name: "liquidityTotal", + type: "uint256", + }, + { + internalType: "int128", + name: "liquidityDelta", + type: "int128", + }, + { + internalType: "int24", + name: "prevTick", + type: "int24", + }, + { + internalType: "int24", + name: "nextTick", + type: "int24", + }, + { + internalType: "uint256", + name: "outerFeeGrowth0Token", + type: "uint256", + }, + { + internalType: "uint256", + name: "outerFeeGrowth1Token", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "totalRewardGrowth", + outputs: [ + { + internalType: "uint256", + name: "rewardGrowth0", + type: "uint256", + }, + { + internalType: "uint256", + name: "rewardGrowth1", + type: "uint256", + }, + ], + stateMutability: "view", + type: "function", + }, +] as const; diff --git a/src/abis/farming/algebraEternalFarming.ts b/src/abis/farming/algebraEternalFarming.ts index 9b437723..2f644204 100644 --- a/src/abis/farming/algebraEternalFarming.ts +++ b/src/abis/farming/algebraEternalFarming.ts @@ -1,1291 +1,1348 @@ export const algebraEternalFarmingABI = [ - { - "inputs": [ - { - "internalType": "contract IAlgebraPoolDeployer", - "name": "_deployer", - "type": "address" - }, - { - "internalType": "contract INonfungiblePositionManager", - "name": "_nonfungiblePositionManager", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "constructor" - }, - { - "inputs": [], - "name": "anotherFarmingIsActive", - "type": "error" - }, - { - "inputs": [], - "name": "claimToZeroAddress", - "type": "error" - }, - { - "inputs": [], - "name": "emergencyActivated", - "type": "error" - }, - { - "inputs": [], - "name": "farmDoesNotExist", - "type": "error" - }, - { - "inputs": [], - "name": "incentiveNotExist", - "type": "error" - }, - { - "inputs": [], - "name": "incentiveStopped", - "type": "error" - }, - { - "inputs": [], - "name": "incorrectWeight", - "type": "error" - }, - { - "inputs": [], - "name": "invalidPool", - "type": "error" - }, - { - "inputs": [], - "name": "invalidTokenAmount", - "type": "error" - }, - { - "inputs": [], - "name": "minimalPositionWidthTooWide", - "type": "error" - }, - { - "inputs": [], - "name": "pluginNotConnected", - "type": "error" - }, - { - "inputs": [], - "name": "poolReentrancyLock", - "type": "error" - }, - { - "inputs": [], - "name": "positionIsTooNarrow", - "type": "error" - }, - { - "inputs": [], - "name": "reentrancyLock", - "type": "error" - }, - { - "inputs": [], - "name": "tokenAlreadyFarmed", - "type": "error" - }, - { - "inputs": [], - "name": "zeroLiquidity", - "type": "error" - }, - { - "inputs": [], - "name": "zeroRewardAmount", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "bool", - "name": "newStatus", - "type": "bool" - } - ], - "name": "EmergencyWithdraw", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "indexed": true, - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "virtualPool", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "reward", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bonusReward", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint24", - "name": "minimalAllowedPositionWidth", - "type": "uint24" - }, - { - "indexed": false, - "internalType": "uint16", - "name": "weight0", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint16", - "name": "weight1", - "type": "uint16" - } - ], - "name": "EternalFarmingCreated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - }, - { - "indexed": true, - "internalType": "address", - "name": "rewardAddress", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "bonusRewardToken", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "reward", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bonusReward", - "type": "uint256" - } - ], - "name": "FarmEnded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "liquidity", - "type": "uint128" - } - ], - "name": "FarmEntered", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "farmingCenter", - "type": "address" - } - ], - "name": "FarmingCenter", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint16", - "name": "weight0", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "uint16", - "name": "weight1", - "type": "uint16" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "FeesWeightsChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "IncentiveDeactivated", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bonusRewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "RewardAmountsDecreased", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "reward", - "type": "uint256" - }, - { - "indexed": true, - "internalType": "address", - "name": "rewardAddress", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "owner", - "type": "address" - } - ], - "name": "RewardClaimed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bonusRewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "RewardsAdded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "bonusRewardAmount", - "type": "uint256" - } - ], - "name": "RewardsCollected", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint128", - "name": "rewardRate", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "uint128", - "name": "bonusRewardRate", - "type": "uint128" - }, - { - "indexed": false, - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "RewardsRatesChanged", - "type": "event" - }, - { - "inputs": [], - "name": "FARMINGS_ADMINISTRATOR_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "FEE_WEIGHT_DENOMINATOR", - "outputs": [ - { - "internalType": "uint16", - "name": "", - "type": "uint16" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "INCENTIVE_MAKER_ROLE", - "outputs": [ - { - "internalType": "bytes32", - "name": "", - "type": "bytes32" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint128", - "name": "rewardAmount", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusRewardAmount", - "type": "uint128" - } - ], - "name": "addRewards", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountRequested", - "type": "uint256" - } - ], - "name": "claimReward", - "outputs": [ - { - "internalType": "uint256", - "name": "reward", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "address", - "name": "from", - "type": "address" - }, - { - "internalType": "address", - "name": "to", - "type": "address" - }, - { - "internalType": "uint256", - "name": "amountRequested", - "type": "uint256" - } - ], - "name": "claimRewardFrom", - "outputs": [ - { - "internalType": "uint256", - "name": "reward", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "name": "collectRewards", - "outputs": [ - { - "internalType": "uint256", - "name": "reward", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bonusReward", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "components": [ - { - "internalType": "uint128", - "name": "reward", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusReward", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "rewardRate", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusRewardRate", - "type": "uint128" - }, - { - "internalType": "uint24", - "name": "minimalPositionWidth", - "type": "uint24" - }, - { - "internalType": "uint16", - "name": "weight0", - "type": "uint16" - }, - { - "internalType": "uint16", - "name": "weight1", - "type": "uint16" - } - ], - "internalType": "struct IAlgebraEternalFarming.IncentiveParams", - "name": "params", - "type": "tuple" - }, - { - "internalType": "address", - "name": "plugin", - "type": "address" - } - ], - "name": "createEternalFarming", - "outputs": [ - { - "internalType": "address", - "name": "virtualPool", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - } - ], - "name": "deactivateIncentive", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint128", - "name": "rewardAmount", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusRewardAmount", - "type": "uint128" - } - ], - "name": "decreaseRewardsAmount", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "enterFarming", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "address", - "name": "_owner", - "type": "address" - } - ], - "name": "exitFarming", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "farmingCenter", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - }, - { - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "farms", - "outputs": [ - { - "internalType": "uint128", - "name": "liquidity", - "type": "uint128" - }, - { - "internalType": "int24", - "name": "tickLower", - "type": "int24" - }, - { - "internalType": "int24", - "name": "tickUpper", - "type": "int24" - }, - { - "internalType": "uint256", - "name": "innerRewardGrowth0", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "innerRewardGrowth1", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint256", - "name": "tokenId", - "type": "uint256" - } - ], - "name": "getRewardInfo", - "outputs": [ - { - "internalType": "uint256", - "name": "reward", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "bonusReward", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "incentives", - "outputs": [ - { - "internalType": "uint128", - "name": "totalReward", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusReward", - "type": "uint128" - }, - { - "internalType": "address", - "name": "virtualPoolAddress", - "type": "address" - }, - { - "internalType": "uint24", - "name": "minimalPositionWidth", - "type": "uint24" - }, - { - "internalType": "bool", - "name": "deactivated", - "type": "bool" - }, - { - "internalType": "address", - "name": "pluginAddress", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "isEmergencyWithdrawActivated", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bytes32", - "name": "incentiveId", - "type": "bytes32" - } - ], - "name": "isIncentiveDeactivated", - "outputs": [ - { - "internalType": "bool", - "name": "res", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "nonfungiblePositionManager", - "outputs": [ - { - "internalType": "contract INonfungiblePositionManager", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "numOfIncentives", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "owner", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - } - ], - "name": "rewards", - "outputs": [ - { - "internalType": "uint256", - "name": "rewardAmount", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "bool", - "name": "newStatus", - "type": "bool" - } - ], - "name": "setEmergencyWithdrawStatus", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_farmingCenter", - "type": "address" - } - ], - "name": "setFarmingCenterAddress", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint128", - "name": "rewardRate", - "type": "uint128" - }, - { - "internalType": "uint128", - "name": "bonusRewardRate", - "type": "uint128" - } - ], - "name": "setRates", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "uint16", - "name": "weight0", - "type": "uint16" - }, - { - "internalType": "uint16", - "name": "weight1", - "type": "uint16" - } - ], - "name": "setWeights", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "components": [ - { - "internalType": "contract IERC20Minimal", - "name": "rewardToken", - "type": "address" - }, - { - "internalType": "contract IERC20Minimal", - "name": "bonusRewardToken", - "type": "address" - }, - { - "internalType": "contract IAlgebraPool", - "name": "pool", - "type": "address" - }, - { - "internalType": "uint256", - "name": "nonce", - "type": "uint256" - } - ], - "internalType": "struct IncentiveKey", - "name": "key", - "type": "tuple" - }, - { - "internalType": "bool", - "name": "isActive", - "type": "bool" - } - ], - "name": "switchDynamicRate", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - } + { + "inputs": [ + { + "internalType": "contract IAlgebraPoolDeployer", + "name": "_deployer", + "type": "address" + }, + { + "internalType": "contract INonfungiblePositionManager", + "name": "_nonfungiblePositionManager", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "anotherFarmingIsActive", + "type": "error" + }, + { + "inputs": [], + "name": "claimToZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "emergencyActivated", + "type": "error" + }, + { + "inputs": [], + "name": "farmDoesNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "incentiveNotExist", + "type": "error" + }, + { + "inputs": [], + "name": "incentiveStopped", + "type": "error" + }, + { + "inputs": [], + "name": "invalidPool", + "type": "error" + }, + { + "inputs": [], + "name": "invalidTokenAmount", + "type": "error" + }, + { + "inputs": [], + "name": "minimalPositionWidthTooWide", + "type": "error" + }, + { + "inputs": [], + "name": "pluginNotConnected", + "type": "error" + }, + { + "inputs": [], + "name": "poolReentrancyLock", + "type": "error" + }, + { + "inputs": [], + "name": "positionIsTooNarrow", + "type": "error" + }, + { + "inputs": [], + "name": "reentrancyLock", + "type": "error" + }, + { + "inputs": [], + "name": "tokenAlreadyFarmed", + "type": "error" + }, + { + "inputs": [], + "name": "zeroLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "zeroRewardAmount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "newStatus", + "type": "bool" + } + ], + "name": "EmergencyWithdraw", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "virtualPool", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint24", + "name": "minimalAllowedPositionWidth", + "type": "uint24" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "name": "EternalFarmingCreated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardAddress", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "bonusRewardToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "name": "FarmEnded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + } + ], + "name": "FarmEntered", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "farmingCenter", + "type": "address" + } + ], + "name": "FarmingCenter", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "FeesWeightsChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "IncentiveDeactivated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardAmountsDecreased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "indexed": true, + "internalType": "address", + "name": "rewardAddress", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "RewardClaimed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardsAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "bonusRewardAmount", + "type": "uint256" + } + ], + "name": "RewardsCollected", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "RewardsRatesChanged", + "type": "event" + }, + { + "inputs": [], + "name": "FARMINGS_ADMINISTRATOR_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INCENTIVE_MAKER_ROLE", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardAmount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardAmount", + "type": "uint128" + } + ], + "name": "addRewards", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountRequested", + "type": "uint256" + } + ], + "name": "claimReward", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amountRequested", + "type": "uint256" + } + ], + "name": "claimRewardFrom", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "collectRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "reward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusReward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + }, + { + "internalType": "uint24", + "name": "minimalPositionWidth", + "type": "uint24" + }, + { + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + }, + { + "internalType": "uint128", + "name": "maxRate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "maxRate1", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "minRate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "minRate1", + "type": "uint128" + } + ], + "internalType": "struct IAlgebraEternalFarming.IncentiveParams", + "name": "params", + "type": "tuple" + }, + { + "internalType": "address", + "name": "plugin", + "type": "address" + } + ], + "name": "createEternalFarming", + "outputs": [ + { + "internalType": "address", + "name": "virtualPool", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + } + ], + "name": "deactivateIncentive", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardAmount", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardAmount", + "type": "uint128" + } + ], + "name": "decreaseRewardsAmount", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "enterFarming", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_owner", + "type": "address" + } + ], + "name": "exitFarming", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "farmingCenter", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "farms", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint256", + "name": "innerRewardGrowth0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "innerRewardGrowth1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "getRewardInfo", + "outputs": [ + { + "internalType": "uint256", + "name": "reward", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bonusReward", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "incentives", + "outputs": [ + { + "internalType": "uint128", + "name": "totalReward", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusReward", + "type": "uint128" + }, + { + "internalType": "address", + "name": "virtualPoolAddress", + "type": "address" + }, + { + "internalType": "uint24", + "name": "minimalPositionWidth", + "type": "uint24" + }, + { + "internalType": "bool", + "name": "deactivated", + "type": "bool" + }, + { + "internalType": "address", + "name": "pluginAddress", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "isEmergencyWithdrawActivated", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "incentiveId", + "type": "bytes32" + } + ], + "name": "isIncentiveDeactivated", + "outputs": [ + { + "internalType": "bool", + "name": "res", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "nonfungiblePositionManager", + "outputs": [ + { + "internalType": "contract INonfungiblePositionManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "numOfIncentives", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + } + ], + "name": "rewards", + "outputs": [ + { + "internalType": "uint256", + "name": "rewardAmount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "maxRate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "maxRate1", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "minRate0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "minRate1", + "type": "uint128" + } + ], + "name": "setDynamicRateLimits", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "newStatus", + "type": "bool" + } + ], + "name": "setEmergencyWithdrawStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_farmingCenter", + "type": "address" + } + ], + "name": "setFarmingCenterAddress", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint128", + "name": "rewardRate", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "bonusRewardRate", + "type": "uint128" + } + ], + "name": "setRates", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "uint16", + "name": "weight0", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "weight1", + "type": "uint16" + } + ], + "name": "setWeights", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "contract IERC20Minimal", + "name": "rewardToken", + "type": "address" + }, + { + "internalType": "contract IERC20Minimal", + "name": "bonusRewardToken", + "type": "address" + }, + { + "internalType": "contract IAlgebraPool", + "name": "pool", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + } + ], + "internalType": "struct IncentiveKey", + "name": "key", + "type": "tuple" + }, + { + "internalType": "bool", + "name": "isActive", + "type": "bool" + } + ], + "name": "switchDynamicRate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } ] as const; diff --git a/src/components/create-pool/CreatePoolForm/index.tsx b/src/components/create-pool/CreatePoolForm/index.tsx index db67521f..95330297 100644 --- a/src/components/create-pool/CreatePoolForm/index.tsx +++ b/src/components/create-pool/CreatePoolForm/index.tsx @@ -1,37 +1,36 @@ -import { Button } from '@/components/ui/button'; -import { useDerivedSwapInfo, useSwapState } from '@/state/swapStore'; -import { useEffect, useMemo } from 'react'; -import { SwapField } from '@/types/swap-field'; -import { - ADDRESS_ZERO, - INITIAL_POOL_FEE, - NonfungiblePositionManager, - computePoolAddress, -} from '@cryptoalgebra/integral-sdk'; -import { usePrepareAlgebraPositionManagerMulticall } from '@/generated'; -import { useTransitionAwait } from '@/hooks/common/useTransactionAwait'; -import { Address, useContractWrite } from 'wagmi'; -import { useDerivedMintInfo, useMintState } from '@/state/mintStore'; -import Loader from '@/components/common/Loader'; -import { PoolState, usePool } from '@/hooks/pools/usePool'; -import Summary from '../Summary'; -import SelectPair from '../SelectPair'; -import { STABLECOINS } from '@/constants/tokens'; +import { Button } from "@/components/ui/button"; +import { useDerivedSwapInfo, useSwapState } from "@/state/swapStore"; +import { useEffect, useMemo } from "react"; +import { SwapField } from "@/types/swap-field"; +import { ADDRESS_ZERO, INITIAL_POOL_FEE, NonfungiblePositionManager, computePoolAddress } from "@cryptoalgebra/integral-sdk"; +import { usePrepareAlgebraPositionManagerMulticall } from "@/generated"; +import { useTransitionAwait } from "@/hooks/common/useTransactionAwait"; +import { Address, useContractWrite } from "wagmi"; +import { useDerivedMintInfo, useMintState } from "@/state/mintStore"; +import Loader from "@/components/common/Loader"; +import { PoolState, usePool } from "@/hooks/pools/usePool"; +import Summary from "../Summary"; +import SelectPair from "../SelectPair"; +import { STABLECOINS } from "@/constants/tokens"; const CreatePoolForm = () => { const { currencies } = useDerivedSwapInfo(); - const { actions: { selectCurrency } } = useSwapState(); + const { + actions: { selectCurrency }, + } = useSwapState(); - const { startPriceTypedValue, actions: { typeStartPriceInput } } = useMintState() + const { + startPriceTypedValue, + actions: { typeStartPriceInput }, + } = useMintState(); const currencyA = currencies[SwapField.INPUT]; const currencyB = currencies[SwapField.OUTPUT]; const areCurrenciesSelected = currencyA && currencyB; - const isSameToken = - areCurrenciesSelected && currencyA.wrapped.equals(currencyB.wrapped); + const isSameToken = areCurrenciesSelected && currencyA.wrapped.equals(currencyB.wrapped); const poolAddress = areCurrenciesSelected && !isSameToken @@ -64,76 +63,52 @@ const CreatePoolForm = () => { return NonfungiblePositionManager.createCallParameters(mintInfo.pool); }, [mintInfo?.pool]); - const { config: createPoolConfig } = - usePrepareAlgebraPositionManagerMulticall({ - args: Array.isArray(calldata) - ? [calldata as Address[]] - : [[calldata] as Address[]], - value: BigInt(value || 0), - enabled: Boolean(calldata), - }); + const { config: createPoolConfig } = usePrepareAlgebraPositionManagerMulticall({ + args: Array.isArray(calldata) ? [calldata as Address[]] : [[calldata] as Address[]], + value: BigInt(value || 0), + enabled: Boolean(calldata), + }); + const { data: createPoolData, write: createPool } = useContractWrite(createPoolConfig); - const { data: createPoolData, write: createPool } = - useContractWrite(createPoolConfig); - - const { isLoading } = useTransitionAwait( - createPoolData?.hash, - 'Create Pool', - '', - '/pools' - ); + const { isLoading } = useTransitionAwait(createPoolData?.hash, "Create Pool", "", "/pools"); useEffect(() => { - selectCurrency(SwapField.INPUT, undefined) - selectCurrency(SwapField.OUTPUT, undefined) - typeStartPriceInput('') + selectCurrency(SwapField.INPUT, undefined); + selectCurrency(SwapField.OUTPUT, undefined); + typeStartPriceInput(""); return () => { - selectCurrency(SwapField.INPUT, ADDRESS_ZERO) - selectCurrency(SwapField.OUTPUT, STABLECOINS.USDT.address as Account) - typeStartPriceInput('') - } - }, []) + selectCurrency(SwapField.INPUT, ADDRESS_ZERO); + selectCurrency(SwapField.OUTPUT, STABLECOINS.USDT.address); + typeStartPriceInput(""); + }; + }, []); return (
-

- Select Pair -

- - - {areCurrenciesSelected && !isSameToken && !isPoolExists && ( - - )} +

Select Pair

+ + + {areCurrenciesSelected && !isSameToken && !isPoolExists && }
diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index d7e32818..a447856d 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -1,28 +1,19 @@ -import { Address } from 'viem'; +import { Address } from "viem"; -export const POOL_INIT_CODE_HASH: Address = - '0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d'; +export const POOL_INIT_CODE_HASH: Address = "0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d"; -export const ALGEBRA_FACTORY: Address = - '0x32f22b73d887dC91334077BC9C4F9C0879319D44'; +export const ALGEBRA_FACTORY: Address = "0x6AD6A4f233F1E33613e996CCc17409B93fF8bf5f"; -export const ALGEBRA_POOL_DEPLOYER: Address = - '0x23cA0Fb37cbdC80f8317972aBc8ae928866F62a8'; +export const ALGEBRA_POOL_DEPLOYER: Address = "0x69D57B9D705eaD73a5d2f2476C30c55bD755cc2F"; -export const ALGEBRA_POSITION_MANAGER: Address = - '0x39332453FA5000439D146416b83041b00625A537'; +export const ALGEBRA_POSITION_MANAGER: Address = "0x5AeFBA317BAba46EAF98Fd6f381d07673bcA6467"; -export const ALGEBRA_QUOTER: Address = - '0x48d2d05dEfcAC212fAD90085fdeE0f40E3188AaE'; +export const ALGEBRA_QUOTER: Address = "0x38A5C36FA8c8c9E4649b51FCD61810B14e7ce047"; -export const ALGEBRA_QUOTER_V2: Address = - '0xd14cA1EFb707bfE9cD46aD0F5b80A968358a27d8'; +export const ALGEBRA_QUOTER_V2: Address = "0x83D4a9Ea77a4dbA073cD90b30410Ac9F95F93E7C"; -export const ALGEBRA_ROUTER: Address = - '0x5E491EEF515b802Cf0E40053677Cf61048302513'; +export const ALGEBRA_ROUTER: Address = "0xEC250E6856e14A494cb1f0abC61d72348c79F418"; -export const ALGEBRA_ETERNAL_FARMING: Address = - '0x748DddDfb4780168346ac628593dB1b17cF62dA8'; +export const ALGEBRA_ETERNAL_FARMING: Address = "0x61C74d608c427b348cDA28943f86B01964eFFd65"; -export const FARMING_CENTER: Address = - '0x754Fd5fB70efBcDe132F76c5F5A5cb1716b9FFa2'; +export const FARMING_CENTER: Address = "0x31078E06356fFc9a4ae03897355ea4c8326a8deF"; diff --git a/yarn.lock b/yarn.lock index 1bedd71e..85eb9b97 100644 --- a/yarn.lock +++ b/yarn.lock @@ -554,10 +554,10 @@ stream-browserify "^3.0.0" util "^0.12.4" -"@cryptoalgebra/integral-sdk@^0.12.5": - version "0.12.5" - resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.12.5.tgz#3ab56df5794a018231a072ab43c9631b3d8dfd89" - integrity sha512-rq+GMtytxGzLon/C0c0+WyDi+4TYt7FI5pAi71aFnQUjJrN9t/c69fPNHiL3XBup3bSg8/1gIP5/3dCx0/wvPA== +"@cryptoalgebra/integral-sdk@0.11.22": + version "0.11.22" + resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.11.22.tgz#01b367f05461b279a8bd7d26207ddc05f96b8549" + integrity sha512-JHI3QVX/ybYDaegawhnKS83awWBmMLsp/GqIiMLJkX5XKeyix/bYyt1s86Tui7QC7bLbZPUJb+xCJ7t+DxYmqA== dependencies: "@ethersproject/abi" "^5.7.0" "@ethersproject/address" "^5.7.0" From ea36cd75cded84ddf8ae1d5031a0fa59f98e1745 Mon Sep 17 00:00:00 2001 From: damnnou Date: Fri, 17 May 2024 17:19:30 +0300 Subject: [PATCH 9/9] update: holesky redeploy --- .env | 6 ++--- codegen.ts | 4 +-- package.json | 2 +- .../farming/ActiveFarming/index.tsx | 6 ++++- src/constants/addresses.ts | 16 ++++++------ src/hooks/farming/useFarmingRewardRates.ts | 4 +-- src/utils/common/formatAmount.ts | 25 ++++++++++++++++++- yarn.lock | 8 +++--- 8 files changed, 49 insertions(+), 22 deletions(-) diff --git a/.env b/.env index 4907c8a2..670bf7a4 100644 --- a/.env +++ b/.env @@ -1,6 +1,6 @@ -VITE_INFO_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core +VITE_INFO_GRAPH=https://api.studio.thegraph.com/query/50593/holesky-analytics/version/latest VITE_LIMIT_ORDERS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/integral-limit-order VITE_BLOCKS_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks -VITE_FARMING_GRAPH=https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test -VITE_INFURA_RPC=https://ethereum-holesky-rpc.publicnode.com +VITE_FARMING_GRAPH=https://api.studio.thegraph.com/query/50593/holesky-farming/version/latest +VITE_INFURA_RPC=https://holesky.drpc.org VITE_WALLETCONNECT_PROJECT_ID=79c313a96c99edbc26d06cd97bff1126 \ No newline at end of file diff --git a/codegen.ts b/codegen.ts index c7255257..5d3a07f4 100644 --- a/codegen.ts +++ b/codegen.ts @@ -3,9 +3,9 @@ import type { CodegenConfig } from "@graphql-codegen/cli"; const config: CodegenConfig = { overwrite: true, schema: [ - "https://api.thegraph.com/subgraphs/name/iliaazhel/integral-core", + "https://api.studio.thegraph.com/query/50593/holesky-analytics/version/latest", + "https://api.studio.thegraph.com/query/50593/holesky-farming/version/latest", "https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks", - "https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test", ], documents: "src/graphql/queries/!(*.d).{ts,tsx}", generates: { diff --git a/package.json b/package.json index ba3f265a..066303eb 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ }, "dependencies": { "@apollo/client": "^3.8.4", - "@cryptoalgebra/integral-sdk": "0.11.22", + "@cryptoalgebra/integral-sdk": "0.12.6-dev", "@radix-ui/react-avatar": "^1.0.4", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-hover-card": "^1.0.7", diff --git a/src/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 5262c2e7..64183b2e 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -15,6 +15,7 @@ import { useFarmingAPR } from "@/hooks/farming/useFarmingAPR"; import { useFarmingUserTVL } from "@/hooks/farming/useFarmingUserTVL"; import { useFarmingRewardRates } from "@/hooks/farming/useFarmingRewardRates"; import { useFarmingRewardsEarned } from "@/hooks/farming/useFarmingRewardsEarned"; +import { formatAmount, reverseFormatAmount } from "@/utils/common/formatAmount"; interface ActiveFarmingProps { farming: Farming; @@ -101,7 +102,10 @@ const ActiveFarming = ({ farming, deposits, positionsData }: ActiveFarmingProps) <>

- {`${Number(rewardRatePerDay) + Number(bonusRewardRatePerDay)} ${farming.rewardToken.symbol} / day`} + {`${formatAmount( + (reverseFormatAmount(rewardRatePerDay) + reverseFormatAmount(bonusRewardRatePerDay)).toString(), + 4 + )} ${farming.rewardToken.symbol} / day`}

) : ( diff --git a/src/constants/addresses.ts b/src/constants/addresses.ts index a447856d..f0d5288d 100644 --- a/src/constants/addresses.ts +++ b/src/constants/addresses.ts @@ -2,18 +2,18 @@ import { Address } from "viem"; export const POOL_INIT_CODE_HASH: Address = "0xf96d2474815c32e070cd63233f06af5413efc5dcb430aee4ff18cc29007c562d"; -export const ALGEBRA_FACTORY: Address = "0x6AD6A4f233F1E33613e996CCc17409B93fF8bf5f"; +export const ALGEBRA_FACTORY: Address = "0x3490e9f5397c081506471b5680f89975598D3233"; -export const ALGEBRA_POOL_DEPLOYER: Address = "0x69D57B9D705eaD73a5d2f2476C30c55bD755cc2F"; +export const ALGEBRA_POOL_DEPLOYER: Address = "0xc297668be7Bc759944Ee14374821f74329910771"; -export const ALGEBRA_POSITION_MANAGER: Address = "0x5AeFBA317BAba46EAF98Fd6f381d07673bcA6467"; +export const ALGEBRA_POSITION_MANAGER: Address = "0xbd61CFBD63b08Fec49a72028882C6611E7191244"; -export const ALGEBRA_QUOTER: Address = "0x38A5C36FA8c8c9E4649b51FCD61810B14e7ce047"; +export const ALGEBRA_QUOTER: Address = "0xCb682245bD146D59AE9c3fFE280A8Ac085A5FD4D"; -export const ALGEBRA_QUOTER_V2: Address = "0x83D4a9Ea77a4dbA073cD90b30410Ac9F95F93E7C"; +export const ALGEBRA_QUOTER_V2: Address = "0x5764E20EE690A14b004047A15cD7E42C733b0cBD"; -export const ALGEBRA_ROUTER: Address = "0xEC250E6856e14A494cb1f0abC61d72348c79F418"; +export const ALGEBRA_ROUTER: Address = "0xFd1098017D752186Ff8F6Fb9f4Eb6bce512502DF"; -export const ALGEBRA_ETERNAL_FARMING: Address = "0x61C74d608c427b348cDA28943f86B01964eFFd65"; +export const ALGEBRA_ETERNAL_FARMING: Address = "0xb5d5D98d2CB1164d9a8f1A6696FbAfCcf88D0FCe"; -export const FARMING_CENTER: Address = "0x31078E06356fFc9a4ae03897355ea4c8326a8deF"; +export const FARMING_CENTER: Address = "0xA0960ca3D15Aa579A73b49DbbF76615C8e702848"; diff --git a/src/hooks/farming/useFarmingRewardRates.ts b/src/hooks/farming/useFarmingRewardRates.ts index 875f64c8..45c9ff68 100644 --- a/src/hooks/farming/useFarmingRewardRates.ts +++ b/src/hooks/farming/useFarmingRewardRates.ts @@ -15,7 +15,7 @@ export function useFarmingRewardRates(farming: Farming) { const bonusRewardRatePerDay = Number(formatUnits(bonusRewardRate, farming.bonusRewardToken?.decimals)) * 60 * 60 * 24; return { - rewardRatePerDay: formatAmount(rewardRatePerDay.toString(), 2), - bonusRewardRatePerDay: formatAmount(bonusRewardRatePerDay.toString(), 2), + rewardRatePerDay: formatAmount(rewardRatePerDay.toString(), 4), + bonusRewardRatePerDay: formatAmount(bonusRewardRatePerDay.toString(), 4), }; } diff --git a/src/utils/common/formatAmount.ts b/src/utils/common/formatAmount.ts index 5c907733..24cbb3ff 100644 --- a/src/utils/common/formatAmount.ts +++ b/src/utils/common/formatAmount.ts @@ -16,5 +16,28 @@ export function formatAmount(amount: string, decimals = 3): string { if (amountNum < 1000000000000) return formatCurrency.format(Math.floor(amountNum * 100) / 100); - return "∞"; + return "> 1T"; +} + +export function reverseFormatAmount(formattedNumber: string): number { + const suffixes: { [key: string]: number } = { + K: 1e3, + M: 1e6, + B: 1e9, + T: 1e12, + }; + + const suffix = formattedNumber.slice(-1); + const value = parseFloat(formattedNumber.slice(0, -1)); + + if (formattedNumber.startsWith("< ") || formattedNumber.startsWith("> ")) { + const value = parseFloat(formattedNumber.slice(2)); + return value > 0 ? value : 0; + } + + if (suffixes[suffix]) { + return value * suffixes[suffix]; + } else { + return parseFloat(formattedNumber); + } } diff --git a/yarn.lock b/yarn.lock index 85eb9b97..44e22571 100644 --- a/yarn.lock +++ b/yarn.lock @@ -554,10 +554,10 @@ stream-browserify "^3.0.0" util "^0.12.4" -"@cryptoalgebra/integral-sdk@0.11.22": - version "0.11.22" - resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.11.22.tgz#01b367f05461b279a8bd7d26207ddc05f96b8549" - integrity sha512-JHI3QVX/ybYDaegawhnKS83awWBmMLsp/GqIiMLJkX5XKeyix/bYyt1s86Tui7QC7bLbZPUJb+xCJ7t+DxYmqA== +"@cryptoalgebra/integral-sdk@0.12.6-dev": + version "0.12.6-dev" + resolved "https://registry.yarnpkg.com/@cryptoalgebra/integral-sdk/-/integral-sdk-0.12.6-dev.tgz#3070d35585e9e637a4e2951c9f63fb6d810ac9ae" + integrity sha512-K+ii8XH3tkOGLN9iE9xkfgqw1OW1LfEnynymaO71bD5CbhT0g3YB3gnrbm9jOHDy3gzGGp7ueL7MAJi9W4iOfg== dependencies: "@ethersproject/abi" "^5.7.0" "@ethersproject/address" "^5.7.0"