Formulas
Last updated
Last updated
interestPerYear
to interestPerSecond
with both and 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).
Find a sample calculation here.
interestPerSecond
to interestPerYear
with both and 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
where is the current block.timestamp
and is the collateral assetโs maturity
both expressed in seconds.
normalDebt
to debt
debt
to normalDebt
normalDebt
to debtAtMaturity
collateralizationRatio
debt
for a given collateralizationRatio
and collateral
amountcollateral
for a given collateralizationRatio
and debt
amountcollateralizationRatio
for a levered depositcollateralizationRatio
for a levered depositflashloan
amount for a levered depositcollateralizationRatio
for a levered withdrawalcollateralizationRatio
for a levered withdrawalflashloan
amount for a levered withdrawalunderlier
for a levered withdrawalprofitAtMaturity
for a levered deposityieldToMaturity
for a levered deposityieldToMaturity
to annualYield
amountOut
for a max slippagePercentage
where it is assumed that .
The following correction has to be performed on the resulting amount to avoid rounding errors due to precision loss:
where and are the FIAT/underlying and underlying/collateral exchange rates including price impact and slippage.
where is the deposited underlier amount and is the underlying/collateral exchange rate including price impact and slippage.
where is the deposited underlier amount and and are the FIAT/underlying and underlying/collateral exchange rates including price impact and slippage.
where and are the position collateral and debt, and is the withdrawn collateral amount.
where is the position collateral and the withdrawn collateral amount.
where and are the position collateral and debt, and is the withdrawn collateral amount. It is thus assumed that and as the computation would otherwise yield an invalid result.
where is the withdrawn collateral amount, is the flashloan amount used for the withdrawal, and and 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. .
where is the estimated underlier amount withdrawn at maturity (i.e. with an input of and ) and is the deposited underlier amount. It is further assumed that the collateral token can be redeemed for underlier tokens at a rate of .
where is the deposited underlier amount and is the estimated profitAtMaturity
.
where is the estimated amountOut
without accounting for slippage.