Skip to content

Commit

Permalink
Merge pull request #609 from OasisDEX/daily-improvements-05-nov-6
Browse files Browse the repository at this point in the history
Daily improvements - 05 November
  • Loading branch information
juan-langa authored Nov 5, 2024
2 parents 2582cba + 023cb26 commit c783c27
Show file tree
Hide file tree
Showing 8 changed files with 461 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/0_1_regressionWithRealWallet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on:
required: false

jobs:
with-real-tests:
with-real-wallet:
uses: ./.github/workflows/z_Reusable_RegressionWithRealWallet.yml
with:
base_url: ${{ inputs.base_url }}
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/z_Reusable_RegressionWithRealWallet.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reusable Workflow - Regression - With-wallet tests
name: Reusable Workflow - Regression - With real wallet tests

on:
workflow_call:
Expand Down Expand Up @@ -31,6 +31,9 @@ jobs:
run: npx playwright install && npx playwright install-deps
- name: Install xvfb
run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
- name: Verify that staging environment is ready for testing
if: ${{ inputs.base_url == 'https://staging.summer.fi' }}
run: yarn verify-staging
- name: Build Synpress cache
run: |
BASE_URL=${{ inputs.base_url }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ test.describe('Aave V3 Multiply - Arbitrum - Wallet connected', async () => {

await app.position.openPage('/arbitrum/aave/v3/multiply/eth-dai/1#overview');

// Pause to avoid random fails
await app.page.waitForTimeout(1_000);

await test.step('It should set Auto-Buy', async () => {
await automations.testAutoBuy({
metamask,
Expand All @@ -63,6 +66,9 @@ test.describe('Aave V3 Multiply - Arbitrum - Wallet connected', async () => {
await app.page.reload();
await app.position.overview.shouldBeVisible();

// Pause to avoid random fails
await app.page.waitForTimeout(1_000);

await automations.testAutoSell({
metamask,
app,
Expand All @@ -80,6 +86,9 @@ test.describe('Aave V3 Multiply - Arbitrum - Wallet connected', async () => {
await app.page.reload();
await app.position.overview.shouldBeVisible();

// Pause to avoid random fails
await app.page.waitForTimeout(1_000);

await automations.testRegularStopLoss({
metamask,
app,
Expand Down
159 changes: 159 additions & 0 deletions tests/withWallet/aaveV3/base/aaveV3BorrowBase.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import { testWithSynpress } from '@synthetixio/synpress';
import { metaMaskFixtures } from '@synthetixio/synpress/playwright';
import baseSetup from 'utils/synpress/test-wallet-setup/base.setup';
import { setup } from 'utils/setup';
import * as tenderly from 'utils/tenderly';
import { extremelyLongTestTimeout } from 'utils/config';
import { App } from 'src/app';
import {
close,
manageDebtOrCollateral,
openPosition,
} from 'tests/sharedTestSteps/positionManagement';

let app: App;
let forkId: string;

const test = testWithSynpress(metaMaskFixtures(baseSetup));

test.describe('Aave V3 Borrow - Base - Wallet connected', async () => {
test.beforeEach(async ({ metamask, page }) => {
test.setTimeout(extremelyLongTestTimeout);

app = new App(page);
({ forkId } = await setup({ metamask, app, network: 'base' }));
});

test.afterEach(async () => {
await tenderly.deleteFork(forkId);
await app.page.close();
});

test('It should open and magage an Aave V3 Borrow Base position @regression', async ({
metamask,
}) => {
test.info().annotations.push({
type: 'Test case',
description: '12473',
});

test.setTimeout(extremelyLongTestTimeout);

await app.page.goto('/base/aave/v3/borrow/eth-usdbc#simulate');

await test.step('It should Open a position', async () => {
await app.page.waitForTimeout(1_000);

await openPosition({
metamask,
app,
forkId,
deposit: { token: 'ETH', amount: '9.12345' },
borrow: { token: 'USDBC', amount: '2000' },
});
});

// Skip again if DB collision also happeningwith omni
await test.step('It should Deposit and Borrow in a single tx', async () => {
await app.page.waitForTimeout(1_000);

await manageDebtOrCollateral({
metamask,
app,
forkId,
deposit: { token: 'ETH', amount: '1' },
borrow: { token: 'USDBC', amount: '3000' },
expectedCollateralDeposited: {
amount: '10.12',
token: 'ETH',
},
expectedDebt: { amount: '5,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDBC' },
protocol: 'Aave V3',
});
});

await test.step('It should Withdraw and Pay back in a single tx', async () => {
await app.page.waitForTimeout(1_000);

await app.position.manage.withdrawCollateral();

await manageDebtOrCollateral({
metamask,
app,
forkId,
withdraw: { token: 'ETH', amount: '2' },
payBack: { token: 'USDBC', amount: '1000' },
expectedCollateralDeposited: {
amount: '8.12',
token: 'ETH',
},
expectedDebt: { amount: '4,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDBC' },
protocol: 'Aave V3',
});
});

await test.step('It should Borrow and Deposit in a single tx', async () => {
await app.page.waitForTimeout(1_000);

await app.position.manage.openManageOptions({ currentLabel: 'ETH' });
await app.position.manage.select('Manage debt');

await manageDebtOrCollateral({
metamask,
app,
forkId,
borrow: { token: 'USDBC', amount: '2000' },
deposit: { token: 'ETH', amount: '1' },
expectedCollateralDeposited: {
amount: '9.12',
token: 'ETH',
},
expectedDebt: { amount: '6,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDBC' },
protocol: 'Aave V3',
});
});

await test.step('It should Pay back and Withdraw in a single tx', async () => {
// Reload page to avoid random fails
await app.page.reload();
await app.page.waitForTimeout(1_000);

await app.position.manage.openManageOptions({ currentLabel: 'ETH' });
await app.position.manage.select('Manage debt');
await app.position.manage.payBackDebt();

await manageDebtOrCollateral({
metamask,
app,
forkId,
payBack: { token: 'USDBC', amount: '3000' },
withdraw: { token: 'ETH', amount: '1.5' },
expectedCollateralDeposited: {
amount: '7.62',
token: 'ETH',
},
expectedDebt: { amount: '3,[0-9]{3}.[0-9]{2}([0-9]{1,2})?', token: 'USDBC' },
protocol: 'Aave V3',
allowanceNotNeeded: true,
});
});

// Skip again if DB collision also happening with omni
await test.step('It should Close a position', async () => {
// Pause and Reload page to avoid random fails
await app.page.reload();
await app.page.waitForTimeout(1_000);

await close({
metamask,
app,
forkId,
positionType: 'Borrow',
closeTo: 'collateral',
collateralToken: 'ETH',
debtToken: 'USDBC',
tokenAmountAfterClosing: '[0-9]{1,2}.[0-9]{1,2}',
});
});
});
});
106 changes: 106 additions & 0 deletions tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism1.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import { testWithSynpress } from '@synthetixio/synpress';
import { metaMaskFixtures } from '@synthetixio/synpress/playwright';
import optimismSetup from 'utils/synpress/test-wallet-setup/optimism.setup';
import { setup } from 'utils/setup';
import * as tenderly from 'utils/tenderly';
import { extremelyLongTestTimeout, veryLongTestTimeout } from 'utils/config';
import { App } from 'src/app';
import { adjustRisk, close, openPosition } from 'tests/sharedTestSteps/positionManagement';

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

const test = testWithSynpress(metaMaskFixtures(optimismSetup));

test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
test.beforeEach(async ({ metamask, page }) => {
test.setTimeout(extremelyLongTestTimeout);

app = new App(page);
({ forkId } = await setup({ metamask, app, network: 'optimism' }));
});

test.afterEach(async () => {
await tenderly.deleteFork(forkId);
await app.page.close();
});

test('It should open and manage an Aave v3 Multiply Optimism position - ETH/USDC @regression', async ({
metamask,
}) => {
test.setTimeout(extremelyLongTestTimeout);

await app.page.goto('/optimism/aave/v3/multiply/eth-usdc');

await test.step('It should Open a position', async () => {
await app.page.waitForTimeout(1_000);

await openPosition({
metamask,
app,
forkId,
deposit: { token: 'ETH', amount: '10.12345' },
});
});

await test.step('It should Adjust risk - Up', async () => {
await tenderly.changeAccountOwner({
account: '0x2047e97451955c98bf8378f6ac2f04d95578990c',
newOwner: walletAddress,
forkId,
});

await app.page.goto('/optimism/aave/v3/multiply/eth-usdc.e/2#overview');

await app.page.waitForTimeout(1_000);

await adjustRisk({
metamask,
forkId,
app,
risk: 'up',
newSliderPosition: 0.9,
});
});

await test.step('It should Adjust risk - Down', async () => {
await app.page.waitForTimeout(1_000);

await adjustRisk({
metamask,
forkId,
app,
risk: 'down',
newSliderPosition: 0.05,
});
});
});

test('It should close an existent Aave V3 Multiply Optimism position - Close to collateral token (ETH) @regression', async ({
metamask,
}) => {
test.setTimeout(veryLongTestTimeout);

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

await app.page.goto('/optimism/aave/v3/multiply/eth-usdc.e/2#overview');

await app.page.waitForTimeout(1_000);

await close({
metamask,
app,
forkId,
positionType: 'Multiply',
closeTo: 'collateral',
collateralToken: 'ETH',
debtToken: 'USDC',
tokenAmountAfterClosing: '0.[0-9]{3,4}',
});
});
});
Loading

0 comments on commit c783c27

Please sign in to comment.