Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add sepolia values to uniswap tests #358

Open
wants to merge 3 commits into
base: development
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 30 additions & 30 deletions test/connectors/uniswap/uniswap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ let mockProvider: typeof MockProvider;

const WETH = new Token(
3,
'0xd0A1E359811322d97991E03f863a0C30C2cF029C',
'0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14',
18,
'WETH'
);

const DAI = new Token(
3,
'0x4f96fe3b7a6cf9725f59d353f723c1bdb64ca6aa',
'0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357',
18,
'DAI'
);

const DAI_WETH_POOL_ADDRESS = '0xBEff876AC507446457C2A6bDA9F7021A97A8547f';
const DAI_WETH_POOL_ADDRESS = '0x122450AE55BD9B74768A128Bda99906351F81827';
const POOL_SQRT_RATIO_START = encodeSqrtRatioX96(100e6, 100e18);
const POOL_TICK_CURRENT = TickMath.getTickAtSqrtRatio(POOL_SQRT_RATIO_START);
const POOL_LIQUIDITY = 0;
Expand All @@ -50,7 +50,7 @@ const DAI_WETH_POOL = new UniswapV3Pool(
);

beforeAll(async () => {
ethereum = Ethereum.getInstance('goerli');
ethereum = Ethereum.getInstance('sepolia');
patchEVMNonceManager(ethereum.nonceManager);
await ethereum.init();
});
Expand Down Expand Up @@ -112,7 +112,7 @@ const patchTrade = (_key: string, error?: Error) => {
route: [],
blockNumber: BigNumber.from(5000),
};
}
}
});
};

Expand All @@ -125,20 +125,20 @@ const patchMockProvider = () => {
mockProvider.stub(FACTORY_ADDRESS, 'getPool', DAI_WETH_POOL_ADDRESS);

mockProvider.setMockContract(
UniswapConfig.config.quoterContractAddress('ethereum', 'goerli'),
UniswapConfig.config.quoterContractAddress('ethereum', 'sepolia'),
require('@uniswap/swap-router-contracts/artifacts/contracts/lens/QuoterV2.sol/QuoterV2.json')
.abi
);
mockProvider.stub(
UniswapConfig.config.quoterContractAddress('ethereum', 'goerli'),
UniswapConfig.config.quoterContractAddress('ethereum', 'sepolia'),
'quoteExactInputSingle',
/* amountOut */ 1,
/* sqrtPriceX96After */ 0,
/* initializedTicksCrossed */ 0,
/* gasEstimate */ 0
);
mockProvider.stub(
UniswapConfig.config.quoterContractAddress('ethereum', 'goerli'),
UniswapConfig.config.quoterContractAddress('ethereum', 'sepolia'),
'quoteExactOutputSingle',
/* amountIn */ 1,
/* sqrtPriceX96After */ 0,
Expand Down Expand Up @@ -183,7 +183,7 @@ const useRouter = async () => {
config.useRouter = true;

patch(Uniswap, '_instances', () => ({}));
uniswap = Uniswap.getInstance('ethereum', 'goerli');
uniswap = Uniswap.getInstance('ethereum', 'sepolia');
await uniswap.init();
};

Expand All @@ -193,7 +193,7 @@ const useQouter = async () => {
config.feeTier = 'MEDIUM';

patch(Uniswap, '_instances', () => ({}));
uniswap = Uniswap.getInstance('ethereum', 'goerli');
uniswap = Uniswap.getInstance('ethereum', 'sepolia');
await uniswap.init();

mockProvider = new MockProvider();
Expand Down Expand Up @@ -232,18 +232,18 @@ describe('verify Uniswap estimateSellTrade', () => {
await useQouter();
});

// it('Should return an ExpectedTrade when available', async () => {
// patchGetPool(DAI_WETH_POOL_ADDRESS);
it('Should return an ExpectedTrade when available', async () => {
patchGetPool(DAI_WETH_POOL_ADDRESS);

// const expectedTrade = await uniswap.estimateSellTrade(
// WETH,
// DAI,
// BigNumber.from(1)
// );
const expectedTrade = await uniswap.estimateSellTrade(
WETH,
DAI,
BigNumber.from(1)
);

// expect(expectedTrade).toHaveProperty('trade');
// expect(expectedTrade).toHaveProperty('expectedAmount');
// });
expect(expectedTrade).toHaveProperty('trade');
expect(expectedTrade).toHaveProperty('expectedAmount');
});

it('Should throw an error if no pair is available', async () => {
patchGetPool(constants.AddressZero);
Expand Down Expand Up @@ -287,18 +287,18 @@ describe('verify Uniswap estimateBuyTrade', () => {
await useQouter();
});

// it('Should return an ExpectedTrade when available', async () => {
// patchGetPool(DAI_WETH_POOL_ADDRESS);
it('Should return an ExpectedTrade when available', async () => {
patchGetPool(DAI_WETH_POOL_ADDRESS);

// const expectedTrade = await uniswap.estimateBuyTrade(
// WETH,
// DAI,
// BigNumber.from(1)
// );
const expectedTrade = await uniswap.estimateBuyTrade(
WETH,
DAI,
BigNumber.from(1)
);

// expect(expectedTrade).toHaveProperty('trade');
// expect(expectedTrade).toHaveProperty('expectedAmount');
// });
expect(expectedTrade).toHaveProperty('trade');
expect(expectedTrade).toHaveProperty('expectedAmount');
});

it('Should throw an error if no pair is available', async () => {
patchGetPool(constants.AddressZero);
Expand Down
Loading