Scripts
Module info
Name:
yuzuswap::scripts
Description: This module contains entry functions for users to call and interact with the
yuzuswap
contract.
Public Functions
Create Pool
Create pool with two fungible assets
Creates a new liquidity pool for two fungible assets. Reverts if the pool already exists.
Function arguments
sender
&signer
The sender’s signer
token_0
Object
Fungible asset metadata of token 0
token_1
Object
Fungible asset metadata of token 1
fee
u64
Fee tier of the pool
sqrt_price
u128
Initial sqrt price of the pool
Create pool with one coin and one fungible asset
Creates a new liquidity pool with one coin (Token0
) and one fungible asset. Reverts if the pool already exists.
Function type arguments
Token0
The coin’s type
Function arguments
sender
&signer
The sender’s signer
token_1
Object
Fungible asset metadata of token 1
fee
u64
Fee tier of the pool
sqrt_price
u128
Initial sqrt price of the pool
Create pool with two coins
Creates a new liquidity pool with two coins Token0
and Token1
. Reverts if the pool already exists.
Function type arguments
Token1
The coin’s type of the token 0
Token0
The coin’s type of the token 1
Function arguments
sender
&signer
The sender’s signer
fee
u64
Fee tier of the pool
sqrt_price
u128
Initial sqrt price of the pool
Add liquidity
Add liquidity to a pool with two fungible assets
Adds liquidity to a pool with two fungible assets.
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool to add liquidity to.
position_id
u64
The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet.
tick_lower
u32
The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
tick_upper
u32
The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
amount_0
u64
The amount of token 0 to add to the liquidity.
amount_1
u64
The amount of token 1 to add to the liquidity.
amount_0_min
u64
The minimum amount of token 0 to add to the liquidity.
amount_1_min
u64
The minimum amount of token 1 to add to the liquidity.
Add liquidity to a pool with one coin and one fungible asset
Adds liquidity to a pool with one coin and one fungible asset.
Function type arguments
CoinType
The coin’s type
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool to add liquidity to.
position_id
u64
The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet.
tick_lower
u32
The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
tick_upper
u32
The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
amount_0
u64
The amount of token 0 to add to the liquidity.
amount_1
u64
The amount of token 1 to add to the liquidity.
amount_0_min
u64
The minimum amount of token 0 to add to the liquidity.
amount_1_min
u64
The minimum amount of token 1 to add to the liquidity.
Add liquidity to a pool with two coins
Adds liquidity to a pool with two coins.
Function type arguments
Coin0
The coin’s type of the token 0
Coin1
The coin’s type of the token 1
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool to add liquidity to.
position_id
u64
The position ID of the liquidity. Leave it as 0 if you want to create a new position or you don’t have any position yet.
tick_lower
u32
The lower tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
tick_upper
u32
The upper tick of the liquidity. Required in the case of creating a new position. Otherwise, leave it as 0.
amount_0
u64
The amount of token 0 to add to the liquidity.
amount_1
u64
The amount of token 1 to add to the liquidity.
amount_0_min
u64
The minimum amount of token 0 to add to the liquidity.
amount_1_min
u64
The minimum amount of token 1 to add to the liquidity.
Remove liquidity |
Remove liquidity from a pool
Removes liquidity from a pool.
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool to remove liquidity from.
position_id
u64
The position ID of the liquidity.
liquidity
u128
The amount of liquidity to remove.
amount_0_min
u64
The minimum amount of token 0 to get.
amount_1_min
u64
The minimum amount of token 1 to get.
Burn position
Burns a position.
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool.
position_id
u64
The position ID to burn.
Collect fee
Collects fee from a position.
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool.
position_id
u64
The position ID.
amount_0_requested
u64
The amount of token 0 requested.
amount_1_requested
u64
The amount of token 1 requested.
recipient
address
The recipient address.
Collect reward
Collects reward from a position.
Function arguments
user
&signer
The user’s signer.
pool
Object
The liquidity pool.
position_id
u64
The position ID.
reward_index
u64
The reward index.
amount_requested
u64
The amount of reward requested.
recipient
address
The recipient address.
Swap functions
Swap exact fungible asset for fungible asset
Swaps an exact amount of fungible asset for another fungible asset.
Function arguments
trader
&signer
The trader’s signer.
pool
Object
The liquidity pool.
token_in
Object
The input token metadata.
amount_in
u64
The amount of input token.
amount_out_min
u64
The minimum amount of output token.
sqrt_price_limit
u128
The sqrt price limit.
recipient
address
The recipient address.
Swap exact coin for fungible asset
Swaps an exact amount of coin for a fungible asset.
Function type arguments
CoinType
The coin’s type
Function arguments
trader
&signer
The trader’s signer.
pool
Object
The liquidity pool.
amount_in
u64
The amount of input coin.
amount_out_min
u64
The minimum amount of output token.
sqrt_price_limit
u128
The sqrt price limit.
recipient
address
The recipient address.
Swap fungible asset for exact fungible asset
Swaps a fungible asset for an exact amount of another fungible asset.
Function arguments
trader
&signer
The trader’s signer.
pool
Object
The liquidity pool.
token_in
Object
The input token metadata.
amount_in
u64
The amount of input token.
amount_out_min
u64
The minimum amount of output token.
sqrt_price_limit
u128
The sqrt price limit.
recipient
address
The recipient address.
Swap coin for exact fungible asset
Swaps a coin for an exact amount of a fungible asset.
Function type arguments
CoinType
The coin’s type
Function arguments
trader
&signer
The trader’s signer.
pool
Object
The liquidity pool.
amount_in
u64
The amount of input coin.
amount_out_min
u64
The minimum amount of output token.
sqrt_price_limit
u128
The sqrt price limit.
recipient
address
The recipient address.
Swap exact fungible asset for fungible asset with multiple hops
Swaps an exact amount of fungible asset for another fungible asset with multiple hops.
Function arguments
trader
&signer
The trader’s signer.
pools
vector<Object>
The liquidity pools.
token_in
Object
The input token metadata.
amount_in
u64
The amount of input token.
amount_out_min
u64
The minimum amount of output token.
recipient
address
The recipient address.
Swap exact coin for fungible asset with multiple hops
Swaps an exact amount of coin for a fungible asset with multiple hops.
Function type arguments
CoinType
The coin’s type
Function arguments
trader
&signer
The trader’s signer.
pools
vector<Object>
The liquidity pools.
amount_in
u64
The amount of input coin.
amount_out_min
u64
The minimum amount of output token.
recipient
address
The recipient address.
Swap fungible asset for exact fungible asset with multiple hops
Swaps a fungible asset for an exact amount of another fungible asset with multiple hops.
Function arguments
trader
&signer
The trader’s signer.
pools
vector<Object>
The liquidity pools.
token_in
Object
The input token metadata.
amount_in_max
u64
The maximum amount of input token.
amount_out_desired
u64
The desired amount of output token.
recipient
address
The recipient address.
Swap coin for exact fungible asset with multiple hops
Swaps a coin for an exact amount of a fungible asset with multiple hops.
Function type arguments
CoinType
The coin’s type
Function arguments
trader
&signer
The trader’s signer.
pools
vector<Object>
The liquidity pools.
amount_in_max
u64
The maximum amount of input coin.
amount_out_desired
u64
The desired amount of output token.
recipient
address
The recipient address.
Last updated