utils#getCallStateResult TypeScript Examples
The following examples show how to use
utils#getCallStateResult.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: hooks.ts From interface-v2 with GNU General Public License v3.0 | 6 votes |
export function getStakingFees(
stakingInfo: StakingBasic | DualStakingBasic,
balanceState?: CallState,
totalSupplyState?: CallState,
) {
let oneYearFeeAPY = 0;
let oneDayFee = 0;
let accountFee = 0;
if (pairs !== undefined) {
oneYearFeeAPY = pairs[stakingInfo.pair]?.oneDayVolumeUSD;
const balanceResult = getCallStateResult(balanceState);
const totalSupplyResult = getCallStateResult(totalSupplyState);
if (oneYearFeeAPY && balanceResult && totalSupplyResult) {
const totalSupply = web3.utils.toWei(
pairs[stakingInfo.pair]?.totalSupply,
'ether',
);
const ratio = Number(totalSupplyResult) / Number(totalSupply);
const myRatio = Number(balanceResult) / Number(totalSupplyResult);
oneDayFee = oneYearFeeAPY * GlobalConst.utils.FEEPERCENT * ratio;
accountFee = oneDayFee * myRatio;
oneYearFeeAPY = getOneYearFee(
oneYearFeeAPY,
pairs[stakingInfo.pair]?.reserveUSD,
);
}
}
return { oneYearFeeAPY, oneDayFee, accountFee };
}