Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Commit

Permalink
use safeApprove & replace while loop for block rotations;
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey authored and Andrey committed Jul 25, 2023
1 parent 8f9a543 commit 4f1e95c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions contracts/core/index-fund/IndexFund.sol
Original file line number Diff line number Diff line change
Expand Up @@ -262,10 +262,7 @@ contract IndexFund is IIndexFund, Storage, OwnableUpgradeable, ReentrancyGuard {
// tokens must be transfered from the sender to this contract
IERC20(token).safeTransferFrom(msg.sender, address(this), amount);
// we give allowance to accounts contract
require(
IERC20(token).approve(registrarConfig.accountsContract, amount),
"Approval needed for Accounts Contract to spend"
);
IERC20(token).safeApprove(registrarConfig.accountsContract, amount);

if (fundId != 0) {
// Depositor has chosen a specific fund to send tokens to. Send 100% to that fund.
Expand Down Expand Up @@ -294,9 +291,8 @@ contract IndexFund is IIndexFund, Storage, OwnableUpgradeable, ReentrancyGuard {
state.activeFund = nextActiveFund();
state.roundDonations = 0;

while (block.number >= state.nextRotationBlock) {
state.nextRotationBlock += state.config.fundRotation;
}
uint256 addIters = (block.number - state.nextRotationBlock).div(state.config.fundRotation);
state.nextRotationBlock += state.config.fundRotation.mul(addIters);
}
// send donation messages to Accounts contract
processDonations(
Expand Down

0 comments on commit 4f1e95c

Please sign in to comment.