Example
To swap for tokens A and B, a liquidity pool must exist.
If you issued Mint and didn't deposit one liquidity provider for both tokens, the swap will fail.
A token pair (liquidity pool) is created and updated to the following status when a user (wallet) who owns both A and B tokens calls the ProviderLiquidity contract to provide liquidity. If you deposit 1057 tokens, 4877 quantities, a token, the liquidity pool information is generated as follows.
{
"accumulated_reward_per_unit": "0",
"address_a": "46ad99f9f71283e51391d6b221ac6108ed31fd5fa96c7273b1c1edc93a60de
"address_b": "ab554089bd163af30b166bcfbda7cce176b362693a0c36dbdcca1c5fb41d
"pair_address": "65a98a55dd832147cb54925e70444672badaa7a47feb008b70cab43b
"rate_a_to_b": "105...45",
"rate_b_to_a": "4862...3790",
"reserve_a": "4877...0100",
"reserve_b": "105...762",
"total_liquidity": "194369"
}The total swappable quantity (total_liquidity) will be (reserve_a *reserve_b)^ (1/2).
When the user swaps on the liquidity pool present, the amount (reserve of A or B) decreases by the amount corresponding to amount_in, and updates it to k' that satisfies a *b = k. (The swap rate is determined through these reservations, and the depositor receives an lp token) (if you swapped within the limit and met all the prerequisites)
Navite Contracts
Send: Transferring Saseul Gold Coin
Deploy: Smart Contract Deployment
Transfer: token remittance
ProvideLiquidity: Providing liquidity
Swap: token exchange
Withdraw: LP token withdrawal
Faucet: Generating Saseul Gold Coin (Development Network Only)
Navite Contracts
GetBalance: Check Saseul Gold Coin Balance
BalanceOf: Token balance check
GetPairInfo: Check liquidity pool token pair information
Last updated