Skip to content

Commit

Permalink
fix: store pool router used to create position
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmellis committed Jan 11, 2024
1 parent a1e12dc commit 83fb739
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
15 changes: 12 additions & 3 deletions packages/core/src/positions/fetchLiquidityPositions/getManager.ts
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -94,6 +94,7 @@ const transformPosition = ({
initialValue: value,
lockedUntil,
manager,
poolRouter,
};
};

Expand Down
2 changes: 1 addition & 1 deletion packages/queue/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/positions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 83fb739

Please sign in to comment.