Skip to content

Commit

Permalink
Add unstake usdc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oskarvu committed Dec 19, 2024
1 parent 1b4222c commit 2ba6a80
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 88 deletions.
Original file line number Diff line number Diff line change
@@ -1,99 +1,101 @@
// import { FarmDetailsPageObject } from '@/features/farm-details/FarmDetails.PageObject'
// import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants'
// import { setupFork } from '@/test/e2e/forking/setupFork'
// import { overrideInfoSkyRouteWithHAR } from '@/test/e2e/info-sky'
// import { setup } from '@/test/e2e/setup'
// import { test } from '@playwright/test'
// import { mainnet } from 'viem/chains'
// import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject'
// import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject'
import { FarmDetailsPageObject } from '@/features/farm-details/FarmDetails.PageObject'
import { DEFAULT_BLOCK_NUMBER } from '@/test/e2e/constants'
import { overrideInfoSkyRouteWithHAR } from '@/test/e2e/info-sky'
import { setup } from '@/test/e2e/setup'
import { test } from '@playwright/test'
import { mainnet } from 'viem/chains'
import { StakeDialogPageObject } from '../../../stake/StakeDialog.PageObject'
import { UnstakeDialogPageObject } from '../../UnstakeDialog.PageObject'

// test.describe('Unstake USDC from SKY farm', () => {
// const fork = setupFork({ blockNumber: DEFAULT_BLOCK_NUMBER, chainId: mainnet.id, useTenderlyVnet: true })
// let farmDetailsPage: FarmDetailsPageObject
// let unstakeDialog: UnstakeDialogPageObject
// let stakeDialog: StakeDialogPageObject
test.describe('Unstake USDC from SKY farm', () => {
let farmDetailsPage: FarmDetailsPageObject
let unstakeDialog: UnstakeDialogPageObject
let stakeDialog: StakeDialogPageObject

// test.beforeEach(async ({ page }) => {
// await setup(page, fork, {
// initialPage: 'farmDetails',
// initialPageParams: {
// chainId: mainnet.id.toString(),
// address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275',
// },
// account: {
// type: 'connected-random',
// assetBalances: {
// ETH: 1,
// USDC: 10_000,
// USDS: 10_000,
// },
// },
// })
// await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' })
test.beforeEach(async ({ page }) => {
const testContext = await setup(page, {
blockchain: {
blockNumber: DEFAULT_BLOCK_NUMBER,
chainId: mainnet.id,
},
initialPage: 'farmDetails',
initialPageParams: {
chainId: mainnet.id.toString(),
address: '0x0650CAF159C5A49f711e8169D4336ECB9b950275',
},
account: {
type: 'connected-random',
assetBalances: {
ETH: 1,
USDC: 10_000,
USDS: 10_000,
},
},
})
await overrideInfoSkyRouteWithHAR({ page, key: '1-sky-farm-with-8_51-apy' })

// farmDetailsPage = new FarmDetailsPageObject(page)
// await farmDetailsPage.clickInfoPanelStakeButtonAction()
// stakeDialog = new StakeDialogPageObject(page)
farmDetailsPage = new FarmDetailsPageObject(testContext)
await farmDetailsPage.clickInfoPanelStakeButtonAction()
stakeDialog = new StakeDialogPageObject(testContext)

// await stakeDialog.selectAssetAction('USDS')
// await stakeDialog.fillAmountAction(10_000)
// await stakeDialog.actionsContainer.acceptAllActionsAction(2)
await stakeDialog.selectAssetAction('USDS')
await stakeDialog.fillAmountAction(10_000)
await stakeDialog.actionsContainer.acceptAllActionsAction(2)

// await stakeDialog.clickBackToFarmAction()
await stakeDialog.clickBackToFarmAction()

// await fork.progressSimulation(page, 24 * 60 * 60) // 24 hours
// await page.reload()
await testContext.testnetController.progressSimulationAndMine(24 * 60 * 60) // 24 hours
await page.reload()

// await farmDetailsPage.clickInfoPanelUnstakeButtonAction()
// unstakeDialog = new UnstakeDialogPageObject(page)
await farmDetailsPage.clickInfoPanelUnstakeButtonAction()
unstakeDialog = new UnstakeDialogPageObject(testContext)

// await unstakeDialog.selectAssetAction('USDC')
// await unstakeDialog.fillAmountAction(5_000)
// })
await unstakeDialog.selectAssetAction('USDC')
await unstakeDialog.fillAmountAction(5_000)
})

// test('has correct action plan', async () => {
// await unstakeDialog.actionsContainer.expectActions([
// { type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false },
// { type: 'approve', asset: 'USDS' },
// { type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' },
// ])
// })
test('has correct action plan', async () => {
await unstakeDialog.actionsContainer.expectActions([
{ type: 'unstake', stakingToken: 'USDS', rewardToken: 'SKY', exit: false },
{ type: 'approve', asset: 'USDS' },
{ type: 'psmConvert', inToken: 'USDS', outToken: 'USDC' },
])
})

// test('displays transaction overview', async () => {
// await unstakeDialog.expectTransactionOverview({
// route: {
// swaps: [
// {
// tokenAmount: '5,000.00 USDS',
// tokenUsdValue: '$5,000.00',
// },
// {
// tokenAmount: '5,000.00 USDC',
// tokenUsdValue: '$5,000.00',
// },
// ],
// farm: {
// upperText: 'SKY Farm',
// lowerText: 'Deposited',
// },
// },
// outcome: '5,000.00 USDC',
// })
// })
test('displays transaction overview', async () => {
await unstakeDialog.expectTransactionOverview({
route: {
swaps: [
{
tokenAmount: '5,000.00 USDS',
tokenUsdValue: '$5,000.00',
},
{
tokenAmount: '5,000.00 USDC',
tokenUsdValue: '$5,000.00',
},
],
farm: {
upperText: 'SKY Farm',
lowerText: 'Deposited',
},
},
outcome: '5,000.00 USDC',
})
})

// test('executes transaction', async () => {
// await unstakeDialog.actionsContainer.acceptAllActionsAction(3)
test('executes transaction', async () => {
await unstakeDialog.actionsContainer.acceptAllActionsAction(3)

// await unstakeDialog.expectSuccessPage()
// await unstakeDialog.clickBackToFarmAction()
await unstakeDialog.expectSuccessPage()
await unstakeDialog.clickBackToFarmAction()

// await farmDetailsPage.expectTokenToDepositBalance('USDC', '15,000.00')
// await farmDetailsPage.expectTokenToDepositBalance('USDS', '-')
// await farmDetailsPage.expectReward({
// reward: '3,539',
// rewardUsd: '$213',
// })
// await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' })
// })
// })
await farmDetailsPage.expectTokenToDepositBalance('USDC', '15,000.00')
await farmDetailsPage.expectTokenToDepositBalance('USDS', '-')
await farmDetailsPage.expectReward({
reward: '49.441',
rewardUsd: '2.98',
})
await farmDetailsPage.expectStaked({ amount: '5,000.00', asset: 'USDS' })
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ test.describe('Withdraw max USDS from SKY farm', () => {
await unstakeDialog.expectExitFarmSwitchReward({
amount: 49.44,
token: 'SKY',
usdValue: '213',
usdValue: '2.98',
})
})

Expand Down Expand Up @@ -139,7 +139,7 @@ test.describe('Withdraw max USDS from SKY farm', () => {
await farmDetailsPage.expectTokenToDepositBalance('USDS', '10,000.00')
await farmDetailsPage.expectReward({
reward: '49.436543',
rewardUsd: '$2.98',
rewardUsd: '2.98',
})
})

Expand Down

0 comments on commit 2ba6a80

Please sign in to comment.