Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated lint #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/strategies/sd-vote-boost-twavp-v4/examples.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
"liquidLocker": "0x52f541764E6e90eeBc5c21Ff570De0e2D63766B6",
"sdTokenGauge": "0x7f50786A0b15723D741727882ee99a0BF34e3466",
"sdToken": "0xD1b5651E55D4CeeD36251c61c50C889B36F6abB5",
"pools": ["0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717","0xca0253a98d16e9c1e3614cafda19318ee69772d0"],
"pools": [
"0xf7b55c3732ad8b2c2da7c24f30a69f55c54fb717",
"0xca0253a98d16e9c1e3614cafda19318ee69772d0"
],
"symbol": "sdToken",
"decimals": 18,
"sampleSize": 10,
Expand Down
55 changes: 35 additions & 20 deletions src/strategies/sd-vote-boost-twavp-v4/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const abi = [
'function working_supply() external view returns (uint256)',
'function totalSupply() external view returns (uint256)',
'function working_balances(address account) external view returns (uint256)',
'function balances(uint256 i) external view returns (uint256)',
'function balances(uint256 i) external view returns (uint256)'
];

const MIN_BOOST = 0.4;
Expand Down Expand Up @@ -94,18 +94,32 @@ export async function strategy(
);
}

const workingSupply = parseFloat(formatUnits(response[response.length - 1].shift()[0], 18));
const lockerVotingPower = parseFloat(formatUnits(response[response.length - 1].pop()[0], 18));
const workingSupply = parseFloat(
formatUnits(response[response.length - 1].shift()[0], 18)
);
const lockerVotingPower = parseFloat(
formatUnits(response[response.length - 1].pop()[0], 18)
);

const poolsBalances = options.pools.map(() => response[response.length - 1].pop()[0]);
const sumPoolsBalance = parseFloat(formatUnits(poolsBalances.reduce((acc, balance) => acc.add(balance), BigNumber.from(0)), 18));
const poolsBalances = options.pools.map(
() => response[response.length - 1].pop()[0]
);
const sumPoolsBalance = parseFloat(
formatUnits(
poolsBalances.reduce(
(acc, balance) => acc.add(balance),
BigNumber.from(0)
),
18
)
);

const sdTknSupply = parseFloat(formatUnits(response[response.length - 1].pop()[0], 18));
const sdTknSupply = parseFloat(
formatUnits(response[response.length - 1].pop()[0], 18)
);

const liquidityVoteFee = MIN_BOOST
* sumPoolsBalance
* lockerVotingPower
/ sdTknSupply;
const liquidityVoteFee =
(MIN_BOOST * sumPoolsBalance * lockerVotingPower) / sdTknSupply;

const totalUserVotes = lockerVotingPower - liquidityVoteFee;

Expand All @@ -122,23 +136,24 @@ export async function strategy(
}

if (addresses[i].toLowerCase() === options.botAddress.toLowerCase()) {
return [
addresses[i],
Number(liquidityVoteFee)
];
return [addresses[i], Number(liquidityVoteFee)];
} else {
// Get average working balance.
const averageWorkingBalance = parseFloat(
formatUnits(average(
userWorkingBalances,
addresses[i],
options.whiteListedAddress
), 18));
formatUnits(
average(
userWorkingBalances,
addresses[i],
options.whiteListedAddress
),
18
)
);

// Calculate voting power.
const userVote =
workingSupply != 0
? (averageWorkingBalance / workingSupply * totalUserVotes)
? (averageWorkingBalance / workingSupply) * totalUserVotes
: 0;

// Return address and voting power
Expand Down