Skip to content
This repository has been archived by the owner on Jan 31, 2023. It is now read-only.

Commit

Permalink
docs: added frequented message helper
Browse files Browse the repository at this point in the history
  • Loading branch information
psy2848048 committed Nov 25, 2020
1 parent d8802b5 commit ab36d46
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .gitignore
@@ -1,3 +1,3 @@
public/
resources/

server
162 changes: 160 additions & 2 deletions content/docs/howto/freq_used_msg.md
Expand Up @@ -7,10 +7,168 @@ bookFlatSection: true

## Transaction

### Provider liquid
### Provide liquidity / Withdraw

### Withdraw
As the swap ratio is stated as [here]({{< relref "/docs/introduction/mechanism" >}}), the size of the pool is related with the difference of swap ratio. The ratio goes stable if the size of the pool increases, and vice versa. Otherwise, LP provider needs more tokens for adjusting the price in bigger pool. It means that the market loses elastic. LP provider adjusts this market by providing & withdraw the liquidity within this trade-off.

#### Provide liquidity

Contribute to pool by sending sender's token pair. Not only increasing its size, but also it affects to the swap ratio.

Execute this message by the **Pair contract** address!

```json
{
"provide_liquidity": {
"assets": [
{
"info" : {
"token": {
"contract_addr": "<HumanAddr>"
}
},
"amount": "10"
},
{
"info" : {
"native_token": {
"denom": "uluna"
}
},
"amount": "10"
}
]
}
}
```

#### Withdraw

Withdraw your tokens and decrease the size of the pool.

Execute this message by the **Liquidity token contract** address! Not token contract, not pair contract neither!

```json
{
"send": {
"contract": "<PairContractAddress>",
"amount": 123,
"msg": "base64-encodedStringOfWithdrawMsg"
},
}
```

In `send.msg`, you may decode this JSON string into base64 encoding.

```json
{
"withdraw_liquidity": {}
}
```

Then, the liquidity token contract calculates the portion of your liquidity token comparing to the total supply, and withdraw the pairs.

## Query

### Pool

Pool query message returns the amount of the tokens in the pool from the given pair contract address.

```json
{
"pool":{}
}
```

Response:

```json
{
"height": "699536",
"result": {
"assets": [
{
"info": {
"native_token": {
"denom": "ukrw"
}
},
"amount": "616618779506317"
},
{
"info": {
"native_token": {
"denom": "uluna"
}
},
"amount": "1407689375952"
}
],
"total_share": "29432943447776"
}
}
```

### Simulation / Reverse simulation

Simulation works for guessing how much you will be swapped with your token.

If you want to know how much the target token will be given from source token, use `simulation`. Or if you want to derive the number of source token from the number of target token, use this query message.

#### Simulation request

```json
{
"simulation": {
"offer_asset": {
"amount":"10000000",
"info": {
"native_token": {
"denom":"uluna"
}
}
}
}
}
```

#### Simulation request

```json
{
"height": "1274586",
"result": {
"return_amount": "2875706843",
"spread_amount": "147593468",
"commission_amount": "8653079"
}
}
```

#### Reverse simulation response

```json
{
"reverse_simulation":{
"ask_asset": {
"amount":"5000000000",
"info": {
"native_token": {
"denom": "ukrw"
}
}
}
}
}
```

```json
{
"height":"1274605",
"result": {
"offer_amount": "18070071",
"spread_amount": "463716168",
"commission_amount": "15045135"
}
}
```
1 change: 1 addition & 0 deletions content/menu/index.md
Expand Up @@ -11,6 +11,7 @@ headless: true
- [Create Your Own Pair]({{< relref "/docs/howto/create_your_own_pair" >}})
- [Query]({{< relref "/docs/howto/query" >}})
- [Swap]({{< relref "/docs/howto/swap" >}})
- [Frequently Used Message]({{< relref "/docs/howto/freq_used_msg" >}})
<br />
- **Message reference**
- [CW20 Token]({{< relref "/docs/reference/token" >}})
Expand Down

0 comments on commit ab36d46

Please sign in to comment.