Skip to content

Commit

Permalink
StopLoss updates
Browse files Browse the repository at this point in the history
  • Loading branch information
juan-langa committed Feb 21, 2024
1 parent bd05791 commit 0065007
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ test.describe('Aave v3 Multiply - Arbitrum - Wallet connected', async () => {
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();

await app.position.setup.setupStopLoss1Of3();
await app.position.setup.continueWithoutStopLoss();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
Expand Down
131 changes: 66 additions & 65 deletions tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {
await resetState();
});

test('It should adjust risk of an existent Aave V3 Multiply Base position - Down @regression', async () => {
test('It should open an Aave v3 Multiply Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12465',
description: '12463',
});

test.setTimeout(extremelyLongTestTimeout);
Expand All @@ -39,8 +39,72 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {
app = new App(page);

({ forkId, walletAddress } = await setup({ app, network: 'base' }));

await tenderly.setTokenBalance({
forkId,
walletAddress,
network: 'base',
token: 'CBETH',
balance: '50',
});
});

await app.page.goto('/base/aave/v3/multiply/cbethusdbc');

// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'CBETH', amount: '14.12345' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
await app.position.setup.approveAllowance();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

// Logging position ID for debugging purposes
const positionId = await app.position.setup.getNewPositionId();
console.log('+++ Position ID: ', positionId);

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
});

test('It should adjust risk of an existent Aave V3 Multiply Base position - Down @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12465',
});

test.setTimeout(longTestTimeout);

await tenderly.changeAccountOwner({
account: '0xf5922d700883214f689efe190a978ac51c50e6b1',
newOwner: walletAddress,
Expand Down Expand Up @@ -160,69 +224,6 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {
await app.position.overview.shouldHaveMultiple('1.00');
});

test('It should open an Aave v3 Multiply Base position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '12463',
});

test.setTimeout(extremelyLongTestTimeout);
await tenderly.setTokenBalance({
forkId,
walletAddress,
network: 'base',
token: 'CBETH',
balance: '50',
});

await app.page.goto('/base/aave/v3/multiply/cbethusdbc');

// Depositing collateral too quickly after loading page returns wrong simulation results
await app.position.overview.waitForComponentToBeStable();
await app.position.setup.deposit({ token: 'CBETH', amount: '14.12345' });
await app.position.setup.createSmartDeFiAccount();

// Smart DeFi Acount creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.createSmartDeFiAccount();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();

// Setting up allowance randomly fails - Retry until it's set.
await expect(async () => {
await app.position.setup.setupAllowance();
await app.position.setup.approveAllowance();
await test.step('Metamask: ConfirmAddToken', async () => {
await metamask.confirmAddToken();
});
await app.position.setup.continueShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();

// Position creation randomly fails - Retry until it's created.
await expect(async () => {
await app.position.setup.confirmOrRetry();
await test.step('Metamask: ConfirmPermissionToSpend', async () => {
await metamask.confirmPermissionToSpend();
});
await app.position.setup.goToPositionShouldBeVisible();
}).toPass({ timeout: longTestTimeout });

// Logging position ID for debugging purposes
const positionId = await app.position.setup.getNewPositionId();
console.log('+++ Position ID: ', positionId);

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage ');
});

test.skip('It should list an opened Aave v3 Multiply Base position in portfolio', async () => {
test.info().annotations.push({
type: 'Test case',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
}).toPass({ timeout: longTestTimeout });

await app.position.setup.continue();
await app.position.setup.openMultiplyPosition1Of2();

await app.position.setup.setupStopLoss1Of3();
await app.position.setup.continueWithoutStopLoss();

// Confirm action randomly fails - Retry until it's applied.
await expect(async () => {
Expand All @@ -79,7 +81,7 @@ test.describe('Aave v3 Multiply - Optimism - Wallet connected', async () => {
console.log('+++ Position ID: ', positionId);

await app.position.setup.goToPosition();
await app.position.manage.shouldBeVisible('Manage Multiply position');
await app.position.manage.shouldBeVisible('Manage ');
});

test('It should adjust risk of an existent Aave V3 Multiply Optimism position - Up @regression', async () => {
Expand Down
4 changes: 2 additions & 2 deletions tests/withWallet/morphoBlue/morphoBlueBorrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ test.describe('Morpho Blue Borrow - Wallet connected', async () => {
// ============================================================

await app.position.overview.shouldHaveNetValue({
value: '[3-4][0-9],[0-9]{3}.[0-9]{2}',
value: '[0-9]{2,3},[0-9]{3}.[0-9]{2}',
});
await app.position.overview.shouldHaveCollateralDeposited({ amount: '20.00', token: 'WSTETH' });
await app.position.overview.shouldHaveDebt({
Expand Down Expand Up @@ -248,7 +248,7 @@ test.describe('Morpho Blue Borrow - Wallet connected', async () => {
// ============================================================

await app.position.overview.shouldHaveNetValue({
value: '[2-3][0-9],[0-9]{3}.[0-9]{2}',
value: '[0-9]{2,3},[0-9]{3}.[0-9]{2}',
});
await app.position.overview.shouldHaveCollateralDeposited({ amount: '15.00', token: 'WSTETH' });
await app.position.overview.shouldHaveDebt({
Expand Down

0 comments on commit 0065007

Please sign in to comment.