MINT

➡️ How to mint mAssets like mUSD

Minting mAssets

mAssets represent a basket of underlying bAssets and that be minted using any of the bAssets that make up the basket. Developers may mint mAssets using a single bAsset or a combination of more than one.

To mint, interact with the mAsset contract. You can discover the deployed addresses for the mAsset contract here. In order to execute the mint:

  • choose a bAsset to mint with, or select optimally with suggestMintAsset

  • approve the mAsset address to spend the input asset

  • call mint to execute

You may wish to use the IMasset Interface in your contracts.

Minting with a bAsset cannot push this asset past its maximum weight.

Masset

mint

Input

Output

Estimated gas cost

bAsset

mAsset

~140-280k

/**
* @dev Mint an mAsset (e.g. mUSD) with a single bAsset (e.g. USDC)
* @param _bAsset bAsset to mint with
* @param _bAssetQuanity The amount of bAsset
* @return massetMinted The amount of mAsset that was minted
*/
function mint(
address _basset,
uint256 _bassetQuantity
)
external returns (uint256 massetMinted);

mintTo

Input

Output

Estimated gas cost

bAsset

mAsset

~140-280k

/**
* @dev Mint an mAsset (e.g. mUSD) with a single bAsset (e.g. USDC)
* and transfer to a recipient
* @param _bAsset bAsset to mint with
* @param _bAssetQuanity The amount of bAsset
* @param _recipient The address to transfer minted the minted mAsset to
* @return massetMinted The amount of mAsset that was minted
*/
function mintTo (
address _basset,
uint256 _bassetQuantity,
address _recipient
)
external returns (uint256 massetMinted);

mintMulti

Input

Output

Estimated gas cost

bAssets

mAsset

20k + ~120-250k per bAsset

/**
* @dev Mint an mAsset (e.g. mUSD) with a multiple bAssets (e.g. USDC & USDT)
* @param _bAsset bAssets to mint with
* @param _bAssetQuanity The amount of bAssets
* @param _recipient The address to transfer the minted mAsset to
* @return massetMinted The amount of mAsset that was minted
*/
function mintMulti(
address[] calldata _bAssets,
uint256[] calldata _bassetQuantity,
address _recipient
)
external returns (uint256 massetMinted);

The mStable Helper contract provides the suggestMintAsset function to help integrations verify that a mAsset exists and suggests a bAsset to mint with. The mStable Helper deployed contract addresses may be discovered here.

MStableHelper

See Deployed addresses for the current address of the MStableHelper.

NB: This helper is not optimised for gas

suggestMintAsset

The mStable Helper contract provides the suggestMintAsset function to help integrations select the most optimal bAsset to mint with. The returned bAsset is optimal in terms of price and availability.

/**
* @dev Returns a valid bAsset with which to mint
* @param _mAsset Masset addr
* @return valid bool
* @return string message
* @return address of bAsset to mint
*/
function suggestMintAsset(
address _mAsset
)
external
view
returns (
bool,
string memory,
address
);