ScopeLift / reimbursement-tokens

0 stars 0 forks source link

YieldSpace Contracts Discovery #24

Open apbendi opened 3 years ago

apbendi commented 3 years ago

Investigate the YieldSpace v2 contracts.

Key things to understand:

High level frontend spec:

Bold elements are those most likely to touch the YieldSpace contracts

mds1 commented 3 years ago

General notes

Creating Pools

Adding/Removing Liquidity

Swaps

Effective interest rate

Assuming effective interest rate is calculated as follows, but let me know if this is incorrect:

// At maturity, the token is expected to be worth `percentToAccrue` more than it is now
const percentToAccrue = (maturityValue - currentValue) / currentValue;

// Number of seconds over which that value increase will occur
const timeRemaining = riToken.maturity - (new Date().getTime() / 1000);

// Convert that interest rate into an APR (pretty sure this gives APR, not APY,
// since there's no compounding considered here)
const effectiveInterestRateAPR = percentToAccrue * secondsPerYear / timeRemaining

If so, we get maturityValue based on the riToken target exchange rate, currentValue by getting a quote from the pool (what quote inputs?), and the riToken's maturity is read from its contract