From aa6c01c2dc63ed434a1afaeaeab853c8543dbe7c Mon Sep 17 00:00:00 2001 From: juan-langa Date: Fri, 1 Mar 2024 18:00:10 +0100 Subject: [PATCH 1/2] Small fixes --- .github/workflows/regression.yml | 4 ++-- .../aaveV3/base/aaveV3MultiplyBase.spec.ts | 15 +++++---------- .../ajna/arbitrum/ajnaArbitrumBorrow.spec.ts | 10 +++++----- .../spark/sparkMultiplyAutomations.spec.ts | 2 +- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/.github/workflows/regression.yml b/.github/workflows/regression.yml index 3d9de55..b1e4999 100644 --- a/.github/workflows/regression.yml +++ b/.github/workflows/regression.yml @@ -142,7 +142,7 @@ jobs: retention-days: 30 with-wallet-ajna-tests: - name: 'With wallet - Ajna & Morpho Blue' + name: 'With wallet - Ajna' runs-on: ubuntu-latest env: TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }} @@ -161,7 +161,7 @@ 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: Run With wallet Ajna & Morpho Blue tests + - name: Run With wallet Ajna run: | TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \ TENDERLY_USER=${{ secrets.TENDERLY_USER }} \ diff --git a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts index a983e2d..9e4be17 100644 --- a/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts +++ b/tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts @@ -11,6 +11,7 @@ let context: BrowserContext; let app: App; let forkId: string; let walletAddress: string; +let positionId: string; test.describe.configure({ mode: 'serial' }); @@ -90,7 +91,7 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { }).toPass({ timeout: longTestTimeout }); // Logging position ID for debugging purposes - const positionId = await app.position.setup.getNewPositionId(); + positionId = await app.position.setup.getNewPositionId(); console.log('+++ Position ID: ', positionId); await app.position.setup.goToPosition(); @@ -105,13 +106,7 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { test.setTimeout(longTestTimeout); - await tenderly.changeAccountOwner({ - account: '0xf5922d700883214f689efe190a978ac51c50e6b1', - newOwner: walletAddress, - forkId, - }); - - await app.page.goto('/base/aave/v3/17#overview'); + await app.page.goto(positionId); await app.position.manage.shouldBeVisible('Manage Multiply position'); const initialLiqPrice = await app.position.manage.getLiquidationPrice(); @@ -213,13 +208,13 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => { await app.position.overview.shouldHaveLiquidationPrice({ price: '0.00', - token: 'ETH/USDBC', + token: 'CBETH/USDBC', timeout: positionTimeout, }); await app.position.overview.shouldHaveLoanToValue('0.00'); await app.position.overview.shouldHaveNetValue({ value: '\\$0.00' }); await app.position.overview.shouldHaveBuyingPower('\\$0.00'); - await app.position.overview.shouldHaveExposure({ amount: '0.00', token: 'ETH' }); + await app.position.overview.shouldHaveExposure({ amount: '0.00', token: 'CBETH' }); await app.position.overview.shouldHaveDebt({ amount: '0.00', token: 'USDBC' }); await app.position.overview.shouldHaveMultiple('1.00'); }); diff --git a/tests/withWallet/ajna/arbitrum/ajnaArbitrumBorrow.spec.ts b/tests/withWallet/ajna/arbitrum/ajnaArbitrumBorrow.spec.ts index 3d1a7c2..1dec66c 100644 --- a/tests/withWallet/ajna/arbitrum/ajnaArbitrumBorrow.spec.ts +++ b/tests/withWallet/ajna/arbitrum/ajnaArbitrumBorrow.spec.ts @@ -68,7 +68,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => { }); }); - test('It should Deposit and Borrow in a single tx form an existing Ajna Base Borrow position @regression', async () => { + test('It should Deposit and Borrow in a single tx form an existing Ajna Arbitrum Borrow position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxxx', @@ -89,7 +89,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => { }); }); - test('It should Withdraw and Pay back in a single tx form an existing Ajna Base Borrow position @regression', async () => { + test('It should Withdraw and Pay back in a single tx form an existing Ajna Arbitrum Borrow position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxxx', @@ -112,7 +112,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => { }); }); - test('It should Borrow and Deposit in a single tx on an existing Ajna Base Borrow position @regression', async () => { + test('It should Borrow and Deposit in a single tx on an existing Ajna Arbitrum Borrow position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxx', @@ -136,7 +136,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => { }); }); - test('It should Pay back and Withdraw in a single tx on an existing Ajna Base Borrow position @regression', async () => { + test('It should Pay back and Withdraw in a single tx on an existing Ajna Arbitrum Borrow position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxx', @@ -163,7 +163,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => { }); // !! tx failing with very low liquidity - To re-test when liquidity rises - test.skip('It should Close to collateral an existing Ajna Base Borrow position @regression', async () => { + test.skip('It should Close to collateral an existing Ajna Arbitrum Borrow position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxxx', diff --git a/tests/withWallet/spark/sparkMultiplyAutomations.spec.ts b/tests/withWallet/spark/sparkMultiplyAutomations.spec.ts index 5224754..d63cd8b 100644 --- a/tests/withWallet/spark/sparkMultiplyAutomations.spec.ts +++ b/tests/withWallet/spark/sparkMultiplyAutomations.spec.ts @@ -26,7 +26,7 @@ test.describe('Spark Multiply - Mainnet - Wallet connected', async () => { await resetState(); }); - test('It should Deposit and Borrow in a single tx on an existing Spark Multiply position', async () => { + test('It should Deposit and Borrow in a single tx on an existing Spark Multiply position @regression', async () => { test.info().annotations.push({ type: 'Test case', description: '13659', From 3c49ddb789a9f596643812454e25b43dd741221e Mon Sep 17 00:00:00 2001 From: juan-langa Date: Fri, 1 Mar 2024 18:34:09 +0100 Subject: [PATCH 2/2] Ajna Optimism Earn --- .../ajna/arbitrum/ajnaArbitrumEarn.spec.ts | 10 +- .../ajna/optimism/ajnaOptimismEarn.spec.ts | 157 ++++++++++++++++++ utils/tenderly.ts | 2 + 3 files changed, 160 insertions(+), 9 deletions(-) create mode 100644 tests/withWallet/ajna/optimism/ajnaOptimismEarn.spec.ts diff --git a/tests/withWallet/ajna/arbitrum/ajnaArbitrumEarn.spec.ts b/tests/withWallet/ajna/arbitrum/ajnaArbitrumEarn.spec.ts index 1112e85..29c0265 100644 --- a/tests/withWallet/ajna/arbitrum/ajnaArbitrumEarn.spec.ts +++ b/tests/withWallet/ajna/arbitrum/ajnaArbitrumEarn.spec.ts @@ -14,7 +14,7 @@ let walletAddress: string; test.describe.configure({ mode: 'serial' }); -test.describe('Ajna Arbitrum Earn & Borrow - Wallet connected', async () => { +test.describe('Ajna Arbitrum Earn - Wallet connected', async () => { test.afterAll(async () => { await tenderly.deleteFork(forkId); @@ -43,14 +43,6 @@ test.describe('Ajna Arbitrum Earn & Borrow - Wallet connected', async () => { network: 'arbitrum', })); - await tenderly.setTokenBalance({ - forkId, - walletAddress, - network: 'arbitrum', - token: 'USDC', - balance: '50000', - }); - await tenderly.setTokenBalance({ forkId, walletAddress, diff --git a/tests/withWallet/ajna/optimism/ajnaOptimismEarn.spec.ts b/tests/withWallet/ajna/optimism/ajnaOptimismEarn.spec.ts new file mode 100644 index 0000000..ac75445 --- /dev/null +++ b/tests/withWallet/ajna/optimism/ajnaOptimismEarn.spec.ts @@ -0,0 +1,157 @@ +import { BrowserContext, test } from '@playwright/test'; +import { expect, metamaskSetUp } from 'utils/setup'; +import { resetState } from '@synthetixio/synpress/commands/synpress'; +import * as tenderly from 'utils/tenderly'; +import { setup } from 'utils/setup'; +import { extremelyLongTestTimeout, longTestTimeout } from 'utils/config'; +import { App } from 'src/app'; +import { openPosition } from 'tests/sharedTestSteps/positionManagement'; + +let context: BrowserContext; +let app: App; +let forkId: string; +let walletAddress: string; + +test.describe.configure({ mode: 'serial' }); + +test.describe('Ajna Optimism Earn & Borrow - Wallet connected', async () => { + test.afterAll(async () => { + await tenderly.deleteFork(forkId); + + await app.page.close(); + + await context.close(); + + await resetState(); + }); + + test('It should open an Ajna Optimism Earn position @regression', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + await test.step('Test setup', async () => { + ({ context } = await metamaskSetUp({ network: 'optimism' })); + let page = await context.newPage(); + app = new App(page); + + ({ forkId, walletAddress } = await setup({ + app, + network: 'optimism', + })); + + await tenderly.setTokenBalance({ + forkId, + walletAddress, + network: 'optimism', + token: 'DAI', + balance: '100000', + }); + }); + + await app.page.goto('/optimism/ajna/earn/OP-ETH#setup'); + await app.position.setup.acknowlegeAjnaInfo(); + + await openPosition({ + app, + forkId, + deposit: { token: 'ETH', amount: '10' }, + adjustRisk: { value: 0.8 }, + }); + }); + + test('It should allow to simulate an Ajna Optimism Earn position before opening it', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/optimism/ajna/earn/WBTC-DAI#setup'); + await app.position.setup.acknowlegeAjnaInfo(); + await app.position.setup.deposit({ token: 'DAI', amount: '20000' }); + + await app.position.overview.shouldHaveProjectedEarnings30days({ + token: 'DAI', + amount: '[0-9]{2,3}.[0-9]{2}', + }); + + await app.position.setup.orderInformation.shouldHaveAmountToLend({ + current: '0.00', + future: '20,000.00', + token: 'DAI', + }); + await app.position.setup.orderInformation.shouldHaveLendingPrice({ + current: '0.00', + future: '[0-9]{3}.[0-9]{2}', + tokensPair: 'WBTC/DAI', + }); + await app.position.setup.orderInformation.shouldHaveMaxLTV({ + current: '0.00', + future: '[0-9]{1,2}.[0-9]{2}', + }); + }); + + test('It should allow to simulate Lending Price adjustment (Up) in an Ajna Base Earn position before opening it', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + const initialLendingPrice = await app.position.setup.getLendingPrice(); + const initialMaxLTV = await app.position.setup.getMaxLTV(); + + await app.position.setup.showLendingPriceEditor({ pair: 'WBTC/DAI' }); + await app.position.setup.updateLendingPrice({ + collateralToken: 'DAI', + adjust: 'up', + }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance'); + await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance'); + + const updatedLendingPrice = await app.position.manage.getLendingPrice(); + const updatedMaxLTV = await app.position.manage.getMaxLTV(); + expect(updatedLendingPrice).toBeGreaterThan(initialLendingPrice); + expect(updatedMaxLTV).toBeGreaterThan(initialMaxLTV); + + await app.position.setup.orderInformation.shouldHaveMaxLTV({ + current: '0.00', + future: updatedMaxLTV.toFixed(2), + }); + }); + + test('It should allow to simulate Lending Price adjustment (Down) in an Ajna Base Earn position before opening it', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + const initialLendingPrice = await app.position.setup.getLendingPrice(); + const initialMaxLTV = await app.position.setup.getMaxLTV(); + + await app.position.setup.updateLendingPrice({ + collateralToken: 'DAI', + adjust: 'down', + }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance'); + await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance'); + + const updatedLendingPrice = await app.position.manage.getLendingPrice(); + const updatedMaxLTV = await app.position.manage.getMaxLTV(); + expect(updatedLendingPrice).toBeLessThan(initialLendingPrice); + expect(updatedMaxLTV).toBeLessThan(initialMaxLTV); + + await app.position.setup.orderInformation.shouldHaveMaxLTV({ + current: '0.00', + future: updatedMaxLTV.toFixed(2), + }); + }); +}); diff --git a/utils/tenderly.ts b/utils/tenderly.ts index 70c3892..41b5662 100644 --- a/utils/tenderly.ts +++ b/utils/tenderly.ts @@ -81,6 +81,7 @@ export const tokenAddresses = { }, optimism: { DAI: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1', + OP: '0x4200000000000000000000000000000000000042', RETH: '0x9Bcef72be871e61ED4fBbc7630889beE758eb81D', USDC: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', WBTC: '0x68f180fcCe6836688e9084f035309E29Bf0A2095', @@ -94,6 +95,7 @@ export const tokenBalances = { DAI: '200000', ETH: '1000', GHO: '10000', + OP: '100000', RETH: '1000', SDAI: '200000', TBTC: '10000',