Skip to main content

RebaseLogic

RebaseLogic

Provides pool's rebase functions

dripSeniorDebt

function dripSeniorDebt(struct DataTypes.Storage _poolStorage) public returns (uint256)

accumulates the senior interest

Return Values

NameTypeDescription
[0]uint256_seniorDebt the senior debt

seniorDebt

function seniorDebt(struct DataTypes.Storage _poolStorage) public view returns (uint256 _seniorDebt)

returns the senior debt with up to date interest

Return Values

NameTypeDescription
_seniorDebtuint256senior debt

rebase

function rebase(struct DataTypes.Storage _poolStorage, uint256 _nav, uint256 _reserve) public

This function is used to rebase the pool's assets. It updates the senior debt and balance based on the provided NAV and reserve values.

The expected senior asset is calculated using the calcExpectedSeniorAsset function, which takes into account the current senior balance and the dripped senior debt.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.StorageA reference to the pool's storage object.
_navuint256The new net asset value of the pool.
_reserveuint256The amount of reserve in the pool.

changeSeniorAsset

function changeSeniorAsset(struct DataTypes.Storage _poolStorage, uint256 _nav, uint256 _reserve, uint256 _seniorSupply, uint256 _seniorRedeem) external

Function to change senior asset parameters.

Parameters

NameTypeDescription
_poolStoragestruct DataTypes.Storage
_navuint256The new net asset value.
_reserveuint256The new reserve amount.
_seniorSupplyuint256The new senior supply amount.
_seniorRedeemuint256The new senior redeem amount.

_rebase

function _rebase(uint256 _nav, uint256 _reserve, uint256 _seniorAsset) public pure returns (uint256, uint256)

This function re-balances the senior and junior assets according to the new ratio.

The senior asset will own all of its debt if it has more than 100% of the NAV, otherwise it will own what's left after subtracting the debt from the total senior asset.

Parameters

NameTypeDescription
_navuint256The Net Asset Value of the pool.
_reserveuint256The reserve amount in the pool.
_seniorAssetuint256The current amount of senior assets in the pool.

Return Values

NameTypeDescription
[0]uint256The new balance and debt for the senior asset after re-balancing.
[1]uint256

calcSeniorRatio

function calcSeniorRatio(uint256 seniorAsset, uint256 nav, uint256 reserve) public pure returns (uint256 seniorRatio)

calculates the senior ratio

Parameters

NameTypeDescription
seniorAssetuint256the current senior asset value
navuint256the current NAV
reserveuint256the current reserve

Return Values

NameTypeDescription
seniorRatiouint256the senior ratio

calcExpectedSeniorAsset

function calcExpectedSeniorAsset(uint256 _seniorRedeem, uint256 _seniorSupply, uint256 _seniorBalance, uint256 _seniorDebt) public pure returns (uint256 expectedSeniorAsset)

expected senior return if no losses occur

Parameters

NameTypeDescription
_seniorRedeemuint256the senior redeem amount
_seniorSupplyuint256the senior supply amount
_seniorBalanceuint256the current senior balance
_seniorDebtuint256the current senior debt

Return Values

NameTypeDescription
expectedSeniorAssetuint256the expected senior asset value

calcExpectedSeniorAsset

function calcExpectedSeniorAsset(uint256 _seniorDebt, uint256 _seniorBalance) public pure returns (uint256 seniorAsset)

calculates the expected Senior asset value

Parameters

NameTypeDescription
_seniorDebtuint256the current senior debt
_seniorBalanceuint256the current senior balance

Return Values

NameTypeDescription
seniorAssetuint256returns the senior asset value

calcSeniorTokenPrice

function calcSeniorTokenPrice(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance, uint256 _sotTotalSupply) external pure returns (uint256 seniorTokenPrice)

Calculates the price per Senior Token based on various parameters

This calculation ensures fair distribution of rewards to seniors

Parameters

NameTypeDescription
_navuint256The Net Asset Value
_reserveuint256The reserve amount
_seniorDebtuint256The senior debt amount
_seniorBalanceuint256The balance of the senior tokens
_sotTotalSupplyuint256The total supply of SOT (Senior Token)

Return Values

NameTypeDescription
seniorTokenPriceuint256The price per Senior Token

calcJuniorTokenPrice

function calcJuniorTokenPrice(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance, uint256 _jotTotalSupply) external pure returns (uint256 juniorTokenPrice)

Calculates the junior token price

Parameters

NameTypeDescription
_navuint256the NAV
_reserveuint256the reserve
_seniorDebtuint256the senior debt
_seniorBalanceuint256the senior balance
_jotTotalSupplyuint256the total supply of junior tokens

Return Values

NameTypeDescription
juniorTokenPriceuint256the junior token price in RAY decimal (10^27)

calcTokenPrices

function calcTokenPrices(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance, uint256 _jotTotalSupply, uint256 _sotTotalSupply) external pure returns (uint256 juniorTokenPrice, uint256 seniorTokenPrice)

Calculates the price of junior and senior tokens.

Parameters

NameTypeDescription
_navuint256The nav value.
_reserveuint256The reserve value.
_seniorDebtuint256The senior debt value.
_seniorBalanceuint256The senior balance value.
_jotTotalSupplyuint256Total supply of JOT tokens.
_sotTotalSupplyuint256Total supply of SOT tokens.

Return Values

NameTypeDescription
juniorTokenPriceuint256Price of the junior token.
seniorTokenPriceuint256Price of the senior token.

_calcSeniorTokenPrice

function _calcSeniorTokenPrice(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance, uint256 _sotTotalSupply) internal pure returns (uint256 seniorTokenPrice)

internal function to calculate the senior token price

Parameters

NameTypeDescription
_navuint256the NAV
_reserveuint256the reserve
_seniorDebtuint256the senior debt
_seniorBalanceuint256the senior balance
_sotTotalSupplyuint256the token supply

Return Values

NameTypeDescription
seniorTokenPriceuint256the senior token price in RAY decimal (10^27)

_calcJuniorTokenPrice

function _calcJuniorTokenPrice(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance, uint256 _jotTotalSupply) internal pure returns (uint256 juniorTokenPrice)

internal function to calculate the junior token price

Parameters

NameTypeDescription
_navuint256the NAV
_reserveuint256the reserve
_seniorDebtuint256the senior debt
_seniorBalanceuint256the senior balance
_jotTotalSupplyuint256the token supply

Return Values

NameTypeDescription
juniorTokenPriceuint256the junior token price in RAY decimal (10^27)

calcJuniorRatio

function calcJuniorRatio(uint256 _nav, uint256 _reserve, uint256 _seniorDebt, uint256 _seniorBalance) external pure returns (uint256 juniorRatio_)

Calculates junior ratio based on NAV, reserve, senior debt and senior balance. Uses safe arithmetic operations to prevent overflows or underflows.

Parameters

NameTypeDescription
_navuint256The Net Asset Value of the portfolio.
_reserveuint256The amount of funds that are currently in the reserve.
_seniorDebtuint256The total debt owed by senior holders.
_seniorBalanceuint256The balance of assets held by senior holders.

Return Values

NameTypeDescription
juniorRatio_uint256The calculated junior ratio.