Skip to content

Commit

Permalink
prettier.
Browse files Browse the repository at this point in the history
  • Loading branch information
clement-ux committed Feb 12, 2025
1 parent b41c933 commit 5a1ba5d
Show file tree
Hide file tree
Showing 3 changed files with 238 additions and 90 deletions.
76 changes: 53 additions & 23 deletions contracts/contracts/pool-booster/CurvePoolBoosterL2.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {Initializable} from "../utils/Initializable.sol";
import {Strategizable} from "../governance/Strategizable.sol";
import {IVotemarket} from "../interfaces/IVotemarket.sol";
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import { Initializable } from "../utils/Initializable.sol";
import { Strategizable } from "../governance/Strategizable.sol";
import { IVotemarket } from "../interfaces/IVotemarket.sol";

/// @title CurvePoolBooster
/// @author Origin Protocol
Expand Down Expand Up @@ -55,14 +55,21 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
uint256 totalRewardAmount
);
event CampaignManaged(
uint256 campaignId, uint8 numberOfPeriods, uint256 maxRewardPerVote, uint256 totalRewardAmount
uint256 campaignId,
uint8 numberOfPeriods,
uint256 maxRewardPerVote,
uint256 totalRewardAmount
);
event TokensRescued(address token, uint256 amount, address receiver);

////////////////////////////////////////////////////
/// --- CONSTRUCTOR && INITIALIZATION
////////////////////////////////////////////////////
constructor(address _rewardToken, address _gauge, address _votemarket) {
constructor(
address _rewardToken,
address _gauge,
address _votemarket
) {
gauge = _gauge;
votemarket = IVotemarket(_votemarket);
rewardToken = IERC20(_rewardToken);
Expand All @@ -71,7 +78,11 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
_setGovernor(address(0));
}

function initialize(address _strategist, uint16 _fee, address _feeCollector) external onlyGovernor initializer {
function initialize(
address _strategist,
uint16 _fee,
address _feeCollector
) external onlyGovernor initializer {
_setStrategistAddr(_strategist);
_setFee(_fee);
_setFeeCollector(_feeCollector);
Expand All @@ -85,12 +96,11 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
/// @param _numberOfPeriods Duration of the campaign in weeks
/// @param _maxRewardPerVote Maximum reward per vote to distribute, to avoid overspending
/// @param _blacklist List of addresses to exclude from the campaign
function createCampaign(uint8 _numberOfPeriods, uint256 _maxRewardPerVote, address[] calldata _blacklist)
external
nonReentrant
onlyGovernorOrStrategist
returns (uint256)
{
function createCampaign(
uint8 _numberOfPeriods,
uint256 _maxRewardPerVote,
address[] calldata _blacklist
) external nonReentrant onlyGovernorOrStrategist returns (uint256) {
require(campaignId == 0, "Campaign already created");
require(_numberOfPeriods > 1, "Invalid number of periods");
require(_maxRewardPerVote > 0, "Invalid reward per vote");
Expand All @@ -116,7 +126,13 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
true
);

emit CampaignCreated(campaignId, gauge, address(rewardToken), _maxRewardPerVote, balanceSubFee);
emit CampaignCreated(
campaignId,
gauge,
address(rewardToken),
_maxRewardPerVote,
balanceSubFee
);

return campaignId;
}
Expand All @@ -127,11 +143,11 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
/// that will be added to already existing amount of periods.
/// @param _newMaxRewardPerVote New maximum reward per vote
/// @param _increaseTotalReward Boolean to increase the total reward amount or not
function manageCampaign(uint8 _extraNumberOfPeriods, uint256 _newMaxRewardPerVote, bool _increaseTotalReward)
external
nonReentrant
onlyGovernorOrStrategist
{
function manageCampaign(
uint8 _extraNumberOfPeriods,
uint256 _newMaxRewardPerVote,
bool _increaseTotalReward
) external nonReentrant onlyGovernorOrStrategist {
require(campaignId != 0, "Campaign not created");

// Handle fee (if any)
Expand All @@ -145,9 +161,19 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
}

// Update the campaign
votemarket.manageCampaign(campaignId, _extraNumberOfPeriods, balanceSubFee, _newMaxRewardPerVote);
votemarket.manageCampaign(
campaignId,
_extraNumberOfPeriods,
balanceSubFee,
_newMaxRewardPerVote
);

emit CampaignManaged(campaignId, _extraNumberOfPeriods, _newMaxRewardPerVote, balanceSubFee);
emit CampaignManaged(
campaignId,
_extraNumberOfPeriods,
_newMaxRewardPerVote,
balanceSubFee
);
}

/// @notice Close the campaign.
Expand Down Expand Up @@ -192,7 +218,11 @@ contract CurvePoolBoosterL2 is Initializable, Strategizable {
/// @notice Rescue ERC20 tokens from the contract
/// @dev Only callable by the governor or strategist
/// @param token Address of the token to rescue
function rescueToken(address token, address receiver) external nonReentrant onlyGovernor {
function rescueToken(address token, address receiver)
external
nonReentrant
onlyGovernor
{
require(receiver != address(0), "Invalid receiver");
uint256 balance = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransfer(receiver, balance);
Expand Down
Loading

0 comments on commit 5a1ba5d

Please sign in to comment.