Skip to content

Commit

Permalink
Merge pull request mushroomsforest#3 from alsco77/mstable
Browse files Browse the repository at this point in the history
fix: Paths to mint want corrected
  • Loading branch information
sajanrajdev committed Jun 4, 2021
2 parents 94385ef + 0a7ad99 commit c21f3ae
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import "../BaseStrategy.sol";
/// - earns APY on staked MTA
/// - boost rewards in vault deposits
/// - vote on proposals on the mStableDAO (after the next version of staking comes that allows vote delegation)
contract StrategyMStableVaultBase is BaseStrategy {
abstract contract StrategyMStableVaultBase is BaseStrategy {
using SafeERC20Upgradeable for IERC20Upgradeable;
using SafeMathUpgradeable for uint256;

Expand All @@ -40,6 +40,7 @@ contract StrategyMStableVaultBase is BaseStrategy {

address public constant mta = 0xa3BeD4E1c75D00fa6f4E5E6922DB7261B5E9AcD2; // MTA token
address public constant weth = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2; // Weth Token, used for mta -> weth -> lpComponent route
address public constant mBTC = 0x945Facb997494CC2570096c74b5F66A3507330a1; // mBTC token

uint256 public govMta; // % of MTA returned to VoterProxy

Expand Down Expand Up @@ -94,7 +95,11 @@ contract StrategyMStableVaultBase is BaseStrategy {
withdrawalFee = _feeConfig[2];
govMta = _feeConfig[3];

// For FpMbtcHbtc just approve lp to want
_safeApproveHelper(lpComponent, want, type(uint256).max);
// For imBTC, approve lp to mBTC, then mBTC to want (imBTC)
_safeApproveHelper(lpComponent, mBTC, type(uint256).max);
_safeApproveHelper(mBTC, want, type(uint256).max);
}

/// ===== View Functions =====
Expand Down Expand Up @@ -242,10 +247,7 @@ contract StrategyMStableVaultBase is BaseStrategy {
/// @dev Mints mStable Asset using a specified input and amount
/// @param _input Address of asset to be used in the mint
/// @param _amount Units of _input to mint with
function _mintWant(address _input, uint256 _amount) internal virtual {
// minOut = amountIn * 0.8
IMStableAsset(want).mint(_input, _amount, _amount.mul(80).div(100), address(this));
}
function _mintWant(address _input, uint256 _amount) internal virtual;

/// @dev Processes performance fees for a particular token
/// @param _token Address of the token to process
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@ pragma solidity ^0.6.11;
pragma experimental ABIEncoderV2;

import "./StrategyMStableVaultBase.sol";
import "interfaces/mStable/IMStableAsset.sol";

/// @title StrategyMStableVaultFpMbtcHbtc
/// @author mStable
/// @notice Strategy utilising mStable's mBTC Feeder Pool with HBTC
contract StrategyMStableVaultFpMbtcHbtc is StrategyMStableVaultBase {

/// @dev Mints mStable Asset using a specified input and amount
/// @param _input Address of asset to be used in the mint
/// @param _amount Units of _input to mint with
function _mintWant(address _input, uint256 _amount) internal override {
// minOut = amountIn * 0.8
IMStableAsset(want).mint(_input, _amount, _amount.mul(80).div(100), address(this));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@ pragma solidity ^0.6.11;
pragma experimental ABIEncoderV2;

import "./StrategyMStableVaultBase.sol";
import "interfaces/mStable/IMStableImbtc.sol";

/// @title StrategyMStableVaultImbtc
/// @author mStable
/// @notice Strategy utilising mStable interest bearing BTC
contract StrategyMStableVaultImbtc is StrategyMStableVaultBase {

/// @dev Mints mStable Asset using a specified input and amount
/// @param _input Address of asset to be used in the mint
/// @param _amount Units of _input to mint with
function _mintWant(address _input, uint256 _amount) internal override {
// minOut = amountIn * 0.8
uint256 minted = IMStableAsset(mBTC).mint(_input, _amount, _amount.mul(80).div(100), address(this));
IMStableImbtc(want).depositSavings(minted);
}
}
8 changes: 8 additions & 0 deletions interfaces/mStable/IMStableImbtc.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

import {IERC20} from "../erc20/IERC20.sol";

abstract contract IMStableImbtc is IERC20 {
function depositSavings(uint256 _amount) external virtual returns (uint256 creditsIssued);
}

0 comments on commit c21f3ae

Please sign in to comment.