@t2000/engine 1.23.1 → 1.24.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/dist/index.js +52 -3
- 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 { ALL_NAVI_ASSETS, getDecimalsForCoinType, resolveSymbol, isInRegistry, normalizeCoinType, assertAllowedAsset, normalizeAsset, SUPPORTED_ASSETS, getSwapQuote, resolveTokenType, extractTransferDetails, classifyTransaction } from '@t2000/sdk';
|
|
2
|
+
import { ALL_NAVI_ASSETS, getDecimalsForCoinType, resolveSymbol, isInRegistry, normalizeCoinType, assertAllowedAsset, normalizeAsset, SUPPORTED_ASSETS, getSwapQuote, getPendingRewardsByAddress, resolveTokenType, extractTransferDetails, classifyTransaction } from '@t2000/sdk';
|
|
3
3
|
import { randomUUID } from 'crypto';
|
|
4
4
|
import { readdirSync, readFileSync } from 'fs';
|
|
5
5
|
import { join } from 'path';
|
|
@@ -5225,10 +5225,21 @@ var pendingRewardsTool = buildTool({
|
|
|
5225
5225
|
// across turns within the same session.
|
|
5226
5226
|
cacheable: false,
|
|
5227
5227
|
async call(_input, context) {
|
|
5228
|
-
const agent = requireAgent(context);
|
|
5229
5228
|
let rewards;
|
|
5230
5229
|
try {
|
|
5231
|
-
|
|
5230
|
+
const agent = context.agent;
|
|
5231
|
+
if (agent && typeof agent.getPendingRewards === "function") {
|
|
5232
|
+
rewards = await agent.getPendingRewards();
|
|
5233
|
+
} else if (context.walletAddress) {
|
|
5234
|
+
rewards = await getPendingRewardsByAddress(
|
|
5235
|
+
context.walletAddress,
|
|
5236
|
+
context.suiRpcUrl
|
|
5237
|
+
);
|
|
5238
|
+
} else {
|
|
5239
|
+
throw new Error(
|
|
5240
|
+
"pending_rewards requires either context.agent (CLI path) or context.walletAddress + context.suiRpcUrl (audric path)."
|
|
5241
|
+
);
|
|
5242
|
+
}
|
|
5232
5243
|
} catch (err) {
|
|
5233
5244
|
const errAny = err;
|
|
5234
5245
|
const isProtocolDown = errAny?.code === "PROTOCOL_UNAVAILABLE";
|
|
@@ -5273,6 +5284,43 @@ var pendingRewardsTool = buildTool({
|
|
|
5273
5284
|
return { data, displayText };
|
|
5274
5285
|
}
|
|
5275
5286
|
});
|
|
5287
|
+
var harvestRewardsTool = buildTool({
|
|
5288
|
+
name: "harvest_rewards",
|
|
5289
|
+
description: 'Compound write: claim all NAVI rewards, swap each non-USDC reward to USDC inline, deposit the merged USDC into NAVI savings. ONE confirm card, atomic settlement (every leg lands or none of them do). Use when the user wants their rewards to keep earning yield (the common case). Prefer `claim_rewards` instead when the user explicitly wants to RECEIVE the reward token (e.g. "I want my NAVX in my wallet"). Untradeable rewards get transferred back to wallet automatically \u2014 they don\'t block the harvest. Dust rewards (< $0.01) likewise. Returns a plan: claimed[], swaps[] (with expected USDC out per leg), skipped[] (with reason), expectedUsdcDeposited, plus the on-chain tx hash. Permission: always `confirm` \u2014 never auto-executes regardless of preset, because the bundle includes a swap + deposit and the user should see the breakdown.',
|
|
5290
|
+
inputSchema: z.object({
|
|
5291
|
+
slippage: z.number().min(1e-3).max(0.05).optional().describe("Per-swap slippage tolerance (0.001\u20130.05). Defaults to 0.01 (1%)."),
|
|
5292
|
+
minRewardUsd: z.number().min(0).optional().describe(
|
|
5293
|
+
'USD floor for "is this worth swapping?". Rewards below this transfer to wallet instead of being swapped. Default $0.01. Pass 0 to disable.'
|
|
5294
|
+
)
|
|
5295
|
+
}),
|
|
5296
|
+
jsonSchema: {
|
|
5297
|
+
type: "object",
|
|
5298
|
+
properties: {
|
|
5299
|
+
slippage: { type: "number", minimum: 1e-3, maximum: 0.05 },
|
|
5300
|
+
minRewardUsd: { type: "number", minimum: 0 }
|
|
5301
|
+
},
|
|
5302
|
+
required: []
|
|
5303
|
+
},
|
|
5304
|
+
isReadOnly: false,
|
|
5305
|
+
permissionLevel: "confirm",
|
|
5306
|
+
flags: { mutating: true },
|
|
5307
|
+
async call(input, context) {
|
|
5308
|
+
const data = {
|
|
5309
|
+
success: false,
|
|
5310
|
+
tx: null,
|
|
5311
|
+
claimed: [],
|
|
5312
|
+
swaps: [],
|
|
5313
|
+
skipped: [],
|
|
5314
|
+
expectedUsdcDeposited: 0,
|
|
5315
|
+
totalClaimedValueUsd: 0,
|
|
5316
|
+
gasCost: 0,
|
|
5317
|
+
degraded: false,
|
|
5318
|
+
degradationReason: null
|
|
5319
|
+
};
|
|
5320
|
+
const displayText = "Ready to harvest your NAVI rewards: I will claim everything that's pending, swap any non-USDC rewards into USDC, and deposit the total back into your NAVI savings \u2014 all in one transaction. Untradeable or tiny rewards transfer to your wallet so nothing is lost.";
|
|
5321
|
+
return { data, displayText };
|
|
5322
|
+
}
|
|
5323
|
+
});
|
|
5276
5324
|
var todoStatusSchema = z.enum(["pending", "in_progress", "completed"]);
|
|
5277
5325
|
var todoItemSchema = z.object({
|
|
5278
5326
|
id: z.string().min(1, "id must be a non-empty string").max(40, "id must be \u226440 chars (use a slug, not a sentence)"),
|
|
@@ -5564,6 +5612,7 @@ var WRITE_TOOLS = [
|
|
|
5564
5612
|
borrowTool,
|
|
5565
5613
|
repayDebtTool,
|
|
5566
5614
|
claimRewardsTool,
|
|
5615
|
+
harvestRewardsTool,
|
|
5567
5616
|
payApiTool,
|
|
5568
5617
|
swapExecuteTool,
|
|
5569
5618
|
voloStakeTool,
|