[forte-staking] Forte staking strategy#1754
Conversation
|
|
||
| function calculateVotingPower(rawBatches: batch[], kycLevel: number): number { | ||
| let votingPower: bigint = 0n; | ||
| rawBatches.forEach((batch) => { |
There was a problem hiding this comment.
This forEach could be replaced with reduce and ``votingPowerbeing replaced withaccumulator` so line 61 would be `rawBatches.reduce((acc, batch) => {` and the return value would be `return acc + (stake * BigInt(4 * (daysStaked > 1 ? daysStaked - 1 : 0))) / 1461n;`
There was a problem hiding this comment.
Great suggestion. Implemented.
| (today - stakeDate) / (60 * 60 * 24 * 1000) // (...) / (1 day in ms) | ||
| ); | ||
| const stake: bigint = BigInt(batch[stakeAmount]._hex); | ||
| return (votingPower += |
There was a problem hiding this comment.
this works however votingPower as the accumulator is assigned to whatever is returned by the called function, so votingPower does not need to be updated and the called function can return votingPower + (stake * BigInt(4 * (daysStaked > 1 ? daysStaked - 1 : 0))) / 1461n)
| import { Multicaller } from '../../utils'; | ||
| import { formatUnits } from '@ethersproject/units'; | ||
|
|
||
| export const author = 'forte'; |
There was a problem hiding this comment.
Should be a github related to forte 😅 it will help identify you if you want to update this strategy in future
There was a problem hiding this comment.
😅 ok I wasn't aware this had the purpose of giving update privileges. I changed it to my GH user
|
Also, lint is failing. Could you check? |
|
PR changes addressed |
No description provided.