Skip to content

Commit

Permalink
add CompoundingMoe (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
midnight-commit authored May 23, 2024
1 parent 081d421 commit 01bbef7
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
50 changes: 50 additions & 0 deletions contracts/strategies/mantle/moe/CompoundingMoe.sol
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 contracts/strategies/mantle/moe/interfaces/IMoeStaking.sol
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;
}
5 changes: 5 additions & 0 deletions contracts/strategies/mantle/moe/interfaces/IStableMoe.sol
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);
}

0 comments on commit 01bbef7

Please sign in to comment.