Skip to content

Commit

Permalink
add sepolia v4 1 eth -> usdc quote test
Browse files Browse the repository at this point in the history
  • Loading branch information
jsy1218 committed Oct 15, 2024
1 parent 0068562 commit e6c0482
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions test/integ/routers/alpha-router/alpha-router.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
DAI_ON,
EthEstimateGasSimulator,
FallbackTenderlySimulator,
getApplicableV4FeesTickspacingsHooks,
ID_TO_NETWORK_NAME,
ID_TO_PROVIDER,
MethodParameters,
Expand Down Expand Up @@ -3599,13 +3600,27 @@ describe('quote for other networks', () => {
multicall2Provider,
v4SubgraphProvider,
simulator,
v4PoolParams: getApplicableV4FeesTickspacingsHooks(chain).concat(
[
[500, 10, '0x0000000000000000000000000000000000000020'],
[1500, 30, '0x0000000000000000000000000000000000000020'],
[3000, 60, '0x0000000000000000000000000000000000000020'],
]
),
});
} else {
alphaRouter = new AlphaRouter({
chainId: chain,
provider,
multicall2Provider,
simulator,
v4PoolParams: getApplicableV4FeesTickspacingsHooks(chain).concat(
[
[500, 10, '0x0000000000000000000000000000000000000020'],
[1500, 30, '0x0000000000000000000000000000000000000020'],
[3000, 60, '0x0000000000000000000000000000000000000020'],
]
),
});
}
});
Expand Down Expand Up @@ -3650,7 +3665,7 @@ describe('quote for other networks', () => {

const tokenIn = wrappedNative;
const tokenOut = erc1;
const amount = ChainId.ASTROCHAIN_SEPOLIA ?
const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ?
tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.001', tokenIn):
parseAmount('0.001', tokenOut) :
Expand Down Expand Up @@ -3717,7 +3732,7 @@ describe('quote for other networks', () => {

// Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount
const exactOutAmount = '1';
const amount = ChainId.ASTROCHAIN_SEPOLIA ?
const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ?
tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.001', tokenIn):
parseAmount('0.001', tokenOut) :
Expand Down Expand Up @@ -3765,12 +3780,9 @@ describe('quote for other networks', () => {
? tradeType == TradeType.EXACT_INPUT
? parseAmount('10', tokenIn)
: parseAmount('10', tokenOut)
: (chain !== ChainId.SEPOLIA ? tradeType == TradeType.EXACT_INPUT
: tradeType == TradeType.EXACT_INPUT
? parseAmount('1', tokenIn)
: parseAmount('1', tokenOut) :
tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.00000000000001', tokenIn):
parseAmount('0.000001', tokenOut));
: parseAmount('1', tokenOut);

const swap = await alphaRouter.route(
amount,
Expand All @@ -3796,9 +3808,12 @@ describe('quote for other networks', () => {
const tokenIn = USDC_NATIVE_SEPOLIA;
const tokenOut = nativeOnChain(chain);

// as of now, in sepolia v4, v4 pools having > 1eth is only the ETH/USDC pools with hook address 0x0000000000000000000000000000000000000020
// this means if we try an exact in 1 ETH -> USDC quote against v4 sepolia, the only way is to route through v4 ETH/USDC pools with hook address 0x0000000000000000000000000000000000000020
// this validates that the getApplicableV4FeesTickspacingsHooks along with the hardcoded fees + tickspacings + hook address 0x0000000000000000000000000000000000000020 are working as expected
const amount = tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.000001', tokenIn):
parseAmount('0.00000000000001', tokenOut);
parseAmount('1', tokenIn)
: parseAmount('1', tokenOut);

const swap = await alphaRouter.route(
amount,
Expand Down Expand Up @@ -3827,7 +3842,7 @@ describe('quote for other networks', () => {

// Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount
const exactOutAmount = '1';
const amount = ChainId.ASTROCHAIN_SEPOLIA ?
const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ?
tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.001', tokenIn):
parseAmount('0.001', tokenOut) :
Expand Down Expand Up @@ -3873,7 +3888,7 @@ describe('quote for other networks', () => {

// Current WETH/USDB pool (https://blastscan.io/address/0xf52b4b69123cbcf07798ae8265642793b2e8990c) has low WETH amount
const exactOutAmount = chain === ChainId.BLAST ? '0.002' : '1';
const amount = ChainId.ASTROCHAIN_SEPOLIA ?
const amount = chain === ChainId.ASTROCHAIN_SEPOLIA ?
tradeType == TradeType.EXACT_INPUT ?
parseAmount('0.001', tokenIn):
parseAmount('0.001', tokenOut) :
Expand Down

0 comments on commit e6c0482

Please sign in to comment.