We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
/** * Calculate amounts from percentage allocations (100000 => 100%) * * @param allocations : array of protocol allocations in percentage * @param total : total amount * @return : array with amounts */ function _amountsFromAllocations(uint256[] memory allocations, uint256 total) internal view returns (uint256[] memory newAmounts) { newAmounts = new uint256[](allocations.length); uint256 currBalance; uint256 allocatedBalance; uint256 firstProtocolIndexWithAllocation; for (uint256 i = 0; i < allocations.length; i++) { // Take last protocol with valid allocations if (allocations[i] > 0){ firstProtocolIndexWithAllocation = i; } currBalance = total.mul(allocations[i]).div(FULL_ALLOC); allocatedBalance = allocatedBalance.add(currBalance); newAmounts[i] = currBalance; } // Allocate remaining amount to last protocol if (total.sub(allocatedBalance) > 0){ newAmounts[firstProtocolIndexWithAllocation] = newAmounts[firstProtocolIndexWithAllocation].add(total.sub(allocatedBalance)); } return newAmounts; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
The text was updated successfully, but these errors were encountered: