Fund
It is a utility struct to easily know how many shares to issue/burn based on an underlying amount.
Structs
Account
shares - The amount of shares issued based on the underlying amount.
underlying - The amount of assets in the fund.
Interface
empty
Creates an empty Fund.
@return Fund.
underlying
Returns the amount of underlying in the self
.
@param self: A Fund.
@return u64. The amount of underlying.
shares
Returns the amount of shares in the self
.
@param self: A Fund.
@return u64. The amount of shares.
to_shares
Returns the number of shares the self
would issue if more underlying
was deposited in it.
@param self: A Fund.
@param underlying: The amount of underlying that the caller intends to add to the
self
.@param round_up: If true we would round up the returned value.
@return u64. The amount of shares the fund would issue.
to_underlying
Returns the number of shares the self
would issue if more underlying
was deposited in it.
@param self: A Fund.
@param shares: The amount of shares that the caller intends to burn.
@param round_up: If true we would round up the returned value.
@return u64. The amount underlying the fund would release.
sub_shares
This function reduces the amount of underlying and shares in the fund.
@param self: A Fund.
@param shares: The amount of shares that the caller intends to burn.
@param round_up: If true we would round up the returned value.
@return u64. The amount underlying the
shares
were worth.
add_underlying
Adds underlying
to the self
and returns the additional shares issued. This function increases the amount of underlying and shares in the fund.
@param self: A Fund.
@param underlying: The amount of underlying to deposit in the
self
.@param round_up: If true we would round up the returned value.
@return u64. The amount of shares the fund issued.
sub_underlying
Removes underlying
from the self
and returns the burned shares. This function reduces the amount of underlying and shares in the fund.
@param self: A Fund.
@param underlying: The amount of underlying to remove from the
self
.@param round_up: If true we would round up the returned value.
@return u64. The amount of shares the fund burned.
add_profit
Adds profits to the underlying. This is to add profits to the fund.
@param self: A Fund.
@param profit: The amount of underlying to add as profit to
self.underlying
.
Last updated