-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
155 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
import { expect } from '@playwright/test'; | ||
|
||
import base from '../../fixture/base'; | ||
import _balance from '../../common/balance'; | ||
import _allowance from '../../common/allowance'; | ||
import _dashboard from '../../page/dashboard'; | ||
import _app from '../../common/app'; | ||
import _rollover from '../../components/rollover'; | ||
import { getFixedPools } from '../../utils/pools'; | ||
import { debtManager } from '../../utils/contracts'; | ||
|
||
const test = base(); | ||
|
||
test.describe.configure({ mode: 'serial' }); | ||
|
||
test('OP rollover', async ({ page, web3, setup }) => { | ||
const pools = getFixedPools(); | ||
if (pools.length < 4) throw new Error('Not enough pools'); | ||
|
||
await web3.fork.setBalance(web3.account.address, { | ||
ETH: 1, | ||
OP: 50_000, | ||
}); | ||
|
||
await page.goto('/dashboard'); | ||
|
||
const app = _app({ test, page }); | ||
const balance = _balance({ test, page, publicClient: web3.publicClient }); | ||
const allowance = _allowance({ test, page, publicClient: web3.publicClient }); | ||
const dashboard = _dashboard(page); | ||
const rollover = _rollover(page); | ||
|
||
const spender = await debtManager(); | ||
|
||
await setup.enterMarket('OP'); | ||
await setup.deposit({ symbol: 'OP', amount: '30000', receiver: web3.account.address }); | ||
await setup.borrow({ symbol: 'OP', amount: '5000', receiver: web3.account.address }); | ||
|
||
await app.reload(); | ||
|
||
await test.step('Roll floating debt to fixed', async () => { | ||
await dashboard.switchTab('borrow'); | ||
await dashboard.checkFloatingTableRow('borrow', 'OP'); | ||
|
||
await expect(rollover.cta('floating', 'USDC')).toBeDisabled(); | ||
await expect(rollover.cta('floating', 'OP')).not.toBeDisabled(); | ||
|
||
await rollover.open('floating', 'OP'); | ||
|
||
await rollover.checkOption('from', { type: 'floating' }); | ||
await rollover.checkOption('to', { type: 'empty' }); | ||
|
||
await rollover.openSheet('to'); | ||
await rollover.selectDebt('OP', pools[0]); | ||
|
||
await rollover.checkOption('to', { type: 'fixed', maturity: pools[0] }); | ||
|
||
await rollover.waitForModalReady(); | ||
|
||
await rollover.submit(); | ||
|
||
await rollover.waitForTransaction(); | ||
await rollover.checkTransactionStatus('success', 'Your position has been refinanced'); | ||
|
||
await rollover.close(); | ||
|
||
await balance.check({ address: web3.account.address, symbol: 'OP', amount: '25000' }); | ||
await allowance.check({ | ||
address: web3.account.address, | ||
type: 'market', | ||
symbol: 'OP', | ||
less: '5', | ||
spender: spender.address, | ||
}); | ||
|
||
await dashboard.checkFixedTableRow('borrow', 'OP', pools[0]); | ||
}); | ||
|
||
await test.step('Roll fixed debt to another fixed', async () => { | ||
await dashboard.switchTab('borrow'); | ||
|
||
await expect(rollover.cta('floating', 'OP')).toBeDisabled(); | ||
await expect(rollover.cta('fixed', 'OP', pools[0])).not.toBeDisabled(); | ||
|
||
await rollover.open('fixed', 'OP', pools[0]); | ||
|
||
await rollover.checkOption('from', { type: 'fixed', maturity: pools[0] }); | ||
await rollover.checkOption('to', { type: 'empty' }); | ||
|
||
await rollover.openSheet('to'); | ||
await rollover.selectDebt('OP', pools[1]); | ||
|
||
await rollover.checkOption('to', { type: 'fixed', maturity: pools[1] }); | ||
|
||
await rollover.waitForModalReady(); | ||
|
||
await rollover.submit(); | ||
|
||
await rollover.waitForTransaction(); | ||
await rollover.checkTransactionStatus('success', 'Your position has been refinanced'); | ||
|
||
await rollover.close(); | ||
|
||
await balance.check({ address: web3.account.address, symbol: 'OP', amount: '25000' }); | ||
await allowance.check({ | ||
address: web3.account.address, | ||
type: 'market', | ||
symbol: 'OP', | ||
less: '5', | ||
spender: spender.address, | ||
}); | ||
|
||
await dashboard.checkFixedTableRow('borrow', 'OP', pools[1]); | ||
}); | ||
|
||
await test.step('Roll fixed debt to floating', async () => { | ||
await dashboard.switchTab('borrow'); | ||
|
||
await expect(rollover.cta('floating', 'USDC')).toBeDisabled(); | ||
await expect(rollover.cta('fixed', 'OP', pools[1])).not.toBeDisabled(); | ||
|
||
await rollover.open('fixed', 'OP', pools[1]); | ||
|
||
await rollover.checkOption('from', { type: 'fixed', maturity: pools[1] }); | ||
await rollover.checkOption('to', { type: 'empty' }); | ||
|
||
await rollover.openSheet('to'); | ||
await rollover.selectDebt('OP'); | ||
|
||
await rollover.checkOption('to', { type: 'floating' }); | ||
|
||
await rollover.waitForModalReady(); | ||
|
||
await rollover.submit(); | ||
|
||
await rollover.waitForTransaction(); | ||
await rollover.checkTransactionStatus('success', 'Your position has been refinanced'); | ||
|
||
await rollover.close(); | ||
|
||
await balance.check({ address: web3.account.address, symbol: 'OP', amount: '25000' }); | ||
await allowance.check({ | ||
address: web3.account.address, | ||
type: 'market', | ||
symbol: 'OP', | ||
less: '5', | ||
spender: spender.address, | ||
}); | ||
|
||
await dashboard.checkFloatingTableRow('borrow', 'OP'); | ||
}); | ||
}); |