From 3a4ad6291bd7a4563ced2ccdfc9cf2dc74f57f21 Mon Sep 17 00:00:00 2001 From: paraschiv-r-toptal Date: Tue, 31 Jan 2023 15:11:27 +0200 Subject: [PATCH 01/31] Add support for Ethereum Mainnet for PancakeswapV2 --- src/dex/uniswap-v2/config.ts | 7 + .../uniswap-v2/uniswap-v2-e2e-mainnet.test.ts | 171 ++++++++++++++++++ tests/constants-e2e.ts | 4 + 3 files changed, 182 insertions(+) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index dc6a92b2b..01f217d52 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -379,6 +379,13 @@ export const UniswapV2Config: DexConfigMap = { poolGasCost: 90 * 1000, feeCode: 25, }, + [Network.MAINNET]: { + factoryAddress: '0x1097053Fd2ea711dad45caCcc45EfF7548fCB362', + initCode: + '0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d', + poolGasCost: 90 * 1000, + feeCode: 25, + }, }, PaintSwap: { [Network.FANTOM]: { diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts index b65914c6b..1b8549abf 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts @@ -1222,4 +1222,175 @@ describe('UniswapV2 E2E Mainnet', () => { }); }); }); + + describe('PancakeSwapV2', () => { + const dexKey = 'PancakeSwapV2'; + + describe('Simpleswap', () => { + it('TOKEN -> ETH', async () => { + await testE2E( + tokens.USDT, + tokens.ETH, + holders.USDT, + '200000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + it('ETH -> TOKEN', async () => { + await testE2E( + tokens.ETH, + tokens.USDT, + holders.ETH, + '500000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + it('TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.STG, + holders.USDC, + '50000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + }); + + describe('SimpleBuy', () => { + it('TOKEN -> ETH', async () => { + await testE2E( + tokens.USDT, + tokens.ETH, + holders.USDT, + '2000000000', + SwapSide.BUY, + dexKey, + ContractMethod.simpleBuy, + network, + provider, + ); + }); + it('ETH -> TOKEN', async () => { + await testE2E( + tokens.ETH, + tokens.USDT, + holders.ETH, + '1000000', + SwapSide.BUY, + dexKey, + ContractMethod.simpleBuy, + network, + provider, + ); + }); + it('TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.STG, + holders.USDC, + '100000', + SwapSide.BUY, + dexKey, + ContractMethod.simpleBuy, + network, + provider, + ); + }); + }); + + describe('Multiswap', () => { + it('TOKEN -> ETH', async () => { + await testE2E( + tokens.USDT, + tokens.ETH, + holders.USDT, + '200000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + it('ETH -> TOKEN', async () => { + await testE2E( + tokens.ETH, + tokens.USDT, + holders.ETH, + '500000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + it('TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.STG, + holders.USDC, + '1000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + }); + describe('MegaPath', () => { + it('TOKEN -> ETH', async () => { + await testE2E( + tokens.USDT, + tokens.ETH, + holders.USDT, + '200000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + it('ETH -> TOKEN', async () => { + await testE2E( + tokens.ETH, + tokens.USDT, + holders.ETH, + '500000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + it('TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.STG, + holders.USDC, + '1000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + }); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 543254690..81b43e167 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -117,6 +117,10 @@ export const Tokens: { address: '0x43Dfc4159D86F3A37A5A4B3D4580b888ad7d4DDd', decimals: 18, }, + STG: { + address: '0xAf5191B0De278C7286d6C7CC6ab6BB8A73bA2Cd6', + decimals: 18, + }, ADAI: { address: '0x028171bca77440897b824ca71d1c56cac55b68a3', decimals: 18, From 3a1c12db11c4ee120fd51495123ace45d05faac5 Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 10:04:53 +0000 Subject: [PATCH 02/31] 2.9.51-pancake-v2-mainnet.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 52b44fcd7..c6e9c58b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.50", + "version": "2.9.51-pancake-v2-mainnet.0", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 73e82b83091d72c642f8eeb3cf7da759c6a29eb3 Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 13:17:45 +0000 Subject: [PATCH 03/31] chore: restore original dex-lib version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d08118f11..c6e9c58b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.53", + "version": "2.9.51-pancake-v2-mainnet.0", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From d842abc369758a817cb6f1a6e9c0c92751d190db Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 13:18:22 +0000 Subject: [PATCH 04/31] 2.9.51-pancake-v2-mainnet.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c6e9c58b3..f48d3a4f5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.51-pancake-v2-mainnet.0", + "version": "2.9.51-pancake-v2-mainnet.1", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 4ad4dc5146ca19b32f1d652a3305f4c99b6254f6 Mon Sep 17 00:00:00 2001 From: rorrieswap Date: Mon, 21 Nov 2022 11:25:26 +0000 Subject: [PATCH 05/31] Added polygon chain to existing Swapsicle integration --- src/dex/uniswap-v2/config.ts | 8 + .../uniswap-v2/uniswap-v2-e2e-polygon.test.ts | 242 ++++++++++++++++++ 2 files changed, 250 insertions(+) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index dc6a92b2b..7b42a1079 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -449,6 +449,14 @@ export const UniswapV2Config: DexConfigMap = { '0x9e43ee37212e3296c7f6087d3e0a37b48a4e4e413538dac0fd18cfe2f80666c1', feeCode: 30, }, + [Network.POLYGON]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/jenniyus/swapsicle-exchange-polygon', + factoryAddress: '0x1eb5644fAC0FB43f79dE25C0BaB94F0d56062718', + initCode: + '0x647d9b2d483bb87af1032b1d49b999692ae322ab75628ce2fb56e3cd52fe4feb', + feeCode: 30, + }, }, QuickSwap: { [Network.POLYGON]: { diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts index e646eaa76..d97d3a6e1 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts @@ -1345,4 +1345,246 @@ describe('UniswapV2 E2E Polygon', () => { }); }); }); + + describe('Swapsicle', () => { + const dexKey = 'Swapsicle'; + + describe('Simpleswap', () => { + it('QuickSwap MATIC -> TOKEN', async () => { + await testE2E( + tokens.MATIC, + tokens.USDC, + holders.MATIC, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> MATIC', async () => { + await testE2E( + tokens.USDC, + tokens.MATIC, + holders.DAI, + '700000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.ETH, + holders.WMATIC, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + }); + + describe('Multiswap', () => { + it('QuickSwap MATIC -> TOKEN', async () => { + await testE2E( + tokens.MATIC, + tokens.USDC, + holders.MATIC, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> MATIC', async () => { + await testE2E( + tokens.USDC, + tokens.MATIC, + holders.DAI, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.DAI, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + }); + + describe('BuyMethod', () => { + it('QuickSwap MATIC -> TOKEN', async () => { + await testE2E( + tokens.MATIC, + tokens.USDC, + holders.MATIC, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> MATIC', async () => { + await testE2E( + tokens.USDC, + tokens.MATIC, + holders.DAI, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + it('QuickSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.DAI, + '70000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + }); + + describe('FeeOnTransfer', () => { + describe('sell', () => { + describe('megaSwap', () => { + it('WMATIC -> USDC', async () => { + await testE2E( + tokens.WMATIC, + tokens.USDC, + holders.WMATIC, + '1000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, + ); + }); + it('USDC -> WMATIC', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.HANZO, + '41234567000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, + ); + }); + }); + describe('swapOnUniswapV2Fork', () => { + it('WMATIC -> USDC', async () => { + await testE2E( + tokens.WMATIC, + tokens.USDC, + holders.WMATIC, + '1000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapOnUniswapV2Fork, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, + ); + }); + it('USDC -> WMATIC', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.HANZO, + '41234567000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapOnUniswapV2Fork, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, + ); + }); + }); + }); + describe('buy', () => { + describe('buy', () => { + it('USDC -> WMATIC', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.USDC, + '1000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, + ); + }); + }); + describe('buyOnUniswapV2Fork', () => { + it('USDC -> WMATIC', async () => { + await testE2E( + tokens.USDC, + tokens.WMATIC, + holders.USDC, + '1000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.buyOnUniswapV2Fork, + network, + provider, + undefined, + undefined, + { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, + ); + }); + }); + }); + }); + }); + }); From 439c8247392b0a668e657302fccabdf3b2ccb71c Mon Sep 17 00:00:00 2001 From: rorrieswap Date: Mon, 21 Nov 2022 12:14:16 +0000 Subject: [PATCH 06/31] Fixed swapsicledex unit tests --- .../uniswap-v2/uniswap-v2-e2e-polygon.test.ts | 93 ++++++++----------- 1 file changed, 39 insertions(+), 54 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts index d97d3a6e1..c6c8ce931 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts @@ -1353,9 +1353,9 @@ describe('UniswapV2 E2E Polygon', () => { it('QuickSwap MATIC -> TOKEN', async () => { await testE2E( tokens.MATIC, - tokens.USDC, + tokens.WETH, holders.MATIC, - '7000000000000000000', + '100000000000000000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -1365,10 +1365,10 @@ describe('UniswapV2 E2E Polygon', () => { }); it('QuickSwap TOKEN -> MATIC', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.MATIC, - holders.DAI, - '700000000000000000000', + holders.WETH, + '70000000000000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -1378,10 +1378,10 @@ describe('UniswapV2 E2E Polygon', () => { }); it('QuickSwap TOKEN -> TOKEN', async () => { await testE2E( - tokens.USDC, - tokens.ETH, - holders.WMATIC, - '700000000000000000', + tokens.WETH, + tokens.WMATIC, + holders.WETH, + '70000000000000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -1392,12 +1392,12 @@ describe('UniswapV2 E2E Polygon', () => { }); describe('Multiswap', () => { - it('QuickSwap MATIC -> TOKEN', async () => { + it('Multiswap MATIC -> TOKEN', async () => { await testE2E( tokens.MATIC, - tokens.USDC, + tokens.WETH, holders.MATIC, - '7000000000000000000', + '100000000000000000', SwapSide.SELL, dexKey, ContractMethod.multiSwap, @@ -1405,12 +1405,12 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> MATIC', async () => { + it('Multiswap TOKEN -> MATIC', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.MATIC, - holders.DAI, - '7000000000000000000', + holders.WETH, + '70000000000000', SwapSide.SELL, dexKey, ContractMethod.multiSwap, @@ -1418,12 +1418,12 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> TOKEN', async () => { + it('Multiswap TOKEN -> TOKEN', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.WMATIC, - holders.DAI, - '7000000000000000000', + holders.WETH, + '70000000000000', SwapSide.SELL, dexKey, ContractMethod.multiSwap, @@ -1434,12 +1434,12 @@ describe('UniswapV2 E2E Polygon', () => { }); describe('BuyMethod', () => { - it('QuickSwap MATIC -> TOKEN', async () => { + it('Multiswap MATIC -> TOKEN', async () => { await testE2E( tokens.MATIC, - tokens.USDC, + tokens.WETH, holders.MATIC, - '7000000000000000000', + '70000000000000', SwapSide.BUY, dexKey, ContractMethod.buy, @@ -1449,10 +1449,10 @@ describe('UniswapV2 E2E Polygon', () => { }); it('QuickSwap TOKEN -> MATIC', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.MATIC, - holders.DAI, - '7000000000000000000', + holders.WETH, + '100000000000000000', SwapSide.BUY, dexKey, ContractMethod.buy, @@ -1462,10 +1462,10 @@ describe('UniswapV2 E2E Polygon', () => { }); it('QuickSwap TOKEN -> TOKEN', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.WMATIC, - holders.DAI, - '70000000000000000000', + holders.WETH, + '100000000000000000', SwapSide.BUY, dexKey, ContractMethod.buy, @@ -1478,12 +1478,12 @@ describe('UniswapV2 E2E Polygon', () => { describe('FeeOnTransfer', () => { describe('sell', () => { describe('megaSwap', () => { - it('WMATIC -> USDC', async () => { + it('WMATIC -> WETH', async () => { await testE2E( tokens.WMATIC, - tokens.USDC, + tokens.WETH, holders.WMATIC, - '1000000000000000000', + '100000000000000000', SwapSide.SELL, dexKey, ContractMethod.megaSwap, @@ -1494,30 +1494,15 @@ describe('UniswapV2 E2E Polygon', () => { { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, ); }); - it('USDC -> WMATIC', async () => { - await testE2E( - tokens.USDC, - tokens.WMATIC, - holders.HANZO, - '41234567000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, - ); - }); + }); describe('swapOnUniswapV2Fork', () => { it('WMATIC -> USDC', async () => { await testE2E( tokens.WMATIC, - tokens.USDC, + tokens.WETH, holders.WMATIC, - '1000000000000000000', + '100000000000000000', SwapSide.SELL, dexKey, ContractMethod.swapOnUniswapV2Fork, @@ -1528,12 +1513,12 @@ describe('UniswapV2 E2E Polygon', () => { { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, ); }); - it('USDC -> WMATIC', async () => { + it('WETH -> WMATIC', async () => { await testE2E( - tokens.USDC, + tokens.WETH, tokens.WMATIC, - holders.HANZO, - '41234567000000000', + holders.WETH, + '70000000000000', SwapSide.SELL, dexKey, ContractMethod.swapOnUniswapV2Fork, From b03ec76f4edfa4851eda9409d8ccbb77dd9908a1 Mon Sep 17 00:00:00 2001 From: rorrieswap Date: Wed, 14 Dec 2022 15:25:46 +0000 Subject: [PATCH 07/31] Updated Swapsicle subgraph Added Fantom, Polygon, BSC, Arbitrum --- src/dex/uniswap-v2/config.ts | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index 7b42a1079..413ec1a7a 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -443,7 +443,7 @@ export const UniswapV2Config: DexConfigMap = { }, Swapsicle: { [Network.AVALANCHE]: { - subgraphURL: 'https://api.thegraph.com/subgraphs/name/billy93/exchange', + subgraphURL: 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-avalanche', factoryAddress: '0x9C60C867cE07a3c403E2598388673C10259EC768', initCode: '0x9e43ee37212e3296c7f6087d3e0a37b48a4e4e413538dac0fd18cfe2f80666c1', @@ -451,10 +451,34 @@ export const UniswapV2Config: DexConfigMap = { }, [Network.POLYGON]: { subgraphURL: - 'https://api.thegraph.com/subgraphs/name/jenniyus/swapsicle-exchange-polygon', - factoryAddress: '0x1eb5644fAC0FB43f79dE25C0BaB94F0d56062718', + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-polygon', + factoryAddress: '0x735ab9808d792B5c8B54e31196c011c26C08b4ce', initCode: - '0x647d9b2d483bb87af1032b1d49b999692ae322ab75628ce2fb56e3cd52fe4feb', + '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + feeCode: 30, + }, + [Network.BSC]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-bnb', + factoryAddress: '0xEe673452BD981966d4799c865a96e0b92A8d0E45', + initCode: + '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + feeCode: 30, + }, + [Network.FANTOM]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-fantom', + factoryAddress: '0x98F23162E3a7FE610aC89C88E4217a599A15858F', + initCode: + 'cb64282d14f9033fbb6a3a827bd515fff027bb6994a0d33ac0424e7e3037dad3', + feeCode: 30, + }, + [Network.ARBITRUM]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-arbitrum', + factoryAddress: '0x2f0c7c98462651bb2102f6cd05acdad333e031b0', + initCode: + '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, }, From 55e66131d0f7d35e787d543077c23de0aec68f22 Mon Sep 17 00:00:00 2001 From: rorrieswap Date: Sat, 17 Dec 2022 17:44:10 +0000 Subject: [PATCH 08/31] Added Eth and Optimism to existing Swapsicle integration --- src/dex/uniswap-v2/config.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index 413ec1a7a..c3180f81e 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -481,6 +481,22 @@ export const UniswapV2Config: DexConfigMap = { '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, + [Network.MAINNET]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-ethereum', + factoryAddress: '0x2F0C7C98462651BB2102F6Cd05acDAd333E031b0', + initCode: + '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + feeCode: 30, + }, + [Network.OPTIMISM]: { + subgraphURL: + 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-optimism', + factoryAddress: '0x2f0c7c98462651bb2102f6cd05acdad333e031b0', + initCode: + '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + feeCode: 30, + }, }, QuickSwap: { [Network.POLYGON]: { From 1dee80f1197ee452b8443cc86a9d2106e48b3b17 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Wed, 1 Feb 2023 18:06:44 +0300 Subject: [PATCH 09/31] remove FeeOnTransfer tests --- .../uniswap-v2/uniswap-v2-e2e-polygon.test.ts | 97 ------------------- 1 file changed, 97 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts index c6c8ce931..73897e39e 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts @@ -1474,102 +1474,5 @@ describe('UniswapV2 E2E Polygon', () => { ); }); }); - - describe('FeeOnTransfer', () => { - describe('sell', () => { - describe('megaSwap', () => { - it('WMATIC -> WETH', async () => { - await testE2E( - tokens.WMATIC, - tokens.WETH, - holders.WMATIC, - '100000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, - ); - }); - - }); - describe('swapOnUniswapV2Fork', () => { - it('WMATIC -> USDC', async () => { - await testE2E( - tokens.WMATIC, - tokens.WETH, - holders.WMATIC, - '100000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.swapOnUniswapV2Fork, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 0, destDexFee: 500 }, - ); - }); - it('WETH -> WMATIC', async () => { - await testE2E( - tokens.WETH, - tokens.WMATIC, - holders.WETH, - '70000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.swapOnUniswapV2Fork, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, - ); - }); - }); - }); - describe('buy', () => { - describe('buy', () => { - it('USDC -> WMATIC', async () => { - await testE2E( - tokens.USDC, - tokens.WMATIC, - holders.USDC, - '1000000000000000000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, - ); - }); - }); - describe('buyOnUniswapV2Fork', () => { - it('USDC -> WMATIC', async () => { - await testE2E( - tokens.USDC, - tokens.WMATIC, - holders.USDC, - '1000000000000000000', - SwapSide.BUY, - dexKey, - ContractMethod.buyOnUniswapV2Fork, - network, - provider, - undefined, - undefined, - { srcFee: 0, destFee: 0, srcDexFee: 500, destDexFee: 0 }, - ); - }); - }); - }); - }); }); - }); From 77ba40adce3d7e8e04778ae7a35572b4d06226d2 Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 17:08:57 +0000 Subject: [PATCH 10/31] feat: enable comsposable stable pools again --- src/dex/balancer-v2/balancer-v2.ts | 12 ++++++------ src/dex/balancer-v2/types.ts | 2 +- src/dex/balancer-v2/utils.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/dex/balancer-v2/balancer-v2.ts b/src/dex/balancer-v2/balancer-v2.ts index c7ae8cd33..94007bee2 100644 --- a/src/dex/balancer-v2/balancer-v2.ts +++ b/src/dex/balancer-v2/balancer-v2.ts @@ -158,11 +158,11 @@ export class BalancerV2EventPool extends StatefulEventSubscriber { The difference of note for swaps is ComposableStable must use 'actualSupply' instead of VirtualSupply. VirtualSupply could be calculated easily whereas actualSupply cannot hence the use of onchain call. */ - // const composableStable = new PhantomStablePool( - // this.vaultAddress, - // this.vaultInterface, - // true, - // ); + const composableStable = new PhantomStablePool( + this.vaultAddress, + this.vaultInterface, + true, + ); const linearPool = new LinearPool(this.vaultAddress, this.vaultInterface); this.pools = {}; @@ -177,7 +177,7 @@ export class BalancerV2EventPool extends StatefulEventSubscriber { // Beets uses "Linear" generically for all linear pool types this.pools[BalancerPoolTypes.Linear] = linearPool; this.pools[BalancerPoolTypes.StablePhantom] = stablePhantomPool; - // this.pools[BalancerPoolTypes.ComposableStable] = composableStable; + this.pools[BalancerPoolTypes.ComposableStable] = composableStable; this.vaultDecoder = (log: Log) => this.vaultInterface.parseLog(log); this.addressesSubscribed = [vaultAddress]; diff --git a/src/dex/balancer-v2/types.ts b/src/dex/balancer-v2/types.ts index 91d8ffc2c..d2945d539 100644 --- a/src/dex/balancer-v2/types.ts +++ b/src/dex/balancer-v2/types.ts @@ -11,7 +11,7 @@ export enum BalancerPoolTypes { StablePhantom = 'StablePhantom', ERC4626Linear = 'ERC4626Linear', Linear = 'Linear', - // ComposableStable = 'ComposableStable', + ComposableStable = 'ComposableStable', } export type TokenState = { diff --git a/src/dex/balancer-v2/utils.ts b/src/dex/balancer-v2/utils.ts index 5284923f6..e92b795ef 100644 --- a/src/dex/balancer-v2/utils.ts +++ b/src/dex/balancer-v2/utils.ts @@ -162,8 +162,8 @@ function isLinearPool(poolType: string) { function isPhantomStablePool(poolType: string) { return ( - poolType === BalancerPoolTypes.StablePhantom - // || poolType === BalancerPoolTypes.ComposableStable + poolType === BalancerPoolTypes.StablePhantom || + poolType === BalancerPoolTypes.ComposableStable ); } From e1de407014ff92c045e4f3a4efcbd966d9a80c93 Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 17:30:31 +0000 Subject: [PATCH 11/31] fix: fix gascost issue --- src/dex/balancer-v2/balancer-v2.ts | 9 +++++++-- src/dex/balancer-v2/constants.ts | 9 +++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/dex/balancer-v2/balancer-v2.ts b/src/dex/balancer-v2/balancer-v2.ts index 94007bee2..badf3db39 100644 --- a/src/dex/balancer-v2/balancer-v2.ts +++ b/src/dex/balancer-v2/balancer-v2.ts @@ -51,7 +51,11 @@ import { poolGetMainTokens, poolGetPathForTokenInOut, } from './utils'; -import { MIN_USD_LIQUIDITY_TO_FETCH } from './constants'; +import { + MIN_USD_LIQUIDITY_TO_FETCH, + STABLE_GAS_COST, + VARIABLE_GAS_COST_PER_CYCLE, +} from './constants'; const fetchAllPools = `query ($count: Int) { pools: pools( @@ -760,7 +764,8 @@ export class BalancerV2 }, poolAddresses: [poolAddress], exchange: this.dexKey, - gasCost: 150 * 1000 * (path.length - 1), + gasCost: + STABLE_GAS_COST + VARIABLE_GAS_COST_PER_CYCLE * path.length, poolIdentifier: `${this.dexKey}_${poolAddress}`, }; diff --git a/src/dex/balancer-v2/constants.ts b/src/dex/balancer-v2/constants.ts index d71ecc39e..39d700520 100644 --- a/src/dex/balancer-v2/constants.ts +++ b/src/dex/balancer-v2/constants.ts @@ -1 +1,10 @@ export const MIN_USD_LIQUIDITY_TO_FETCH = 100n; + +// Let's take this trade as an example: +// https://dashboard.tenderly.co/paraswap/paraswap/fork/e4c81946-fd6e-4299-b35c-c47b775e3c05/simulation/8839462c-6239-4ae1-9ed0-8013f89b41de/gas-usage + +// 271719 - 57856 - 79098 - 51041 = 83724 ~ 84k +export const STABLE_GAS_COST = 84_000; + +// I see three pools used in trade: (57856 + 79098 + 51041) / 3 = 62665 ~ 63k +export const VARIABLE_GAS_COST_PER_CYCLE = 63_000; From 3cf2a9b24127e67697eaa7bc0553cf30625056b0 Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 18:47:08 +0000 Subject: [PATCH 12/31] feat: fix and test Balancer-v2 pricing issue --- src/dex/balancer-v2/LinearPool.ts | 11 -- src/dex/balancer-v2/PhantomStablePool.ts | 19 +-- .../balancer-v2-integration.test.ts | 148 +++++++++++------- 3 files changed, 95 insertions(+), 83 deletions(-) diff --git a/src/dex/balancer-v2/LinearPool.ts b/src/dex/balancer-v2/LinearPool.ts index 1ae8a6379..81a829012 100644 --- a/src/dex/balancer-v2/LinearPool.ts +++ b/src/dex/balancer-v2/LinearPool.ts @@ -346,11 +346,6 @@ export class LinearPool extends BasePool { target: pool.address, callData: this.poolInterface.encodeFunctionData('getScalingFactors'), }); - //getScalingFactors does not include the rate for the phantom bpt, need to fetch it separately - poolCallData.push({ - target: pool.address, - callData: this.poolInterface.encodeFunctionData('getRate'), - }); // returns lowerTarget, upperTarget poolCallData.push({ target: pool.address, @@ -389,12 +384,6 @@ export class LinearPool extends BasePool { data[startIndex++], pool.address, )[0]; - const rate = decodeThrowError( - this.poolInterface, - 'getRate', - data[startIndex++], - pool.address, - )[0]; const [lowerTarget, upperTarget] = decodeThrowError( this.poolInterface, 'getTargets', diff --git a/src/dex/balancer-v2/PhantomStablePool.ts b/src/dex/balancer-v2/PhantomStablePool.ts index 999b07130..e9408d8d8 100644 --- a/src/dex/balancer-v2/PhantomStablePool.ts +++ b/src/dex/balancer-v2/PhantomStablePool.ts @@ -311,10 +311,6 @@ export class PhantomStablePool extends BasePool { target: pool.address, callData: this.poolInterface.encodeFunctionData('getScalingFactors'), }, - { - target: pool.address, - callData: this.poolInterface.encodeFunctionData('getRate'), - }, { target: pool.address, callData: this.poolInterface.encodeFunctionData( @@ -373,12 +369,6 @@ export class PhantomStablePool extends BasePool { data[startIndex++], pool.address, )[0]; - const rate = decodeThrowError( - this.poolInterface, - 'getRate', - data[startIndex++], - pool.address, - )[0]; const amp = decodeThrowError( this.poolInterface, 'getAmplificationParameter', @@ -386,17 +376,10 @@ export class PhantomStablePool extends BasePool { pool.address, ); - const bptIndex = pool.tokens.findIndex( - t => t.address.toLowerCase() === pool.address.toLowerCase(), - ); - const tokens = poolTokens.tokens.map((address: string, idx: number) => ({ address: address.toLowerCase(), balance: BigInt(poolTokens.balances[idx].toString()), - scalingFactor: - idx === bptIndex - ? BigInt(rate.toString()) - : BigInt(scalingFactors[idx].toString()), + scalingFactor: BigInt(scalingFactors[idx].toString()), })); const poolState: PoolState = { diff --git a/src/dex/balancer-v2/balancer-v2-integration.test.ts b/src/dex/balancer-v2/balancer-v2-integration.test.ts index 7c41aaa1d..cc29f0408 100644 --- a/src/dex/balancer-v2/balancer-v2-integration.test.ts +++ b/src/dex/balancer-v2/balancer-v2-integration.test.ts @@ -50,61 +50,24 @@ const amounts = [0n, BI_POWS[18], 2000000000000000000n]; const dexKey = 'BalancerV2'; describe('BalancerV2', function () { - describe('BeetsFi', () => { - it('FTM -> BOO: getPoolIdentifiers and getPricesVolume', async () => { - const dexKey = 'BeetsFi'; - const network = Network.FANTOM; - const srcToken = Tokens[network]['FTM']; - const destToken = Tokens[network]['BOO']; - const amounts = [0n, BI_POWS[18]]; + describe('ComposableStable', () => { + it('USDC -> USDT getPoolIdentifiers and getPricesVolume', async () => { + const network = Network.MAINNET; + const srcToken = Tokens[network]['USDC']; + const destToken = Tokens[network]['USDT']; + const amounts = [0n, 10000001000000n]; const dexHelper = new DummyDexHelper(network); - // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); - const blockNumber = 54734626; - const beetsFi = new BalancerV2(network, dexKey, dexHelper); - - await beetsFi.initializePricing(blockNumber); - - const pools = await beetsFi.getPoolIdentifiers( - srcToken, - destToken, - SwapSide.SELL, - blockNumber, - ); - console.log('Pool Identifiers: ', pools); + const blockNumber = await dexHelper.web3Provider.eth.getBlockNumber(); + // You will need blockTimestamp to check onchain calculation, because + // it depends on timestamp. If you have different values, they are incomparable + // const block = await dexHelper.web3Provider.eth.getBlock(blockNumber); - expect(pools.length).toBeGreaterThan(0); + const balancerV2 = new BalancerV2(network, dexKey, dexHelper); - const poolPrices = await beetsFi.getPricesVolume( - srcToken, - destToken, - amounts, - SwapSide.SELL, - blockNumber, - pools, - ); - console.log('Pool Prices: ', poolPrices); + await balancerV2.initializePricing(blockNumber); - expect(poolPrices).not.toBeNull(); - checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); - - await beetsFi.releaseResources(); - }); - it('WETH -> FTM: getPoolIdentifiers and getPricesVolume', async () => { - const dexKey = 'BeetsFi'; - const network = Network.FANTOM; - const srcToken = Tokens[network]['WETH']; - const destToken = Tokens[network]['FTM']; - const amounts = [0n, BI_POWS[18]]; - - const dexHelper = new DummyDexHelper(network); - // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); - const blockNumber = 54782005; - const beetsFi = new BalancerV2(network, dexKey, dexHelper); - - await beetsFi.initializePricing(blockNumber); - - const pools = await beetsFi.getPoolIdentifiers( + const pools = await balancerV2.getPoolIdentifiers( srcToken, destToken, SwapSide.SELL, @@ -114,7 +77,7 @@ describe('BalancerV2', function () { expect(pools.length).toBeGreaterThan(0); - const poolPrices = await beetsFi.getPricesVolume( + const poolPrices = await balancerV2.getPricesVolume( srcToken, destToken, amounts, @@ -127,11 +90,9 @@ describe('BalancerV2', function () { expect(poolPrices).not.toBeNull(); checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); - await beetsFi.releaseResources(); + await balancerV2.releaseResources(); }); - }); - describe('ComposableStable', () => { it('getPoolIdentifiers and getPricesVolume', async () => { const dexHelper = new DummyDexHelper(Network.POLYGON); const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); @@ -397,3 +358,82 @@ describe('BalancerV2', function () { }); }); }); + +describe('BeetsFi', () => { + it('FTM -> BOO: getPoolIdentifiers and getPricesVolume', async () => { + const dexKey = 'BeetsFi'; + const network = Network.FANTOM; + const srcToken = Tokens[network]['FTM']; + const destToken = Tokens[network]['BOO']; + const amounts = [0n, BI_POWS[18]]; + + const dexHelper = new DummyDexHelper(network); + const blockNumber = await dexHelper.web3Provider.eth.getBlockNumber(); + const beetsFi = new BalancerV2(network, dexKey, dexHelper); + + await beetsFi.initializePricing(blockNumber); + + const pools = await beetsFi.getPoolIdentifiers( + srcToken, + destToken, + SwapSide.SELL, + blockNumber, + ); + console.log('Pool Identifiers: ', pools); + + expect(pools.length).toBeGreaterThan(0); + + const poolPrices = await beetsFi.getPricesVolume( + srcToken, + destToken, + amounts, + SwapSide.SELL, + blockNumber, + pools, + ); + console.log('Pool Prices: ', poolPrices); + + expect(poolPrices).not.toBeNull(); + checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); + + await beetsFi.releaseResources(); + }); + it('WETH -> FTM: getPoolIdentifiers and getPricesVolume', async () => { + const dexKey = 'BeetsFi'; + const network = Network.FANTOM; + const srcToken = Tokens[network]['WETH']; + const destToken = Tokens[network]['FTM']; + const amounts = [0n, BI_POWS[18]]; + + const dexHelper = new DummyDexHelper(network); + const blockNumber = await dexHelper.web3Provider.eth.getBlockNumber(); + const beetsFi = new BalancerV2(network, dexKey, dexHelper); + + await beetsFi.initializePricing(blockNumber); + + const pools = await beetsFi.getPoolIdentifiers( + srcToken, + destToken, + SwapSide.SELL, + blockNumber, + ); + console.log('Pool Identifiers: ', pools); + + expect(pools.length).toBeGreaterThan(0); + + const poolPrices = await beetsFi.getPricesVolume( + srcToken, + destToken, + amounts, + SwapSide.SELL, + blockNumber, + pools, + ); + console.log('Pool Prices: ', poolPrices); + + expect(poolPrices).not.toBeNull(); + checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); + + await beetsFi.releaseResources(); + }); +}); From 46a5bb02aec64c68c030e71a189b5b88168f256d Mon Sep 17 00:00:00 2001 From: Verisana Date: Wed, 1 Feb 2023 18:49:56 +0000 Subject: [PATCH 13/31] 2.9.54 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d08118f11..911d9d299 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.53", + "version": "2.9.54", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 941f436ed1deaff5b8d5197a580d1bcd5b78da68 Mon Sep 17 00:00:00 2001 From: Verisana Date: Thu, 2 Feb 2023 13:05:43 +0000 Subject: [PATCH 14/31] feat: change default slippage to 1% --- tests/utils-e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/utils-e2e.ts b/tests/utils-e2e.ts index 9f18f329e..4dd053148 100644 --- a/tests/utils-e2e.ts +++ b/tests/utils-e2e.ts @@ -246,8 +246,8 @@ export async function testE2E( ); expect(parseFloat(priceRoute.destAmount)).toBeGreaterThan(0); - // Calculate slippage. Default is 7% - const _slippage = slippage || 700; + // Calculate slippage. Default is 1% + const _slippage = slippage || 100; const minMaxAmount = (swapSide === SwapSide.SELL ? BigInt(priceRoute.destAmount) * (10000n - BigInt(_slippage)) From a9faef222e62bd3926bad95f7f22c308219b3974 Mon Sep 17 00:00:00 2001 From: Verisana Date: Thu, 2 Feb 2023 13:09:12 +0000 Subject: [PATCH 15/31] 2.9.55 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 911d9d299..0c018f387 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.54", + "version": "2.9.55", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From cb17ba92c7fe7f422055ad2a81d45f3aa9a9e613 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Thu, 2 Feb 2023 18:41:45 +0300 Subject: [PATCH 16/31] update tests --- .../uniswap-v2/uniswap-v2-e2e-polygon.test.ts | 254 +++++++++++++++--- tests/constants-e2e.ts | 5 + 2 files changed, 227 insertions(+), 32 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts index 73897e39e..1bdeb9022 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts @@ -38,7 +38,7 @@ describe('UniswapV2 E2E Polygon', () => { tokens.DAI, tokens.MATIC, holders.DAI, - '700000000000000000000', + '100000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -1258,6 +1258,7 @@ describe('UniswapV2 E2E Polygon', () => { ); }); }); + describe('multiSwap', () => { it('MATIC -> TOKEN', async () => { await testE2E( @@ -1301,6 +1302,7 @@ describe('UniswapV2 E2E Polygon', () => { ); }); }); + describe('megaSwap', () => { it('MATIC -> TOKEN', async () => { await testE2E( @@ -1350,10 +1352,10 @@ describe('UniswapV2 E2E Polygon', () => { const dexKey = 'Swapsicle'; describe('Simpleswap', () => { - it('QuickSwap MATIC -> TOKEN', async () => { + it('QuickSwap MATIC -> USDC', async () => { await testE2E( tokens.MATIC, - tokens.WETH, + tokens.USDC, holders.MATIC, '100000000000000000', SwapSide.SELL, @@ -1363,12 +1365,13 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> MATIC', async () => { + + it('QuickSwap USDC -> MATIC', async () => { await testE2E( - tokens.WETH, + tokens.USDC, tokens.MATIC, - holders.WETH, - '70000000000000', + holders.USDC, + '10000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -1376,11 +1379,40 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> TOKEN', async () => { + + it('QuickSwap MATIC -> DAI', async () => { await testE2E( - tokens.WETH, - tokens.WMATIC, - holders.WETH, + tokens.MATIC, + tokens.DAI, + holders.MATIC, + '70000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('QuickSwap DAI > MATIC', async () => { + await testE2E( + tokens.DAI, + tokens.MATIC, + holders.DAI, + '50000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('QuickSwap MATIC -> USDT', async () => { + await testE2E( + tokens.MATIC, + tokens.USDT, + holders.MATIC, '70000000000000', SwapSide.SELL, dexKey, @@ -1389,13 +1421,55 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); + + it('QuickSwap USDT -> MATIC', async () => { + await testE2E( + tokens.USDT, + tokens.MATIC, + holders.USDT, + '1000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('QuickSwap MATIC -> POPS', async () => { + await testE2E( + tokens.MATIC, + tokens.POPS, + holders.MATIC, + '70000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + // it('QuickSwap POPS -> MATIC', async () => { + // await testE2E( + // tokens.POPS, + // tokens.WMATIC, + // holders.POPS, + // '8000000', + // SwapSide.SELL, + // dexKey, + // ContractMethod.simpleSwap, + // network, + // provider, + // ); + // }); }); describe('Multiswap', () => { - it('Multiswap MATIC -> TOKEN', async () => { + it('Multiswap MATIC -> USDC', async () => { await testE2E( tokens.MATIC, - tokens.WETH, + tokens.USDC, holders.MATIC, '100000000000000000', SwapSide.SELL, @@ -1405,11 +1479,26 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('Multiswap TOKEN -> MATIC', async () => { + + it('Multiswap USDC -> MATIC', async () => { await testE2E( - tokens.WETH, + tokens.USDC, tokens.MATIC, - holders.WETH, + holders.USDC, + '200', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('Multiswap MATIC -> DAI', async () => { + await testE2E( + tokens.MATIC, + tokens.DAI, + holders.MATIC, '70000000000000', SwapSide.SELL, dexKey, @@ -1418,11 +1507,12 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('Multiswap TOKEN -> TOKEN', async () => { + + it('Multiswap DAI -> MATIC', async () => { await testE2E( - tokens.WETH, - tokens.WMATIC, - holders.WETH, + tokens.DAI, + tokens.MATIC, + holders.DAI, '70000000000000', SwapSide.SELL, dexKey, @@ -1431,15 +1521,57 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); + + it('Multiswap MATIC -> USDT', async () => { + await testE2E( + tokens.MATIC, + tokens.USDT, + holders.MATIC, + '70000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('Multiswap USDT -> MATIC', async () => { + await testE2E( + tokens.USDT, + tokens.MATIC, + holders.USDT, + '500', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('Multiswap MATIC -> POPS', async () => { + await testE2E( + tokens.MATIC, + tokens.POPS, + holders.MATIC, + '70000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); }); describe('BuyMethod', () => { - it('Multiswap MATIC -> TOKEN', async () => { + it('Buy MATIC -> USDC', async () => { await testE2E( tokens.MATIC, - tokens.WETH, + tokens.USDC, holders.MATIC, - '70000000000000', + '7000000', SwapSide.BUY, dexKey, ContractMethod.buy, @@ -1447,12 +1579,13 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> MATIC', async () => { + + it('Buy USDC -> MATIC', async () => { await testE2E( - tokens.WETH, + tokens.USDC, tokens.MATIC, - holders.WETH, - '100000000000000000', + holders.USDC, + '150', SwapSide.BUY, dexKey, ContractMethod.buy, @@ -1460,12 +1593,69 @@ describe('UniswapV2 E2E Polygon', () => { provider, ); }); - it('QuickSwap TOKEN -> TOKEN', async () => { + + it('Buy MATIC -> DAI', async () => { await testE2E( - tokens.WETH, - tokens.WMATIC, - holders.WETH, - '100000000000000000', + tokens.MATIC, + tokens.DAI, + holders.MATIC, + '650000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + it('Buy DAI -> MATIC', async () => { + await testE2E( + tokens.DAI, + tokens.MATIC, + holders.DAI, + '150', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + it('Buy MATIC -> USDT', async () => { + await testE2E( + tokens.MATIC, + tokens.USDT, + holders.MATIC, + '150000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + it('Buy USDT -> MATIC', async () => { + await testE2E( + tokens.USDT, + tokens.MATIC, + holders.USDT, + '250', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + it('Buy MATIC -> POPS', async () => { + await testE2E( + tokens.MATIC, + tokens.POPS, + holders.MATIC, + '70000', SwapSide.BUY, dexKey, ContractMethod.buy, diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 39fed375c..ac6188fa9 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -296,6 +296,10 @@ export const Tokens: { address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174', decimals: 6, }, + POPS: { + address: '0xa92A1576D11dB45c53be71d59245ac97ce0d8147', + decimals: 18, + }, WETH: { address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619', decimals: 18, @@ -795,6 +799,7 @@ export const Holders: { WMATIC: '0xFffbCD322cEace527C8ec6Da8de2461C6D9d4e6e', AMWMATIC: '0x8832924854e3Cedb0a6Abf372e6CCFF9F7654332', USDC: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B', + POPS: '0xcc4c2d391b2abcf6d95463f3315f983696bbd6c2', MUST: '0x9f2a409848fb9b7bd058b24a23e8dbf1e166a109', AMDAI: '0xFA0DCe8280FCDf369a4cbFc1830d3302789307a6', mUSD: '0x5084f622cbDf1E22E473d66d97916524745B9b6e', From d49b7db8543891c5f9826ad87931c606b503b06c Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 11:10:59 +0300 Subject: [PATCH 17/31] add swapcicle tests for avalanche chain --- .../uniswap-v2-e2e-avalanche.test.ts | 212 +++++++++++++++++- tests/constants-e2e.ts | 9 +- 2 files changed, 218 insertions(+), 3 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts index 8e7f85d19..0c83f80ae 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts @@ -472,6 +472,34 @@ describe('UniswapV2 E2E Avalanche', () => { const dexKey = 'Swapsicle'; describe('simpleSwap', () => { + it('WAVAX -> USDC', async () => { + await testE2E( + tokens.WAVAX, + tokens.USDC, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('USDC -> WAVAX', async () => { + await testE2E( + tokens.USDC, + tokens.WAVAX, + holders.USDC, + '5000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + it('USDC -> MIM', async () => { await testE2E( tokens.USDC, @@ -491,7 +519,7 @@ describe('UniswapV2 E2E Avalanche', () => { tokens.MIM, tokens.USDC, holders.MIM, - '3000000000000000000000', + '300000000000000000', SwapSide.SELL, dexKey, ContractMethod.simpleSwap, @@ -513,9 +541,79 @@ describe('UniswapV2 E2E Avalanche', () => { provider, ); }); + + it('USDCe -> WAVAX', async () => { + await testE2E( + tokens.USDCe, + tokens.WAVAX, + holders.USDCe, + '5', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('POPS -> WAVAX', async () => { + await testE2E( + tokens.POPS, + tokens.WAVAX, + holders.POPS, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('WAVAX -> POPS', async () => { + await testE2E( + tokens.WAVAX, + tokens.POPS, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); }); describe('multiSwap', () => { + it('WAVAX -> USDC', async () => { + await testE2E( + tokens.WAVAX, + tokens.USDC, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('USDC -> WAVAX', async () => { + await testE2E( + tokens.USDC, + tokens.WAVAX, + holders.USDC, + '5000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + it('USDC -> MIM', async () => { await testE2E( tokens.USDC, @@ -557,9 +655,79 @@ describe('UniswapV2 E2E Avalanche', () => { provider, ); }); + + it('USDCe -> WAVAX', async () => { + await testE2E( + tokens.USDCe, + tokens.WAVAX, + holders.USDCe, + '5', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('POPS -> WAVAX', async () => { + await testE2E( + tokens.POPS, + tokens.WAVAX, + holders.POPS, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('WAVAX -> POPS', async () => { + await testE2E( + tokens.WAVAX, + tokens.POPS, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); }); describe('megaSwap', () => { + it('WAVAX -> USDC', async () => { + await testE2E( + tokens.WAVAX, + tokens.USDC, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('USDC -> WAVAX', async () => { + await testE2E( + tokens.USDC, + tokens.WAVAX, + holders.USDC, + '5000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + it('USDC -> MIM', async () => { await testE2E( tokens.USDC, @@ -601,6 +769,48 @@ describe('UniswapV2 E2E Avalanche', () => { provider, ); }); + + it('USDCe -> WAVAX', async () => { + await testE2E( + tokens.USDCe, + tokens.WAVAX, + holders.USDCe, + '5', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('POPS -> WAVAX', async () => { + await testE2E( + tokens.POPS, + tokens.WAVAX, + holders.POPS, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('WAVAX -> POPS', async () => { + await testE2E( + tokens.WAVAX, + tokens.POPS, + holders.WAVAX, + '7000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index ac6188fa9..22e034600 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -517,6 +517,10 @@ export const Tokens: { address: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7', decimals: 6, }, + POPS: { + address: '0x240248628B7B6850352764C5dFa50D1592A033A8', + decimals: 18, + }, WAVAX: { address: '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7', decimals: 18, @@ -855,11 +859,12 @@ export const Holders: { avWAVAX: '0xc5ed2333f8a2C351fCA35E5EBAdb2A82F5d254C3', WAVAX: '0xAc1F5F1eDBcAE771be00d0eC044deC5BEdbFd816', sAVAX: '0xC73DF1e68FC203F6E4b6270240D6f82A850e8D38', - USDCe: '0xCe2CC46682E9C6D5f174aF598fb4931a9c0bE68e', + USDCe: '0x3a2434c698f8d79af1f5a9e43013157ca8b11a66', USDC: '0x4aefa39caeadd662ae31ab0ce7c8c2c9c0a013e8', USDTe: '0x84d34f4f83a87596cd3fb6887cff8f17bf5a7b83', USDT: '0x715f3c533Cf264215Ba8BE00838a053284351086', WETHe: '0xD291B51f7a1a1F4917D085F2a7731A447E4aF82D', + POPS: '0x5268c2331658cb0b2858cfa9db27d8f22f5434bc', ETH: '0x9852e84b5AA485683d8AeE7B0332e42442763b75', DAIE: '0xED2a7edd7413021d440b09D654f3b87712abAB66', TUSD: '0x5Db946411F08f15300f23D9bde4A407B07D56C03', @@ -868,7 +873,7 @@ export const Holders: { wBTC: '0xbB2BD754A45f400A01158A8b3C89DE085D58ABF1', renBTC: '0xb8D1D22609D10078Db36915fc4610F8674b44319', ADAI: '0xc5ed2333f8a2C351fCA35E5EBAdb2A82F5d254C3', - MIM: '0x652aD82d4CcbA3b162094b7bee69436d36754317', + MIM: '0xae4d3a42e46399827bd094b4426e2f79cca543ca', TSD: '0x691A89db352B72dDb249bFe16503494eC0D920A4', THO: '0xc40d16c47394a506d451475c8a7c46c1175c1da1', aAvaUSDT: '0x4cf82fe8e0072d546729d005b08faeeab8528cb7', From f5257c13ef5265da82e7158593e2241514b9d5a4 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 12:20:59 +0300 Subject: [PATCH 18/31] add tests swapcicle tests for bsc --- src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts | 237 ++++++++++++++++++ tests/constants-e2e.ts | 9 +- 2 files changed, 244 insertions(+), 2 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts index fe7f5d56c..75e7b3667 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts @@ -1406,4 +1406,241 @@ describe('UniswapV2 E2E BSC', () => { }); }); }); + + describe('Swapsicle', () => { + const dexKey = 'Swapsicle'; + + describe('simpleSwap', () => { + it('WBNB -> BUSD', async () => { + await testE2E( + tokens.WBNB, + tokens.BUSD, + holders.WBNB, + '1', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('WBNB -> POPS', async () => { + await testE2E( + tokens.WBNB, + tokens.POPS, + holders.WBNB, + '25', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('DAI -> WBNB', async () => { + await testE2E( + tokens.DAI, + tokens.WBNB, + holders.DAI, + '7000000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + + it('USDC -> WBNB', async () => { + await testE2E( + tokens.USDC, + tokens.WBNB, + holders.USDC, + '1000', + SwapSide.SELL, + dexKey, + ContractMethod.simpleSwap, + network, + provider, + ); + }); + }); + + describe('multiSwap', () => { + it('WBNB -> BUSD', async () => { + await testE2E( + tokens.WBNB, + tokens.BUSD, + holders.WBNB, + '1', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('WBNB -> POPS', async () => { + await testE2E( + tokens.WBNB, + tokens.POPS, + holders.WBNB, + '25', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('DAI -> WBNB', async () => { + await testE2E( + tokens.DAI, + tokens.WBNB, + holders.DAI, + '7000000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + + it('USDC -> WBNB', async () => { + await testE2E( + tokens.USDC, + tokens.WBNB, + holders.USDC, + '1000', + SwapSide.SELL, + dexKey, + ContractMethod.multiSwap, + network, + provider, + ); + }); + }); + + + describe('megaSwap', () => { + it('WBNB -> BUSD', async () => { + await testE2E( + tokens.WBNB, + tokens.BUSD, + holders.WBNB, + '1', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('WBNB -> POPS', async () => { + await testE2E( + tokens.WBNB, + tokens.POPS, + holders.WBNB, + '25', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('DAI -> WBNB', async () => { + await testE2E( + tokens.DAI, + tokens.WBNB, + holders.DAI, + '7000000000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + + it('USDC -> WBNB', async () => { + await testE2E( + tokens.USDC, + tokens.WBNB, + holders.USDC, + '1000', + SwapSide.SELL, + dexKey, + ContractMethod.megaSwap, + network, + provider, + ); + }); + }); + + describe('BuyMethod', () => { + it('WBNB -> BUSD', async () => { + await testE2E( + tokens.WBNB, + tokens.BUSD, + holders.WBNB, + '1', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + it('WBNB -> POPS', async () => { + await testE2E( + tokens.WBNB, + tokens.POPS, + holders.WBNB, + '25', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + + // it('DAI -> WBNB', async () => { + // await testE2E( + // tokens.DAI, + // tokens.WBNB, + // holders.DAI, + // '7000000000000000000', + // SwapSide.BUY, + // dexKey, + // ContractMethod.buy, + // network, + // provider, + // ); + // }); + + it('USDC -> WBNB', async () => { + await testE2E( + tokens.USDC, + tokens.WBNB, + holders.USDC, + '1000', + SwapSide.BUY, + dexKey, + ContractMethod.buy, + network, + provider, + ); + }); + }); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 22e034600..218777c98 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -442,6 +442,10 @@ export const Tokens: { }, }, [Network.BSC]: { + POPS: { + address: '0xa1051433EC7b5cc249c75Fdd5b96BF423f2f4A32', + decimals: 18, + }, DAI: { address: '0x1af3f329e8be154074d8769d1ffa4ee058b1dbc3', decimals: 18, @@ -761,7 +765,7 @@ export const Holders: { DODO: '0x3e19d726ed435afd3a42967551426b3a47c0f5b7', ADAI: '0x826c3064d4f5b9507152f5cb440ca9326e1ec8fa', AWETH: '0xa433105e7396070a5e1fdd7e2b2338f1bfa0de68', - BUSD: '0x47ac0Fb4F2D84898e4D9E7b4DaB3C24507a6D503', + BUSD: '0xf977814e90da44bfa03b6295a0616a897441acec', INCH: '0x4ee7c0f5480eb1edd8902a5e8b991ed52992d5f5', mUSD: '0x3aD1D5CFCF9169Da73C23D85d5f2Bf53bC9d39dF', mBTC: '0x15A295e9BCFcF93a8721DCb9A19330fc59771271', @@ -844,10 +848,11 @@ export const Holders: { DAI: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d', WBNB: '0x59d779bed4db1e734d3fda3172d45bc3063ecd69', BUSD: '0x0D0707963952f2fBA59dD06f2b425ace40b492Fe', + POPS: '0x74966a14eb9c5f185a34b31032264815e84104d8', BNB: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d', USDT: '0xf89d7b9c864f589bbf53a82105107622b35eaa40', ETH: '0xefdca55e4bce6c1d535cb2d0687b5567eef2ae83', - USDC: '0xF977814e90dA44bFA03b6295A0616a897441aceC', + USDC: '0x8894e0a0c962cb723c1976a4421c95949be2d4e3', RADIO: '0x75b3efed620e2d6750d88263cd4d7a27b0d7d3c5', bBTC: '0x72a53cdbbcc1b9efa39c834a540550e23463aacb', anyBTC: '0x4ffef8e8a75c20ab0ddf96c50d2457277d27923c', From 51931ca6998ba3e486c84dbc58b3ffd329de45f4 Mon Sep 17 00:00:00 2001 From: rorrieswap Date: Thu, 2 Feb 2023 20:00:15 +0000 Subject: [PATCH 19/31] Fixed swapsicle initCode --- src/dex/uniswap-v2/config.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index c3180f81e..b5d837d33 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -454,7 +454,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-polygon', factoryAddress: '0x735ab9808d792B5c8B54e31196c011c26C08b4ce', initCode: - '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + '0x2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, [Network.BSC]: { @@ -462,7 +462,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-bnb', factoryAddress: '0xEe673452BD981966d4799c865a96e0b92A8d0E45', initCode: - '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + '0x2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, [Network.FANTOM]: { @@ -470,7 +470,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-fantom', factoryAddress: '0x98F23162E3a7FE610aC89C88E4217a599A15858F', initCode: - 'cb64282d14f9033fbb6a3a827bd515fff027bb6994a0d33ac0424e7e3037dad3', + '0xcb64282d14f9033fbb6a3a827bd515fff027bb6994a0d33ac0424e7e3037dad3', feeCode: 30, }, [Network.ARBITRUM]: { @@ -478,7 +478,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-arbitrum', factoryAddress: '0x2f0c7c98462651bb2102f6cd05acdad333e031b0', initCode: - '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + '0x2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, [Network.MAINNET]: { @@ -486,7 +486,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-ethereum', factoryAddress: '0x2F0C7C98462651BB2102F6Cd05acDAd333E031b0', initCode: - '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + '0x2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, [Network.OPTIMISM]: { @@ -494,7 +494,7 @@ export const UniswapV2Config: DexConfigMap = { 'https://api.thegraph.com/subgraphs/name/swapsicledex/swapsicle-exchange-optimism', factoryAddress: '0x2f0c7c98462651bb2102f6cd05acdad333e031b0', initCode: - '2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', + '0x2ed0c8714ca80192f88764ee4b4c8c8cb6dfc01859a02b25ce67f304e499d48e', feeCode: 30, }, }, From ffb20b64243c27cbf4e80b53cccb09c0d5a30db7 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 16:16:21 +0300 Subject: [PATCH 20/31] refactor polygon swapsicle tests --- .../uniswap-v2/uniswap-v2-e2e-polygon.test.ts | 370 +++--------------- tests/constants-e2e.ts | 2 +- 2 files changed, 57 insertions(+), 315 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts index 1bdeb9022..2760a0f9a 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-polygon.test.ts @@ -2,8 +2,8 @@ import dotenv from 'dotenv'; dotenv.config(); import { testE2E } from '../../../tests/utils-e2e'; -import { Tokens, Holders } from '../../../tests/constants-e2e'; -import { Network, ContractMethod, SwapSide } from '../../constants'; +import { Holders, Tokens } from '../../../tests/constants-e2e'; +import { ContractMethod, Network, SwapSide } from '../../constants'; import { StaticJsonRpcProvider } from '@ethersproject/providers'; import { generateConfig } from '../../config'; @@ -1348,321 +1348,63 @@ describe('UniswapV2 E2E Polygon', () => { }); }); - describe('Swapsicle', () => { + describe(`Swapsicle`, () => { const dexKey = 'Swapsicle'; - describe('Simpleswap', () => { - it('QuickSwap MATIC -> USDC', async () => { - await testE2E( - tokens.MATIC, - tokens.USDC, - holders.MATIC, - '100000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap USDC -> MATIC', async () => { - await testE2E( - tokens.USDC, - tokens.MATIC, - holders.USDC, - '10000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap MATIC -> DAI', async () => { - await testE2E( - tokens.MATIC, - tokens.DAI, - holders.MATIC, - '70000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap DAI > MATIC', async () => { - await testE2E( - tokens.DAI, - tokens.MATIC, - holders.DAI, - '50000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap MATIC -> USDT', async () => { - await testE2E( - tokens.MATIC, - tokens.USDT, - holders.MATIC, - '70000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap USDT -> MATIC', async () => { - await testE2E( - tokens.USDT, - tokens.MATIC, - holders.USDT, - '1000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('QuickSwap MATIC -> POPS', async () => { - await testE2E( - tokens.MATIC, - tokens.POPS, - holders.MATIC, - '70000', - SwapSide.SELL, - dexKey, + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ ContractMethod.simpleSwap, - network, - provider, - ); - }); - - // it('QuickSwap POPS -> MATIC', async () => { - // await testE2E( - // tokens.POPS, - // tokens.WMATIC, - // holders.POPS, - // '8000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // ); - // }); - }); - - describe('Multiswap', () => { - it('Multiswap MATIC -> USDC', async () => { - await testE2E( - tokens.MATIC, - tokens.USDC, - holders.MATIC, - '100000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap USDC -> MATIC', async () => { - await testE2E( - tokens.USDC, - tokens.MATIC, - holders.USDC, - '200', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap MATIC -> DAI', async () => { - await testE2E( - tokens.MATIC, - tokens.DAI, - holders.MATIC, - '70000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap DAI -> MATIC', async () => { - await testE2E( - tokens.DAI, - tokens.MATIC, - holders.DAI, - '70000000000000', - SwapSide.SELL, - dexKey, ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap MATIC -> USDT', async () => { - await testE2E( - tokens.MATIC, - tokens.USDT, - holders.MATIC, - '70000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap USDT -> MATIC', async () => { - await testE2E( - tokens.USDT, - tokens.MATIC, - holders.USDT, - '500', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('Multiswap MATIC -> POPS', async () => { - await testE2E( - tokens.MATIC, - tokens.POPS, - holders.MATIC, - '70000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - }); - - describe('BuyMethod', () => { - it('Buy MATIC -> USDC', async () => { - await testE2E( - tokens.MATIC, - tokens.USDC, - holders.MATIC, - '7000000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy USDC -> MATIC', async () => { - await testE2E( - tokens.USDC, - tokens.MATIC, - holders.USDC, - '150', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy MATIC -> DAI', async () => { - await testE2E( - tokens.MATIC, - tokens.DAI, - holders.MATIC, - '650000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy DAI -> MATIC', async () => { - await testE2E( - tokens.DAI, - tokens.MATIC, - holders.DAI, - '150', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy MATIC -> USDT', async () => { - await testE2E( - tokens.MATIC, - tokens.USDT, - holders.MATIC, - '150000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy USDT -> MATIC', async () => { - await testE2E( - tokens.USDT, - tokens.MATIC, - holders.USDT, - '250', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('Buy MATIC -> POPS', async () => { - await testE2E( - tokens.MATIC, - tokens.POPS, - holders.MATIC, - '70000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - }); + ContractMethod.megaSwap, + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'MATIC', sellAmount: '100000000000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '10000000', buyAmount: '1000' }], + [{ name: 'MATIC', sellAmount: '1000000000', buyAmount: '1000' }, { name: 'DAI', sellAmount: '50000', buyAmount: '1000000000' }], + [{ name: 'MATIC', sellAmount: '100000000000000000', buyAmount: '1000' }, { name: 'USDT', sellAmount: '100000000', buyAmount: '1000' }], + [{ name: 'MATIC', sellAmount: '10000000', buyAmount: '1000' }, { name: 'POPS', sellAmount: '8000000', buyAmount: '1000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 218777c98..60fd70442 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -807,7 +807,7 @@ export const Holders: { WMATIC: '0xFffbCD322cEace527C8ec6Da8de2461C6D9d4e6e', AMWMATIC: '0x8832924854e3Cedb0a6Abf372e6CCFF9F7654332', USDC: '0x06959153B974D0D5fDfd87D561db6d8d4FA0bb0B', - POPS: '0xcc4c2d391b2abcf6d95463f3315f983696bbd6c2', + POPS: '0x2693b57ee51f4e2a26dfb339a911fa8731061f49', MUST: '0x9f2a409848fb9b7bd058b24a23e8dbf1e166a109', AMDAI: '0xFA0DCe8280FCDf369a4cbFc1830d3302789307a6', mUSD: '0x5084f622cbDf1E22E473d66d97916524745B9b6e', From 784659fa98e646cb37baa1205e52d243335e3332 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 19:05:23 +0300 Subject: [PATCH 21/31] refactor avalanche tests --- .../uniswap-v2-e2e-avalanche.test.ts | 392 +++--------------- tests/constants-e2e.ts | 2 +- 2 files changed, 54 insertions(+), 340 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts index 0c83f80ae..b5ee4da4f 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-avalanche.test.ts @@ -468,350 +468,64 @@ describe('UniswapV2 E2E Avalanche', () => { }); }); - describe('Swapsicle', () => { + describe(`Swapsicle`, () => { const dexKey = 'Swapsicle'; - describe('simpleSwap', () => { - it('WAVAX -> USDC', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDC, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('USDC -> WAVAX', async () => { - await testE2E( - tokens.USDC, - tokens.WAVAX, - holders.USDC, - '5000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('USDC -> MIM', async () => { - await testE2E( - tokens.USDC, - tokens.MIM, - holders.USDC, - '3000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('MIM -> USDC', async () => { - await testE2E( - tokens.MIM, - tokens.USDC, - holders.MIM, - '300000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('WAVAX -> USDCe', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDCe, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('USDCe -> WAVAX', async () => { - await testE2E( - tokens.USDCe, - tokens.WAVAX, - holders.USDCe, - '5', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('POPS -> WAVAX', async () => { - await testE2E( - tokens.POPS, - tokens.WAVAX, - holders.POPS, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('WAVAX -> POPS', async () => { - await testE2E( - tokens.WAVAX, - tokens.POPS, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ ContractMethod.simpleSwap, - network, - provider, - ); - }); - }); - - describe('multiSwap', () => { - it('WAVAX -> USDC', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDC, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('USDC -> WAVAX', async () => { - await testE2E( - tokens.USDC, - tokens.WAVAX, - holders.USDC, - '5000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('USDC -> MIM', async () => { - await testE2E( - tokens.USDC, - tokens.MIM, - holders.USDC, - '3000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('MIM -> USDC', async () => { - await testE2E( - tokens.MIM, - tokens.USDC, - holders.MIM, - '3000000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('WAVAX -> USDCe', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDCe, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('USDCe -> WAVAX', async () => { - await testE2E( - tokens.USDCe, - tokens.WAVAX, - holders.USDCe, - '5', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('POPS -> WAVAX', async () => { - await testE2E( - tokens.POPS, - tokens.WAVAX, - holders.POPS, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('WAVAX -> POPS', async () => { - await testE2E( - tokens.WAVAX, - tokens.POPS, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, ContractMethod.multiSwap, - network, - provider, - ); - }); - }); - - describe('megaSwap', () => { - it('WAVAX -> USDC', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDC, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('USDC -> WAVAX', async () => { - await testE2E( - tokens.USDC, - tokens.WAVAX, - holders.USDC, - '5000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('USDC -> MIM', async () => { - await testE2E( - tokens.USDC, - tokens.MIM, - holders.USDC, - '3000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('MIM -> USDC', async () => { - await testE2E( - tokens.MIM, - tokens.USDC, - holders.MIM, - '3000000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('WAVAX -> USDCe', async () => { - await testE2E( - tokens.WAVAX, - tokens.USDCe, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('USDCe -> WAVAX', async () => { - await testE2E( - tokens.USDCe, - tokens.WAVAX, - holders.USDCe, - '5', - SwapSide.SELL, - dexKey, ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('POPS -> WAVAX', async () => { - await testE2E( - tokens.POPS, - tokens.WAVAX, - holders.POPS, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('WAVAX -> POPS', async () => { - await testE2E( - tokens.WAVAX, - tokens.POPS, - holders.WAVAX, - '7000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - }); + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'WAVAX', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '5000', buyAmount: '10000000' }], + [{ name: 'USDCe', sellAmount: '3000000000', buyAmount: '1000' }, { name: 'MIM', sellAmount: '300000000000000000', buyAmount: '300000' }], + [{ name: 'WAVAX', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'USDCe', sellAmount: '1000', buyAmount: '1000' }], + [{ name: 'POPS', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'WAVAX', sellAmount: '7000000000000000000', buyAmount: '1000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); }); describe('CanarySwap', () => { diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 60fd70442..697f3079b 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -878,7 +878,7 @@ export const Holders: { wBTC: '0xbB2BD754A45f400A01158A8b3C89DE085D58ABF1', renBTC: '0xb8D1D22609D10078Db36915fc4610F8674b44319', ADAI: '0xc5ed2333f8a2C351fCA35E5EBAdb2A82F5d254C3', - MIM: '0xae4d3a42e46399827bd094b4426e2f79cca543ca', + MIM: '0x64cb3f5aada07d831b8db6c6d9c715c53c251ef3', TSD: '0x691A89db352B72dDb249bFe16503494eC0D920A4', THO: '0xc40d16c47394a506d451475c8a7c46c1175c1da1', aAvaUSDT: '0x4cf82fe8e0072d546729d005b08faeeab8528cb7', From b2b4780e771a2fa8f771d92d7d574cf4a5ae5d15 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 19:17:57 +0300 Subject: [PATCH 22/31] refactor bsc chain tests --- src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts | 283 ++++-------------- tests/constants-e2e.ts | 2 +- 2 files changed, 54 insertions(+), 231 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts index 75e7b3667..98e86d090 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-bsc.test.ts @@ -1407,240 +1407,63 @@ describe('UniswapV2 E2E BSC', () => { }); }); - describe('Swapsicle', () => { + describe(`Swapsicle`, () => { const dexKey = 'Swapsicle'; - describe('simpleSwap', () => { - it('WBNB -> BUSD', async () => { - await testE2E( - tokens.WBNB, - tokens.BUSD, - holders.WBNB, - '1', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('WBNB -> POPS', async () => { - await testE2E( - tokens.WBNB, - tokens.POPS, - holders.WBNB, - '25', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('DAI -> WBNB', async () => { - await testE2E( - tokens.DAI, - tokens.WBNB, - holders.DAI, - '7000000000000000000000', - SwapSide.SELL, - dexKey, + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ ContractMethod.simpleSwap, - network, - provider, - ); - }); - - it('USDC -> WBNB', async () => { - await testE2E( - tokens.USDC, - tokens.WBNB, - holders.USDC, - '1000', - SwapSide.SELL, - dexKey, - ContractMethod.simpleSwap, - network, - provider, - ); - }); - }); - - describe('multiSwap', () => { - it('WBNB -> BUSD', async () => { - await testE2E( - tokens.WBNB, - tokens.BUSD, - holders.WBNB, - '1', - SwapSide.SELL, - dexKey, ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('WBNB -> POPS', async () => { - await testE2E( - tokens.WBNB, - tokens.POPS, - holders.WBNB, - '25', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('DAI -> WBNB', async () => { - await testE2E( - tokens.DAI, - tokens.WBNB, - holders.DAI, - '7000000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - - it('USDC -> WBNB', async () => { - await testE2E( - tokens.USDC, - tokens.WBNB, - holders.USDC, - '1000', - SwapSide.SELL, - dexKey, - ContractMethod.multiSwap, - network, - provider, - ); - }); - }); - - - describe('megaSwap', () => { - it('WBNB -> BUSD', async () => { - await testE2E( - tokens.WBNB, - tokens.BUSD, - holders.WBNB, - '1', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('WBNB -> POPS', async () => { - await testE2E( - tokens.WBNB, - tokens.POPS, - holders.WBNB, - '25', - SwapSide.SELL, - dexKey, ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('DAI -> WBNB', async () => { - await testE2E( - tokens.DAI, - tokens.WBNB, - holders.DAI, - '7000000000000000000000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - - it('USDC -> WBNB', async () => { - await testE2E( - tokens.USDC, - tokens.WBNB, - holders.USDC, - '1000', - SwapSide.SELL, - dexKey, - ContractMethod.megaSwap, - network, - provider, - ); - }); - }); - - describe('BuyMethod', () => { - it('WBNB -> BUSD', async () => { - await testE2E( - tokens.WBNB, - tokens.BUSD, - holders.WBNB, - '1', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - it('WBNB -> POPS', async () => { - await testE2E( - tokens.WBNB, - tokens.POPS, - holders.WBNB, - '25', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - - // it('DAI -> WBNB', async () => { - // await testE2E( - // tokens.DAI, - // tokens.WBNB, - // holders.DAI, - // '7000000000000000000', - // SwapSide.BUY, - // dexKey, - // ContractMethod.buy, - // network, - // provider, - // ); - // }); - - it('USDC -> WBNB', async () => { - await testE2E( - tokens.USDC, - tokens.WBNB, - holders.USDC, - '1000', - SwapSide.BUY, - dexKey, - ContractMethod.buy, - network, - provider, - ); - }); - }); + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'WBNB', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'BUSD', sellAmount: '5000', buyAmount: '10000000' }], + [{ name: 'WBNB', sellAmount: '3000000000', buyAmount: '1000' }, { name: 'POPS', sellAmount: '800000000000', buyAmount: '800000000000' }], + [{ name: 'WBNB', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'DAI', sellAmount: '1000', buyAmount: '1000' }], + [{ name: 'WBNB', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '700', buyAmount: '1000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 697f3079b..5f1f1c3ce 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -848,7 +848,7 @@ export const Holders: { DAI: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d', WBNB: '0x59d779bed4db1e734d3fda3172d45bc3063ecd69', BUSD: '0x0D0707963952f2fBA59dD06f2b425ace40b492Fe', - POPS: '0x74966a14eb9c5f185a34b31032264815e84104d8', + POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591', BNB: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d', USDT: '0xf89d7b9c864f589bbf53a82105107622b35eaa40', ETH: '0xefdca55e4bce6c1d535cb2d0687b5567eef2ae83', From c2cbc59f2b17a3ad72af8b9bd8d3efea88fe5b32 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 19:41:57 +0300 Subject: [PATCH 23/31] add fantom tests --- .../uniswap-v2/uniswap-v2-e2e-fantom.test.ts | 61 +++++++++++++++++++ tests/constants-e2e.ts | 17 +++++- 2 files changed, 77 insertions(+), 1 deletion(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-fantom.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-fantom.test.ts index b1d849ea3..e472bdf41 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-fantom.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-fantom.test.ts @@ -1345,4 +1345,65 @@ describe('UniswapV2 E2E Fantom', () => { }); }); }); + + describe(`Swapsicle`, () => { + const dexKey = 'Swapsicle'; + + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ + ContractMethod.simpleSwap, + ContractMethod.multiSwap, + ContractMethod.megaSwap, + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'WFTM', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '5000', buyAmount: '10000000' }], + [{ name: 'WFTM', sellAmount: '3000000000', buyAmount: '1000' }, { name: 'POPS', sellAmount: '800000000000', buyAmount: '800000000000' }], + [{ name: 'WFTM', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'MIM', sellAmount: '1000', buyAmount: '1000' }], + [{ name: 'WFTM', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'DAI', sellAmount: '1000', buyAmount: '1000' }], + [{ name: 'WFTM', sellAmount: '7000000000000000000', buyAmount: '1000' }, { name: 'FUSDT', sellAmount: '1000', buyAmount: '1000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 5f1f1c3ce..bcac2fd0b 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -404,6 +404,10 @@ export const Tokens: { address: '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83', decimals: 18, }, + DAI: { + address: '0x8d11ec38a3eb5e956b052f67da8bdc9bef8abf3e', + decimals: 18, + }, USDC: { address: '0x04068DA6C83AFCFA0e13ba15A6696662335D5B75', decimals: 6, @@ -412,6 +416,14 @@ export const Tokens: { address: '0x049d68029688eabf473097a2fc38ef61633a3c7a', decimals: 6, }, + POPS: { + address: '0x9dE4b40bDcE50Ec6a1A668bF85997BbBD324069a', + decimals: 18, + }, + MIM: { + address: '0x82f0b8b456c1a451378467398982d4834b6829c1', + decimals: 18, + }, FRAX: { address: '0xdc301622e621166BD8E82f2cA0A26c13Ad0BE355', decimals: 18, @@ -830,12 +842,15 @@ export const Holders: { MAI: '0x9a8cf02f3e56c664ce75e395d0e4f3dc3dafe138', }, [Network.FANTOM]: { + DAI: '0x370f4b2dcf75c94d8d4450b493661a9c6170d0b5', FTM: '0xEBf4FBB9C81b84dd5CF89BC75588E5d0018501b3', WFTM: '0x4901C740607E415685b4d09E4Aa960329cd183Ca', USDC: '0xd1e4a32679216f4a4dd38e45dab9bc4b8a45e592', - FUSDT: '0xca436e14855323927d6e6264470ded36455fc8bd', + FUSDT: '0x66b870ddf78c975af5cd8edc6de25eca81791de1', + POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591', aFanUSDT: '0xb0c9c5b5211de3a75b61bb798887b76accd64193', aFanWFTM: '0x639ade8805c0081ea5da9495bb50751003e827cc', + MIM: '0xbcab7d083cf6a01e0dda9ed7f8a02b47d125e682', FRAX: '0x4423ac71f53ca92e2f2be5917a9c2468e7412f4a', nETH: '0x16b658270ac50c0063940ed287c401b3df7ccf70', WETH: '0x4ad64fd7ca6d6150614179b9bce4094bc18f29cb', From 13a9bd0985261eacd44f1910f964706977919588 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Fri, 3 Feb 2023 20:02:38 +0300 Subject: [PATCH 24/31] add mainnet tests --- .../uniswap-v2/uniswap-v2-e2e-mainnet.test.ts | 57 +++++++++++++++++++ tests/constants-e2e.ts | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts index b65914c6b..9df50d5d4 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-mainnet.test.ts @@ -1222,4 +1222,61 @@ describe('UniswapV2 E2E Mainnet', () => { }); }); }); + + describe(`Swapsicle`, () => { + const dexKey = 'Swapsicle'; + + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ + ContractMethod.simpleSwap, + ContractMethod.multiSwap, + ContractMethod.megaSwap, + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'USDC', sellAmount: '7000', buyAmount: '10000' }, { name: 'WETH', sellAmount: '1000000000000000000', buyAmount: '4000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index bcac2fd0b..45652753e 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -761,7 +761,7 @@ export const Holders: { BADGER: '0x34e2741a3f8483dbe5231f61c005110ff4b9f50a', STETH: '0x9bdb521a97e95177bf252c253e256a60c3e14447', wstETH: '0x6cE0F913F035ec6195bC3cE885aec4C66E485BC4', - WETH: '0x6555e1CC97d3cbA6eAddebBCD7Ca51d75771e0B8', + WETH: '0x56178a0d5f301baf6cf3e1cd53d9863437345bf9', USDT: '0x5754284f345afc66a98fbb0a0afe71e0f007b949', XAUT: '0xc4e161e8d8a4bc4ac762ab33a28bbac5474203d7', CVX: '0x0aCA67Fa70B142A3b9bF2eD89A81B40ff85dACdC', From d676e6610a881d295d7ee7420b82aeff41bea131 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Mon, 6 Feb 2023 11:27:26 +0300 Subject: [PATCH 25/31] add optimism tests --- .../uniswap-v2-e2e-arbitrum.test.ts | 62 +++++++++++++++++++ .../uniswap-v2-e2e-optimism.test.ts | 61 ++++++++++++++++++ tests/constants-e2e.ts | 12 +++- 3 files changed, 134 insertions(+), 1 deletion(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts index ea899debb..2026a2432 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts @@ -187,4 +187,66 @@ describe('UniswapV2 E2E Arbitrum', () => { }); }); }); + + // describe(`Swapsicle`, () => { + // const dexKey = 'Swapsicle'; + // + // const sideToContractMethods = new Map([ + // [ + // SwapSide.SELL, + // [ + // ContractMethod.simpleSwap, + // ContractMethod.multiSwap, + // ContractMethod.megaSwap, + // ], + // ], + // [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + // ]); + // + // const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + // // [{ name: 'WETH', sellAmount: '70000', buyAmount: '700000000' }, { name: 'USDC', sellAmount: '1000000', buyAmount: '4000000' }], + // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'USDT', sellAmount: '10000', buyAmount: '40000' }], + // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'DAI', sellAmount: '10000', buyAmount: '40000' }], + // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'DAI', sellAmount: '10000', buyAmount: '40000' }], + // // [{ name: 'POPS', sellAmount: '7000', buyAmount: '10000' }, { name: 'USDC', sellAmount: '10000', buyAmount: '40000' }], + // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'POPS', sellAmount: '10000', buyAmount: '40000' }], + // ]; + // + // sideToContractMethods.forEach((contractMethods, side) => + // describe(`${side}`, () => { + // contractMethods.forEach((contractMethod: ContractMethod) => { + // pairs.forEach((pair) => { + // describe(`${contractMethod}`, () => { + // it(`${pair[0].name} -> ${pair[1].name}`, async () => { + // await testE2E( + // tokens[pair[0].name], + // tokens[pair[1].name], + // holders[pair[0].name], + // side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + // side, + // dexKey, + // contractMethod, + // network, + // provider, + // ); + // }); + // it(`${pair[1].name} -> ${pair[0].name}`, async () => { + // await testE2E( + // tokens[pair[1].name], + // tokens[pair[0].name], + // holders[pair[1].name], + // side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + // side, + // dexKey, + // contractMethod, + // network, + // provider, + // ); + // }); + // }); + // }); + // }); + // }), + // ); + // }); }); diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-optimism.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-optimism.test.ts index d61a57b9a..0040b5556 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-optimism.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-optimism.test.ts @@ -187,4 +187,65 @@ describe('UniswapV2 E2E Optimism', () => { }); }); }); + + describe(`Swapsicle`, () => { + const dexKey = 'Swapsicle'; + + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ + ContractMethod.simpleSwap, + ContractMethod.multiSwap, + ContractMethod.megaSwap, + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'OP', sellAmount: '1000000000000000000', buyAmount: '7000' }, { name: 'USDC', sellAmount: '1000', buyAmount: '4000' }], + [{ name: 'WETH', sellAmount: '700000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '100000', buyAmount: '40000' }], + [{ name: 'WETH', sellAmount: '1000000000000000000', buyAmount: '70000000' }, { name: 'DAI', sellAmount: '1000000000000000000', buyAmount: '4000' }], + [{ name: 'WETH', sellAmount: '1000000000000000000', buyAmount: '1000' }, { name: 'USDT', sellAmount: '100000', buyAmount: '40000' }], + [{ name: 'POPS', sellAmount: '1000000000000000000', buyAmount: '10000000' }, { name: 'WETH', sellAmount: '1000000000000000000', buyAmount: '1000000000000000000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 977a970d5..a32e1714c 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -673,6 +673,10 @@ export const Tokens: { address: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8', decimals: 6, }, + USDT: { + address: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9', + decimals: 6, + }, FRAX: { address: '0x17FC002b466eEc40DaE837Fc4bE5c67993ddBd6F', decimals: 18, @@ -720,6 +724,10 @@ export const Tokens: { address: '0x94b008aA00579c1307B0EF2c499aD98a8ce58e58', decimals: 6, }, + POPS: { + address: '0x3D51a9fB5dCc87F7B237B04975559b920a9a56Ff', + decimals: 18, + }, OP: { address: '0x4200000000000000000000000000000000000042', decimals: 18, @@ -914,6 +922,7 @@ export const Holders: { DAI: '0xc5ed2333f8a2C351fCA35E5EBAdb2A82F5d254C3', WETH: '0xc2707568D31F3fB1Fc55B2F8b2ae5682eAa72041', USDC: '0xd6216fc19db775df9774a6e33526131da7d19a2c', + USDT: '0x9dd329f5411466d9e0c488ff72519ca9fef0cb40', FRAX: '0x59bf0545fca0e5ad48e13da269facd2e8c886ba4', nUSD: '0x9dd329f5411466d9e0c488ff72519ca9fef0cb40', nETH: '0xa067668661c84476afcdc6fa5d758c4c01c34352', @@ -925,7 +934,8 @@ export const Holders: { [Network.OPTIMISM]: { ETH: '0x9ef21bE1C270AA1c3c3d750F458442397fBFFCB6', DAI: '0x1337bedc9d22ecbe766df105c9623922a27963ec', - WETH: '0x68526A4295236D2f18cEda8A200CdDD5Aab9e2cC', + WETH: '0x85149247691df622eaf1a8bd0cafd40bc45154a9', + POPS: '0x3cbd9044aaabef08ce93a68448e093cff405ad76', USDC: '0xEBb8EA128BbdFf9a1780A4902A9380022371d466', USDT: '0xEBb8EA128BbdFf9a1780A4902A9380022371d466', OP: '0xEBb8EA128BbdFf9a1780A4902A9380022371d466', From 209ed1ec5e5b7fcafc089984646a66c72fc452a6 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Mon, 6 Feb 2023 14:18:52 +0300 Subject: [PATCH 26/31] add test for arbitrum --- .../uniswap-v2-e2e-arbitrum.test.ts | 121 +++++++++--------- tests/constants-e2e.ts | 11 +- 2 files changed, 68 insertions(+), 64 deletions(-) diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts index 2026a2432..7286001ab 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts @@ -188,65 +188,64 @@ describe('UniswapV2 E2E Arbitrum', () => { }); }); - // describe(`Swapsicle`, () => { - // const dexKey = 'Swapsicle'; - // - // const sideToContractMethods = new Map([ - // [ - // SwapSide.SELL, - // [ - // ContractMethod.simpleSwap, - // ContractMethod.multiSwap, - // ContractMethod.megaSwap, - // ], - // ], - // [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], - // ]); - // - // const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ - // // [{ name: 'WETH', sellAmount: '70000', buyAmount: '700000000' }, { name: 'USDC', sellAmount: '1000000', buyAmount: '4000000' }], - // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'USDT', sellAmount: '10000', buyAmount: '40000' }], - // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'DAI', sellAmount: '10000', buyAmount: '40000' }], - // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'DAI', sellAmount: '10000', buyAmount: '40000' }], - // // [{ name: 'POPS', sellAmount: '7000', buyAmount: '10000' }, { name: 'USDC', sellAmount: '10000', buyAmount: '40000' }], - // // [{ name: 'WETH', sellAmount: '7000', buyAmount: '10000' }, { name: 'POPS', sellAmount: '10000', buyAmount: '40000' }], - // ]; - // - // sideToContractMethods.forEach((contractMethods, side) => - // describe(`${side}`, () => { - // contractMethods.forEach((contractMethod: ContractMethod) => { - // pairs.forEach((pair) => { - // describe(`${contractMethod}`, () => { - // it(`${pair[0].name} -> ${pair[1].name}`, async () => { - // await testE2E( - // tokens[pair[0].name], - // tokens[pair[1].name], - // holders[pair[0].name], - // side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, - // side, - // dexKey, - // contractMethod, - // network, - // provider, - // ); - // }); - // it(`${pair[1].name} -> ${pair[0].name}`, async () => { - // await testE2E( - // tokens[pair[1].name], - // tokens[pair[0].name], - // holders[pair[1].name], - // side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, - // side, - // dexKey, - // contractMethod, - // network, - // provider, - // ); - // }); - // }); - // }); - // }); - // }), - // ); - // }); + describe(`Swapsicle`, () => { + const dexKey = 'Swapsicle'; + + const sideToContractMethods = new Map([ + [ + SwapSide.SELL, + [ + ContractMethod.simpleSwap, + ContractMethod.multiSwap, + ContractMethod.megaSwap, + ], + ], + [SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]], + ]); + + const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [ + [{ name: 'WETH', sellAmount: '700000000000', buyAmount: '1000' }, { name: 'USDC', sellAmount: '100000', buyAmount: '4000' }], + [{ name: 'WETH', sellAmount: '700000000000', buyAmount: '10000' }, { name: 'USDT', sellAmount: '100000', buyAmount: '40000' }], + [{ name: 'WETH', sellAmount: '700000000000', buyAmount: '10000' }, { name: 'DAI', sellAmount: '1000000000000', buyAmount: '40000000' }], + [{ name: 'POPS', sellAmount: '1000000000000000000', buyAmount: '10000' }, { name: 'USDC', sellAmount: '10000', buyAmount: '40000' }], + [{ name: 'WETH', sellAmount: '1000000000000000000', buyAmount: '10000000' }, { name: 'POPS', sellAmount: '1000000000000000000', buyAmount: '1000000000000000000' }], + ]; + + sideToContractMethods.forEach((contractMethods, side) => + describe(`${side}`, () => { + contractMethods.forEach((contractMethod: ContractMethod) => { + pairs.forEach((pair) => { + describe(`${contractMethod}`, () => { + it(`${pair[0].name} -> ${pair[1].name}`, async () => { + await testE2E( + tokens[pair[0].name], + tokens[pair[1].name], + holders[pair[0].name], + side === SwapSide.SELL ? pair[0].sellAmount : pair[0].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + it(`${pair[1].name} -> ${pair[0].name}`, async () => { + await testE2E( + tokens[pair[1].name], + tokens[pair[0].name], + holders[pair[1].name], + side === SwapSide.SELL ? pair[1].sellAmount : pair[1].buyAmount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }); + }), + ); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index a32e1714c..1fd1688f5 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -705,6 +705,10 @@ export const Tokens: { address: '0x64343594ab9b56e99087bfa6f2335db24c2d1f17', decimals: 18, }, + POPS: { + address: '0xa0b20DecBc557E3f68E140eD5a0c69bc865F865A', + decimals: 18, + }, }, [Network.OPTIMISM]: { DAI: { @@ -919,10 +923,11 @@ export const Holders: { }, [Network.ARBITRUM]: { ETH: '0xF977814e90dA44bFA03b6295A0616a897441aceC', - DAI: '0xc5ed2333f8a2C351fCA35E5EBAdb2A82F5d254C3', - WETH: '0xc2707568D31F3fB1Fc55B2F8b2ae5682eAa72041', - USDC: '0xd6216fc19db775df9774a6e33526131da7d19a2c', + DAI: '0x252cd7185db7c3689a571096d5b57d45681aa080', + WETH: '0xb7e50106a5bd3cf21af210a755f9c8740890a8c9', + USDC: '0x905dfcd5649217c42684f23958568e533c711aa3', USDT: '0x9dd329f5411466d9e0c488ff72519ca9fef0cb40', + POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591', FRAX: '0x59bf0545fca0e5ad48e13da269facd2e8c886ba4', nUSD: '0x9dd329f5411466d9e0c488ff72519ca9fef0cb40', nETH: '0xa067668661c84476afcdc6fa5d758c4c01c34352', From 3da8b7fd7da085189b2c10fdea88f2f6d1548b8e Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Mon, 6 Feb 2023 14:26:35 +0300 Subject: [PATCH 27/31] add GH Actions basic CI --- .github/workflows/ci.yaml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 000000000..489c583bb --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,22 @@ +name: CI +on: push + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + node: [ '16.x' ] + name: Node ${{ matrix.node }} sample + steps: + - uses: actions/checkout@v2 + - name: Setup node + uses: actions/setup-node@v2 + with: + node-version: ${{ matrix.node }} + + - name: Install Dependencies + run: yarn + + - name: Run Eslint checks + run: yarn check:es From 491f913f6da1a82cb6b52261c5f68909752a82d2 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Mon, 6 Feb 2023 16:28:42 +0300 Subject: [PATCH 28/31] add GCI badge in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c4f62d38f..723826186 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# ParaSwap DexLib +# ParaSwap DexLib [![CI](https://github.com/paraswap/paraswap-dex-lib/actions/workflows/ci.yaml/badge.svg?branch=master)](https://github.com/paraswap/paraswap-dex-lib/actions/workflows/ci.yaml) **DexLib** is a library used by ParaSwap backend to integrate with decentralized exchanges. This library enables external DEX developers to integrate their DEX with ParaSwap by creating pull requests to this repository. From c937437b425b4a1a98fc5ff882dc2d1cfc781a7c Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Tue, 7 Feb 2023 11:12:04 +0300 Subject: [PATCH 29/31] 2.9.56-swapsicle-integration --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c018f387..7cc7886d6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.55", + "version": "2.9.56-swapsicle-integration", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 51a5d273e7f7544c9b1cbd63137912122aeae04f Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Wed, 8 Feb 2023 10:57:11 +0300 Subject: [PATCH 30/31] 2.9.56 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7cc7886d6..5766eabb3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.56-swapsicle-integration", + "version": "2.9.56", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 020e2fbccfd9c6a28f28315d06eaa8bf0df2c0dd Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Wed, 8 Feb 2023 13:26:05 +0300 Subject: [PATCH 31/31] 2.9.57 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5766eabb3..333fd33ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.9.56", + "version": "2.9.57", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib",