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 a6ff6e8d..5d3a07f4 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/integral-core', - 'https://api.thegraph.com/subgraphs/name/iliaazhel/goerli-blocks', - 'https://api.thegraph.com/subgraphs/name/iliaazhel/farming-test', + "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", ], - 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 482aa8b7..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/abis/algebraVirtualPool.ts b/src/abis/algebraVirtualPool.ts new file mode 100644 index 00000000..eb9eba75 --- /dev/null +++ b/src/abis/algebraVirtualPool.ts @@ -0,0 +1,542 @@ +export const algebraVirtualPoolABI = [ + { + 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 254a855c..2f644204 100644 --- a/src/abis/farming/algebraEternalFarming.ts +++ b/src/abis/farming/algebraEternalFarming.ts @@ -1,1141 +1,1348 @@ export const algebraEternalFarmingABI = [ - { - inputs: [ - { - internalType: 'contract IAlgebraPoolDeployer', - name: '_deployer', - type: 'address', - }, - { - internalType: 'contract INonfungiblePositionManager', - name: '_nonfungiblePositionManager', - type: 'address', - }, + { + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - name: 'FarmEntered', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'address', - name: 'farmingCenter', - type: 'address', - }, + "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" + } ], - name: 'FarmingCenter', - type: 'event', - }, - { - anonymous: false, - inputs: [ - { - indexed: true, - internalType: 'bytes32', - name: 'incentiveId', - type: 'bytes32', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - 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', - }, + "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" + } ], - name: 'RewardsRatesChanged', - type: 'event', - }, - { - inputs: [], - name: 'FARMINGS_ADMINISTRATOR_ROLE', - outputs: [ - { - internalType: 'bytes32', - name: '', - type: 'bytes32', - }, + "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" + } ], - 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: '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', - }, + "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/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/components/farming/ActiveFarming/index.tsx b/src/components/farming/ActiveFarming/index.tsx index 3db4a60a..64183b2e 100644 --- a/src/components/farming/ActiveFarming/index.tsx +++ b/src/components/farming/ActiveFarming/index.tsx @@ -1,21 +1,21 @@ -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 { 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"; +import { formatAmount, reverseFormatAmount } from "@/utils/common/formatAmount"; interface ActiveFarmingProps { farming: Farming; @@ -23,82 +23,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 userTVL = useFarmingUserTVL({ deposits, positionsData }); - const formattedBonusRewardEarned = Number( - formatUnits(bonusRewardEarned, farming.bonusRewardToken?.decimals) - ); - - const rewardEarnedUSD = useRewardEarnedUSD({ - token: farming.rewardToken, - reward: rewardEarned, - }); + const { rewardRatePerDay, bonusRewardRatePerDay } = useFarmingRewardRates(farming); - const bonusRewardEarnedUSD = useRewardEarnedUSD({ - token: farming.bonusRewardToken, - reward: bonusRewardEarned, + const { rewardEarned, bonusRewardEarned, totalEarned, totalEarnedUSD, refetch } = useFarmingRewardsEarned({ + farming, + deposits, }); - const farmingRewards = (rewardEarnedUSD + bonusRewardEarnedUSD).toFixed(4); - const rewardTokenCurrency = useCurrency(farming.farming.rewardToken); - const bonusRewardTokenCurrency = useCurrency( - farming.farming.bonusRewardToken - ); - - 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 bonusRewardTokenCurrency = useCurrency(farming.farming.bonusRewardToken); - const rewardRatePerDay = - Number( - formatUnits( - farming.farming.rewardRate, - farming.rewardToken.decimals - ) - ) * - 60 * - 60 * - 24; - - const bonusRewardRatePerDay = - Number( - formatUnits( - farming.farming.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( { @@ -117,33 +61,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 (
@@ -154,32 +74,24 @@ const ActiveFarming = ({

{APR}%

-

${formattedTVL}

+

${userTVL}

-

${farmingRewards}

+

${totalEarnedUSD}

@@ -188,63 +100,24 @@ const ActiveFarming = ({
{isSameReward ? ( <> - +

- {`${( - rewardRatePerDay + - bonusRewardRatePerDay - ).toFixed(2)} ${ - farming.rewardToken.symbol - } / day`} + {`${formatAmount( + (reverseFormatAmount(rewardRatePerDay) + reverseFormatAmount(bonusRewardRatePerDay)).toString(), + 4 + )} ${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`}

)}
@@ -254,16 +127,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/constants/addresses.ts b/src/constants/addresses.ts index 85d4b343..f0d5288d 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 = - '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 = - '0x49a390a3dFd2d01389f799965F3af5961f87d228'; +export const ALGEBRA_ETERNAL_FARMING: Address = "0xb5d5D98d2CB1164d9a8f1A6696FbAfCcf88D0FCe"; -export const FARMING_CENTER: Address = - '0x37A4950b4ea0C46596404895c5027B088B0e70e7'; +export const FARMING_CENTER: Address = "0xA0960ca3D15Aa579A73b49DbbF76615C8e702848"; 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..98429d40 --- /dev/null +++ b/src/hooks/farming/useFarmingDepositRewardsEarned.ts @@ -0,0 +1,70 @@ +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"; +import { formatAmount } from "@/utils/common/formatAmount"; + +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, + }, + }); + + 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: formatAmount(formattedRewardEarned.toString(), 2), + bonusRewardEarned: formatAmount(formattedBonusRewardEarned.toString(), 2), + rewardEarnedUSD, + bonusRewardEarnedUSD, + totalEarned: formatAmount(formattedTotalEarned.toString(), 2), + totalEarnedUSD, + refetch: fetchDepositRewards, + }; +} diff --git a/src/hooks/farming/useFarmingRewardRates.ts b/src/hooks/farming/useFarmingRewardRates.ts new file mode 100644 index 00000000..45c9ff68 --- /dev/null +++ b/src/hooks/farming/useFarmingRewardRates.ts @@ -0,0 +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 bonusRewardRatePerDay = Number(formatUnits(bonusRewardRate, farming.bonusRewardToken?.decimals)) * 60 * 60 * 24; + + return { + rewardRatePerDay: formatAmount(rewardRatePerDay.toString(), 4), + bonusRewardRatePerDay: formatAmount(bonusRewardRatePerDay.toString(), 4), + }; +} diff --git a/src/hooks/farming/useFarmingRewardsEarned.ts b/src/hooks/farming/useFarmingRewardsEarned.ts new file mode 100644 index 00000000..b1770f9e --- /dev/null +++ b/src/hooks/farming/useFarmingRewardsEarned.ts @@ -0,0 +1,71 @@ +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"; +import { formatAmount } from "@/utils/common/formatAmount"; + +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: formatAmount(formattedRewardEarned.toString(), 2), + bonusRewardEarned: formatAmount(formattedBonusRewardEarned.toString(), 2), + totalEarned: formatAmount(formattedTotalEarned.toString(), 2), + totalEarnedUSD, + refetch: fetchAllRewards, + }; +} 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]); diff --git a/src/utils/common/formatAmount.ts b/src/utils/common/formatAmount.ts new file mode 100644 index 00000000..24cbb3ff --- /dev/null +++ b/src/utils/common/formatAmount.ts @@ -0,0 +1,43 @@ +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 "> 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/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..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"