Skip to content

Commit

Permalink
Merge pull request #110 from OasisDEX/single-tx-aave-v3-mainnet-multiply
Browse files Browse the repository at this point in the history
Aave V3 Mainnet Multiply - Multiple actions in single tx
  • Loading branch information
juan-langa authored Dec 21, 2023
2 parents 0c57547 + 8d53710 commit 686dd1d
Show file tree
Hide file tree
Showing 3 changed files with 142 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import { BrowserContext, test } from '@playwright/test';
import { expect, metamaskSetUp, setupNewFork } from 'utils/setup';
import { resetState } from '@synthetixio/synpress/commands/synpress';
import * as metamask from '@synthetixio/synpress/commands/metamask';
import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import {
extremelyLongTestTimeout,
longTestTimeout,
positionTimeout,
veryLongTestTimeout,
} from 'utils/config';
import { App } from 'src/app';

let context: BrowserContext;
let app: App;
let forkId: string;
let walletAddress: string;

test.describe.configure({ mode: 'serial' });

test.describe('Aave v3 Multiply - Ethereum - Wallet connected', async () => {
test.afterAll(async () => {
await tenderly.deleteFork(forkId);

await app.page.close();

await context.close();

await resetState();
});

test('It should Deposit and Borrow in a single tx on an existing Aave V3 Multiply Ethereum position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13664',
});

test.setTimeout(extremelyLongTestTimeout);

await test.step('Test setup', async () => {
({ context } = await metamaskSetUp({ network: 'mainnet' }));
let page = await context.newPage();
app = new App(page);

({ forkId, walletAddress } = await setup({ app, network: 'mainnet' }));
await tenderly.setRethBalance({ forkId, walletAddress, rEthBalance: '100' });
});

await tenderly.changeAccountOwner({
account: '0x6bb713b56e73a115164b4b56ea1f5a76640c4d19',
newOwner: walletAddress,
forkId,
});

await app.page.goto('/ethereum/aave/v3/1276#overview');
// Wait for all position data to be loaded
await app.position.shouldHaveTab('Protection ON');

await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('Manage collateral');
await app.position.manage.deposit({ token: 'RETH', amount: '50' });
await app.position.manage.borrow({ token: 'DAI', amount: '40000' });

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
await app.position.setup.approveAllowance();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken({});
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });
await app.position.setup.continue();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: veryLongTestTimeout });

await app.position.manage.ok();

await app.position.overview.shouldHaveExposure({
amount: '50.[0-9]{5}',
token: 'RETH',
timeout: positionTimeout,
});
await app.position.overview.shouldHaveDebt({ amount: '40,[0-9]{3}.[0-9]{4}', token: 'DAI' });
});

test('It should Withdraw and Pay back in a single tx on an existing Aave V3 Multiply Ethereum position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13665',
});

test.setTimeout(veryLongTestTimeout);

await app.position.manage.shouldBeVisible('Manage Multiply position');
await app.position.overview.shouldHaveExposure({ amount: '50.[0-9]{5}', token: 'RETH' });
await app.position.overview.shouldHaveDebt({ amount: '40,[0-9]{3}.[0-9]{4}', token: 'DAI' });

await app.position.manage.openManageOptions({ currentLabel: 'Adjust' });
await app.position.manage.select('Manage collateral');
await app.position.manage.withdrawCollateral();
await app.position.manage.withdraw({ token: 'RETH', amount: '8' });
await app.position.manage.payback({ token: 'DAI', amount: '10000' });
// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
await app.position.setup.approveAllowance();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken({});
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });
await app.position.setup.continue();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.manage.shouldShowSuccessScreen();
}).toPass({ timeout: longTestTimeout });

await app.position.manage.ok();

await app.position.overview.shouldHaveExposure({
amount: '4[1-2].[0-9]{5}',
token: 'RETH',
timeout: positionTimeout,
});
await app.position.overview.shouldHaveDebt({ amount: '30,[0-9]{3}.[0-9]{4}', token: 'DAI' });
});
});
2 changes: 1 addition & 1 deletion utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const hooksTimeout: number =
baseUrl.includes('localhost') || baseUrl.includes('3000.csb.app') ? 130_000 : 110_000;

export const longTestTimeout: number =
baseUrl.includes('localhost') || baseUrl.includes('3000.csb.app') ? 65_000 : 60_000;
baseUrl.includes('localhost') || baseUrl.includes('3000.csb.app') ? 85_000 : 70_000;

export const veryLongTestTimeout: number =
baseUrl.includes('localhost') || baseUrl.includes('3000.csb.app') ? 120_000 : 110_000;
Expand Down

0 comments on commit 686dd1d

Please sign in to comment.