Created
February 4, 2022 17:07
-
-
Save 0xmikko/034a51202ea197434c1a5f1d28b39f3c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// @dev Calculates Threshold Weighted Total Value | |
/// More: https://dev.gearbox.fi/developers/credit/economy#threshold-weighted-value | |
/// | |
/// @param creditAccount Credit account address | |
function calcThresholdWeightedValue(address creditAccount) | |
public | |
view | |
override | |
returns (uint256 total) | |
{ | |
uint256 tokenMask; | |
uint256 eTokens = enabledTokens[creditAccount]; | |
for (uint256 i = 0; i < allowedTokens.length; i++) { | |
tokenMask = 1 << i; // T:[CF-18] | |
if (eTokens & tokenMask > 0) { | |
(, , , uint256 twv) = getCreditAccountTokenById( | |
creditAccount, | |
i | |
); | |
total += twv; | |
} | |
} // T:[CF-18] | |
return total / PERCENTAGE_FACTOR; // T:[CF-18] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment