diff --git a/tests/withWallet/aaveV3/ethereum/swap/toSpark/multEthWbtcToMultEthDai.spec.ts b/tests/withWallet/aaveV3/ethereum/swap/toSpark/multEthWbtcToMultEthDai.spec.ts new file mode 100644 index 0000000..b5481a8 --- /dev/null +++ b/tests/withWallet/aaveV3/ethereum/swap/toSpark/multEthWbtcToMultEthDai.spec.ts @@ -0,0 +1,92 @@ +import { BrowserContext, test } from '@playwright/test'; +import { resetState } from '@synthetixio/synpress/commands/synpress'; +import { metamaskSetUp } from 'utils/setup'; +import * as tenderly from 'utils/tenderly'; +import { setup } from 'utils/setup'; +import { extremelyLongTestTimeout } from 'utils/config'; +import { App } from 'src/app'; +import { openPosition, swapMakerToSpark } from 'tests/sharedTestSteps/positionManagement'; + +let context: BrowserContext; +let app: App; +let forkId: string; + +test.describe.configure({ mode: 'serial' }); + +test.describe('Aave V3 Multiply - Swap to Spark', async () => { + test.afterAll(async () => { + await tenderly.deleteFork(forkId); + + await app.page.close(); + + await context.close(); + + await resetState(); + }); + + test.use({ + viewport: { width: 1400, height: 720 }, + }); + + // Create an Aave V3 position as part of the Swap tests setup + test('It should open an Aave V3 Multiply position', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + await test.step('Test setup', async () => { + ({ context } = await metamaskSetUp({ network: 'mainnet' })); + let page = await context.newPage(); + app = new App(page); + + ({ forkId } = await setup({ + app, + network: 'mainnet', + extraFeaturesFlags: 'MakerTenderly:true EnableRefinance:true', + })); + }); + + await app.page.goto('/ethereum/aave/v3/multiply/ETH-WBTC#setup'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + + await openPosition({ + app, + forkId, + deposit: { token: 'ETH', amount: '10' }, + }); + }); + + test('It should swap an Aave V3 Multiply position (ETH/WBTC) to Spark Multiply (ETH/DAI)', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + // Wait an reload to avoid flakiness + await app.page.waitForTimeout(1000); + await app.page.reload(); + + await swapMakerToSpark({ + app, + forkId, + reason: 'Switch to higher max Loan To Value', + targetPool: 'ETH/DAI', + expectedTargetExposure: { + amount: '1[0-9].[0-9]{2}', + token: 'ETH', + }, + expectedTargetDebt: { + amount: '[2-8],[0-9]{3}.[0-9]{2}', + token: 'DAI', + }, + originalPosition: { type: 'Multiply', collateralToken: 'ETH', debtToken: 'WBTC' }, + }); + }); +}); diff --git a/tests/withWallet/morphoBlue/swap/toSpark/multWstethUSDCToMultWstethDai.spec.ts b/tests/withWallet/morphoBlue/swap/toSpark/multWstethUSDCToMultWstethDai.spec.ts index fe114ea..cf0498b 100644 --- a/tests/withWallet/morphoBlue/swap/toSpark/multWstethUSDCToMultWstethDai.spec.ts +++ b/tests/withWallet/morphoBlue/swap/toSpark/multWstethUSDCToMultWstethDai.spec.ts @@ -30,7 +30,7 @@ test.describe('Morpho Blue Multiply - Swap to Spark', async () => { }); // Create a Morpho Blue position as part of the Swap tests setup - test('It should open a Morpho Blue Borrow position', async () => { + test('It should open a Morpho Blue Multiply position', async () => { test.info().annotations.push({ type: 'Test case', description: 'xxx', @@ -88,11 +88,11 @@ test.describe('Morpho Blue Multiply - Swap to Spark', async () => { reason: 'Switch to higher max Loan To Value', targetPool: 'WSTETH/DAI', expectedTargetExposure: { - amount: '[0-9]{1,2}.[0-9]{2}', + amount: '1[0-2].[0-9]{2}', token: 'WSTETH', }, expectedTargetDebt: { - amount: '[1][4-5],[0-9]{3}.[0-9]{2}', + amount: '[3-7],[0-9]{3}.[0-9]{2}', token: 'DAI', }, originalPosition: { type: 'Multiply', collateralToken: 'WSTETH', debtToken: 'USDC' }, diff --git a/tests/withWallet/morphoBlue/swap/toSpark/multWstethUsdtToMultWbtcDai.spec.ts b/tests/withWallet/morphoBlue/swap/toSpark/multWstethUsdtToMultWbtcDai.spec.ts new file mode 100644 index 0000000..6fbb5cf --- /dev/null +++ b/tests/withWallet/morphoBlue/swap/toSpark/multWstethUsdtToMultWbtcDai.spec.ts @@ -0,0 +1,101 @@ +import { BrowserContext, test } from '@playwright/test'; +import { resetState } from '@synthetixio/synpress/commands/synpress'; +import { metamaskSetUp } from 'utils/setup'; +import * as tenderly from 'utils/tenderly'; +import { setup } from 'utils/setup'; +import { extremelyLongTestTimeout } from 'utils/config'; +import { App } from 'src/app'; +import { openPosition, swapMakerToSpark } from 'tests/sharedTestSteps/positionManagement'; + +let context: BrowserContext; +let app: App; +let forkId: string; +let walletAddress: string; + +test.describe.configure({ mode: 'serial' }); + +test.describe('Morpho Blue Multiply - Swap to Spark', async () => { + test.afterAll(async () => { + await tenderly.deleteFork(forkId); + + await app.page.close(); + + await context.close(); + + await resetState(); + }); + + test.use({ + viewport: { width: 1400, height: 720 }, + }); + + // Create a Morpho Blue position as part of the Swap tests setup + test('It should open a Morpho Blue Multiply position', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + 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', + extraFeaturesFlags: 'MakerTenderly:true EnableRefinance:true', + })); + + await tenderly.setTokenBalance({ + forkId, + walletAddress, + network: 'mainnet', + token: 'WSTETH', + balance: '100', + }); + }); + + await app.page.goto('/ethereum/morphoblue/multiply/WSTETH-USDT#setup'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + + await openPosition({ + app, + forkId, + deposit: { token: 'WSTETH', amount: '10' }, + }); + }); + + test('It should swap a Morpho Blue Multiply position (WSTETH/USDT) to Spark Multiply (WBTC/DAI)', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + // Wait an reload to avoid flakiness + await app.page.waitForTimeout(1000); + await app.page.reload(); + + await swapMakerToSpark({ + app, + forkId, + reason: 'Switch to higher max Loan To Value', + targetPool: 'WBTC/DAI', + expectedTargetExposure: { + amount: '[0-1].[0-9]{2}', + token: 'WBTC', + }, + expectedTargetDebt: { + amount: '[3-7],[0-9]{3}.[0-9]{2}', + token: 'DAI', + }, + originalPosition: { type: 'Multiply', collateralToken: 'WSTETH', debtToken: 'USDT' }, + }); + }); +}); diff --git a/tests/withWallet/spark/swap/toSpark/multEthDaiToMultWbtcDai.spec.ts b/tests/withWallet/spark/swap/toSpark/multEthDaiToMultWbtcDai.spec.ts index 0b66c77..d24658a 100644 --- a/tests/withWallet/spark/swap/toSpark/multEthDaiToMultWbtcDai.spec.ts +++ b/tests/withWallet/spark/swap/toSpark/multEthDaiToMultWbtcDai.spec.ts @@ -13,7 +13,7 @@ let forkId: string; test.describe.configure({ mode: 'serial' }); -test.describe('Spark Borrow - Swap', async () => { +test.describe('Spark Multiply - Swap to Spark', async () => { test.afterAll(async () => { await tenderly.deleteFork(forkId); @@ -52,7 +52,7 @@ test.describe('Spark Borrow - Swap', async () => { await app.page.goto('/ethereum/spark/multiply/ETH-DAI#setup'); // Depositing collateral too quickly after loading page returns wrong simulation results - await app.position.overview.waitForComponentToBeStable({ positionType: 'Maker' }); + await app.position.overview.waitForComponentToBeStable(); await openPosition({ app, diff --git a/tests/withWallet/spark/swap/toSpark/multSdaiEthToMultEthDai.spec.ts b/tests/withWallet/spark/swap/toSpark/multSdaiEthToMultEthDai.spec.ts new file mode 100644 index 0000000..345d4f4 --- /dev/null +++ b/tests/withWallet/spark/swap/toSpark/multSdaiEthToMultEthDai.spec.ts @@ -0,0 +1,101 @@ +import { BrowserContext, test } from '@playwright/test'; +import { resetState } from '@synthetixio/synpress/commands/synpress'; +import { metamaskSetUp } from 'utils/setup'; +import * as tenderly from 'utils/tenderly'; +import { setup } from 'utils/setup'; +import { extremelyLongTestTimeout } from 'utils/config'; +import { App } from 'src/app'; +import { openPosition, swapMakerToSpark } from 'tests/sharedTestSteps/positionManagement'; + +let context: BrowserContext; +let app: App; +let forkId: string; +let walletAddress: string; + +test.describe.configure({ mode: 'serial' }); + +test.describe('Spark Multiply - Swap to Spark', async () => { + test.afterAll(async () => { + await tenderly.deleteFork(forkId); + + await app.page.close(); + + await context.close(); + + await resetState(); + }); + + test.use({ + viewport: { width: 1400, height: 720 }, + }); + + // Create a Maker position as part of the Swap tests setup + test('It should open a Spark Multiply position', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + 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', + extraFeaturesFlags: 'MakerTenderly:true EnableRefinance:true', + })); + + await tenderly.setTokenBalance({ + forkId, + walletAddress, + network: 'mainnet', + token: 'SDAI', + balance: '50000', + }); + }); + + await app.page.goto('/ethereum/spark/multiply/SDAI-ETH#setup'); + + // Depositing collateral too quickly after loading page returns wrong simulation results + await app.position.overview.waitForComponentToBeStable(); + + await openPosition({ + app, + forkId, + deposit: { token: 'SDAI', amount: '30000' }, + }); + }); + + test('It should swap a Spark Multiply position (SDAI/ETH) to Spark Multiply (ETH/DAI)', async () => { + test.info().annotations.push({ + type: 'Test case', + description: 'xxx', + }); + + test.setTimeout(extremelyLongTestTimeout); + + // Wait an reload to avoid flakiness + await app.page.waitForTimeout(1000); + await app.page.reload(); + + await swapMakerToSpark({ + app, + forkId, + reason: 'Change direction of my position', + targetPool: 'ETH/DAI', + expectedTargetExposure: { + amount: '[0-9]{1,2}.[0-9]{2}', + token: 'ETH', + }, + expectedTargetDebt: { + amount: '[2-6],[0-9]{3}.[0-9]{2}', + token: 'DAI', + }, + originalPosition: { type: 'Multiply', collateralToken: 'SDAI', debtToken: 'ETH' }, + }); + }); +});