Struct pallet_asset_index::pallet::Pallet [−][src]
pub struct Pallet<T>(_);
Expand description
The pallet implementing the on-chain logic.
Implementations
Callable by the governance committee to add new liquid assets to the index and mint the given amount IndexToken. The amount of PINT minted and awarded to the LP is specified as part of the associated proposal Caller’s balance is updated to allocate the correct amount of the IndexToken. The given amount of assets must already exist in the caller’s account, they are then transferred to the treasury account.
The Governance committee decides the tokens that comprise the index, as well as the allocation of each and their value.
pub fn force_add_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
units: T::Balance,
amount: T::Balance,
recipient: T::AccountId
) -> DispatchResult
pub fn force_add_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
units: T::Balance,
amount: T::Balance,
recipient: T::AccountId
) -> DispatchResult
Add liquid asset with root origin, see add_asset
pub fn remove_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
units: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
pub fn remove_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
units: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
Dispatches transfer to move assets out of the index’s account, if a liquid asset is specified Callable by an admin.
Updates the index to reflect the removed assets (units) by burning index token accordingly. If the given asset is liquid, an xcm transfer will be dispatched to transfer the given units into the sovereign account of either:
- the given
recipient
if provided - the caller’s account if
recipient
isNone
pub fn force_remove_asset(
origin: OriginFor<T>,
who: T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
pub fn force_remove_asset(
origin: OriginFor<T>,
who: T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
Remove liquid asset with root origin
pub fn register_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
availability: AssetAvailability
) -> DispatchResult
pub fn register_asset(
origin: OriginFor<T>,
asset_id: T::AssetId,
availability: AssetAvailability
) -> DispatchResult
Registers a new asset in the index together with its availability
Only callable by the admin origin and for assets that are not yet registered.
pub fn set_deposit_range(
origin: OriginFor<T>,
new_range: DepositRange<T::Balance>
) -> DispatchResult
pub fn set_deposit_range(
origin: OriginFor<T>,
new_range: DepositRange<T::Balance>
) -> DispatchResult
Updates the range for how much a deposit must be worth in index token in order to be accpedted. Only callable by the admin origin
Parameters:
new_range
: The new valid range for deposits.
pub fn update_redemption_fees(
origin: OriginFor<T>,
new_range: RedemptionFeeRange<T::BlockNumber>
) -> DispatchResult
pub fn update_redemption_fees(
origin: OriginFor<T>,
new_range: RedemptionFeeRange<T::BlockNumber>
) -> DispatchResult
Updates the range for redemption fee
Only callable by the admin origin
Parameters:
new_range
: The new valid range for redemption fee.
pub fn set_lockup_period(
origin: OriginFor<T>,
lockup_period: T::BlockNumber
) -> DispatchResult
pub fn set_lockup_period(
origin: OriginFor<T>,
lockup_period: T::BlockNumber
) -> DispatchResult
Updates the lockup period
Only callable by the admin origin
Parameters:
lockup_period
: how long will the depositing assets will be locked
pub fn set_metadata(
origin: OriginFor<T>,
id: T::AssetId,
name: Vec<u8>,
symbol: Vec<u8>,
decimals: u8
) -> DispatchResult
pub fn set_metadata(
origin: OriginFor<T>,
id: T::AssetId,
name: Vec<u8>,
symbol: Vec<u8>,
decimals: u8
) -> DispatchResult
Force the metadata for an asset to some value.
Origin must be ForceOrigin.
Any deposit is left alone.
id
: The identifier of the asset to update.name
: The user friendly name of this asset. Limited in length byStringLimit
.symbol
: The exchange symbol for this asset. Limited in length byStringLimit
.decimals
: The number of decimals this asset uses to represent one unit.
Emits MetadataSet
.
Weight: O(N + S)
where N and S are the length of the name and
symbol respectively.
Initiate a transfer from the user’s sovereign account into the index.
This will withdraw the given amount from the user’s sovereign account and mints PINT proportionally using the latest available price pairs
Starts the withdraw process for the given amount of PINT to redeem for a distribution of underlying assets.
All withdrawals undergo an unlocking period after which the assets can be withdrawn. A withdrawal fee will be deducted from the PINT being redeemed by the LP depending on how long the assets remained in the index. The remaining PINT will be burned to match the new NAV after this withdrawal.
The distribution of the underlying assets will be equivalent to the ratio of the liquid assets in the index.
Attempts to complete all currently pending redemption processes
started by the withdraw
extrinsic.
This checks every pending withdrawal within PendingWithdrawal
and
tries to close it. Completing a withdrawal will succeed if
following conditions are met:
- the
LockupPeriod
has passed since the withdrawal was initiated - the treasury can cover the asset transfer to the caller’s account, from which the
caller then can initiate an
Xcm::Withdraw
to remove the assets from the PINT parachain entirely, if xcm transfers are supported.
NOTE: All individual withdrawals that resulted from “Withdraw”
will be completed separately, however, the entire record of pending
withdrawals will not be fully closed until the last withdrawal is
completed. This means that a single AssetWithdrawal
will be closed
as soon as the aforementioned conditions are met, regardless of
whether the other AssetWithdrawal
s in the same PendingWithdrawal
set
can also be closed successfully.
Updates the index token locks of the caller.
This removes expired locks and updates the caller’s index token balance accordingly.
The account of the treausry that keeps track of all the assets contributed to the index
The amount of index tokens held by the given user
The amount of index tokens
The free balance of the given account for the given asset.
The combined balance of the given account for the given asset.
The combined balance of the treasury account for the given asset.
The free balance of the treasury account for the given asset.
Iterates over all liquid assets
Iterates over all SAFT assets
pub fn liquid_asset_redemptions(
redeem: u128
) -> Result<AssetRedemption<T::AssetId, T::Balance>, DispatchError>
pub fn liquid_asset_redemptions(
redeem: u128
) -> Result<AssetRedemption<T::AssetId, T::Balance>, DispatchError>
Calculates the pure asset redemption for the given amount of the index token to be redeemed for all the liquid tokens in the index
NOTE:
- This does not account for fees
- This is a no-op for
redeem == 0
Ensures the given lies within the configured deposit range
(AssetId) -> AssetAvailability
pub fn deposits<KArg>(
k: KArg
) -> BoundedVec<(T::Balance, T::BlockNumber), T::MaxActiveDeposits> where
KArg: EncodeLike<T::AccountId>,
pub fn deposits<KArg>(
k: KArg
) -> BoundedVec<(T::Balance, T::BlockNumber), T::MaxActiveDeposits> where
KArg: EncodeLike<T::AccountId>,
All timestamped deposits of an account.
This tracks all deposits, the index token a LP received upon deposit
.
This will be used to calculate a withdrawal fee depending on how long the deposit remained
in the index.
pub fn pending_withrawals<KArg>(
k: KArg
) -> Option<Vec<PendingRedemption<T::AssetId, T::Balance, BlockNumberFor<T>>>> where
KArg: EncodeLike<T::AccountId>,
pub fn pending_withrawals<KArg>(
k: KArg
) -> Option<Vec<PendingRedemption<T::AssetId, T::Balance, BlockNumberFor<T>>>> where
KArg: EncodeLike<T::AccountId>,
All currently pending withdrawal sets for an account.
Where a single PendingRedemption
is the result of a withdraw
call.
(AccountId) -> Vec
pub fn index_token_locks<KArg>(
k: KArg
) -> Vec<IndexTokenLock<T::BlockNumber, T::Balance>> where
KArg: EncodeLike<T::AccountId>,
pub fn index_token_locks<KArg>(
k: KArg
) -> Vec<IndexTokenLock<T::BlockNumber, T::Balance>> where
KArg: EncodeLike<T::AccountId>,
Tracks the locks of the minted index token that are locked up until
their LockupPeriod
is over (AccountId) -> Vec
Tracks the amount of the currently locked index token per user. This is equal to the sum(IndexTokenLocks[AccountId]) (AccountId) -> Balance
The range of the index token equivalent a deposit must be in in order to be allowed.
A valid deposit lies within [deposit_bounds.minimum, deposit_bounds.maximum]
.
pub fn asset_metadata<KArg>(
k: KArg
) -> AssetMetadata<BoundedVec<u8, T::StringLimit>> where
KArg: EncodeLike<T::AssetId>,
pub fn asset_metadata<KArg>(
k: KArg
) -> AssetMetadata<BoundedVec<u8, T::StringLimit>> where
KArg: EncodeLike<T::AssetId>,
Metadata of an asset ( for reversed usage now ).
Trait Implementations
fn add_liquid(
caller: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
nav: T::Balance
) -> DispatchResult
fn add_liquid(
caller: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
nav: T::Balance
) -> DispatchResult
Creates an entry in the assets map and contributes the given amount of asset to the treasury.
Mints the SAFT into the index and awards the caller with given amount of PINT token. If an asset with the given AssetId does not already exist, it will be registered as SAFT. Fails if the availability of the asset is liquid. Read more
fn insert_asset_availability(
asset_id: T::AssetId,
availability: AssetAvailability
) -> Option<AssetAvailability>
fn insert_asset_availability(
asset_id: T::AssetId,
availability: AssetAvailability
) -> Option<AssetAvailability>
Sets the availability of the given asset.
If the asset was already registered, the old AssetAvailability
is
returned. Read more
fn remove_liquid(
who: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
nav: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
fn remove_liquid(
who: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
nav: T::Balance,
recipient: Option<T::AccountId>
) -> DispatchResult
Dispatches transfer to move liquid assets out of the index’s account. Updates the index by burning the given amount of index token from the caller’s account. Read more
fn remove_saft(
who: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
saft_nav: T::Balance
) -> DispatchResult
fn remove_saft(
who: &T::AccountId,
asset_id: T::AssetId,
units: T::Balance,
saft_nav: T::Balance
) -> DispatchResult
Burns the given amount of SAFT token from the index and the nav from the caller’s account Read more
fn add_asset(
asset_id: T::AssetId,
units: T::Balance,
location: MultiLocation,
amount: T::Balance
) -> DispatchResult
fn add_asset(
asset_id: T::AssetId,
units: T::Balance,
location: MultiLocation,
amount: T::Balance
) -> DispatchResult
create feed and add new liquid asset
deposit index tokens to the testing account with saft_nav
Get the benchmarks available for this pallet. Generally there is one benchmark per extrinsic, so these are sometimes just called “extrinsics”. Read more
fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
fn run_benchmark(
extrinsic: &[u8],
c: &[(BenchmarkParameter, u32)],
whitelist: &[TrackedStorageKey],
verify: bool,
internal_repeats: u32
) -> Result<Vec<BenchmarkResult>, BenchmarkError>
Run the benchmarks for this pallet.
Returns the current storage version as supported by the pallet.
Returns the on-chain storage version of the pallet as stored in the storage.
The block is being finalized. Implement to have something happen.
This will be run when the block is being finalized (before on_finalize
).
Implement to have something happen using the remaining weight.
Will not fire if the remaining weight is 0.
Return the weight used, the hook will subtract it from current weight used
and pass the result to the next on_idle
hook if it exists. Read more
The block is being initialized. Implement to have something happen. Read more
Perform a module upgrade. Read more
Implementing this function on a module allows you to perform long-running tasks that make (by default) validators generate transactions that feed results of those long-running computations back on chain. Read more
Run integrity test. Read more
Run integrity test. Read more
Determines the relative location of the consensus system where the given asset is native from the point of view of the current system Read more
Whether the given identifier is currently supported as a liquid asset
fn index_token_equivalent(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
fn index_token_equivalent(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
Calculates the amount of index tokens that the given units of the asset are worth. Read more
fn asset_equivalent(
index_tokens: T::Balance,
asset: T::AssetId
) -> Result<T::Balance, DispatchError>
fn asset_equivalent(
index_tokens: T::Balance,
asset: T::AssetId
) -> Result<T::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
. Read more
fn relative_asset_price(
asset: T::AssetId
) -> Result<AssetPricePair<T::AssetId>, DispatchError>
fn relative_asset_price(
asset: T::AssetId
) -> Result<AssetPricePair<T::AssetId>, DispatchError>
Returns the price of the asset relative to the NAV
of the index token. Read more
fn calculate_net_asset_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
fn calculate_net_asset_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
Calculates the net value of the given units of the given asset. Read more
fn calculate_net_liquid_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
fn calculate_net_liquid_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
Calculates the net value of the given units of the given liquid asset. Read more
fn calculate_net_saft_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
fn calculate_net_saft_value(
asset: T::AssetId,
units: T::Balance
) -> Result<T::Balance, DispatchError>
Calculates the net value of the given units of the given SAFT. Read more
Calculates the net value of all liquid assets combined. Read more
Calculates the net value of all SAFT combined. Read more
Calculates the net asset value of all the index tokens which is equal to the sum of the total value of all assets. Read more
Calculates the net value of the given asset that were contributed to the index. Read more
Calculates the NAV
of the index token, consisting of liquid assets
and SAFT. Read more
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. Read more
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. Read more
Returns the share of the asset in the total value of the index:
Asset Value / Total Net Asset Value
Read more
Returns the share of the liquid asset in the total value of all liquid assets in the index:
Asset Value / Liquid Net Asset Value
Read more
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
Read more
Returns the proportions for each asset in the index
Returns the proportions for each liquid asset in total value of liquid assets in the index
Returns the proportions for each saft asset in total value of SAFTs in the index
The total supply of index tokens currently in circulation.
The amount of the given asset currently held in the index.
Calculates the net value of the given liquid asset. Read more
Returns the per token NAV
of the index token split to (liquid
, saft
). Read more
This function is being called after every block import (when fully synced). Read more
The block is being finalized. Implement to have something happen. Read more
Something that should happen at genesis.
The block is being finalized.
Implement to have something happen in case there is leftover weight.
Check the passed remaining_weight
to make sure it is high enough to allow for
your pallet’s extra computation. Read more
The block is being initialized. Implement to have something happen. Read more
Perform a module upgrade. Read more
Name of the Rust module containing the pallet.
Version of the crate containing the pallet.
Extend the given vector by all of the pallets’ information that this type represents. Read more
All of the pallets’ information that this type represents.
Returns the value of the assets currently secured by the SAFTS
Auto Trait Implementations
impl<T> RefUnwindSafe for Pallet<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for Pallet<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
Compare self to key
and return true
if they are equal.
Causes self
to use its Binary
implementation when Debug
-formatted.
Causes self
to use its Display
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerExp
implementation when
Debug
-formatted. Read more
Causes self
to use its LowerHex
implementation when
Debug
-formatted. Read more
Causes self
to use its Octal
implementation when Debug
-formatted.
Causes self
to use its Pointer
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperExp
implementation when
Debug
-formatted. Read more
Causes self
to use its UpperHex
implementation when
Debug
-formatted. Read more
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
impl<T> PalletVersionToStorageVersionHelper for T where
T: GetStorageVersion + PalletInfoAccess,
Pipes by value. This is generally the method you want to use. Read more
Borrows self
and passes that borrow into the pipe function. Read more
Mutably borrows self
and passes that borrow into the pipe function. Read more
Borrows self
, then passes self.borrow()
into the pipe function. Read more
Mutably borrows self
, then passes self.borrow_mut()
into the pipe
function. Read more
Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe
function. Read more
Borrows self
, then passes self.deref()
into the pipe function.
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
Self: Deref,
R: 'a,
Pipes a dereference into a function that cannot normally be called in suffix position. Read more
Pipes a reference into a function that cannot ordinarily be called in suffix position. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.
Immutable access to the Borrow<B>
of a value. Read more
Mutable access to the BorrowMut<B>
of a value. Read more
Immutable access to the AsRef<R>
view of a value. Read more
Mutable access to the AsMut<R>
view of a value. Read more
Immutable access to the Deref::Target
of a value. Read more
Mutable access to the Deref::Target
of a value. Read more
Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more
Calls .tap_deref()
only in debug builds, and is erased in release
builds. Read more
Provides immutable access to the reference for inspection.
Calls tap_ref
in debug builds, and does nothing in release builds.
Provides mutable access to the reference for modification.
Calls tap_ref_mut
in debug builds, and does nothing in release builds.
Provides immutable access to the borrow for inspection. Read more
Calls tap_borrow
in debug builds, and does nothing in release builds.
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Provides mutable access to the borrow for modification.
Immutably dereferences self
for inspection.
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Calls tap_deref
in debug builds, and does nothing in release builds.
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Mutably dereferences self
for modification.
The counterpart to unchecked_from
.
Consume self to return an equivalent value of T
.
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more