This repo shows an example of integrating with the mStable protocol. The target network is Ropsten but this could be amended to target Mainnet.
An introduction to the mStable protocol is available that shows what mStable is and how you can use it.
By walking through this repo you'll be able to
- Write a basic smart contract that integrates with mStable
- Mint, deposit and redeem mUSD from your application
- Node.js v10.22.0 (you may wish to use nvm)
The mStable protocol contracts are available as an npm module that may be included in your projects.
npm install @mstable/protocol --save-dev
yarn add @mstable/protocol --dev
mStable Assets (mAssets) are built to be the solid base layer in DeFi. The first mAsset, mUSD
, comprises of USDT
, TUSD
, DAI
and USDC
. mAssets can be minted with any of the underlying and used as a trustworthy base layer with which to, for example, collateralise synthetic assets or loans. Read more about mAssets.
mAssets produce a native yield through the SAVE contract. Yield is derived from AMM swap trades and lending markets. Underlying assets can be redeemed at any time. mStable aims to be a foundational layer for DeFi applications.
Essentially anything that builds on top of or extends the mStable protocol, or simply utilises mAssets to their potential. We would also welcome any application utilising the system token MTA.
Some ideas to build on top of mStable:
- A no loss lottery (e.g. PoolTogether)
- A derivative using mStable SAVE or mUSD (e.g. CHAI)
- A derivative using mAssets as the settlement layer
- Deriving a yield for any application that accepts DAI, USDT, TUSD or USDC
- Utilising mStable MINT/SWAP as part of a trading bot
- An interest bearing stablecoin product for custodied stablecoins (e.g. a CEX)
Some ideas to utilise mAssets or MTA:
- Using mAssets to collateralise synthetic instruments
- An application that uses mUSD as collateral
- An application that uses MTA as collateral
- An index fund using MTA or mStable, where the SAVE product contributes to the yield
Have a look at the PoolWithMStable
contract for an example on how to integrate the mStable protocol. This represents a basic integration and more advanced developers may wish to go straight to the contract documentation or the smart contracts on Github.
Note that the mStable contracts are compiled against 0.5.16
of solidity.
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.
See example here
mAssets (e.g. mUSD) may be deposited into the relevant SAVE contract to earn a yield. Once deposited, mAsset is held on the SAVE contract but may be redeemed at any time. Balances are represented internally through credits, but these do not have an ERC20 token attached.
See deposit example here and withdraw here
An mAsset can be redeemed for any one of its underlying bAssets, providing that:
- the bAsset being redeemed has sufficient liquidity
- redeeming the bAsset does not push another bAsset beyond its maximum weight
See example here