From 83fb739be5e38ce72dceadc59a2a2254a570a21f Mon Sep 17 00:00:00 2001 From: Jack Ellis Date: Thu, 11 Jan 2024 14:09:42 +0000 Subject: [PATCH] fix: store pool router used to create position --- .../fetchLiquidityPositions/fetchPositionsSet.ts | 2 +- .../fetchLiquidityPositions/getManager.ts | 15 ++++++++++++--- .../fetchLiquidityPositions/transformPosition.ts | 3 ++- packages/queue/src/constants.ts | 2 +- packages/types/src/positions.ts | 2 ++ 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/core/src/positions/fetchLiquidityPositions/fetchPositionsSet.ts b/packages/core/src/positions/fetchLiquidityPositions/fetchPositionsSet.ts index 0d17102..a57026a 100644 --- a/packages/core/src/positions/fetchLiquidityPositions/fetchPositionsSet.ts +++ b/packages/core/src/positions/fetchLiquidityPositions/fetchPositionsSet.ts @@ -78,7 +78,7 @@ export const makeFetchPositionsSet = const [claimable0, claimable1] = await fetchClaimableAmount({ tokenId: position.tokenId as TokenId, provider, - manager: getManager(network, position.timestampOpened), + manager: getManager(network, position.timestampOpened).manager, }); return transformPosition({ network, diff --git a/packages/core/src/positions/fetchLiquidityPositions/getManager.ts b/packages/core/src/positions/fetchLiquidityPositions/getManager.ts index 9d55749..d894d98 100644 --- a/packages/core/src/positions/fetchLiquidityPositions/getManager.ts +++ b/packages/core/src/positions/fetchLiquidityPositions/getManager.ts @@ -1,14 +1,23 @@ -import { NONFUNGIBLE_POSITION_MANAGER, Network } from '@nftx/constants'; +import { + NONFUNGIBLE_POSITION_MANAGER, + Network, + POOL_ROUTER, +} from '@nftx/constants'; import { getChainConstant } from '@nftx/utils'; const getManager = (network: number, timestampOpened: string) => { const lastTimeOldContractUsed = 1704206700; const timestamp = Number(timestampOpened); + + let manager = getChainConstant(NONFUNGIBLE_POSITION_MANAGER, network); + let poolRouter = getChainConstant(POOL_ROUTER, network); + // If older than this, it's the old contract if (timestamp <= lastTimeOldContractUsed && network === Network.Sepolia) { - return '0x55bdc76262b1e6e791d0636a0bc61cee23cdfa87'; + manager = '0x55bdc76262b1e6e791d0636a0bc61cee23cdfa87'; + poolRouter = '0xD36ece08F76c50EC3F01db65BBc5Ef5Aa5fbE849'; } - return getChainConstant(NONFUNGIBLE_POSITION_MANAGER, network); + return { manager, poolRouter }; }; export default getManager; diff --git a/packages/core/src/positions/fetchLiquidityPositions/transformPosition.ts b/packages/core/src/positions/fetchLiquidityPositions/transformPosition.ts index 626b354..b023a8d 100644 --- a/packages/core/src/positions/fetchLiquidityPositions/transformPosition.ts +++ b/packages/core/src/positions/fetchLiquidityPositions/transformPosition.ts @@ -67,7 +67,7 @@ const transformPosition = ({ // TODO: get this from... somwhere? const lifetimeRewards = Zero; - const manager = getManager(network, position.timestampOpened); + const { manager, poolRouter } = getManager(network, position.timestampOpened); return { id: position.id as Address, @@ -94,6 +94,7 @@ const transformPosition = ({ initialValue: value, lockedUntil, manager, + poolRouter, }; }; diff --git a/packages/queue/src/constants.ts b/packages/queue/src/constants.ts index 9b4a769..085910f 100644 --- a/packages/queue/src/constants.ts +++ b/packages/queue/src/constants.ts @@ -3,7 +3,7 @@ import { Network } from '@nftx/constants'; export const BULLMQ_REDIS_URI = process.env.BULLMQ_REDIS_URI || ''; if (!BULLMQ_REDIS_URI) { - throw new Error('MULLMQ_REDIS_URI environment variable is not set'); + throw new Error('BULLMQ_REDIS_URI environment variable is not set'); } export const NETWORK_QUEUE_NAMES = { diff --git a/packages/types/src/positions.ts b/packages/types/src/positions.ts index 32b510d..a218410 100644 --- a/packages/types/src/positions.ts +++ b/packages/types/src/positions.ts @@ -43,6 +43,8 @@ export type LiquidityPosition = { lockedUntil: number; /** The address of the manager contract for this position */ manager: Address; + /** The pool router for this position */ + poolRouter: Address; }; /** A user's Inventory Position, essentially a single xNFT */