From 70257312227a1f566bf582b02014f7cfa472293c Mon Sep 17 00:00:00 2001 From: juan-langa Date: Fri, 3 Nov 2023 16:19:46 +0100 Subject: [PATCH] No-wallet - Simultae risk adjustment - Aave --- src/pages/position/base.ts | 2 +- src/pages/position/manage.ts | 10 +- src/pages/position/setup.ts | 36 ++-- tests/noWallet/aaveV2/aaveV2Earn.spec.ts | 54 +++++- tests/noWallet/aaveV2/aaveV2Multiply.spec.ts | 62 ++++++- .../arbitrum/aaveV3MultiplyArbitrum.spec.ts | 163 +++++++---------- .../aaveV3/base/aaveV3MultiplyBase.spec.ts | 172 +++++++----------- .../ethereum/aaveV3EarnEthereum.spec.ts | 119 ++++++------ .../ethereum/aaveV3MultiplyEthereum.spec.ts | 165 +++++++---------- .../optimism/aaveV3MultiplyOptimism.spec.ts | 62 ++++++- 10 files changed, 446 insertions(+), 399 deletions(-) diff --git a/src/pages/position/base.ts b/src/pages/position/base.ts index 19a568a..312b836 100644 --- a/src/pages/position/base.ts +++ b/src/pages/position/base.ts @@ -11,7 +11,7 @@ export class Base { @step async getLiquidationPrice(): Promise { const value = await this.page.locator('span:has-text("Liquidation Price") + span').innerText(); - return parseFloat(value.slice(0, value.indexOf(' '))); + return parseFloat(value.slice(0, value.indexOf(' ')).replace(',', '')); } @step diff --git a/src/pages/position/manage.ts b/src/pages/position/manage.ts index d9d178d..ca63d7a 100644 --- a/src/pages/position/manage.ts +++ b/src/pages/position/manage.ts @@ -59,14 +59,8 @@ export class Manage { * @param value should be between '0' and '1' both included | 0: far left | 1: far right */ @step - async moveSlider({ - protocol, - value, - }: { - protocol: 'Aave V2' | 'Aave V3' | 'Ajna' | 'Maker' | 'Spark'; - value: number; - }) { - if (protocol === 'Ajna') { + async moveSlider({ protocol, value }: { protocol?: 'Ajna'; value: number }) { + if (protocol) { await this.base.moveSlider({ value }); } else { await this.base.moveSlider({ process: 'manage', value }); diff --git a/src/pages/position/setup.ts b/src/pages/position/setup.ts index df83c01..a0f9971 100644 --- a/src/pages/position/setup.ts +++ b/src/pages/position/setup.ts @@ -111,14 +111,8 @@ export class Setup { * @param value should be between '0' and '1' both included | 0: far left | 1: far right */ @step - async moveSlider({ - protocol, - value, - }: { - protocol: 'Aave V2' | 'Aave V3' | 'Ajna' | 'Maker' | 'Spark'; - value: number; - }) { - if (protocol === 'Ajna') { + async moveSlider({ protocol, value }: { protocol?: 'Ajna'; value: number }) { + if (protocol) { await this.base.moveSlider({ value }); } else { await this.base.moveSlider({ process: 'setup', value }); @@ -266,13 +260,27 @@ export class Setup { } @step - async shouldHaveLiquidationPrice({ amount, pair }: { amount: string; pair?: string }) { - const regExp = new RegExp(`${amount}${pair ? ` ${pair}` : ''}`); + async shouldHaveLiquidationPrice({ + amount, + pair, + exactAmount, + }: { + amount: string; + pair?: string; + exactAmount?: boolean; + }) { + if (exactAmount) { + await expect(this.page.locator('span:has-text("Liquidation Price") + span')).toHaveText( + amount + ); + } else { + const regExp = new RegExp(`${amount}${pair ? ` ${pair}` : ''}`); - await expect(this.page.locator('span:has-text("Liquidation Price") + span')).toContainText( - regExp, - { timeout: positionTimeout } // Liquidation price takes longer to be updated - ); + await expect(this.page.locator('span:has-text("Liquidation Price") + span')).toContainText( + regExp, + { timeout: positionTimeout } // Liquidation price takes longer to be updated + ); + } } @step diff --git a/tests/noWallet/aaveV2/aaveV2Earn.spec.ts b/tests/noWallet/aaveV2/aaveV2Earn.spec.ts index be8b41e..8e1d06c 100644 --- a/tests/noWallet/aaveV2/aaveV2Earn.spec.ts +++ b/tests/noWallet/aaveV2/aaveV2Earn.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v2 Earn', async () => { @@ -65,4 +65,56 @@ test.describe('Aave v2 Earn', async () => { }); await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '0' }); }); + + test('It should allow to simulate an Aave V2 Earn position before opening it - Adjust risk - Down and Up - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12601', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/ethereum/aave/v2/earn/stETHeth#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.setup.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'ETH', amount: '19' }); + + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? STETH/ETH', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? STETH/ETH', + }); + + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + expect(updatedLiqPrice).toBeLessThan(initialLiqPrice); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.8 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? STETH/ETH', + }); + + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + expect(updatedLiqPrice2).toBeGreaterThan(updatedLiqPrice); + }); }); diff --git a/tests/noWallet/aaveV2/aaveV2Multiply.spec.ts b/tests/noWallet/aaveV2/aaveV2Multiply.spec.ts index 4967691..c41c074 100644 --- a/tests/noWallet/aaveV2/aaveV2Multiply.spec.ts +++ b/tests/noWallet/aaveV2/aaveV2Multiply.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v2 Multiply', async () => { @@ -72,4 +72,64 @@ test.describe('Aave v2 Multiply', async () => { token: 'USDC', }); }); + + test('It should allow to simulate an Aave V2 Multiply position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12599', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/ethereum/aave/v2/multiply/wBTCusdc#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'WBTC', amount: '1.12345' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9],[0-9]{3}.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9],[0-9]{3}(.[0-9]{1,2})? USDC', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{2},[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeGreaterThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{1,2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeLessThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); }); diff --git a/tests/noWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts b/tests/noWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts index 76a29be..cb24092 100644 --- a/tests/noWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts +++ b/tests/noWallet/aaveV3/arbitrum/aaveV3MultiplyArbitrum.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v3 Multiply Arbitrum', async () => { @@ -18,161 +18,120 @@ test.describe('Aave v3 Multiply Arbitrum', async () => { await app.position.overview.waitForComponentToBeStable(); await app.position.setup.deposit({ token: 'DAI', amount: '6000' }); - /* Asserting that Liquidation Price After pill will be: - - x6 digits whole-number part --> 1xx,xxx.xx - - x2 digits decimal part - --> [4/5/6/7/8/9],xxx.xx - */ await app.position.overview.shouldHaveLiquidationPriceAfterPill('1[0-9]{2},[0-9]{3}.[0-9]{2}'); - /* Asserting that Loan to Value After pill will be a percentage: - - x2 digits whole-number part --> [1/2/3/4]x - - x2 digits decimal part - --> [1/2/3/4]x.xx%% - */ await app.position.overview.shouldHaveLoanToValueAfterPill('[1-4][0-9].[0-9]{2}%'); - /* Asserting that Borrow Cost After pill will be a percentage: - - negative - - x1 digit whole-number part - - x2 digits decimal part - --> x.xx% - */ await app.position.overview.shouldHaveBorrowCostAfterPill('-[0-9]{1,2}.[0-9]{2}'); - /* Asserting that Net Value After pill will be a number: - - x4 digits whole-number part, with a ',' separator for thousands -> [2-8]x,xxx - - x2 digits decimal part - --> [2-88],xxx.xx - */ await app.position.overview.shouldHaveNetValueAfterPill('[2-8],[0-9]{3}.[0-9]{2}'); - /* Asserting that Total Exposure After pill will be a number: - - x4 digit whole-number part -> [1/2/3/4] - - x4 digits decimal part - --> [1/2/3/4].xxxxx - */ await app.position.overview.shouldHaveExposureAfterPill({ amount: '[4-9],[0-9]{3}.[0-9]{4}', token: 'DAI', }); - /* Asserting that Position Debt After pill will be a number: - - x1 digit whole-number part -> 0 - - x4 digits decimal part - --> 0.xxxx - */ await app.position.overview.shouldHaveDebtAfterPill({ amount: '0.[0-9]{4}', token: 'WBTC', }); - /* Asserting that Multiple After pill will be a number: - - x1 digit whole-number part -> 1 - - x1 digit decimal part - --> 1.x - */ await app.position.overview.shouldHaveMultipleAfterPill('1(.[0-9]{1,2})?'); - /* Asserting that Buying Power After pill will be a number: - - x4 digits whole-number part, with a ',' separator for thousands -> [1-7],xxx - - 0, x1 or x2 digits decimal part - --> [1-7]x,xxx.xx - */ await app.position.overview.shouldHaveBuyingPowerAfterPill({ amount: '[1-7],[0-9]{3}(.[0-9]{1,2})?', }); - - /* Asserting that Liquidation price is a number: - - x6 digits whole-number part, with a ',' separator for thousands -> 1xx,xxx - - x1 or x2 digits decimal part - --> [4/5/6/7/8],xxx.xx - */ await app.position.setup.shouldHaveLiquidationPrice({ amount: '1[0-9]{2},[0-9]{3}(.[0-9]{1,2})? DAI', }); - /* Asserting that Liquidation price is a number: - - x2 digits whole-number part - - x1 digit decimal part - --> xx.x - */ await app.position.setup.shouldHaveLoanToValue('[1-4][0-9].[0-9]'); - - /* Asserting that Buying amount in token value is a number: - - x4 digits whole-number part --> 1,xxx - - x4 digits decimal part - --> 1,xxx.xxxx - Asserting that Buying amount in $ is a number: - - x4 digits whole-number part, with a ',' separator for thousands -> 1,xxx - - x2 digits decimal part - --> 1,xxx.xx - */ await app.position.setup.orderInformation.shouldHaveBuyingAmount({ tokenAmount: '1,[0-9]{3}.[0-9]{4}', token: 'DAI', dollarsAmount: '1,[0-9]{3}.[0-9]{2}', }); - /* Asserting that Price impact amount is a number: - - x5 digits whole-number part, with a ',' separator for thousands -> '[1/2/3/4]x,xxx' - - x2 digits decimal part - --> [1/2/3/4]x,xxx.xx - Asserting that Price impact percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHavePriceImpact({ amount: '[1-4][0-9],[0-9]{3}.[0-9]{2}', percentage: '0.[0-9]{2}', }); - /* Asserting that Slipage limit percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}'); - /* Asserting that Multiply future value is a number: - - x1 digit whole-number part --> [1/2] - - none or x1 or x2 digits decimal part - --> [1/2] or [1/2].x or [1/2].xx - */ await app.position.setup.orderInformation.shouldHaveMultiply({ current: '1', future: '[1-2](.[0-9]{1,2})?', }); - /* Asserting that Outstanding Debt future value is a number: - - x1 digit whole-number part -> 0 - - x5 digits decimal part - --> 0.xxxxx - */ await app.position.setup.orderInformation.shouldHaveOutstandingDebt({ token: 'WBTC', current: '0.00', future: '0.[0-9]{5}', }); - /* Asserting that Total collateral future value is a number: - - x4 digits whole-number part, with comma for thousands separator -> [4-9],xxx - - x4 digits decimal part - --> [2/3].xxxx - */ await app.position.setup.orderInformation.shouldHaveTotalCollateral({ token: 'DAI', current: '0.0000', future: '[4-9],[0-9]{3}.[0-9]{4}', }); - /* Asserting that LTV future value is a number: - - x2 digits whole-number part -> [1/2]x - - x2 digits decimal part - --> [1/2]x.xx - */ await app.position.setup.orderInformation.shouldHaveLTV({ current: '0.00', future: '[1-2][0-9].[0-9]{2}', }); - /* Asserting that Transaction is a number: - - x1 digit whole-number part -> [1-5] - - x4 digits decimal part - --> [1-5].xxxx - */ await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '[1-5].[0-9]{4}', token: 'DAI', }); }); + test('It should allow to simulate an Aave V3 Arbitrum Multiply position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12598', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/arbitrum/aave/v3/multiply/usdcwbtc#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'USDC', amount: '20000' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{3},[0-9]{3}.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3},[0-9]{3}(.[0-9]{1,2})? USDC', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{2},[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeLessThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3},[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeGreaterThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); + test('It should open existent Aave V3 Multiply Arbitrum vault page @regression', async ({ app, }) => { diff --git a/tests/noWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts b/tests/noWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts index f8f2956..5b751c9 100644 --- a/tests/noWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts +++ b/tests/noWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v3 Multiply Base', async () => { @@ -18,175 +18,125 @@ test.describe('Aave v3 Multiply Base', async () => { await app.position.overview.waitForComponentToBeStable(); await app.position.setup.deposit({ token: 'CBETH', amount: '19.6543' }); - /* Asserting that Liquidation Price After pill will be: - - x6 digits whole-number part --> 1xx,xxx.xx - - x2 digits decimal part - --> [4/5/6/7/8/9],xxx.xx - */ await app.position.overview.shouldHaveLiquidationPriceAfterPill('[1-9][0-9]{2}.[0-9]{2}'); - /* Asserting that Loan to Value After pill will be a percentage: - - x2 digits whole-number part --> [1/2/3/4]x - - x2 digits decimal part - --> [1/2/3/4]x.xx%% - */ await app.position.overview.shouldHaveLoanToValueAfterPill('[1-5][0-9].[0-9]{2}%'); - /* Asserting that Borrow Cost After pill will be a percentage: - - x1 digit whole-number part - - x2 digits decimal part - --> x.xx% - */ await app.position.overview.shouldHaveBorrowCostAfterPill('[0-9].[0-9]{2}'); - /* Asserting that Net Value After pill will be a number: - - x4 digits whole-number part, with a ',' separator for thousands -> [2-8]x,xxx - - x2 digits decimal part - --> [2-88],xxx.xx - */ await app.position.overview.shouldHaveNetValueAfterPill('[1-7][0-9],[0-9]{3}.[0-9]{2}'); - /* Asserting that Total Exposure After pill will be a number: - - x4 digit whole-number part -> [1/2/3/4] - - x4 digits decimal part - --> [1/2/3/4].xxxxx - */ await app.position.overview.shouldHaveExposureAfterPill({ amount: '[1-5][0-9].[0-9]{5}', token: 'CBETH', }); - /* Asserting that Position Debt After pill will be a number: - - x1 digit whole-number part -> 0 - - x4 digits decimal part - --> 0.xxxx - */ await app.position.overview.shouldHaveDebtAfterPill({ amount: '[0-9]{1,2},[0-9]{3}.[0-9]{4}', token: 'USDBC', }); - /* Asserting that Multiple After pill will be a number: - - x1 digit whole-number part -> 1 - - x1 digit decimal part - --> 1.x - */ await app.position.overview.shouldHaveMultipleAfterPill('1(.[0-9]{1,2})?'); - /* Asserting that Buying Power After pill will be a number: - - x4 digits whole-number part, with a ',' separator for thousands -> [1-7],xxx - - 0, x1 or x2 digits decimal part - --> [1-7]x,xxx.xx - */ await app.position.overview.shouldHaveBuyingPowerAfterPill({ amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})?', }); - - /* Asserting that Liquidation price is a number: - - x6 digits whole-number part, with a ',' separator for thousands -> 1xx,xxx - - x1 or x2 digits decimal part - --> [4/5/6/7/8],xxx.xx - */ await app.position.setup.shouldHaveLiquidationPrice({ amount: '[1-9][0-9]{2}(.[0-9]{1,2})? USDBC', }); - /* Asserting that Liquidation price is a number: - - x2 digits whole-number part - - x1 digit decimal part - --> xx.x - */ await app.position.setup.shouldHaveLoanToValue('[1-4][0-9].[0-9]'); - - /* Asserting that Buying amount in token value is a number: - - x4 digits whole-number part --> 1,xxx - - x4 digits decimal part - --> 1,xxx.xxxx - Asserting that Buying amount in $ is a number: - - x4 digits whole-number part, with a ',' separator for thousands -> 1,xxx - - x2 digits decimal part - --> 1,xxx.xx - */ await app.position.setup.orderInformation.shouldHaveBuyingAmount({ tokenAmount: '[1-9].[0-9]{5}', token: 'CBETH', dollarsAmount: '[0-9]{1,2},[0-9]{3}.[0-9]{2}', }); - /* Asserting that Flashloan Amount is a number: - - x1/x2 digits whole-number part -> 'x' or 'xx' - - x5 digits decimal part - --> x.xxxxx or xx.xxxxx - */ await app.position.setup.orderInformation.shouldHaveFlashloanAmount({ amount: '[0-9]{1,2}.[0-9]{5}', token: 'WETH', }); - /* Asserting that Flashloan Provider Liquidity is a number: - - x2/x3/x4 digits whole-number part -> 'xx' or 'xxx' or 'xxxx' - - x5 digits decimal part - --> xx.xxxxx or xxx.xxxxx or xxxx.xxxxx - */ await app.position.setup.orderInformation.shouldHaveFlashloanProviderLiquidity({ amount: '[0-9]{3,4}.[0-9]{5}', token: 'WETH', }); - /* Asserting that Price impact amount is a number: - - x5 digits whole-number part, with a ',' separator for thousands -> '[1/2/3/4]x,xxx' - - x2 digits decimal part - --> [1/2/3/4]x,xxx.xx - Asserting that Price impact percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHavePriceImpact({ amount: '[1-3],[0-9]{3}.[0-9]{2}', percentage: '0.[0-9]{2}', }); - /* Asserting that Slipage limit percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}'); - /* Asserting that Multiply future value is a number: - - x1 digit whole-number part --> [1/2] - - none or x1 or x2 digits decimal part - --> [1/2] or [1/2].x or [1/2].xx - */ await app.position.setup.orderInformation.shouldHaveMultiply({ current: '1', future: '[1-2](.[0-9]{1,2})?', }); - /* Asserting that Outstanding Debt future value is a number: - - x1 digit whole-number part -> 0 - - x5 digits decimal part - --> 0.xxxxx - */ await app.position.setup.orderInformation.shouldHaveOutstandingDebt({ token: 'USDBC', current: '0.00', future: '[0-9]{1,2},[0-9]{3}.[0-9]{2}', }); - /* Asserting that Total collateral future value is a number: - - x4 digits whole-number part, with comma for thousands separator -> [4-9],xxx - - x4 digits decimal part - --> [2/3].xxxx - */ await app.position.setup.orderInformation.shouldHaveTotalCollateral({ token: 'CBETH', current: '0.00000', future: '[0-9]{2}.[0-9]{5}', }); - /* Asserting that LTV future value is a number: - - x2 digits whole-number part -> [1/2]x - - x2 digits decimal part - --> [1/2]x.xx - */ await app.position.setup.orderInformation.shouldHaveLTV({ current: '0.00', future: '[1-2][0-9].[0-9]{2}', }); - /* Asserting that Transaction is a number: - - x1 digit whole-number part -> [1-5] - - x4 digits decimal part - --> [1-5].xxxx - */ await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '[0-9]{1,2}.[0-9]{2}', token: 'USDBC', }); }); + + test('It should allow to simulate an Aave V3 Base Multiply position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12597', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/base/aave/v3/multiply/ethusdbc#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'ETH', amount: '20' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{3}.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3}(.[0-9]{1,2})? USDBC', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '([0-9],)?[0-9]{3}(.[0-9]{1,2})? USDBC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('([0-9],)?[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeGreaterThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3}(.[0-9]{1,2})? USDBC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeLessThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); }); diff --git a/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts b/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts index 851d946..943284c 100644 --- a/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts +++ b/tests/noWallet/aaveV3/ethereum/aaveV3EarnEthereum.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v3 Earn Ethereum', async () => { @@ -23,93 +23,38 @@ test.describe('Aave v3 Earn Ethereum', async () => { token: 'ETH', amount: '50.[0-9]{2}', }); - - /* Asserting that Current price is a number: - - x1 digit whole-number part - - x4 digits decimal part - --> x.xxxx - */ await app.position.setup.shouldHaveCurrentPrice({ amount: '[1-9].[0-9]{2,4}', pair: 'WSTETH/ETH', }); - /* Asserting that Liquidation price is a number: - - x1 digit whole-number part - - x4 digits decimal part - --> x.xxxx - */ await app.position.setup.shouldHaveLiquidationPrice({ amount: '[1-9].[0-9]{3,4}', pair: 'WSTETH/ETH', }); - - /* Asserting that Buying amount in token value is a number: - - x3 digits whole-number part - - x5 digits decimal part - --> xxx.xxxxx - Asserting that Buying amount in $ is a number: - - x6 digit whole-number part - - x2 digits decimal part - --> xxx,xxx.xx - */ await app.position.setup.orderInformation.shouldHaveBuyingAmount({ tokenAmount: '[1-9][0-9]{2}.[0-9]{5}', token: 'WSTETH', dollarsAmount: '[1-9][0-9]{2},[0-9]{3}.[0-9]{2}', }); - /* Asserting that Price impact amount is a number: - - x1 digit whole-number part -> '1' - - x4 digits decimal part - --> 1.xxxx - Asserting that Price impact percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHavePriceImpact({ amount: '1.[0-9]{4}', percentage: '0.[0-9]{2}', }); - /* Asserting that Slipage limit percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}'); - /* Asserting that Multiply future value is a number: - - x1 digit whole-number part - - none or x1 digit decimal part - --> x or x.x - */ await app.position.setup.orderInformation.shouldHaveMultiply({ current: '1', future: '[1-9](.[0-9]{1,2})?', }); - /* Asserting that Outstanding Debt future value is a number: - - x3 digits whole-number part - - x5 digits decimal part - --> xxx.xxxxx - */ await app.position.setup.orderInformation.shouldHaveOutstandingDebt({ token: 'ETH', current: '0.00000', future: '[1-9][0-9]{2}.[0-9]{5}', }); - /* Asserting that Total collateral future value is a number: - - x3 digits whole-number part - - x5 digits decimal part - --> xxx.xxxxx - */ await app.position.setup.orderInformation.shouldHaveTotalCollateral({ token: 'WSTETH', current: '0.00000', future: '[1-9][0-9]{2}.[0-9]{5}', }); - /* Asserting that LTV future value is a number: - - x2 digit2 whole-number part - - x2 digits decimal part - --> xx.xx - */ await app.position.setup.orderInformation.shouldHaveLTV({ current: '0.00', future: '[1-9][0-9].[0-9]{2}', @@ -117,6 +62,66 @@ test.describe('Aave v3 Earn Ethereum', async () => { await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '0' }); }); + test('It should allow to simulate an Aave V3 Ethereum Earn position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12600', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/ethereum/aave/v3/earn/sdaiusdc#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'SDAI', amount: '15000' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('0.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? USDC', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('0.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeGreaterThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '0.[0-9]([0-9]{2,3})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('0.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeLessThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); + test('It should validate "Deposit " field - No enough collateral in wallet', async ({ app, }) => { @@ -147,7 +152,7 @@ test.describe('Aave v3 Earn Ethereum', async () => { await app.position.setup.deposit({ token: 'ETH', amount: '5' }); // It takes some time for the slider to be editable await app.position.setup.waitForSliderToBeEditable(); - await app.position.setup.moveSlider({ protocol: 'Aave V3', value: 0.5 }); + await app.position.setup.moveSlider({ value: 0.5 }); await app.position.setup.shouldHaveWarning( 'At the chosen risk level, the price of WSTETH needs to move over ', '% with respect to ETH for this position to be available for liquidation.', diff --git a/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts b/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts index 9e0c900..8f39dff 100644 --- a/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts +++ b/tests/noWallet/aaveV3/ethereum/aaveV3MultiplyEthereum.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v3 Multiply Ethereum', async () => { @@ -18,161 +18,120 @@ test.describe('Aave v3 Multiply Ethereum', async () => { await app.position.overview.waitForComponentToBeStable(); await app.position.setup.deposit({ token: 'WBTC', amount: '2.5' }); - /* Asserting that Liquidation Price After pill will be: - - x4 digits whole-number part --> [4/5/6/7/8/9],xxx.xx - - x2 digits decimal part - --> [4/5/6/7/8/9],xxx.xx - */ await app.position.overview.shouldHaveLiquidationPriceAfterPill('[4-9],[0-9]{3}.[0-9]{2}'); - /* Asserting that Loan to Value After pill will be a percentage: - - x2 digits whole-number part --> [1/2/3/4]x - - x2 digits decimal part - --> [1/2/3/4]x.xx%% - */ await app.position.overview.shouldHaveLoanToValueAfterPill('[1-4][0-9].[0-9]{2}%'); - /* Asserting that Borrow Cost After pill will be a percentage: - - positive - - x1 digit whole-number part - - x2 digits decimal part - --> x.xx% - */ await app.position.overview.shouldHaveBorrowCostAfterPill('[0-9].[0-9]{2}'); - /* Asserting that Net Value After pill will be a number: - - x5 digits whole-number part, with a ',' separator for thousands -> [4/5/67/8]x,xxx - - x2 digits decimal part - --> [4/5/6/7/8]x,xxx.xx - */ await app.position.overview.shouldHaveNetValueAfterPill('[4-8][0-9],[0-9]{3}.[0-9]{2}'); - /* Asserting that Total Exposure After pill will be a number: - - x1 digit whole-number part -> [1/2/3/4] - - x5 digits decimal part - --> [1/2/3/4].xxxxx - */ await app.position.overview.shouldHaveExposureAfterPill({ amount: '[1-4].[0-9]{5}', token: 'WBTC', }); - /* Asserting that Position Debt After pill will be a number: - - x5 digits whole-number part, with a ',' separator for thousands -> [1/2/3/4]x,xxx - - x4 digits decimal part - --> [1/2/3/4]x,xxx.xxxx - */ await app.position.overview.shouldHaveDebtAfterPill({ amount: '[1-4][0-9],[0-9]{3}.[0-9]{4}', token: 'USDC', }); - /* Asserting that Multiple After pill will be a number: - - x1 digit whole-number part -> 1 - - x1 digit decimal part - --> 1.x - */ await app.position.overview.shouldHaveMultipleAfterPill('1(.[0-9]{1,2})?'); - /* Asserting that Buying Power After pill will be a number: - - x5 digits whole-number part, with a ',' separator for thousands -> [2/3/4/5/6]x,xxx - - 0, x1 or x2 digits decimal part - --> [2/3/4/5/6]x,xxx.xx - */ await app.position.overview.shouldHaveBuyingPowerAfterPill({ amount: '[2-6][0-9],[0-9]{3}(.[0-9]{1,2})?', }); - - /* Asserting that Liquidation price is a number: - - x4 digits whole-number part, with a ',' separator for thousands -> [4/5/6/7/8],xxx - - x1 or x2 digits decimal part - --> [4/5/6/7/8],xxx.xx - */ await app.position.setup.shouldHaveLiquidationPrice({ amount: '[0-9]{1,2},[0-9]{3}(.[0-9]{1,2})? USDC', }); - /* Asserting that Liquidation price is a number: - - x2 digits whole-number part - - x1 digit decimal part - --> xx.x - */ await app.position.setup.shouldHaveLoanToValue('[1-4][0-9].[0-9]'); - - /* Asserting that Buying amount in token value is a number: - - x1 digit whole-number part --> [0/1] - - x5 digits decimal part - --> [0/1].xxxxx - Asserting that Buying amount in $ is a number: - - x5 digits whole-number part, with a ',' separator for thousands -> [1/2/3] - - x2 digits decimal part - --> [1/2/3]x,xxx.xx - */ await app.position.setup.orderInformation.shouldHaveBuyingAmount({ tokenAmount: '[0-1].[0-9]{5}', token: 'WBTC', dollarsAmount: '[1-3][0-9],[0-9]{3}.[0-9]{2}', }); - /* Asserting that Price impact amount is a number: - - x5 digits whole-number part, with a ',' separator for thousands -> '[1/2/3/4]x,xxx' - - x2 digits decimal part - --> [1/2/3/4]x,xxx.xx - Asserting that Price impact percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHavePriceImpact({ amount: '[1-4][0-9],[0-9]{3}.[0-9]{2}', percentage: '[0-9].[0-9]{2}', }); - /* Asserting that Slipage limit percentage is a number: - - x1 digit whole-number part -> '0' - - x2 digits decimal part - --> 0.xx - */ await app.position.setup.orderInformation.shouldHaveSlippageLimit('0.[0-9]{2}'); - /* Asserting that Multiply future value is a number: - - x1 digit whole-number part --> [1/2] - - none or x1 or x2 digits decimal part - --> [1/2] or [1/2].x or [1/2].xx - */ await app.position.setup.orderInformation.shouldHaveMultiply({ current: '1', future: '[1-2](.[0-9]{1,2})?', }); - /* Asserting that Outstanding Debt future value is a number: - - x5 digits whole-number part, with a ',' separator for thousands -> '[1/2/3]x,xxx' - - x2 digits decimal part - --> [1/2/3]x,xxx.xx - */ await app.position.setup.orderInformation.shouldHaveOutstandingDebt({ token: 'USDC', current: '0.00', future: '[1-3][0-9],[0-9]{3}.[0-9]{2}', }); - /* Asserting that Total collateral future value is a number: - - x1 digit1 whole-number part -> [2/3] - - x5 digits decimal part - --> [2/3].xxxxx - */ await app.position.setup.orderInformation.shouldHaveTotalCollateral({ token: 'WBTC', current: '0.00000', future: '[2-3].[0-9]{5}', }); - /* Asserting that LTV future value is a number: - - x2 digit2 whole-number part -> [1/2]x - - x2 digits decimal part - --> [1/2]x.xx - */ await app.position.setup.orderInformation.shouldHaveLTV({ current: '0.00', future: '[1-2][0-9].[0-9]{2}', }); - /* Asserting that Transaction Fee is a number: - - x2 digits whole-number part -> [2/3/4]x - - x2 digits decimal part - --> [2/3/4]x.xx - */ await app.position.setup.orderInformation.shouldHaveTransactionFee({ fee: '[2-4][0-9].[0-9]{2}', token: 'USDC', }); }); + test('It should allow to simulate an Aave V3 Ethereum Multiply position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12595', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/ethereum/aave/v3/multiply/daiwbtc#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'DAI', amount: '20000' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{3},[0-9]{3}.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3},[0-9]{3}(.[0-9]{1,2})? DAI', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{2},[0-9]{3}(.[0-9]{1,2})? DAI', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeLessThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9]{3},[0-9]{3}(.[0-9]{1,2})? DAI', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9]{2},[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeGreaterThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); + test('It should validate "Deposit " field - No enough collateral in wallet @regression', async ({ app, }) => { @@ -224,7 +183,7 @@ test.describe('Aave v3 Multiply Ethereum', async () => { await app.position.setup.deposit({ token: 'ETH', amount: '5' }); // It takes some time for the slider to be editable await app.position.setup.waitForSliderToBeEditable(); - await app.position.setup.moveSlider({ protocol: 'Aave V3', value: 0.9 }); + await app.position.setup.moveSlider({ value: 0.9 }); await app.position.setup.shouldHaveWarning( 'At the chosen risk level, if the price of ETH moves over ', '% with respect to DAI this Multiply position could be liquidated. ', diff --git a/tests/noWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts b/tests/noWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts index 5f79889..babb36e 100644 --- a/tests/noWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts +++ b/tests/noWallet/aaveV3/optimism/aaveV3MultiplyOptimism.spec.ts @@ -1,4 +1,4 @@ -import { test } from '#noWalletFixtures'; +import { expect, test } from '#noWalletFixtures'; import { longTestTimeout } from 'utils/config'; test.describe('Aave v3 Multiply Optimism', async () => { @@ -79,4 +79,64 @@ test.describe('Aave v3 Multiply Optimism', async () => { token: 'DAI', }); }); + + test('It should allow to simulate an Aave V3 Optimism Multiply position before opening it - Adjust risk - Up and Down - No wallet connected @regression', async ({ + app, + }) => { + test.info().annotations.push({ + type: 'Test case', + description: '12596', + }); + + test.setTimeout(longTestTimeout); + + await app.page.goto('/optimism/aave/v3/multiply/usdceth#simulate'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + await app.position.setup.deposit({ token: 'USDC', amount: '15000' }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9],[0-9]{3}.[0-9]{2}'); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9],[0-9]{3}(.[0-9]{1,2})? USDC', + }); + const initialLiqPrice = await app.position.manage.getLiquidationPrice(); + const initialLoanToValue = await app.position.manage.getLoanToValue(); + + // RISK UP + await app.position.setup.moveSlider({ value: 0.5 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9],[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9],[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice).toBeLessThan(initialLiqPrice); + expect(updatedLoanToValue).toBeGreaterThan(initialLoanToValue); + + // RISK DOWN + await app.position.setup.moveSlider({ value: 0.1 }); + + // Wait for simulation to update with new risk + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '...', + exactAmount: true, + }); + await app.position.setup.shouldHaveLiquidationPrice({ + amount: '[0-9],[0-9]{3}(.[0-9]{1,2})? USDC', + }); + + await app.position.overview.shouldHaveLiquidationPriceAfterPill('[0-9],[0-9]{3}.[0-9]{2}'); + const updatedLiqPrice2 = await app.position.manage.getLiquidationPrice(); + const updatedLoanToValue2 = await app.position.manage.getLoanToValue(); + expect(updatedLiqPrice2).toBeGreaterThan(updatedLiqPrice); + expect(updatedLoanToValue2).toBeLessThan(updatedLoanToValue); + }); });