-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #324 from OasisDEX/refinance-more-tests
Refinance - Aave V3, Morpho and Spark test
- Loading branch information
Showing
5 changed files
with
299 additions
and
5 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
tests/withWallet/aaveV3/ethereum/swap/toSpark/multEthWbtcToMultEthDai.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
tests/withWallet/morphoBlue/swap/toSpark/multWstethUsdtToMultWbtcDai.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }, | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
tests/withWallet/spark/swap/toSpark/multSdaiEthToMultEthDai.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' }, | ||
}); | ||
}); | ||
}); |