@t2000/engine 0.6.13 → 0.6.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +11 -38
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { getSwapQuote } from '@t2000/sdk';
|
|
2
|
+
import { resolveSymbol, getDecimalsForCoinType, getSwapQuote, SUI_TYPE } from '@t2000/sdk';
|
|
3
3
|
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
4
4
|
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
5
5
|
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
|
|
@@ -152,21 +152,9 @@ async function executeSingleTool(tool, call, context) {
|
|
|
152
152
|
const result = await tool.call(parsed.data, context);
|
|
153
153
|
return { data: result.data, isError: false };
|
|
154
154
|
}
|
|
155
|
-
|
|
156
|
-
// src/sui-rpc.ts
|
|
157
155
|
var SUI_MAINNET_URL = "https://fullnode.mainnet.sui.io:443";
|
|
158
|
-
var
|
|
159
|
-
"
|
|
160
|
-
"0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC": { symbol: "USDC", decimals: 6 },
|
|
161
|
-
"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN": { symbol: "USDT", decimals: 6 },
|
|
162
|
-
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT": { symbol: "USDT", decimals: 6 },
|
|
163
|
-
"0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI": { symbol: "USDsui", decimals: 6 },
|
|
164
|
-
"0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE": { symbol: "USDe", decimals: 6 },
|
|
165
|
-
"0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH": { symbol: "ETH", decimals: 8 },
|
|
166
|
-
"0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC": { symbol: "BTC", decimals: 8 },
|
|
167
|
-
"0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL": { symbol: "WAL", decimals: 9 },
|
|
168
|
-
"0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX": { symbol: "NAVX", decimals: 9 },
|
|
169
|
-
"0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM": { symbol: "GOLD", decimals: 6 }
|
|
156
|
+
var EXTRA_COINS = {
|
|
157
|
+
"0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN": { symbol: "USDT", decimals: 6 }
|
|
170
158
|
};
|
|
171
159
|
async function fetchWalletCoins(address, rpcUrl) {
|
|
172
160
|
const url = rpcUrl || SUI_MAINNET_URL;
|
|
@@ -190,9 +178,9 @@ async function fetchWalletCoins(address, rpcUrl) {
|
|
|
190
178
|
}
|
|
191
179
|
const balances = json.result ?? [];
|
|
192
180
|
return balances.map((b) => {
|
|
193
|
-
const
|
|
194
|
-
const symbol =
|
|
195
|
-
const decimals =
|
|
181
|
+
const extra = EXTRA_COINS[b.coinType];
|
|
182
|
+
const symbol = extra?.symbol ?? resolveSymbol(b.coinType);
|
|
183
|
+
const decimals = extra?.decimals ?? getDecimalsForCoinType(b.coinType);
|
|
196
184
|
return {
|
|
197
185
|
coinType: b.coinType,
|
|
198
186
|
symbol,
|
|
@@ -202,10 +190,6 @@ async function fetchWalletCoins(address, rpcUrl) {
|
|
|
202
190
|
};
|
|
203
191
|
});
|
|
204
192
|
}
|
|
205
|
-
function extractSymbol(coinType) {
|
|
206
|
-
const parts = coinType.split("::");
|
|
207
|
-
return parts[parts.length - 1] ?? "UNKNOWN";
|
|
208
|
-
}
|
|
209
193
|
|
|
210
194
|
// src/navi-config.ts
|
|
211
195
|
var NAVI_SERVER_NAME = "navi";
|
|
@@ -274,8 +258,6 @@ function getMcpManager(context) {
|
|
|
274
258
|
function getWalletAddress(context) {
|
|
275
259
|
return context.walletAddress;
|
|
276
260
|
}
|
|
277
|
-
|
|
278
|
-
// src/navi-transforms.ts
|
|
279
261
|
function toNum(v) {
|
|
280
262
|
if (v == null) return 0;
|
|
281
263
|
const n = typeof v === "number" ? v : Number(v);
|
|
@@ -372,7 +354,7 @@ function transformBalance(rawCoins, rawPositions, rawRewards, prices) {
|
|
|
372
354
|
let gasReserveUsd = 0;
|
|
373
355
|
for (const coin of coins) {
|
|
374
356
|
const symbol = coin.symbol ?? "";
|
|
375
|
-
const decimals = coin.decimals ?? (
|
|
357
|
+
const decimals = coin.decimals ?? getDecimalsForCoinType(coin.coinType ?? "");
|
|
376
358
|
const balance = toNum(coin.totalBalance) / 10 ** decimals;
|
|
377
359
|
const price = prices?.[symbol] ?? (STABLECOIN_SYMBOLS.has(symbol) ? 1 : 0);
|
|
378
360
|
if (symbol === "SUI" || coin.coinType === "0x2::sui::SUI") {
|
|
@@ -526,7 +508,7 @@ var balanceCheckTool = buildTool({
|
|
|
526
508
|
coins = coinArr.map((c) => ({
|
|
527
509
|
coinType: c.coinType ?? "",
|
|
528
510
|
symbol: c.symbol ?? "",
|
|
529
|
-
decimals: c.decimals ?? (c.
|
|
511
|
+
decimals: c.decimals ?? getDecimalsForCoinType(c.coinType ?? ""),
|
|
530
512
|
totalBalance: c.totalBalance ?? "0",
|
|
531
513
|
coinObjectCount: 0
|
|
532
514
|
}));
|
|
@@ -910,7 +892,6 @@ var ratesInfoTool = buildTool({
|
|
|
910
892
|
return { data: rates, displayText: formatRatesSummary(rates) };
|
|
911
893
|
}
|
|
912
894
|
});
|
|
913
|
-
var SUI_TYPE = "0x2::sui::SUI";
|
|
914
895
|
var KNOWN_TARGETS = [
|
|
915
896
|
[/::suilend|::obligation/, "lending"],
|
|
916
897
|
[/::navi|::incentive_v\d+|::oracle_pro/, "lending"],
|
|
@@ -963,9 +944,9 @@ function parseRpcTx(tx, address) {
|
|
|
963
944
|
let recipient;
|
|
964
945
|
if (primaryOutflow) {
|
|
965
946
|
const coinType = primaryOutflow.coinType;
|
|
966
|
-
const decimals = coinType
|
|
947
|
+
const decimals = getDecimalsForCoinType(coinType);
|
|
967
948
|
amount = Math.abs(Number(BigInt(primaryOutflow.amount))) / 10 ** decimals;
|
|
968
|
-
asset =
|
|
949
|
+
asset = resolveSymbol(coinType);
|
|
969
950
|
const recipientChange = inflows.find((c) => c.coinType === coinType);
|
|
970
951
|
recipient = recipientChange ? resolveOwner(recipientChange.owner) ?? void 0 : void 0;
|
|
971
952
|
}
|
|
@@ -1620,14 +1601,6 @@ var webSearchTool = buildTool({
|
|
|
1620
1601
|
var inputSchema2 = z.object({
|
|
1621
1602
|
digest: z.string().describe("Sui transaction digest to explain")
|
|
1622
1603
|
});
|
|
1623
|
-
var SIX_DECIMAL_TOKENS = /* @__PURE__ */ new Set(["USDC", "USDT", "USDe", "WBTC"]);
|
|
1624
|
-
var EIGHT_DECIMAL_TOKENS = /* @__PURE__ */ new Set(["WETH", "ETH"]);
|
|
1625
|
-
function guessDecimals(coinType) {
|
|
1626
|
-
const symbol = coinType.split("::").pop()?.toUpperCase() ?? "";
|
|
1627
|
-
if (SIX_DECIMAL_TOKENS.has(symbol)) return 6;
|
|
1628
|
-
if (EIGHT_DECIMAL_TOKENS.has(symbol)) return 8;
|
|
1629
|
-
return 9;
|
|
1630
|
-
}
|
|
1631
1604
|
var explainTxTool = buildTool({
|
|
1632
1605
|
name: "explain_tx",
|
|
1633
1606
|
description: "Explain a Sui transaction in plain English. Provide a transaction digest and get a human-readable breakdown of what happened \u2014 transfers, swaps, deposits, etc.",
|
|
@@ -1687,7 +1660,7 @@ var explainTxTool = buildTool({
|
|
|
1687
1660
|
const symbol = coinParts[coinParts.length - 1] ?? bc.coinType;
|
|
1688
1661
|
const amount = Number(bc.amount);
|
|
1689
1662
|
const isNegative = amount < 0;
|
|
1690
|
-
const decimals =
|
|
1663
|
+
const decimals = getDecimalsForCoinType(bc.coinType);
|
|
1691
1664
|
const absHuman = Math.abs(amount / 10 ** decimals);
|
|
1692
1665
|
if (bc.coinType.endsWith("::sui::SUI") && isNegative) {
|
|
1693
1666
|
if (ownerAddr === gasPayer) {
|