> For the complete documentation index, see [llms.txt](https://eosfi.gitbook.io/zh-cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://eosfi.gitbook.io/zh-cn/kai-fa-zhe/dolphinswap-zuo-shi-jie-ru.md).

# DolphinSwap做市接入

## 合约名

Dolphin Swap的合约名是：dolphinsswap

可以使用bloks区块浏览器查看合约信息：[点击查看](https://bloks.io/account/dolphinsswap?loadContract=true\&tab=Tables\&account=dolphinsswap\&scope=dolphinsswap\&limit=100)

## 基础类型

### pooltoken

| 字段      | 类型               | 说明            |
| ------- | ---------------- | ------------- |
| weight  | uint32\_t        | 权重            |
| symbol  | extended\_symbol | 币种，带合约名、符号和精度 |
| reserve | asset            | 币种的资产总量       |

## 流动池 Pool

### 说明

pool表是用于存放所有交易对数据的表，是整个合约的核心部分。

### 表结构

Table: pools

Scope: dolphinsswap

| 字段                 | 类型           | 说明               |
| ------------------ | ------------ | ---------------- |
| id                 | uint64\_t    | 流动池ID            |
| code               | symbol\_code | 做市凭证的名字，例如DOPA   |
| swap\_fee          | uint16\_t    | 交易费率，计算时除以10000  |
| total\_lptoken     | uint64\_t    | 做市凭证总数           |
| create\_time       | uint32\_t    | 流动池创建时间          |
| last\_update\_time | uint32\_t    | 上次更新的时间          |
| tokens             | std::vector  | 交易对列表，包含两种或以上的币种 |

### 请求示例：

```
curl -X POST -d '{"code":"dolphinsswap","scope":"dolphinsswap","table":"pools","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows
```

## 做市凭证表 Lptoken

### 说明

lptoken表是用于存储用户做市凭证(LP)。

### LP命名规则

Dolphin Swap LP Token都是以DOP开头，然后加上流动池的pool\_id转成26进制（字母），例如流动池ID是1，转换后就是DOPA，如果是27，对应的是DOPAA，以此类推。pool\_id转换成lp code的代码方法：

```
symbol_code id2lpcode(uint64_t id) {
    std::string code = "DOP";
    std::string s;
    while (id > 0) {
        uint32_t rem = id % 26;
        if (rem == 0) rem = 26;
        s += ('A' + rem - 1);
        id = (id - rem) / 26;
    }
    std::reverse(s.begin(), s.end());
    code += s;
    return symbol_code(code.c_str());
}
```

### 表结构

Table: lptokens

Scope: 做市凭证名字，例如DOPA

| 字段    | 类型        | 说明   |
| ----- | --------- | ---- |
| owner | name      | 做市用户 |
| token | uint64\_t | 凭证数量 |

### 请求示例：

```
curl -X POST -d '{"code":"dolphinsswap","scope":"DOPA","table":"lptokens","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows
```

## 做市存款表 Deposit

### 说明

deposit表是用于存储临时的做市存款，用户做市需要充值多个资产，该表用于临时记录用户的单次做市存款，做市成功后该条记录会自动清除。

### 表结构

Table: deposits

Scope: pool\_id

| 字段         | 类型          | 说明     |
| ---------- | ----------- | ------ |
| owner      | name        | 做市存款用户 |
| quantities | std::vector | 存款资产列表 |

### 请求示例：

```
curl -X POST -d '{"code":"dolphinsswap","scope":1,"table":"deposits","json":true,"limit":10}' -H 'Content-Type: application/json' http://eos.greymass.com/v1/chain/get_table_rows
```
