-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f3e749
commit 81e3e8e
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
contracts/strategies/arbitrum/dopex/DopexStrategyForSA.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
12
contracts/strategies/arbitrum/dopex/interfaces/IMultiRewards.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |