-
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
081d421
commit 01bbef7
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
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,50 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.13; | ||
|
||
import "../../BaseStrategy.sol"; | ||
|
||
import "./interfaces/IMoeStaking.sol"; | ||
import "./interfaces/IStableMoe.sol"; | ||
|
||
contract CompoundingMoe is BaseStrategy { | ||
IMoeStaking public moeStaking; | ||
|
||
constructor(address _moeStaking, BaseStrategySettings memory _settings, StrategySettings memory _strategySettings) | ||
BaseStrategy(_settings, _strategySettings) | ||
{ | ||
moeStaking = IMoeStaking(_moeStaking); | ||
} | ||
|
||
function _depositToStakingContract(uint256 _amount, uint256) internal override { | ||
depositToken.approve(address(moeStaking), _amount); | ||
moeStaking.stake(_amount); | ||
} | ||
|
||
function _withdrawFromStakingContract(uint256 _amount) internal override returns (uint256 withdrawAmount) { | ||
moeStaking.unstake(_amount); | ||
return _amount; | ||
} | ||
|
||
function _emergencyWithdraw() internal override { | ||
moeStaking.unstake(totalDeposits()); | ||
depositToken.approve(address(moeStaking), 0); | ||
} | ||
|
||
function _pendingRewards() internal view override returns (Reward[] memory) { | ||
(address[] memory tokens, uint256[] memory amounts) = | ||
IStableMoe(moeStaking.getSMoe()).getPendingRewards(address(this)); | ||
Reward[] memory pendingRewards = new Reward[](tokens.length); | ||
for (uint256 i = 0; i < tokens.length; i++) { | ||
pendingRewards[i] = Reward({reward: tokens[i], amount: amounts[i]}); | ||
} | ||
return pendingRewards; | ||
} | ||
|
||
function _getRewards() internal override { | ||
moeStaking.claim(); | ||
} | ||
|
||
function totalDeposits() public view override returns (uint256) { | ||
return moeStaking.getDeposit(address(this)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
contracts/strategies/mantle/moe/interfaces/IMoeStaking.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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity 0.8.13; | ||
|
||
interface IMoeStaking { | ||
function getSMoe() external view returns (address); | ||
function getDeposit(address user) external view returns (uint256); | ||
function stake(uint256 amount) external; | ||
function unstake(uint256 amount) external; | ||
function claim() external; | ||
} |
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,5 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
interface IStableMoe { | ||
function getPendingRewards(address account) external view returns (address[] memory, uint256[] memory); | ||
} |