From 006500719e78b309d0b0be8503a40b6e3b17c77d Mon Sep 17 00:00:00 2001 From: juan-langa Date: Wed, 21 Feb 2024 11:19:44 +0100 Subject: [PATCH] StopLoss updates --- .../arbitrum/aaveV3MultiplyArbitrum.spec.ts | 4 +- .../aaveV3/base/aaveV3MultiplyBase.spec.ts | 131 +++++++++--------- .../optimism/aaveV3MultiplyOptimism.spec.ts | 6 +- .../morphoBlue/morphoBlueBorrow.spec.ts | 4 +- 4 files changed, 75 insertions(+), 70 deletions(-) diff --git a/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts b/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts index 56269b4..5e4d49c 100644 --- a/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts +++ b/tests/withWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts @@ -63,7 +63,9 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => { }).toPass({ timeout: longTestTimeout }); await app.position.setup.continue(); - await app.position.setup.openMultiplyPosition1Of2(); + + await app.position.setup.setupStopLoss1Of3(); + await app.position.setup.continueWithoutStopLoss(); // Position creation randomly fails - Retry until it's created. await expect(async () => { diff --git a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts index 9c20130..a983e2d 100644 --- a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts +++ b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts @@ -25,10 +25,10 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { await resetState(); }); - test('It should adjust risk of an existent Aave V3 Multiply Base position - Down @regression', async () => { + test('It should open an Aave v3 Multiply Base position @regression', async () => { test.info().annotations.push({ type: 'Test case', - description: '12465', + description: '12463', }); test.setTimeout(extremelyLongTestTimeout); @@ -39,8 +39,72 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { app = new App(page); ({ forkId, walletAddress } = await setup({ app, network: 'base' })); + + await tenderly.setTokenBalance({ + forkId, + walletAddress, + network: 'base', + token: 'CBETH', + balance: '50', + }); + }); + + await app.page.goto('/base/aave/v3/multiply/cbethusdbc'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'CBETH', amount: '14.12345' }); + await app.position.setup.createSmartDeFiAccount(); + + // Smart DeFi Acount creation randomly fails - Retry until it's created. + await expect(async () => { + await app.position.setup.createSmartDeFiAccount(); + await test.step('Metamask: ConfirmAddToken', async () => { + await metamask.confirmAddToken(); + }); + await app.position.setup.continueShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + + await app.position.setup.continue(); + + // 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(); + await app.position.setup.openMultiplyPosition1Of2(); + + // Position creation randomly fails - Retry until it's created. + await expect(async () => { + await app.position.setup.confirmOrRetry(); + await test.step('Metamask: ConfirmPermissionToSpend', async () => { + await metamask.confirmPermissionToSpend(); + }); + await app.position.setup.goToPositionShouldBeVisible(); + }).toPass({ timeout: longTestTimeout }); + + // Logging position ID for debugging purposes + const positionId = await app.position.setup.getNewPositionId(); + console.log('+++ Position ID: ', positionId); + + await app.position.setup.goToPosition(); + await app.position.manage.shouldBeVisible('Manage '); + }); + + test('It should adjust risk of an existent Aave V3 Multiply Base position - Down @regression', async () => { + test.info().annotations.push({ + type: 'Test case', + description: '12465', }); + test.setTimeout(longTestTimeout); + await tenderly.changeAccountOwner({ account: '0xf5922d700883214f689efe190a978ac51c50e6b1', newOwner: walletAddress, @@ -160,69 +224,6 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { await app.position.overview.shouldHaveMultiple('1.00'); }); - test('It should open an Aave v3 Multiply Base position @regression', async () => { - test.info().annotations.push({ - type: 'Test case', - description: '12463', - }); - - test.setTimeout(extremelyLongTestTimeout); - await tenderly.setTokenBalance({ - forkId, - walletAddress, - network: 'base', - token: 'CBETH', - balance: '50', - }); - - await app.page.goto('/base/aave/v3/multiply/cbethusdbc'); - - // Depositing collateral too quickly after loading page returns wrong simulation results - await app.position.overview.waitForComponentToBeStable(); - await app.position.setup.deposit({ token: 'CBETH', amount: '14.12345' }); - await app.position.setup.createSmartDeFiAccount(); - - // Smart DeFi Acount creation randomly fails - Retry until it's created. - await expect(async () => { - await app.position.setup.createSmartDeFiAccount(); - await test.step('Metamask: ConfirmAddToken', async () => { - await metamask.confirmAddToken(); - }); - await app.position.setup.continueShouldBeVisible(); - }).toPass({ timeout: longTestTimeout }); - - await app.position.setup.continue(); - - // 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(); - await app.position.setup.openMultiplyPosition1Of2(); - - // Position creation randomly fails - Retry until it's created. - await expect(async () => { - await app.position.setup.confirmOrRetry(); - await test.step('Metamask: ConfirmPermissionToSpend', async () => { - await metamask.confirmPermissionToSpend(); - }); - await app.position.setup.goToPositionShouldBeVisible(); - }).toPass({ timeout: longTestTimeout }); - - // Logging position ID for debugging purposes - const positionId = await app.position.setup.getNewPositionId(); - console.log('+++ Position ID: ', positionId); - - await app.position.setup.goToPosition(); - await app.position.manage.shouldBeVisible('Manage '); - }); - test.skip('It should list an opened Aave v3 Multiply Base position in portfolio', async () => { test.info().annotations.push({ type: 'Test case', diff --git a/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts b/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts index add57f5..77508df 100644 --- a/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts +++ b/tests/withWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts @@ -63,7 +63,9 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => { }).toPass({ timeout: longTestTimeout }); await app.position.setup.continue(); - await app.position.setup.openMultiplyPosition1Of2(); + + await app.position.setup.setupStopLoss1Of3(); + await app.position.setup.continueWithoutStopLoss(); // Confirm action randomly fails - Retry until it's applied. await expect(async () => { @@ -79,7 +81,7 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => { console.log('+++ Position ID: ', positionId); await app.position.setup.goToPosition(); - await app.position.manage.shouldBeVisible('Manage Multiply position'); + await app.position.manage.shouldBeVisible('Manage '); }); test('It should adjust risk of an existent Aave V3 Multiply Optimism position - Up @regression', async () => { diff --git a/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts b/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts index fb47f88..e483e79 100644 --- a/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts +++ b/tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts @@ -201,7 +201,7 @@ test.describe('Morpho Blue Borrow - Wallet connected', async () => { // ============================================================ await app.position.overview.shouldHaveNetValue({ - value: '[3-4][0-9],[0-9]{3}.[0-9]{2}', + value: '[0-9]{2,3},[0-9]{3}.[0-9]{2}', }); await app.position.overview.shouldHaveCollateralDeposited({ amount: '20.00', token: 'WSTETH' }); await app.position.overview.shouldHaveDebt({ @@ -248,7 +248,7 @@ test.describe('Morpho Blue Borrow - Wallet connected', async () => { // ============================================================ await app.position.overview.shouldHaveNetValue({ - value: '[2-3][0-9],[0-9]{3}.[0-9]{2}', + value: '[0-9]{2,3},[0-9]{3}.[0-9]{2}', }); await app.position.overview.shouldHaveCollateralDeposited({ amount: '15.00', token: 'WSTETH' }); await app.position.overview.shouldHaveDebt({