Smart contract architecture
When a user makes a deposit, their funds are transferred to the
MoneyMarketcontract owned by the
DInterestcontract, which are then put to work in the underlying yield protocol. The user receives an ERC-721 NFT that represents the ownership of the deposit, which can be transferred.
Each deposit has a maturity date, after which the deposit NFT can be used to withdraw the deposited principal plus the promised fixed-rate interest. Before the maturity date, the user can also withdraw a deposit, though the fixed-rate interest would be forfeit, and an additional withdrawal fee would be applied. The user can choose to only withdraw a portion of a deposit.
The user may topup a deposit before reaching its maturity date, adding more principal to the deposit and earning more fixed-rate interest (albeit likely at a different fixed-rate). After a deposit is mature, the user can roll it over to create a new deposit using the principal + interest of the old deposit.
The NFT corresponding to a deposit is not burnt at any point, to preserve the potential artistic value of the metadata attached.
When a user buys some yield tokens of a particular deposit, the funds are transferred to
MoneyMarketand deposited into the underlying yield protocol. The user will earn the future floating-rate interest generated by the portion of the deposit's principal whose debt is funded by the YT plus the funds used for purchasing the YT. For instance, if a 100 DAI deposit has 10 DAI of debt, then buying yield tokens using 5 DAI will allow you to earn interest on (5 / 10) * 100 + 5 = 55 DAI.
The interest payout is triggered whenever a portion of the deposit is withdrawn, or when someone manually triggers a payout using
Money market is an abstract interface 88mphs uses to support different underlying yield protocols. Each protocol has its corresponding money market, for instance a
DInterestpool using Aave to generate interest will use
AaveMarketas its money market contract.
Money markets store all funds deposited into a
MPHMintercontract is in charge of the minting of MPH tokens. 88mph mints MPH tokens to reward users who make deposits or purchase YTs. The governance treasury and the developer funds also receive MPH rewards any time new MPH is minted.
Whenever a user makes a deposit or purchases YTs,
DInterestmakes a call to
MPHMinterto mint MPH rewards. The reward could be vested using
Vesting02, or be distributed using