Skip to content

Commit

Permalink
feat: added APY module
Browse files Browse the repository at this point in the history
  • Loading branch information
duongnd-183902 committed Nov 8, 2022
1 parent 1ae6a9c commit b398da2
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/lib/apr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ export default class APRCalCulator {
);
return validatorCommission;
}
/**
* This function to calculator apr from apr
* @param stakingAPR staking APR
* @param partition partitions number of a year
* @returns
*/
async stakingAPY(stakingAPR: number, partition: number = 0): Promise<number> {
if (partition === 0) {
return Math.exp(stakingAPR)
}
else
return (1 + stakingAPR / partition) ** partition;
}
}
function uint8ArrayStringToNumber(
x: Uint8Array | string,
Expand Down

0 comments on commit b398da2

Please sign in to comment.