Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix/1224-fix-wrong-…
Browse files Browse the repository at this point in the history
…event-handling
  • Loading branch information
Verisana committed Aug 10, 2023
2 parents 79edf3d + d2839f7 commit 872ed9d
Show file tree
Hide file tree
Showing 6 changed files with 191 additions and 4 deletions.
19 changes: 19 additions & 0 deletions src/dex/pancakeswap-v3/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,21 @@ export const PancakeswapV3Config: DexConfigMap<DexParams> = {
subgraphURL:
'https://api.thegraph.com/subgraphs/name/pancakeswap/exchange-v3-bsc',
},
[Network.ARBITRUM]: {
factory: '0x0BFbCF9fa4f9C56B0F40a671Ad40E0805A091865',
deployer: '0x41ff9AA7e16B8B1a8a8dc4f0eFacd93D02d071c9',
quoter: '0xB048Bbc1Ee6b733FFfCFb9e9CeF7375518e25997',
router: '0x1b81D678ffb9C0263b24A97847620C99d213eB14',
supportedFees: PANCAKE_SUPPORTED_FEES,
stateMulticall: '0xF8498aCeD3aFa417653415B8e32BAE9d764FBFf5',
uniswapMulticall: '0x1F98415757620B543A52E61c46B32eB19261F984',
chunksCount: 10,
initRetryFrequency: 30,
initHash:
'0x6ce8eb472fa82df5469c6ab6d485f17c3ad13c8cd7af59b3d4a8026c5ce0f7e2',
subgraphURL:
'https://api.studio.thegraph.com/query/45376/exchange-v3-arbitrum/version/latest',
},
},
};

Expand All @@ -50,4 +65,8 @@ export const Adapters: Record<number, AdapterMappings> = {
[SwapSide.SELL]: [{ name: 'BscAdapter02', index: 4 }],
[SwapSide.BUY]: [{ name: 'BscBuyAdapter', index: 5 }],
},
[Network.ARBITRUM]: {
[SwapSide.SELL]: [{ name: 'ArbitrumAdapter01', index: 3 }],
[SwapSide.BUY]: [{ name: 'ArbitrumBuyAdapter', index: 2 }],
},
};
78 changes: 78 additions & 0 deletions src/dex/pancakeswap-v3/pancakeswap-v3-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,82 @@ describe('PancakeswapV3 E2E', () => {
}),
);
});

describe('PancakeswapV3 Arbitrum', () => {
const network = Network.ARBITRUM;
const tokens = Tokens[network];
const holders = Holders[network];
const provider = new StaticJsonRpcProvider(
generateConfig(network).privateHttpProvider,
network,
);

const sideToContractMethods = new Map([
[
SwapSide.SELL,
[
ContractMethod.simpleSwap,
ContractMethod.multiSwap,
ContractMethod.megaSwap,
],
],
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
]);

const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
[
{
name: NativeTokenSymbols[network],
sellAmount: '2687649500000000',
buyAmount: '5000000',
},
{
name: 'USDC',
sellAmount: '5000000',
buyAmount: '1000000000000000',
},
],
];

sideToContractMethods.forEach((contractMethods, side) =>
describe(`${side}`, () => {
contractMethods.forEach((contractMethod: ContractMethod) => {
pairs.forEach(pair => {
describe(`${contractMethod}`, () => {
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
await testE2E(
tokens[pair[0].name],
tokens[pair[1].name],
holders[pair[0].name],
side === SwapSide.SELL
? pair[0].sellAmount
: pair[0].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
await testE2E(
tokens[pair[1].name],
tokens[pair[0].name],
holders[pair[1].name],
side === SwapSide.SELL
? pair[1].sellAmount
: pair[1].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
});
});
});
}),
);
});
});
4 changes: 2 additions & 2 deletions src/dex/pancakeswap-v3/pancakeswap-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ export class PancakeswapV3
balanceDestToken,
);

if (!unitResult || !pricesResult) {
if (!pricesResult) {
this.logger.debug('Prices or unit is not calculated');
return null;
}
Expand All @@ -644,7 +644,7 @@ export class PancakeswapV3
}),
];
return {
unit: unitResult.outputs[0],
unit: unitResult?.outputs[0] || 0n,
prices,
data: {
path: [
Expand Down
9 changes: 9 additions & 0 deletions src/dex/uniswap-v2/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,15 @@ export const UniswapV2Config: DexConfigMap<DexParams> = {
poolGasCost: 90 * 1000,
feeCode: 25,
},
[Network.ARBITRUM]: {
subgraphURL:
'https://api.studio.thegraph.com/query/45376/exchange-v2-arbitrum/version/latest',
factoryAddress: '0x02a84c1b3BBD7401a5f7fa98a384EBC70bB5749E',
initCode:
'0x57224589c67f3f30a6b0d7a1b54cf3153ab84563bc609ef41dfb34f8b2974d2d',
poolGasCost: 90 * 1000,
feeCode: 25,
},
},
PaintSwap: {
[Network.FANTOM]: {
Expand Down
76 changes: 76 additions & 0 deletions src/dex/uniswap-v2/uniswap-v2-e2e-arbitrum.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -359,4 +359,80 @@ describe('UniswapV2 E2E Arbitrum', () => {
}),
);
});

describe('PancakeSwapV2', () => {
const dexKey = 'PancakeSwapV2';

const sideToContractMethods = new Map([
[
SwapSide.SELL,
[
ContractMethod.simpleSwap,
ContractMethod.multiSwap,
ContractMethod.megaSwap,
],
],
[SwapSide.BUY, [ContractMethod.simpleBuy, ContractMethod.buy]],
]);

const pairs: { name: string; sellAmount: string; buyAmount: string }[][] = [
[
{ name: 'ETH', sellAmount: '505000000000000', buyAmount: '940617' },
{ name: 'USDC', sellAmount: '940617', buyAmount: '505000000000000' },
],
[
{
name: 'ETH',
sellAmount: '631955000000000',
buyAmount: '1000000000000000000',
},
{
name: 'ARB',
sellAmount: '1000000000000000000',
buyAmount: '631955000000000',
},
],
];

sideToContractMethods.forEach((contractMethods, side) =>
describe(`${side}`, () => {
contractMethods.forEach((contractMethod: ContractMethod) => {
pairs.forEach(pair => {
describe(`${contractMethod}`, () => {
it(`${pair[0].name} -> ${pair[1].name}`, async () => {
await testE2E(
tokens[pair[0].name],
tokens[pair[1].name],
holders[pair[0].name],
side === SwapSide.SELL
? pair[0].sellAmount
: pair[0].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
it(`${pair[1].name} -> ${pair[0].name}`, async () => {
await testE2E(
tokens[pair[1].name],
tokens[pair[0].name],
holders[pair[1].name],
side === SwapSide.SELL
? pair[1].sellAmount
: pair[1].buyAmount,
side,
dexKey,
contractMethod,
network,
provider,
);
});
});
});
});
}),
);
});
});
9 changes: 7 additions & 2 deletions tests/constants-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,14 @@ export const Tokens: {
addAllowance: _allowancesFn,
},
ETH: { address: ETHER_ADDRESS, decimals: 18 },
USDC: {
USDCe: {
address: '0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8',
decimals: 6,
},
USDC: {
address: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
decimals: 6,
},
OHM: {
address: '0xf0cb2dc0db5e6c66b9a70ac27b06b878da017028',
decimals: 9,
Expand Down Expand Up @@ -1013,7 +1017,8 @@ export const Holders: {
ETH: '0xF977814e90dA44bFA03b6295A0616a897441aceC',
DAI: '0x07d7f291e731a41d3f0ea4f1ae5b6d920ffb3fe0',
WETH: '0xc31e54c7a869b9fcbecc14363cf510d1c41fa443',
USDC: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
USDCe: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
USDC: '0xa843392198862f98d17e3aa1421b08f2c2020cff',
OHM: '0xebce5f29ff5ca9aa330ebdf7ec6b5f474bff271e',
USDT: '0x62383739d68dd0f844103db8dfb05a7eded5bbe6',
POPS: '0x4b78b52e7de4d8b7d367297cb8a87c1875a9d591',
Expand Down

0 comments on commit 872ed9d

Please sign in to comment.