interest accrual factors (and not interest rates) and where it is assumed that one full year consists of 31622400 seconds (366 days with 86400 seconds each).
interest accrual factors (and not interest rates) and where it is assumed that one full year consists of 31622400 seconds (366 days with 86400 seconds each).
interestPerSecond to interestToMaturity
imaturity={(isecond)T−t1e18if t<Telse
where
t
is the current block.timestamp and
T
is the collateral asset’s maturityboth expressed in seconds.
normalDebt to debt
d=1e18dn∗rate
debt to normalDebt
dn={rated∗1e18∞ifrate>0else
where it is assumed that
rate≥1e18
.
The following correction has to be performed on the resulting amount
dn
to avoid rounding errors due to precision loss:
dn={dn+1dnif 1e18dn∗rate<delse
normalDebt to debtAtMaturity
dm=dn118rate+imaturity−118
collateralizationRatio
r={dp∗c∞ifd>0else
Max.debt for a given collateralizationRatio and collateral amount
dmax={rp∗c∞ifr>0else
Min. collateral for a given collateralizationRatio and debt amount
cmin={pr∗d∞ifp>0else
Leverage Formulas
Min. collateralizationRatio for a levered deposit
rmin=1e181e18p∗xf→uxu→c
where
xf→u
and
xu→c
are the FIAT/underlying and underlying/collateral exchange rates including price impact and slippage.
Max. collateralizationRatio for a levered deposit
rmax={dp∗(c+1e18xu→cu)∞if d>0else
where
u
is the deposited underlier amount and
xuc
is the underlying/collateral exchange rate including price impact and slippage.
flashloan amount for a levered deposit
f=1e18r−1e18pxf→uxu→cp∗(c+1e18xu→cu)−rd
where
u
is the deposited underlier amount and
xf→u
and
xu→c
are the FIAT/underlying and underlying/collateral exchange rates including price impact and slippage.
Min. collateralizationRatio for a levered withdrawal
rmin={dp(c−Δc)∞ifΔc<c AND d>0else
where
c
and
d
are the position collateral and debt, and
Δc
is the withdrawn collateral amount.
Max. collateralizationRatio for a levered withdrawal
rmax={d−Δcxc→uxu→fp(c−Δc)∞ifΔc<c AND d>0else
where
c
is the position collateral and
Δc
the withdrawn collateral amount.
flashloan amount for a levered withdrawal
f=⎩⎨⎧d−rp(c−Δc)drevertifc>Δcif elsec=Δcelse
where
c
and
d
are the position collateral and debt, and
Δc
is the withdrawn collateral amount. It is thus assumed that
Δc≤c
and
d>0
as the computation would otherwise yield an invalid result.
Estimated underlier for a levered withdrawal
w=1e18(Δc−xc→uxu→ff∗1e181e18)xc→u
where
Δc
is the withdrawn collateral amount,
f
is the flashloan amount used for the withdrawal, and
xu→f
and
xc→u
are the underlying/FIAT and collateral/underlying exchange rates including price impact and slippage.
Note that for a collateral asset beyond its maturity the formula remains intact with the difference that the input underlying/collateral exchange rate is fixed, i.e.
xu→c=1e18
.
profitAtMaturity for a levered deposit
g=w−u
where
w
is the estimated underlier amount withdrawn at maturity (i.e. with an input of
xcu=1e18
and
Δc=c
) and
u
is the deposited underlier amount. It is further assumed that the collateral token can be redeemed for underlier tokens at a rate of