DolphinSwap做市接入
本文档用于介绍Dolphin Swap的合约表结构,方便第三方开发者接入。
合约名
Dolphin Swap的合约名是:dolphinsswap
可以使用bloks区块浏览器查看合约信息:点击查看
基础类型
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
最后更新于