Skip to content

Move rewards section to Dashboard and combine all rewards in one place #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion liquidity/components/ClaimModal/ClaimModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ export function ClaimModal({ onClose }: { onClose: () => void }) {
settle: settleBorrow,
} = useBorrow({
accountId: params.accountId,
poolId: params.poolId,
collateralTypeAddress: collateralType?.tokenAddress,
debtChange,
});
Expand Down
9 changes: 3 additions & 6 deletions liquidity/components/DepositModal/DepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export function DepositModal({
const { exec: execDeposit } = useDeposit({
accountId: params.accountId,
newAccountId,
poolId: params.poolId,
collateralTypeAddress: collateralType?.tokenAddress,
collateralChange,
currentCollateral,
Expand All @@ -110,7 +109,6 @@ export function DepositModal({
const { exec: depositBaseAndromeda } = useDepositBaseAndromeda({
accountId: params.accountId,
newAccountId,
poolId: params.poolId,
collateralTypeAddress: synthToken?.token?.address,
collateralChange,
currentCollateral,
Expand All @@ -123,7 +121,7 @@ export function DepositModal({

// TODO: Update logic on new account id

const { data: pool } = usePool(params.poolId);
const { data: pool } = usePool();

const errorParser = useContractErrorParser();

Expand Down Expand Up @@ -266,21 +264,20 @@ export function DepositModal({
const handleClose = React.useCallback(() => {
const isSuccess = state.matches(State.success);

if (isSuccess && params.poolId && params.accountId && collateralType?.symbol) {
if (isSuccess && params.accountId && collateralType?.symbol) {
send(Events.RESET);
onClose();
setParams({
page: 'position',
collateralSymbol: collateralType.symbol,
poolId: params.poolId,
manageAction: 'deposit',
accountId: params.accountId,
});
return;
}
send(Events.RESET);
onClose();
}, [state, params.poolId, params.accountId, collateralType?.symbol, send, onClose, setParams]);
}, [state, params.accountId, collateralType?.symbol, send, onClose, setParams]);

const onSubmit = React.useCallback(async () => {
if (state.matches(State.success)) {
Expand Down
8 changes: 3 additions & 5 deletions liquidity/components/DepositModal/StataDepositModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ export function StataDepositModal({
const { exec: depositBaseAndromeda } = useDepositBaseAndromeda({
accountId: params.accountId,
newAccountId,
poolId: params.poolId,
collateralTypeAddress: synthToken?.token?.address,
collateralChange,
currentCollateral: liquidityPosition?.collateralAmount,
Expand Down Expand Up @@ -338,21 +337,20 @@ export function StataDepositModal({
const handleClose = React.useCallback(() => {
const isSuccess = state.matches(State.success);

if (isSuccess && params.poolId && params.accountId && collateralType?.symbol) {
if (isSuccess && params.accountId && collateralType?.symbol) {
send(Events.RESET);
onClose();
setParams({
page: 'position',
collateralSymbol: collateralType.symbol,
poolId: params.poolId,
manageAction: 'deposit',
accountId: params.accountId,
});
return;
}
send(Events.RESET);
onClose();
}, [state, params.poolId, params.accountId, collateralType?.symbol, send, onClose, setParams]);
}, [state, params.accountId, collateralType?.symbol, send, onClose, setParams]);

const onSubmit = React.useCallback(async () => {
if (state.matches(State.success)) {
Expand All @@ -372,7 +370,7 @@ export function StataDepositModal({
state.matches(State.deposit) ||
state.matches(State.wrap);

const { data: pool } = usePool(params.poolId);
const { data: pool } = usePool();

if (state.matches(State.success)) {
return (
Expand Down
2 changes: 0 additions & 2 deletions liquidity/components/RepayModal/RepayModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function RepayModal({ onClose }: { onClose: () => void }) {

const { exec: execRepay, settle: settleRepay } = useRepay({
accountId: params.accountId,
poolId: params.poolId,
collateralTypeAddress: collateralType?.tokenAddress,
debtChange,
availableUSDCollateral: availableCollateral,
Expand All @@ -56,7 +55,6 @@ export function RepayModal({ onClose }: { onClose: () => void }) {

const { exec: execRepayBaseAndromeda, settle: settleRepayBaseAndromeda } = useRepayBaseAndromeda({
accountId: params.accountId,
poolId: params.poolId,
collateralTypeAddress: collateralType?.tokenAddress,
debtChange,
availableUSDCollateral: availableCollateral,
Expand Down
1 change: 0 additions & 1 deletion liquidity/components/UndelegateModal/UndelegateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export function UndelegateModal({ onClose }: { onClose: () => void }) {

const { exec: execUndelegate } = useUndelegate({
accountId: params.accountId,
poolId: params.poolId,
collateralTypeAddress: collateralType?.tokenAddress,
collateralChange,
currentCollateral: currentCollateral,
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Borrow.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'claim',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Close.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'close',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Deposit.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'deposit',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Repay.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'repay',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Unlock.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'undelegate',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/1-main/SNX_Withdraw.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'withdraw',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'SNX',
poolId: 1,
manageAction: 'withdraw-debt',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { makeSearch } from '@snx-v3/useParams';
describe(__filename, () => {
Cypress.env('chainId', '42161');
Cypress.env('preset', 'main');
Cypress.env('walletAddress', '0xeEBb1b80e75b44180EbF7893DA00034d30BDfF7C');
Cypress.env('accountId', '170141183460469231731687303715884106023');
Cypress.env('walletAddress', '0xc3Cf311e04c1f8C74eCF6a795Ae760dc6312F345');
Cypress.env('accountId', '58655818123');

beforeEach(() => {
cy.task('startAnvil', {
chainId: Cypress.env('chainId'),
forkUrl: `https://arbitrum-mainnet.infura.io/v3/${Cypress.env('INFURA_KEY')}`,
block: '281318272',
block: '285187379',
}).then(() => cy.log('Anvil started'));

cy.on('window:before:load', (win) => {
Expand All @@ -28,10 +28,7 @@ describe(__filename, () => {

cy.visit(
`?${makeSearch({
page: 'position',
collateralSymbol: 'ARB',
poolId: 1,
manageAction: 'deposit',
page: 'dashboard',
accountId: Cypress.env('accountId'),
})}`
);
Expand All @@ -41,23 +38,29 @@ describe(__filename, () => {

cy.get('[data-cy="claim rewards info"]')
.should('exist')
.and('include.text', 'Claiming 53.87 ARB')
.and('include.text', 'Claiming 0.55 USDe')
.and('include.text', 'Claiming 0.0078 WETH')
.and('include.text', 'Claiming 0.0000004 tBTC');

cy.get('[data-cy="claim rewards info"]', { timeout: 180_000 })
.should('exist')
.and('include.text', 'Claimed 53.87 ARB')
.and('include.text', 'Claimed 0.55 USDe')
.and('include.text', 'Claimed 0.0078 WETH')
.and('include.text', 'Claimed 0.0000004 tBTC');
.and('include.text', 'Claiming 0.35 ARB')
.and('include.text', 'Claiming 0.18 USDe')
.and('include.text', 'Claiming 0.0012 WETH')
.and('include.text', 'Claiming 0.000000071 tBTC');

cy.contains('[data-status="success"]', 'Your rewards have been claimed').should('exist');
cy.contains('[data-status="success"]', 'Your rewards have been claimed', {
timeout: 180_000,
}).should('exist');
cy.get('[data-cy="transaction hash"]').should('exist');

cy.get('[data-cy="claim rewards info"]')
.should('exist')
.and('include.text', 'Claimed 0.35 ARB')
.and('include.text', 'Claimed 0.18 USDe')
.and('include.text', 'Claimed 0.0012 WETH')
.and('include.text', 'Claimed 0.000000071 tBTC');

cy.contains('[data-cy="claim rewards dialog"] button', 'Done').click();
cy.get('[data-cy="rewards table"]').should('include.text', 'No Rewards Available');
cy.get('[data-cy="rewards table"]', { timeout: 180_000 }).should(
'include.text',
'No Rewards Available'
);
cy.get('[data-cy="claim rewards submit"]').should('be.disabled');
});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ describe(__filename, () => {
cy.get('[data-cy="transaction hash"]').should('exist');

cy.contains('[data-cy="unwrap synths dialog"] button', 'Done').click();
cy.get('[data-cy="synths table"]').should('include.text', 'You do not have any synths');
cy.get('[data-cy="synths table"]', { timeout: 180_000 }).should(
'include.text',
'You do not have any synths'
);
cy.get('[data-cy="unwrap synths submit"]').should('be.disabled');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'claim',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/42161-main/USDC_Close.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'close',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'deposit',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/42161-main/USDC_Repay.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'repay',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'undelegate',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'USDC',
poolId: 1,
manageAction: 'withdraw',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'WETH',
poolId: 1,
manageAction: 'claim',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/42161-main/WETH_Close.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'WETH',
poolId: 1,
manageAction: 'close',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'WETH',
poolId: 1,
manageAction: 'deposit',
accountId: Cypress.env('accountId'),
})}`
Expand Down
1 change: 0 additions & 1 deletion liquidity/cypress/cypress/e2e/42161-main/WETH_Repay.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'WETH',
poolId: 1,
manageAction: 'repay',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe(__filename, () => {
`?${makeSearch({
page: 'position',
collateralSymbol: 'WETH',
poolId: 1,
manageAction: 'undelegate',
accountId: Cypress.env('accountId'),
})}`
Expand Down
Loading