-
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 #340 from OasisDEX/swap-more-to-aave
Swap position - To aave
- Loading branch information
Showing
5 changed files
with
180 additions
and
44 deletions.
There are no files selected for viewing
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
106 changes: 106 additions & 0 deletions
106
tests/withWallet/maker/swap/makerToAave/multEthDaiToMultSdaiEth.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,106 @@ | ||
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; | ||
|
||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test.describe('Maker Multiply - Swap to Aave V3', 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('Test setup - Open Maker Mutiply position and start Swap process', async () => { | ||
test.info().annotations.push({ | ||
type: 'Test case', | ||
description: '11788, 11790', | ||
}); | ||
|
||
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-multiply/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' }, | ||
}); | ||
|
||
await app.page.waitForTimeout(3000); | ||
|
||
await swapPosition({ | ||
app, | ||
forkId, | ||
reason: 'Change direction of my position', | ||
originalProtocol: 'Maker', | ||
targetProtocol: 'Aave V3', | ||
targetPool: { colToken: 'SDAI', debtToken: 'ETH' }, | ||
upToStep5: true, | ||
}); | ||
}); | ||
|
||
( | ||
[ | ||
{ colToken: 'ETH', debtToken: 'DAI' }, | ||
{ colToken: 'SDAI', debtToken: 'ETH' }, | ||
] as const | ||
).forEach((targetPool) => | ||
test(`It should swap a Maker Multiply position (ETH/DAI) to Aave V3 Multiply (${targetPool.colToken}/${targetPool.debtToken})`, 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 swapPosition({ | ||
app, | ||
forkId, | ||
reason: 'Switch to higher max Loan To Value', | ||
originalProtocol: 'Maker', | ||
targetProtocol: 'Aave V3', | ||
targetPool: { colToken: targetPool.colToken, debtToken: targetPool.debtToken }, | ||
existingDpmAndApproval: true, | ||
rejectSwap: true, | ||
}); | ||
}) | ||
); | ||
}); |
File renamed without changes.
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