输入/搜索内容
内置函数
结构体
内置变量与常量
通用约定
交易所
能力矩阵
中心化交易所
去中心化交易所
预测市场
证券与期货
链上与自定义接入

查询仓位的资金流水与盈亏:存入、撤出的本金和领取的手续费,按当前池价折算。

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 / 空值

{id, symbol, events, depositedBase, depositedQuote, withdrawnBase, withdrawnQuote, feesCollectedBase, feesCollectedQuote, price, pnlQuote, note},字段说明见备注。节点查不了历史日志时返回空值并报错。

参数

名称类型必填描述

k

string

是

固定为lp.history,用于查询仓位流水。

positionId

string / number

是

仓位ID。

参考

备注

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代币没有按仓位的事件,不支持。