From 36938956fb7946e4ad755250f1ac7b587c29a15e Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Fri, 25 Aug 2023 10:39:13 +0100 Subject: [PATCH 1/4] Fix onchain data to handle broken rates. --- test/lib/onchainData.ts | 38 +++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/test/lib/onchainData.ts b/test/lib/onchainData.ts index bf4a60bd..8313e77a 100644 --- a/test/lib/onchainData.ts +++ b/test/lib/onchainData.ts @@ -138,11 +138,14 @@ export async function getOnChainBalances( ); multiPool.call(`${pool.id}.targets`, pool.address, 'getTargets'); - multiPool.call( - `${pool.id}.rate`, - pool.address, - 'getWrappedTokenRate' - ); + // AaveLinear pools with version === 1 rates will still work + if (pool.poolType === 'AaveLinear' && pool.poolTypeVersion === 1) { + multiPool.call( + `${pool.id}.rate`, + pool.address, + 'getWrappedTokenRate' + ); + } } else if (pool.poolType.toString().includes('Gyro')) { multiPool.call( `${pool.id}.swapFee`, @@ -252,19 +255,24 @@ export async function getOnChainBalances( ); } - const wrappedIndex = subgraphPools[index].wrappedIndex; if ( - wrappedIndex === undefined || - onchainData.rate === undefined + subgraphPools[index].poolType === 'AaveLinear' && + subgraphPools[index].poolTypeVersion === 1 ) { - console.error( - `Linear Pool Missing WrappedIndex or PriceRate: ${poolId}` - ); - return; + const wrappedIndex = subgraphPools[index].wrappedIndex; + if ( + wrappedIndex === undefined || + onchainData.rate === undefined + ) { + console.error( + `Linear Pool Missing WrappedIndex or PriceRate: ${poolId}` + ); + return; + } + // Update priceRate of wrappedToken + subgraphPools[index].tokens[wrappedIndex].priceRate = + formatFixed(onchainData.rate, 18); } - // Update priceRate of wrappedToken - subgraphPools[index].tokens[wrappedIndex].priceRate = - formatFixed(onchainData.rate, 18); } subgraphPools[index].swapFee = formatFixed(swapFee, 18); From 92cbb55fc4d65fb0670063ab88f2560851c70489 Mon Sep 17 00:00:00 2001 From: johngrantuk Date: Thu, 31 Aug 2023 09:34:00 +0100 Subject: [PATCH 2/4] Add Gnosis constants and 3POOL/wstETH midpool. --- test/testScripts/constants.ts | 17 +++++++++++++++++ test/testScripts/swapExample.ts | 8 ++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/test/testScripts/constants.ts b/test/testScripts/constants.ts index 4eeb98bc..3d0436cf 100644 --- a/test/testScripts/constants.ts +++ b/test/testScripts/constants.ts @@ -114,6 +114,13 @@ export const SOR_CONFIG: Record = { symbol: 'weth', address: '0x6A023CCd1ff6F2045C3309768eAd9E68F978f6e1', }, + { + symbol: 'wsteth', + address: '0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6', + }, + ], + triPathMidPoolIds: [ + '0xeb30c85cc528537f5350cf5684ce6a4538e13394000200000000000000000059', // 3POOL_BPT/wstETH ], }, [Network.ZKEVM]: { @@ -522,6 +529,16 @@ export const ADDRESSES = { decimals: 6, symbol: 'USDT', }, + wstETH: { + address: '0x6C76971f98945AE98dD7d4DFcA8711ebea946eA6', + decimals: 18, + symbol: 'wstETH', + }, + STETH: { + address: 'todo', + decimals: 18, + symbol: 'STETH', + }, }, [Network.GOERLI]: { DAI: { diff --git a/test/testScripts/swapExample.ts b/test/testScripts/swapExample.ts index 9c6bcf2b..68b70aa1 100644 --- a/test/testScripts/swapExample.ts +++ b/test/testScripts/swapExample.ts @@ -58,17 +58,17 @@ function setUp(networkId: Network, provider: JsonRpcProvider): SOR { } export async function swap(): Promise { - const networkId = Network.BASE; + const networkId = Network.GNOSIS; const provider = new JsonRpcProvider(PROVIDER_URLS[networkId]); // gasPrice is used by SOR as a factor to determine how many pools to swap against. // i.e. higher cost means more costly to trade against lots of different pools. const gasPrice = BigNumber.from('14000000000'); // This determines the max no of pools the SOR will use to swap. const maxPools = 4; - const tokenIn = ADDRESSES[networkId].DAI; - const tokenOut = ADDRESSES[networkId].BALD; + const tokenIn = ADDRESSES[networkId].WXDAI; + const tokenOut = ADDRESSES[networkId].WETH; const swapType: SwapTypes = SwapTypes.SwapExactIn; - const swapAmount = parseFixed('900', 18); + const swapAmount = parseFixed('20000', 18); const sor = setUp(networkId, provider); From 64f94da64b6fe0443a541d4568d2db3291bffc8b Mon Sep 17 00:00:00 2001 From: Luiz Gustavo Abou Hatem De Liz Date: Mon, 11 Sep 2023 21:06:10 -0300 Subject: [PATCH 3/4] Fixing the gyroEV2.integration.spec.ts tests; Removing the skip of xaveFxPool.polygon.integration.spec.ts (the test is running fine); --- test/gyroEV2.integration.spec.ts | 19 +++++++++---------- test/xaveFxPool.polygon.integration.spec.ts | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/test/gyroEV2.integration.spec.ts b/test/gyroEV2.integration.spec.ts index 07191125..bd489083 100644 --- a/test/gyroEV2.integration.spec.ts +++ b/test/gyroEV2.integration.spec.ts @@ -12,10 +12,10 @@ import { setUp } from './testScripts/utils'; dotenv.config(); const networkId = Network.POLYGON; -const jsonRpcUrl = ''; +const jsonRpcUrl = process.env.RPC_URL_POLYGON ?? ''; const rpcUrl = 'http://127.0.0.1:8137'; const provider = new JsonRpcProvider(rpcUrl, networkId); -const blocknumber = 42173266; +const blocknumber = 47427007; const vault = Vault__factory.connect(vaultAddr, provider); @@ -64,7 +64,7 @@ const gyroEV2PoolWMATIC_stMATIC_POLYGON: SubgraphPoolBase = { dSq: '0.9999999999999999988662409334210612', }; -describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { +describe('gyroEV2: WMATIC-stMATIC integration tests', () => { let sor: SOR; const funds = { sender: AddressZero, @@ -91,21 +91,20 @@ describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { it('should return no swaps when above limit', async () => { const tokenIn = ADDRESSES[Network.POLYGON].WMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].stMATIC.address; - const swapAmount = parseFixed('33.33333333333333', 18); + const swapAmount = parseFixed('100000000', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, swapType, swapAmount ); - expect(swapInfo.swaps.length).to.eq(0); expect(swapInfo.returnAmount.toString()).to.eq('0'); }); it('token > LSD, getSwaps result should match queryBatchSwap', async () => { const tokenIn = ADDRESSES[Network.POLYGON].WMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].stMATIC.address; - const swapAmount = parseFixed('1.12345678', 18); + const swapAmount = parseFixed('1603426', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, @@ -130,7 +129,7 @@ describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { it('LSD > token, getSwaps result should match queryBatchSwap', async () => { const tokenIn = ADDRESSES[Network.POLYGON].stMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].WMATIC.address; - const swapAmount = parseFixed('0.999', 18); + const swapAmount = parseFixed('160342', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, @@ -160,7 +159,7 @@ describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { it('should return no swaps when above limit', async () => { const tokenIn = ADDRESSES[Network.POLYGON].WMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].stMATIC.address; - const swapAmount = parseFixed('100', 18); + const swapAmount = parseFixed('100000000', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, @@ -174,7 +173,7 @@ describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { it('token > LSD, getSwaps result should match queryBatchSwap', async () => { const tokenIn = ADDRESSES[Network.POLYGON].WMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].stMATIC.address; - const swapAmount = parseFixed('1.987654321', 18); + const swapAmount = parseFixed('1603426', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, @@ -198,7 +197,7 @@ describe.skip('gyroEV2: WMATIC-stMATIC integration tests', () => { it('LSD > token, getSwaps result should match queryBatchSwap', async () => { const tokenIn = ADDRESSES[Network.POLYGON].stMATIC.address; const tokenOut = ADDRESSES[Network.POLYGON].WMATIC.address; - const swapAmount = parseFixed('0.999', 18); + const swapAmount = parseFixed('1603420', 18); const swapInfo = await sor.getSwaps( tokenIn, tokenOut, diff --git a/test/xaveFxPool.polygon.integration.spec.ts b/test/xaveFxPool.polygon.integration.spec.ts index d247f4b8..44658396 100644 --- a/test/xaveFxPool.polygon.integration.spec.ts +++ b/test/xaveFxPool.polygon.integration.spec.ts @@ -72,7 +72,7 @@ const xaveFxPoolXSGD_USDC_POLYGON: SubgraphPoolBase = { epsilon: '0.0005', }; -describe.skip('xaveFxPool: DAI-USDC integration (Polygon) tests', () => { +describe('xaveFxPool: DAI-USDC integration (Polygon) tests', () => { context('test swaps vs queryBatchSwap', () => { // Setup chain before(async function () { From 740be872acb92b677ca1d43f15035ab5708f7e82 Mon Sep 17 00:00:00 2001 From: Bruno Eidam Guerios Date: Sat, 2 Dec 2023 17:33:05 -0300 Subject: [PATCH 4/4] Add sBAL3 as tripathmidpool to gnosis --- .nvmrc | 1 + test/testScripts/constants.ts | 13 ++++++++++++- test/testScripts/swapExample.ts | 4 ++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..112a2eae --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +lts/gallium \ No newline at end of file diff --git a/test/testScripts/constants.ts b/test/testScripts/constants.ts index 3d0436cf..1905c381 100644 --- a/test/testScripts/constants.ts +++ b/test/testScripts/constants.ts @@ -121,6 +121,7 @@ export const SOR_CONFIG: Record = { ], triPathMidPoolIds: [ '0xeb30c85cc528537f5350cf5684ce6a4538e13394000200000000000000000059', // 3POOL_BPT/wstETH + '0x7644fa5d0ea14fcf3e813fdf93ca9544f8567655000000000000000000000066', // sBAL3 ], }, [Network.ZKEVM]: { @@ -522,7 +523,7 @@ export const ADDRESSES = { WXDAI: { address: '0xe91d153e0b41518a2ce8dd3d7944fa863463a97d', decimals: 18, - symbol: 'DAI', + symbol: 'WXDAI', }, USDT: { address: '0x4ECaBa5870353805a9F068101A40E0f32ed605C6', @@ -539,6 +540,16 @@ export const ADDRESSES = { decimals: 18, symbol: 'STETH', }, + crvUSD: { + address: '0xaBEf652195F98A91E490f047A5006B71c85f058d', + decimals: 18, + symbol: 'crvUSD', + }, + sDAI: { + address: '0xaf204776c7245bf4147c2612bf6e5972ee483701', + decimals: 18, + symbol: 'sDAI', + }, }, [Network.GOERLI]: { DAI: { diff --git a/test/testScripts/swapExample.ts b/test/testScripts/swapExample.ts index 68b70aa1..7518eb7a 100644 --- a/test/testScripts/swapExample.ts +++ b/test/testScripts/swapExample.ts @@ -66,9 +66,9 @@ export async function swap(): Promise { // This determines the max no of pools the SOR will use to swap. const maxPools = 4; const tokenIn = ADDRESSES[networkId].WXDAI; - const tokenOut = ADDRESSES[networkId].WETH; + const tokenOut = ADDRESSES[networkId].crvUSD; const swapType: SwapTypes = SwapTypes.SwapExactIn; - const swapAmount = parseFixed('20000', 18); + const swapAmount = parseFixed('200', 18); const sor = setUp(networkId, provider);