Skip to content

Commit

Permalink
add DopexStrategyForSA (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
midnight-commit authored Dec 18, 2023
1 parent 5f3e749 commit 81e3e8e
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
51 changes: 51 additions & 0 deletions contracts/strategies/arbitrum/dopex/DopexStrategyForSA.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// SPDX-License-Identifier: MIT

pragma solidity 0.8.13;

import "../../BaseStrategy.sol";
import "./interfaces/IMultiRewards.sol";

contract DopexStrategyForSA is BaseStrategy {
IMultiRewards immutable rewarder;

constructor(
address _stakingContract,
BaseStrategySettings memory _baseStrategySettings,
StrategySettings memory _strategySettings
) BaseStrategy(_baseStrategySettings, _strategySettings) {
rewarder = IMultiRewards(_stakingContract);
}

function _depositToStakingContract(uint256 _amount, uint256) internal override {
depositToken.approve(address(rewarder), _amount);
rewarder.stake(_amount);
}

function _withdrawFromStakingContract(uint256 _amount) internal override returns (uint256 _withdrawAmount) {
rewarder.withdraw(_amount);
return _amount;
}

function _pendingRewards() internal view override returns (Reward[] memory) {
Reward[] memory pendingRewards = new Reward[](supportedRewards.length);
for (uint256 i; i < pendingRewards.length; i++) {
address reward = supportedRewards[i];
uint256 pending = rewarder.earned(address(this), reward);
pendingRewards[i] = Reward({reward: reward, amount: pending});
}
return pendingRewards;
}

function _getRewards() internal override {
rewarder.getReward();
}

function totalDeposits() public view override returns (uint256) {
return rewarder.balanceOf(address(this));
}

function _emergencyWithdraw() internal override {
rewarder.exit();
depositToken.approve(address(rewarder), 0);
}
}
12 changes: 12 additions & 0 deletions contracts/strategies/arbitrum/dopex/interfaces/IMultiRewards.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

interface IMultiRewards {
function balanceOf(address account) external view returns (uint256);
function rewardTokens(uint256 index) external view returns (address);
function earned(address account, address reward) external view returns (uint256);
function getReward() external;
function stake(uint256 amount) external;
function withdraw(uint256 amount) external;
function exit() external;
}

0 comments on commit 81e3e8e

Please sign in to comment.