Track Position (TP/SL)
After a swap, create a position group with a filled buy order and optional take-profit / stop-loss sell orders. Entry cost is auto-converted to USD (USDC). The platform monitors and auto-sells when thresholds are hit.
内置操作 内置
在交换后,创建一个包含已成交买单以及可选止盈/止损卖单的仓位组。入场成本自动转换为 USD (USDC)。平台将监控仓位,并在达到阈值时自动执行卖出。
概览
| 字段 | 值 |
|---|---|
| 动作 ID | track-position |
| 类别 | 内置 |
| 连接器 | 不需要 |
| 需要 Gas | 否 |
| 资金移动 | 未声明 |
| 标签 | trading, order, take-profit, stop-loss, tp-sl, defi, swap, polymarket, perp, hyperliquid, position |
负载架构
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
walletId | string | 是 | 持有仓位代币的钱包 ID。 |
chainId | number | 是 | 购买代币的链 ID。 |
assetAddress | string | 是 | 您购买的资产的合约地址(代币、条件代币等)。 |
entryCost | string | 是 | BigInt:花费的报价代币数量(来自交换/投注结果)。 |
entryAmount | string | 是 | BigInt:接收到的资产数量(来自交换/投注结果)。 |
entryTxHash | string | 是 | 买入/入场的交易哈希。 |
tpMultiplier | number | 否 | 止盈倍数(例如,2.0 = 当价值达到入场成本的 2 倍时卖出)。 |
slMultiplier | number | 否 | 止损倍数(例如,0.5 = 当价值达到入场成本的 50% 时卖出)。 |
label | string | 否 | 仓位的显示名称(例如,'DEGEN'、'Trump YES')。 |
quoteToken | string | 否 | 您支付的代币的合约地址。对于原生 ETH,使用 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE。 |
assetDecimals | number | 否 | 代币小数位(默认:18)。 |
metadata | object | 否 | 协议特定数据(例如,Polymarket marketId、conditionId、outcome)。 |
sellToToken | string | 否 | 卖出时接收的代币合约地址。默认为 USDC。 |
positionType | string | 否 | 仓位类型。默认为 'dex'。 |
结果架构
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
groupId | string | 是 | 订单组的唯一 ID。通过 API 查询订单状态。 |
orders | array | 是 | 创建的订单列表(已成交买单 + 可选 TP/SL 卖单)。 |
示例
json{ "type": "track-position", "payload": { "walletId": "0x0000000000000000000000000000000000000000", "chainId": 8453, "assetAddress": "0x0000000000000000000000000000000000000000", "entryCost": "example-entryCost", "entryAmount": "1000000", "entryTxHash": "example-entryTxHash" }, "children": []}
bashcurl -X POST "https://api.b3os.org/v1/actions/track-position/test" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "inputs": { "walletId": "0x0000000000000000000000000000000000000000", "chainId": 8453, "assetAddress": "0x0000000000000000000000000000000000000000", "entryCost": "example-entryCost", "entryAmount": "1000000", "entryTxHash": "example-entryTxHash" }}'
负载字段可以在值应来自触发器、先前节点或可重用工作流属性时,使用工作流表达式,例如 {{$trigger.body.amount}}、{{$nodes.fetch.result.price}} 和 {{$props.asset}}。
