Skip to content

Commit

Permalink
fix: return contract address in quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmellis committed Jan 11, 2024
1 parent 6bdf681 commit a819085
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 33 deletions.
10 changes: 3 additions & 7 deletions packages/trade/src/pools/createVault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import type {
Signer,
Transaction,
} from '@nftx/types';
import { getChainConstant, getContract } from '@nftx/utils';
import { CREATE_VAULT_ZAP } from '@nftx/constants';
import { getContract } from '@nftx/utils';

type GetContract = typeof getContract;

Expand All @@ -23,18 +22,15 @@ const makeCreateVault = ({
getContract: GetContract;
}): ((args: Args) => Promise<Transaction>) =>
async function createVault({
network,
signer,
provider,
quote: {
methodParameters: { params, value },
methodParameters: { params, value, contractAddress },
},
}: Args) {
const address = getChainConstant(CREATE_VAULT_ZAP, network);

const contract = getContract({
abi: CreateVaultZap,
address,
address: contractAddress,
provider,
signer,
});
Expand Down
8 changes: 3 additions & 5 deletions packages/trade/src/positions/createInventoryPosition.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import { InventoryStaking } from '@nftx/abi';
import config from '@nftx/config';
import { INVENTORY_STAKING } from '@nftx/constants';
import {
CreateInventoryPositionQuote,
Permit2Quote,
Provider,
Signer,
} from '@nftx/types';
import { getChainConstant, getContract } from '@nftx/utils';
import { getContract } from '@nftx/utils';

const createInventoryPosition = ({
provider,
Expand All @@ -19,10 +17,10 @@ const createInventoryPosition = ({
vaultId,
vToken,
usePermit2,
contractAddress,
},
},
signer,
network = config.network,
permit2,
}: {
network?: number;
Expand All @@ -32,7 +30,7 @@ const createInventoryPosition = ({
permit2?: Permit2Quote;
}) => {
const contract = getContract({
address: getChainConstant(INVENTORY_STAKING, network),
address: contractAddress,
provider,
abi: InventoryStaking,
signer,
Expand Down
6 changes: 2 additions & 4 deletions packages/trade/src/positions/createLiquidityPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getChainConstant, getContract } from '@nftx/utils';

const createLiquidityPosition = ({
quote: {
methodParameters: { params, value, usePermit2 },
methodParameters: { params, value, usePermit2, contractAddress },
},
provider,
signer,
Expand All @@ -24,10 +24,8 @@ const createLiquidityPosition = ({
signer: Signer;
permit2?: Permit2Quote;
}) => {
const address = getChainConstant(POOL_ROUTER, network);

const contract = getContract({
address: address,
address: contractAddress,
abi: PoolRouter,
provider,
signer,
Expand Down
9 changes: 3 additions & 6 deletions packages/trade/src/positions/increaseLiquidity.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import { PoolRouter } from '@nftx/abi';
import config from '@nftx/config';
import { POOL_ROUTER } from '@nftx/constants';
import {
IncreaseLiquidityQuote,
Permit2Quote,
Provider,
Signer,
} from '@nftx/types';
import { getChainConstant, getContract } from '@nftx/utils';
import { getContract } from '@nftx/utils';

const increaseLiquidity = ({
provider,
quote: {
methodParameters: { params, value, usePermit2 },
methodParameters: { params, value, usePermit2, contractAddress },
},
signer,
network = config.network,
permit2,
}: {
network?: number;
Expand All @@ -25,7 +22,7 @@ const increaseLiquidity = ({
permit2?: Permit2Quote;
}) => {
const contract = getContract({
address: getChainConstant(POOL_ROUTER, network),
address: contractAddress,
abi: PoolRouter,
provider,
signer,
Expand Down
8 changes: 3 additions & 5 deletions packages/trade/src/positions/withdrawInventory.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { InventoryStaking } from '@nftx/abi';
import config from '@nftx/config';
import { INVENTORY_STAKING } from '@nftx/constants';
import { Provider, Signer, WithdrawInventoryQuote } from '@nftx/types';
import { getChainConstant, getContract } from '@nftx/utils';
import { getContract } from '@nftx/utils';

const withdrawInventory = ({
provider,
Expand All @@ -13,10 +11,10 @@ const withdrawInventory = ({
vTokenPremiumLimit,
vTokenShares,
value,
contractAddress,
},
},
signer,
network = config.network,
}: {
network?: number;
quote: WithdrawInventoryQuote;
Expand All @@ -25,7 +23,7 @@ const withdrawInventory = ({
}) => {
const contract = getContract({
abi: InventoryStaking,
address: getChainConstant(INVENTORY_STAKING, network),
address: contractAddress,
provider,
signer,
});
Expand Down
9 changes: 3 additions & 6 deletions packages/trade/src/positions/withdrawLiquidity.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { PoolRouter } from '@nftx/abi';
import config from '@nftx/config';
import { POOL_ROUTER } from '@nftx/constants';
import { Provider, Signer, WithdrawLiquidityQuote } from '@nftx/types';
import { getChainConstant, getContract } from '@nftx/utils';
import { getContract } from '@nftx/utils';

const withdrawLiquidity = ({
network = config.network,
provider,
quote: {
methodParameters: { params, value },
methodParameters: { params, value, contractAddress },
},
signer,
}: {
Expand All @@ -19,7 +16,7 @@ const withdrawLiquidity = ({
}) => {
const contract = getContract({
abi: PoolRouter,
address: getChainConstant(POOL_ROUTER, network),
address: contractAddress,
provider,
signer,
});
Expand Down
6 changes: 6 additions & 0 deletions packages/types/src/quotes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export type CreateVaultQuote = {
};
};
value: bigint;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};
Expand All @@ -80,6 +81,7 @@ export type WithdrawLiquidityQuote = {
vTokenPremiumLimit: bigint;
};
value: bigint;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};
Expand All @@ -98,6 +100,7 @@ export type WithdrawInventoryQuote = {
nftIds: bigint[];
vTokenPremiumLimit: bigint;
value: bigint;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};
Expand All @@ -118,6 +121,7 @@ export type CreateInventoryPositionQuote = {
nftAmounts: bigint[];
userAddress: Address;
usePermit2: boolean;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};
Expand Down Expand Up @@ -159,6 +163,7 @@ export type CreateLiquidityPositionQuote = {
recipient: Address;
};
usePermit2: boolean;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};
Expand Down Expand Up @@ -192,6 +197,7 @@ export type IncreaseLiquidityQuote = {
positionId: bigint;
};
usePermit2: boolean;
contractAddress: Address;
};
approveContracts: ApproveContract[];
};

0 comments on commit a819085

Please sign in to comment.