Introduction
General information about mStable can be found in the general mStable Docs. These Docs here are for Developers and give an overview of the smart contracts.

Smart Contract Dependency Tree

Ethereum Mainnet
Polygon

Smart Contract Overview

mStable's smart contracts can be divided into 5 categories that serve different purposes:
  • mAssets (e.g. mUSD and mBTC) are meta Assets that combine 2 or more assets into a new one. Such as DAI, USDT, USDC and sUSD are being composed into mUSD. mAsset contracts hold the logic for minting, swapping the underlying, and redeeming mAssets back to the underlying.
  • imAssets (e.g. imUSD and imBTC) are interest-bearing meta Assets, that earn interest from third-party lending platforms and swaps. In the front-end, this is denoted as the SAVE. imAssets smart contracts are used for depositing mAssets into SAVE and minting imAssets and also redeeming back to mAssets.
  • Feeder Pools (e.g. mUSD/alUSD) are 50/50 AMM pool that consists of one mAsset and one other similar asset. This has to be an asset that is not part of the mAsset basket but holds the same price. Feeder Pool contracts allow to deposit, redeem and swap.
  • Vaults are the contracts for staking Feeder Pool tokens or imAssets in order to earn and claim MTA rewards. The tokens in the Vault are non-transferable but tokens can be staked and unstaked at any time.
  • Save Wrapper is a utility smart contract that allows combining a multistep process into one smart contract call. E.g. Deposit into SAVE and stake with one single call.
The mStable contracts can be found on Github here.

Price function: Stableswap AMM

  • mAssets price function is based on the Stableswap AMM invariant. The price for minting, redeeming, and swapping is determined by that formula. It does not use any oracles to price the assets.
  • The implementation is similar to Curve's Stableswap: https://curve.fi/files/stableswap-paper.pdf.
  • An adjustment was made to accommodate the min and max weights of each asset. In case a mint, swap, or redeem will result in the weights being out of bound, the transaction would revert. However, given the design of the AMM, this would practically not be the case, since arbitrage would occur much sooner than those limits could be hit.
Last modified 2mo ago