Gas Improvements Launched for MINT, SWAP, REDEEM and SAVE

Derek E. Silva
mStable
Published in
3 min readJan 6, 2021

In late October 2020, mStable Lead Developer Alex Scott created two mStable Improvement Proposals (MIPs):

  • MIP-3 proposed implementing a cache to reduce the frequency of interactions with lending pools, thereby reducing gas costs in MINT, SWAP and REDEEM by 60–80% for most users.
  • MIP-4 proposed more passive methods of collecting lending market yield, reducing SAVE deposit gas costs by approximately 60%.

The mStable genesis team is happy to share that MIPs 3 and 4 were successfully deployed to Ethereum mainnet in late December 2020!

MIP-3

We can see using Tenderly’s Gas Profiler that, prior to the cache, minting mUSD cost roughly 372,000 gas. As identified, this is largely in part to lending market interaction could be greatly reduced by making keeping a percentage of assets outside the lending markets, ready for swapping. This amount of gas also required users to put far more thought into how much mUSD they were minting, and whether the cost was justifiable depending on Ethereum gas prices at the time.

Gas profile of transaction minting mUSD prior to upgrades

Now that MIP-3 has been deployed, minting mUSD requires only ~202,000 gas, representing a difference of 59% in gas costs! This is on target for the predicted gas savings beforehand, and means minting and redeeming mUSD is significantly less expensive than before.

Gas profile of transaction minting mUSD after upgrades

MIP-4

The SAVE contracts are a core part of mStable’s ecosystem, representing the manner in which USD earnings are distributed to participants. It makes sense to identify opportunities to make it less costly to deposit funds into SAVE, while also making it easier for people to pull their mUSD out when needed.

The original hypothesis was that gas savings could be roughly halved. Now that MIP-4 has been deployed, the results show gas savings exceeding the predictions originally made. Here is an example:

Prior to MIP-4 being deployed, a typical SAVE deposit used over 390,000 gas. Large portions of this were functions like _collectAndDistributeInterest, which was a big focus of the MIP.

Gas profile of transaction depositing mUSD into SAVE prior to upgrades

After MIP-4 was deployed, SAVE deposits now use ~167,000 gas. That represents a roughly 60% difference in gas, and well less than half of the gas that was used before. This opens SAVE up to users with smaller deposits than ever before, lowering the barrier to entry.

Gas profile of transaction depositing mUSD into SAVE after upgrades

Credit to Alex Scott for identifying these gas reduction opportunities, and to MTA Governors for approving them in two Snapshot polls here and here.

Join the community

App | Discord | Twitter | Website | Docs | Telegram

--

--