Skip to content

Commit

Permalink
Merge branch 'master' into aburkut/back-1332-tests-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
aburkut committed Nov 2, 2023
2 parents 8454d9e + cfec4ae commit 57588db
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 47 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@paraswap/dex-lib",
"version": "2.42.1",
"version": "2.42.3",
"main": "build/index.js",
"types": "build/index.d.ts",
"repository": "https://github.com/paraswap/paraswap-dex-lib",
Expand Down
5 changes: 3 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,13 @@ const baseConfigs: { [network: number]: BaseConfig } = {
multicallV2Address: '0x7eCfBaa8742fDf5756DAC92fbc8b90a19b8815bF',
privateHttpProvider: process.env.HTTP_PROVIDER_42161,
hashFlowAuthToken: process.env.API_KEY_HASHFLOW_AUTH_TOKEN || '',
swaapV2AuthToken: process.env.API_KEY_SWAAP_V2_AUTH_TOKEN || '',
hashFlowDisabledMMs:
process.env[`HASHFLOW_DISABLED_MMS_42161`]?.split(',') || [],
adapterAddresses: {
ArbitrumAdapter01: '0xD8134ACfc9c71Ab51452b5bA23A31354F4739032',
ArbitrumAdapter02: '0xD1F70c98a78d48A93F0B4dDa49057469dc5aC126',
ArbitrumBuyAdapter: '0x434C1Cca4842629230067674Dd54E21a14D9FD5D',
ArbitrumAdapter02: '0x248009f6F78b5AcD5EA2fc86d56b77A7AeEe2eFc',
ArbitrumBuyAdapter: '0xEECA9223063bD13e8ca77ed9e39a07f2BD1923E6',
},
uniswapV2ExchangeRouterAddress:
'0xB41dD984730dAf82f5C41489E21ac79D5e3B61bC',
Expand Down
13 changes: 12 additions & 1 deletion src/dex/balancer-v1/balancer-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ import { generatePoolStates } from './utils';
import BalancerV1ExchangeProxyABI from '../../abi/BalancerV1ExchangeProxy.json';
import BalancerCustomMulticallABI from '../../abi/BalancerCustomMulticall.json';

const BLACKLISTED_POOLS = new Set([
'0x7860e28ebfb8ae052bfe279c07ac5d94c9cd2937',
]);

export class BalancerV1
extends SimpleExchange
implements IDex<BalancerV1Data | OptimizedBalancerV1Data>
Expand Down Expand Up @@ -82,11 +86,18 @@ export class BalancerV1
// for pricing requests. It is optional for a DEX to
// implement this function
async initializePricing(_blockNumber: number) {
this.poolsInfo = await this.dexHelper.httpRequest.get<PoolsInfo>(
const _poolsInfo = await this.dexHelper.httpRequest.get<PoolsInfo>(
this.config.poolsURL,
POOLS_FETCH_TIMEOUT,
);

this.poolInfosByToken = {};
if (!_poolsInfo) return;
this.poolsInfo = {
..._poolsInfo,
pools: _poolsInfo.pools.filter(p => !BLACKLISTED_POOLS.has(p.id)),
};

for (const poolInfo of this.poolsInfo.pools) {
for (const tokenAddress of poolInfo.tokensList) {
if (!this.poolInfosByToken[tokenAddress]) {
Expand Down
7 changes: 5 additions & 2 deletions src/dex/swaap-v2/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export const SwaapV2Config: DexConfigMap<DexParams> = {
SwaapV2: {
[Network.MAINNET]: {},
[Network.POLYGON]: {},
// Arbitrum will be supported later
// [Network.ARBITRUM]: {},
[Network.ARBITRUM]: {},
},
};

Expand All @@ -20,4 +19,8 @@ export const Adapters: Record<number, AdapterMappings> = {
[SwapSide.SELL]: [{ name: 'PolygonAdapter02', index: 8 }],
[SwapSide.BUY]: [{ name: 'PolygonBuyAdapter', index: 7 }],
},
[Network.ARBITRUM]: {
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter02', index: 6 }],
[SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 8 }],
},
};
115 changes: 74 additions & 41 deletions src/dex/swaap-v2/swaap-v2-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,46 +224,79 @@ describe('SwaapV2 E2E', () => {
);
});

// Arbitrum will be supported later
// describe('Arbitrum', () => {
// const network = Network.ARBITRUM;
//
// const tokenASymbol: string = 'ETH';
// const tokenBSymbol: string = 'DAI';
//
// const tokenAAmount: string = '100000000';
// const tokenBAmount: string = '1000000000000000000';
// const nativeTokenAmount = '1000000000000000000';
//
// testForNetwork(
// network,
// dexKey,
// tokenASymbol,
// tokenBSymbol,
// tokenAAmount,
// tokenBAmount,
// nativeTokenAmount,
// );
// });
describe('Arbitrum', () => {
const network = Network.ARBITRUM;
const provider = new StaticJsonRpcProvider(
generateConfig(network).privateHttpProvider,
network,
);
const tokens = Tokens[network];
const holders = Holders[network];

const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
[
{
name: 'WETH',
sellAmount: '10000000000000000',
buyAmount: '1000000000000000000',
},
{
name: 'DAI',
sellAmount: '1000000000000000000',
buyAmount: '10000000000000000',
},
],
];

// Mainnet will be supported later
// describe('Mainnet', () => {
// const network = Network.MAINNET;
// const tokenASymbol: string = 'USDC';
// const tokenBSymbol: string = 'USDT';
//
// const tokenAAmount: string = '100000000';
// const tokenBAmount: string = '1000000000000000000';
// const nativeTokenAmount = '1000000000000000000';
//
// testForNetwork(
// network,
// dexKey,
// tokenASymbol,
// tokenBSymbol,
// tokenAAmount,
// tokenBAmount,
// nativeTokenAmount,
// );
// });
sideToContractMethods.forEach((contractMethods, side) =>
describe(`${side}`, () => {
contractMethods.forEach((contractMethod: ContractMethod) => {
pairs.forEach(pair => {
describe(`${contractMethod}`, () => {
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
await testE2E(
tokens[pair[0].name],
tokens[pair[1].name],
holders[pair[0].name],
side === SwapSide.SELL
? pair[0].sellAmount
: pair[0].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
undefined,
sleepMs,
);
});
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
await testE2E(
tokens[pair[1].name],
tokens[pair[0].name],
holders[pair[1].name],
side === SwapSide.SELL
? pair[1].sellAmount
: pair[1].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
undefined,
undefined,
undefined,
undefined,
sleepMs,
);
});
});
});
});
}),
);
});
});
5 changes: 5 additions & 0 deletions tests/constants-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export const Tokens: {
address: '0x8f8221aFbB33998d8584A2B05749bA73c37a938a',
decimals: 18,
},
AMPL: {
address: '0xd46ba6d942050d489dbd938a2c909a5d5039a161',
decimals: 9,
},
USDC: {
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
decimals: 6,
Expand Down Expand Up @@ -958,6 +962,7 @@ export const Holders: {
[Network.MAINNET]: {
ETH: '0x176F3DAb24a159341c0509bB36B833E7fdd0a132',
USDC: '0x79E2Ba942B0e8fDB6ff3d406e930289d10B49ADe',
AMPL: '0x223592a191ECfC7FDC38a9256c3BD96E771539A9',
WBTC: '0x1cb17a66dc606a52785f69f08f4256526abd4943',
sBTC: '0xA2e3475D13776C6E42ff37B47286827d959B2195',
BADGER: '0x34e2741a3f8483dbe5231f61c005110ff4b9f50a',
Expand Down

0 comments on commit 57588db

Please sign in to comment.