Skip to main content
The Liquidity Pools pallet is a fully permissionless Substrate pallet that enables the creation and management of liquidity pools for any asset pair. It provides a flexible framework for users to stake their assets in pools and earn rewards, with automatic rollover capabilities to maintain continuous participation across successive pools.

Calls

create_pool

Creates a new liquidity pool specifying reward and staked asset IDs, interest rate, maximum token limit, and lock period (start and end blocks). Anyone can create a pool without special permissions. Namespace
Type

set_pool_succession

Links a predecessor pool to a successor pool, enabling automatic rollover of user stakes when the predecessor pool completes its cycle. Namespace
Type

set_pool_rollover

Lets users opt in or out of automatic rollover to the successor pool when the current pool matures. Namespace
Type

close_pool

Allows a pool creator to close their pool. Upon closing, only unclaimed reward tokens are returned to the creator. Staked tokens remain in the pool for users to withdraw. The pool remains in the Closed state until all user funds are withdrawn. Namespace
Type

enter_pool

Enables users to join an open pool by staking their assets up to the pool’s maximum capacity. Namespace
Type

exit_pool

Permits users to withdraw their staked assets from an Open pool before the lock period begins, and also from a Closed pool after the pool has been manually closed by the creator. Namespace
Type

claim_reward

Allows users to claim their earned rewards after a pool matures. If the user opted out of rollover, their principle is also returned. Namespace
Type

rollover_unsigned

An internal extrinsic executed by the offchain worker to process the automatic rollover of user stakes. Namespace
Type

Storage

Pools

Stores information about each liquidity pool Namespace
Type

PoolUsers

Tracks user participation in pools Namespace
Type

PoolRelationships

Maps predecessor pools to successor pools Namespace
Type

NextPoolId

Increment-only unique pool id Namespace
Type

NextRolloverUnsignedAt

Tracks when next rollover should occur Namespace
Type

RolloverPivot

Tracks progress during batch rollover operations Namespace
Type

ProcessedPoolPivot

Tracks the next pool id pivot used for batched processing during on_idle. Namespace
Type

Events

PoolOpen

When a new pool is created Namespace
Type

PoolStarted

When a pool enters lock period Namespace
Type

PoolRenewing

When a pool starts rollover process Namespace
Type

PoolMatured

When a pool is ready for rewards claiming Namespace
Type

PoolClosed

When a pool is closed Namespace
Type
Note: On close, only reward tokens are transferred to the creator; users must exit to withdraw staked tokens.

SetSuccession

When pools are linked for rollover Namespace
Type

UserInfoUpdated

When user rollover preference is updated Namespace
Type

UserJoined

When user joins a pool Namespace
Type

UserExited

When user exits a pool Namespace
Type

UserRolledOver

When user is rolled over to successor pool Namespace
Type

RewardsClaimed

When rewards are claimed Namespace
Type

Errors

NotPoolCreator

Caller is not the pool creator Namespace

InvalidBlockRange

Invalid block range for pool Namespace

PoolAlreadyExists

Pool already exists Namespace

PoolDoesNotExist

Pool does not exist Namespace

SuccessorPoolDoesNotExist

Successor pool does not exist Namespace

PredecessorPoolDoesNotExist

Predecessor pool does not exist Namespace

SuccessorPoolSizeShouldBeGreaterThanPredecessor

Successor pool too small Namespace

SuccessorPoolSizeShouldBeLockedAfterPredecessor

Invalid successor timing Namespace

RolloverPoolsShouldBeTheSameAsset

Asset mismatch between pools Namespace

NoTokensStaked

No tokens staked for operation Namespace

PoolNotOpen

Pool not in open state Namespace

NotReadyForClaimingReward

Pool not mature for claiming Namespace

NoAvailablePoolId

Exceeds maximum pool ID Namespace

StakingLimitExceeded

Pool capacity limit reached Namespace

OffchainErrNotValidator

Offchain worker not validator Namespace

OffchainErrTooEarly

Offchain worker called too early Namespace

OffchainErrSubmitTransaction

Offchain transaction submission error Namespace

OffchainErrWrongTransactionSource

Offchain transaction source error Namespace

PivotStringTooLong

Pivot string exceeds maximum length Namespace

PoolAlreadyClosed

Pool is already in the Closed state Namespace

CannotExitPool

Cannot exit the pool in the current state or conditions Namespace

RewardCalculationOverflow

Overflow occurred during reward calculation Namespace