Skip to content

Commit

Permalink
Automated lint (#1381)
Browse files Browse the repository at this point in the history
Co-authored-by: ChaituVR <[email protected]>
  • Loading branch information
github-actions[bot] and ChaituVR authored Dec 31, 2023
1 parent ee38f82 commit cbe0f37
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions src/strategies/sd-vote-boost-twavp-vsdtoken/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ export async function strategy(
);

const balanceOfQueries: any[] = [];
for(const address of addresses) {
balanceOfQueries.push([
options.vsdToken,
'balanceOf',
[address]
]);
balanceOfQueries.push([
options.vsdToken,
'totalSupply',
[]
]);
for (const address of addresses) {
balanceOfQueries.push([options.vsdToken, 'balanceOf', [address]]);
balanceOfQueries.push([options.vsdToken, 'totalSupply', []]);
}

const response: any[] = [];
for (let i = 0; i < options.sampleStep; i++) {
// Use good block number
Expand All @@ -76,7 +68,11 @@ export async function strategy(
// End
loopCalls.push([options.veAddress, 'balanceOf', [options.locker]]);
loopCalls.push([options.sdTokenGauge, 'working_supply']);
loopCalls.push([options.sdTokenGauge, 'working_balances', [options.booster]]);
loopCalls.push([
options.sdTokenGauge,
'working_balances',
[options.booster]
]);
loopCalls.push(...balanceOfQueries);
} else {
loopCalls.push(...balanceOfQueries);
Expand All @@ -91,9 +87,10 @@ export async function strategy(
const workingSupply = response[response.length - 1].shift()[0]; // Last response, latest block
const workingBalances = response[response.length - 1].shift()[0]; // Last response, latest block

const totalVP = parseFloat(formatUnits(workingBalances, 18))
/ parseFloat(formatUnits(workingSupply, 18))
* parseFloat(formatUnits(lockerVeBalance, 18));
const totalVP =
(parseFloat(formatUnits(workingBalances, 18)) /
parseFloat(formatUnits(workingSupply, 18))) *
parseFloat(formatUnits(lockerVeBalance, 18));

return Object.fromEntries(
Array(addresses.length)
Expand All @@ -107,7 +104,7 @@ export async function strategy(
const totalSupply = BigNumber.from(response[j].shift()[0]);

// Add working balance to array.
if(totalSupply.eq(0)) {
if (totalSupply.eq(0)) {
userWorkingBalances.push(0);
} else {
userWorkingBalances.push(balanceOf.div(totalSupply).toNumber());
Expand All @@ -122,18 +119,14 @@ export async function strategy(
);

// Calculate voting power.
const votingPower =
totalVP != 0
? averageWorkingBalance * totalVP
: 0;
const votingPower = totalVP != 0 ? averageWorkingBalance * totalVP : 0;

// Return address and voting power
return [addresses[i], Number(votingPower)];
})
);
}


function average(
numbers: number[],
address: string,
Expand All @@ -156,7 +149,6 @@ function average(
return sum / numbers.length;
}


function getPreviousBlocks(
currentBlockNumber: number,
numberOfBlocks: number,
Expand Down Expand Up @@ -185,4 +177,4 @@ function getPreviousBlocks(

// Return array of block numbers
return blockNumbers;
}
}

0 comments on commit cbe0f37

Please sign in to comment.