Skip to content

Commit

Permalink
Merge pull request #804 from paraswap/feat/paraswap-pool-x
Browse files Browse the repository at this point in the history
GenericRFQ tests fixes
  • Loading branch information
KanievskyiDanylo authored Oct 23, 2024
2 parents b06bbcc + e38c0a7 commit 9b2a4b2
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 68 deletions.
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type BaseConfig = {
wrappedNativeTokenAddress: Address;
hasEIP1559: boolean;
augustusAddress: Address;
augustusV6Address?: Address;
augustusV6Address: Address;
augustusRFQAddress: Address;
tokenTransferProxyAddress: Address;
multicallV2Address: Address;
Expand Down
66 changes: 5 additions & 61 deletions src/dex/generic-rfq/e2e-test-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,74 +8,18 @@ export const testConfig: {
amount: string;
}>;
} = {
[Network.MAINNET]: [
// {
// srcToken: 'USDT',
// destToken: 'WETH',
// swapSide: SwapSide.BUY,
// amount: '10000000000000000',
// },
// {
// srcToken: 'WETH',
// destToken: 'USDT',
// swapSide: SwapSide.BUY,
// amount: '1000000',
// },
// {
// srcToken: 'USDT',
// destToken: 'WETH',
// swapSide: SwapSide.SELL,
// amount: '1000000',
// },
{
// srcToken: 'WETH',
// destToken: 'DAI',
srcToken: 'DAI',
destToken: 'WETH',
swapSide: SwapSide.BUY,
amount: '10000000000000000',
},
{
srcToken: 'DAI',
destToken: 'ETH',
swapSide: SwapSide.BUY,
amount: '10000000000000000',
},
{
srcToken: 'ETH',
destToken: 'DAI',
swapSide: SwapSide.BUY,
amount: '10000000000000000',
},
[Network.ARBITRUM]: [
{
srcToken: 'WETH',
destToken: 'DAI',
destToken: 'USDC',
amount: '10000',
swapSide: SwapSide.BUY,
amount: '10000000000000000',
},
{
srcToken: 'DAI',
srcToken: 'USDC',
destToken: 'WETH',
amount: '10000',
swapSide: SwapSide.SELL,
amount: '10000000000000000',
},
{
srcToken: 'DAI',
destToken: 'ETH',
swapSide: SwapSide.SELL,
amount: '10000000000000000',
},
{
srcToken: 'ETH',
destToken: 'DAI',
swapSide: SwapSide.SELL,
amount: '10000000000000000',
},
{
srcToken: 'WETH',
destToken: 'DAI',
swapSide: SwapSide.SELL,
amount: '10000000000000000',
},
],
};
7 changes: 4 additions & 3 deletions src/dex/generic-rfq/generic-rfq-e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ const buildConfigForGenericRFQ = (): RFQConfig => {
};
};

const SKIP_TENDERLY = !!getEnv('GENERIC_RFQ_SKIP_TENDERLY', true);
const SKIP_TENDERLY =
(process.env.GENERIC_RFQ_SKIP_TENDERLY ?? 'true') === 'true';
const dexKey = 'YOUR_NAME';

describe(`GenericRFQ ${dexKey} E2E`, () => {
Expand Down Expand Up @@ -133,8 +134,8 @@ describe(`GenericRFQ ${dexKey} E2E`, () => {
}
const contractMethod =
testCase.swapSide === SwapSide.BUY
? ContractMethod.swapExactAmountInOutOnAugustusRFQTryBatchFill
: ContractMethod.swapExactAmountInOutOnAugustusRFQTryBatchFill;
? ContractMethod.swapOnAugustusRFQTryBatchFill
: ContractMethod.swapOnAugustusRFQTryBatchFill;
describe(`${contractMethod}`, () => {
it(`${testCase.swapSide} ${testCase.srcToken} -> ${testCase.destToken}`, async () => {
await newTestE2E({
Expand Down
2 changes: 1 addition & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ export type Config = {
wrappedNativeTokenAddress: Address;
hasEIP1559: boolean;
augustusAddress: Address;
augustusV6Address?: Address;
augustusV6Address: Address;
augustusRFQAddress: Address;
tokenTransferProxyAddress: Address;
multicallV2Address: Address;
Expand Down
9 changes: 9 additions & 0 deletions tests/constants-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
allowedFn,
_balancesFn,
_allowancesFn,
balanceAndBlacklistStatesFn,
} from '../tests/smart-tokens';
import { Address } from '../src/types';
import { ETHER_ADDRESS, Network } from '../src/constants';
Expand Down Expand Up @@ -1177,6 +1178,12 @@ export const Tokens: {
address: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
decimals: 6,
symbol: 'USDC',
addBalance: balanceAndBlacklistStatesFn,
addAllowance: allowedFn,
},
SUSHI: {
address: '0xd4d42F0b6DEF4CE0383636770eF773390d85c61A',
decimals: 18,
},
crvUSD: {
address: '0x498bf2b1e120fed3ad3d42ea2165e9b73f99c1e5',
Expand Down Expand Up @@ -1319,6 +1326,8 @@ export const Tokens: {
WETH: {
address: '0x4200000000000000000000000000000000000006',
decimals: 18,
addBalance: balanceOfFn,
addAllowance: allowanceFn,
},
ETH: { address: ETHER_ADDRESS, decimals: 18 },
USDCe: {
Expand Down
3 changes: 3 additions & 0 deletions tests/smart-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const constructAddBAllowanceFn = (varName: string): AddAllowanceFn => {

export const balanceOfFn = constructAddBalanceFn('balanceOf');
export const balancesFn = constructAddBalanceFn('balances');
export const balanceAndBlacklistStatesFn = constructAddBalanceFn(
'balanceAndBlacklistStates',
);
export const _balancesFn = constructAddBalanceFn('_balances');
export const allowanceFn = constructAddBAllowanceFn('allowance');
export const _allowancesFn = constructAddBAllowanceFn('_allowances');
Expand Down
8 changes: 6 additions & 2 deletions tests/utils-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,19 @@ export async function newTestE2E({
.addBalance(senderAddress, twiceAmount.toString())
.addAllowance(
senderAddress,
config.tokenTransferProxyAddress,
priceRoute.version === ParaSwapVersion.V5
? config.tokenTransferProxyAddress
: config.augustusV6Address,
amount.toString(),
);
} else {
srcToken
.addBalance(senderAddress, MAX_UINT)
.addAllowance(
senderAddress,
config.tokenTransferProxyAddress,
priceRoute.version === ParaSwapVersion.V5
? config.tokenTransferProxyAddress
: config.augustusV6Address,
(BigInt(MAX_UINT) / 8n).toString(),
);
}
Expand Down

0 comments on commit 9b2a4b2

Please sign in to comment.