Skip to content

Commit

Permalink
Merge pull request #351 from OasisDEX/swap-tests-updates-to-any-morpho
Browse files Browse the repository at this point in the history
Swap - test updates - to any - morpho
  • Loading branch information
juan-langa authored Jun 5, 2024
2 parents 8c4d57b + b357336 commit 9404f6b
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 4 deletions.
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 },
},
},
});
});
})
);
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let forkId: string;

test.describe.configure({ mode: 'serial' });

test.describe('Maker Multiply - Swap to Morpho', async () => {
test.describe.skip('Maker Multiply - Swap to Morpho', async () => {
test.afterAll(async () => {
await tenderly.deleteFork(forkId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ let forkId: string;
viewport: { width: 1400, height: 720 },
});

test(`It should swap a Maker Borrow position (ETH/DAI) to Spark Multoply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test(`It should swap a Maker Borrow position (ETH/DAI) to Spark Multiply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let walletAddress: string;
viewport: { width: 1400, height: 720 },
});

test(`It should swap a Maker Borrow position (WBTC/DAI) to Spark Multoply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test(`It should swap a Maker Borrow position (WBTC/DAI) to Spark Multiply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ let walletAddress: string;
viewport: { width: 1400, height: 720 },
});

test(`It should swap a Maker Borrow position (WSTETH/DAI) to Spark Multoply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test(`It should swap a Maker Borrow position (WSTETH/DAI) to Spark Multiply ${targetPool.colToken}/${targetPool.debtToken})`, async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
Expand Down

0 comments on commit 9404f6b

Please sign in to comment.