Skip to content

Commit

Permalink
fix dividends
Browse files Browse the repository at this point in the history
  • Loading branch information
Digberi committed Sep 13, 2023
1 parent 0c740f4 commit aa92042
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import BigNumber from 'bignumber.js';

import { DEFAULT_STABLESWAP_POOL_ID, STABLESWAP_DIVIDENDS_ACCUM_PRECISION, ZERO_AMOUNT } from '@config/constants';
import { getStorageInfo } from '@shared/dapp/get-storage-info';
import { isExist, isNull, toArray } from '@shared/helpers';
import { isExist, isNull, resolveOrNull, toArray } from '@shared/helpers';
import { nat, Nullable } from '@shared/types';

import { earningsMapSchema, rewardMapSchema } from '../../../schemas/get-staker-info.schemas';
Expand Down Expand Up @@ -49,7 +49,9 @@ const getSinglePoolStakerInfo = async (
) => {
const { storage } = await getStorageInfo<StableswapStorage>(tezos, contractAddress);
const { pools, stakers_balance } = storage;
const stakerAccum = (await stakers_balance.get([accountPkh, poolId])) ?? {
const _stakerAccum = await resolveOrNull(stakers_balance.get([accountPkh, poolId]));

const stakerAccum = _stakerAccum ?? {
balance: new BigNumber(ZERO_AMOUNT),
earnings: new MichelsonMap<nat, EarningsValue>(earningsMapSchema)
};
Expand Down
1 change: 1 addition & 0 deletions src/shared/helpers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,4 @@ export * from './math';
export * from './get-precentage-from-number';
export * from './set-caret-position';
export * from './can-use-three-route-api';
export * from './resolve-or-null';
7 changes: 7 additions & 0 deletions src/shared/helpers/resolve-or-null.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export const resolveOrNull = async <T>(value: Promise<T>): Promise<T | null> => {
try {
return await value;
} catch (e) {
return null;
}
};

0 comments on commit aa92042

Please sign in to comment.