Documentation Index
Fetch the complete documentation index at: https://initialabs-develop.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Creating New Pools
InitiaDEX allows anyone to create a liquidity pool.| Parameter | Description |
|---|---|
name | Name of the trading pair and the corresponding LP Token |
symbol | Symbol for the LP Token |
swap_fee_rate | Fee rate applied to swaps |
coin_a_weight and coin_b_weight | Balancer weights for the respective coins |
coin_a_metadata and coin_b_metadata | Metadata for each coin in the pair |
coin_a_amount and coin_b_amount | Initial amounts for each coin |
- CLI
- InitiaJS
How to Provide Liquidity
Provide Liquidity
provide_liquidity enables the users to provide liquidity of both coin_a and coin_b in the specific pair. In order to maximize liquidity, the user should provide in resonation with the current ratio. The Move module interface is as follows:
pair: The metadata or object address of pair.coin_a_amount_inandcoin_b_amount_in: Amount of token provided forcoin_aandcoin_b.min_liquidity: Minimum amout of liquidity token to receive. In case that the actual value is smaller thanmin_liquidity, the transaction will fail.
- CLI
- InitiaJS
Single Asset Provide Liquidity
Instead of creating a pair, the user can provide a pool of only one token. Internally, the token will be swapped to another token and provide liquidity, so there can be fee and slippage in occurance. The Move function interface is as follows:pair: The metadata or object address of pair.provide_coin: The metadata of the provided coin.amount_in: The amount of provided coin.min_liquidity: Minimum amout of liquidity token to receive. In case that the actual value is smaller thanmin_liquidity, the transaction will fail.
- CLI
- InitiaJS
How to Withdraw Liquidity
Withdraw Liquidity
withdraw_liquidity allows users to provide liquidity tokens and receive coin_a and coin_b. The Move module interface is as follows:
pair: The metadata or object address of pair.liquidity: Amount of liquidity token.min_coin_a_amountandmin_coin_b_amount: Minimum amout ofcoin_aorcoin_bto receive. In case that the actual value is smaller thanmin_coin_a_amountormin_coin_b_amount, the transaction will fail.
- CLI
- InitiaJS
How to Swap Pair
Swap Simulation
swap_simulation is a view function to estimate the return value of said swap.
pair: The metadata or object address of pair.offer_metadata: Metadata of offered coin.offer_amount: Amount of offered coin.
- curl
- CLI
- InitiaJS
Swap
The Move module interface for swap function is as follows:pair: The metadata or object address of pair.offer_coin: Metadata of offered coin.offer_coin_amount: Amount of offered coin.min_return: Minimum return amount of coin. In case that the actual value is smaller thanmin_return, the transaction will fail.
- CLI
- InitiaJS
How to Delegate LP Tokens
Whitelist a Pair
To delegate your LP tokens to a validator, you need to whitelist the LP token first. We can use MsgWhitelist to whitelist the LP token.- CLI
- InitiaJS
proposal.json
Delegate LP Tokens
After whitelisting the LP token, you can delegate your LP tokens to a validator. We can useMsgDelegate to delegate LP tokens.
- CLI
- InitiaJS
Example Code
The following example demonstrates the above functions in a single script using InitiaJS. The script includes the following steps:- Create a pair
- Provide liquidity
- Whitelist LP
- Delegate LP tokens to the validator
- Withdraw rewards from the validator
- Local Initia node is running on
http://localhost:1317. - The user and validator share the same mnemonic for simplicity.