From 49c3951fec521e7df7dd69d4ad26c4531d54224c Mon Sep 17 00:00:00 2001 From: Vatsal Gupta <48270372+vatsalgupta13@users.noreply.github.com> Date: Fri, 3 Sep 2021 08:06:43 +0530 Subject: [PATCH] [dfyn-staked-in-vaults] Update dfyn-staked-in-vaults index.ts (#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 --- src/strategies/dfyn-staked-in-vaults/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/strategies/dfyn-staked-in-vaults/index.ts b/src/strategies/dfyn-staked-in-vaults/index.ts index 28ebb4f6b..ccb0c34d3 100644 --- a/src/strategies/dfyn-staked-in-vaults/index.ts +++ b/src/strategies/dfyn-staked-in-vaults/index.ts @@ -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 ]) ); }