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

feat: Frax middleman example #41

Merged
merged 8 commits into from
Jan 31, 2024
Merged

feat: Frax middleman example #41

merged 8 commits into from
Jan 31, 2024

Conversation

sogipec
Copy link
Contributor

@sogipec sogipec commented Oct 26, 2023

No description provided.

Comment on lines 82 to 110
function incentivizePool(
address poolAddress,
address,
address,
address incentiveTokenAddress,
uint256,
uint256 amount
) external {
IERC20(incentiveTokenAddress).safeTransferFrom(msg.sender, address(this), amount);
DistributionParameters memory params = gaugeParams[poolAddress][incentiveTokenAddress];
if (params.uniV3Pool == address(0)) revert InvalidParams();
DistributionCreator creator = merklDistributionCreator();
// Minimum amount of incentive tokens to be distributed per hour
uint256 minAmount = creator.rewardTokenMinAmounts(incentiveTokenAddress) * params.numEpoch;
params.epochStart = uint32(block.timestamp);
// Adding the leftover amounts to the total amount to be distributed
uint256 leftover = leftovers[incentiveTokenAddress][poolAddress];
amount += leftover;
params.amount = amount;
if (amount > 0) {
if (amount > minAmount) {
_handleIncentiveTokenAllowance(IERC20(incentiveTokenAddress), address(creator), amount);
merklDistributionCreator().createDistribution(params);
if (leftover > 0) leftovers[incentiveTokenAddress][poolAddress] = 0;
} else {
leftovers[incentiveTokenAddress][poolAddress] = amount;
}
}
}

Check warning

Code scanning / Slither

Unused return

MerklFraxIncentivizationHandler.incentivizePool(address,address,address,address,uint256,uint256) (contracts/middleman/MerklFraxIncentivizationHandler.sol#82-110) ignores return value by merklDistributionCreator().createDistribution(params) (contracts/middleman/MerklFraxIncentivizationHandler.sol#104)
Comment on lines +75 to +77
function setOperator(address _operatorAddress) external onlyByOwnerOperator {
operatorAddress = _operatorAddress;
}

Check notice

Code scanning / Slither

Missing events access control

MerklFraxIncentivizationHandler.setOperator(address) (contracts/middleman/MerklFraxIncentivizationHandler.sol#75-77) should emit an event for: - operatorAddress = _operatorAddress (contracts/middleman/MerklFraxIncentivizationHandler.sol#76)
}

/// @notice Sets the operator of the contract
function setOperator(address _operatorAddress) external onlyByOwnerOperator {

Check notice

Code scanning / Slither

Missing zero address validation

MerklFraxIncentivizationHandler.setOperator(address)._operatorAddress (contracts/middleman/MerklFraxIncentivizationHandler.sol#75) lacks a zero-check on : - operatorAddress = _operatorAddress (contracts/middleman/MerklFraxIncentivizationHandler.sol#76)
Comment on lines 82 to 110
function incentivizePool(
address poolAddress,
address,
address,
address incentiveTokenAddress,
uint256,
uint256 amount
) external {
IERC20(incentiveTokenAddress).safeTransferFrom(msg.sender, address(this), amount);
DistributionParameters memory params = gaugeParams[poolAddress][incentiveTokenAddress];
if (params.uniV3Pool == address(0)) revert InvalidParams();
DistributionCreator creator = merklDistributionCreator();
// Minimum amount of incentive tokens to be distributed per hour
uint256 minAmount = creator.rewardTokenMinAmounts(incentiveTokenAddress) * params.numEpoch;
params.epochStart = uint32(block.timestamp);
// Adding the leftover amounts to the total amount to be distributed
uint256 leftover = leftovers[incentiveTokenAddress][poolAddress];
amount += leftover;
params.amount = amount;
if (amount > 0) {
if (amount > minAmount) {
_handleIncentiveTokenAllowance(IERC20(incentiveTokenAddress), address(creator), amount);
merklDistributionCreator().createDistribution(params);
if (leftover > 0) leftovers[incentiveTokenAddress][poolAddress] = 0;
} else {
leftovers[incentiveTokenAddress][poolAddress] = amount;
}
}
}

Check notice

Code scanning / Slither

Reentrancy vulnerabilities

Reentrancy in MerklFraxIncentivizationHandler.incentivizePool(address,address,address,address,uint256,uint256) (contracts/middleman/MerklFraxIncentivizationHandler.sol#82-110): External calls: - IERC20(incentiveTokenAddress).safeTransferFrom(msg.sender,address(this),amount) (contracts/middleman/MerklFraxIncentivizationHandler.sol#90) State variables written after the call(s): - leftovers[incentiveTokenAddress][poolAddress] = amount (contracts/middleman/MerklFraxIncentivizationHandler.sol#107)
@sogipec sogipec force-pushed the frax-incentivizor-handler branch from ebcf76c to ce72f26 Compare January 12, 2024 11:52
@sogipec sogipec enabled auto-merge (squash) January 31, 2024 14:26
@sogipec sogipec merged commit e7e7e2d into main Jan 31, 2024
4 checks passed
@sogipec sogipec deleted the frax-incentivizor-handler branch January 31, 2024 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants