From 0d55b8110aa40e6be02f160d32cfeeaad8806900 Mon Sep 17 00:00:00 2001 From: ftm1337 <84405345+ftm1337@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:15:09 -0500 Subject: [PATCH 01/12] add solidly fork: equalizer --- src/dex/solidly/forks-override/equalizer.ts | 58 +++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/dex/solidly/forks-override/equalizer.ts diff --git a/src/dex/solidly/forks-override/equalizer.ts b/src/dex/solidly/forks-override/equalizer.ts new file mode 100644 index 000000000..ee9531e64 --- /dev/null +++ b/src/dex/solidly/forks-override/equalizer.ts @@ -0,0 +1,58 @@ +import { Solidly } from '../solidly'; +import { SolidlyPair } from '../types'; +import { Network } from '../../../constants'; +import { IDexHelper } from '../../../dex-helper'; +import { Interface } from '@ethersproject/abi'; +import { getDexKeysWithNetwork } from '../../../utils'; +import { SolidlyConfig } from '../config'; +import _ from 'lodash'; + +const EqualizerFactoryABI = [ + { + inputs: [{ internalType: 'bool', name: '_stable', type: 'bool' }], + name: 'getFee', + outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], + stateMutability: 'view', + type: 'function', + }, +]; + +const equalizerFactoryIface = new Interface(EqualizerFactoryABI); + +export class Equalizer extends Solidly { + public static dexKeysWithNetwork: { key: string; networks: Network[] }[] = + getDexKeysWithNetwork(_.pick(SolidlyConfig, ['Equalizer'])); + + constructor( + protected network: Network, + dexKey: string, + protected dexHelper: IDexHelper, + ) { + super( + network, + dexKey, + dexHelper, + true, // dynamic fees + ); + } + + protected getFeesMultiCallData(pair: SolidlyPair) { + const callEntry = { + target: this.factoryAddress, + callData: equalizerFactoryIface.encodeFunctionData('getFee', [ + pair.stable, + ]), + }; + const callDecoder = (values: any[]) => + parseInt( + equalizerFactoryIface + .decodeFunctionResult('getFee', values)[0] + .toString(), + ); + + return { + callEntry, + callDecoder, + }; + } +} From e8ef680257115ac5fa6c1aa3e5d9f8a0decc2cb7 Mon Sep 17 00:00:00 2001 From: ftm1337 <84405345+ftm1337@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:33:36 -0500 Subject: [PATCH 02/12] Equalizer --- src/dex/solidly/config.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/dex/solidly/config.ts b/src/dex/solidly/config.ts index acff06d0e..33d7f5ccc 100644 --- a/src/dex/solidly/config.ts +++ b/src/dex/solidly/config.ts @@ -72,6 +72,21 @@ export const SolidlyConfig: DexConfigMap = { feeCode: 0, // variable }, }, + Equalizer: { + [Network.FANTOM]: { + subgraphURL: '',//'https://api.thegraph.com/subgraphs/name/ftm1337/equalizer-subgraph-1',//inactive + factoryAddress: '0xc6366EFD0AF1d09171fe0EBF32c7943BB310832a', + router: '0x1A05EB736873485655F29a37DEf8a0AA87F5a447', + initCode: + '0x02ada2a0163cd4f7e0f0c9805f5230716a95b174140e4c84c14883de216cc6a3', + // updatable fees on the factory without event + //stableFee: 2, + //volatileFee: 20, + //feeCode: 2, + feeCode: 0, // variable + poolGasCost: 180 * 1000, + }, + }, }; export const Adapters: Record = { @@ -79,7 +94,7 @@ export const Adapters: Record = { [SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 3 }], // dystopia }, [Network.FANTOM]: { - [SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly + spiritSwapV2 + [SwapSide.SELL]: [{ name: 'FantomAdapter01', index: 10 }], // solidly + spiritSwapV2 + Equalizer }, [Network.OPTIMISM]: { [SwapSide.SELL]: [{ name: 'OptimismAdapter01', index: 8 }], // velodrome From 099723d01164e6e524b93e62e9810f99155d73ac Mon Sep 17 00:00:00 2001 From: ftm1337 <84405345+ftm1337@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:37:38 -0500 Subject: [PATCH 03/12] Add Equalizer --- src/dex/index.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dex/index.ts b/src/dex/index.ts index 30e32623b..944d0b21a 100644 --- a/src/dex/index.ts +++ b/src/dex/index.ts @@ -46,6 +46,7 @@ import { Velodrome } from './solidly/forks-override/velodrome'; import { SpiritSwapV2 } from './solidly/forks-override/spiritSwapV2'; import { Synthetix } from './synthetix/synthetix'; import { Cone } from './solidly/forks-override/cone'; +import { Equalizer } from './solidly/forks-override/equalizer'; import { QuickSwapV3 } from './quickswap-v3'; import { BalancerV1 } from './balancer-v1/balancer-v1'; import { balancerV1Merge } from './balancer-v1/optimizer'; @@ -105,6 +106,7 @@ const Dexes = [ SpiritSwapV2, Velodrome, Cone, + Equalizer, Synthetix, CurveV1Factory, SwaapV1, From 2d21c80bbcd79373019f23915159d3945c169aa6 Mon Sep 17 00:00:00 2001 From: ftm1337 <84405345+ftm1337@users.noreply.github.com> Date: Mon, 23 Jan 2023 11:46:29 -0500 Subject: [PATCH 04/12] Add Equalizer --- src/dex/solidly/solidly.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dex/solidly/solidly.ts b/src/dex/solidly/solidly.ts index 68475e380..2254b02c3 100644 --- a/src/dex/solidly/solidly.ts +++ b/src/dex/solidly/solidly.ts @@ -64,7 +64,7 @@ export class Solidly extends UniswapV2 { public static dexKeysWithNetwork: { key: string; networks: Network[] }[] = getDexKeysWithNetwork( - _.omit(SolidlyConfig, ['Velodrome', 'SpiritSwapV2', 'Cone']), + _.omit(SolidlyConfig, ['Velodrome', 'SpiritSwapV2', 'Cone', 'Equalizer']), ); constructor( From d9dcfe300e1ee8040d98280fb5e1bafa548f77fe Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Wed, 30 Aug 2023 14:31:26 +0300 Subject: [PATCH 05/12] add fixes --- src/dex/solidly/solidly.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/dex/solidly/solidly.ts b/src/dex/solidly/solidly.ts index 11a32031f..899acd50f 100644 --- a/src/dex/solidly/solidly.ts +++ b/src/dex/solidly/solidly.ts @@ -128,6 +128,8 @@ export class Solidly extends UniswapV2 { routerAddress !== undefined ? routerAddress : SolidlyConfig[dexKey][network].router || ''; + + this.feeFactor = SolidlyConfig[dexKey][network].feeFactor || this.feeFactor; } async findSolidlyPair(from: Token, to: Token, stable: boolean) { @@ -429,8 +431,13 @@ export class Solidly extends UniswapV2 { ): Promise { if (!this.subgraphURL) return []; - const stableFieldKey = - this.dexKey.toLowerCase() === 'solidly' ? 'stable' : 'isStable'; + let stableFieldKey = ''; + + if (this.dexKey.toLowerCase() === 'solidly') { + stableFieldKey = 'stable'; + } else if (this.dexKey.toLowerCase() !== 'solidlyv2') { + stableFieldKey = 'isStable'; + } const query = `query ($token: Bytes!, $count: Int) { pools0: pairs(first: $count, orderBy: reserveUSD, orderDirection: desc, where: {token0: $token, reserve0_gt: 1, reserve1_gt: 1}) { @@ -516,6 +523,7 @@ export class Solidly extends UniswapV2 { const pair = await this.findSolidlyPair(from, to, stable); if (!(pair && pair.pool && pair.exchange)) return null; const pairState = pair.pool.getState(blockNumber); + if (!pairState) { this.logger.error( `Error_orderPairParams expected reserves, got none (maybe the pool doesn't exist) ${ From 3986835a78963930e56fcc187b6711cac1bbc641 Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Thu, 31 Aug 2023 13:15:58 +0300 Subject: [PATCH 06/12] add tests --- src/dex/solidly/config.ts | 9 +- src/dex/solidly/solidly-e2e.test.ts | 23 ++++ src/dex/solidly/solidly-integration.test.ts | 115 ++++++++++++++++++++ 3 files changed, 140 insertions(+), 7 deletions(-) diff --git a/src/dex/solidly/config.ts b/src/dex/solidly/config.ts index f1fe91653..b18dba6d7 100644 --- a/src/dex/solidly/config.ts +++ b/src/dex/solidly/config.ts @@ -150,16 +150,11 @@ export const SolidlyConfig: DexConfigMap = { }, Equalizer: { [Network.FANTOM]: { - subgraphURL: '',//'https://api.thegraph.com/subgraphs/name/ftm1337/equalizer-subgraph-1',//inactive factoryAddress: '0xc6366EFD0AF1d09171fe0EBF32c7943BB310832a', - router: '0x1A05EB736873485655F29a37DEf8a0AA87F5a447', + router: '0x93d2611EB8b85bE4FDEa9D94Ce9913D90072eC0f', initCode: '0x02ada2a0163cd4f7e0f0c9805f5230716a95b174140e4c84c14883de216cc6a3', - // updatable fees on the factory without event - //stableFee: 2, - //volatileFee: 20, - //feeCode: 2, - feeCode: 0, // variable + feeCode: 0, poolGasCost: 180 * 1000, }, }, diff --git a/src/dex/solidly/solidly-e2e.test.ts b/src/dex/solidly/solidly-e2e.test.ts index 93e4e791f..96bb9796f 100644 --- a/src/dex/solidly/solidly-e2e.test.ts +++ b/src/dex/solidly/solidly-e2e.test.ts @@ -389,6 +389,29 @@ describe('Solidly E2E', () => { }); }); }); + + describe('Equalizer', () => { + const dexKey = 'Equalizer'; + const network = Network.FANTOM; + + const tokenASymbol: string = 'FUSDT'; + const tokenBSymbol: string = 'USDC'; + + const tokenAAmount: string = '111110'; + const tokenBAmount: string = '100000'; + const nativeTokenAmount = '11000000000000000'; + + testForNetwork( + network, + dexKey, + tokenASymbol, + tokenBSymbol, + tokenAAmount, + tokenBAmount, + nativeTokenAmount, + ); + + }); }); describe('Mainnet', () => { diff --git a/src/dex/solidly/solidly-integration.test.ts b/src/dex/solidly/solidly-integration.test.ts index 77e70a694..629fa1025 100644 --- a/src/dex/solidly/solidly-integration.test.ts +++ b/src/dex/solidly/solidly-integration.test.ts @@ -15,6 +15,7 @@ import { Chronos } from './forks-override/chronos'; import { Ramses } from './forks-override/ramses'; import * as util from 'util'; import { VelodromeV2 } from './forks-override/velodromeV2'; +import { Equalizer } from './forks-override/equalizer'; const amounts18 = [0n, BI_POWS[18], 2000000000000000000n]; const amounts6 = [0n, BI_POWS[6], 2000000n]; @@ -353,6 +354,120 @@ describe('Solidly integration tests', () => { }); }); }); + + describe('Equalizer', () => { + const dexKey = 'Equalizer'; + const equalizer = new Equalizer(network, dexKey, dexHelper); + + describe('UniswapV2 like pool', function () { + const TokenASymbol = 'WFTM'; + const tokenA = Tokens[network][TokenASymbol]; + const TokenBSymbol = 'FUSDT'; + const tokenB = Tokens[network][TokenBSymbol]; + + const amounts = amounts18; + + it('getPoolIdentifiers and getPricesVolume', async function () { + const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); + const pools = await equalizer.getPoolIdentifiers( + tokenA, + tokenB, + SwapSide.SELL, + blocknumber, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, + pools, + ); + + expect(pools.length).toBeGreaterThan(0); + + const poolPrices = await equalizer.getPricesVolume( + tokenA, + tokenB, + amounts, + SwapSide.SELL, + blocknumber, + pools, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, + poolPrices, + ); + + expect(poolPrices).not.toBeNull(); + checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); + + // Check if onchain pricing equals to calculated ones + + for (const i in poolPrices || []) { + await checkOnChainPricing( + equalizer, + 'getAmountOut', + blocknumber, + poolPrices![i].prices, + poolPrices![i].poolAddresses![0], + tokenA.address, + amounts, + ); + } + }); + }); + + describe('Curve like stable pool', function () { + const TokenASymbol = 'FUSDT'; + const tokenA = Tokens[network][TokenASymbol]; + const TokenBSymbol = 'USDC'; + const tokenB = Tokens[network][TokenBSymbol]; + + const amounts = amounts6; // amounts6; + + it('getPoolIdentifiers and getPricesVolume', async function () { + const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); + const pools = await equalizer.getPoolIdentifiers( + tokenA, + tokenB, + SwapSide.SELL, + blocknumber, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, + pools, + ); + + expect(pools.length).toBeGreaterThan(0); + + const poolPrices = await equalizer.getPricesVolume( + tokenA, + tokenB, + amounts, + SwapSide.SELL, + blocknumber, + pools, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, + poolPrices, + ); + + expect(poolPrices).not.toBeNull(); + checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); + + // Check if onchain pricing equals to calculated ones + for (const i in poolPrices || []) { + await checkOnChainPricing( + equalizer, + 'getAmountOut', + blocknumber, + poolPrices![i].prices, + poolPrices![i].poolAddresses![0], + tokenA.address, + amounts, + ); + } + }); + }); + }); }); describe('Polygon', () => { From fba865acff11976f21dbc1d223778e2efee8708c Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Thu, 31 Aug 2023 13:17:57 +0300 Subject: [PATCH 07/12] 2.33.1-equalizer --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ed144096..151015786 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.33.0", + "version": "2.33.1-equalizer", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 5a55c83c247f94f934260a56d6b62a0574735c4e Mon Sep 17 00:00:00 2001 From: Alexander Burkut Date: Thu, 31 Aug 2023 18:57:17 +0300 Subject: [PATCH 08/12] add tintegration test for FTM -> EQUAL --- src/dex/solidly/solidly-integration.test.ts | 56 +++++++++++++++++++++ tests/constants-e2e.ts | 5 ++ 2 files changed, 61 insertions(+) diff --git a/src/dex/solidly/solidly-integration.test.ts b/src/dex/solidly/solidly-integration.test.ts index 629fa1025..5ff9928cf 100644 --- a/src/dex/solidly/solidly-integration.test.ts +++ b/src/dex/solidly/solidly-integration.test.ts @@ -467,6 +467,62 @@ describe('Solidly integration tests', () => { } }); }); + + describe('FTM -> EQUAL', () => { + const TokenASymbol = 'WFTM'; + const tokenA = Tokens[network][TokenASymbol]; + const TokenBSymbol = 'EQUAL'; + const tokenB = Tokens[network][TokenBSymbol]; + + const amounts = [0n, 10000000n]; + + console.log('AMOUNTS: ', amounts); + it('getPoolIdentifiers and getPricesVolume', async function () { + // const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); + const blocknumber = 67666611; + const pools = await equalizer.getPoolIdentifiers( + tokenA, + tokenB, + SwapSide.SELL, + blocknumber, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Identifiers: `, + pools, + ); + + expect(pools.length).toBeGreaterThan(0); + + const poolPrices = await equalizer.getPricesVolume( + tokenA, + tokenB, + amounts, + SwapSide.SELL, + blocknumber, + pools, + ); + console.log( + `${TokenASymbol} <> ${TokenBSymbol} Pool Prices: `, + poolPrices, + ); + + expect(poolPrices).not.toBeNull(); + checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); + + // Check if onchain pricing equals to calculated ones + for (const i in poolPrices || []) { + await checkOnChainPricing( + equalizer, + 'getAmountOut', + blocknumber, + poolPrices![i].prices, + poolPrices![i].poolAddresses![0], + tokenA.address, + amounts, + ); + } + }); + }); }); }); diff --git a/tests/constants-e2e.ts b/tests/constants-e2e.ts index 06ca492e8..faa56d798 100644 --- a/tests/constants-e2e.ts +++ b/tests/constants-e2e.ts @@ -460,6 +460,10 @@ export const Tokens: { address: '0x049d68029688eabf473097a2fc38ef61633a3c7a', decimals: 6, }, + EQUAL: { + address: '0x3fd3a0c85b70754efc07ac9ac0cbbdce664865a6', + decimals: 18 + }, POPS: { address: '0x9dE4b40bDcE50Ec6a1A668bF85997BbBD324069a', decimals: 18, @@ -979,6 +983,7 @@ export const Holders: { ETH: '0xf48883940b4056801de30f12b934dcea90133ee6', GUSDC: '0x894d774a293f8aa3d23d67815d4cadb5319c1094', GDAI: '0x0e2ed73f9c1409e2b36fe6c46e60d4557b7c2ac0', + EQUAL: '0x8b187ea19c93091a4d6b426b71871648182b5fac', }, [Network.BSC]: { DAI: '0xf68a4b64162906eff0ff6ae34e2bb1cd42fef62d', From 078fe78c10e19136210dfa9fb04535e4ac53acb6 Mon Sep 17 00:00:00 2001 From: Verisana Date: Fri, 1 Sep 2023 12:09:23 +0100 Subject: [PATCH 09/12] fix: use getRealFee instead of getFee --- src/dex/solidly/forks-override/equalizer.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dex/solidly/forks-override/equalizer.ts b/src/dex/solidly/forks-override/equalizer.ts index ee9531e64..c72a61068 100644 --- a/src/dex/solidly/forks-override/equalizer.ts +++ b/src/dex/solidly/forks-override/equalizer.ts @@ -9,8 +9,8 @@ import _ from 'lodash'; const EqualizerFactoryABI = [ { - inputs: [{ internalType: 'bool', name: '_stable', type: 'bool' }], - name: 'getFee', + inputs: [{ internalType: 'address', name: '_pair', type: 'address' }], + name: 'getRealFee', outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }], stateMutability: 'view', type: 'function', @@ -39,14 +39,14 @@ export class Equalizer extends Solidly { protected getFeesMultiCallData(pair: SolidlyPair) { const callEntry = { target: this.factoryAddress, - callData: equalizerFactoryIface.encodeFunctionData('getFee', [ - pair.stable, + callData: equalizerFactoryIface.encodeFunctionData('getRealFee', [ + pair.exchange, ]), }; const callDecoder = (values: any[]) => parseInt( equalizerFactoryIface - .decodeFunctionResult('getFee', values)[0] + .decodeFunctionResult('getRealFee', values)[0] .toString(), ); From 5f3f501ef92cbd28755289068f578625a42f92cc Mon Sep 17 00:00:00 2001 From: Verisana Date: Fri, 1 Sep 2023 12:25:10 +0100 Subject: [PATCH 10/12] test: update tests and fix issues --- src/dex/solidly/solidly-integration.test.ts | 123 ++++++++++---------- 1 file changed, 62 insertions(+), 61 deletions(-) diff --git a/src/dex/solidly/solidly-integration.test.ts b/src/dex/solidly/solidly-integration.test.ts index 5ff9928cf..73f50a127 100644 --- a/src/dex/solidly/solidly-integration.test.ts +++ b/src/dex/solidly/solidly-integration.test.ts @@ -1,3 +1,4 @@ +/* eslint-disable no-console */ import dotenv from 'dotenv'; dotenv.config(); @@ -47,7 +48,7 @@ function decodeReaderResult( const constructCheckOnChainPricing = (dexHelper: DummyDexHelper) => async ( - soldily: Solidly, + solidly: Solidly, funcName: string, blockNumber: number, prices: bigint[], @@ -89,7 +90,7 @@ describe('Solidly integration tests', () => { describe('Solidly', function () { const dexKey = 'Solidly'; - const soldily = new Solidly(network, dexKey, dexHelper); + const solidly = new Solidly(network, dexKey, dexHelper); describe('UniswapV2 like pool', function () { const TokenASymbol = 'WFTM'; @@ -101,7 +102,7 @@ describe('Solidly integration tests', () => { it('getPoolIdentifiers and getPricesVolume', async function () { const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); - const pools = await soldily.getPoolIdentifiers( + const pools = await solidly.getPoolIdentifiers( tokenA, tokenB, SwapSide.SELL, @@ -114,7 +115,7 @@ describe('Solidly integration tests', () => { expect(pools.length).toBeGreaterThan(0); - const poolPrices = await soldily.getPricesVolume( + const poolPrices = await solidly.getPricesVolume( tokenA, tokenB, amounts, @@ -132,13 +133,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( - soldily, + solidly, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -146,7 +147,7 @@ describe('Solidly integration tests', () => { }); it('getTopPoolsForToken', async function () { - const poolLiquidity = await soldily.getTopPoolsForToken( + const poolLiquidity = await solidly.getTopPoolsForToken( tokenA.address, 10, ); @@ -166,7 +167,7 @@ describe('Solidly integration tests', () => { it('getPoolIdentifiers and getPricesVolume', async function () { const blocknumber = await dexHelper.web3Provider.eth.getBlockNumber(); - const pools = await soldily.getPoolIdentifiers( + const pools = await solidly.getPoolIdentifiers( tokenA, tokenB, SwapSide.SELL, @@ -179,7 +180,7 @@ describe('Solidly integration tests', () => { expect(pools.length).toBeGreaterThan(0); - const poolPrices = await soldily.getPricesVolume( + const poolPrices = await solidly.getPricesVolume( tokenA, tokenB, amounts, @@ -196,13 +197,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( - soldily, + solidly, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -210,7 +211,7 @@ describe('Solidly integration tests', () => { }); it('getTopPoolsForToken', async function () { - const poolLiquidity = await soldily.getTopPoolsForToken( + const poolLiquidity = await solidly.getTopPoolsForToken( tokenA.address, 10, ); @@ -266,13 +267,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( spiritSwapV2, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -330,13 +331,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( spiritSwapV2, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -400,13 +401,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( equalizer, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -454,13 +455,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( equalizer, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -510,13 +511,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( equalizer, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -576,13 +577,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( dystopia, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -640,13 +641,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( dystopia, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -716,13 +717,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( cone, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -780,13 +781,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( cone, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -856,13 +857,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( chronos, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -920,13 +921,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( chronos, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -992,13 +993,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( ramses, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -1056,13 +1057,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( ramses, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -1132,13 +1133,13 @@ describe('Solidly integration tests', () => { // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( velodromeV2, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); @@ -1186,13 +1187,13 @@ describe('Solidly integration tests', () => { checkPoolPrices(poolPrices!, amounts, SwapSide.SELL, dexKey); // Check if onchain pricing equals to calculated ones - for (const i in poolPrices || []) { + for (const poolPrice of poolPrices || []) { await checkOnChainPricing( velodromeV2, 'getAmountOut', blocknumber, - poolPrices![i].prices, - poolPrices![i].poolAddresses![0], + poolPrice.prices, + poolPrice.poolAddresses![0], tokenA.address, amounts, ); From 5e331cc355b67a56fd8d98abee5386ad696e587c Mon Sep 17 00:00:00 2001 From: Verisana Date: Fri, 1 Sep 2023 12:26:38 +0100 Subject: [PATCH 11/12] chore: set version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 151015786..1d70eb47b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.33.1-equalizer", + "version": "2.33.1", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib", From 9bf6de48998d0f0deac0cd159ce655ceb46c3047 Mon Sep 17 00:00:00 2001 From: Verisana Date: Fri, 1 Sep 2023 12:27:08 +0100 Subject: [PATCH 12/12] 2.33.2 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1d70eb47b..5383acecf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@paraswap/dex-lib", - "version": "2.33.1", + "version": "2.33.2", "main": "build/index.js", "types": "build/index.d.ts", "repository": "https://github.com/paraswap/paraswap-dex-lib",