@t2000/engine 0.50.3 → 0.51.1

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/README.md CHANGED
@@ -120,11 +120,11 @@ QueryEngine.submitMessage()
120
120
 
121
121
  | Tool | Description |
122
122
  |------|-------------|
123
- | `save_deposit` | Deposit **USDC** to savings (NAVI); non-USDC collateral must be swapped first |
124
- | `withdraw` | Withdraw from savings (optional `asset` for multi-asset withdrawals) |
123
+ | `save_deposit` | Deposit **USDC or USDsui** to NAVI savings (v0.51.0+ strategic exception). Pass `asset: 'USDC' \| 'USDsui'`. Other tokens must be swapped first — never auto-chained. |
124
+ | `withdraw` | Withdraw from savings (optional `asset` for multi-asset withdrawals; supports USDC, USDsui, plus legacy USDe / SUI positions) |
125
125
  | `send_transfer` | Send USDC to an address |
126
- | `borrow` | Borrow USDC against collateral |
127
- | `repay_debt` | Repay outstanding debt |
126
+ | `borrow` | Borrow **USDC or USDsui** against collateral (v0.51.0+). Pass `asset: 'USDC' \| 'USDsui'`. |
127
+ | `repay_debt` | Repay outstanding **USDC or USDsui** debt (v0.51.1+). Pass `asset` to target a specific debt; omit for highest-APY repay. **Repay symmetry is enforced:** USDsui debt MUST be repaid with USDsui. |
128
128
  | `claim_rewards` | Claim pending yield rewards |
129
129
  | `pay_api` | Pay for an API service via MPP |
130
130
  | `swap_execute` | Swap any token pair via Cetus Aggregator (20+ DEXs) |
package/dist/index.d.ts CHANGED
@@ -1969,6 +1969,7 @@ declare const balanceCheckTool: Tool<{
1969
1969
  stables: number;
1970
1970
  holdings: any[];
1971
1971
  saveableUsdc: number;
1972
+ saveableUsdsui: number;
1972
1973
  address: string;
1973
1974
  isSelfQuery: boolean;
1974
1975
  }>;
@@ -2030,12 +2031,12 @@ declare const transactionHistoryTool: Tool<{
2030
2031
 
2031
2032
  declare const saveDepositTool: Tool<{
2032
2033
  amount: number;
2033
- asset?: string | undefined;
2034
+ asset?: "USDC" | "USDsui" | undefined;
2034
2035
  }, {
2035
2036
  success: boolean;
2036
2037
  tx: string;
2037
2038
  amount: number;
2038
- asset: string;
2039
+ asset: "USDC" | "USDsui";
2039
2040
  apy: number;
2040
2041
  fee: number;
2041
2042
  gasCost: number;
@@ -2073,11 +2074,12 @@ declare const sendTransferTool: Tool<{
2073
2074
 
2074
2075
  declare const borrowTool: Tool<{
2075
2076
  amount: number;
2076
- asset?: string | undefined;
2077
+ asset?: "USDC" | "USDsui" | undefined;
2077
2078
  }, {
2078
2079
  success: boolean;
2079
2080
  tx: string;
2080
2081
  amount: number;
2082
+ asset: string;
2081
2083
  fee: number;
2082
2084
  healthFactor: number;
2083
2085
  gasCost: number;
@@ -2085,10 +2087,12 @@ declare const borrowTool: Tool<{
2085
2087
 
2086
2088
  declare const repayDebtTool: Tool<{
2087
2089
  amount: number;
2090
+ asset?: "USDC" | "USDsui" | undefined;
2088
2091
  }, {
2089
2092
  success: boolean;
2090
2093
  tx: string;
2091
2094
  amount: number;
2095
+ asset: string;
2092
2096
  remainingDebt: number;
2093
2097
  gasCost: number;
2094
2098
  }>;
@@ -2390,6 +2394,6 @@ interface WalletCoin {
2390
2394
  */
2391
2395
  declare function fetchWalletCoins(address: string, rpcUrl?: string): Promise<WalletCoin[]>;
2392
2396
 
2393
- declare const DEFAULT_SYSTEM_PROMPT = "You are Audric \u2014 a financial agent on Sui. Audric is exactly five products: Audric Passport (the trust layer \u2014 Google sign-in, non-custodial wallet, tap-to-confirm consent, sponsored gas \u2014 wraps every other product), Audric Intelligence (you \u2014 the 5-system brain: Agent Harness with 34 tools, Reasoning Engine with 9 guards and 7 skill recipes, Silent Profile, Chain Memory, AdviceLog), Audric Finance (manage money on Sui \u2014 Save via NAVI lending at 3-8% APY USDC, Credit via NAVI borrowing with health factor, Swap via Cetus aggregator across 20+ DEXs at 0.1% fee, Charts for yield/health/portfolio viz), Audric Pay (move money \u2014 send USDC, receive via payment links / invoices / QR; free, global, instant on Sui), and Audric Store (creator marketplace, ships Phase 5 \u2014 say \"coming soon\" if asked). Save, swap, borrow, repay, withdraw, charts \u2192 Audric Finance. Send, receive, payment-link, invoice, QR \u2192 Audric Pay. Your silent context (profile, memory, chain facts, advice log) shapes your replies but never surfaces as a notification \u2014 you act only when the user asks, and every write waits on their tap-to-confirm via Passport. You can also call 41 paid APIs (music, image, research, translation, weather, fulfilment) via MPP micropayments using the pay_api tool \u2014 this is an internal capability, not a promoted product, so only mention it when the user asks for something that needs it.\n\n## Response rules\n- 1-2 sentences max. No bullet lists unless asked. No preambles.\n- Never say \"Would you like me to...\", \"Sure!\", \"Great question!\", \"Absolutely!\" \u2014 just do it or say you can't.\n- Lead with the result. After tool calls, state the outcome with real numbers. Done.\n- Present amounts as $1,234.56 and rates as X.XX% APY.\n- Show top 3 results unless asked for more. Summarize totals in one line.\n\n## Execution rule\nOnly offer to execute actions you have tools for. If you retrieved a quote, data, or information but have no tool to act on it, give the user the result and tell them where to execute manually \u2014 in one sentence. Never say \"Would you like me to proceed?\" unless you have a tool that can actually proceed.\n\n## Before acting\n- ALWAYS call a read tool first before any write tool \u2014 balance_check before save/send/borrow, savings_info before withdraw.\n- Show real numbers from tools \u2014 never fabricate rates, amounts, or balances.\n- When user says \"all\" or an imprecise amount, call the read tool first to get the exact number.\n\n## Tool usage\n- Use tools proactively \u2014 don't refuse requests you can handle.\n- For real-world questions (weather, search, news, prices), use pay_api. Tell the user the cost first.\n- For NAVI lending APYs, use rates_info; for VOLO liquid staking stats, use volo_stats; for spot token prices, use token_prices.\n- For protocol-level due diligence (TVL, fees, audits, safety) on Sui DeFi protocols, use protocol_deep_dive with the slug.\n- Run multiple read-only tools in parallel when you need several data points.\n- If a tool errors, say what went wrong and what to try instead. One sentence.\n\n## Savings = USDC only (critical)\n- save_deposit accepts ONLY USDC. No other token can be deposited into savings.\n- When asked \"how much can I save?\", report only the user's USDC wallet balance (saveableUsdc field from balance_check). Other tokens like GOLD, SUI, USDT are NOT saveable and NOT savings positions \u2014 they are just wallet holdings.\n- NEVER say a non-USDC token is \"in savings\" or \"earning APY in savings\" unless it appears in the savings_info positions list. Wallet holdings \u2260 savings.\n- If user wants to save non-USDC tokens, tell them to swap to USDC first. Do NOT auto-chain swap + deposit.\n\n## Multi-step flows\n- \"How much X for Y?\": swap_quote first, then swap_execute if user confirms.\n- \"Swap then save\": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.\n- \"Buy $X of token\": token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + volo_stats (vSUI liquid staking).\n- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.\n- \"Deposit SUI to earn yield\": volo_stake for SUI liquid staking. save_deposit is USDC only.\n- \"Is protocol X safe?\" / \"Tell me about NAVI\": protocol_deep_dive with the slug.\n- \"Full account report\" / \"account summary\" / \"give me everything\" / \"complete overview\": triggers the `account_report` recipe \u2014 when the recipe block appears, follow EVERY step including all six tool calls. Each step renders a distinct rich card; skipping a step means a missing card.\n\n## Safety\n- Never encourage risky financial behavior.\n- Warn when health factor < 1.5.\n- All amounts in USDC unless stated otherwise.";
2397
+ declare const DEFAULT_SYSTEM_PROMPT = "You are Audric \u2014 a financial agent on Sui. Audric is exactly five products: Audric Passport (the trust layer \u2014 Google sign-in, non-custodial wallet, tap-to-confirm consent, sponsored gas \u2014 wraps every other product), Audric Intelligence (you \u2014 the 5-system brain: Agent Harness with 34 tools, Reasoning Engine with 9 guards and 7 skill recipes, Silent Profile, Chain Memory, AdviceLog), Audric Finance (manage money on Sui \u2014 Save via NAVI lending at 3-8% APY USDC, Credit via NAVI borrowing with health factor, Swap via Cetus aggregator across 20+ DEXs at 0.1% fee, Charts for yield/health/portfolio viz), Audric Pay (move money \u2014 send USDC, receive via payment links / invoices / QR; free, global, instant on Sui), and Audric Store (creator marketplace, ships Phase 5 \u2014 say \"coming soon\" if asked). Save, swap, borrow, repay, withdraw, charts \u2192 Audric Finance. Send, receive, payment-link, invoice, QR \u2192 Audric Pay. Your silent context (profile, memory, chain facts, advice log) shapes your replies but never surfaces as a notification \u2014 you act only when the user asks, and every write waits on their tap-to-confirm via Passport. You can also call 41 paid APIs (music, image, research, translation, weather, fulfilment) via MPP micropayments using the pay_api tool \u2014 this is an internal capability, not a promoted product, so only mention it when the user asks for something that needs it.\n\n## Response rules\n- 1-2 sentences max. No bullet lists unless asked. No preambles.\n- Never say \"Would you like me to...\", \"Sure!\", \"Great question!\", \"Absolutely!\" \u2014 just do it or say you can't.\n- Lead with the result. After tool calls, state the outcome with real numbers. Done.\n- Present amounts as $1,234.56 and rates as X.XX% APY.\n- Show top 3 results unless asked for more. Summarize totals in one line.\n\n## Execution rule\nOnly offer to execute actions you have tools for. If you retrieved a quote, data, or information but have no tool to act on it, give the user the result and tell them where to execute manually \u2014 in one sentence. Never say \"Would you like me to proceed?\" unless you have a tool that can actually proceed.\n\n## Before acting\n- ALWAYS call a read tool first before any write tool \u2014 balance_check before save/send/borrow, savings_info before withdraw.\n- Show real numbers from tools \u2014 never fabricate rates, amounts, or balances.\n- When user says \"all\" or an imprecise amount, call the read tool first to get the exact number.\n\n## Tool usage\n- Use tools proactively \u2014 don't refuse requests you can handle.\n- For real-world questions (weather, search, news, prices), use pay_api. Tell the user the cost first.\n- For NAVI lending APYs, use rates_info; for VOLO liquid staking stats, use volo_stats; for spot token prices, use token_prices.\n- For protocol-level due diligence (TVL, fees, audits, safety) on Sui DeFi protocols, use protocol_deep_dive with the slug.\n- Run multiple read-only tools in parallel when you need several data points.\n- If a tool errors, say what went wrong and what to try instead. One sentence.\n\n## Savings = USDC or USDsui (critical)\n- save_deposit and borrow accept ONLY USDC or USDsui. No other token can be deposited or borrowed.\n- USDC is the canonical default. USDsui is permitted because it has a productive NAVI pool (often a higher APY than USDC). All other holdings (GOLD, SUI, USDT, USDe, ETH, NAVX, WAL) are NOT saveable.\n- When asked \"how much can I save?\":\n - Report saveableUsdc from balance_check (the user's USDC wallet balance \u2014 canonical saveable).\n - If the user also holds USDsui in their wallet, report that separately as \"USDsui (saveable): X.XX\". Do NOT roll the two together \u2014 the LLM must keep the per-asset distinction so the user can pick.\n- When the user says \"save 10 USDC\" \u2192 call save_deposit with asset=\"USDC\". When they say \"save 10 USDsui\" \u2192 call with asset=\"USDsui\". Never silently substitute.\n- When the user says \"save 10\" (no asset) \u2192 call balance_check first and ask which stable they want, OR pick whichever they hold more of with a one-line explanation.\n- \"Best stable to save right now?\" \u2192 call rates_info to compare USDC vs USDsui APY on NAVI; let the user pick.\n- NEVER say a non-saveable token (GOLD, SUI, USDT, etc.) is \"in savings\" or \"earning APY in savings\". Wallet holdings \u2260 savings positions, even for stables we don't accept.\n- If user wants to save a non-saveable token, tell them to swap to USDC or USDsui first. Do NOT auto-chain swap + deposit.\n- Repay symmetry: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC). When calling repay_debt, pass asset=\"USDsui\" if the borrow is USDsui. If the user asks \"repay my debt\" and savings_info shows borrows in BOTH stables, list both and ask which to repay first. If the user holds the wrong stable, tell them to swap manually \u2014 do NOT auto-chain swap + repay.\n\n## Multi-step flows\n- \"How much X for Y?\": swap_quote first, then swap_execute if user confirms.\n- \"Swap then save\": swap_execute \u2192 balance_check \u2192 save_deposit. Confirm each step.\n- \"Buy $X of token\": token_prices \u2192 calculate amount \u2192 swap_execute.\n- \"Best yield on SUI\": compare rates_info (NAVI lending) + volo_stats (vSUI liquid staking).\n- withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.\n- \"Deposit SUI to earn yield\": volo_stake for SUI liquid staking. save_deposit only accepts USDC or USDsui.\n- \"Is protocol X safe?\" / \"Tell me about NAVI\": protocol_deep_dive with the slug.\n- \"Full account report\" / \"account summary\" / \"give me everything\" / \"complete overview\": triggers the `account_report` recipe \u2014 when the recipe block appears, follow EVERY step including all six tool calls. Each step renders a distinct rich card; skipping a step means a missing card.\n\n## Safety\n- Never encourage risky financial behavior.\n- Warn when health factor < 1.5.\n- All amounts in USDC unless stated otherwise.";
2394
2398
 
2395
2399
  export { type AddressPortfolio, AnthropicProvider, type AnthropicProviderConfig, type BalancePrices, type BalanceResult, BalanceTracker, type BuildToolOptions, CANVAS_TEMPLATES, type CanvasTemplate, type ChatParams, type CompactOptions, type ContentBlock, ContextBudget, type ContextBudgetConfig, type ConversationState, type ConversationStateStore, type CostSnapshot, CostTracker, type CostTrackerConfig, DEFAULT_GUARD_CONFIG, DEFAULT_PERMISSION_CONFIG, DEFAULT_SYSTEM_PROMPT, EarlyToolDispatcher, type EngineConfig, type EngineEvent, type GuardCheckResult, type GuardConfig, type GuardEvent, type GuardInjection, type GuardResult, type GuardRunnerState, type GuardTier, type GuardVerdict, type HealthFactorResult, type LLMProvider, type McpCallResult, McpClientManager, McpResponseCache, type McpServerConfig, type McpServerConnection, type McpToolAdapterConfig, type McpToolDescriptor, MemorySessionStore, type Message, NAVI_MCP_CONFIG, NAVI_MCP_URL, NAVI_SERVER_NAME, type NaviRawCoin, type NaviRawHealthFactor, type NaviRawPool, type NaviRawPosition, type NaviRawPositionsResponse, type NaviRawProtocolStats, type NaviRawRewardsResponse, type NaviReadOptions, NaviTools, type OutputConfig, PERMISSION_PRESETS, type PendingAction, type PendingActionModifiableField, type PendingReward, type PendingToolCall, type PermissionLevel, type PermissionOperation, type PermissionResponse, type PermissionRule, type PortfolioCoin, type PositionEntry, type PreflightResult, type ProtocolStats, type ProviderEvent, QueryEngine, READ_TOOLS, type RatesResult, type Recipe, type RecipePrerequisite, RecipeRegistry, type RecipeStep, type RecipeStepOnError, RetryTracker, type SSEEvent, type SavingsResult, type ServerPositionData, type SessionData, type SessionStore, type StateType, type StopReason, type SuiCoinBalance, type SystemBlock, type SystemPrompt, TOOL_FLAGS, TOOL_MODIFIABLE_FIELDS, type ThinkingConfig, type ThinkingEffort, type Tool, type ToolChoice, type ToolContext, type ToolDefinition, type ToolFlags, type ToolJsonSchema, type ToolResult, TxMutex, type UserFinancialProfile, type UserPermissionConfig, WRITE_TOOLS, type WalletCoin, activitySummaryTool, adaptAllMcpTools, adaptAllServerTools, adaptMcpTool, applyToolFlags, balanceCheckTool, borrowTool, budgetToolResult, buildCachedSystemPrompt, buildMcpTools, buildProactivenessInstructions, buildProfileContext, buildSelfEvaluationInstruction, buildStateContext, buildTool, claimRewardsTool, classifyEffort, clearPortfolioCache, clearPortfolioCacheFor, clearPriceMapCache, compactMessages, createGuardRunnerState, engineToSSE, estimateTokens, explainTxTool, extractConversationText, extractMcpText, fetchAddressPortfolio, fetchAvailableRewards, fetchBalance, fetchHealthFactor, fetchPositions, fetchProtocolStats, fetchRates, fetchSavings, fetchTokenPrices, fetchWalletCoins, findTool, getDefaultTools, getMcpManager, getModifiableFields, getToolFlags, getWalletAddress, guardArtifactPreview, guardStaleData, hasNaviMcp, healthCheckTool, loadRecipes, microcompact, mppServicesTool, parseMcpJson, parseRecipe, parseSSE, payApiTool, portfolioAnalysisTool, protocolDeepDiveTool, ratesInfoTool, registerEngineTools, renderCanvasTool, repayDebtTool, requireAgent, resolvePermissionTier, resolveUsdValue, runGuards, runTools, saveContactTool, saveDepositTool, savingsInfoTool, sendTransferTool, serializeSSE, spendingAnalyticsTool, swapExecuteTool, swapQuoteTool, tokenPricesTool, toolNameToOperation, toolsToDefinitions, transactionHistoryTool, transformBalance, transformHealthFactor, transformPositions, transformRates, transformRewards, transformSavings, updateGuardStateAfterToolResult, validateHistory, voloStakeTool, voloStatsTool, voloUnstakeTool, webSearchTool, withdrawTool, yieldSummaryTool };
package/dist/index.js CHANGED
@@ -1155,7 +1155,7 @@ async function loadPortfolio(address, blockvisionApiKey, fallbackRpcUrl, cache)
1155
1155
  }
1156
1156
  var balanceCheckTool = buildTool({
1157
1157
  name: "balance_check",
1158
- description: "Get the full balance breakdown for the signed-in user OR any public Sui address. Returns wallet holdings (tokens the address owns \u2014 NOT savings), NAVI savings deposits (USDC deposited into NAVI Protocol earning yield), outstanding debt, pending rewards, gas reserve, total net worth, and saveableUsdc (only USDC can be deposited into savings). IMPORTANT: wallet holdings like GOLD, SUI, USDT are NOT savings positions \u2014 they are just tokens sitting in the wallet. Pass `address` to inspect a contact / watched / public wallet; defaults to the signed-in user when omitted.",
1158
+ description: "Get the full balance breakdown for the signed-in user OR any public Sui address. Returns wallet holdings (tokens the address owns \u2014 NOT savings), NAVI savings deposits (USDC and/or USDsui deposited into NAVI Protocol earning yield), outstanding debt, pending rewards, gas reserve, total net worth, saveableUsdc (USDC wallet balance available to save), and saveableUsdsui (USDsui wallet balance available to save \u2014 surfaces only when > 0). IMPORTANT: wallet holdings like GOLD, SUI, USDT, USDe are NOT savings positions and are NOT saveable \u2014 only USDC and USDsui can be saved/borrowed. Pass `address` to inspect a contact / watched / public wallet; defaults to the signed-in user when omitted.",
1159
1159
  inputSchema: z.object({
1160
1160
  address: z.string().regex(SUI_ADDRESS_REGEX).optional().describe("Sui address to inspect (defaults to the signed-in wallet)")
1161
1161
  }),
@@ -1279,6 +1279,8 @@ var balanceCheckTool = buildTool({
1279
1279
  const visibleHoldings = holdings.filter((h) => h.usdValue >= 0.01).sort((a, b) => b.usdValue - a.usdValue);
1280
1280
  const usdcHolding2 = holdings.find((h) => h.symbol === "USDC");
1281
1281
  const saveableUsdc = usdcHolding2 ? usdcHolding2.balance : 0;
1282
+ const usdsuiHolding2 = holdings.find((h) => h.symbol === "USDsui");
1283
+ const saveableUsdsui = usdsuiHolding2 ? usdsuiHolding2.balance : 0;
1282
1284
  const defi2 = defiPortfolio;
1283
1285
  const bal = {
1284
1286
  available: availableUsd,
@@ -1293,6 +1295,7 @@ var balanceCheckTool = buildTool({
1293
1295
  stables: stablesUsd,
1294
1296
  holdings: visibleHoldings,
1295
1297
  saveableUsdc,
1298
+ saveableUsdsui,
1296
1299
  priceSource: portfolio.source,
1297
1300
  address,
1298
1301
  isSelfQuery
@@ -1300,9 +1303,10 @@ var balanceCheckTool = buildTool({
1300
1303
  const holdingsList = visibleHoldings.map((h) => `${h.symbol}: ${h.balance < 1 ? h.balance.toFixed(6) : h.balance.toFixed(2)} ($${h.usdValue.toFixed(2)})`).join(", ");
1301
1304
  const subjectPrefix = isSelfQuery ? "Balance" : `Balance for ${address.slice(0, 6)}\u2026${address.slice(-4)}`;
1302
1305
  const defiSummaryText = defi2.totalUsd > 0 ? ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi2.perProtocol).join("/")}): $${defi2.totalUsd.toFixed(2)}.` : "";
1306
+ const saveableSummary = saveableUsdsui > 0 ? `Saveable: ${saveableUsdc.toFixed(2)} USDC + ${saveableUsdsui.toFixed(saveableUsdsui < 1 ? 4 : 2)} USDsui (only USDC and USDsui can be saved/borrowed).` : `Saveable USDC (only USDC and USDsui can be saved): ${saveableUsdc.toFixed(2)} USDC.`;
1303
1307
  return {
1304
1308
  data: bal,
1305
- displayText: `${subjectPrefix}: $${bal.total.toFixed(2)} total. Wallet holdings (NOT savings): ${holdingsList || "none"}. NAVI savings deposits: $${bal.savings.toFixed(2)}.${defiSummaryText} Saveable USDC (only USDC can be saved): ${saveableUsdc.toFixed(2)} USDC.`
1309
+ displayText: `${subjectPrefix}: $${bal.total.toFixed(2)} total. Wallet holdings (NOT savings): ${holdingsList || "none"}. NAVI savings deposits: $${bal.savings.toFixed(2)}.${defiSummaryText} ${saveableSummary}`
1306
1310
  };
1307
1311
  }
1308
1312
  if (input.address && context.walletAddress && input.address.toLowerCase() !== context.walletAddress.toLowerCase()) {
@@ -1331,6 +1335,8 @@ var balanceCheckTool = buildTool({
1331
1335
  const holdingsArr = Array.isArray(sdkHoldings) ? sdkHoldings : [];
1332
1336
  const usdcHolding = holdingsArr.find((h) => h.symbol === "USDC");
1333
1337
  const sdkSaveableUsdc = usdcHolding ? usdcHolding.balance ?? 0 : 0;
1338
+ const usdsuiHolding = holdingsArr.find((h) => h.symbol === "USDsui");
1339
+ const sdkSaveableUsdsui = usdsuiHolding ? usdsuiHolding.balance ?? 0 : 0;
1334
1340
  const sdkDefiSummaryText = defi.totalUsd > 0 ? ` Other DeFi positions (LPs/staking/lending across ${Object.keys(defi.perProtocol).join("/")}): $${defi.totalUsd.toFixed(2)}.` : "";
1335
1341
  const sdkTotal = balance.total + defi.totalUsd;
1336
1342
  return {
@@ -1347,10 +1353,11 @@ var balanceCheckTool = buildTool({
1347
1353
  stables: stablesTotal,
1348
1354
  holdings: holdingsArr,
1349
1355
  saveableUsdc: sdkSaveableUsdc,
1356
+ saveableUsdsui: sdkSaveableUsdsui,
1350
1357
  address: targetAddress ?? "",
1351
1358
  isSelfQuery: true
1352
1359
  },
1353
- displayText: `Balance: $${sdkTotal.toFixed(2)} total. Wallet: $${balance.available.toFixed(2)} available. NAVI savings deposits: $${balance.savings.toFixed(2)}.${sdkDefiSummaryText} Saveable USDC (only USDC can be saved): ${sdkSaveableUsdc.toFixed(2)} USDC.`
1360
+ displayText: `Balance: $${sdkTotal.toFixed(2)} total. Wallet: $${balance.available.toFixed(2)} available. NAVI savings deposits: $${balance.savings.toFixed(2)}.${sdkDefiSummaryText} ${sdkSaveableUsdsui > 0 ? `Saveable: ${sdkSaveableUsdc.toFixed(2)} USDC + ${sdkSaveableUsdsui.toFixed(sdkSaveableUsdsui < 1 ? 4 : 2)} USDsui (only USDC and USDsui can be saved/borrowed).` : `Saveable USDC (only USDC and USDsui can be saved): ${sdkSaveableUsdc.toFixed(2)} USDC.`}`
1354
1361
  };
1355
1362
  }
1356
1363
  });
@@ -2080,22 +2087,24 @@ var transactionHistoryTool = buildTool({
2080
2087
  };
2081
2088
  }
2082
2089
  });
2090
+ var SAVE_ASSETS = ["USDC", "USDsui"];
2083
2091
  var saveDepositTool = buildTool({
2084
2092
  name: "save_deposit",
2085
- description: "Deposit USDC into NAVI savings to earn yield. ONLY USDC is accepted. If the user asks to save/deposit any other token (USDT, SUI, USDe, etc.), do NOT call this tool and do NOT automatically swap their tokens and deposit. Instead, tell the user that only USDC deposits are supported and ask if they would like to swap to USDC first. Let the user decide \u2014 never auto-chain swap + deposit.",
2093
+ description: 'Deposit USDC or USDsui into NAVI savings to earn yield. ONLY these two stables are accepted. If the user asks to save/deposit any other token (GOLD, SUI, USDT, USDe, ETH, etc.), do NOT call this tool and do NOT automatically swap their tokens and deposit. Instead, tell the user that only USDC and USDsui deposits are supported and ask if they would like to swap first. Let the user decide \u2014 never auto-chain swap + deposit. When the user says "save 10 USDC" pass asset="USDC". When they say "save 10 USDsui" pass asset="USDsui". When they say "save 10" with no asset, ALWAYS call balance_check first and ask which stable they want to deposit (or default to whichever they hold more of, with a one-line note). Never silently substitute USDsui for USDC or vice versa.',
2086
2094
  inputSchema: z.object({
2087
2095
  amount: z.number().positive(),
2088
- asset: z.string().optional().describe("Must be USDC or omitted. Any other asset is rejected.")
2096
+ asset: z.enum(SAVE_ASSETS).optional().describe('"USDC" or "USDsui". Defaults to USDC when omitted.')
2089
2097
  }),
2090
2098
  jsonSchema: {
2091
2099
  type: "object",
2092
2100
  properties: {
2093
2101
  amount: {
2094
- description: "Exact amount of USDC to deposit"
2102
+ description: "Exact amount to deposit (in units of the chosen asset)"
2095
2103
  },
2096
2104
  asset: {
2097
2105
  type: "string",
2098
- description: "Must be USDC or omitted. Any other asset is rejected."
2106
+ enum: ["USDC", "USDsui"],
2107
+ description: 'Stable to deposit. "USDC" or "USDsui". Defaults to USDC when omitted.'
2099
2108
  }
2100
2109
  },
2101
2110
  required: ["amount"]
@@ -2104,36 +2113,40 @@ var saveDepositTool = buildTool({
2104
2113
  permissionLevel: "confirm",
2105
2114
  flags: { mutating: true, requiresBalance: true },
2106
2115
  preflight: (input) => {
2107
- if (input.asset && input.asset.toUpperCase() !== "USDC") {
2108
- return { valid: false, error: `Only USDC deposits are supported. Got: "${input.asset}"` };
2116
+ if (input.asset) {
2117
+ const allowed = SAVE_ASSETS.map((a) => a.toUpperCase());
2118
+ if (!allowed.includes(input.asset.toUpperCase())) {
2119
+ return { valid: false, error: `Only USDC or USDsui deposits are supported. Got: "${input.asset}"` };
2120
+ }
2109
2121
  }
2110
2122
  return { valid: true };
2111
2123
  },
2112
2124
  async call(input, context) {
2113
2125
  assertAllowedAsset("save", input.asset);
2114
2126
  const agent = requireAgent(context);
2115
- const result = await agent.save({ amount: input.amount });
2127
+ const asset = input.asset ?? "USDC";
2128
+ const result = await agent.save({ amount: input.amount, asset });
2116
2129
  return {
2117
2130
  data: {
2118
2131
  success: result.success,
2119
2132
  tx: result.tx,
2120
2133
  amount: result.amount,
2121
- asset: "USDC",
2134
+ asset,
2122
2135
  apy: result.apy,
2123
2136
  fee: result.fee,
2124
2137
  gasCost: result.gasCost,
2125
2138
  savingsBalance: result.savingsBalance
2126
2139
  },
2127
- displayText: `Saved ${result.amount.toFixed(result.amount < 1 ? 6 : 2)} USDC at ${(result.apy * 100).toFixed(2)}% APY (tx: ${result.tx.slice(0, 8)}\u2026)`
2140
+ displayText: `Saved ${result.amount.toFixed(result.amount < 1 ? 6 : 2)} ${asset} at ${(result.apy * 100).toFixed(2)}% APY (tx: ${result.tx.slice(0, 8)}\u2026)`
2128
2141
  };
2129
2142
  }
2130
2143
  });
2131
2144
  var withdrawTool = buildTool({
2132
2145
  name: "withdraw",
2133
- description: "Withdraw from NAVI lending back to wallet. Defaults to USDC. Also supports withdrawing legacy positions (USDe, USDsui, SUI) if the user has them.",
2146
+ description: "Withdraw from NAVI lending back to wallet. Defaults to USDC; also withdraws USDsui (the second active saveable stable). Legacy positions in other assets (USDe, SUI) can still be withdrawn if the user has them \u2014 but only USDC and USDsui are eligible to be re-deposited via save_deposit.",
2134
2147
  inputSchema: z.object({
2135
2148
  amount: z.number().positive(),
2136
- asset: z.string().optional().describe("Asset to withdraw (default: USDC). Legacy positions: USDe, USDsui, SUI")
2149
+ asset: z.string().optional().describe("Asset to withdraw (default: USDC). Active: USDsui. Legacy positions: USDe, SUI.")
2137
2150
  }),
2138
2151
  jsonSchema: {
2139
2152
  type: "object",
@@ -2143,7 +2156,7 @@ var withdrawTool = buildTool({
2143
2156
  },
2144
2157
  asset: {
2145
2158
  type: "string",
2146
- description: "Asset to withdraw (default: USDC). Legacy positions: USDe, USDsui, SUI"
2159
+ description: "Asset to withdraw (default: USDC). Active: USDsui. Legacy positions: USDe, SUI."
2147
2160
  }
2148
2161
  },
2149
2162
  required: ["amount"]
@@ -2248,23 +2261,25 @@ var sendTransferTool = buildTool({
2248
2261
  };
2249
2262
  }
2250
2263
  });
2264
+ var BORROW_ASSETS = ["USDC", "USDsui"];
2251
2265
  var borrowTool = buildTool({
2252
2266
  name: "borrow",
2253
- description: "Borrow USDC against savings collateral. ONLY USDC borrows are supported. Requires existing savings deposits. Checks max safe borrow and health factor. Returns tx hash, fee, and post-borrow health factor.",
2267
+ description: 'Borrow USDC or USDsui against savings collateral. ONLY these two stables are supported. Requires existing savings deposits as collateral. Checks max safe borrow and health factor. Returns tx hash, fee, asset borrowed, and post-borrow health factor. When the user says "borrow 10 USDC" pass asset="USDC". When they say "borrow 10 USDsui" pass asset="USDsui". When they say "borrow 10" with no asset, default to USDC unless the user has only USDsui collateral.',
2254
2268
  inputSchema: z.object({
2255
2269
  amount: z.number().positive(),
2256
- asset: z.string().optional().describe("Must be USDC or omitted. Any other asset is rejected.")
2270
+ asset: z.enum(BORROW_ASSETS).optional().describe('"USDC" or "USDsui". Defaults to USDC when omitted.')
2257
2271
  }),
2258
2272
  jsonSchema: {
2259
2273
  type: "object",
2260
2274
  properties: {
2261
2275
  amount: {
2262
2276
  type: "number",
2263
- description: "Amount in USDC to borrow"
2277
+ description: "Amount to borrow (in units of the chosen asset)"
2264
2278
  },
2265
2279
  asset: {
2266
2280
  type: "string",
2267
- description: "Must be USDC or omitted. Any other asset is rejected."
2281
+ enum: ["USDC", "USDsui"],
2282
+ description: 'Stable to borrow. "USDC" or "USDsui". Defaults to USDC when omitted.'
2268
2283
  }
2269
2284
  },
2270
2285
  required: ["amount"]
@@ -2273,39 +2288,51 @@ var borrowTool = buildTool({
2273
2288
  permissionLevel: "confirm",
2274
2289
  flags: { mutating: true, affectsHealth: true },
2275
2290
  preflight: (input) => {
2276
- if (input.asset && input.asset.toUpperCase() !== "USDC") {
2277
- return { valid: false, error: `Only USDC borrows are supported. Got: "${input.asset}"` };
2291
+ if (input.asset) {
2292
+ const allowed = BORROW_ASSETS.map((a) => a.toUpperCase());
2293
+ if (!allowed.includes(input.asset.toUpperCase())) {
2294
+ return { valid: false, error: `Only USDC or USDsui borrows are supported. Got: "${input.asset}"` };
2295
+ }
2278
2296
  }
2279
2297
  return { valid: true };
2280
2298
  },
2281
2299
  async call(input, context) {
2282
2300
  assertAllowedAsset("borrow", input.asset);
2283
2301
  const agent = requireAgent(context);
2284
- const result = await agent.borrow({ amount: input.amount });
2302
+ const asset = input.asset ?? "USDC";
2303
+ const result = await agent.borrow({ amount: input.amount, asset });
2285
2304
  return {
2286
2305
  data: {
2287
2306
  success: result.success,
2288
2307
  tx: result.tx,
2289
2308
  amount: result.amount,
2309
+ asset: result.asset ?? asset,
2290
2310
  fee: result.fee,
2291
2311
  healthFactor: result.healthFactor,
2292
2312
  gasCost: result.gasCost
2293
2313
  },
2294
- displayText: `Borrowed $${result.amount.toFixed(2)} \u2014 HF: ${result.healthFactor.toFixed(2)} (tx: ${result.tx.slice(0, 8)}\u2026)`
2314
+ displayText: `Borrowed ${result.amount.toFixed(2)} ${asset} \u2014 HF: ${result.healthFactor.toFixed(2)} (tx: ${result.tx.slice(0, 8)}\u2026)`
2295
2315
  };
2296
2316
  }
2297
2317
  });
2318
+ var REPAY_ASSETS = ["USDC", "USDsui"];
2298
2319
  var repayDebtTool = buildTool({
2299
2320
  name: "repay_debt",
2300
- description: "Repay outstanding USDC debt. Always call balance_check first to know the debt amount, then pass the exact number here. Prioritises the highest-APY borrow first. Returns tx hash, amount repaid, and remaining debt.",
2321
+ description: 'Repay outstanding USDC or USDsui debt. Always call balance_check first to know the debt amount + which asset is owed (savings_info shows per-asset borrow positions). Pass asset="USDC" or asset="USDsui" to target a specific debt. When omitted, repays the highest-APY borrow first. Important: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC) \u2014 the SDK fetches the correct coin type for the targeted asset, but the user must hold enough of that stable in their wallet. If the user has only the wrong stable, do NOT auto-swap \u2014 tell them to swap manually first. Returns tx hash, amount repaid, asset, and remaining debt.',
2301
2322
  inputSchema: z.object({
2302
- amount: z.number().positive()
2323
+ amount: z.number().positive(),
2324
+ asset: z.enum(REPAY_ASSETS).optional().describe('"USDC" or "USDsui". When omitted, repays the highest-APY borrow first.')
2303
2325
  }),
2304
2326
  jsonSchema: {
2305
2327
  type: "object",
2306
2328
  properties: {
2307
2329
  amount: {
2308
- description: "Exact amount in USD to repay (call balance_check first to get debt amount)"
2330
+ description: "Exact amount to repay (in units of the chosen asset; call balance_check first)"
2331
+ },
2332
+ asset: {
2333
+ type: "string",
2334
+ enum: ["USDC", "USDsui"],
2335
+ description: "Asset of the borrow being repaid. When omitted, picks the highest-APY borrow."
2309
2336
  }
2310
2337
  },
2311
2338
  required: ["amount"]
@@ -2313,18 +2340,30 @@ var repayDebtTool = buildTool({
2313
2340
  isReadOnly: false,
2314
2341
  permissionLevel: "confirm",
2315
2342
  flags: { mutating: true, requiresBalance: true },
2343
+ preflight: (input) => {
2344
+ if (input.asset) {
2345
+ const allowed = REPAY_ASSETS.map((a) => a.toUpperCase());
2346
+ if (!allowed.includes(input.asset.toUpperCase())) {
2347
+ return { valid: false, error: `Only USDC or USDsui repays are supported. Got: "${input.asset}"` };
2348
+ }
2349
+ }
2350
+ return { valid: true };
2351
+ },
2316
2352
  async call(input, context) {
2317
2353
  const agent = requireAgent(context);
2318
- const result = await agent.repay({ amount: input.amount });
2354
+ const asset = input.asset;
2355
+ const result = await agent.repay({ amount: input.amount, asset });
2356
+ const repaidAsset = result.asset ?? asset ?? "USDC";
2319
2357
  return {
2320
2358
  data: {
2321
2359
  success: result.success,
2322
2360
  tx: result.tx,
2323
2361
  amount: result.amount,
2362
+ asset: repaidAsset,
2324
2363
  remainingDebt: result.remainingDebt,
2325
2364
  gasCost: result.gasCost
2326
2365
  },
2327
- displayText: `Repaid $${result.amount.toFixed(2)} \u2014 remaining debt: $${result.remainingDebt.toFixed(2)} (tx: ${result.tx.slice(0, 8)}\u2026)`
2366
+ displayText: `Repaid ${result.amount.toFixed(2)} ${repaidAsset} \u2014 remaining debt: $${result.remainingDebt.toFixed(2)} (tx: ${result.tx.slice(0, 8)}\u2026)`
2328
2367
  };
2329
2368
  }
2330
2369
  });
@@ -4085,11 +4124,18 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
4085
4124
  - Run multiple read-only tools in parallel when you need several data points.
4086
4125
  - If a tool errors, say what went wrong and what to try instead. One sentence.
4087
4126
 
4088
- ## Savings = USDC only (critical)
4089
- - save_deposit accepts ONLY USDC. No other token can be deposited into savings.
4090
- - When asked "how much can I save?", report only the user's USDC wallet balance (saveableUsdc field from balance_check). Other tokens like GOLD, SUI, USDT are NOT saveable and NOT savings positions \u2014 they are just wallet holdings.
4091
- - NEVER say a non-USDC token is "in savings" or "earning APY in savings" unless it appears in the savings_info positions list. Wallet holdings \u2260 savings.
4092
- - If user wants to save non-USDC tokens, tell them to swap to USDC first. Do NOT auto-chain swap + deposit.
4127
+ ## Savings = USDC or USDsui (critical)
4128
+ - save_deposit and borrow accept ONLY USDC or USDsui. No other token can be deposited or borrowed.
4129
+ - USDC is the canonical default. USDsui is permitted because it has a productive NAVI pool (often a higher APY than USDC). All other holdings (GOLD, SUI, USDT, USDe, ETH, NAVX, WAL) are NOT saveable.
4130
+ - When asked "how much can I save?":
4131
+ - Report saveableUsdc from balance_check (the user's USDC wallet balance \u2014 canonical saveable).
4132
+ - If the user also holds USDsui in their wallet, report that separately as "USDsui (saveable): X.XX". Do NOT roll the two together \u2014 the LLM must keep the per-asset distinction so the user can pick.
4133
+ - When the user says "save 10 USDC" \u2192 call save_deposit with asset="USDC". When they say "save 10 USDsui" \u2192 call with asset="USDsui". Never silently substitute.
4134
+ - When the user says "save 10" (no asset) \u2192 call balance_check first and ask which stable they want, OR pick whichever they hold more of with a one-line explanation.
4135
+ - "Best stable to save right now?" \u2192 call rates_info to compare USDC vs USDsui APY on NAVI; let the user pick.
4136
+ - NEVER say a non-saveable token (GOLD, SUI, USDT, etc.) is "in savings" or "earning APY in savings". Wallet holdings \u2260 savings positions, even for stables we don't accept.
4137
+ - If user wants to save a non-saveable token, tell them to swap to USDC or USDsui first. Do NOT auto-chain swap + deposit.
4138
+ - Repay symmetry: a USDsui debt MUST be repaid with USDsui (and USDC debt with USDC). When calling repay_debt, pass asset="USDsui" if the borrow is USDsui. If the user asks "repay my debt" and savings_info shows borrows in BOTH stables, list both and ask which to repay first. If the user holds the wrong stable, tell them to swap manually \u2014 do NOT auto-chain swap + repay.
4093
4139
 
4094
4140
  ## Multi-step flows
4095
4141
  - "How much X for Y?": swap_quote first, then swap_execute if user confirms.
@@ -4097,7 +4143,7 @@ Only offer to execute actions you have tools for. If you retrieved a quote, data
4097
4143
  - "Buy $X of token": token_prices \u2192 calculate amount \u2192 swap_execute.
4098
4144
  - "Best yield on SUI": compare rates_info (NAVI lending) + volo_stats (vSUI liquid staking).
4099
4145
  - withdraw supports legacy positions: USDC, USDe, USDsui, SUI. Pass asset param to withdraw a specific token.
4100
- - "Deposit SUI to earn yield": volo_stake for SUI liquid staking. save_deposit is USDC only.
4146
+ - "Deposit SUI to earn yield": volo_stake for SUI liquid staking. save_deposit only accepts USDC or USDsui.
4101
4147
  - "Is protocol X safe?" / "Tell me about NAVI": protocol_deep_dive with the slug.
4102
4148
  - "Full account report" / "account summary" / "give me everything" / "complete overview": triggers the \`account_report\` recipe \u2014 when the recipe block appears, follow EVERY step including all six tool calls. Each step renders a distinct rich card; skipping a step means a missing card.
4103
4149