Installation
Install the SDK using npm:Configuration
senderAddress
to your sdk instance
Key Concepts
Gauge
A smart contract that manages staked positions rewards and oSAIL token distribution. Core functions:- Position Staking Management: Tracks staked positions, calculates rewards, and enables withdrawal
- Reward & oSAIL Distribution: Distributes rewards and oSAIL tokens to staked positions. New oSAIL tokens are issued weekly for each epoch
- Reward Calculation: Calculates earned oSAIL rewards based on staked liquidity and time, and processes reward claims to position owners
- Fee Collection: Collects and manages fees generated by the associated liquidity pool
Ticks
Discrete price points that define the boundaries of liquidity ranges. Important considerations:- Each tick represents a specific price ratio
- Ticks are spaced at constant intervals determined by the pool’s tick spacing
Pool
Initially created without a gauge. It can be added later to enable reward distribution. There are two pool entities available through the SDK: Chain Pool (Pool.getByIdFromChain()
): Contains real-time data directly from the blockchain. Data from this entity is always relevant.
Some core/unique properties:
currentTickIndex
: The tick corresponding to the current price of the pool (determines which liquidity positions are currently active)rewardCoinsInfo
: List of reward coins available for this poolcurrentSqrtPrice
: Current sqrt price of the pool
Pool.getById()
): Contains calculated data and metadata from the backend which can be convinient for frontend. It can contain same fields as ChainPool but they may be outdated by a few minutes, especially those that change frequently.
Some core/unique properties:
gauge_id
: Unique identifier for gauge contract related to this pool
gauge_id
, use chain pool for relevant current price and reward data.
Position
Represents a range of prices where you provide liquidity to a pool. If gauge exists for this pool, position should be staked, otherwise it will not receive rewards. Some core properties:tick_lower
: The lower bound of your price range (minimum price where your liquidity is active)tick_upper
: The upper bound of your price range (maximum price where your liquidity is active)liquidity
: The amount of liquidity provided in this price rangestake_info
: Information about the position stake object within the gauge. Can be undefined if position not staked or no gauge exists for this pool.
Position Rewards
Different position states receive different types of rewards:- Position in pool without gauge: Receives pool fees and pool rewards
- Unstaked position in pool with gauge: Receives nothing
- Staked position in pool with gauge: Receives oSAIL tokens and pool rewards
oSAIL
oSAIL is the emissions token distributed to staked positions. Each epoch has its own oSAIL token with a specific expiration date - 5 weeks from the start of the epoch. It offers two possible paths: lock it into veSAIL to participate in governance and earn trading fees, or redeem it for liquid SAIL at 50% of the current spot price at time of redemption, paid in USDC. Expired oSAIL can be only locked into veSAIL.Usage examples
If method name ends with...Transaction
, it returns a transaction that should be signed and executed using your sui client or wallet kit.
Create Position
Create Position
Add Liquidity To Position
Add Liquidity To Position
Only oSAIL claimed automatically within this transaction. Fees and pool rewards are not.
Stake Position
Stake Position
This method can be used only if position is created before gauge is added to the pool or if
gaugeId
was not provided when creating the position via Position.openTransaction()
. Unstaked positions within a pool with gauge will not receive rewards. Only fees claimed automatically within this transaction. Pool rewards are not.Remove Liquidity From Position
Remove Liquidity From Position
Only oSAIL claimed automatically within this transaction. Fees and pool rewards are not.
Close Position
Close Position
All rewards claimed automatically within this transaction.
Claim Fee
Claim Fee
This method can be used only if position is not staked.
Claim Unstaked Position Rewards
Claim Unstaked Position Rewards
This method can be used only if position is not staked.
Claim All Unstaked Position Rewards
Claim All Unstaked Position Rewards
This method claims both fee and pool rewards for unstaked position.
Claim oSAIL
Claim oSAIL
This method can be used only if position is staked.
Claim Staked Position Rewards
Claim Staked Position Rewards
This method can be used only if position is staked.
Claim All Staked Position Rewards
Claim All Staked Position Rewards
This method claims both oSAIL and pool rewards for staked position.
Swap Using Router
Swap Using Router
See Aftermath router docs for more details.
Swap Without Router
Swap Without Router
Directly through smart contract.