Trait shot_runtime::traits::NavProvider [−][src]
pub trait NavProvider<AssetId, Balance>: SaftRegistry<AssetId, Balance> where
AssetId: Clone, {
Show 23 methods
fn index_token_equivalent(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>;
fn asset_equivalent(
index_tokens: Balance,
asset: AssetId
) -> Result<Balance, DispatchError>;
fn relative_asset_price(
asset: AssetId
) -> Result<AssetPricePair<AssetId>, DispatchError>;
fn calculate_net_asset_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>;
fn calculate_net_liquid_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>;
fn calculate_net_saft_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>;
fn total_net_liquid_value() -> Result<U256, DispatchError>;
fn total_net_saft_value() -> Result<U256, DispatchError>;
fn total_net_asset_value() -> Result<U256, DispatchError>;
fn net_asset_value(asset: AssetId) -> Result<Balance, DispatchError>;
fn nav() -> Result<FixedU128, DispatchError>;
fn liquid_nav() -> Result<FixedU128, DispatchError>;
fn saft_nav() -> Result<FixedU128, DispatchError>;
fn asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>;
fn liquid_asset_proportion(
asset: AssetId
) -> Result<FixedU128, DispatchError>;
fn saft_asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>;
fn asset_proportions() -> Result<AssetProportions<AssetId>, DispatchError>;
fn liquid_asset_proportions(
) -> Result<AssetProportions<AssetId>, DispatchError>;
fn saft_asset_proportions(
) -> Result<AssetProportions<AssetId>, DispatchError>;
fn index_token_issuance() -> Balance;
fn asset_balance(asset: AssetId) -> Balance;
fn net_liquid_value(asset: AssetId) -> Result<Balance, DispatchError> { ... }
fn navs() -> Result<(FixedU128, FixedU128), DispatchError> { ... }
}
Expand description
Abstracts net asset value (NAV
) related calculations
Required methods
fn index_token_equivalent(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
fn index_token_equivalent(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
Calculates the amount of index tokens that the given units of the asset are worth.
This is achieved by dividing the value of the given units by the index’ NAV
(the on chain
price of a index token). The value, or volume, of all the units
is determined by
value(units) = units * Price_asset
(see: asset_net_value
), and since the NAV
represents the per token value of the index token, the equivalent number of index token is
value(units) / NAV
.
fn asset_equivalent(
index_tokens: Balance,
asset: AssetId
) -> Result<Balance, DispatchError>
fn asset_equivalent(
index_tokens: Balance,
asset: AssetId
) -> Result<Balance, DispatchError>
Calculates the units of the given asset that the given number of
index_tokens are worth.
This is the reverse of index_token_equivalent
.
This is calculated by determining the net value of the given amount of index tokens
and dividing it by the current price of the asset
:
units_asset = (NAV * index_tokens) / Price_asset
fn relative_asset_price(
asset: AssetId
) -> Result<AssetPricePair<AssetId>, DispatchError>
fn relative_asset_price(
asset: AssetId
) -> Result<AssetPricePair<AssetId>, DispatchError>
Returns the price of the asset relative to the NAV
of the index token.
This is a price pair in the form of base/quote
whereas base
is the NAV
of the index
token and quote
the current price for the asset: NAV / Price_asset
.
Note:
The price (or the value of 1 unit) of an asset secured by SAFTs is determined by the
total asset value secured by all SAFTs divided by the units held in the index, (see:
SaftRegistry::net_saft_value
)
fn calculate_net_asset_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
fn calculate_net_asset_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
Calculates the net value of the given units of the given asset.
If the asset is liquid then the net value of an asset is determined by
multiplying the share price of the asset by the given amount.: units * Price_asset
.
If the asset is secured by SAFTs then the net value is determined by the net value
of the associated SAFTRecords
, (see: SaftRegistry::net_saft_value
).
fn calculate_net_liquid_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
fn calculate_net_liquid_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
Calculates the net value of the given units of the given liquid asset.
In contrast to calculate_asset_net_value
, here it is not checked
whether the specified asset is liquid, but it is expected that this is
the case and it attempts to determine the net value using the asset’s
price feed.
fn calculate_net_saft_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
fn calculate_net_saft_value(
asset: AssetId,
units: Balance
) -> Result<Balance, DispatchError>
Calculates the net value of the given units of the given SAFT.
In contrast to calculate_asset_net_value
, here it is not checked
whether the specified asset is secured by SAFT.
The net value is then determined by SaftRegistry::net_saft_value
fn total_net_liquid_value() -> Result<U256, DispatchError>
fn total_net_liquid_value() -> Result<U256, DispatchError>
Calculates the net value of all liquid assets combined.
This is essentially the sum of the value of all liquid assets:
net_liquid_value(Asset_0) + net_liquid_value(Asset_1) ...
fn total_net_saft_value() -> Result<U256, DispatchError>
fn total_net_saft_value() -> Result<U256, DispatchError>
Calculates the net value of all SAFT combined.
This is essentially the sum of the value of all SAFTs:
net_saft_value(Asset_0) + net_saft_value(Asset_1) ...
fn total_net_asset_value() -> Result<U256, DispatchError>
fn total_net_asset_value() -> Result<U256, DispatchError>
Calculates the net asset value of all the index tokens which is equal to the sum of the total value of all assets.
Since the NAV
represents the per index token value, net value of all
index tokens is the product of the NAV
and the total supply of index
tokens: NAV * index_token_issuance
.
Or Simplified:
total_net_liquid_value + total_net_saft_value
.
fn net_asset_value(asset: AssetId) -> Result<Balance, DispatchError>
fn net_asset_value(asset: AssetId) -> Result<Balance, DispatchError>
Calculates the net value of the given asset that were contributed to the index.
The net value of an asset is determined by multiplying the share price
of the asset by the amount deposited in the index.: Price_asset * Index Deposit
Calculates the NAV
of the index token, consisting of liquid assets
and SAFT.
This the per token value (value of a single unit of index token, or its on chain price)
The the NAV is calculated by dividing the total value of all the
contributed assets by the total supply of index token:
NAV = (NAV_0 + NAV_1+ ... + NAV_n) / TotalSupply(PINT)
. where
NAV_n
is the net value of all shares of the specific asset that were
contributed to the index (see calculate_net_asset_value
). And the sum of all of them is
the total_asset_net_value
.
Note: in contrast to the index’ NAV
(which is a per token value) all NAV_n
are the
total volume of the specific asset. For example if the index consists of two liquid assets
L1
and L2
then the total formula is NAV = ( L1_units * L1_price + L2_units * L2_price) / TotalSupply(PINT)
which is also equivalent to
(L1_units * L1_price / TotalSupply(PINT)) + (L2_units * L2_price / TotalSupply(PINT))
This can be simplified to
NAV = (Liquid_net_value + SAFT_net_value) / Total Supply
,
which is also NAV = NAV_liquids + NAV_saft
.
Calculates the NAV of the index token solely for the liquid assets. This is a per token value: the value of a single unit of index token for the funds total liquid value.
Following the total_nav
calculation, the NAV_liquids
is determined
by NAV_liquids = NAV - (SAFT_net_value / TotalSupply(PINT))
Or simplified
NAV - NAV_saft
, which is Liquid_net_value / TotalSupply(PINT)
Calculates the NAV of the index token solely for the SAFT This is a per token value: the value of a single unit of index token for the funds total SAFT value.
Following liquid_nav
calculation, this is determined by:
SAFT_net_value / TotalSupply(PINT)
fn asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
fn asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
Returns the share of the asset in the total value of the index:
Asset Value / Total Net Asset Value
fn liquid_asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
fn liquid_asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
Returns the share of the liquid asset in the total value of all liquid assets in the index:
Asset Value / Liquid Net Asset Value
fn saft_asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
fn saft_asset_proportion(asset: AssetId) -> Result<FixedU128, DispatchError>
Returns the share of the asset in the total value of all SAFTs of the asset in the index:
Asset Value / SAFT Net Asset Value
fn asset_proportions() -> Result<AssetProportions<AssetId>, DispatchError>
fn asset_proportions() -> Result<AssetProportions<AssetId>, DispatchError>
Returns the proportions for each asset in the index
fn liquid_asset_proportions(
) -> Result<AssetProportions<AssetId>, DispatchError>
fn liquid_asset_proportions(
) -> Result<AssetProportions<AssetId>, DispatchError>
Returns the proportions for each liquid asset in total value of liquid assets in the index
fn saft_asset_proportions() -> Result<AssetProportions<AssetId>, DispatchError>
fn saft_asset_proportions() -> Result<AssetProportions<AssetId>, DispatchError>
Returns the proportions for each saft asset in total value of SAFTs in the index
fn index_token_issuance() -> Balance
fn index_token_issuance() -> Balance
The total supply of index tokens currently in circulation.
fn asset_balance(asset: AssetId) -> Balance
fn asset_balance(asset: AssetId) -> Balance
The amount of the given asset currently held in the index.
Provided methods
fn net_liquid_value(asset: AssetId) -> Result<Balance, DispatchError>
fn net_liquid_value(asset: AssetId) -> Result<Balance, DispatchError>
Calculates the net value of the given liquid asset.
In contrast to net_asset_value
, here it is not checked whether the
specified asset is liquid.
Returns the per token NAV
of the index token split to (liquid
, saft
).
Summed up, both of them add up to the total nav NavProvider::nav