Skip to content

Commit

Permalink
One click withdrawals for Andromeda with PM (#158)
Browse files Browse the repository at this point in the history
* PositionManager.withdraw on Andromeda

* One click PM withdrawals for Andromeda
  • Loading branch information
noisekit authored Jan 20, 2025
1 parent 083bc46 commit 3196518
Show file tree
Hide file tree
Showing 18 changed files with 515 additions and 743 deletions.
233 changes: 0 additions & 233 deletions liquidity/components/WithdrawModal/WithdrawModal.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions liquidity/components/WithdrawModal/index.ts

This file was deleted.

27 changes: 0 additions & 27 deletions liquidity/components/WithdrawModal/package.json

This file was deleted.

48 changes: 35 additions & 13 deletions liquidity/cypress/cypress/e2e/8453-andromeda/USDC_Withdraw.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import { makeSearch } from '@snx-v3/useParams';
describe(__filename, () => {
Cypress.env('chainId', '8453');
Cypress.env('preset', 'andromeda');
Cypress.env('walletAddress', '0xc3Cf311e04c1f8C74eCF6a795Ae760dc6312F345');
Cypress.env('accountId', '522433293696');
Cypress.env('walletAddress', '0xaaaa6c341C4Df916d9f0583Ba9Ea953618e5f008');

beforeEach(() => {
cy.task('startAnvil', {
chainId: Cypress.env('chainId'),
forkUrl:
Cypress.env('RPC_BASE_MAINNET') ??
`https://base-mainnet.infura.io/v3/${Cypress.env('INFURA_KEY')}`,
block: '24043002',
block: '25229684',
}).then(() => cy.log('Anvil started'));
cy.pythBypass();
cy.on('window:before:load', (win) => {
Expand All @@ -28,37 +27,60 @@ describe(__filename, () => {
it(__filename, () => {
cy.setEthBalance({ balance: 100 });
cy.getUSDC({ amount: 1000 });
cy.pmSetupPosition({ symbol: 'USDC', amount: 500 });
cy.pmDecreasePosition({ symbol: 'USDC', amount: 100 });
cy.getSystemToken({ amount: 1000 });
cy.depositSystemToken({ amount: 50 });
cy.setWithdrawTimeout({ timeout: '0' });

cy.visit(
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
manageAction: 'withdraw',
accountId: Cypress.env('accountId'),
})}`
);

cy.get('[data-cy="withdraw form"]').should('exist');
cy.get('[data-cy="withdraw amount"]', { timeout: 180_000 })
.should('exist')
.and('include.text', 'Max');
.and('include.text', 'Unlocked: 150 USDC');

cy.get('[data-cy="stats collateral"] [data-cy="change stats current"]')
.should('exist')
.and('include.text', '400 USDC');

cy.get('[data-cy="withdraw amount input"]').should('exist');
cy.get('[data-cy="withdraw amount input"]').type('1');
cy.get('[data-cy="withdraw amount input"]').should('have.value', 150);

cy.get('[data-cy="withdraw submit"]').should('be.enabled');
cy.get('[data-cy="withdraw submit"]').click();

cy.get('[data-cy="withdraw multistep"]')
cy.get('[data-cy="withdraw dialog"]')
.should('exist')
.and('include.text', '1 USDC will be withdrawn');

cy.get('[data-cy="withdraw confirm button"]').should('include.text', 'Execute Transaction');
cy.get('[data-cy="withdraw confirm button"]').click();
.and('include.text', 'Withdrawing USDC')
.and('include.text', 'Withdrawing 150 USDC');

cy.contains('[data-status="success"]', 'Collateral successfully Withdrawn', {
timeout: 120_000,
cy.contains('[data-status="success"]', 'Withdrawal was successful', {
timeout: 180_000,
}).should('exist');
cy.get('[data-cy="transaction hash"]').should('exist');

cy.get('[data-cy="withdraw dialog"]')
.should('exist')
.and('include.text', 'Withdrawing USDC')
.and('include.text', 'Withdrew 150 USDC');

cy.contains('[data-cy="withdraw dialog"] button', 'Done').click();

cy.get('[data-cy="withdraw amount"]')
.should('exist')
.and('include.text', 'Unlocked: 0.00 USDC');

cy.get('[data-cy="stats collateral"] [data-cy="change stats current"]').and(
'include.text',
'400 USDC'
);
cy.get('[data-cy="withdraw submit"]').should('be.disabled');
});
});
Loading

0 comments on commit 3196518

Please sign in to comment.