Pool
本文的token指代币,请与Bearer Token
作区分,本文的代币指资产。
本文的代币数量均为整数,只有LP奖励和手续费可能包含浮点数,但均用字符串存储,便于大整数或高精度浮点数计算。
查询
所有接口需要 Bearer Token
1.池信息
请求
GET
/pool/query/pool_info
示例
/pool/query/pool_info?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产ID
A、B顺序无所谓,相同的两个 token
查到的都是同一个池
响应
pair_id
uint pair ID,pair指代币对share_id
uint share ID,share指份额,对池添加流动性的用户可以获得shareis_token_zero_sat
bool 该池是否为聪和资产token0
string 代币0,sat
或资产IDtoken1
string 代币1,资产IDreserve0
string 代币0池余额reserve1
string 代币1池余额liquidity
string 总流动性,实际为当前总发放的share
2.1.[总数]流动性和奖励记录
请求
GET
/pool/query/liquidity_and_award_records/count
示例
/pool/query/liquidity_and_award_records/count
参数
无
响应
data
总数
2.2.[分页]流动性和奖励记录
请求
GET
/pool/query/liquidity_and_award_records
示例
/pool/query/liquidity_and_award_records?limit=10&offset=0
参数
limit
限制数据条数offset
跳过数据条数
响应
token_0
string 代币0,sat
或资产IDtoken_1
string 代币1,资产IDliquidity
string 流动性lp_award_balance
string 可提取奖励余额lp_award_cumulative
string 总奖励
3.1.[总数]池流动性添加/移除记录
请求
GET
/pool/query/share_records/count
示例
/pool/query/share_records/count?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&username=ivan
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDusername
用户名,可选字段,查询指定用户参与的记录。可置空或不加该字段,即查询所有用户
响应
data
总数
3.2.[分页]池流动性添加/移除记录
请求
GET
/pool/query/share_records
示例
/pool/query/share_records?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&limit=10&offset=0&username=ivan
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDlimit
限制数据条数offset
跳过数据条数
例如:一共有14条记录,查询第10-14条记录,则 offset
=9,limit
>=5 即可
username
用户名,可选字段,查询指定用户参与的记录。可置空或不加该字段,即查询所有用户。
响应
id
uint IDtime
int64 时间戳share_id
uint share IDusername
string 用户名liquidity
string 流动性reserve0
string 代币0池余额reserve1
string 代币1池余额amount0
string 代币0数量amount1
string 代币1数量share_supply
string 总share数量share_amt
string 该用户share数量is_first_mint
bool 是否第一次对池添加流动性record_type
int 记录类型0
添加流动性1
移除流动性
4.1.[总数]用户所有池流动性添加/移除记录
请求
GET
/pool/query/all_share_records/count
示例
/pool/query/all_share_records/count
参数
无
响应
data
总数
4.2.[分页]用户所有池流动性添加/移除记录
请求
GET
/pool/query/all_share_records
示例
/pool/query/all_share_records?limit=10&offset=0
参数
limit
限制数据条数offset
跳过数据条数
响应
id
uint IDtime
int64 时间戳token0
string 代币0,sat
或资产IDtoken1
string 代币1,资产IDshare_id
uint share IDusername
string 用户名liquidity
string 流动性reserve0
string 代币0池余额reserve1
string 代币1池余额amount0
string 代币0数量amount1
string 代币1数量share_supply
string 总share数量share_amt
string 该用户share数量is_first_mint
bool 是否第一次对池添加流动性record_type
int 记录类型0
添加流动性1
移除流动性
5.流动性持有量
请求
GET
/pool/query/share_balance
示例
/pool/query/share_balance?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产ID
响应
id
uint IDshare_id
uint share IDusername
string 用户名balance
string 流动性持有量(余额)
6.1.[总数]swap交易记录
请求
GET
/pool/query/swap_records/count
示例
/pool/query/swap_records/count?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&username=eve
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDusername
用户名,可选字段,查询指定用户参与的记录。可置空或不加该字段,即查询所有用户
响应
data
总数
6.2.[分页]swap交易记录
请求
GET
/pool/query/swap_records
示例
/pool/query/swap_records?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&limit=10&offset=0&username=eve
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDlimit
限制数据条数offset
跳过数据条数username
用户名,可选字段,查询指定用户参与的记录。可置空或不加该字段,即查询所有用户。
响应
id
uint IDtime
int64 时间戳pair_id
uint pair IDusername
string 用户名token_in
string 换入代币token_out
string 换出代币amount_in
string 换入代币数量amount_out
string 换出代币数量reserve_in
string 换入代币池余额reserve_out
string 换出代币池余额swap_fee
string 交易费swap_fee_type
int 交易费类型0
千分之六手续费(单位非聪,为代币(资产))1
千分之六手续费(单位:聪)2
最低20聪手续费swap_record_type
int 交易类型0
指定具体数量代币交换不定数量另一代币1
不定数量代币交换指定数量另一代币
7.1.[总数]用户所有swap交易记录
请求
GET
/pool/query/all_swap_records/count
示例
/pool/query/all_swap_records/count
参数
无
响应
data
总数
7.2.[分页]用户所有swap交易记录
请求
GET
/pool/query/all_swap_records
示例
/pool/query/all_swap_records?limit=10&offset=0
参数
limit
限制数据条数offset
跳过数据条数
响应
id
uint IDtime
int64 时间戳token0
string 代币0,sat
或资产IDtoken1
string 代币1,资产IDpair_id
uint pair IDusername
string 用户名token_in
string 换入代币token_out
string 换出代币amount_in
string 换入代币数量amount_out
string 换出代币数量reserve_in
string 换入代币池余额reserve_out
string 换出代币池余额swap_fee
string 交易费swap_fee_type
int 交易费类型0
千分之六手续费(单位非聪,为代币(资产))1
千分之六手续费(单位:聪)2
最低20聪手续费swap_record_type
int 交易类型0
指定具体数量代币交换不定数量另一代币1
不定数量代币交换指定数量另一代币
8.LP奖励余额信息
LP(Liquidity Provider) 即流动性提供者,如果用户对某池添加过流动性,则该用户被称为该池的LP,该池的每一笔交易会给该LP发放奖励,奖励达到一定数量可以进行提现。
此接口查询自己的奖励余额(单位:聪)。
请求
GET
/pool/query/lp_award_balance
示例
/pool/query/lp_award_balance
参数
无
响应
id
uint IDbalance
string 余额
9.1.[总数]奖励记录
请求
GET
/pool/query/lp_award_records/count
示例
/pool/query/lp_award_records/count
参数
无
响应
data
总数
9.2.[分页]奖励记录
请求
GET
/pool/query/lp_award_records
示例
/pool/query/lp_award_records?limit=10&offset=0
参数
limit
限制数据条数offset
跳过数据条数
响应
id
uint IDtime
int64 时间戳share_id
uint share IDamount
string 奖励数量fee
string 来自swap交易费总额award_balance
string 当时奖励余额share_balance
string 当时持有流动性total_supply
string 当时池总流动性swap_record_id
uint Swap 记录 IDaward_type
int 奖励类型0
int Swap奖励
(目前只有一种类型)
10.1.[总数]奖励提现记录
此接口查询自己的奖励提现记录总数。
请求
GET
/pool/query/withdraw_award_records/count
示例
/pool/query/withdraw_award_records/count
参数
无
响应
data
总数
10.2.[分页]奖励提现记录
此接口查询自己的奖励提现记录。
请求
GET
/pool/query/withdraw_award_records
示例
/pool/query/withdraw_award_records?limit=10&offset=0
参数
limit
限制数据条数offset
跳过数据条数
响应
id
uint IDtime
int64 时间戳username
string 用户名amount
string 提现数量award_balance
string 提现时余额
计算
所有接口需要 Bearer Token
1.添加流动性另一代币成比例数量
简单估算
请求
GET
/pool/calc/quote
示例
/pool/calc/quote?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&amount_a=10000
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDamount_a
代币A添加数量
响应
data
amount_b,即代币B按池代币比例计算出的数量
2.添加流动性
完整参数,估算结果
请求
POST
/pool/calc/add_liquidity
请求体
token_a
string 代币A,sat
或资产IDtoken_b
string 代币B,sat
或资产IDamount_a_desired
string 代币A最大添加数量amount_b_desired
string 代币B最大添加数量amount_a_min
string 代币A最小添加数量amount_b_min
string 代币B最小添加数量username
string 用户名
响应
amount_a
string 代币A实际添加数量amount_b
string 代币B实际添加数量liquidity
string 获得流动性share_record
Object 本次操作生成的流动性操作记录,字段与前文一致
3.移除流动性代币数量计算
简单估算
请求
GET
/pool/calc/burn_liquidity
示例
/pool/calc/burn_liquidity?token_a=sat&token_b=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&liquidity=100
参数
token_a
代币A,sat
或资产IDtoken_b
代币B,sat
或资产IDliquidity
流动性
响应
amount_a
string 代币A可移除数量amount_b
string 代币B可移除数量
4.移除流动性
完整参数,估算结果
请求
POST
/pool/calc/remove_liquidity
请求体
token_a
string 代币A,sat
或资产IDtoken_b
string 代币B,sat
或资产IDliquidity
string 要移除的流动性数量amount_a_min
string 代币A最小移除数量amount_b_min
string 代币B最小移除数量username
string 用户名fee_k
string 手续费比例,固定填3,代表千分之三
响应
amount_a
string 代币A实际移除数量amount_b
string 代币B实际移除数量share_record
Object 本次操作生成的流动性操作记录,字段与前文一致
5.swap换出数量
简单估算
请求
GET
/pool/calc/amount_out
示例
/pool/calc/amount_out?token_in=sat&token_out=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&amount_in=10000
参数
oken_in
string 换入代币token_out
string 换出代币amount_in
string 换入代币数量
响应
data
amount_out 换出代币数量
6.swap换入数量
简单估算
请求
GET
/pool/calc/amount_in
示例
/pool/calc/amount_in?token_in=sat&token_out=9f03947580b8a5dc4c27799b176467cf4b9a48158d377ce2d0c3fe8757971e41&amount_out=10000
参数
oken_in
string 换入代币token_out
string 换出代币amount_out
string 换出代币数量
响应
data
amount_in 换入代币数量
7.swap用确切数量代币交换不确定数量代币(单池)
完整参数,估算结果
请求
POST
/pool/calc/swap_exact_token_for_token_no_path
请求体
token_in
string 换入代币token_out
string 换出代币amount_in
string 换入代币数量amount_out_min
string 换出代币最小数量username
string 用户名project_party_fee_k
int 项目方手续费比例,固定填3,代表千分之三lp_award_fee_k
int LP奖励手续费比例,固定填3,代表千分之三
响应
amount_out
string 换出代币实际数量swap_record
Object 本次操作生成的swap交易记录,字段与前文一致
8.swap用不确定数量代币交换确切数量代币(单池)
完整参数,估算结果
请求
POST
/pool/calc/swap_token_for_exact_token_no_path
请求体
token_in
string 换入代币token_out
string 换出代币amount_out
string 换出代币数量amount_in_max
string 换入代币最大数量username
string 用户名project_party_fee_k
int 项目方手续费比例,固定填3,代表千分之三lp_award_fee_k
int LP奖励手续费比例,固定填3,代表千分之三
响应
amount_in
string 换入代币实际数量swap_record
Object 本次操作生成的swap交易记录,字段与前文一致
业务
所有接口需要 Bearer Token
// TODO: 该部分文档,响应返回值已更新,示例JSON待更新,暂以null占位,提现未实现会直接返错误
1.添加流动性
添加流动性,对于sat
,至少为1000,否则无法添加。
请求
POST
/pool/sync/add_liquidity
请求体
token_a
string 代币A,sat
或资产IDtoken_b
string 代币B,sat
或资产IDamount_a_desired
string 代币A最大添加数量amount_b_desired
string 代币B最大添加数量amount_a_min
string 代币A最小添加数量amount_b_min
string 代币B最小添加数量username
string 用户名
响应
amount_a
string 代币A实际添加数量amount_b
string 代币B实际添加数量liquidity
string 获得流动性
2.移除流动性
添加流动性,至少移除1000sat,否则无法移除。(现1sat即可移除)
请求
POST
/pool/sync/remove_liquidity
请求体
token_a
string 代币A,sat
或资产IDtoken_b
string 代币B,sat
或资产IDliquidity
string 要移除的流动性数量amount_a_min
string 代币A最小移除数量amount_b_min
string 代币B最小移除数量username
string 用户名fee_k
string 手续费比例,固定填3,代表千分之三
响应
amount_a
string 代币A实际移除数量amount_b
string 代币B实际移除数量
3.swap用确切数量代币交换不确定数量代币(单池)
swap中,由于最小手续费为20sats,sat至少为21
请求
POST
/pool/sync/swap_exact_token_for_token_no_path
请求体
token_in
string 换入代币token_out
string 换出代币amount_in
string 换入代币数量amount_out_min
string 换出代币最小数量username
string 用户名project_party_fee_k
int 项目方手续费比例,固定填3,代表千分之三lp_award_fee_k
int LP奖励手续费比例,固定填3,代表千分之三
响应
amount_out
string 换出代币实际数量
4.swap用不确定数量代币交换确切数量代币(单池)
请求
POST
/pool/sync/swap_token_for_exact_token_no_path
请求体
token_in
string 换入代币token_out
string 换出代币amount_out
string 换出代币数量amount_in_max
string 换入代币最大数量username
string 用户名project_party_fee_k
int 项目方手续费比例,固定填3,代表千分之三lp_award_fee_k
int LP奖励手续费比例,固定填3,代表千分之三
响应
amount_in
string 换入代币实际数量
5.LP奖励提现
提现到托管账户
请求
POST
/pool/sync/withdraw_award
请求体
token_a
string 代币A,sat
或资产IDtoken_b
string 代币B,sat
或资产IDusername
string 用户名amount
string 提现数量,至少为100,整数
响应
new_balance
string 提现后余额
Last updated