ZivoeMath.sol

Mathematics for Yield Distributions

Introduction

This contract facilitates mathematics, intended solely for the YDL.

Note: This contract is deployed and tracked via ZivoeYDL, see ZivoeYDL.sol and for further information on the derivation of the equations, see

State Variables

TypeNameDescription

uint256

BIPS

Private constant, 10000

uint256

WAD

Private constant, 10**18

uint256

RAY

Private constant, 10**27

Sections

Read Functions

  • ema() - Calculates the current EMA (exponential moving average).

  • juniorProportion() - Calculates proportion of yield attributable to junior tranche.

  • seniorProportion() - Calculates proportion of yield distributble which is attributable to the senior tranche.

  • seniorProportionBase() - Calculates proportion of yield attributed to senior tranche (no extenuating circumstances).

  • seniorProportionShortfall() - Calculates proportion of yield attributed to senior tranche (shortfall occurence).

  • yieldTarget() - Calculates amount of annual yield required to meet target rate for both tranches.

Read Functions

ema()

Calculates the current EMA (exponential moving average).

function ema(
    uint256 bV, 
    uint256 cV, 
    uint256 N
) external pure returns (uint256 eV);
TypeNameDescription

uint256

bV

The base value (typically an EMA from prior calculations).

uint256

cV

The current value, which is factored into bV.

uint256

N

Number of steps to average over.

Returns

TypeNameDescription

uint256

eV

EMA-based value given prior and current conditions.

juniorProportion()

Calculates proportion of yield attributable to junior tranche.

function juniorProportion(
    uint256 eSTT,
    uint256 eJTT, 
    uint256 sP,
    uint256 Q
) external pure returns (uint256 jP);
TypeNameDescription

uint256

eSTT

ema-based supply of zSTT (units = WEI)

uint256

eJTT

ema-based supply of zJTT (units = WEI)

uint256

sP

Proportion of yield attributable to seniors (units = RAY)

uint256

Q

senior to junior tranche target ratio (units = BIPS)

Returns

TypeNameDescription

uint256

jP

Yield attributable to junior tranche in RAY.

seniorProportion()

Calculates proportion of yield distributable which is attributable to the senior tranche.

function seniorProportion(
    uint256 yD,
    uint256 yT,
    uint256 eSTT, 
    uint256 eJTT, 
    uint256 Y, 
    uint256 Q, 
    uint256 T
) external pure returns (uint256 sP);
TypeNameDescription

uint256

yD

yield distributable (units = WEI)

uint256

yT

ema-based yield target (units = WEI)

uint256

eSTT

ema-based supply of zSTT (units = WEI)

uint256

eJTT

ema-based supply of zJTT (units = WEI)

uint256

Y

target annual yield for senior tranche (units = BIPS)

uint256

Q

multiple of Y (units = BIPS)

uint256

T

# of days between distributions (units = integer)

Returns

TypeNameDescription

uint256

sP

Proportion of yD attributable to senior tranche.

seniorProportionBase()

Calculates proportion of yield attributed to senior tranche (no extenuating circumstances).

function seniorProportionBase(
    uint256 yD, 
    uint256 eSTT, 
    uint256 Y, 
    uint256 T
) public pure returns (uint256 sPB);
TypeNameDescription

uint256

yD

yield distributable (units = WEI)

uint256

eSTT

ema-based supply of zSTT (units = WEI)

uint256

Y

target annual yield for senior tranche (units = BIPS)

uint256

T

# of days between distributions (units = integer)

Returns

TypeNameDescription

uint256

sPB

Proportion of yield attributed to senior tranche in RAY.

seniorProportionShortfall()

Calculates proportion of yield attributed to senior tranche (shortfall occurence).

function seniorProportionShortfall(
    uint256 eSTT, 
    uint256 eJTT, 
    uint256 Q
) public pure returns (uint256 sPS);
TypeNameDescription

uint256

eSTT

ema-based supply of zSTT (units = WEI)

uint256

eJTT

ema-based supply of zJTT (units = WEI)

uint256

Q

multiple of Y (units = BIPS)

Returns

TypeNameDescription

uint256

sPS

Proportion of yield attributed to senior tranche in RAY.

yieldTarget()

Calculates amount of annual yield required to meet target rate for both tranches.

function yieldTarget(
    uint256 eSTT,
    uint256 eJTT, 
    uint256 Y, 
    uint256 Q, 
    uint256 T
) public pure returns (uint256 yT);
TypeNameDescription

uint256

eSTT

ema-based supply of zSTT (units = WEI)

uint256

eJTT

ema-based supply of zJTT (units = WEI)

uint256

Y

target annual yield for senior tranche (units = BIPS)

uint256

Q

multiple of Y (units = BIPS)

uint256

T

# of days between distributions (units = integer)

Returns

TypeNameDescription

uint256

yT

yield target for the senior and junior tranche combined.

Last updated

Zivoe Finance - Official Documentation