From ced221cde94bca0555f3a40eced2e58f2fbedd6e Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 19 Jun 2024 10:12:57 +0300 Subject: [PATCH 01/28] feat: add X Layer chain & config --- src/config.ts | 31 ++++++++++++++++++++++++++++++- src/constants.ts | 1 + tests/constants-e2e.ts | 29 +++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/config.ts b/src/config.ts index e04b92ff6..5db6f2b0b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -366,7 +366,6 @@ const baseConfigs: { [network: number]: BaseConfig } = { PolygonZkEvmAdapter01: '0xd63B7691dD98fa89A2ea5e1604700489c585aa7B', PolygonZkEvmBuyAdapter: '0xe2137168CdA486a2555E16c597905854C84F9127', }, - rpcPollingMaxAllowedStateDelayInBlocks: 0, rpcPollingBlocksBackToTriggerUpdate: 0, hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '', @@ -378,6 +377,36 @@ const baseConfigs: { [network: number]: BaseConfig } = { // FIXME: Not set properly uniswapV2ExchangeRouterAddress: '', }, + [Network.X_LAYER]: { + network: Network.X_LAYER, + networkName: 'X Layer', + isTestnet: false, + nativeTokenName: 'OKB', + nativeTokenSymbol: 'OKB', + wrappedNativeTokenAddress: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + // TODO-X + hasEIP1559: true, + augustusAddress: '0x0000000000000000000000000000000000000000', + augustusRFQAddress: '0x0000000000000000000000000000000000000000', + tokenTransferProxyAddress: '0x0000000000000000000000000000000000000000', + multicallV2Address: '0xBCfc39fad3118e307504F4F776BEAe2b478bA61c', + privateHttpProvider: process.env.HTTP_PROVIDER_196, + augustusV6Address: '0xcef4aa30328d1802c0e596fa6090a9ea36103ea3', + adapterAddresses: {}, + executorsAddresses: { + Executor01: '0xa89e2ed6f043cb0cea9221f532bcdc9a41580c78', + Executor02: '0xc2465233ae9fa2f8d68a435901129cfd23a06441', + Executor03: '0x9eca9e8529da35b456d6ecf01626f22d65b54859', + }, + rpcPollingMaxAllowedStateDelayInBlocks: 0, + rpcPollingBlocksBackToTriggerUpdate: 0, + hashFlowDisabledMMs: [], + uniswapV3EventLoggingSampleRate: 0, + rfqConfigs: {}, + forceRpcFallbackDexs: [], + // FIXME: Not set properly + uniswapV2ExchangeRouterAddress: '', + }, [Network.BASE]: { network: Network.BASE, networkName: 'Base', diff --git a/src/constants.ts b/src/constants.ts index 7a8adb4b8..230620cd2 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -41,6 +41,7 @@ export enum Network { ARBITRUM = 42161, OPTIMISM = 10, BASE = 8453, + X_LAYER = 196, } export const SUBGRAPH_TIMEOUT = 20 * 1000; diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 66c7e7508..4df17735f 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1220,6 +1220,28 @@ export const Tokens: { decimals: 6, }, }, + [Network.X_LAYER]: { + OKB: { + address: ETHER_ADDRESS, + decimals: 18, + }, + WETH: { + address: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', + decimals: 18, + }, + WBTC: { + address: '0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1', + decimals: 8, + }, + USDC: { + address: '0x74b7f16337b8972027f6196a17a631ac6de26d22', + decimals: 6, + }, + USDT: { + address: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', + decimals: 6, + }, + }, [Network.BASE]: { PRIME: { address: '0xfA980cEd6895AC314E7dE34Ef1bFAE90a5AdD21b', @@ -1573,6 +1595,13 @@ export const Holders: { WBTC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c', USDC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c', }, + [Network.X_LAYER]: { + OKB: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', + WOKB: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', + USDT: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', + WBTC: '0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1', + USDC: '0x74b7f16337b8972027f6196a17a631ac6de26d22', + }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', PRIME: '0x956bcc6b56c99db382d9d97a30ba5f1402144b3e', From edbfab5c8618ad1277cc0a6c45050608b8d3951a Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 19 Jun 2024 10:14:09 +0300 Subject: [PATCH 02/28] feat: add QuickSwapV3 on xLayer --- .../algebra-pool-v1_9_bidirectional_fee.ts | 2 +- src/dex/algebra/config.ts | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts b/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts index 5e83e5a81..81be0ba20 100644 --- a/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts +++ b/src/dex/algebra/algebra-pool-v1_9_bidirectional_fee.ts @@ -32,7 +32,7 @@ export class AlgebraEventPoolV1_9_bidirectional_fee extends AlgebraEventPoolV1_1 mapKey, poolInitCodeHash, poolDeployer, - false, // forceManualStateGeneration; mainly for zkEVM + true, // forceManualStateGeneration; mainly used for xLayer false, // areTicksCompressed ); diff --git a/src/dex/algebra/config.ts b/src/dex/algebra/config.ts index e3d726231..a06611b4b 100644 --- a/src/dex/algebra/config.ts +++ b/src/dex/algebra/config.ts @@ -34,6 +34,24 @@ export const AlgebraConfig: DexConfigMap = { version: 'v1.1', forceManualStateGenerate: true, }, + [Network.X_LAYER]: { + factory: '0xd2480162Aa7F02Ead7BF4C127465446150D58452', + router: '0x4B9f4d2435Ef65559567e5DbFC1BbB37abC43B57', + quoter: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', + initHash: + '0xbce37a54eab2fcd71913a0d40723e04238970e7fc1159bfd58ad5b79531697e7', + // TODO-X + chunksCount: 3, + // TODO-X + initRetryFrequency: 30, + algebraStateMulticall: '0x6a34523Cb05BdfD39F01016358A8dF717Dbd5aca', + subgraphURL: + 'https://api.studio.thegraph.com/query/72680/quickswapv3-x-layer/v0.0.7', + uniswapMulticall: '0xc7efb32470dEE601959B15f1f923e017C6A918cA', + deployer: '0x56c2162254b0E4417288786eE402c2B41d4e181e', + version: 'v1.9-bidirectional-fee', + forceManualStateGenerate: true, + }, }, ZyberSwapV3: { [Network.ARBITRUM]: { From af970ee1c2bd6759c0063a5b1a33e60d19100a86 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Mon, 24 Jun 2024 18:40:15 +0300 Subject: [PATCH 03/28] 3.5.5-x-layer.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 36a30cf30..3f393306d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.5.4", + "version": "3.5.5-x-layer.0", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 47e96dee522016425ba924239de4762c696844d2 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Mon, 24 Jun 2024 18:52:40 +0300 Subject: [PATCH 04/28] feat: add Wokb support on XLayer --- src/dex/weth/config.ts | 5 +++ src/dex/weth/weth-e2e.test.ts | 68 +++++++++++++++++++++++++++++ src/executor/WETHBytecodeBuilder.ts | 1 + tests/constants-e2e.ts | 4 ++ 4 files changed, 78 insertions(+) diff --git a/src/dex/weth/config.ts b/src/dex/weth/config.ts index f9313cf80..ef057bb82 100644 --- a/src/dex/weth/config.ts +++ b/src/dex/weth/config.ts @@ -46,6 +46,11 @@ export const WethConfig: DexConfigMap = { poolGasCost: WethGasCost, }, }, + Wokb: { + [Network.X_LAYER]: { + poolGasCost: WethGasCost, + }, + }, }; export const Adapters: { diff --git a/src/dex/weth/weth-e2e.test.ts b/src/dex/weth/weth-e2e.test.ts index fddab634e..b2acbe6d4 100644 --- a/src/dex/weth/weth-e2e.test.ts +++ b/src/dex/weth/weth-e2e.test.ts @@ -873,4 +873,72 @@ describe('Weth E2E', () => { }); }); }); + + describe('Wokb XLayer', () => { + const dexKey = 'Wokb'; + const network = Network.X_LAYER; + + const nativeTokenSymbol = 'OKB'; + const wrappedTokenSymbol = 'WOKB'; + + const nativeAmount = '1000000000000000000'; + const wrappedAmount = '1000000000000000000'; + + const tokens = Tokens[network]; + const holders = Holders[network]; + const provider = new StaticJsonRpcProvider( + generateConfig(network).privateHttpProvider, + network, + ); + + const nativeToken = tokens[nativeTokenSymbol]; + const wrappedToken = tokens[wrappedTokenSymbol]; + + const nativeHolder = holders[nativeTokenSymbol]; + const wrappedHolder = holders[wrappedTokenSymbol]; + + describe('swapExactAmountIn SELL', () => { + const contractMethod = ContractMethod.swapExactAmountIn; + const side = SwapSide.SELL; + + it('native -> wrapped', async () => { + await testE2E( + nativeToken, + wrappedToken, + nativeHolder, + nativeAmount, + side, + dexKey, + contractMethod, + network, + provider, + undefined, + undefined, + undefined, + undefined, + undefined, + true, + ); + }); + it('wrapped -> native', async () => { + await testE2E( + wrappedToken, + nativeToken, + wrappedHolder, + wrappedAmount, + side, + dexKey, + contractMethod, + network, + provider, + undefined, + undefined, + undefined, + undefined, + undefined, + true, + ); + }); + }); + }); }); diff --git a/src/executor/WETHBytecodeBuilder.ts b/src/executor/WETHBytecodeBuilder.ts index 7e2d68106..f84e03571 100644 --- a/src/executor/WETHBytecodeBuilder.ts +++ b/src/executor/WETHBytecodeBuilder.ts @@ -15,6 +15,7 @@ const SUPPORTED_NETWORKS = [ Network.POLYGON, Network.OPTIMISM, Network.ZKEVM, + Network.X_LAYER, ]; const SUPPORTED_EXCHANGES = Object.keys(WethConfig); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 4df17735f..a318b5e2d 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1241,6 +1241,10 @@ export const Tokens: { address: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', decimals: 6, }, + WOKB: { + address: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + decimals: 18, + }, }, [Network.BASE]: { PRIME: { From a0454a04c7ae985f12ba4c695397f4b66d271a7e Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Mon, 24 Jun 2024 18:53:19 +0300 Subject: [PATCH 05/28] 3.5.5-x-layer.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3f393306d..51f103c22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.5.5-x-layer.0", + "version": "3.5.5-x-layer.1", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From b67ff06c49db96d1e990a20f104cbaa09621a7aa Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 25 Jun 2024 13:45:18 +0300 Subject: [PATCH 06/28] feat: update config for xlayer: addresses & eip1559 support --- src/config.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/config.ts b/src/config.ts index 5db6f2b0b..00328dc62 100644 --- a/src/config.ts +++ b/src/config.ts @@ -384,19 +384,18 @@ const baseConfigs: { [network: number]: BaseConfig } = { nativeTokenName: 'OKB', nativeTokenSymbol: 'OKB', wrappedNativeTokenAddress: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', - // TODO-X - hasEIP1559: true, + hasEIP1559: false, augustusAddress: '0x0000000000000000000000000000000000000000', - augustusRFQAddress: '0x0000000000000000000000000000000000000000', tokenTransferProxyAddress: '0x0000000000000000000000000000000000000000', multicallV2Address: '0xBCfc39fad3118e307504F4F776BEAe2b478bA61c', privateHttpProvider: process.env.HTTP_PROVIDER_196, - augustusV6Address: '0xcef4aa30328d1802c0e596fa6090a9ea36103ea3', adapterAddresses: {}, + augustusRFQAddress: '0xF6322953d6bFcEACf77D90BC9a01B055249D44fE', + augustusV6Address: '0x6a000f20005980200259b80c5102003040001068', executorsAddresses: { - Executor01: '0xa89e2ed6f043cb0cea9221f532bcdc9a41580c78', - Executor02: '0xc2465233ae9fa2f8d68a435901129cfd23a06441', - Executor03: '0x9eca9e8529da35b456d6ecf01626f22d65b54859', + Executor01: '0x5f0000d4780a00d2dce0a00004000800cb0e5041', + Executor02: '0xd08d0006f00040b400180f9500b00c5026ac0900', + Executor03: '0x5006860a0906b0d8c9c050200947000030081006', }, rpcPollingMaxAllowedStateDelayInBlocks: 0, rpcPollingBlocksBackToTriggerUpdate: 0, From 951bf6063897178e29feeb075952d0ec5ac86cd2 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 26 Jun 2024 12:49:36 +0300 Subject: [PATCH 07/28] chore: update subgraph for quickswap on xlayer --- src/dex/algebra/config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dex/algebra/config.ts b/src/dex/algebra/config.ts index a06611b4b..32b127cce 100644 --- a/src/dex/algebra/config.ts +++ b/src/dex/algebra/config.ts @@ -46,7 +46,7 @@ export const AlgebraConfig: DexConfigMap = { initRetryFrequency: 30, algebraStateMulticall: '0x6a34523Cb05BdfD39F01016358A8dF717Dbd5aca', subgraphURL: - 'https://api.studio.thegraph.com/query/72680/quickswapv3-x-layer/v0.0.7', + 'https://api.studio.thegraph.com/query/72680/quickswapv3-x-layer/v0.2', uniswapMulticall: '0xc7efb32470dEE601959B15f1f923e017C6A918cA', deployer: '0x56c2162254b0E4417288786eE402c2B41d4e181e', version: 'v1.9-bidirectional-fee', From f15215dbf66d2c0e53d1d4991e0350add244d3ab Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 26 Jun 2024 12:50:08 +0300 Subject: [PATCH 08/28] 3.5.5-x-layer.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 51f103c22..0f56f7524 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.5.5-x-layer.1", + "version": "3.5.5-x-layer.2", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From a8cd9456c10e0ba78bb63e2ade230e670f7c1924 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 23 Oct 2024 16:19:18 +0300 Subject: [PATCH 09/28] feat: re-map `x-layer` to `gnosis` --- src/config.ts | 19 ++++++++++--------- src/constants.ts | 2 +- src/dex/algebra/config.ts | 18 ------------------ src/dex/weth/config.ts | 4 ++-- src/executor/WETHBytecodeBuilder.ts | 6 +++--- tests/constants-e2e.ts | 29 +++++++++++++++-------------- 6 files changed, 31 insertions(+), 47 deletions(-) diff --git a/src/config.ts b/src/config.ts index c467e6e70..4e985379e 100644 --- a/src/config.ts +++ b/src/config.ts @@ -386,20 +386,21 @@ const baseConfigs: { [network: number]: BaseConfig } = { // FIXME: Not set properly uniswapV2ExchangeRouterAddress: '', }, - [Network.X_LAYER]: { - network: Network.X_LAYER, - networkName: 'X Layer', + [Network.GNOSIS]: { + network: Network.GNOSIS, + networkName: 'Gnosis', isTestnet: false, - nativeTokenName: 'OKB', - nativeTokenSymbol: 'OKB', - wrappedNativeTokenAddress: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + nativeTokenName: 'xDAI', + nativeTokenSymbol: 'XDAI', + wrappedNativeTokenAddress: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d', hasEIP1559: false, augustusAddress: '0x0000000000000000000000000000000000000000', tokenTransferProxyAddress: '0x0000000000000000000000000000000000000000', - multicallV2Address: '0xBCfc39fad3118e307504F4F776BEAe2b478bA61c', - privateHttpProvider: process.env.HTTP_PROVIDER_196, + multicallV2Address: '0xca11bde05977b3631167028862be2a173976ca11', + privateHttpProvider: process.env.HTTP_PROVIDER_100, adapterAddresses: {}, - augustusRFQAddress: '0xF6322953d6bFcEACf77D90BC9a01B055249D44fE', + augustusRFQAddress: '0x0000000000000000000000000000000000000000', + // TODO-gnosis: deploy contacts augustusV6Address: '0x6a000f20005980200259b80c5102003040001068', executorsAddresses: { Executor01: '0x5f0000d4780a00d2dce0a00004000800cb0e5041', diff --git a/src/constants.ts b/src/constants.ts index 7f4918c56..4bdfb1679 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -41,7 +41,7 @@ export enum Network { ARBITRUM = 42161, OPTIMISM = 10, BASE = 8453, - X_LAYER = 196, + GNOSIS = 100, } export const SUBGRAPH_TIMEOUT = 20 * 1000; diff --git a/src/dex/algebra/config.ts b/src/dex/algebra/config.ts index 32b127cce..e3d726231 100644 --- a/src/dex/algebra/config.ts +++ b/src/dex/algebra/config.ts @@ -34,24 +34,6 @@ export const AlgebraConfig: DexConfigMap = { version: 'v1.1', forceManualStateGenerate: true, }, - [Network.X_LAYER]: { - factory: '0xd2480162Aa7F02Ead7BF4C127465446150D58452', - router: '0x4B9f4d2435Ef65559567e5DbFC1BbB37abC43B57', - quoter: '0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270', - initHash: - '0xbce37a54eab2fcd71913a0d40723e04238970e7fc1159bfd58ad5b79531697e7', - // TODO-X - chunksCount: 3, - // TODO-X - initRetryFrequency: 30, - algebraStateMulticall: '0x6a34523Cb05BdfD39F01016358A8dF717Dbd5aca', - subgraphURL: - 'https://api.studio.thegraph.com/query/72680/quickswapv3-x-layer/v0.2', - uniswapMulticall: '0xc7efb32470dEE601959B15f1f923e017C6A918cA', - deployer: '0x56c2162254b0E4417288786eE402c2B41d4e181e', - version: 'v1.9-bidirectional-fee', - forceManualStateGenerate: true, - }, }, ZyberSwapV3: { [Network.ARBITRUM]: { diff --git a/src/dex/weth/config.ts b/src/dex/weth/config.ts index 84168b913..e91ceeaf6 100644 --- a/src/dex/weth/config.ts +++ b/src/dex/weth/config.ts @@ -46,8 +46,8 @@ export const WethConfig: DexConfigMap = { poolGasCost: WethGasCost, }, }, - Wokb: { - [Network.X_LAYER]: { + Wxdai: { + [Network.GNOSIS]: { poolGasCost: WethGasCost, }, }, diff --git a/src/executor/WETHBytecodeBuilder.ts b/src/executor/WETHBytecodeBuilder.ts index f84e03571..e53d291b5 100644 --- a/src/executor/WETHBytecodeBuilder.ts +++ b/src/executor/WETHBytecodeBuilder.ts @@ -1,9 +1,9 @@ import { DexExchangeBuildParam } from '../types'; -import { OptimalRate, SwapSide } from '@paraswap/core'; +import { OptimalRate } from '@paraswap/core'; import { isETHAddress } from '../utils'; import { DepositWithdrawReturn } from '../dex/weth/types'; import { WethConfig } from '../dex/weth/config'; -import { Executors, Flag, SpecialDex } from './types'; +import { Executors } from './types'; import { ExecutorBytecodeBuilder } from './ExecutorBytecodeBuilder'; import { Network } from '../constants'; @@ -15,7 +15,7 @@ const SUPPORTED_NETWORKS = [ Network.POLYGON, Network.OPTIMISM, Network.ZKEVM, - Network.X_LAYER, + Network.GNOSIS, ]; const SUPPORTED_EXCHANGES = Object.keys(WethConfig); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index be563a20b..d51b17181 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1459,29 +1459,29 @@ export const Tokens: { decimals: 6, }, }, - [Network.X_LAYER]: { - OKB: { + [Network.GNOSIS]: { + XDAI: { address: ETHER_ADDRESS, decimals: 18, }, WETH: { - address: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', + address: '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1', decimals: 18, }, WBTC: { - address: '0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1', + address: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', decimals: 8, }, USDC: { - address: '0x74b7f16337b8972027f6196a17a631ac6de26d22', + address: '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83', decimals: 6, }, USDT: { - address: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', + address: '0x4ECaBa5870353805a9F068101A40E0f32ed605C6', decimals: 6, }, - WOKB: { - address: '0xe538905cf8410324e03a5a23c1c177a474d59b2b', + WXDAI: { + address: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', decimals: 18, }, }, @@ -1922,12 +1922,13 @@ export const Holders: { WBTC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c', USDC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c', }, - [Network.X_LAYER]: { - OKB: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', - WOKB: '0x5a77f1443d16ee5761d310e38b62f77f726bc71c', - USDT: '0x1e4a5963abfd975d8c9021ce480b42188849d41d', - WBTC: '0xea034fb02eb1808c2cc3adbc15f447b93cbe08e1', - USDC: '0x74b7f16337b8972027f6196a17a631ac6de26d22', + [Network.GNOSIS]: { + XDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', + WXDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', + WETH: '0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696', + USDT: '0x1098503a90c3224F0e6BE7c124a337888C0BA564', + WBTC: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', + USDC: '0xd4A39d219ADB43aB00739DC5D876D98Fdf0121Bf', }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', From d3984f76d03c9b490acb3109bc45ce201099bc6b Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Wed, 23 Oct 2024 19:51:36 +0300 Subject: [PATCH 10/28] feat: add `Augustus` deployed addresses on `gnosis` --- src/config.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.ts b/src/config.ts index 4e985379e..c0b4664b7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -399,13 +399,12 @@ const baseConfigs: { [network: number]: BaseConfig } = { multicallV2Address: '0xca11bde05977b3631167028862be2a173976ca11', privateHttpProvider: process.env.HTTP_PROVIDER_100, adapterAddresses: {}, - augustusRFQAddress: '0x0000000000000000000000000000000000000000', - // TODO-gnosis: deploy contacts + augustusRFQAddress: '0x92EaD5bACf6F0E995FA46Ad8215A9b11f67ca241', augustusV6Address: '0x6a000f20005980200259b80c5102003040001068', executorsAddresses: { - Executor01: '0x5f0000d4780a00d2dce0a00004000800cb0e5041', - Executor02: '0xd08d0006f00040b400180f9500b00c5026ac0900', - Executor03: '0x5006860a0906b0d8c9c050200947000030081006', + Executor01: '0x000010036c0190e009a000d0fc3541100a07380a', + Executor02: '0x00c600b30fb0400701010f4b080409018b9006e0', + Executor03: '0xe009f00e200a090090fc70e02d70b232000c0802', }, rpcPollingMaxAllowedStateDelayInBlocks: 0, rpcPollingBlocksBackToTriggerUpdate: 0, From 480437823661bdd6540fdcf3ed0e9686653b1525 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 11:33:16 +0300 Subject: [PATCH 11/28] feat: integrate AaveV3 on Gnosis --- src/dex/aave-v3/aave-v3-e2e.test.ts | 69 +++++++++++++++++++++++++++++ src/dex/aave-v3/aave-v3.ts | 2 +- src/dex/aave-v3/config.ts | 7 +++ tests/constants-e2e.ts | 24 ++++++++++ 4 files changed, 101 insertions(+), 1 deletion(-) diff --git a/src/dex/aave-v3/aave-v3-e2e.test.ts b/src/dex/aave-v3/aave-v3-e2e.test.ts index be24e0763..75487d09b 100644 --- a/src/dex/aave-v3/aave-v3-e2e.test.ts +++ b/src/dex/aave-v3/aave-v3-e2e.test.ts @@ -506,4 +506,73 @@ describe('AaveV3 E2E', () => { ); }); }); + + describe('AaveV3 GNOSIS', () => { + const network = Network.GNOSIS; + const tokens = Tokens[network]; + const holders = Holders[network]; + const provider = new StaticJsonRpcProvider( + generateConfig(network).privateHttpProvider, + network, + ); + + const pairs = [ + { + tokenSymbol: 'XDAI', + aTokenSymbol: 'aGnoWXDAI', + amount: '1000000000000000000', + }, + { + tokenSymbol: 'USDC', + aTokenSymbol: 'aGnoUSDC', + amount: '10000000', + }, + { + tokenSymbol: 'wstETH', + aTokenSymbol: 'aGnowstETH', + amount: '1000000000000000000', + }, + ]; + + const sideToContractMethods = new Map([ + [SwapSide.SELL, [ContractMethod.swapExactAmountIn]], + [SwapSide.BUY, [ContractMethod.swapExactAmountOut]], + ]); + + pairs.forEach(pair => { + sideToContractMethods.forEach((contractMethods, side) => + contractMethods.forEach((contractMethod: ContractMethod) => { + describe(`${contractMethod}`, () => { + it(pair.aTokenSymbol + ' -> ' + pair.tokenSymbol, async () => { + await testE2E( + tokens[pair.aTokenSymbol], + tokens[pair.tokenSymbol], + holders[pair.aTokenSymbol], + pair.amount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + + it(pair.tokenSymbol + ' -> ' + pair.aTokenSymbol, async () => { + await testE2E( + tokens[pair.tokenSymbol], + tokens[pair.aTokenSymbol], + holders[pair.tokenSymbol], + pair.amount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }), + ); + }); + }); }); diff --git a/src/dex/aave-v3/aave-v3.ts b/src/dex/aave-v3/aave-v3.ts index aef5a7479..80c941ddc 100644 --- a/src/dex/aave-v3/aave-v3.ts +++ b/src/dex/aave-v3/aave-v3.ts @@ -60,7 +60,7 @@ export class AaveV3 extends SimpleExchange implements IDex { } getAdapters(side: SwapSide): { name: string; index: number }[] | null { - return this.adapters[side]; + return this.adapters?.[side] ?? null; } async initializePricing(blockNumber: number): Promise { diff --git a/src/dex/aave-v3/config.ts b/src/dex/aave-v3/config.ts index c0d058bff..046c8d7ed 100644 --- a/src/dex/aave-v3/config.ts +++ b/src/dex/aave-v3/config.ts @@ -11,6 +11,7 @@ import { AaveV3Optimism, AaveV3Polygon, AaveV3PolygonZkEvm, + AaveV3Gnosis, } from '@bgd-labs/aave-address-book'; // TODO: find vals for V3 @@ -70,6 +71,12 @@ export const Config: DexConfigMap = { poolAddress: AaveV3PolygonZkEvm.POOL, wethGatewayAddress: AaveV3PolygonZkEvm.WETH_GATEWAY, }, + [Network.GNOSIS]: { + ethGasCost: 246 * 100, + lendingGasCost: 328 * 1000, + poolAddress: AaveV3Gnosis.POOL, + wethGatewayAddress: AaveV3Gnosis.WETH_GATEWAY, + }, }, }; diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index d51b17181..7dbf1d4a0 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1484,6 +1484,26 @@ export const Tokens: { address: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', decimals: 18, }, + aGnoWETH: { + address: '0xa818f1b57c201e092c4a2017a91815034326efd1', + decimals: 18, + }, + aGnowstETH: { + address: '0x23e4e76d01b2002be436ce8d6044b0aa2f68b68a', + decimals: 18, + }, + aGnoUSDC: { + address: '0xc6b7aca6de8a6044e0e32d0c841a89244a10d284', + decimals: 6, + }, + wstETH: { + address: '0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6', + decimals: 18, + }, + aGnoWXDAI: { + address: '0xd0dd6cef72143e22cced4867eb0d5f2328715533', + decimals: 18, + }, }, [Network.BASE]: { wstETH: { @@ -1929,6 +1949,10 @@ export const Holders: { USDT: '0x1098503a90c3224F0e6BE7c124a337888C0BA564', WBTC: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', USDC: '0xd4A39d219ADB43aB00739DC5D876D98Fdf0121Bf', + aGnoWXDAI: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', + aGnoUSDC: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', + wstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', + aGnowstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', From 77c4b2e2172d4ed8febdc1fbdd6641be6a938705 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 13:41:36 +0300 Subject: [PATCH 12/28] feat: add `needWrapNative` support on WUSDM --- src/dex/wusdm/wusdm.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/dex/wusdm/wusdm.ts b/src/dex/wusdm/wusdm.ts index 5505e0696..98c0e1682 100644 --- a/src/dex/wusdm/wusdm.ts +++ b/src/dex/wusdm/wusdm.ts @@ -38,6 +38,7 @@ export class WUSDM { readonly hasConstantPriceLargeAmounts = true; readonly isFeeOnTransferSupported = false; + readonly needWrapNative: boolean = true; public static dexKeysWithNetwork: { key: string; networks: Network[] }[] = getDexKeysWithNetwork(WUSDMConfig); @@ -89,7 +90,10 @@ export class WUSDM side: SwapSide, blockNumber: number, ): Promise { - return this.isAppropriatePair(srcToken, destToken) + const _srcToken = this.dexHelper.config.wrapETH(srcToken); + const _destToken = this.dexHelper.config.wrapETH(destToken); + + return this.isAppropriatePair(_srcToken, _destToken) ? [`${this.dexKey}_${this.wUSDMAddress}`] : []; } @@ -121,13 +125,16 @@ export class WUSDM blockNumber: number, limitPools?: string[], ): Promise> { - if (!this.isAppropriatePair(srcToken, destToken)) return null; + const _srcToken = this.dexHelper.config.wrapETH(srcToken); + const _destToken = this.dexHelper.config.wrapETH(destToken); + + if (!this.isAppropriatePair(_srcToken, _destToken)) return null; const state = this.eventPool.getState(blockNumber); if (!state) return null; - const isSrcAsset = this.isUSDM(srcToken.address); + const isSrcAsset = this.isUSDM(_srcToken.address); - const isWrap = this.isWrap(srcToken, destToken, side); + const isWrap = this.isWrap(_srcToken, _destToken, side); let calcFunction: Function; From 05bc4214be00dea3b84d05a638abd0f7e09bf2ca Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 13:42:37 +0300 Subject: [PATCH 13/28] feat: integrate sDAI via WUSDM on Gnosis --- src/dex/wusdm/config.ts | 8 +++++++ src/dex/wusdm/wusdm-e2e.test.ts | 38 +++++++++++++++++++++++++++++++++ tests/constants-e2e.ts | 7 +++++- 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/dex/wusdm/config.ts b/src/dex/wusdm/config.ts index 7e7d1733d..d2f1e1de6 100644 --- a/src/dex/wusdm/config.ts +++ b/src/dex/wusdm/config.ts @@ -25,4 +25,12 @@ export const WUSDMConfig: DexConfigMap = { USDMAddress: '0x59D9356E565Ab3A36dD77763Fc0d87fEaf85508C', }, }, + // not really wUSDM, but works in the same way + // might give 1wei difference on BUY + sDAI: { + [Network.GNOSIS]: { + wUSDMAddress: '0xaf204776c7245bF4147c2612BF6e5972Ee483701', // sDAI + USDMAddress: '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', // WXDAI + }, + }, }; diff --git a/src/dex/wusdm/wusdm-e2e.test.ts b/src/dex/wusdm/wusdm-e2e.test.ts index 89aad8afb..9c922575b 100644 --- a/src/dex/wusdm/wusdm-e2e.test.ts +++ b/src/dex/wusdm/wusdm-e2e.test.ts @@ -163,4 +163,42 @@ describe('MountainProtocol E2E', () => { tokenBAmount, ); }); + + describe('Gnosis', () => { + const network = Network.GNOSIS; + + const tokenASymbol: string = 'sDAI'; + const tokenBSymbol: string = 'WXDAI'; + + const tokenAAmount: string = '500000000000000000'; + const tokenBAmount: string = '500000000000000000'; + + testForNetwork( + network, + 'sDAI', + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + ); + }); + + describe('Gnosis with Native', () => { + const network = Network.GNOSIS; + + const tokenASymbol: string = 'sDAI'; + const tokenBSymbol: string = 'XDAI'; + + const tokenAAmount: string = '500000000000000000'; + const tokenBAmount: string = '500000000000000000'; + + testForNetwork( + network, + 'sDAI', + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + ); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 7dbf1d4a0..60fc4197a 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1504,6 +1504,10 @@ export const Tokens: { address: '0xd0dd6cef72143e22cced4867eb0d5f2328715533', decimals: 18, }, + sDAI: { + address: '0xaf204776c7245bF4147c2612BF6e5972Ee483701', + decimals: 18, + }, }, [Network.BASE]: { wstETH: { @@ -1944,7 +1948,7 @@ export const Holders: { }, [Network.GNOSIS]: { XDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', - WXDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', + WXDAI: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', WETH: '0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696', USDT: '0x1098503a90c3224F0e6BE7c124a337888C0BA564', WBTC: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', @@ -1953,6 +1957,7 @@ export const Holders: { aGnoUSDC: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', wstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', aGnowstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', + sDAI: '0x79f08F2e75A8C99428DE4A2e6456c07C99E55da5', }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', From 77c6dc16c23b699e37f0fc9914429ac6cf0c555f Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 14:18:46 +0300 Subject: [PATCH 14/28] feat: integrate `BalancerV2` on Gnosis --- src/dex/balancer-v2/balancer-v2-e2e.test.ts | 272 ++------------------ src/dex/balancer-v2/balancer-v2.ts | 2 +- src/dex/balancer-v2/config.ts | 4 + tests/constants-e2e.ts | 4 +- 4 files changed, 30 insertions(+), 252 deletions(-) diff --git a/src/dex/balancer-v2/balancer-v2-e2e.test.ts b/src/dex/balancer-v2/balancer-v2-e2e.test.ts index 43f0062cd..c8f1ff3c0 100644 --- a/src/dex/balancer-v2/balancer-v2-e2e.test.ts +++ b/src/dex/balancer-v2/balancer-v2-e2e.test.ts @@ -1444,256 +1444,28 @@ describe('BalancerV2 E2E', () => { ); }); - // describe('BeetsFi OPTIMISM', () => { - // const dexKey = 'BeetsFi'; - // const network = Network.OPTIMISM; - // const tokens = Tokens[network]; - // const holders = Holders[network]; - // const provider = new StaticJsonRpcProvider( - // generateConfig(network).privateHttpProvider, - // network, - // ); - // const BBAUSD_OP = '0x6222ae1d2a9f6894da50aa25cb7b303497f9bebd'; - // const BBAUSDMAI_OP = '0x1f131ec1175f023ee1534b16fa8ab237c00e2381'; - // const LIDO_SHUFFLE = '0xde45f101250f2ca1c0f8adfc172576d10c12072d'; - // const YELLOW_SUBMARINE = '0x981fb05b738e981ac532a99e77170ecb4bc27aef'; + describe('BalancerV2_GNOSIS', () => { + const dexKey = 'BalancerV2'; + const network = Network.GNOSIS; - // describe('Simpleswap', () => { - // it('ETH -> TOKEN', async () => { - // await testE2E( - // tokens['ETH'], - // tokens['USDC'], - // holders['ETH'], - // '7000000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // ); - // }); - // it('TOKEN -> ETH', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['ETH'], - // holders['USDC'], - // '2000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // ); - // }); - // it('TOKEN -> TOKEN', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['WETH'], - // holders['USDC'], - // '20000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // ); - // }); - // it('USDC -> DAI using bbaUSD', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['DAI'], - // holders['USDC'], - // '20000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${BBAUSD_OP}`], - // ); - // }); - // it('DAI -> USDT using bbaUSD', async () => { - // await testE2E( - // tokens['DAI'], - // tokens['USDT'], - // holders['DAI'], - // '1000000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${BBAUSD_OP}`], - // ); - // }); - // it('USDC -> MAI through bbaUSD-MAI', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['MAI'], - // holders['USDC'], - // '20000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${BBAUSDMAI_OP}`], - // ); - // }); - // it('wstETH -> WETH through composable stable', async () => { - // await testE2E( - // tokens['wstETH'], - // tokens['WETH'], - // holders['wstETH'], - // '10000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${LIDO_SHUFFLE}`], - // ); - // }); - // it('wstETH -> ETH through composable stable', async () => { - // await testE2E( - // tokens['wstETH'], - // tokens['ETH'], - // holders['wstETH'], - // '10000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${LIDO_SHUFFLE}`], - // ); - // }); - // it('ETH -> wstETH through composable stable', async () => { - // await testE2E( - // tokens['ETH'], - // tokens['wstETH'], - // holders['ETH'], - // '10000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${LIDO_SHUFFLE}`], - // ); - // }); - // it('wstETH -> WBTC through boosted weighted', async () => { - // await testE2E( - // tokens['wstETH'], - // tokens['WBTC'], - // holders['wstETH'], - // '25000000000000000', //1e18 - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${YELLOW_SUBMARINE}`], - // ); - // }); - // it('USDC -> WBTC through boosted weighted', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['WBTC'], - // holders['USDC'], - // '1000000', //1e6 - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${YELLOW_SUBMARINE}`], - // ); - // }); - // it('wstETH -> USDC through boosted weighted', async () => { - // await testE2E( - // tokens['wstETH'], - // tokens['USDC'], - // holders['wstETH'], - // '1000000000000000000', //1e18 - // SwapSide.SELL, - // dexKey, - // ContractMethod.simpleSwap, - // network, - // provider, - // [`${dexKey}_${YELLOW_SUBMARINE}`], - // ); - // }); - // }); + testForNetwork( + network, + dexKey, + 'USDC', + 'USDT', + '11110010', + '21000000', + '100000000000000000', + ); - // describe('Multiswap', () => { - // it('ETH -> TOKEN', async () => { - // await testE2E( - // tokens['ETH'], - // tokens['USDC'], - // holders['ETH'], - // '7000000000000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.multiSwap, - // network, - // provider, - // ); - // }); - // it('TOKEN -> ETH', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['ETH'], - // holders['USDC'], - // '2000000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.multiSwap, - // network, - // provider, - // ); - // }); - // it('TOKEN -> TOKEN', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['WETH'], - // holders['USDC'], - // '20000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.multiSwap, - // network, - // provider, - // ); - // }); - // it('USDC -> DAI using bbaUSD', async () => { - // await testE2E( - // tokens['USDC'], - // tokens['DAI'], - // holders['USDC'], - // '20000000', - // SwapSide.SELL, - // dexKey, - // ContractMethod.multiSwap, - // network, - // provider, - // [`${dexKey}_${BBAUSD_OP}`], - // ); - // }); - // it('wstETH -> USDC through boosted weighted', async () => { - // await testE2E( - // tokens['wstETH'], - // tokens['USDC'], - // holders['wstETH'], - // '1000000000000000000', //1e18 - // SwapSide.SELL, - // dexKey, - // ContractMethod.multiSwap, - // network, - // provider, - // [`${dexKey}_${YELLOW_SUBMARINE}`], - // ); - // }); - // }); - // }); + testForNetwork( + network, + dexKey, + 'WETH', + 'WXDAI', + '1000000000000000000', + '1000000000000000000', + '1000000000000000000', + ); + }); }); diff --git a/src/dex/balancer-v2/balancer-v2.ts b/src/dex/balancer-v2/balancer-v2.ts index aadafdb19..97f60f1aa 100644 --- a/src/dex/balancer-v2/balancer-v2.ts +++ b/src/dex/balancer-v2/balancer-v2.ts @@ -789,7 +789,7 @@ export class BalancerV2 } getAdapters(side: SwapSide): { name: string; index: number }[] | null { - return this.adapters[side] ? this.adapters[side] : null; + return this.adapters?.[side] ? this.adapters[side] : null; } async getPoolIdentifiers( diff --git a/src/dex/balancer-v2/config.ts b/src/dex/balancer-v2/config.ts index ea36a9647..f28a3fc86 100644 --- a/src/dex/balancer-v2/config.ts +++ b/src/dex/balancer-v2/config.ts @@ -25,6 +25,10 @@ export const BalancerConfig: DexConfigMap = { 'https://api.studio.thegraph.com/query/24660/balancer-base-v2/version/latest', vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', }, + [Network.GNOSIS]: { + subgraphURL: 'EJezH1Cp31QkKPaBDerhVPRWsKVZLrDfzjrLqpmv6cGg', + vaultAddress: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', + }, }, BeetsFi: { [Network.FANTOM]: { diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 60fc4197a..9b8b6e203 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1949,7 +1949,7 @@ export const Holders: { [Network.GNOSIS]: { XDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', WXDAI: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', - WETH: '0xD692Fd2D0b2Fbd2e52CFa5B5b9424bC981C30696', + WETH: '0x800e12aF6c96790EDDdc5B3f3302899e27B2A918', USDT: '0x1098503a90c3224F0e6BE7c124a337888C0BA564', WBTC: '0x8e5bBbb09Ed1ebdE8674Cda39A0c169401db4252', USDC: '0xd4A39d219ADB43aB00739DC5D876D98Fdf0121Bf', @@ -2010,6 +2010,7 @@ export const NativeTokenSymbols: { [network: number]: string } = { [Network.ARBITRUM]: 'ETH', [Network.OPTIMISM]: 'ETH', [Network.BASE]: 'ETH', + [Network.GNOSIS]: 'XDAI', }; export const WrappedNativeTokenSymbols: { [network: number]: string } = { @@ -2021,4 +2022,5 @@ export const WrappedNativeTokenSymbols: { [network: number]: string } = { [Network.ARBITRUM]: 'WETH', [Network.OPTIMISM]: 'WETH', [Network.BASE]: 'WETH', + [Network.GNOSIS]: 'WXDAI', }; From 02e09faeca9bd8b374c25c1b8593289ceb7ce498 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 17:38:54 +0300 Subject: [PATCH 15/28] feat: integrate `SushiSwap` on Gnosis --- src/config.ts | 3 +- src/dex/uniswap-v2/config.ts | 7 ++ .../uniswap-v2/uniswap-v2-e2e-gnosis.test.ts | 106 ++++++++++++++++++ src/dex/uniswap-v2/uniswap-v2.ts | 2 +- tests/constants-e2e.ts | 2 +- 5 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts diff --git a/src/config.ts b/src/config.ts index c0b4664b7..ae728ff17 100644 --- a/src/config.ts +++ b/src/config.ts @@ -413,7 +413,8 @@ const baseConfigs: { [network: number]: BaseConfig } = { rfqConfigs: {}, forceRpcFallbackDexs: [], // FIXME: Not set properly - uniswapV2ExchangeRouterAddress: '', + uniswapV2ExchangeRouterAddress: + '0xfa39c1c670b48956eeF9fd0BbD0E81A290326330', }, [Network.BASE]: { network: Network.BASE, diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index 02a45af11..e0d88eb44 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -427,6 +427,13 @@ export const UniswapV2Config: DexConfigMap = { '0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303', feeCode: 30, }, + [Network.GNOSIS]: { + subgraphURL: '7czeiia7ZXvsW45szX2w8EK1ZNgZWZET83zYCwE6JT9x', + factoryAddress: '0xc35dadb65012ec5796536bd9864ed8773abc74c4', + initCode: + '0xe18a34eb0e04b04f7a0ac29a6e80748dca96319b42c54d679cb821dca90c6303', + feeCode: 30, + }, }, Zyberswap: { [Network.ARBITRUM]: { diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts new file mode 100644 index 000000000..b7141376f --- /dev/null +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts @@ -0,0 +1,106 @@ +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 { StaticJsonRpcProvider } from '@ethersproject/providers'; +import { generateConfig } from '../../config'; + +describe('UniswapV2 E2E Gnosis', () => { + const network = Network.GNOSIS; + const tokens = Tokens[network]; + const holders = Holders[network]; + const provider = new StaticJsonRpcProvider( + generateConfig(network).privateHttpProvider, + network, + ); + + describe('SushiSwap', () => { + const dexKey = 'SushiSwap'; + + describe('swapExactAmountIn', () => { + it('SushiSwap ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + tokens.USDC, + holders.XDAI, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> ETH', async () => { + await testE2E( + tokens.WETH, + tokens.XDAI, + holders.WETH, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.WETH, + tokens.USDC, + holders.WETH, + '7000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + }); + + describe('swapExactAmountOut', () => { + it('SushiSwap ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + tokens.USDC, + holders.XDAI, + '700000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> ETH', async () => { + await testE2E( + tokens.USDC, + tokens.XDAI, + holders.USDC, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.WETH, + holders.USDC, + '7000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + }); + }); +}); diff --git a/src/dex/uniswap-v2/uniswap-v2.ts b/src/dex/uniswap-v2/uniswap-v2.ts index 111b1edc4..ff022a36c 100644 --- a/src/dex/uniswap-v2/uniswap-v2.ts +++ b/src/dex/uniswap-v2/uniswap-v2.ts @@ -681,7 +681,7 @@ export class UniswapV2 } getAdapters(side: SwapSide): { name: string; index: number }[] | null { - return this.adapters[side]; + return this.adapters?.[side] ?? null; } async getTopPoolsForToken( diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 9b8b6e203..a0062538d 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1947,7 +1947,7 @@ export const Holders: { USDC: '0x99b31498b0a1dae01fc3433e3cb60f095340935c', }, [Network.GNOSIS]: { - XDAI: '0x56CF0ff00fd6CfB23ce964C6338B228B0FA76640', + XDAI: '0x9fc062032d4F2Fe7dAA601bd8B06C45F9c8f17Be', WXDAI: '0xBA12222222228d8Ba445958a75a0704d566BF2C8', WETH: '0x800e12aF6c96790EDDdc5B3f3302899e27B2A918', USDT: '0x1098503a90c3224F0e6BE7c124a337888C0BA564', From ee49dba6baf2e077620b55ea6f9f5c802a6f2b47 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 17:44:55 +0300 Subject: [PATCH 16/28] feat: integrate `HoneySwap` on Gnosis --- src/dex/uniswap-v2/config.ts | 9 ++ .../uniswap-v2/uniswap-v2-e2e-gnosis.test.ts | 88 +++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/src/dex/uniswap-v2/config.ts b/src/dex/uniswap-v2/config.ts index e0d88eb44..9adbda125 100644 --- a/src/dex/uniswap-v2/config.ts +++ b/src/dex/uniswap-v2/config.ts @@ -435,6 +435,15 @@ export const UniswapV2Config: DexConfigMap = { feeCode: 30, }, }, + HoneySwap: { + [Network.GNOSIS]: { + subgraphURL: '7vjh6q6gj6M1bhRNgkKZmWqd5jot79kV84BiQtUDQSdV', + factoryAddress: '0xa818b4f111ccac7aa31d0bcc0806d64f2e0737d7', + initCode: + '0xdbd265d4828759db2a0351a7b97180bcc41449a038bcd08a45afe937147f6267', + feeCode: 30, + }, + }, Zyberswap: { [Network.ARBITRUM]: { subgraphURL: '3g83GYhbyHtjy581vpTmN1AP9cB9MjWMh5TiuNpvTU4R', diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts index b7141376f..2c469185a 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts @@ -103,4 +103,92 @@ describe('UniswapV2 E2E Gnosis', () => { }); }); }); + + describe('HoneySwap', () => { + const dexKey = 'HoneySwap'; + + describe('swapExactAmountIn', () => { + it('SushiSwap ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + tokens.USDC, + holders.XDAI, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> ETH', async () => { + await testE2E( + tokens.WETH, + tokens.XDAI, + holders.WETH, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.WETH, + tokens.USDC, + holders.WETH, + '7000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + }); + + describe('swapExactAmountOut', () => { + it('SushiSwap ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + tokens.USDC, + holders.XDAI, + '700000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> ETH', async () => { + await testE2E( + tokens.USDC, + tokens.XDAI, + holders.USDC, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SushiSwap TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.WETH, + holders.USDC, + '700000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + }); + }); }); From d3c8ff48a272a773c6b419345e33f18558fa685f Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 19:58:06 +0300 Subject: [PATCH 17/28] feat: integrate `CurveV1` on Gnosis --- src/config.ts | 1 - src/dex/curve-v1/config.ts | 36 ++++++++++++++ src/dex/curve-v1/curve-v1-e2e.test.ts | 69 +++++++++++++++++++++++++++ src/dex/curve-v1/curve-v1.ts | 2 +- tests/constants-e2e.ts | 5 ++ 5 files changed, 111 insertions(+), 2 deletions(-) diff --git a/src/config.ts b/src/config.ts index ae728ff17..80106a65b 100644 --- a/src/config.ts +++ b/src/config.ts @@ -412,7 +412,6 @@ const baseConfigs: { [network: number]: BaseConfig } = { uniswapV3EventLoggingSampleRate: 0, rfqConfigs: {}, forceRpcFallbackDexs: [], - // FIXME: Not set properly uniswapV2ExchangeRouterAddress: '0xfa39c1c670b48956eeF9fd0BbD0E81A290326330', }, diff --git a/src/dex/curve-v1/config.ts b/src/dex/curve-v1/config.ts index f87777fc1..f00de2e85 100644 --- a/src/dex/curve-v1/config.ts +++ b/src/dex/curve-v1/config.ts @@ -1115,6 +1115,42 @@ export const CurveV1Config: DexConfigMap = { }, }, }, + [Network.GNOSIS]: { + baseTokens: { + '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d': { + address: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d', + decimals: 18, + reasonableVolume: 1000000000000000000000n, + }, + '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83': { + address: '0xddafbb505ad214d7b80b1f830fccc89b60fb7a83', + decimals: 6, + reasonableVolume: 1000000000n, + }, + '0x4ecaba5870353805a9f068101a40e0f32ed605c6': { + address: '0x4ecaba5870353805a9f068101a40e0f32ed605c6', + decimals: 6, + reasonableVolume: 1000000000n, + }, + }, + eventSupportedPools: [], + pools: { + '3pool': { + underlying: [], + coins: [ + '0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d', + '0xDDAfbb505ad214D7b80b1f830fcCc89B60fb7A83', + '0x4ECaBa5870353805a9F068101A40E0f32ed605C6', + ], + address: '0x7f90122BF0700F9E7e1F688fe926940E8839F353', + name: '3pool (x3CRV)', + type: 1, + version: 3, + isLending: false, + isMetapool: false, + }, + }, + }, }, }; diff --git a/src/dex/curve-v1/curve-v1-e2e.test.ts b/src/dex/curve-v1/curve-v1-e2e.test.ts index d5a6efe43..b5a0b4f29 100644 --- a/src/dex/curve-v1/curve-v1-e2e.test.ts +++ b/src/dex/curve-v1/curve-v1-e2e.test.ts @@ -338,6 +338,75 @@ describe('CurveV1 E2E', () => { ); }); }); + + describe('GNOSIS', () => { + const network = Network.GNOSIS; + const tokens = Tokens[network]; + const holders = Holders[network]; + const provider = new StaticJsonRpcProvider( + generateConfig(network).privateHttpProvider, + network, + ); + + const tokensToTest = [ + [ + { + symbol: 'WXDAI', + amount: (10 ** 18).toString(), + }, + { + symbol: 'USDC', + amount: (10 ** 6).toString(), + }, + ], + [ + { + symbol: 'WXDAI', + amount: (10 ** 18).toString(), + }, + { + symbol: 'USDT', + amount: (10 ** 6).toString(), + }, + ], + [ + { + symbol: 'USDC', + amount: (10 ** 6).toString(), + }, + { + symbol: 'USDT', + amount: (10 ** 6).toString(), + }, + ], + ]; + + const sideToContractMethods = new Map([ + [SwapSide.SELL, [ContractMethod.swapExactAmountIn]], + ]); + + sideToContractMethods.forEach((contractMethods, side) => + contractMethods.forEach((contractMethod: ContractMethod) => { + tokensToTest.forEach(pair => { + describe(`${contractMethod}`, () => { + it(`${pair[0].symbol} -> ${pair[1].symbol}`, async () => { + await testE2E( + tokens[pair[0].symbol], + tokens[pair[1].symbol], + holders[pair[0].symbol], + side === SwapSide.SELL ? pair[0].amount : pair[1].amount, + side, + dexKey, + contractMethod, + network, + provider, + ); + }); + }); + }); + }), + ); + }); }); describe('Acryptos E2E', () => { diff --git a/src/dex/curve-v1/curve-v1.ts b/src/dex/curve-v1/curve-v1.ts index 98d574d54..2af608b36 100644 --- a/src/dex/curve-v1/curve-v1.ts +++ b/src/dex/curve-v1/curve-v1.ts @@ -861,7 +861,7 @@ export class CurveV1 } getAdapters(side: SwapSide): { name: string; index: number }[] | null { - return this.adapters[side]; + return this.adapters?.[side] ?? null; } static getDirectFunctionName(): string[] { diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index a0062538d..9dc87f242 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1508,6 +1508,10 @@ export const Tokens: { address: '0xaf204776c7245bF4147c2612BF6e5972Ee483701', decimals: 18, }, + crvUSD: { + address: '0xaBEf652195F98A91E490f047A5006B71c85f058d', + decimals: 18, + }, }, [Network.BASE]: { wstETH: { @@ -1958,6 +1962,7 @@ export const Holders: { wstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', aGnowstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', sDAI: '0x79f08F2e75A8C99428DE4A2e6456c07C99E55da5', + crvUSD: '0xE4A982fa1f1E8AD1AF238A7b1226b13b56bf5CcD', }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', From aa63a35522263cc303541278fa08f1ce3a3b8237 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Thu, 24 Oct 2024 20:04:54 +0300 Subject: [PATCH 18/28] feat: integrate `CurveV1StableNg` on Gnosis --- src/dex/curve-v1-factory/constants.ts | 1 + src/dex/curve-v1-factory/curve-v1-factory.ts | 3 +- src/dex/curve-v1-stable-ng/config.ts | 28 +++++++++++++++++++ .../curve-v1-stable-ng-e2e.test.ts | 20 +++++++++++++ 4 files changed, 51 insertions(+), 1 deletion(-) diff --git a/src/dex/curve-v1-factory/constants.ts b/src/dex/curve-v1-factory/constants.ts index ccedadfba..bc7db3de4 100644 --- a/src/dex/curve-v1-factory/constants.ts +++ b/src/dex/curve-v1-factory/constants.ts @@ -29,6 +29,7 @@ export const NETWORK_ID_TO_NAME: Record = { [Network.ARBITRUM]: 'arbitrum', [Network.OPTIMISM]: 'optimism', [Network.BASE]: 'base', + [Network.GNOSIS]: 'xdai', }; // They are hardcoded in factory contract. If factory is changing, must be diff --git a/src/dex/curve-v1-factory/curve-v1-factory.ts b/src/dex/curve-v1-factory/curve-v1-factory.ts index 8082c8b46..1e1fad10b 100644 --- a/src/dex/curve-v1-factory/curve-v1-factory.ts +++ b/src/dex/curve-v1-factory/curve-v1-factory.ts @@ -605,7 +605,8 @@ export class CurveV1Factory const allResultsFromFactory = ( await this.dexHelper.multiWrapper.tryAggregate< string[] | number[] | string - >(true, callDataFromFactoryPools) + // decrease batch size to 450 to avoid 'out-of-limit' error on gnosis + >(true, callDataFromFactoryPools, undefined, 450) ).map(r => r.returnData); const resultsFromFactory = allResultsFromFactory.slice( diff --git a/src/dex/curve-v1-stable-ng/config.ts b/src/dex/curve-v1-stable-ng/config.ts index 76334d128..5a517d17e 100644 --- a/src/dex/curve-v1-stable-ng/config.ts +++ b/src/dex/curve-v1-stable-ng/config.ts @@ -192,6 +192,34 @@ const CurveV1StableNgConfig: DexConfigMap = { }, customPools: {}, }, + [Network.GNOSIS]: { + factories: [ + { + address: '0xbc0797015fcfc47d9c1856639cae50d0e69fbee8', + isStableNg: true, + }, + ], + router: '0x0dcded3545d565ba3b19e683431381007245d983', // https://github.com/curvefi/curve-router-ng + stateUpdatePeriodMs: 5 * 1000, + disabledPools: new Set([]), + disabledImplementations: new Set([]), + factoryPoolImplementations: { + // TODO-gnosis: check if there's no missing implementations + '0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a': { + name: ImplementationNames.FACTORY_STABLE_NG, + address: '0x3d6cb2f6dcf47cdd9c13e4e3beae9af041d8796a', + liquidityApiSlug: '/factory-stable-ng', + isStoreRateSupported: true, + }, + '0xc1b393efef38140662b91441c6710aa704973228': { + name: ImplementationNames.FACTORY_STABLE_NG, + address: '0xc1b393efef38140662b91441c6710aa704973228', + liquidityApiSlug: '/factory-stable-ng', + isStoreRateSupported: true, + }, + }, + customPools: {}, + }, }, }; diff --git a/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts b/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts index 5cc02e4ef..cfea4d743 100644 --- a/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts +++ b/src/dex/curve-v1-stable-ng/curve-v1-stable-ng-e2e.test.ts @@ -196,4 +196,24 @@ describe('CurveV1StableNG E2E', () => { sidesToContractMethods, ); }); + + describe('Gnosis', () => { + const network = Network.GNOSIS; + + const tokenASymbol: string = 'sDAI'; + const tokenBSymbol: string = 'crvUSD'; + + const tokenAAmount: string = '1000000000000000000'; + const tokenBAmount: string = '1000000000000000000'; + + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + sidesToContractMethods, + ); + }); }); From b39117a49a9ecfd9490228c051ad88f9a7071263 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Fri, 25 Oct 2024 13:01:13 +0300 Subject: [PATCH 19/28] 3.9.5-gnosis.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f42e0948b..541cf1e4e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.4", + "version": "3.9.5-gnosis.0", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 1277606ed281118220682e2ed138a69291be6d55 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Fri, 25 Oct 2024 16:24:48 +0300 Subject: [PATCH 20/28] 3.9.5-gnosis.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 541cf1e4e..12aea6dcd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.5-gnosis.0", + "version": "3.9.5-gnosis.1", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 76bd0e50b052bf1520aac628d9ed191599d50a29 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Mon, 28 Oct 2024 11:58:46 +0200 Subject: [PATCH 21/28] feat: integrate `aave-v3-stata` on Gnosis --- src/dex/aave-v3-stata/config.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/dex/aave-v3-stata/config.ts b/src/dex/aave-v3-stata/config.ts index a24cf6825..0ab9c22a2 100644 --- a/src/dex/aave-v3-stata/config.ts +++ b/src/dex/aave-v3-stata/config.ts @@ -7,7 +7,7 @@ import { AaveV3BNB, AaveV3Base, AaveV3Ethereum, - // AaveV3Gnosis, + AaveV3Gnosis, // AaveV3Metis, AaveV3Optimism, AaveV3Polygon, @@ -37,9 +37,9 @@ export const AaveV3StataConfig: DexConfigMap = { [Network.BSC]: { factoryAddress: AaveV3BNB.STATIC_A_TOKEN_FACTORY, }, - // [Network.Gnosis]: { - // factoryAddress: AaveV3Gnosis.STATIC_A_TOKEN_FACTORY, - // }, + [Network.GNOSIS]: { + factoryAddress: AaveV3Gnosis.STATIC_A_TOKEN_FACTORY, + }, // [Network.Scroll]: { // factoryAddress: AaveV3Scroll.STATIC_A_TOKEN_FACTORY, // }, From 1326a8cd966f003a13ece942bb4d74bc6893da18 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Mon, 28 Oct 2024 11:59:25 +0200 Subject: [PATCH 22/28] 3.9.5-gnosis.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 12aea6dcd..0aa8ce33a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.5-gnosis.1", + "version": "3.9.5-gnosis.2", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From e4ac8b024106e0343e4697099a1bd7de4e4218e8 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 12:57:04 +0200 Subject: [PATCH 23/28] feat: integrate `OkuTradeV3` UniV3 fork on Gnosis --- src/dex/uniswap-v3/config.ts | 14 +++++++++++++ src/dex/uniswap-v3/uniswap-v3-e2e.test.ts | 24 +++++++++++++++++++++++ src/dex/uniswap-v3/uniswap-v3.ts | 1 + 3 files changed, 39 insertions(+) diff --git a/src/dex/uniswap-v3/config.ts b/src/dex/uniswap-v3/config.ts index 88aa59a65..e2b2a0678 100644 --- a/src/dex/uniswap-v3/config.ts +++ b/src/dex/uniswap-v3/config.ts @@ -346,6 +346,20 @@ export const UniswapV3Config: DexConfigMap = { subgraphURL: 'https://api.studio.thegraph.com/query/59130/v3alb/0.3', }, }, + OkuTradeV3: { + [Network.GNOSIS]: { + factory: '0xe32f7dd7e3f098d518ff19a22d5f028e076489b1', + quoter: '0x7E9cB3499A6cee3baBe5c8a3D328EA7FD36578f4', + router: '0xB5253c895361678FF5D0fFDdA81Dd02f1F7a81D6', + supportedFees: SUPPORTED_FEES, + stateMulticall: '0x35Db9Ac2ff3C5A86fde165Bd26D43d303417942E', + uniswapMulticall: '0x4dfa9a980efE4802E969AC33968E3d6E59B8a19e', + chunksCount: 10, + initRetryFrequency: 10, + initHash: `0xe34f199b19b2b4f47f68442619d555527d244f78a3297ea89325f843f87b8b54`, + subgraphURL: 'Dimv1udMsJu1DqirVM4G2vNRvH8CWzWTn7GffQQCGAaq', + }, + }, VelodromeSlipstream: { [Network.OPTIMISM]: { factory: '0x548118C7E0B865C2CfA94D15EC86B666468ac758', diff --git a/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts b/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts index a0096439d..3c8a7a425 100644 --- a/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts +++ b/src/dex/uniswap-v3/uniswap-v3-e2e.test.ts @@ -1364,4 +1364,28 @@ describe('UniswapV3 E2E', () => { }); }); }); + + describe('OkuTradeV3 E2E', () => { + const dexKey = 'OkuTradeV3'; + describe('Gnosis', () => { + const network = Network.GNOSIS; + + const tokenASymbol: string = 'WETH'; + const tokenBSymbol: string = 'sDAI'; + + const tokenAAmount: string = '1000000000000000000'; + const tokenBAmount: string = '1000000000000000000'; + const nativeTokenAmount = '1000000000000000000'; + + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + nativeTokenAmount, + ); + }); + }); }); diff --git a/src/dex/uniswap-v3/uniswap-v3.ts b/src/dex/uniswap-v3/uniswap-v3.ts index 3c2e3385a..40defeeae 100644 --- a/src/dex/uniswap-v3/uniswap-v3.ts +++ b/src/dex/uniswap-v3/uniswap-v3.ts @@ -115,6 +115,7 @@ export class UniswapV3 'BaseswapV3', 'PharaohV2', 'AlienBaseV3', + 'OkuTradeV3', ]), ); From dac9f92877308ec70eeb3db6e131008f178958eb Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 12:58:01 +0200 Subject: [PATCH 24/28] 3.9.5-gnosis.3 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0aa8ce33a..9dcac77e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.5-gnosis.2", + "version": "3.9.5-gnosis.3", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 84d97589c1706f561ef0bbbe09bcbc0e71c54153 Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 18:39:43 +0200 Subject: [PATCH 25/28] feat: integrate `SwaprV2` (UniV2 fork) on Gnosis --- src/dex/uniswap-v2/nomiswap-v2.ts | 11 +++ .../uniswap-v2/uniswap-v2-e2e-gnosis.test.ts | 89 +++++++++++++++++++ tests/constants-e2e.ts | 5 ++ 3 files changed, 105 insertions(+) diff --git a/src/dex/uniswap-v2/nomiswap-v2.ts b/src/dex/uniswap-v2/nomiswap-v2.ts index 0dac17734..51cd2320c 100644 --- a/src/dex/uniswap-v2/nomiswap-v2.ts +++ b/src/dex/uniswap-v2/nomiswap-v2.ts @@ -18,6 +18,17 @@ export const NomiswapV2Config: DexConfigMap = { subgraphURL: '5CBKsDihF7KeBrNX4bgtb4tVFqy41PguVm88zBGpd4Hi', }, }, + // not exactly the same, but swapFee logic works in the same way + SwaprV2: { + [Network.GNOSIS]: { + factoryAddress: '0x5D48C95AdfFD4B40c1AAADc4e08fc44117E02179', + initCode: + '0xfcee8e246628cf9708fcb9d6f5d4aa0d96b62bb50f1af012a75a3292849e2dca', + poolGasCost: 120 * 1000, + feeCode: 25, // this is ignored as SwaprV2 uses dynamic fees, + subgraphURL: 'EWoa3JwNntAWtaLsLixTU25smp4R5tzGvs9rFXx9NHKZ', + }, + }, }; export class NomiswapV2 extends UniswapV2 { diff --git a/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts index 2c469185a..66ced3f61 100644 --- a/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts +++ b/src/dex/uniswap-v2/uniswap-v2-e2e-gnosis.test.ts @@ -191,4 +191,93 @@ describe('UniswapV2 E2E Gnosis', () => { }); }); }); + + describe('SwaprV2', () => { + const dexKey = 'SwaprV2'; + + describe('swapExactAmountIn', () => { + it('SushiSwap ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + tokens.USDC, + holders.XDAI, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SwaprV2 TOKEN -> ETH', async () => { + await testE2E( + tokens.WETH, + tokens.XDAI, + holders.WETH, + '700000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + it('SwaprV2 TOKEN -> TOKEN', async () => { + await testE2E( + tokens.WETH, + tokens.USDC, + holders.WETH, + '7000000000000000', + SwapSide.SELL, + dexKey, + ContractMethod.swapExactAmountIn, + network, + provider, + ); + }); + }); + + describe('swapExactAmountOut', () => { + it('SwaprV2 ETH -> TOKEN', async () => { + await testE2E( + tokens.XDAI, + // SWPR/WXDAI pool has non-standard feeCode - 100 + tokens.SWPR, + holders.XDAI, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SwaprV2 TOKEN -> ETH', async () => { + await testE2E( + tokens.USDC, + tokens.XDAI, + holders.USDC, + '7000000000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + it('SwaprV2 TOKEN -> TOKEN', async () => { + await testE2E( + tokens.USDC, + tokens.WETH, + holders.USDC, + '700000000000000', + SwapSide.BUY, + dexKey, + ContractMethod.swapExactAmountOut, + network, + provider, + ); + }); + }); + }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 9dc87f242..10ba58193 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -1512,6 +1512,10 @@ export const Tokens: { address: '0xaBEf652195F98A91E490f047A5006B71c85f058d', decimals: 18, }, + SWPR: { + address: '0x532801ED6f82FFfD2DAB70A19fC2d7B2772C4f4b', + decimals: 18, + }, }, [Network.BASE]: { wstETH: { @@ -1963,6 +1967,7 @@ export const Holders: { aGnowstETH: '0x458cD345B4C05e8DF39d0A07220feb4Ec19F5e6f', sDAI: '0x79f08F2e75A8C99428DE4A2e6456c07C99E55da5', crvUSD: '0xE4A982fa1f1E8AD1AF238A7b1226b13b56bf5CcD', + SWPR: '0x9467dcFD4519287e3878C018c02f5670465a9003', }, [Network.BASE]: { WETH: '0x4bb6b2efe7036020ba6f02a05602546c9f25bf28', From 4fa81307b31d26bed59dfa35647cbd8d00b8711d Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 19:50:38 +0200 Subject: [PATCH 26/28] feat: integrate `SwaprV3` (Algebra fork) on Gnosis --- src/dex/algebra/algebra-e2e.test.ts | 22 ++++++++++++++++++++++ src/dex/algebra/config.ts | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/src/dex/algebra/algebra-e2e.test.ts b/src/dex/algebra/algebra-e2e.test.ts index 0482c0899..f07da8330 100644 --- a/src/dex/algebra/algebra-e2e.test.ts +++ b/src/dex/algebra/algebra-e2e.test.ts @@ -288,4 +288,26 @@ describe('Algebra', () => { nativeTokenAmount, ); }); + + describe('SwaprV3', () => { + const dexKey = 'SwaprV3'; + const network = Network.GNOSIS; + + const tokenASymbol: string = 'WXDAI'; + const tokenBSymbol: string = 'USDC'; + + const tokenAAmount: string = '1000000000000000000'; + const tokenBAmount: string = '100000000'; + const nativeTokenAmount = '1000000000000000000'; + + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + nativeTokenAmount, + ); + }); }); diff --git a/src/dex/algebra/config.ts b/src/dex/algebra/config.ts index e3d726231..ae374b7d1 100644 --- a/src/dex/algebra/config.ts +++ b/src/dex/algebra/config.ts @@ -62,6 +62,8 @@ export const AlgebraConfig: DexConfigMap = { subgraphURL: '3CA9ffebLkS3N2otXaSj8XaDDdspty75upBjKTUS79qY', uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984', deployer: '0xc0d4323426c709e8d04b5b130e7f059523464a91', + // optimism fork uses v1.9-bidirectional-fee (with TickSpacing event and simple `fee` in globalState), + // not sure why v1.1 is used here version: 'v1.1', }, }, @@ -79,6 +81,25 @@ export const AlgebraConfig: DexConfigMap = { uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984', deployer: '0x6dd3fb9653b10e806650f107c3b5a0a6ff974f65', version: 'v1.9', + // looks like it isn't used as we override it with dexHelper.config.data.forceRpcFallbackDexs in constructor + forceRPC: true, + }, + }, + SwaprV3: { + [Network.GNOSIS]: { + factory: '0xA0864cCA6E114013AB0e27cbd5B6f4c8947da766', + router: '0xfFB643E73f280B97809A8b41f7232AB401a04ee1', + quoter: '0xcBaD9FDf0D2814659Eb26f600EFDeAF005Eda0F7', + initHash: + '0xbce37a54eab2fcd71913a0d40723e04238970e7fc1159bfd58ad5b79531697e7', + chunksCount: 10, + initRetryFrequency: 10, + // AlgebraStateMulticall + algebraStateMulticall: '0x49C46f7f88110ccA234ef27Cd664510f7bbF5998', + subgraphURL: 'AAA1vYjxwFHzbt6qKwLHNcDSASyr1J1xVViDH8gTMFMR', + uniswapMulticall: '0x4dfa9a980efE4802E969AC33968E3d6E59B8a19e', + deployer: '0xC1b576AC6Ec749d5Ace1787bF9Ec6340908ddB47', + version: 'v1.9-bidirectional-fee', forceRPC: true, }, }, From 7777bac41fadf2f1c5b13261f534e8ca5db2c9cb Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 19:51:16 +0200 Subject: [PATCH 27/28] 3.9.5-gnosis.4 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9dcac77e3..b07310648 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.5-gnosis.3", + "version": "3.9.5-gnosis.4", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 8ac5391b1d1877b1ac64de7c17da82997574030c Mon Sep 17 00:00:00 2001 From: Danylo Kanievskyi Date: Tue, 29 Oct 2024 19:58:58 +0200 Subject: [PATCH 28/28] 3.10.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b07310648..285182360 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "3.9.5-gnosis.4", + "version": "3.10.0", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib",