pub enum Call<T: Config> {
    create_global_farm {
        total_rewards: Balance,
        planned_yielding_periods: <T as Config>::BlockNumber,
        blocks_per_period: BlockNumberFor<T>,
        incentivized_asset: AssetId,
        reward_currency: AssetId,
        owner: T::AccountId,
        yield_per_period: Perquintill,
        min_deposit: Balance,
        price_adjustment: FixedU128,
    },
    update_global_farm {
        global_farm_id: GlobalFarmId,
        price_adjustment: FixedU128,
    },
    terminate_global_farm {
        global_farm_id: GlobalFarmId,
    },
    create_yield_farm {
        global_farm_id: GlobalFarmId,
        asset_pair: AssetPair,
        multiplier: FarmMultiplier,
        loyalty_curve: Option<LoyaltyCurve>,
    },
    update_yield_farm {
        global_farm_id: GlobalFarmId,
        asset_pair: AssetPair,
        multiplier: FarmMultiplier,
    },
    stop_yield_farm {
        global_farm_id: GlobalFarmId,
        asset_pair: AssetPair,
    },
    resume_yield_farm {
        global_farm_id: GlobalFarmId,
        yield_farm_id: YieldFarmId,
        asset_pair: AssetPair,
        multiplier: FarmMultiplier,
    },
    terminate_yield_farm {
        global_farm_id: GlobalFarmId,
        yield_farm_id: YieldFarmId,
        asset_pair: AssetPair,
    },
    deposit_shares {
        global_farm_id: GlobalFarmId,
        yield_farm_id: YieldFarmId,
        asset_pair: AssetPair,
        shares_amount: Balance,
    },
    redeposit_shares {
        global_farm_id: GlobalFarmId,
        yield_farm_id: YieldFarmId,
        asset_pair: AssetPair,
        deposit_id: DepositId,
    },
    claim_rewards {
        deposit_id: DepositId,
        yield_farm_id: YieldFarmId,
    },
    withdraw_shares {
        deposit_id: DepositId,
        yield_farm_id: YieldFarmId,
        asset_pair: AssetPair,
    },
    // some variants omitted
}
Expand description

Contains one variant per dispatchable that can be called by an extrinsic.

Variants§

§

create_global_farm

Fields

§total_rewards: Balance
§planned_yielding_periods: <T as Config>::BlockNumber
§blocks_per_period: BlockNumberFor<T>
§incentivized_asset: AssetId
§reward_currency: AssetId
§owner: T::AccountId
§yield_per_period: Perquintill
§min_deposit: Balance
§price_adjustment: FixedU128

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

Fields

§global_farm_id: GlobalFarmId
§price_adjustment: FixedU128

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_global_farm

Fields

§global_farm_id: GlobalFarmId

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.

§

create_yield_farm

Fields

§global_farm_id: GlobalFarmId
§asset_pair: AssetPair
§multiplier: FarmMultiplier
§loyalty_curve: Option<LoyaltyCurve>

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

Fields

§global_farm_id: GlobalFarmId
§asset_pair: AssetPair
§multiplier: FarmMultiplier

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_yield_farm

Fields

§global_farm_id: GlobalFarmId
§asset_pair: AssetPair

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

Fields

§global_farm_id: GlobalFarmId
§yield_farm_id: YieldFarmId
§asset_pair: AssetPair
§multiplier: FarmMultiplier

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.

§

terminate_yield_farm

Fields

§global_farm_id: GlobalFarmId
§yield_farm_id: YieldFarmId
§asset_pair: AssetPair

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_shares

Fields

§global_farm_id: GlobalFarmId
§yield_farm_id: YieldFarmId
§asset_pair: AssetPair
§shares_amount: Balance

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_shares

Fields

§global_farm_id: GlobalFarmId
§yield_farm_id: YieldFarmId
§asset_pair: AssetPair
§deposit_id: DepositId

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

Fields

§deposit_id: DepositId
§yield_farm_id: YieldFarmId

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_shares

Fields

§deposit_id: DepositId
§yield_farm_id: YieldFarmId
§asset_pair: AssetPair

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

Implementations§

Create a call with the variant create_global_farm.

Create a call with the variant update_global_farm.

Create a call with the variant terminate_global_farm.

Create a call with the variant create_yield_farm.

Create a call with the variant update_yield_farm.

Create a call with the variant stop_yield_farm.

Create a call with the variant resume_yield_farm.

Create a call with the variant terminate_yield_farm.

Create a call with the variant deposit_shares.

Create a call with the variant redeposit_shares.

Create a call with the variant claim_rewards.

Create a call with the variant withdraw_shares.

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
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
Returns the fixed encoded size of the type. Read more
Convert self to a slice and append it to the destination.
If possible give a hint of expected size of the encoding. Read more
Convert self to an owned vector.
Convert self to a slice and then invoke the given closure with it.
Calculates the encoded size. Read more
Return the function name of the Call.
Return all function names.
Return a DispatchInfo, containing relevant information of this dispatch. Read more
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
The type identifying for which type info is provided. Read more
Returns the static type identifier for Self.
The origin type of the runtime, (i.e. frame_system::Config::Origin).
Dispatch this call but do not check the filter in origin.

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
Decode Self and consume all of the given input data. Read more
Decode Self and consume all of the given input data. Read more
Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. 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.

Return an encoding of Self prepended by given slice.
Performs the conversion.
Performs the conversion.
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.