Skip to content

Commit

Permalink
Merge pull request #200 from OasisDEX/ajana-opt-earn
Browse files Browse the repository at this point in the history
Ajana opt earn
  • Loading branch information
juan-langa authored Mar 1, 2024
2 parents db61ecf + 3c49ddb commit 6cf8b2d
Show file tree
Hide file tree
Showing 7 changed files with 173 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ jobs:
retention-days: 30

with-wallet-ajna-tests:
name: 'With wallet - Ajna & Morpho Blue'
name: 'With wallet - Ajna'
runs-on: ubuntu-latest
env:
TENDERLY_PROJECT: ${{ secrets.TENDERLY_PROJECT }}
Expand All @@ -161,7 +161,7 @@ jobs:
run: npx playwright install && npx playwright install-deps
- name: Install xvfb
run: apt-get update -y && apt-get -y install xvfb && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
- name: Run With wallet Ajna & Morpho Blue tests
- name: Run With wallet Ajna
run: |
TENDERLY_PROJECT=${{ secrets.TENDERLY_PROJECT }} \
TENDERLY_USER=${{ secrets.TENDERLY_USER }} \
Expand Down
15 changes: 5 additions & 10 deletions tests/withWallet/aaveV3/base/aaveV3MultiplyBase.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let context: BrowserContext;
let app: App;
let forkId: string;
let walletAddress: string;
let positionId: string;

test.describe.configure({ mode: 'serial' });

Expand Down Expand Up @@ -90,7 +91,7 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {
}).toPass({ timeout: longTestTimeout });

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

await app.position.setup.goToPosition();
Expand All @@ -105,13 +106,7 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {

test.setTimeout(longTestTimeout);

await tenderly.changeAccountOwner({
account: '0xf5922d700883214f689efe190a978ac51c50e6b1',
newOwner: walletAddress,
forkId,
});

await app.page.goto('/base/aave/v3/17#overview');
await app.page.goto(positionId);

await app.position.manage.shouldBeVisible('Manage Multiply position');
const initialLiqPrice = await app.position.manage.getLiquidationPrice();
Expand Down Expand Up @@ -213,13 +208,13 @@ test.describe('Aave v3 Multiply - Base - Wallet connected', async () => {

await app.position.overview.shouldHaveLiquidationPrice({
price: '0.00',
token: 'ETH/USDBC',
token: 'CBETH/USDBC',
timeout: positionTimeout,
});
await app.position.overview.shouldHaveLoanToValue('0.00');
await app.position.overview.shouldHaveNetValue({ value: '\\$0.00' });
await app.position.overview.shouldHaveBuyingPower('\\$0.00');
await app.position.overview.shouldHaveExposure({ amount: '0.00', token: 'ETH' });
await app.position.overview.shouldHaveExposure({ amount: '0.00', token: 'CBETH' });
await app.position.overview.shouldHaveDebt({ amount: '0.00', token: 'USDBC' });
await app.position.overview.shouldHaveMultiple('1.00');
});
Expand Down
10 changes: 5 additions & 5 deletions tests/withWallet/ajna/arbitrum/ajnaArbitrumBorrow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => {
});
});

test('It should Deposit and Borrow in a single tx form an existing Ajna Base Borrow position @regression', async () => {
test('It should Deposit and Borrow in a single tx form an existing Ajna Arbitrum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxxx',
Expand All @@ -89,7 +89,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => {
});
});

test('It should Withdraw and Pay back in a single tx form an existing Ajna Base Borrow position @regression', async () => {
test('It should Withdraw and Pay back in a single tx form an existing Ajna Arbitrum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxxx',
Expand All @@ -112,7 +112,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => {
});
});

test('It should Borrow and Deposit in a single tx on an existing Ajna Base Borrow position @regression', async () => {
test('It should Borrow and Deposit in a single tx on an existing Ajna Arbitrum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxx',
Expand All @@ -136,7 +136,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => {
});
});

test('It should Pay back and Withdraw in a single tx on an existing Ajna Base Borrow position @regression', async () => {
test('It should Pay back and Withdraw in a single tx on an existing Ajna Arbitrum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxx',
Expand All @@ -163,7 +163,7 @@ test.describe('Ajna Arbitrum Borrow - Wallet connected', async () => {
});

// !! tx failing with very low liquidity - To re-test when liquidity rises
test.skip('It should Close to collateral an existing Ajna Base Borrow position @regression', async () => {
test.skip('It should Close to collateral an existing Ajna Arbitrum Borrow position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxxx',
Expand Down
10 changes: 1 addition & 9 deletions tests/withWallet/ajna/arbitrum/ajnaArbitrumEarn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let walletAddress: string;

test.describe.configure({ mode: 'serial' });

test.describe('Ajna Arbitrum Earn & Borrow - Wallet connected', async () => {
test.describe('Ajna Arbitrum Earn - Wallet connected', async () => {
test.afterAll(async () => {
await tenderly.deleteFork(forkId);

Expand Down Expand Up @@ -43,14 +43,6 @@ test.describe('Ajna Arbitrum Earn & Borrow - Wallet connected', async () => {
network: 'arbitrum',
}));

await tenderly.setTokenBalance({
forkId,
walletAddress,
network: 'arbitrum',
token: 'USDC',
balance: '50000',
});

await tenderly.setTokenBalance({
forkId,
walletAddress,
Expand Down
157 changes: 157 additions & 0 deletions tests/withWallet/ajna/optimism/ajnaOptimismEarn.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
import { BrowserContext, test } from '@playwright/test';
import { expect, metamaskSetUp } from 'utils/setup';
import { resetState } from '@synthetixio/synpress/commands/synpress';
import * as tenderly from 'utils/tenderly';
import { setup } from 'utils/setup';
import { extremelyLongTestTimeout, longTestTimeout } from 'utils/config';
import { App } from 'src/app';
import { openPosition } from 'tests/sharedTestSteps/positionManagement';

let context: BrowserContext;
let app: App;
let forkId: string;
let walletAddress: string;

test.describe.configure({ mode: 'serial' });

test.describe('Ajna Optimism Earn & Borrow - Wallet connected', async () => {
test.afterAll(async () => {
await tenderly.deleteFork(forkId);

await app.page.close();

await context.close();

await resetState();
});

test('It should open an Ajna Optimism Earn position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
});

test.setTimeout(extremelyLongTestTimeout);

await test.step('Test setup', async () => {
({ context } = await metamaskSetUp({ network: 'optimism' }));
let page = await context.newPage();
app = new App(page);

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

await tenderly.setTokenBalance({
forkId,
walletAddress,
network: 'optimism',
token: 'DAI',
balance: '100000',
});
});

await app.page.goto('/optimism/ajna/earn/OP-ETH#setup');
await app.position.setup.acknowlegeAjnaInfo();

await openPosition({
app,
forkId,
deposit: { token: 'ETH', amount: '10' },
adjustRisk: { value: 0.8 },
});
});

test('It should allow to simulate an Ajna Optimism Earn position before opening it', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
});

test.setTimeout(longTestTimeout);

await app.page.goto('/optimism/ajna/earn/WBTC-DAI#setup');
await app.position.setup.acknowlegeAjnaInfo();
await app.position.setup.deposit({ token: 'DAI', amount: '20000' });

await app.position.overview.shouldHaveProjectedEarnings30days({
token: 'DAI',
amount: '[0-9]{2,3}.[0-9]{2}',
});

await app.position.setup.orderInformation.shouldHaveAmountToLend({
current: '0.00',
future: '20,000.00',
token: 'DAI',
});
await app.position.setup.orderInformation.shouldHaveLendingPrice({
current: '0.00',
future: '[0-9]{3}.[0-9]{2}',
tokensPair: 'WBTC/DAI',
});
await app.position.setup.orderInformation.shouldHaveMaxLTV({
current: '0.00',
future: '[0-9]{1,2}.[0-9]{2}',
});
});

test('It should allow to simulate Lending Price adjustment (Up) in an Ajna Base Earn position before opening it', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
});

const initialLendingPrice = await app.position.setup.getLendingPrice();
const initialMaxLTV = await app.position.setup.getMaxLTV();

await app.position.setup.showLendingPriceEditor({ pair: 'WBTC/DAI' });
await app.position.setup.updateLendingPrice({
collateralToken: 'DAI',
adjust: 'up',
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance');
await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
expect(updatedLendingPrice).toBeGreaterThan(initialLendingPrice);
expect(updatedMaxLTV).toBeGreaterThan(initialMaxLTV);

await app.position.setup.orderInformation.shouldHaveMaxLTV({
current: '0.00',
future: updatedMaxLTV.toFixed(2),
});
});

test('It should allow to simulate Lending Price adjustment (Down) in an Ajna Base Earn position before opening it', async () => {
test.info().annotations.push({
type: 'Test case',
description: 'xxx',
});

const initialLendingPrice = await app.position.setup.getLendingPrice();
const initialMaxLTV = await app.position.setup.getMaxLTV();

await app.position.setup.updateLendingPrice({
collateralToken: 'DAI',
adjust: 'down',
});

// Wait for simulation to update with new risk
await app.position.setup.shouldHaveButtonDisabled('Set DAI allowance');
await app.position.setup.shouldHaveButtonEnabled('Set DAI allowance');

const updatedLendingPrice = await app.position.manage.getLendingPrice();
const updatedMaxLTV = await app.position.manage.getMaxLTV();
expect(updatedLendingPrice).toBeLessThan(initialLendingPrice);
expect(updatedMaxLTV).toBeLessThan(initialMaxLTV);

await app.position.setup.orderInformation.shouldHaveMaxLTV({
current: '0.00',
future: updatedMaxLTV.toFixed(2),
});
});
});
2 changes: 1 addition & 1 deletion tests/withWallet/spark/sparkMultiplyAutomations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ test.describe('Spark Multiply - Mainnet - Wallet connected', async () => {
await resetState();
});

test('It should Deposit and Borrow in a single tx on an existing Spark Multiply position', async () => {
test('It should Deposit and Borrow in a single tx on an existing Spark Multiply position @regression', async () => {
test.info().annotations.push({
type: 'Test case',
description: '13659',
Expand Down
2 changes: 2 additions & 0 deletions utils/tenderly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const tokenAddresses = {
},
optimism: {
DAI: '0xda10009cbd5d07dd0cecc66161fc93d7c9000da1',
OP: '0x4200000000000000000000000000000000000042',
RETH: '0x9Bcef72be871e61ED4fBbc7630889beE758eb81D',
USDC: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85',
WBTC: '0x68f180fcCe6836688e9084f035309E29Bf0A2095',
Expand All @@ -94,6 +95,7 @@ export const tokenBalances = {
DAI: '200000',
ETH: '1000',
GHO: '10000',
OP: '100000',
RETH: '1000',
SDAI: '200000',
TBTC: '10000',
Expand Down

0 comments on commit 6cf8b2d

Please sign in to comment.