Skip to content

Commit

Permalink
Merge branch 'shah/ogn-rewards-source' into shah/migrator-rebased
Browse files Browse the repository at this point in the history
  • Loading branch information
shahthepro committed Apr 21, 2024
2 parents 4700efc + 7997625 commit a121f8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Governable} from "./Governable.sol";
import {Initializable} from "./upgrades/Initializable.sol";
import "OpenZeppelin/[email protected]/contracts/token/ERC20/IERC20.sol";

contract OGNRewardsSource is Governable, Initializable {
contract FixedRateRewardsSource is Governable, Initializable {
error UnauthorizedCaller();
error InvalidRewardRate();

Expand All @@ -14,7 +14,7 @@ contract OGNRewardsSource is Governable, Initializable {
event RewardsPerSecondChanged(uint256 newRPS, uint256 oldRPS);
event RewardCollected(uint256 amountCollected);

address public immutable ogn;
address public immutable rewardToken;

address public strategistAddr;

Expand All @@ -39,8 +39,8 @@ contract OGNRewardsSource is Governable, Initializable {
_;
}

constructor(address _ogn) {
ogn = _ogn;
constructor(address _rewardToken) {
rewardToken = _rewardToken;
}

/// @dev Initialize the proxy implementation
Expand Down Expand Up @@ -82,7 +82,7 @@ contract OGNRewardsSource is Governable, Initializable {

// Intentionally skipping balance check to save some gas
// since `transfer` anyway would fail in case of low balance
IERC20(ogn).transfer(_target, rewardAmount);
IERC20(rewardToken).transfer(_target, rewardAmount);
}
}

Expand Down Expand Up @@ -126,13 +126,13 @@ contract OGNRewardsSource is Governable, Initializable {
}

/// @dev Set the rate of reward emission
/// @param _rewardsPerSecond Amount of OGN to distribute per second
/// @param _rewardsPerSecond Amount of rewardToken to distribute per second
function setRewardsPerSecond(uint256 _rewardsPerSecond) external onlyGovernorOrStrategist {
_setRewardsPerSecond(_rewardsPerSecond);
}

/// @dev Set the rate of reward emission
/// @param _rewardsPerSecond Amount of OGN to distribute per second
/// @param _rewardsPerSecond Amount of rewardToken to distribute per second
function _setRewardsPerSecond(uint256 _rewardsPerSecond) internal {
if (_rewardsPerSecond > type(uint192).max) {
revert InvalidRewardRate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ pragma solidity 0.8.10;

import {InitializeGovernedUpgradeabilityProxy} from "./InitializeGovernedUpgradeabilityProxy.sol";

contract OGNRewardsSourceProxy is InitializeGovernedUpgradeabilityProxy {}
contract FixedRateRewardsSourceProxy is InitializeGovernedUpgradeabilityProxy {}
14 changes: 7 additions & 7 deletions tests/staking/OGNRewardsSource.t.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import "forge-std/Test.sol";
import "contracts/upgrades/OGNRewardsSourceProxy.sol";
import "contracts/OGNRewardsSource.sol";
import "contracts/upgrades/FixedRateRewardsSourceProxy.sol";
import "contracts/FixedRateRewardsSource.sol";
import "contracts/tests/MockOGN.sol";

contract OGNRewardsSourceTest is Test {
contract FixedRateRewardsSourceTest is Test {
MockOGN ogn;
OGNRewardsSource rewards;
FixedRateRewardsSource rewards;

address staking = address(0x42);
address governor = address(0x43);
Expand All @@ -15,12 +15,12 @@ contract OGNRewardsSourceTest is Test {
function setUp() public {
vm.startPrank(governor);
ogn = new MockOGN();
rewards = new OGNRewardsSource(address(ogn));
rewards = new FixedRateRewardsSource(address(ogn));

// Setup Rewards Proxy
OGNRewardsSourceProxy rewardsProxy = new OGNRewardsSourceProxy();
FixedRateRewardsSourceProxy rewardsProxy = new FixedRateRewardsSourceProxy();
rewardsProxy.initialize(address(rewards), governor, "");
rewards = OGNRewardsSource(address(rewardsProxy));
rewards = FixedRateRewardsSource(address(rewardsProxy));

// Configure Rewards
rewards.initialize(strategist, staking, uint192(100 ether)); // 100 OGN per second
Expand Down

0 comments on commit a121f8e

Please sign in to comment.