exchange.IO("lp.history", ...)
查询仓位的资金流水与盈亏:存入、撤出的本金和领取的手续费,按当前池价折算。
exchange.IO(k, positionId)示例
查看仓位的累计手续费与盈亏。
javascript
function main() {
var h = exchange.IO("lp.history", "1381183")
if (!h) {
Log("查询失败:", GetLastError())
return
}
h.events.forEach(function (e) {
Log(e.action, "区块", e.block, e.amountBase, "+", e.amountQuote)
})
Log("已领手续费:", h.feesCollectedBase, "+", h.feesCollectedQuote, "盈亏:", h.pnlQuote)
}返回值
| 类型 | 描述 |
object / 空值 |
|
参数
| 名称 | 类型 | 必填 | 描述 |
k | string | 是 | 固定为 |
positionId | string / number | 是 | 仓位ID。 |
参考
Uniswap / PancakeSwap Aerodrome / Velodrome exchange.IO exchange.IO("lp.positions") exchange.IO("lp.collect")
备注
events为各次流动性变化[{action, block, txHash, liquidity, amountBase, amountQuote}](action为add、remove、collect);deposited*、withdrawn*、feesCollected*为累计存入、撤出的本金和领取的手续费;pnlQuote为按当前池价price折算的盈亏(现值 + 已领手续费 + 已撤本金 − 存入本金,不含gas)。
需要能查历史日志的节点:公共节点常常不支持,报错如lp.history needs a node that serves historical logs: …,这时请在交易所配置的节点地址里加一个支持归档查询的节点。
Uniswap、PancakeSwap的V4/Infinity CL事件不记录代币数量,这类仓位只给每次流动性变化和当前仓位:{id, pool, symbol, events: [{action, block, txHash, liquidity}], position, note}。Aerodrome、Velodrome的基础池子LP代币没有按仓位的事件,不支持。