Skip to content

Commit

Permalink
add CompoundingJoe (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
midnight-commit authored May 23, 2024
1 parent 01bbef7 commit 632e2a9
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
46 changes: 46 additions & 0 deletions contracts/strategies/mantle/moe/CompoundingJoe.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;

import "../../BaseStrategy.sol";

import "./interfaces/IJoeStaking.sol";

contract CompoundingJoe is BaseStrategy {
IJoeStaking public joeStaking;

constructor(address _joeStaking, BaseStrategySettings memory _settings, StrategySettings memory _strategySettings)
BaseStrategy(_settings, _strategySettings)
{
joeStaking = IJoeStaking(_joeStaking);
}

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

function _withdrawFromStakingContract(uint256 _amount) internal override returns (uint256 withdrawAmount) {
joeStaking.unstake(_amount);
return _amount;
}

function _pendingRewards() internal view override returns (Reward[] memory) {
(address token, uint256 amount) = joeStaking.getPendingReward(address(this));
Reward[] memory pendingRewards = new Reward[](1);
pendingRewards[0] = Reward({reward: token, amount: amount});
return pendingRewards;
}

function _getRewards() internal override {
joeStaking.claim();
}

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

function _emergencyWithdraw() internal override {
joeStaking.unstake(totalDeposits());
depositToken.approve(address(joeStaking), 0);
}
}
10 changes: 10 additions & 0 deletions contracts/strategies/mantle/moe/interfaces/IJoeStaking.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 IJoeStaking {
function getDeposit(address account) external view returns (uint256);
function getPendingReward(address account) external view returns (address, uint256);
function stake(uint256 amount) external;
function unstake(uint256 amount) external;
function claim() external;
}

0 comments on commit 632e2a9

Please sign in to comment.