Skip to content

Commit

Permalink
SOV-3289: claim itokens (#2576)
Browse files Browse the repository at this point in the history
* fix: claim itokens

* fix: increase max cehckpoints for token claim
  • Loading branch information
creed-victor authored Oct 13, 2023
1 parent 2528e07 commit 20c77bf
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TxType } from 'store/global/transactions-store/types';
import { translations } from 'locales/i18n';
import { UserCheckpoint } from './types';

const MAX_CHECKPOINTS = 50;
const MAX_CHECKPOINTS = 150;
const MAX_NEXT_POSITIVE_CHECKPOINT = 75;

type HandleClaimAllResult = [ResetTxResponseInterface, () => void];
Expand Down
23 changes: 17 additions & 6 deletions src/app/pages/RewardPage/hooks/useGetFeesEarned.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { useEffect, useState } from 'react';
import { useAccount, useBlockSync } from 'app/hooks/useAccount';
import { Asset, Chain } from 'types';
import {
assetByLoanTokenAddress,
assetByTokenAddress,
getContract,
getLendingContract,
getTokenContract,
} from 'utils/blockchain/contract-helpers';
import { contractReader } from 'utils/sovryn/contract-reader';
Expand All @@ -16,7 +19,14 @@ import { useIsMounted } from 'app/hooks/useIsMounted';

const MAX_CHECKPOINTS = 50;

const ASSETS = [Asset.RBTC, Asset.WRBTC, Asset.SOV, Asset.MYNT, Asset.ZUSD];
const TOKEN_ASSETS = [
Asset.RBTC,
Asset.WRBTC,
Asset.SOV,
Asset.MYNT,
Asset.ZUSD,
];
const LOAN_ASSETS = [Asset.RBTC];

let btcDummyAddress: string;
const getRbtcDummyAddress = async () => {
Expand All @@ -31,13 +41,14 @@ const getRbtcDummyAddress = async () => {
};

const getTokenAddresses = async () => {
const result = await Promise.all(
ASSETS.map(asset =>
const result = await Promise.all([
...TOKEN_ASSETS.map(asset =>
asset === Asset.RBTC
? getRbtcDummyAddress()
: getTokenContract(asset).address,
),
);
...LOAN_ASSETS.map(asset => getLendingContract(asset).address),
]);
return result;
};

Expand Down Expand Up @@ -118,9 +129,9 @@ export const useGetFeesEarned = (): {
);

const results = tokens.map(
(token, index) =>
token =>
({
asset: ASSETS[index],
asset: assetByTokenAddress(token) || assetByLoanTokenAddress(token),
contractAddress: token,
value: amounts.returnData[token].toString(),
rbtcValue: 0,
Expand Down

0 comments on commit 20c77bf

Please sign in to comment.