ton-xstocks
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesexStocks on TON (buy / sell)
TON上的xStocks(买卖操作)
Backed xStocks are jettons on TON. Resolve the jetton master from the public xStocks API, then use the same quote → execute flow as , with routing preferences learned from real Omniston behavior.
ton-swapCritical: USDT is the only working swap pair.
Omniston consistently returns no quote for TON → xStock and xStock → TON routes.
All xStock buys and sells must go through USDT. If the user lacks sufficient USDT, buy USDT with TON first (see §Pre-fund USDT below).
Backed xStocks是TON上的jetton代币。从公开的xStocks API获取jetton master地址,然后遵循与相同的报价→执行流程,路由规则参考Omniston的实际行为逻辑。
ton-swap重要提示:USDT是唯一可用的兑换交易对。
对于TON→xStock和xStock→TON的兑换路径,Omniston始终返回无报价。
所有xStock的买卖操作必须通过USDT进行。如果用户USDT余额不足,请先将TON兑换为USDT(见下文「预充值USDT」章节)。
Key addresses
关键地址
| Token | Jetton master |
|---|---|
| USDT (TON) | |
| 代币 | Jetton master地址 |
|---|---|
| USDT (TON) | |
Resolve the TON jetton master for an xStock
为xStock获取对应的TON jetton master地址
-
By symbol (e.g.): fetch via
TSLAx(not WebFetch — the xStocks API returns 403 for non-standard user-agents):curlbashcurl -s "https://api.xstocks.fi/api/v2/public/assets/{symbol}"(production base:— see xStocks API).https://api.xstocks.fi/api/v2 -
In the JSON, findwhere
deployments[]isnetwork. Use that object's"Ton"as the jetton master for MCP (address/fromToken).toToken -
Optional:returns all assets with the same
curl -s "https://api.xstocks.fi/api/v2/public/assets"shape.deployments -
Callwith
get_jetton_infoto confirm name / symbol / decimals before swapping.--jettonAddress <jetton_master>
-
通过代币符号(例如):使用**
TSLAx**命令获取(不要用WebFetch——xStocks API会对非标准用户代理返回403错误):curlbashcurl -s "https://api.xstocks.fi/api/v2/public/assets/{symbol}"(生产环境基础地址:——详见xStocks API文档)。https://api.xstocks.fi/api/v2 -
在返回的JSON中,找到**为
network的"Ton"对象。使用该对象的deployments[]**作为MCP兑换时的jetton master地址(对应address/fromToken参数)。toToken -
可选操作:执行可获取所有资产的信息,格式同样包含
curl -s "https://api.xstocks.fi/api/v2/public/assets"字段。deployments -
在执行兑换前,调用命令并传入
get_jetton_info,确认代币的名称/符号/小数位数。--jettonAddress <jetton_master>
MCP tools
MCP工具说明
| Action | Tools |
|---|---|
| Pre-fund USDT | |
| Buy xStock | |
| Sell xStock | |
| Verify | |
Amounts for are human-readable strings (respect jetton decimals from ).
get_swap_quoteget_jetton_info| 操作 | 所用工具 |
|---|---|
| 预充值USDT | |
| 买入xStock | |
| 卖出xStock | |
| 验证操作 | |
get_swap_quoteget_jetton_infoCLI argument names (exact)
CLI参数名称(精确匹配)
| Tool | Arg | CLI flag |
|---|---|---|
| jettonAddress | |
| jettonAddress | |
| fromToken | |
| toToken | |
| amount | |
| slippageBps | |
| messages | |
| messages | |
| normalizedHash | |
| 工具 | 参数 | CLI标识 |
|---|---|---|
| jettonAddress | |
| jettonAddress | |
| fromToken | |
| toToken | |
| amount | |
| slippageBps | |
| messages | |
| messages | |
| normalizedHash | |
Pre-fund USDT (auto, when needed)
预充值USDT(自动触发,当需要时)
Before any xStock trade, check the user's USDT balance:
- for the USDT master address — use the
get_jetton_balancefield for comparison.amount - If < required amount for the planned buy: a. Calculate the shortfall (include a small buffer for price movement). b.
amountwithget_swap_quote=fromToken(the literal string, not an address),"TON"= USDT master,toToken= shortfall. c. Confirm with the user: "You need ~X USDT but only have Y. Swap Z TON → X USDT first?" d. On approval,amount→ pollsend_raw_transactionuntilget_transaction_status. e. Re-check USDT balance before proceeding to the xStock buy.completed
在进行任何xStock交易前,检查用户的USDT余额:
- 调用查询USDT master地址对应的余额——使用返回的
get_jetton_balance字段进行比较。amount - 如果< 买入所需金额: a. 计算差额(需预留少量缓冲以应对价格波动)。 b. 调用
amount,参数get_swap_quote=fromToken(字符串字面量,而非地址),"TON"= USDT master地址,toToken= 差额金额。 c. 向用户确认:「您需要约X USDT,但当前仅持有Y USDT。是否先将Z TON兑换为X USDT?」 d. 获得用户批准后,执行amount→轮询send_raw_transaction直到交易状态为get_transaction_status。 e. 再次检查USDT余额,确认充足后再进行xStock买入操作。completed
Buy workflow
买入流程
- Resolve the Ton jetton master for the xStock symbol (API above).
- Check USDT balance — run Pre-fund USDT if insufficient.
- :
get_swap_quote= USDT master,fromToken= xStock master,toToken= USDT to spend,amount= 100 (1 %).slippageBps - with the quote's
emulate_transaction— verify expected balance changes before sending.transaction.messages - Show the user: fromAmount, toAmount, minReceived, expiresAt, emulation results, and note the forward TON on router messages (gas).
- Confirm once, then with the returned
send_raw_transaction.transaction.messages - Poll on
get_transaction_statusuntilnormalizedHashorcompleted.failed
Do not attempt TON → xStock directly. It will return no quote. Always route through USDT.
- 为目标xStock代币符号获取对应的Ton jetton master地址(使用上述API方法)。
- 检查USDT余额——如果不足,执行预充值USDT流程。
- 调用:参数
get_swap_quote= USDT master地址,fromToken= xStock master地址,toToken= 要花费的USDT金额,amount= 100(即1%)。slippageBps - 使用报价返回的执行
transaction.messages——在发送交易前验证预期的余额变化是否正确。emulate_transaction - 向用户展示:fromAmount(转出金额)、toAmount(转入金额)、minReceived(最低到账金额)、expiresAt(报价过期时间)、模拟交易结果,并提示路由消息中包含的正向TON(作为Gas费用)。
- 获得用户一次确认后,使用返回的执行
transaction.messages。send_raw_transaction - 轮询(传入
get_transaction_status)直到交易状态为normalizedHash或completed。failed
请勿直接尝试TON→xStock的兑换路径。 该路径将返回无报价。必须始终通过USDT中转。
Sell workflow ("sell all" or fixed amount)
卖出流程(「全部卖出」或固定金额卖出)
- for the xStock master → use the returned
get_jetton_balancefield (already a human-readable decimal string, e.g.amount). Use"12.5"only if a raw integer is needed elsewhere.amountRaw - Pass directly as the
amountparameter foramount— no manual conversion needed.get_swap_quote - :
get_swap_quote= xStock master,fromToken= USDT master.toToken - with the quote's
emulate_transaction— verify expected balance changes.transaction.messages - Show the user the quote details and emulation results, then confirm.
- , then poll
send_raw_transactionuntilget_transaction_statusorcompleted.failed
Do not attempt xStock → TON directly. Always sell into USDT.
- 调用查询xStock master地址对应的余额→使用返回的
get_jetton_balance字段(已为人类可读的十进制字符串,例如amount)。仅当需要原始整数值时,才使用"12.5"字段。amountRaw - 将直接作为
amount的get_swap_quote参数传入——无需手动转换格式。amount - 调用:参数
get_swap_quote= xStock master地址,fromToken= USDT master地址。toToken - 使用报价返回的执行
transaction.messages——验证预期的余额变化是否正确。emulate_transaction - 向用户展示报价详情和模拟交易结果,获得确认后再执行下一步。
- 执行,然后轮询
send_raw_transaction直到交易状态为get_transaction_status或completed。failed
请勿直接尝试xStock→TON的兑换路径。 必须始终兑换为USDT。
Post-trade checks
交易后检查
- If balance reads 0 immediately after a buy, wait a few seconds and re-query; indexers can lag.
- After a sell, confirm USDT balance increased as expected.
- 如果买入后余额立即显示为0,请等待几秒后重新查询;索引器可能存在延迟。
- 卖出后,确认USDT余额已按预期增加。
Omniston quirks
Omniston的特殊情况
- "No quote available" — no route at that size / time. Retry after a short wait, or adjust amount / slippage slightly. Do not switch to TON pairing; it won't help.
- Occasional WebSocket errors (e.g. quote ack) — retry .
get_swap_quote - Quotes expire; if the user waited before confirming, fetch a fresh quote before executing.
- 「无可用报价」:当前金额或时间点无可用兑换路径。请稍等片刻后重试,或小幅调整金额/滑点。请勿切换为TON配对;这不会解决问题。
- 偶尔会出现WebSocket错误(例如报价确认失败)——**重新调用**即可。
get_swap_quote - 报价会过期;如果用户在确认前等待了较长时间,执行交易前请重新获取最新报价。
Relations
关联内容
- Execution and confirmation rules: skill.
ton-swap - Wallet funding and status polling: skill.
ton-balance - Issuance / redemption outside DEX: xStocks product docs / dashboard — not covered by MCP swap alone.
- 执行与确认规则:****技能。
ton-swap - 钱包充值与状态轮询:****技能。
ton-balance - DEX之外的发行/赎回操作:请参考xStocks产品文档/控制台——本MCP兑换工具不涵盖该部分内容。