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.

Add liquid asset with root origin, see add_asset

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 is None

Remove liquid asset with root origin

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.

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.

Updates the range for redemption fee

Only callable by the admin origin

Parameters:

  • new_range: The new valid range for redemption fee.

Updates the lockup period

Only callable by the admin origin

Parameters:

  • lockup_period: how long will the depositing assets will be locked

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 by StringLimit.
  • symbol: The exchange symbol for this asset. Limited in length by StringLimit.
  • 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 AssetWithdrawals 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

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

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.

All currently pending withdrawal sets for an account. Where a single PendingRedemption is the result of a withdraw call.

(AccountId) -> Vec

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].

Metadata of an asset ( for reversed usage now ).

Trait Implementations

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

Sets the availability of the given asset. If the asset was already registered, the old AssetAvailability is returned. Read more

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

Burns the given amount of SAFT token from the index and the nav from the caller’s account Read more

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

Run the benchmarks for this pallet.

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Calculates the amount of index tokens that the given units of the asset are worth. Read more

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

Returns the price of the asset relative to the NAV of the index token. Read more

Calculates the net value of the given units of the given asset. Read more

Calculates the net value of the given units of the given liquid asset. Read more

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

Index of the pallet as configured in the runtime.

Name of the pallet as configured in the runtime.

Name of the Rust module containing the pallet.

Version of the crate containing the pallet.

The number of pallets’ information that this type represents. Read more

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.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Returns the value of the assets currently secured by the SAFTS

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert from a value of T into an equivalent instance of Option<Self>. Read more

Consume self to return Some equivalent value of Option<T>. Read more

Converts self into T using Into<T>. Read more

Converts self into a target type. 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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. 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

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Cast reference.

Cast reference.

Cast mutable reference.

Cast mutable reference.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

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.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Pipes a value into a function that cannot ordinarily be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait borrow into a function that cannot normally be called in suffix position. Read more

Pipes a trait mutable borrow into a function that cannot normally be called in suffix position. Read more

Pipes a dereference into a function that cannot normally be called in suffix position. Read more

Pipes a mutable 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

Pipes a mutable reference into a function that cannot ordinarily be called in suffix position. Read more

Should always be Self

Convert from a value of T into an equivalent instance of Self. Read more

Consume self to return an equivalent value of T. 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 a value. Read more

Mutable access to a value. Read more

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

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Provides immutable access for inspection. Read more

Calls tap in debug builds, and does nothing in release builds.

Provides mutable access for modification. Read more

Calls tap_mut in debug builds, and does nothing in release builds.

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.

Provides mutable access to the borrow for modification.

Calls tap_borrow_mut in debug builds, and does nothing in release builds. Read more

Immutably dereferences self for inspection.

Calls tap_deref in debug builds, and does nothing in release builds.

Mutably dereferences self for modification.

Calls tap_deref_mut in debug builds, and does nothing in release builds. Read more

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

Attempts to convert self into T using TryInto<T>. Read more

Attempts to convert self into a target type. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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