-
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
01bbef7
commit 632e2a9
Showing
2 changed files
with
56 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,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
10
contracts/strategies/mantle/moe/interfaces/IJoeStaking.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 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; | ||
} |