> For the complete documentation index, see [llms.txt](https://docs.secretswap.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.secretswap.net/developer-guide/pair.md).

# Pair

## Transaction

### Provide liquidity

Send user's assets to SecretSwap contract and provide liquidity.

Assets can be both SNIP20 and native tokens. It can be distinguished with the key under `info.token` or `info.native_token`.&#x20;

```javascript
{
  "provide_liquidity": {
    "assets": [
      {
        "info": {
          "token": {
            "contract_addr": "<HumanAddr>",
            "token_code_hash": "<HASH>",
            "viewing_key": "" // empty
          }
        },
        "amount": "10"
      },
      {
        "info": {
          "native_token": {
            "denom": "uscrt"
          }
        },
        "amount": "10"
      }
    ],
    "slippage_tolerance": 0.1 // optinonal
  }
}
```

{% hint style="info" %}
For SNIP20 assets, you first have to set an allowance for the pair to spend the token.
{% endhint %}

{% hint style="info" %}
For SCRT, you have to send the SCRT amount to the `provide_liquidity` contract call.&#x20;
{% endhint %}

### Swap

Swap between the given two tokens. `offer_asset` is your source asset and `to` is your destination token contract.

```javascript
{
  "swap": {
    "offer_asset": {
      "info": {
        "native_token": {
          "denom": "uluna"
        }
      },
      "amount": "10"
    },
    "expected_return": "13", // optional
    "belief_price": 0.1, // optional
    "max_spread": 0.1, // optional
    "to": "<HumanAddr>" // optional
  }
}
```

```javascript
{
  "swap": {
    "offer_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    },
    "expected_return": "13", // optional
    "belief_price": 0.1, // optional
    "max_spread": 0.1, // optional
    "to": "<HumanAddr>" // optional
  }
}
```

## Query

### Pool

```javascript
{
  "pool": {}
}
```

### Simulation

```javascript
{
  "simulation": {
    "offer_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    }
  }
}
```

### Reverse Simulation

```javascript
{
  "reverse_simulation": {
    "ask_asset": {
      "info": {
        "token": {
          "contract_addr": "<HumanAddr>",
          "token_code_hash": "<HASH>",
          "viewing_key": "" // empty
        }
      },
      "amount": "10"
    }
  }
}
```
