> For the complete documentation index, see [llms.txt](https://bitlong.gitbook.io/api-doc/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bitlong.gitbook.io/api-doc/tapd-api/pool.md).

# Pool

本文的token指代币，请与`Bearer Token`作区分，本文的代币指资产。

本文的代币数量均为整数，只有LP奖励和手续费可能包含浮点数，但均用字符串存储，便于大整数或高精度浮点数计算。

## 查询

所有接口需要 `Bearer Token`

### 1.池信息

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/pool_info`

示例

/pool/query/pool\_info?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID

*A、B顺序无所谓，相同的两个* `token` *查到的都是同一个池*

#### 响应

* `pair_id` <mark style="color:orange;">uint</mark> pair ID，pair指代币对
* `share_id` <mark style="color:orange;">uint</mark> share ID，share指份额，对池添加流动性的用户可以获得share
* `is_token_zero_sat` <mark style="color:orange;">bool</mark> 该池是否为聪和资产
* `token0` <mark style="color:orange;">string</mark> 代币0，`sat`或资产ID
* `token1` <mark style="color:orange;">string</mark> 代币1，资产ID
* `reserve0` <mark style="color:orange;">string</mark> 代币0池余额
* `reserve1` <mark style="color:orange;">string</mark> 代币1池余额
* `liquidity` <mark style="color:orange;">string</mark> 总流动性，实际为当前总发放的share

```json
{"errno":0,"errmsg":"","data":{"pair_id":1,"share_id":1,"is_token_zero_sat":true,"token0":"sat","token1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","reserve0":"1990832","reserve1":"1971917","liquidity":"1979980"}}
```

### 2.1.\[总数]流动性和奖励记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/liquidity_and_award_records/count`

示例

/pool/query/liquidity\_and\_award\_records/count

#### 参数

无

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":1}
```

### 2.2.\[分页]流动性和奖励记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/liquidity_and_award_records`

示例

/pool/query/liquidity\_and\_award\_records?<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>

#### 参数

* `limit` 限制数据条数
* `offset` 跳过数据条数

#### 响应

* `token_0`<mark style="color:orange;">string</mark> 代币0，`sat`或资产ID
* `token_1`<mark style="color:orange;">string</mark> 代币1，资产ID
* `liquidity`<mark style="color:orange;">string</mark> 流动性
* `lp_award_balance`<mark style="color:orange;">string</mark> 可提取奖励余额
* `lp_award_cumulative`<mark style="color:orange;">string</mark> 总奖励

```json
{"errno":0,"errmsg":"","data":[{"token_0":"sat","token_1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","liquidity":"989990","lp_award_balance":"304.2210769","lp_award_cumulative":"604.2210769"}]}
```

### 3.1.\[总数]池流动性添加/移除记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/share_records/count`

示例

/pool/query/share\_records/count?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">username</mark>=<mark style="color:blue;">ivan</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `username` 用户名，可选字段，查询指定用户参与的记录。可置空或不加该字段，即查询所有用户

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":2}
```

### 3.2.\[分页]池流动性添加/移除记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/share_records`

示例

/pool/query/share\_records?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>&<mark style="color:orange;">username</mark>=<mark style="color:blue;">ivan</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `limit` 限制数据条数
* `offset` 跳过数据条数

*例如：一共有14条记录，查询第10-14条记录，则* `offset`=&#x39;*，*`limit`>=5 *即可*

* `username` 用户名，可选字段，查询指定用户参与的记录。可置空或不加该字段，即查询所有用户。

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `share_id` <mark style="color:orange;">uint</mark> share ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `liquidity` <mark style="color:orange;">string</mark> 流动性
* `reserve0` <mark style="color:orange;">string</mark> 代币0池余额
* `reserve1` <mark style="color:orange;">string</mark> 代币1池余额
* `amount0` <mark style="color:orange;">string</mark> 代币0数量
* `amount1` <mark style="color:orange;">string</mark> 代币1数量
* `share_supply` <mark style="color:orange;">string</mark> 总share数量
* `share_amt` <mark style="color:orange;">string</mark> 该用户share数量
* `is_first_mint` <mark style="color:orange;">bool</mark> 是否第一次对池添加流动性
* `record_type` <mark style="color:orange;">int</mark> 记录类型

  `0` 添加流动性

  `1` 移除流动性

```json
{"errno":0,"errmsg":"","data":[{"id":4,"time":1733882272,"share_id":1,"username":"ivan","liquidity":"10000","reserve0":"1990030","reserve1":"1990030","amount0":"9970","amount1":"9970","share_supply":"1989980","share_amt":"999990","is_first_mint":false,"record_type":1},{"id":1,"time":1733817927,"share_id":1,"username":"ivan","liquidity":"999990","reserve0":"0","reserve1":"0","amount0":"1000000","amount1":"1000000","share_supply":"0","share_amt":"0","is_first_mint":true,"record_type":0}]}
```

### 4.1.\[总数]用户所有池流动性添加/移除记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/all_share_records/count`

示例

/pool/query/all\_share\_records/count

#### 参数

无

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":2}
```

### 4.2.\[分页]用户所有池流动性添加/移除记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/all_share_records`

示例

/pool/query/all\_share\_records?<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>

#### 参数

* `limit` 限制数据条数
* `offset` 跳过数据条数

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `token0` <mark style="color:orange;">string</mark> 代币0，`sat`或资产ID
* `token1` <mark style="color:orange;">string</mark> 代币1，资产ID
* `share_id` <mark style="color:orange;">uint</mark> share ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `liquidity` <mark style="color:orange;">string</mark> 流动性
* `reserve0` <mark style="color:orange;">string</mark> 代币0池余额
* `reserve1` <mark style="color:orange;">string</mark> 代币1池余额
* `amount0` <mark style="color:orange;">string</mark> 代币0数量
* `amount1` <mark style="color:orange;">string</mark> 代币1数量
* `share_supply` <mark style="color:orange;">string</mark> 总share数量
* `share_amt` <mark style="color:orange;">string</mark> 该用户share数量
* `is_first_mint` <mark style="color:orange;">bool</mark> 是否第一次对池添加流动性
* `record_type` <mark style="color:orange;">int</mark> 记录类型

  `0` 添加流动性

  `1` 移除流动性

```json
{"errno":0,"errmsg":"","data":[{"id":3,"time":1733882272,"token0":"sat","token1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","share_id":1,"username":"bob","liquidity":"10000","reserve0":"2000000","reserve1":"2000000","amount0":"9970","amount1":"9970","share_supply":"1999980","share_amt":"999990","is_first_mint":false,"record_type":1},{"id":2,"time":1733817927,"token0":"sat","token1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","share_id":1,"username":"bob","liquidity":"999990","reserve0":"1000000","reserve1":"1000000","amount0":"1000000","amount1":"1000000","share_supply":"999990","share_amt":"0","is_first_mint":false,"record_type":0}]}
```

### 5.流动性持有量

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/share_balance`

示例

/pool/query/share\_balance？<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `share_id` <mark style="color:orange;">uint</mark> share ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `balance` <mark style="color:orange;">string</mark> 流动性持有量(余额)

```json
{"errno":0,"errmsg":"","data":{"id":2,"share_id":1,"username":"bob","balance":"989990"}}
```

### 6.1.\[总数]swap交易记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/swap_records/count`

示例

/pool/query/swap\_records/count?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">username</mark>=<mark style="color:blue;">eve</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `username` 用户名，可选字段，查询指定用户参与的记录。可置空或不加该字段，即查询所有用户

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":2}
```

### 6.2.\[分页]swap交易记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/swap_records`

示例

/pool/query/swap\_records?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>&<mark style="color:orange;">username</mark>=<mark style="color:blue;">eve</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `limit` 限制数据条数
* `offset` 跳过数据条数
* `username` 用户名，可选字段，查询指定用户参与的记录。可置空或不加该字段，即查询所有用户。

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `pair_id` <mark style="color:orange;">uint</mark> pair ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_in` <mark style="color:orange;">string</mark> 换入代币数量
* `amount_out` <mark style="color:orange;">string</mark> 换出代币数量
* `reserve_in` <mark style="color:orange;">string</mark> 换入代币池余额
* `reserve_out` <mark style="color:orange;">string</mark> 换出代币池余额
* `swap_fee` <mark style="color:orange;">string</mark> 交易费
* `swap_fee_type` <mark style="color:orange;">int</mark> 交易费类型

  `0` 千分之六手续费（单位非聪，为代币(资产)）

  `1` 千分之六手续费(单位：聪)

  `2` 最低20聪手续费
* `swap_record_type` <mark style="color:orange;">int</mark> 交易类型

  `0` 指定具体数量代币交换不定数量另一代币

  `1` 不定数量代币交换指定数量另一代币

```json
{"errno":0,"errmsg":"","data":[{"id":8,"time":1733883214,"pair_id":1,"username":"eve","token_in":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","token_out":"sat","amount_in":"9915","amount_out":"10000","reserve_in":"1962002","reserve_out":"2000832","swap_fee":"60.16766955","swap_fee_type":1,"swap_record_type":1},{"id":7,"time":1733883214,"pair_id":1,"username":"eve","token_in":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","token_out":"sat","amount_in":"9816","amount_out":"10000","reserve_in":"1952186","reserve_out":"2010832","swap_fee":"60.7724305","swap_fee_type":1,"swap_record_type":1}]}
```

### 7.1.\[总数]用户所有swap交易记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/all_swap_records/count`

示例

/pool/query/all\_swap\_records/count

#### 参数

无

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":2}
```

### 7.2.\[分页]用户所有swap交易记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/all_swap_records`

示例

/pool/query/all\_swap\_records?<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>

#### 参数

* `limit` 限制数据条数
* `offset` 跳过数据条数

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `token0` <mark style="color:orange;">string</mark> 代币0，`sat`或资产ID
* `token1` <mark style="color:orange;">string</mark> 代币1，资产ID
* `pair_id` <mark style="color:orange;">uint</mark> pair ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_in` <mark style="color:orange;">string</mark> 换入代币数量
* `amount_out` <mark style="color:orange;">string</mark> 换出代币数量
* `reserve_in` <mark style="color:orange;">string</mark> 换入代币池余额
* `reserve_out` <mark style="color:orange;">string</mark> 换出代币池余额
* `swap_fee` <mark style="color:orange;">string</mark> 交易费
* `swap_fee_type` <mark style="color:orange;">int</mark> 交易费类型

  `0` 千分之六手续费（单位非聪，为代币(资产)）

  `1` 千分之六手续费(单位：聪)

  `2` 最低20聪手续费
* `swap_record_type` <mark style="color:orange;">int</mark> 交易类型

  `0` 指定具体数量代币交换不定数量另一代币

  `1` 不定数量代币交换指定数量另一代币

```json
{"errno":0,"errmsg":"","data":[{"id":6,"time":1733883214,"token0":"sat","token1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","pair_id":1,"username":"bob","token_in":"sat","token_out":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","amount_in":"10310","amount_out":"10000","reserve_in":"2000522","reserve_out":"1962186","swap_fee":"62","swap_fee_type":1,"swap_record_type":1},{"id":5,"time":1733883214,"token0":"sat","token1":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","pair_id":1,"username":"bob","token_in":"sat","token_out":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","amount_in":"10205","amount_out":"10000","reserve_in":"1990317","reserve_out":"1972186","swap_fee":"61","swap_fee_type":1,"swap_record_type":1}]}
```

### 8.LP奖励余额信息

LP(Liquidity Provider) 即流动性提供者，如果用户对某池添加过流动性，则该用户被称为该池的LP，该池的每一笔交易会给该LP发放奖励，奖励达到一定数量可以进行提现。

此接口查询自己的奖励余额(单位：聪)。

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/lp_award_balance`

示例

/pool/query/lp\_award\_balance

#### 参数

无

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `balance` <mark style="color:orange;">string</mark> 余额

```json
{"errno":0,"errmsg":"","data":{"ID":1,"balance":"304.2210769"}}
```

### 9.1.\[总数]奖励记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/lp_award_records/count`

示例

/pool/query/lp\_award\_records/count

#### 参数

无

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":8}
```

### 9.2.\[分页]奖励记录

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/lp_award_records`

示例

/pool/query/lp\_award\_records?<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>

#### 参数

* `limit` 限制数据条数
* `offset` 跳过数据条数

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `share_id` <mark style="color:orange;">uint</mark> share ID
* `amount` <mark style="color:orange;">string</mark> 奖励数量
* `fee` <mark style="color:orange;">string</mark> 来自swap交易费总额
* `award_balance` <mark style="color:orange;">string</mark> 当时奖励余额
* `share_balance` <mark style="color:orange;">string</mark> 当时持有流动性
* `total_supply` <mark style="color:orange;">string</mark> 当时池总流动性
* `swap_record_id` <mark style="color:orange;">uint</mark> Swap 记录 ID
* `award_type` <mark style="color:orange;">int</mark> 奖励类型

  `0` <mark style="color:orange;">int</mark> Swap奖励

(目前只有一种类型)

```json
{"errno":0,"errmsg":"","data":[{"id":47,"time":1735022324,"share_id":3,"amount":"15.04191739","fee":"60.16766955","award_balance":"589.1791595","share_balance":"989990","total_supply":"1979980","swap_record_id":24,"award_type":0},{"id":45,"time":1735022324,"share_id":3,"amount":"15.19310762","fee":"60.7724305","award_balance":"573.9860519","share_balance":"989990","total_supply":"1979980","swap_record_id":23,"award_type":0},{"id":43,"time":1735022324,"share_id":3,"amount":"15.5","fee":"62","award_balance":"558.4860519","share_balance":"989990","total_supply":"1979980","swap_record_id":22,"award_type":0},{"id":41,"time":1735022324,"share_id":3,"amount":"15.25","fee":"61","award_balance":"543.2360519","share_balance":"989990","total_supply":"1979980","swap_record_id":21,"award_type":0},{"id":39,"time":1735022318,"share_id":3,"amount":"135.4525788","fee":"541.8103151","award_balance":"407.7834731","share_balance":"989990","total_supply":"1979980","swap_record_id":20,"award_type":0},{"id":37,"time":1735022318,"share_id":3,"amount":"136.5","fee":"546","award_balance":"271.2834731","share_balance":"989990","total_supply":"1979980","swap_record_id":19,"award_type":0},{"id":35,"time":1735022318,"share_id":3,"amount":"135.2834731","fee":"541.1338923","award_balance":"136","share_balance":"989990","total_supply":"1979980","swap_record_id":18,"award_type":0},{"id":33,"time":1735022318,"share_id":3,"amount":"136","fee":"544","award_balance":"0","share_balance":"989990","total_supply":"1979980","swap_record_id":17,"award_type":0}]}
```

### 10.1.\[总数]奖励提现记录

此接口查询自己的奖励提现记录总数。

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/withdraw_award_records/count`

示例

/pool/query/withdraw\_award\_records/count

#### 参数

无

#### 响应

`data` 总数

```json
{"errno":0,"errmsg":"","data":2}
```

### 10.2.\[分页]奖励提现记录

此接口查询自己的奖励提现记录。

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/query/withdraw_award_records`

示例

/pool/query/withdraw\_award\_records?<mark style="color:orange;">limit</mark>=<mark style="color:blue;">10</mark>&<mark style="color:orange;">offset</mark>=<mark style="color:blue;">0</mark>

#### 参数

* `limit` 限制数据条数
* `offset` 跳过数据条数

#### 响应

* `id` <mark style="color:orange;">uint</mark> ID
* `time` <mark style="color:orange;">int64</mark> 时间戳
* `username` <mark style="color:orange;">string</mark> 用户名
* `amount` <mark style="color:orange;">string</mark> 提现数量
* `award_balance` <mark style="color:orange;">string</mark> 提现时余额&#x20;

```json
{"errno":0,"errmsg":"","data":[{"id":4,"time":1733884006,"username":"bob","amount":"100","award_balance":"404.2210769"},{"id":3,"time":1733884006,"username":"bob","amount":"200","award_balance":"604.2210769"}]}
```

## 计算

所有接口需要 `Bearer Token`

### 1.添加流动性另一代币成比例数量

简单估算

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/calc/quote`

示例

/pool/calc/quote?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">amount\_a</mark>=<mark style="color:blue;">10000</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `amount_a` 代币A添加数量

#### 响应

* `data` amount\_b，即代币B按池代币比例计算出的数量

```json
{"errno":0,"errmsg":"","data":"9904"}
```

### 2.添加流动性

完整参数，估算结果

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/calc/add_liquidity`

#### 请求体

* `token_a` <mark style="color:orange;">string</mark> 代币A，`sat`或资产ID
* `token_b` <mark style="color:orange;">string</mark> 代币B，`sat`或资产ID
* `amount_a_desired` <mark style="color:orange;">string</mark> 代币A最大添加数量
* `amount_b_desired` <mark style="color:orange;">string</mark> 代币B最大添加数量
* `amount_a_min` <mark style="color:orange;">string</mark> 代币A最小添加数量
* `amount_b_min` <mark style="color:orange;">string</mark> 代币B最小添加数量
* `username` <mark style="color:orange;">string</mark> 用户名

```json
{
    "token_a": "sat",
    "token_b": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_a_desired": "50000",
    "amount_b_desired": "50000",
    "amount_a_min": "40000",
    "amount_b_min": "40000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92"
}
```

#### 响应

* `amount_a` <mark style="color:orange;">string</mark> 代币A实际添加数量
* `amount_b` <mark style="color:orange;">string</mark> 代币B实际添加数量
* `liquidity` <mark style="color:orange;">string</mark> 获得流动性
* `share_record` <mark style="color:orange;">Object</mark> 本次操作生成的流动性操作记录，字段与前文一致

```json
{"errno":0,"errmsg":"","data":{"amount_a":"50000","amount_b":"49524","liquidity":"49726","share_record":{"id":0,"share_id":1,"username":"npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92","liquidity":"49726","reserve0":"1990832","reserve1":"1971917","amount0":"50000","amount1":"49524","share_supply":"1979980","share_amt":"0","is_first_mint":false,"record_type":0}}}
```

### 3.移除流动性代币数量计算

简单估算

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/calc/burn_liquidity`

示例

/pool/calc/burn\_liquidity?<mark style="color:orange;">token\_a</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_b</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">liquidity</mark>=<mark style="color:blue;">100</mark>

#### 参数

* `token_a` 代币A，`sat`或资产ID
* `token_b` 代币B，`sat`或资产ID
* `liquidity` 流动性

#### 响应

* `amount_a` <mark style="color:orange;">string</mark> 代币A可移除数量
* `amount_b` <mark style="color:orange;">string</mark> 代币B可移除数量

```json
{"errno":0,"errmsg":"","data":{"amount_a":"100","amount_b":"99"}}
```

### 4.移除流动性

完整参数，估算结果

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/calc/remove_liquidity`

#### 请求体

* `token_a` <mark style="color:orange;">string</mark> 代币A，`sat`或资产ID
* `token_b` <mark style="color:orange;">string</mark> 代币B，`sat`或资产ID
* `liquidity` <mark style="color:orange;">string</mark> 要移除的流动性数量
* `amount_a_min` <mark style="color:orange;">string</mark> 代币A最小移除数量
* `amount_b_min` <mark style="color:orange;">string</mark> 代币B最小移除数量
* `username` <mark style="color:orange;">string</mark> 用户名
* `fee_k` <mark style="color:orange;">string</mark> 手续费比例，固定填3，代表千分之三

```json
{
    "token_a": "sat",
    "token_b": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "liquidity": "2000",
    "amount_a_min": "1900",
    "amount_b_min": "1900",
    "username": "bob",
    "fee_k": 3
}
```

#### 响应

* `amount_a` <mark style="color:orange;">string</mark> 代币A实际移除数量
* `amount_b` <mark style="color:orange;">string</mark> 代币B实际移除数量
* `share_record` <mark style="color:orange;">Object</mark> 本次操作生成的流动性操作记录，字段与前文一致

```json
{"errno":0,"errmsg":"","data":{"amount_a":"2004","amount_b":"1985","share_record":{"id":0,"share_id":1,"username":"bob","liquidity":"2000","reserve0":"1990832","reserve1":"1971917","amount0":"2004","amount1":"1985","share_supply":"1979980","share_amt":"989990","is_first_mint":false,"record_type":1}}}
```

### 5.swap换出数量

简单估算

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/calc/amount_out`

示例

/pool/calc/amount\_out?<mark style="color:orange;">token\_in</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_out</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">amount\_in</mark>=<mark style="color:blue;">10000</mark>

#### 参数

* `oken_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_in` <mark style="color:orange;">string</mark> 换入代币数量

#### 响应

* `data` amount\_out 换出代币数量

```json
{"errno":0,"errmsg":"","data":"9796"}
```

### 6.swap换入数量

简单估算

#### 请求

<mark style="color:green;">`GET`</mark> `/pool/calc/amount_in`

示例

/pool/calc/amount\_in?<mark style="color:orange;">token\_in</mark>=<mark style="color:blue;">sat</mark>&<mark style="color:orange;">token\_out</mark>=<mark style="color:blue;">9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41</mark>&<mark style="color:orange;">amount\_out</mark>=<mark style="color:blue;">10000</mark>

#### 参数

* `oken_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_out` <mark style="color:orange;">string</mark> 换出代币数量

#### 响应

* `data` amount\_in 换入代币数量

```json
{"errno":0,"errmsg":"","data":"10209"}
```

### 7.swap用确切数量代币交换不确定数量代币(单池)

完整参数，估算结果

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/calc/swap_exact_token_for_token_no_path`

#### 请求体

* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_in` <mark style="color:orange;">string</mark> 换入代币数量
* ~~`amount_out_min`~~ ~~<mark style="color:orange;">string</mark> 换出代币最小数量~~
* `username` <mark style="color:orange;">string</mark> 用户名
* `project_party_fee_k` <mark style="color:orange;">int</mark> 项目方手续费比例，固定填3，代表千分之三
* `lp_award_fee_k` <mark style="color:orange;">int</mark> LP奖励手续费比例，固定填3，代表千分之三
* `slippage` <mark style="color:orange;">uint</mark> 滑点(0-10000)，这里固定传9999

```json
{
    "token_in": "sat",
    "token_out": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_in": "3000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92",
    "project_party_fee_k": 3,
    "lp_award_fee_k": 3,
    "slippage": 9999
}
```

#### 响应

* `amount_out` <mark style="color:orange;">string</mark> 换出代币实际数量
* `swap_record` <mark style="color:orange;">Object</mark> 本次操作生成的swap交易记录，字段与前文一致

```json
{"errno":0,"errmsg":"","data":{"amount_out":"2947","swap_record":{"id":0,"pair_id":1,"username":"npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92","token_in":"sat","token_out":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","amount_in":"3000","amount_out":"2947","reserve_in":"1990832","reserve_out":"1971917","swap_fee":"20","swap_fee_type":2,"swap_record_type":0}}}
```

### 8.swap用不确定数量代币交换确切数量代币(单池)

完整参数，估算结果

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/calc/swap_token_for_exact_token_no_path`

#### 请求体

* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_out` <mark style="color:orange;">string</mark> 换出代币数量
* ~~`amount_in_max`~~ ~~<mark style="color:orange;">string</mark> 换入代币最大数量~~
* `username` <mark style="color:orange;">string</mark> 用户名
* `project_party_fee_k` <mark style="color:orange;">int</mark> 项目方手续费比例，固定填3，代表千分之三
* `lp_award_fee_k` <mark style="color:orange;">int</mark> LP奖励手续费比例，固定填3，代表千分之三
* `slippage` <mark style="color:orange;">uint</mark> 滑点(0-10000)，这里固定传9999

```json
{
    "token_in": "sat",
    "token_out": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_out": "5000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92",
    "project_party_fee_k": 3,
    "lp_award_fee_k": 3,
    "slippage": 9999
}
```

#### 响应

* `amount_in` <mark style="color:orange;">string</mark> 换入代币实际数量
* `swap_record` <mark style="color:orange;">Object</mark> 本次操作生成的swap交易记录，字段与前文一致

```json
{"errno":0,"errmsg":"","data":{"amount_in":"5092","swap_record":{"id":0,"pair_id":1,"username":"npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92","token_in":"sat","token_out":"9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41","amount_in":"5092","amount_out":"5000","reserve_in":"1990832","reserve_out":"1971917","swap_fee":"31","swap_fee_type":1,"swap_record_type":1}}}
```

## 业务

所有接口需要 `Bearer Token`

*<mark style="color:green;">// TODO: 该部分文档，响应返回值已更新，示例JSON待更新，暂以null占位，提现未实现会直接返错误</mark>*

### 1.添加流动性

添加流动性，对于`sat`，至少为1000，否则无法添加。

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/sync/add_liquidity`

#### 请求体

* `token_a` <mark style="color:orange;">string</mark> 代币A，`sat`或资产ID
* `token_b` <mark style="color:orange;">string</mark> 代币B，`sat`或资产ID
* `amount_a_desired` <mark style="color:orange;">string</mark> 代币A最大添加数量
* `amount_b_desired` <mark style="color:orange;">string</mark> 代币B最大添加数量
* `amount_a_min` <mark style="color:orange;">string</mark> 代币A最小添加数量
* `amount_b_min` <mark style="color:orange;">string</mark> 代币B最小添加数量
* `username` <mark style="color:orange;">string</mark> 用户名

```json
{
    "token_a": "sat",
    "token_b": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_a_desired": "50000",
    "amount_b_desired": "50000",
    "amount_a_min": "40000",
    "amount_b_min": "40000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92"
}
```

#### 响应

* `amount_a` <mark style="color:orange;">string</mark> 代币A实际添加数量
* `amount_b` <mark style="color:orange;">string</mark> 代币B实际添加数量
* `liquidity` <mark style="color:orange;">string</mark> 获得流动性

```json
{"errno":0,"errmsg":"","data":null}
```

### 2.移除流动性

~~添加流动性，至少移除1000`sat`，否则无法移除。~~(现1sat即可移除)

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/sync/remove_liquidity`

#### 请求体

* `token_a` <mark style="color:orange;">string</mark> 代币A，`sat`或资产ID
* `token_b` <mark style="color:orange;">string</mark> 代币B，`sat`或资产ID
* `liquidity` <mark style="color:orange;">string</mark> 要移除的流动性数量
* `amount_a_min` <mark style="color:orange;">string</mark> 代币A最小移除数量
* `amount_b_min` <mark style="color:orange;">string</mark> 代币B最小移除数量
* `username` <mark style="color:orange;">string</mark> 用户名
* `fee_k` <mark style="color:orange;">string</mark> 手续费比例，固定填3，代表千分之三

```json
{
    "token_a": "sat",
    "token_b": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "liquidity": "2000",
    "amount_a_min": "1900",
    "amount_b_min": "1900",
    "username": "bob",
    "fee_k": 3
}
```

#### 响应

* `amount_a` <mark style="color:orange;">string</mark> 代币A实际移除数量
* `amount_b` <mark style="color:orange;">string</mark> 代币B实际移除数量

```json
{"errno":0,"errmsg":"","data":null}
```

### 3.swap用确切数量代币交换不确定数量代币(单池)

swap中，由于最小手续费为20sats，sat至少为21

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/sync/swap_exact_token_for_token_no_path`

#### 请求体

* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_in` <mark style="color:orange;">string</mark> 换入代币数量
* ~~`amount_out_min`~~ ~~<mark style="color:orange;">string</mark> 换出代币最小数量~~
* `username` <mark style="color:orange;">string</mark> 用户名
* `project_party_fee_k` <mark style="color:orange;">int</mark> 项目方手续费比例，固定填3，代表千分之三
* `lp_award_fee_k` <mark style="color:orange;">int</mark> LP奖励手续费比例，固定填3，代表千分之三
* `slippage` <mark style="color:orange;">uint</mark> 滑点(0-10000)

```json
{
    "token_in": "sat",
    "token_out": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_in": "3000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92",
    "project_party_fee_k": 3,
    "lp_award_fee_k": 3,
    "slippage": 50
}
```

#### 响应

* `amount_out` <mark style="color:orange;">string</mark> 换出代币实际数量

```json
{"errno":0,"errmsg":"","data":null}
```

### 4.swap用不确定数量代币交换确切数量代币(单池)

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/sync/swap_token_for_exact_token_no_path`

#### 请求体

* `token_in` <mark style="color:orange;">string</mark> 换入代币
* `token_out` <mark style="color:orange;">string</mark> 换出代币
* `amount_out` <mark style="color:orange;">string</mark> 换出代币数量
* ~~`amount_in_max`~~ ~~<mark style="color:orange;">string</mark> 换入代币最大数量~~
* `username` <mark style="color:orange;">string</mark> 用户名
* `project_party_fee_k` <mark style="color:orange;">int</mark> 项目方手续费比例，固定填3，代表千分之三
* `lp_award_fee_k` <mark style="color:orange;">int</mark> LP奖励手续费比例，固定填3，代表千分之三
* `slippage` <mark style="color:orange;">uint</mark> 滑点(0-10000)

```json
{
    "token_in": "sat",
    "token_out": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "amount_out": "5000",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92",
    "project_party_fee_k": 3,
    "lp_award_fee_k": 3,
    "slippage": 50
}
```

#### 响应

* `amount_in` <mark style="color:orange;">string</mark> 换入代币实际数量

```json
{"errno":0,"errmsg":"","data":null}
```

### 5.LP奖励提现

提现到托管账户

#### 请求

<mark style="color:orange;">`POST`</mark> `/pool/sync/withdraw_award`

#### 请求体

* `token_a`  <mark style="color:orange;">string</mark> 代币A，`sat`或资产ID
* `token_b`  <mark style="color:orange;">string</mark> 代币B，`sat`或资产ID
* `username` <mark style="color:orange;">string</mark> 用户名
* `amount` <mark style="color:orange;">string</mark> 提现数量，至少为100，整数

```json
{
    "token_a": "sat",
    "token_b": "9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41",
    "username": "npubTestUserAlice01234567890123456789012345678901234567890123456789012345678901TotalLength92",
    "amount": "1000"
}
```

#### 响应

* `new_balance` <mark style="color:orange;">string</mark> 提现后余额

```json
{"errno":0,"errmsg":"","data":null}
```
