Skip to content

Commit

Permalink
[dfyn-staked-in-vaults] Update dfyn-staked-in-vaults index.ts (snapsh…
Browse files Browse the repository at this point in the history
…ot-labs#53)

* Update index.ts

Solved an issue with summation code, for more than two summations, add function from the BigNumber library was giving some issues.

* Update index.ts
  • Loading branch information
vatsalgupta13 authored Sep 3, 2021
1 parent a21c9a4 commit 49c3951
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/strategies/dfyn-staked-in-vaults/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@ export async function strategy(
// performing summation over all balances of the user
response = []
result.map((item, index) => {
response.push(result[index].reduce((a, b) => [a.add(b)]))
let sum = 0
result[index].map((element) => {
sum = sum + parseFloat(formatUnits(element.toString(), 18))
})
response.push(sum)
})
}
return Object.fromEntries(
response.map((value, i) => [
addresses[i],
options.scoreMultiplier * parseFloat(formatUnits(value.toString(), options.decimals))
options.scoreMultiplier * value
])
);
}

0 comments on commit 49c3951

Please sign in to comment.