Integration guide
Last updated
Last updated
To interact with an 88mph pool, you will mostly call the pool's DInterest contract. You can find the source code on .
Creating a deposit has two steps:
Give ERC-20 approval to the DInterest contract, the amount of which is at least the deposit amount.
Call DInterest::deposit()
Once an account makes a deposit, the account will also receive vested MPH rewards.
Withdrawing a deposit has the following steps:
Call DInterest::withdraw()
Set virtualTokenAmount
to type(uint256).max
to withdraw all funds from the deposit, otherwise set it to some proportion of getDeposit(depositID).virtualTokenTotalSupply
to do a partial withdrawal. An easy way to determine the value for this field is that after maturation, virtualTokenAmount
equals the amount of underlying tokens that will be withdrawn.
Set early
to true
if withdrawing before maturation, false
if withdrawing after maturation.
If you want to know the interest you'll earn on a 100 DAI deposit for 1 year, the function call would look like calculateInterestAmount(100*1e18, 31556952)
where 100*1e18 is 100 DAI in wei and 31556952 is the number of seconds in a year.
The vesting streams are represented using 1-indexed ERC-721 NFTs, so that they are easily transferrable.
In order to withdraw vested MPH, you need to call Vesting02::withdraw(uint256 vestID)
. You need the index of a vesting NFT, vestID
, in order to withdraw the MPH. You can obtain this value using the Vesting02::depositIDToVestID
mapping using the pool address and deposit ID.
Buying yield tokens takes two steps:
Approve deposit tokens to the DInterest contract, the amount of which should be at least the cost of the bond.
Call DInterest::fund()
with the ID of the deposit to buy yield tokens from and the amount to pay.
Note that if the amount to pay is greater than the value of the available yield tokens, all of the available yield tokens will be purchased.
Notes:
Function on the DInterest contract to call can be found .
The returned value is the amount of DAI, in wei, you'd earn in fixed-rate interest before protocol fees are taken into account. To account for the fee, you'll need to call getInterestFeeAmount()
on the .
Once you have both the interest amount (before fees) and the fee amount, subtract the two values to get the amount of interest earned by the depositor after fees. Divide that value by the original deposit amount to get the APR (some additional math is needed for deposit length of less than a year). Here is of how we do this in our frontend, which calculates the APR for a 10,000 token deposit for 30 days.
Each deposit yields vested MPH rewards to the user. This is handled by the . The vesting is linear and continuous, and is done over the deposit period. If a deposit is withdrawn earlier than the maturation date, the remaining vested rewards are forfeited.
We offer a REST API for fetching basic info of 88mph pools. The endpoint is at . The only supported method is GET.
Read
The mainnet contract addresses are available here and the rinkeby here /
Rinkeby subgraph: