From fde745e37cde57232be0e68aa46f2d127e559152 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 24 Jul 2024 15:42:41 +0800 Subject: [PATCH 1/2] fix: use common token list instead of using test-helper --- .../balancer-v2/logic.flash-loan.test.ts | 3 +- src/logics/compound-v2/logic.repay.test.ts | 9 ++-- src/logics/compound-v2/logic.supply.test.ts | 17 +++---- src/logics/compound-v2/logic.withdraw.test.ts | 17 +++---- .../paraswap-v5/logic.swap-token.test.ts | 13 +++-- src/logics/permit2/logic.pull-token.test.ts | 3 +- .../uniswap-v3/logic.swap-token.test.ts | 49 +++++++++---------- src/logics/utility/logic.send-token.test.ts | 13 +++-- .../logic.wrapped-native-token.test.ts | 19 ++++--- src/logics/zeroex-v4/logic.swap-token.test.ts | 27 +++++----- 10 files changed, 80 insertions(+), 90 deletions(-) diff --git a/src/logics/balancer-v2/logic.flash-loan.test.ts b/src/logics/balancer-v2/logic.flash-loan.test.ts index c22cecc4..004e1f34 100644 --- a/src/logics/balancer-v2/logic.flash-loan.test.ts +++ b/src/logics/balancer-v2/logic.flash-loan.test.ts @@ -5,7 +5,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import { expect } from 'chai'; import { getContractAddress } from './configs'; -import { mainnetTokens } from '@protocolink/test-helpers'; describe('BalancerV2 FlashLoanLogic', function () { context('Test getTokenList', async function () { @@ -26,7 +25,7 @@ describe('BalancerV2 FlashLoanLogic', function () { const testCases: LogicTestCase[] = [ { fields: { - loans: new common.TokenAmounts([mainnetTokens.WETH, '1'], [mainnetTokens.USDC, '1']), + loans: new common.TokenAmounts([common.mainnetTokens.WETH, '1'], [common.mainnetTokens.USDC, '1']), params: '0x', }, }, diff --git a/src/logics/compound-v2/logic.repay.test.ts b/src/logics/compound-v2/logic.repay.test.ts index 7853eea5..b9fb9927 100644 --- a/src/logics/compound-v2/logic.repay.test.ts +++ b/src/logics/compound-v2/logic.repay.test.ts @@ -5,7 +5,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; import { toCToken } from './configs'; describe('CompoundV2 RepayLogic', function () { @@ -29,26 +28,26 @@ describe('CompoundV2 RepayLogic', function () { { fields: { borrower: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', - input: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), }, }, { fields: { borrower: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', - input: new common.TokenAmount(mainnetTokens.USDC, '1'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), }, }, { fields: { borrower: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', - input: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), balanceBps: 5000, }, }, { fields: { borrower: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', - input: new common.TokenAmount(mainnetTokens.USDC, '1'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), balanceBps: 5000, }, }, diff --git a/src/logics/compound-v2/logic.supply.test.ts b/src/logics/compound-v2/logic.supply.test.ts index 157dff49..e98353d1 100644 --- a/src/logics/compound-v2/logic.supply.test.ts +++ b/src/logics/compound-v2/logic.supply.test.ts @@ -5,7 +5,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; import { toCToken } from './configs'; describe('CompoundV2 SupplyLogic', function () { @@ -28,27 +27,27 @@ describe('CompoundV2 SupplyLogic', function () { const testCases: LogicTestCase[] = [ { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(toCToken(mainnetTokens.ETH), '0'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(toCToken(common.mainnetTokens.ETH), '0'), }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(toCToken(mainnetTokens.USDC), '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(toCToken(common.mainnetTokens.USDC), '0'), }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(toCToken(mainnetTokens.ETH), '0'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(toCToken(common.mainnetTokens.ETH), '0'), balanceBps: 5000, }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(toCToken(mainnetTokens.USDC), '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(toCToken(common.mainnetTokens.USDC), '0'), balanceBps: 5000, }, }, diff --git a/src/logics/compound-v2/logic.withdraw.test.ts b/src/logics/compound-v2/logic.withdraw.test.ts index 78165956..0b53fd73 100644 --- a/src/logics/compound-v2/logic.withdraw.test.ts +++ b/src/logics/compound-v2/logic.withdraw.test.ts @@ -5,7 +5,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; import { toCToken } from './configs'; describe('CompoundV2 WithdrawLogic', function () { @@ -27,27 +26,27 @@ describe('CompoundV2 WithdrawLogic', function () { const testCases: LogicTestCase[] = [ { fields: { - input: new common.TokenAmount(toCToken(mainnetTokens.ETH), '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '0'), + input: new common.TokenAmount(toCToken(common.mainnetTokens.ETH), '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0'), }, }, { fields: { - input: new common.TokenAmount(toCToken(mainnetTokens.USDC), '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '0'), + input: new common.TokenAmount(toCToken(common.mainnetTokens.USDC), '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '0'), }, }, { fields: { - input: new common.TokenAmount(toCToken(mainnetTokens.ETH), '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '0'), + input: new common.TokenAmount(toCToken(common.mainnetTokens.ETH), '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0'), balanceBps: 5000, }, }, { fields: { - input: new common.TokenAmount(toCToken(mainnetTokens.USDC), '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '0'), + input: new common.TokenAmount(toCToken(common.mainnetTokens.USDC), '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '0'), balanceBps: 5000, }, }, diff --git a/src/logics/paraswap-v5/logic.swap-token.test.ts b/src/logics/paraswap-v5/logic.swap-token.test.ts index fab79392..3f857361 100644 --- a/src/logics/paraswap-v5/logic.swap-token.test.ts +++ b/src/logics/paraswap-v5/logic.swap-token.test.ts @@ -5,7 +5,6 @@ import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; import { getTokenListUrls, getTokenTransferProxyAddress } from './configs'; -import { mainnetTokens } from '@protocolink/test-helpers'; describe('ParaswapV5 SwapTokenLogic', function () { context('Test getTokenListUrls', function () { @@ -32,8 +31,8 @@ describe('ParaswapV5 SwapTokenLogic', function () { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '0'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '0'), slippage: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -41,8 +40,8 @@ describe('ParaswapV5 SwapTokenLogic', function () { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0'), slippage: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -50,8 +49,8 @@ describe('ParaswapV5 SwapTokenLogic', function () { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(mainnetTokens.DAI, '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '0'), slippage: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, diff --git a/src/logics/permit2/logic.pull-token.test.ts b/src/logics/permit2/logic.pull-token.test.ts index 54cfee52..8c9129a7 100644 --- a/src/logics/permit2/logic.pull-token.test.ts +++ b/src/logics/permit2/logic.pull-token.test.ts @@ -4,7 +4,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; describe('Permit2 PullTokenLogic', function () { context('Test getTokenList', async function () { @@ -26,7 +25,7 @@ describe('Permit2 PullTokenLogic', function () { const iface = routerKit.permit2Iface; const testCases: LogicTestCase[] = [ - { fields: { input: new common.TokenAmount(mainnetTokens.WETH, '1') } }, + { fields: { input: new common.TokenAmount(common.mainnetTokens.WETH, '1') } }, ]; testCases.forEach(({ fields }, i) => { diff --git a/src/logics/uniswap-v3/logic.swap-token.test.ts b/src/logics/uniswap-v3/logic.swap-token.test.ts index 0f9a58e3..0f3ec78e 100644 --- a/src/logics/uniswap-v3/logic.swap-token.test.ts +++ b/src/logics/uniswap-v3/logic.swap-token.test.ts @@ -5,7 +5,6 @@ import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; import { getConfig } from './configs'; -import { mainnetTokens } from '@protocolink/test-helpers'; import * as univ3 from 'src/modules/univ3'; describe('UniswapV3 SwapTokenLogic', function () { @@ -29,8 +28,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '1661.098116'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '1661.098116'), fee: 500, slippage: 100, }, @@ -39,8 +38,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '1661.098116'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '1661.098116'), path: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', slippage: 100, }, @@ -49,8 +48,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), fee: 500, slippage: 100, }, @@ -59,8 +58,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), path: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', slippage: 100, }, @@ -69,8 +68,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.DAI, '1000'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '1000'), fee: 500, slippage: 100, }, @@ -79,8 +78,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactIn, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.DAI, '1000'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '1000'), path: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f46b175474e89094c44da98b954eedeac495271d0f', slippage: 100, }, @@ -89,8 +88,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), - output: new common.TokenAmount(mainnetTokens.USDC, '1000'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), fee: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -98,8 +97,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), - output: new common.TokenAmount(mainnetTokens.USDC, '1000'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), path: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc20001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f4a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -107,8 +106,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), fee: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -116,8 +115,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.ETH, '0.608027615305460657'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0.608027615305460657'), path: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -125,8 +124,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.DAI, '1000'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '1000'), fee: 500, }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, @@ -134,8 +133,8 @@ describe('UniswapV3 SwapTokenLogic', function () { { fields: { tradeType: core.TradeType.exactOut, - input: new common.TokenAmount(mainnetTokens.USDC, '1000'), - output: new common.TokenAmount(mainnetTokens.DAI, '1000'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1000'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '1000'), path: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb480001f42260fac5e5542a773aa44fbcfedf7c193bc2c5990001f4c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', }, options: { account: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa' }, diff --git a/src/logics/utility/logic.send-token.test.ts b/src/logics/utility/logic.send-token.test.ts index bd2d899a..97379d58 100644 --- a/src/logics/utility/logic.send-token.test.ts +++ b/src/logics/utility/logic.send-token.test.ts @@ -4,7 +4,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; describe('Utility SendTokenLogic', function () { context('Test getTokenList', async function () { @@ -26,39 +25,39 @@ describe('Utility SendTokenLogic', function () { const testCases: LogicTestCase[] = [ { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.WETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.WETH, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', balanceBps: 5000, }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.WETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.WETH, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', balanceBps: 5000, }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), recipient: '0xaAaAaAaaAaAaAaaAaAAAAAAAAaaaAaAaAaaAaaAa', balanceBps: 5000, }, diff --git a/src/logics/utility/logic.wrapped-native-token.test.ts b/src/logics/utility/logic.wrapped-native-token.test.ts index d57c3063..2a72a54b 100644 --- a/src/logics/utility/logic.wrapped-native-token.test.ts +++ b/src/logics/utility/logic.wrapped-native-token.test.ts @@ -4,7 +4,6 @@ import * as common from '@protocolink/common'; import { constants, utils } from 'ethers'; import * as core from '@protocolink/core'; import { expect } from 'chai'; -import { mainnetTokens } from '@protocolink/test-helpers'; describe('Utility WrappedNativeTokenLogic', function () { context('Test getTokenList', async function () { @@ -25,27 +24,27 @@ describe('Utility WrappedNativeTokenLogic', function () { const testCases: LogicTestCase[] = [ { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.WETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.WETH, '1'), }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.WETH, '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.WETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '1'), }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.WETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.WETH, '1'), balanceBps: 5000, }, }, { fields: { - input: new common.TokenAmount(mainnetTokens.WETH, '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '1'), + input: new common.TokenAmount(common.mainnetTokens.WETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '1'), balanceBps: 5000, }, }, @@ -59,7 +58,7 @@ describe('Utility WrappedNativeTokenLogic', function () { const sig = routerLogic.data.substring(0, 10); const { input, balanceBps } = fields; - expect(routerLogic.to).to.eq(mainnetTokens.WETH.address); + expect(routerLogic.to).to.eq(common.mainnetTokens.WETH.address); expect(utils.isBytesLike(routerLogic.data)).to.be.true; if (input.token.isNative) { expect(sig).to.eq(iface.getSighash('deposit')); diff --git a/src/logics/zeroex-v4/logic.swap-token.test.ts b/src/logics/zeroex-v4/logic.swap-token.test.ts index 8170676e..dd763158 100644 --- a/src/logics/zeroex-v4/logic.swap-token.test.ts +++ b/src/logics/zeroex-v4/logic.swap-token.test.ts @@ -1,10 +1,9 @@ -import * as common from '@protocolink/common'; -import { expect } from 'chai'; -import { SwapTokenLogic, SwapTokenLogicFields, SwapTokenLogicOptions } from './logic.swap-token'; import { LogicTestCaseWithChainId } from 'test/types'; -import { mainnetTokens } from '@protocolink/test-helpers'; +import { SwapTokenLogic, SwapTokenLogicFields, SwapTokenLogicOptions } from './logic.swap-token'; +import * as common from '@protocolink/common'; import { constants, ethers, utils } from 'ethers'; import * as core from '@protocolink/core'; +import { expect } from 'chai'; import { getExchangeProxyAddress } from './configs'; const apiKey = process.env.ZEROEX_API_KEY as string; @@ -25,8 +24,8 @@ describe('0x SwapTokenLogic', () => { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.USDC, '0'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.USDC, '0'), slippage: 500, apiKey, }, @@ -35,8 +34,8 @@ describe('0x SwapTokenLogic', () => { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0'), slippage: 500, apiKey, }, @@ -45,8 +44,8 @@ describe('0x SwapTokenLogic', () => { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.USDC, '1'), - output: new common.TokenAmount(mainnetTokens.DAI, '0'), + input: new common.TokenAmount(common.mainnetTokens.USDC, '1'), + output: new common.TokenAmount(common.mainnetTokens.DAI, '0'), slippage: 500, apiKey, }, @@ -55,8 +54,8 @@ describe('0x SwapTokenLogic', () => { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.WETH, '1'), - output: new common.TokenAmount(mainnetTokens.ETH, '0'), + input: new common.TokenAmount(common.mainnetTokens.WETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.ETH, '0'), slippage: 500, apiKey, }, @@ -65,8 +64,8 @@ describe('0x SwapTokenLogic', () => { { chainId: common.ChainId.mainnet, fields: { - input: new common.TokenAmount(mainnetTokens.ETH, '1'), - output: new common.TokenAmount(mainnetTokens.WETH, '0'), + input: new common.TokenAmount(common.mainnetTokens.ETH, '1'), + output: new common.TokenAmount(common.mainnetTokens.WETH, '0'), slippage: 500, apiKey, }, From 08874db213cac53ef9a98fe34606f1a27f78c716 Mon Sep 17 00:00:00 2001 From: Jeff Huang Date: Wed, 24 Jul 2024 17:49:49 +0800 Subject: [PATCH 2/2] feat: add Polygon zkevm to Paraswap --- .changeset/chilly-bees-fail.md | 5 +++++ package.json | 4 ++-- src/logics/paraswap-v5/configs.ts | 5 +++++ yarn.lock | 23 +++++++++++++++++++---- 4 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 .changeset/chilly-bees-fail.md diff --git a/.changeset/chilly-bees-fail.md b/.changeset/chilly-bees-fail.md new file mode 100644 index 00000000..6d47675e --- /dev/null +++ b/.changeset/chilly-bees-fail.md @@ -0,0 +1,5 @@ +--- +'@protocolink/logics': minor +--- + +add Polygon zkevm to Paraswap diff --git a/package.json b/package.json index 6869e2a5..f7799f47 100644 --- a/package.json +++ b/package.json @@ -30,8 +30,8 @@ }, "dependencies": { "@paraswap/sdk": "^6.6.0", - "@protocolink/common": "^0.4.2", - "@protocolink/core": "^0.5.1", + "@protocolink/common": "^0.5.1", + "@protocolink/core": "^0.6.0", "@protocolink/smart-accounts": "^0.1.4", "@types/lodash": "^4.14.195", "@uniswap/sdk": "^3.0.3", diff --git a/src/logics/paraswap-v5/configs.ts b/src/logics/paraswap-v5/configs.ts index 6dbf0259..62380fa4 100644 --- a/src/logics/paraswap-v5/configs.ts +++ b/src/logics/paraswap-v5/configs.ts @@ -38,6 +38,11 @@ export const configs: Config[] = [ 'https://tokens.coingecko.com/polygon-pos/all.json', ], }, + { + chainId: common.ChainId.polygonZkevm, + tokenTransferProxyAddress: '0xC8a21FcD5A100c3ecc037c97e2f9C53a8D3A02A1', + tokenListUrls: ['https://unpkg.com/quickswap-default-token-list@latest/build/quickswap-default.tokenlist.json'], + }, { chainId: common.ChainId.base, tokenTransferProxyAddress: '0x93aAAe79a53759cD164340E4C8766E4Db5331cD7', diff --git a/yarn.lock b/yarn.lock index eae2bf0e..77136442 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1035,12 +1035,27 @@ type-fest "^3.12.0" zksync-web3 "^0.14.3" -"@protocolink/core@^0.5.1": +"@protocolink/common@^0.5.0", "@protocolink/common@^0.5.1": version "0.5.1" - resolved "https://registry.yarnpkg.com/@protocolink/core/-/core-0.5.1.tgz#3a1309c323d526c3c87a3562984b061cdeff630c" - integrity sha512-hmkfVkacrbMSYoy+q9o/cIw6eM1SE/+33bST2vlyaHBW+0bf8REYi642XUKGGX0+qPuhu3Uf2+pK5n/S3FGLCQ== + resolved "https://registry.yarnpkg.com/@protocolink/common/-/common-0.5.1.tgz#137598c8b1e20e794066db416854ac9a772da567" + integrity sha512-aqzpdDGidxVdQRdf1CFZqzVWNP//kuFkCj//4Ba4UpwjBmb4Pc2cdWsikBfVVWjc6Dwx9kvkz6CZ/wrApwbRnw== dependencies: - "@protocolink/common" "^0.4.2" + "@types/lodash" "^4.14.195" + axios "^1.3.6" + axios-retry "^3.5.1" + bignumber.js "^9.1.1" + ethers "^5.7.2" + lodash "^4.17.21" + tiny-invariant "^1.3.1" + type-fest "^3.12.0" + zksync-web3 "^0.14.3" + +"@protocolink/core@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@protocolink/core/-/core-0.6.0.tgz#2418b3a25fac3fe75a048604ea0918a7c39dfeb8" + integrity sha512-8Jh4VX7DO8z95FNitJkTZVqWj+/9dTznFUzuYu3BGIO/ueVQ4jYDV1kl5AgAYHDluxv8CFKBr5QEZpO+FBYqEA== + dependencies: + "@protocolink/common" "^0.5.0" "@uniswap/permit2-sdk" "^1.2.0" ethers "^5.7.2" tiny-invariant "^1.3.1"