-
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 #351 from OasisDEX/swap-tests-updates-to-any-morpho
Swap - test updates - to any - morpho
- Loading branch information
Showing
5 changed files
with
158 additions
and
4 deletions.
There are no files selected for viewing
154 changes: 154 additions & 0 deletions
154
tests/withWallet/maker/swap/makerToMorpho/toAny/0_borrEthDaiToany.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,154 @@ | ||
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 { openMakerPosition, swapPosition } from 'tests/sharedTestSteps/positionManagement'; | ||
|
||
let context: BrowserContext; | ||
let app: App; | ||
let forkId: string; | ||
|
||
// ( | ||
// [ | ||
// { colToken: 'EZETH', debtToken: 'ETH' }, | ||
// { colToken: 'OSETH', debtToken: 'ETH' }, | ||
// { colToken: 'SUSDE', debtToken: 'DAI-1' }, | ||
// { colToken: 'SUSDE', debtToken: 'DAI-2' }, | ||
// { colToken: 'SUSDE', debtToken: 'DAI-3' }, | ||
// { colToken: 'SUSDE', debtToken: 'DAI-4' }, | ||
// { colToken: 'SUSDE', debtToken: 'USDT' }, | ||
// { colToken: 'USDE', debtToken: 'DAI-1' }, | ||
// { colToken: 'USDE', debtToken: 'DAI-2' }, | ||
// { colToken: 'USDE', debtToken: 'DAI-3' }, | ||
// { colToken: 'USDE', debtToken: 'DAI-4' }, | ||
// { colToken: 'WBTC', debtToken: 'USDC' }, | ||
// { colToken: 'WBTC', debtToken: 'USDT' }, | ||
// { colToken: 'WEETH', debtToken: 'ETH' }, | ||
// { colToken: 'WSTETH', debtToken: 'ETH-1' }, | ||
// { colToken: 'WSTETH', debtToken: 'ETH-2' }, | ||
// { colToken: 'WSTETH', debtToken: 'ETH-3' }, | ||
// // { colToken: 'WSTETH', debtToken: 'USDA' }, | ||
// { colToken: 'WSTETH', debtToken: 'USDC' }, | ||
// { colToken: 'WSTETH', debtToken: 'USDT' }, | ||
// ] as const | ||
// ) | ||
( | ||
[ | ||
{ | ||
colToken: 'WBTC', | ||
debtToken: 'USDC', | ||
exposure: '0.[0-9]{2}([0-9]{1,2})?', | ||
debt: '[1][4-7],[0-9]{3}.[0-9]{2}', | ||
}, | ||
{ | ||
colToken: 'WBTC', | ||
debtToken: 'USDT', | ||
exposure: '0.[0-9]{2}([0-9]{1,2})?', | ||
debt: '[1][4-7],[0-9]{3}.[0-9]{2}', | ||
}, | ||
{ | ||
colToken: 'WEETH', | ||
debtToken: 'ETH', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[2-9].[0-9]{2}([0-9]{1,2})?', | ||
}, | ||
{ | ||
colToken: 'WSTETH', | ||
debtToken: 'ETH-1', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[2-9].[0-9]{2}([0-9]{1,2})?', | ||
}, | ||
{ | ||
colToken: 'WSTETH', | ||
debtToken: 'ETH-2', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[2-9].[0-9]{2}([0-9]{1,2})?', | ||
}, | ||
{ | ||
colToken: 'WSTETH', | ||
debtToken: 'ETH-3', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[2-9].[0-9]{2}([0-9]{1,2})?', | ||
}, | ||
{ | ||
colToken: 'WSTETH', | ||
debtToken: 'USDC', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[1][4-7],[0-9]{3}.[0-9]{2}', | ||
}, | ||
{ | ||
colToken: 'WSTETH', | ||
debtToken: 'USDT', | ||
exposure: '[0-9]{1,2}.[0-9]{2}', | ||
debt: '[1][4-7],[0-9]{3}.[0-9]{2}', | ||
}, | ||
] as const | ||
).forEach((targetPool) => | ||
test.describe(`Maker Borrow - Swap to Morpho ${targetPool.colToken}/${targetPool.debtToken}`, async () => { | ||
test.afterAll(async () => { | ||
await tenderly.deleteFork(forkId); | ||
|
||
await app.page.close(); | ||
|
||
await context.close(); | ||
|
||
await resetState(); | ||
}); | ||
|
||
test.use({ | ||
viewport: { width: 1400, height: 720 }, | ||
}); | ||
|
||
test(`It should swap a Maker Borrow position (ETH/DAI) to Morpho Multiply ${targetPool.colToken}/${targetPool.debtToken})`, 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('/vaults/open/ETH-C'); | ||
|
||
// Depositing collateral too quickly after loading page returns wrong simulation results | ||
await app.position.overview.waitForComponentToBeStable({ positionType: 'Maker' }); | ||
|
||
await openMakerPosition({ | ||
app, | ||
forkId, | ||
deposit: { token: 'ETH', amount: '10' }, | ||
generate: { token: 'DAI', amount: '15000' }, | ||
}); | ||
|
||
await swapPosition({ | ||
app, | ||
forkId, | ||
reason: 'Switch to lower my cost', | ||
originalProtocol: 'Maker', | ||
targetProtocol: 'Spark', | ||
targetPool: { colToken: targetPool.colToken, debtToken: targetPool.debtToken }, | ||
verifyPositions: { | ||
originalPosition: { type: 'Multiply', collateralToken: 'ETH', debtToken: 'DAI' }, | ||
targetPosition: { | ||
exposure: { amount: targetPool.exposure, token: targetPool.colToken }, | ||
debt: { amount: targetPool.debt, token: targetPool.debtToken }, | ||
}, | ||
}, | ||
}); | ||
}); | ||
}) | ||
); |
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
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
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
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