pub struct Pallet<T>(PhantomData<T>);
Expand description

The pallet implementing the on-chain logic.

Tuple Fields§

§0: PhantomData<T>

Implementations§

Create new liquidity mining program with provided parameters.

owner account has to have at least total_rewards balance. This fund will be transferred from owner to farm account.

The dispatch origin for this call must be T::CreateOrigin. !!!WARN: T::CreateOrigin has power over funds of owner’s account and it should be configured to trusted origin e.g Sudo or Governance.

Parameters:

  • origin: global farm’s owner.
  • total_rewards: total rewards planned to distribute. This rewards will be distributed between all yield farms in the global farm.
  • planned_yielding_periods: planned number of periods to distribute total_rewards. WARN: THIS IS NOT HARD DEADLINE. Not all rewards have to be distributed in planned_yielding_periods. Rewards are distributed based on the situation in the yield farms and can be distributed in a longer time frame but never in the shorter time frame.
  • blocks_per_period: number of blocks in a single period. Min. number of blocks per period is 1.
  • incentivized_asset: asset to be incentivized in XYK pools. All yield farms added into liq. mining program have to have incentivized_asset in their pair.
  • reward_currency: payoff currency of rewards.
  • owner: liq. mining program owner.
  • yield_per_period: percentage return on reward_currency of all farms p.a.
  • min_deposit: minimum amount which can be deposited to the farm
  • price_adjustment: Emits GlobalFarmCreated event when successful.

Update global farm’s prices adjustment.

Only farm’s owner can perform this action.

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: id of the global farm to update
  • price_adjustment: new value for price adjustment

Emits GlobalFarmUpdated event when successful.

Terminate existing liq. mining program.

Only farm owner can perform this action.

WARN: To successfully terminate a farm, farm have to be empty(all yield farms in he global farm must be terminated).

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: id of global farm to be terminated.

Emits GlobalFarmTerminated event when successful.

Add yield farm for given asset_pair XYK pool.

Only farm owner can perform this action.

Only XYKs with asset_pair with incentivized_asset can be added into the farm. XYK pool for asset_pair has to exist to successfully create yield farm. Yield farm for same asset_pair can exist only once in the global farm.

Parameters:

  • origin: global farm’s owner.
  • farm_id: global farm id to which a yield farm will be added.
  • asset_pair: asset pair identifying yield farm. Liq. mining will be allowed for this asset_pair and one of the assets in the pair must be incentivized_asset.
  • multiplier: yield farm multiplier.
  • loyalty_curve: curve to calculate loyalty multiplier to distribute rewards to users with time incentive. None means no loyalty multiplier.

Emits YieldFarmCreated event when successful.

Update yield farm multiplier.

Only farm owner can perform this action.

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: global farm id in which yield farm will be updated.
  • asset_pair: asset pair identifying yield farm in global farm.
  • multiplier: new yield farm multiplier.

Emits YieldFarmUpdated event when successful.

Stop liq. miming for specific yield farm.

This function claims rewards from GlobalFarm last time and stops yield farm incentivization from a GlobalFarm. Users will be able to only withdraw shares(with claiming) after calling this function. deposit_shares() and claim_rewards() are not allowed on canceled yield farm.

Only farm owner can perform this action.

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: farm id in which yield farm will be canceled.
  • asset_pair: asset pair identifying yield farm in the farm.

Emits YieldFarmStopped event when successful.

Resume yield farm for stopped yield farm.

This function resume incentivization from GlobalFarm and restore full functionality for yield farm. Users will be able to deposit, claim and withdraw again.

WARN: Yield farm is NOT rewarded for time it was stopped.

Only farm owner can perform this action.

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: global farm id in which yield farm will be resumed.
  • yield_farm_id: id of yield farm to be resumed.
  • asset_pair: asset pair identifying yield farm in global farm.
  • multiplier: yield farm multiplier in the farm.

Emits YieldFarmResumed event when successful.

Remove yield farm

This function marks a yield farm as ready to be removed from storage when it’s empty. Users will be able to only withdraw shares(without claiming rewards from yield farm). Unpaid rewards will be transferred back to global farm and will be used to distribute to other yield farms.

Yield farm must be stopped before calling this function.

Only global farm’s owner can perform this action. Yield farm stays in the storage until it’s empty(all farm entries are withdrawn). Last withdrawn from yield farm trigger removing from the storage.

Parameters:

  • origin: global farm’s owner.
  • global_farm_id: farm id from which yield farm should be terminated.
  • yield_farm_id: id of yield farm to be terminated.
  • asset_pair: asset pair identifying yield farm in the global farm.

Emits YieldFarmTerminated event when successful.

Deposit LP shares to a liq. mining.

This function transfers LP shares from origin to pallet’s account and mint nft for origin account. Minted nft represents deposit in the liq. mining.

Parameters:

  • origin: account depositing LP shares. This account has to have at least shares_amount of LP shares.
  • global_farm_id: id of global farm to which user wants to deposit LP shares.
  • yield_farm_id: id of yield farm to deposit to.
  • asset_pair: asset pair identifying LP shares user wants to deposit.
  • shares_amount: amount of LP shares user wants to deposit.

Emits SharesDeposited event when successful.

Redeposit already locked LP shares to another yield farm.

This function create yield farm entry for existing deposit. LP shares are not transferred and amount of LP shares is based on existing deposit.

This function DOESN’T create new deposit.

Parameters:

  • origin: account depositing LP shares. This account have to have at least
  • global_farm_id: global farm identifier.
  • yield_farm_id: yield farm identifier redepositing to.
  • asset_pair: asset pair identifying LP shares user want to deposit.
  • deposit_id: identifier of the deposit.

Emits SharesRedeposited event when successful.

Claim rewards from liq. mining for deposit represented by nft_id.

This function calculate user rewards from liq. mining and transfer rewards to origin account. Claiming in the same period is allowed only once.

Parameters:

  • origin: account owner of deposit(nft).
  • deposit_id: nft id representing deposit in the yield farm.
  • yield_farm_id: yield farm identifier to claim rewards from.

Emits RewardClaimed event when successful.

Withdraw LP shares from liq. mining with reward claiming if possible.

List of possible cases of transfers of LP shares and claimed rewards:

  • yield farm is active(yield farm is not stopped) - claim and transfer rewards(if it wasn’t claimed in this period) and transfer LP shares.
  • liq. mining is stopped - claim and transfer rewards(if it wasn’t claimed in this period) and transfer LP shares.
  • yield farm was terminated - only LP shares will be transferred.
  • farm was terminated - only LP shares will be transferred.

User’s unclaimable rewards will be transferred back to global farm’s account.

Parameters:

  • origin: account owner of deposit(nft).
  • deposit_id: nft id representing deposit in the yield farm.
  • yield_farm_id: yield farm identifier to dithdraw shares from.
  • asset_pair: asset pair identifying yield farm in global farm.

Emits:

  • RewardClaimed if claim happen
  • SharesWithdrawn event when successful

Account ID of the pot holding locked LP shares. This account is also owner of NFT class for all the NFTs minted by this pallet.

This function retuns value of lp tokens in the asset currency.

Trait Implementations§

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.
Run integrity test. Read more
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
Execute the sanity checks of this pallet, per block. Read more
Execute some pre-checks prior to a runtime upgrade. Read more
Execute some post-checks after a runtime 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
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
Execute some pre-checks prior to a runtime upgrade. Read more
Execute some post-checks after a runtime 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
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 !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
Execute the state checks.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Casts the value.
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Casts the value.
Casts the value.
Casts the value.
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
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. Read more
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. Read more
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
Formats each item in a sequence. Read more

Returns the argument unchanged.

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

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

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.

Performs the conversion.
Performs the conversion.
Generate a storage key unique to this runtime upgrade. Read more
Get temporary storage data written by Self::set_temp_storage. Read more
Write some temporary data to a specific storage that can be read (potentially in post-upgrade hook) via Self::get_temp_storage. Read more
Casts the value.
Casts the value.
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
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. 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
Casts the value.
Casts the value.
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
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Attempts to convert self into T using TryInto<T>. 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.
Casts the value.
Casts the value.
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
Casts the value.
Casts the value.