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

claimedPrincipalFunds to uint128 #93

Merged
merged 3 commits into from
Oct 2, 2023
Merged
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
10 changes: 4 additions & 6 deletions src/owr/OptimisticWithdrawalRecipient.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ contract OptimisticWithdrawalRecipient is Clone {
/// Amount of distributed OWRecipient token for principal
/// @dev Would be less than or equal to amount of stake
/// @dev ERC20s with very large decimals may overflow & cause issues
uint256 public claimedPrincipalFunds;
uint128 public claimedPrincipalFunds;

/// Mapping to account balances for pulling
mapping(address => uint256) internal pullBalances;
Expand Down Expand Up @@ -239,12 +239,9 @@ contract OptimisticWithdrawalRecipient is Clone {

// load storage into memory
uint256 currentbalance = address(this).balance;
uint256 _fundsToBeDistributed;
uint256 _claimedPrincipalFunds = uint256(claimedPrincipalFunds);
uint256 _memoryFundsPendingWithdrawal = uint256(fundsPendingWithdrawal);
unchecked {
_fundsToBeDistributed = currentbalance - _memoryFundsPendingWithdrawal;
}
uint256 _fundsToBeDistributed = currentbalance - _memoryFundsPendingWithdrawal;

(address principalRecipient, address rewardRecipient, uint256 amountOfPrincipalStake) = getTranches();

Expand Down Expand Up @@ -278,7 +275,8 @@ contract OptimisticWithdrawalRecipient is Clone {
if (_fundsToBeDistributed > type(uint128).max) revert InvalidDistribution_TooLarge();
// Write to storage
// the principal value
claimedPrincipalFunds += _principalPayout;
// it cannot overflow because _principalPayout < _fundsToBeDistributed
if (_principalPayout > 0) claimedPrincipalFunds += uint128(_principalPayout);
}

/// interactions
Expand Down
Loading