Skip to content

Commit

Permalink
GitBook: [#27] No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
nullmames authored and gitbook-bot committed Jan 30, 2022
1 parent 4ff091e commit a86007f
Show file tree
Hide file tree
Showing 56 changed files with 750 additions and 2 deletions.
341 changes: 341 additions & 0 deletions .gitbook/assets/JunoSwap Logo .svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap Logo PNG.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner (6).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap giitbook banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5 (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5 (2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5 (3).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5 (4).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5 (5).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook 5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/JunoSwap gitbook.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (10).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (11).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (12).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (13).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added .gitbook/assets/image (14).png
Binary file added .gitbook/assets/image (15).png
Binary file added .gitbook/assets/image (16).png
Binary file added .gitbook/assets/image (17).png
Binary file added .gitbook/assets/image (18).png
Binary file added .gitbook/assets/image (19).png
Binary file added .gitbook/assets/image (2).png
Binary file added .gitbook/assets/image (20).png
Binary file added .gitbook/assets/image (21).png
Binary file added .gitbook/assets/image (22).png
Binary file added .gitbook/assets/image (23).png
Binary file added .gitbook/assets/image (24).png
Binary file added .gitbook/assets/image (25).png
Binary file added .gitbook/assets/image (26).png
Binary file added .gitbook/assets/image (27).png
Binary file added .gitbook/assets/image (3).png
Binary file added .gitbook/assets/image (4).png
Binary file added .gitbook/assets/image (5).png
Binary file added .gitbook/assets/image (6).png
Binary file added .gitbook/assets/image (7).png
Binary file added .gitbook/assets/image (8).png
Binary file added .gitbook/assets/image (9).png
Binary file added .gitbook/assets/image.png
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
# junoswap-docs
repo for gitbook docs
---
description: >-
JunoSwap is the first ever interchain decentralized exchange focussed on CW-20
(CosmWasm) asset adoption. Built from scratch on the public permission-less
Juno Network.
---

# JunoSwap - The Interchain DEX

![](<.gitbook/assets/JunoSwap Logo .svg>)
15 changes: 15 additions & 0 deletions SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Table of contents

* [JunoSwap - The Interchain DEX](README.md)

## 🧑💼 USERS

* [AMM Overview](users/amm-overview.md)
* [Connect Keplr + Deposit Assets](users/connect-keplr-+-deposit-assets.md)
* [Add or Remove Liquidity](users/add-or-remove-liquidity.md)
* [Swap Assets](users/swap-assets.md)

## 👨💻 DEVELOPERS

* [Create an AMM Pool](developers/create-an-amm-pool.md)
* [Integrate Pool to JunoSwap UI](developers/integrate-pool-to-junoswap-ui.md)
145 changes: 145 additions & 0 deletions developers/create-an-amm-pool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
description: General instructions on creating an AMM pool for use on the JunoSwap.com UI
cover: ../.gitbook/assets/JunoSwap gitbook 5 (1).png
coverY: 0
---

# Create an AMM Pool

JunoSwap AMM pools are created by interacting with the JunoSwap smart contract. These instructions will outline the arguments for your command and the procedure to successfully create your AMM pool on the JunoSwap smart contract.

An AMM pool can be created with any combination of native token, IBC coins and CW20 coins. Developing CW20 coins is outside the scope of this documentation. Refer to information [here](https://docs.junonetwork.io/smart-contracts-and-junod-development/tutorial-erc-20) to get started.

To create a new AMM pool, you will need to have the correct `denom` designations for your coins. In this example, we will be using native JUNO and IBC SCRT. The `denom` for these coins are:

| Symbol | Denom |
| ------ | -------------------------------------------------------------------- |
| JUNO | ujuno |
| SCRT | ibc/CD78EE5B20682E5A61B4D96C9F4DC39361269B88A6B3462C26A18652F7A90A9A |

You can find the `denom` of a token by querying your wallet address:

```bash
junod q bank balances <wallet-address>
```

The procedure to create a new AMM pool is to:

1. [create the empty pool](create-an-amm-pool.md#create-empty-pool); and
2. [add liquidity](create-an-amm-pool.md#add-liquidity-to-amm-pool)

### Create empty pool

The wasm contract `Code ID` of the junoswap contract is `16`. More information on wasm contracts [here](https://docs.cosmwasm.com/docs/1.0/).

To create an empty pool we need to instantiate the wasm contract with our pool data. Using our `denom`'s identified earlier:

```bash
junod tx wasm instantiate 16 \
'{"token1_denom": {"native": "ujuno"},"token2_denom": {"native": "ibc/CD78EE5B20682E5A61B4D96C9F4DC39361269B88A6B3462C26A18652F7A90A9A"},"lp_token_code_id": 1}' \
--label "JUNO SCRT Pool" \
--gas 10000000 \
--fees 250000ujuno \
--from <wallet-name>
```

{% hint style="info" %}
Replace \<wallet-name> with the name of your wallet in your local keystore.
{% endhint %}

If we query the `<transaction-hash>` resultant from the instantiate transaction:

```bash
junod q tx <transaction-hash> | jq -r .raw_log | jq .
```

{% hint style="info" %}
`<transaction-hash>` will look similar to `CA8A5EC4FB69B3DA95411212C9FDB9CF2A4D2128F6D3A15CFBA56136D760E023`
{% endhint %}

We will have a result similar to:

```json
[
{
"type": "instantiate",
"attributes": [
{
"key": "_contract_address",
"value": "juno1zz8vspvcq7a3t40sy6xfxa3yk8wuy3vr8clyn3pt8pthpucnvpyqes54md"
},
{
"key": "code_id",
"value": "16"
},
{
"key": "_contract_address",
"value": "juno1quce89l8clsn8s5tmq5sylg370h58xfnkwadx72crjv90jmetp4s3fkysl"
},
{
"key": "code_id",
"value": "1"
}
]
},
{
"type": "message",
"attributes": [
{
"key": "action",
"value": "/cosmwasm.wasm.v1.MsgInstantiateContract"
},
{
"key": "module",
"value": "wasm"
},
{
"key": "sender",
"value": "juno19w2488ntfgpduzqq3sk4j5x387zynwkn9rn2x3"
}
]
},
{
"type": "reply",
"attributes": [
{
"key": "_contract_address",
"value": "juno1zz8vspvcq7a3t40sy6xfxa3yk8wuy3vr8clyn3pt8pthpucnvpyqes54md"
}
]
}
]
```

From this stdout we can extract the junoswap contract address and the liquidity pool contract address. In this case:

| <p>junoswap </p><p>contract address</p> | juno1zz8vspvcq7a3t40sy6xfxa3yk8wuy3vr8clyn3pt8pthpucnvpyqes54md |
| --------------------------------------------- | --------------------------------------------------------------- |
| <p>liquidity pool </p><p>contract address</p> | juno1quce89l8clsn8s5tmq5sylg370h58xfnkwadx72crjv90jmetp4s3fkysl |

### Add liquidity to AMM pool

To add liquidity, we must first make sure we have funded our wallet with enough token to deposit into the AMM pool. in this example we will be adding `250ujuno` and `1000uscrt`. Please note that we must use the correct `denom` for the tokens on chain.

We will use the following command to send the `add_liquidity` message to our junoswap contract:

```bash
junod tx wasm execute juno1zz8vspvcq7a3t40sy6xfxa3yk8wuy3vr8clyn3pt8pthpucnvpyqes54md \
'{"add_liquidity": {"token1_amount": "250", "min_liquidity": "0", "max_token2": "1000"}}' \
--from <wallet-name> \
--gas 1500000 \
--amount 250ujuno,1000ibc/CD78EE5B20682E5A61B4D96C9F4DC39361269B88A6B3462C26A18652F7A90A9A \
--fees 37500ujuno
```

{% hint style="info" %}
Note that we have used the IBC `denom` for `uscrt` when sending the argument for the `--amount` flag.
{% endhint %}

Check the resultant transaction hash to ensure the transaction was successful:

```bash
junod q tx <transaction-hash>
```

Now that we have created and funded the AMM pool, we can [add it to the JunoSwap user interface](integrate-pool-to-junoswap-ui.md).
71 changes: 71 additions & 0 deletions developers/integrate-pool-to-junoswap-ui.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
description: General instructions for integration of your AMM pool into the JunoSwap.com UI
cover: ../.gitbook/assets/JunoSwap gitbook 5 (3).png
coverY: 0
---

# Integrate Pool to JunoSwap UI

To enable your pool to be visible and useable on the junoswap.com user interface, you must:

1. create formatted JSON according to the template provided;
2. fork the junoswap-asset-list repository on GitHub;
3. add your pool data to token\_list.json; and
4. submit a PR to be assessed and merged.

Please carefully follow these instructions so that your pull request is not rejected.

### Create JSON for integration

The following example JSON is to integrate native JUNO and IBC SCRT pool into the junoswap.com user interface.

You will need to use the `swap_address` that was returned when you created your AMM pool. See [here](create-an-amm-pool.md) for instructions.

You must ensure that your `pool_id` is unique and formatted correctly or your pull request will be rejected. Please use the dominant token first, followed by `-` and then your secondary token.

```json
{
"id": "secret",
"pool_id": "JUNO-SCRT",
"chain_id": "secret-4",
"token_address": "",
"swap_address": "juno1zz8vspvcq7a3t40sy6xfxa3yk8wuy3vr8clyn3pt8pthpucnvpyqes54md",
"symbol": "SCRT",
"name": "SCRT",
"decimals": 6,
"logoURI": "https://raw.githubusercontent.com/osmosis-labs/assetlists/main/images/scrt.png",
"tags": ["native"],
"native":true,
"ibc/CD78EE5B20682E5A61B4D96C9F4DC39361269B88A6B3462C26A18652F7A90A9A"
}
```

{% hint style="info" %}
`pool_id`: unique id

`chain_id`: source chain id or juno-1 if token

`token address`: cw20 token address or empty if native

`swap address`: swap contract address
{% endhint %}

### Fork the assets GitHub repo and add json

You will need to fork the junoswap-asset-list repository:

{% embed url="https://github.com/CosmosContracts/junoswap-asset-list" %}

After forking the repository, locate the asset list: `junoswap-asset-list/token_list.json`

Edit this file. Scroll to the bottom of the list and add your JSON to the end of the `tokens` array in the same manor as all the other pool entries. Please ensure you ad a `,` to the preceding JSON closing curly brace.

Submit a PR with your changes with the following name:

`Add <pool_id>`&#x20;

{% hint style="info" %}
Replace `<pool_id>` with the one used in your JSON.
{% endhint %}

Monitor your pull request and answer any questions from the team, and make modifications as requested.
59 changes: 59 additions & 0 deletions users/add-or-remove-liquidity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
cover: ../.gitbook/assets/JunoSwap gitbook 5 (2).png
coverY: 0
---

# Add or Remove Liquidity

Addiing liquidity to JunoSwap will allow you to earn passive income through various reward functions. These functions include:

* Collection of swap fees from individuals using the swap function of JunoSwap. Your swap fees are calculated based on the percentage of the liquidity pool that your portion of liquidity represents. For example, if you had $50 in a liquidity pool with a total of $100, your liquidity would represent 50% of the pool. These fees are automatically added to your total liquidity as they are incurred.
* Liquidity incentives. There are various incentive mechanisms which reward liquidity providers in the form of additional tokens. These rewards are credited directly to your Juno wallet address.

This tutorial will show show the user how to add liquidity to JunoSwap through the user interface.

### Add liquidity to pool

Begin by selecting the liquidity page on JunoSwap.

![](<../.gitbook/assets/image (17).png>)

You will then be presented with a page that displays all of the available trading pairs on JunoSwap. Select the par you would like to add liquidity too by by click the liquidity pair card. We will be selecting the "JUNO-HUAHUA" pair for this tutorial.

![](<../.gitbook/assets/image (24).png>)

You will be presented with the pool page. Select "Add liquidity from the **Your liquidity** card.

![](<../.gitbook/assets/image (15).png>)

You will be presented with the **Manage liquidity** dialogue box. Enter the amount you would like to deposit for either asset. The other asset amount will auto populate based on the current pool swap rate. click the black box to continue. For this tutorial we will deposit 1000 HUAHUA with the Juno field auto populated.

![](<../.gitbook/assets/image (21).png>)

Check and approve the transaction in the Keplr popup window.

![](<../.gitbook/assets/image (9).png>)

Congratulations, you have added liquidity which will now be shown under **My pools** on your liquidity page.

![](<../.gitbook/assets/image (10).png>)

### Remove liquidity

To remove liquidity, you can select the pool liquidity pair card from **My Pools** section of the **Liquidity** page by clicking the card.

![](<../.gitbook/assets/image (22).png>)

You will be presented with the page for the selected liquidity pool, in this case, the **Juno + HUAHUA** pool. Select "Manage liquidity".

![](<../.gitbook/assets/image (6).png>)

You will then be presented with a dialogue window where you can manage your liquidity for the pair. Select the "Remove" tab and then either enter or select the percentage of your liquidity you would like to remove. For this tutorial we will remove all the liquidity. Click "Remove liquidity after you have made your selection.

![](<../.gitbook/assets/image (11).png>)

You will be presented with a Keplr transaction popup window. Review the transaction and click "Approve".

![](<../.gitbook/assets/image (20).png>)

Congratulations, you have successfully removed your liquidity. Your funds will be credited to your Juno wallet.
14 changes: 14 additions & 0 deletions users/amm-overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
cover: ../.gitbook/assets/JunoSwap gitbook 5 (4).png
coverY: 0
---

# AMM Overview

The JunoSwap AMM consists of the following components:

* the Swap interface
* the asset transfer interface
* the liquidity management interface

A tutorial for each of these components has been developed to assist new users in operation of the AMM.
56 changes: 56 additions & 0 deletions users/connect-keplr-+-deposit-assets.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
cover: ../.gitbook/assets/JunoSwap gitbook 5.png
coverY: 0
---

# Connect Keplr + Deposit Assets



This tutorial will show the user how to connect their Keplr wallet to the AMM and deposit assets from other native blockchains to the Juno Network for use on the AMM.

### Connect Keplr

JunoSwap at this stage of development can only be operated by connecting your Keplr web 3 browser extension wallet. Instructions of setting up your keplr wallet can be found [here](https://docs.junonetwork.io/tutorials/wallets/keplr-browser-extension).

Click the "Connect Keplr" button on the menu sidebar.

![](<../.gitbook/assets/image (12).png>)

Keplr may ask you to approve the connection to the platform. Click "Approve" to continue.

Ensure that you have your desired account selected in the Keplr wallet.

After connecting, you wallet name and balance will show in place of the Connect Keplr button.

![](<../.gitbook/assets/image (16).png>)

### Deposit tokens to Juno Network

To be able to use tokens from other native networks, we must first transfer these assets to the Juno Network. This is made easy providing deposit and withdraw function of the "Transfer" page of junoswap.com

To begin the process, first select the "Transfer" page from the sidebar menu.

![](<../.gitbook/assets/image (14).png>)

From the transfer page, find the asset you would like to deposit and locate and click the "Deposit" button on that asset line.

![](<../.gitbook/assets/image (18).png>)

You will be presented with a window requesting access to your Keplr account associated with that asset. Select "Approve" to continue.

![](<../.gitbook/assets/image (2).png>)

The deposit window will now show your available balance on the native chain. Type in the amount you would like to deposit onto JunoSwap and click "Deposit".

![](<../.gitbook/assets/image (25).png>)

Approve the Keplr transaction after checking the transaction details. This action will create an IBC transfer from the host chain to Juno Network.

![](<../.gitbook/assets/image (8).png>)

After successfully depositing you assets, they will be shown on the "My tokens" list.

![](<../.gitbook/assets/image (3).png>)

Your tokens are now available for use on the platform.
Loading

0 comments on commit a86007f

Please sign in to comment.