@t2000/sdk 4.4.0 → 5.0.0
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 +3 -3
- package/dist/browser.cjs +42 -112
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +4 -4
- package/dist/browser.d.ts +4 -4
- package/dist/browser.js +43 -102
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +670 -6651
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -541
- package/dist/index.d.ts +29 -541
- package/dist/index.js +673 -6626
- package/dist/index.js.map +1 -1
- package/dist/types-CgZWnHhs.d.cts +1214 -0
- package/dist/types-CgZWnHhs.d.ts +1214 -0
- package/package.json +1 -13
- package/dist/adapters/descriptors.cjs +0 -48
- package/dist/adapters/descriptors.cjs.map +0 -1
- package/dist/adapters/descriptors.d.cts +0 -3
- package/dist/adapters/descriptors.d.ts +0 -3
- package/dist/adapters/descriptors.js +0 -45
- package/dist/adapters/descriptors.js.map +0 -1
- package/dist/adapters/index.cjs +0 -4815
- package/dist/adapters/index.cjs.map +0 -1
- package/dist/adapters/index.d.cts +0 -91
- package/dist/adapters/index.d.ts +0 -91
- package/dist/adapters/index.js +0 -4810
- package/dist/adapters/index.js.map +0 -1
- package/dist/descriptors-DqIb4AnV.d.cts +0 -134
- package/dist/descriptors-DqIb4AnV.d.ts +0 -134
- package/dist/types-CFV4VcJJ.d.cts +0 -667
- package/dist/types-Ch0zVUpC.d.cts +0 -727
- package/dist/types-Ch0zVUpC.d.ts +0 -727
- package/dist/types-DqRLGfOC.d.ts +0 -667
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
import { EventEmitter } from 'eventemitter3';
|
|
2
|
-
import {
|
|
2
|
+
import { SuiGrpcClient } from '@mysten/sui/grpc';
|
|
3
3
|
import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
|
|
4
|
-
import {
|
|
5
|
-
export {
|
|
6
|
-
import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-DqIb4AnV.js';
|
|
7
|
-
export { A as AdapterCapability, b as AdapterPositions, c as AdapterTxResult, H as HealthInfo, d as ProtocolDescriptor, e as allDescriptors, n as naviDescriptor } from './descriptors-DqIb4AnV.js';
|
|
8
|
-
import { n as T2000Options, P as PayOptions, d as PayResult, o as SwapResult, p as SwapQuoteResult, i as SendResult, B as BalanceResponse, k as TransactionRecord, D as DepositInfo, q as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, h as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, e as PendingReward, C as ClaimRewardsResult, r as CompoundRewardsResult, g as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, c as OverlayFeeConfig, s as SponsoredCoinMergeCache, j as SwapRouteResult, t as FinancialSummary } from './types-Ch0zVUpC.js';
|
|
9
|
-
export { A as AssetRates, u as CoinPage, G as GasReserve, v as HFAlertLevel, O as OVERLAY_FEE_RATE, f as PositionEntry, w as SelectAndSplitResult, x as SerializedCetusRoute, y as SerializedCetusRoutePath, z as SerializedRouterDataV3, T as TransactionLeg, I as addSwapToTx, l as buildSwapTx, J as deserializeCetusRoute, K as fetchAllCoins, m as findSwapRoute, L as isCetusRouteFresh, N as selectAndSplitCoin, Q as selectSuiCoin, U as serializeCetusRoute, V as verifyCetusRouteCoinMatch } from './types-Ch0zVUpC.js';
|
|
4
|
+
import { W as TxMetadata, p as SafeguardConfig, T as T2000Error, az as T2000Options, U as TransactionSigner, P as PayOptions, l as PayResult, aA as SwapResult, aB as SwapQuoteResult, y as SupportedAsset, t as SendResult, B as BalanceResponse, R as TransactionRecord, f as DepositInfo, aC as PaymentRequest, a2 as ZkLoginProof, aD as SuiCoreClient, aE as SendableAsset, k as OverlayFeeConfig, aF as SponsoredCoinMergeCache, z as SwapRouteResult } from './types-CgZWnHhs.js';
|
|
5
|
+
export { aG as CETUS_USDC_SUI_POOL, C as CLOCK_ID, a as COIN_REGISTRY, b as ClassifyBalanceChange, c as ClassifyResult, d as CoinMeta, aH as CoinPage, aI as DEFAULT_GRPC_URL, D as DEFAULT_NETWORK, e as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, aJ as GASLESS_MIN_STABLE_AMOUNT, aK as GASLESS_STABLE_TYPES, G as GAS_RESERVE_MIN, I as IKA_TYPE, K as KNOWN_TARGETS, h as KeypairSigner, L as LABEL_PATTERNS, i as LOFI_TYPE, M as MANIFEST_TYPE, j as MIST_PER_SUI, N as NAVX_TYPE, aL as OPERATION_ASSETS, O as OVERLAY_FEE_RATE, aM as Operation, aN as SENDABLE_ASSETS, S as STABLE_ASSETS, m as SUI_DECIMALS, n as SUI_TYPE, o as SUPPORTED_ASSETS, q as SafeguardError, r as SafeguardErrorDetails, s as SafeguardRule, aO as SelectAndSplitResult, aP as SerializedCetusRoute, aQ as SerializedCetusRoutePath, aR as SerializedRouterDataV3, u as SimulationResult, v as StableAsset, w as SuiHolding, x as SuiRpcTxBlock, A as T2000ErrorCode, F as T2000ErrorData, H as T2000_OVERLAY_FEE_WALLET, J as TOKEN_MAP, Q as TransactionLeg, V as TxDirection, X as USDC_DECIMALS, Y as USDC_TYPE, Z as USDE_TYPE, _ as USDSUI_TYPE, $ as USDT_TYPE, a0 as WAL_TYPE, a1 as WBTC_TYPE, a3 as ZkLoginSigner, aS as addSwapToTx, aT as assertAllowedAsset, a4 as buildSwapTx, a5 as classifyAction, a6 as classifyLabel, a7 as classifyTransaction, aU as deserializeCetusRoute, a8 as executeTx, a9 as extractAllUserLegs, aa as extractTransferDetails, ab as extractTxCommands, ac as extractTxSender, ad as fallbackLabel, aV as fetchAllCoins, ae as findSwapRoute, af as formatAssetAmount, ag as formatSui, ah as formatUsd, aW as getCoinMeta, ai as getDecimals, aj as getDecimalsForCoinType, aX as getSuiClient, aY as getSuiGrpcClient, aZ as isAllowedAsset, a_ as isCetusRouteFresh, a$ as isInRegistry, ak as mapMoveAbortCode, al as mapWalletError, am as mistToSui, b0 as normalizeAsset, b1 as normalizeCoinType, an as parseSuiRpcTx, ao as payWithMpp, b2 as queryHistory, b3 as queryTransaction, ap as rawToStable, aq as rawToUsdc, ar as refineLendingLabel, as as resolveSymbol, at as resolveTokenType, b4 as selectAndSplitCoin, b5 as selectSuiCoin, b6 as serializeCetusRoute, b7 as simulateTransaction, au as stableToRaw, av as suiToMist, b8 as throwIfSimulationFailed, aw as truncateAddress, ax as usdcToRaw, ay as validateAddress, b9 as verifyCetusRouteCoinMatch } from './types-CgZWnHhs.js';
|
|
10
6
|
import { Transaction, TransactionObjectArgument } from '@mysten/sui/transactions';
|
|
11
7
|
import { SuinsClient } from '@mysten/suins';
|
|
12
|
-
|
|
13
|
-
import '@mysten/sui/grpc';
|
|
8
|
+
import '@mysten/sui/client';
|
|
14
9
|
import '@cetusprotocol/aggregator-sdk';
|
|
10
|
+
import '@mysten/sui/jsonRpc';
|
|
15
11
|
|
|
16
12
|
declare class SafeguardEnforcer {
|
|
17
13
|
private config;
|
|
@@ -30,30 +26,6 @@ declare class SafeguardEnforcer {
|
|
|
30
26
|
private save;
|
|
31
27
|
}
|
|
32
28
|
|
|
33
|
-
interface Contact {
|
|
34
|
-
name: string;
|
|
35
|
-
address: string;
|
|
36
|
-
}
|
|
37
|
-
declare class ContactManager {
|
|
38
|
-
private contacts;
|
|
39
|
-
private readonly filePath;
|
|
40
|
-
private readonly dir;
|
|
41
|
-
constructor(configDir?: string);
|
|
42
|
-
private load;
|
|
43
|
-
private save;
|
|
44
|
-
add(name: string, address: string): {
|
|
45
|
-
action: 'added' | 'updated';
|
|
46
|
-
};
|
|
47
|
-
remove(name: string): boolean;
|
|
48
|
-
get(name: string): Contact | undefined;
|
|
49
|
-
list(): Contact[];
|
|
50
|
-
resolve(nameOrAddress: string): {
|
|
51
|
-
address: string;
|
|
52
|
-
contactName?: string;
|
|
53
|
-
};
|
|
54
|
-
private validateName;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
29
|
interface T2000Events {
|
|
58
30
|
balanceChange: (event: {
|
|
59
31
|
asset: string;
|
|
@@ -85,12 +57,9 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
85
57
|
private readonly _keypair?;
|
|
86
58
|
private readonly client;
|
|
87
59
|
private readonly _address;
|
|
88
|
-
private readonly registry;
|
|
89
60
|
readonly enforcer: SafeguardEnforcer;
|
|
90
|
-
readonly contacts: ContactManager;
|
|
91
61
|
private constructor();
|
|
92
62
|
private constructor();
|
|
93
|
-
private static createDefaultRegistry;
|
|
94
63
|
static create(options?: T2000Options): Promise<T2000>;
|
|
95
64
|
static fromPrivateKey(privateKey: string, options?: {
|
|
96
65
|
network?: 'mainnet' | 'testnet';
|
|
@@ -105,8 +74,8 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
105
74
|
agent: T2000;
|
|
106
75
|
address: string;
|
|
107
76
|
}>;
|
|
108
|
-
/**
|
|
109
|
-
get suiClient():
|
|
77
|
+
/** SuiGrpcClient used by this agent — exposed for integrations. */
|
|
78
|
+
get suiClient(): SuiGrpcClient;
|
|
110
79
|
/** Ed25519Keypair used by this agent — exposed for CLI/MCP integrations. */
|
|
111
80
|
get keypair(): Ed25519Keypair;
|
|
112
81
|
/** Transaction signer (works for both keypair and zkLogin). */
|
|
@@ -136,8 +105,7 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
136
105
|
}): Promise<SwapQuoteResult>;
|
|
137
106
|
address(): string;
|
|
138
107
|
/**
|
|
139
|
-
* Send `amount` of `asset` to `to` (hex address
|
|
140
|
-
* `@audric` handle / saved contact).
|
|
108
|
+
* Send `amount` of `asset` to `to` (hex address or SuiNS name).
|
|
141
109
|
*
|
|
142
110
|
* [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
|
|
143
111
|
*
|
|
@@ -162,34 +130,23 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
162
130
|
asset: SupportedAsset;
|
|
163
131
|
}): Promise<SendResult>;
|
|
164
132
|
/**
|
|
165
|
-
*
|
|
166
|
-
* string into a canonical 0x address, trying each shape in priority
|
|
167
|
-
* order:
|
|
133
|
+
* Resolve a recipient string into a canonical 0x address:
|
|
168
134
|
* 1. **hex** — `0x…` is used directly (no RPC round-trip).
|
|
169
135
|
* 2. **SuiNS** — `alex.sui` resolves via `suix_resolveNameServiceAddress`.
|
|
170
|
-
* 3. **saved contact** — `ContactManager.resolve()` falls back to the
|
|
171
|
-
* legacy `~/.t2000/contacts.json` alias map. Deprecated; the
|
|
172
|
-
* manager surfaces a one-time `console.warn` when this path fires.
|
|
173
136
|
*
|
|
174
|
-
*
|
|
175
|
-
*
|
|
137
|
+
* Anything else is rejected. (The legacy `contacts.json` alias map was
|
|
138
|
+
* removed — SuiNS supersedes local contacts.)
|
|
176
139
|
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* `
|
|
180
|
-
*
|
|
140
|
+
* Returns `{ address, suinsName? }` so `send()` can stamp the name source
|
|
141
|
+
* on the receipt without re-resolving. Throws
|
|
142
|
+
* `T2000Error('SUINS_NOT_REGISTERED', …)` for well-formed but unregistered
|
|
143
|
+
* SuiNS names, keeping the SDK error surface `T2000Error`-only.
|
|
181
144
|
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* same resolution logic as the live execute path. Pre-2.19.1 the
|
|
185
|
-
* MCP dryRun called `agent.contacts.resolve(to)` directly, which
|
|
186
|
-
* rejected SuiNS names — preview-then-execute flows broke for
|
|
187
|
-
* `alex.sui`-style recipients. SSOT: never let preview and execute
|
|
188
|
-
* resolve the same input differently.
|
|
145
|
+
* Public so MCP's `t2000_send` dryRun preview shares one resolution path
|
|
146
|
+
* with the live execute path (never resolve the same input two ways).
|
|
189
147
|
*/
|
|
190
148
|
resolveRecipient(input: string): Promise<{
|
|
191
149
|
address: string;
|
|
192
|
-
contactName?: string;
|
|
193
150
|
suinsName?: string;
|
|
194
151
|
}>;
|
|
195
152
|
balance(): Promise<BalanceResponse>;
|
|
@@ -221,70 +178,6 @@ declare class T2000 extends EventEmitter<T2000Events> {
|
|
|
221
178
|
maxEpoch: number;
|
|
222
179
|
rpcUrl?: string;
|
|
223
180
|
}): T2000;
|
|
224
|
-
registerAdapter(adapter: LendingAdapter): Promise<void>;
|
|
225
|
-
save(params: {
|
|
226
|
-
amount: number | 'all';
|
|
227
|
-
asset?: SupportedAsset;
|
|
228
|
-
protocol?: string;
|
|
229
|
-
}): Promise<SaveResult>;
|
|
230
|
-
withdraw(params: {
|
|
231
|
-
amount: number | 'all';
|
|
232
|
-
asset?: string;
|
|
233
|
-
protocol?: string;
|
|
234
|
-
}): Promise<WithdrawResult>;
|
|
235
|
-
private withdrawAllProtocols;
|
|
236
|
-
/**
|
|
237
|
-
* [v0.51.0] Per-asset wallet balance lookup.
|
|
238
|
-
*
|
|
239
|
-
* `queryBalance.available` rolls up only `STABLE_ASSETS` (USDC), so it cannot
|
|
240
|
-
* answer "do they have enough USDsui to save 10?". This helper hits
|
|
241
|
-
* `getBalance` for the specific coin type — same mechanism `queryBalance`
|
|
242
|
-
* uses internally — and converts to a human-readable amount using the asset's
|
|
243
|
-
* decimals. Returns 0 (not a throw) when the address holds none of the asset,
|
|
244
|
-
* matching the caller's existing "insufficient balance" error path.
|
|
245
|
-
*/
|
|
246
|
-
private _queryAssetBalance;
|
|
247
|
-
private _autoFundFromSavings;
|
|
248
|
-
maxWithdraw(): Promise<MaxWithdrawResult>;
|
|
249
|
-
borrow(params: {
|
|
250
|
-
amount: number;
|
|
251
|
-
asset?: SupportedAsset;
|
|
252
|
-
protocol?: string;
|
|
253
|
-
}): Promise<BorrowResult>;
|
|
254
|
-
repay(params: {
|
|
255
|
-
amount: number | 'all';
|
|
256
|
-
asset?: SupportedAsset;
|
|
257
|
-
protocol?: string;
|
|
258
|
-
}): Promise<RepayResult>;
|
|
259
|
-
private _repayAllBorrows;
|
|
260
|
-
maxBorrow(): Promise<MaxBorrowResult>;
|
|
261
|
-
healthFactor(): Promise<HealthFactorResult>;
|
|
262
|
-
getPendingRewards(): Promise<PendingReward[]>;
|
|
263
|
-
claimRewards(): Promise<ClaimRewardsResult>;
|
|
264
|
-
/**
|
|
265
|
-
* Claim pending rewards, swap non-USDC tokens to USDC via Cetus, and deposit into NAVI.
|
|
266
|
-
* Multi-step: claim (transfers to wallet) -> swap each reward token to USDC -> deposit USDC.
|
|
267
|
-
* Minimum threshold: skips if total rewards < $0.10 (gas not worth it).
|
|
268
|
-
*/
|
|
269
|
-
compoundRewards(options?: {
|
|
270
|
-
minValueUsd?: number;
|
|
271
|
-
}): Promise<CompoundRewardsResult>;
|
|
272
|
-
positions(): Promise<PositionsResult>;
|
|
273
|
-
rates(): Promise<RatesResult>;
|
|
274
|
-
allRates(asset?: string): Promise<{
|
|
275
|
-
protocol: string;
|
|
276
|
-
protocolId: string;
|
|
277
|
-
rates: LendingRates;
|
|
278
|
-
}[]>;
|
|
279
|
-
allRatesAcrossAssets(): Promise<{
|
|
280
|
-
protocol: string;
|
|
281
|
-
protocolId: string;
|
|
282
|
-
asset: string;
|
|
283
|
-
rates: LendingRates;
|
|
284
|
-
}[]>;
|
|
285
|
-
earnings(): Promise<EarningsResult>;
|
|
286
|
-
fundStatus(): Promise<FundStatusResult>;
|
|
287
|
-
private resolveLending;
|
|
288
181
|
private emitBalanceChange;
|
|
289
182
|
}
|
|
290
183
|
|
|
@@ -459,7 +352,7 @@ declare function getAddress(keypair: Ed25519Keypair): string;
|
|
|
459
352
|
* than a silent currency substitution.
|
|
460
353
|
*/
|
|
461
354
|
declare function buildSendTx({ client, address, to, amount, asset, }: {
|
|
462
|
-
client:
|
|
355
|
+
client: SuiCoreClient;
|
|
463
356
|
address: string;
|
|
464
357
|
to: string;
|
|
465
358
|
amount: number;
|
|
@@ -572,23 +465,7 @@ declare function addSendToTx(tx: Transaction, coin: TransactionObjectArgument, r
|
|
|
572
465
|
* Excluded by design:
|
|
573
466
|
* - `save_contact` — no on-chain leg (Prisma-only).
|
|
574
467
|
*/
|
|
575
|
-
type WriteToolName = '
|
|
576
|
-
interface SaveDepositInput {
|
|
577
|
-
amount: number;
|
|
578
|
-
asset?: 'USDC' | 'USDsui';
|
|
579
|
-
}
|
|
580
|
-
interface WithdrawInput {
|
|
581
|
-
amount: number;
|
|
582
|
-
asset?: 'USDC' | 'USDsui';
|
|
583
|
-
}
|
|
584
|
-
interface BorrowInput {
|
|
585
|
-
amount: number;
|
|
586
|
-
asset?: 'USDC' | 'USDsui';
|
|
587
|
-
}
|
|
588
|
-
interface RepayDebtInput {
|
|
589
|
-
amount: number;
|
|
590
|
-
asset?: 'USDC' | 'USDsui';
|
|
591
|
-
}
|
|
468
|
+
type WriteToolName = 'send_transfer' | 'swap_execute';
|
|
592
469
|
/**
|
|
593
470
|
* [v4.0 Phase A Day 2 — SPEC_AGENT_WALLET_GREENFIELD §A]
|
|
594
471
|
* `asset` is now REQUIRED (no more silent USDC default). The parameter
|
|
@@ -633,19 +510,6 @@ interface SwapExecuteInput {
|
|
|
633
510
|
*/
|
|
634
511
|
precomputedRoute?: SwapRouteResult;
|
|
635
512
|
}
|
|
636
|
-
type ClaimRewardsInput = Record<string, never>;
|
|
637
|
-
/**
|
|
638
|
-
* [Track B] `harvest_rewards` accepts only optional tunables — no required
|
|
639
|
-
* inputs, since the user's choice is binary ("harvest now" or not). Default
|
|
640
|
-
* slippage 1%, default dust floor $0.01. The audric host's HARVEST chip
|
|
641
|
-
* passes literal `{}` and gets sensible defaults.
|
|
642
|
-
*/
|
|
643
|
-
interface HarvestRewardsInput {
|
|
644
|
-
/** Per-swap slippage tolerance (0.001–0.05). Default 0.01 (1%). */
|
|
645
|
-
slippage?: number;
|
|
646
|
-
/** USD floor for "is this worth swapping?" — dust below transfers to wallet. Default $0.01. */
|
|
647
|
-
minRewardUsd?: number;
|
|
648
|
-
}
|
|
649
513
|
/**
|
|
650
514
|
* Discriminated union mapping `toolName` → `input`. Used to type
|
|
651
515
|
* `WriteStep` so consumers get autocomplete + compile-time validation
|
|
@@ -658,26 +522,8 @@ interface HarvestRewardsInput {
|
|
|
658
522
|
* bypassing the wallet pre-fetch path. The producer's terminal
|
|
659
523
|
* `tx.transferObjects([coin], sender)` is suppressed automatically so
|
|
660
524
|
* the same handle isn't double-consumed.
|
|
661
|
-
*
|
|
662
|
-
* Producer-only tools (`withdraw`, `borrow`, `claim_rewards`) don't
|
|
663
|
-
* accept the field — they have no input coin slot. Consumer +
|
|
664
|
-
* dual-mode tools all accept it.
|
|
665
525
|
*/
|
|
666
526
|
type WriteStep = {
|
|
667
|
-
toolName: 'save_deposit';
|
|
668
|
-
input: SaveDepositInput;
|
|
669
|
-
inputCoinFromStep?: number;
|
|
670
|
-
} | {
|
|
671
|
-
toolName: 'withdraw';
|
|
672
|
-
input: WithdrawInput;
|
|
673
|
-
} | {
|
|
674
|
-
toolName: 'borrow';
|
|
675
|
-
input: BorrowInput;
|
|
676
|
-
} | {
|
|
677
|
-
toolName: 'repay_debt';
|
|
678
|
-
input: RepayDebtInput;
|
|
679
|
-
inputCoinFromStep?: number;
|
|
680
|
-
} | {
|
|
681
527
|
toolName: 'send_transfer';
|
|
682
528
|
input: SendTransferInput;
|
|
683
529
|
inputCoinFromStep?: number;
|
|
@@ -685,17 +531,11 @@ type WriteStep = {
|
|
|
685
531
|
toolName: 'swap_execute';
|
|
686
532
|
input: SwapExecuteInput;
|
|
687
533
|
inputCoinFromStep?: number;
|
|
688
|
-
} | {
|
|
689
|
-
toolName: 'claim_rewards';
|
|
690
|
-
input: ClaimRewardsInput;
|
|
691
|
-
} | {
|
|
692
|
-
toolName: 'harvest_rewards';
|
|
693
|
-
input: HarvestRewardsInput;
|
|
694
534
|
};
|
|
695
535
|
interface ComposeTxOptions {
|
|
696
536
|
sender: string;
|
|
697
537
|
steps: WriteStep[];
|
|
698
|
-
client:
|
|
538
|
+
client: SuiCoreClient;
|
|
699
539
|
/**
|
|
700
540
|
* S.38 Pyth flag (sponsorship-critical). When true:
|
|
701
541
|
* - NAVI borrow/withdraw appenders apply `skipPythUpdate: true`
|
|
@@ -721,75 +561,9 @@ interface ComposeTxOptions {
|
|
|
721
561
|
* `addSwapToTx`'s `input.overlayFee`.
|
|
722
562
|
*/
|
|
723
563
|
overlayFee?: OverlayFeeConfig;
|
|
724
|
-
/**
|
|
725
|
-
* Optional fee-injection hooks for save_deposit + borrow. Fires inside
|
|
726
|
-
* the appender at the exact moment the user's coin is in hand and BEFORE
|
|
727
|
-
* the protocol step consumes (save) or the canonical transferObjects
|
|
728
|
-
* finalizes (borrow). Audric host uses this to inline `addFeeTransfer`
|
|
729
|
-
* for USDC SAVE_FEE_BPS / BORROW_FEE_BPS without ever leaving the
|
|
730
|
-
* canonical write contract — keeps the SDK fee-free per CLAUDE.md
|
|
731
|
-
* rule #9 while letting hosts charge their own overlay fees.
|
|
732
|
-
*
|
|
733
|
-
* Hooks are fire-and-forget (no return value). They mutate `tx` directly
|
|
734
|
-
* (e.g., `addFeeTransfer(tx, coin, ...)` splits the fee chunk off and
|
|
735
|
-
* appends a top-level `transferObjects` to the host's fee wallet — that
|
|
736
|
-
* recipient automatically appears in `derivedAllowedAddresses`).
|
|
737
|
-
*/
|
|
738
|
-
feeHooks?: ComposeTxFeeHooks;
|
|
739
|
-
}
|
|
740
|
-
/**
|
|
741
|
-
* Per-tool fee-injection callbacks. Each hook fires at a tool-specific
|
|
742
|
-
* moment in the appender flow (see field JSDoc). Currently scoped to
|
|
743
|
-
* the 2 fee-eligible tools — extend if/when new ones land.
|
|
744
|
-
*/
|
|
745
|
-
interface ComposeTxFeeHooks {
|
|
746
|
-
/**
|
|
747
|
-
* Fires inside the `save_deposit` appender AFTER the user's USDC/USDsui
|
|
748
|
-
* coin is split into the deposit amount, BEFORE NAVI's `deposit` move
|
|
749
|
-
* call consumes the coin. Order matters: the `coin` reference passed in
|
|
750
|
-
* is the SAME `TransactionObjectArgument` that flows into the deposit,
|
|
751
|
-
* so any `splitCoins(coin, [feeAmount])` inside the hook reduces the
|
|
752
|
-
* deposit by exactly that fee.
|
|
753
|
-
*/
|
|
754
|
-
save_deposit?: (ctx: ComposeTxFeeHookContext<SaveDepositInput>) => void | Promise<void>;
|
|
755
|
-
/**
|
|
756
|
-
* Fires inside the `borrow` appender AFTER NAVI returns the borrowed
|
|
757
|
-
* coin, BEFORE the canonical `transferObjects(coin, sender)` finalizes.
|
|
758
|
-
* The `coin` reference is the borrowed-and-not-yet-transferred output;
|
|
759
|
-
* splitting a fee here means the user receives the remainder.
|
|
760
|
-
*/
|
|
761
|
-
borrow?: (ctx: ComposeTxFeeHookContext<BorrowInput>) => void | Promise<void>;
|
|
762
|
-
}
|
|
763
|
-
/**
|
|
764
|
-
* Context object passed to every fee hook. Carries the `tx` (mutate it),
|
|
765
|
-
* the in-flight `coin` (split fees off it), the resolved tool input
|
|
766
|
-
* (asset/amount for fee-policy decisions), and the sender (rarely needed
|
|
767
|
-
* but kept for symmetry with `AppenderContext`).
|
|
768
|
-
*/
|
|
769
|
-
interface ComposeTxFeeHookContext<TInput> {
|
|
770
|
-
tx: Transaction;
|
|
771
|
-
coin: TransactionObjectArgument;
|
|
772
|
-
input: TInput;
|
|
773
|
-
sender: string;
|
|
774
564
|
}
|
|
775
565
|
/** Per-step preview returned by each registry appender. Tool-specific shape. */
|
|
776
566
|
type StepPreview = {
|
|
777
|
-
toolName: 'save_deposit';
|
|
778
|
-
effectiveAmount: number;
|
|
779
|
-
asset: 'USDC' | 'USDsui';
|
|
780
|
-
} | {
|
|
781
|
-
toolName: 'withdraw';
|
|
782
|
-
effectiveAmount: number;
|
|
783
|
-
asset: 'USDC' | 'USDsui';
|
|
784
|
-
} | {
|
|
785
|
-
toolName: 'borrow';
|
|
786
|
-
effectiveAmount: number;
|
|
787
|
-
asset: 'USDC' | 'USDsui';
|
|
788
|
-
} | {
|
|
789
|
-
toolName: 'repay_debt';
|
|
790
|
-
effectiveAmount: number;
|
|
791
|
-
asset: 'USDC' | 'USDsui';
|
|
792
|
-
} | {
|
|
793
567
|
toolName: 'send_transfer';
|
|
794
568
|
effectiveAmount: number;
|
|
795
569
|
recipient: string;
|
|
@@ -799,26 +573,6 @@ type StepPreview = {
|
|
|
799
573
|
effectiveAmountIn: number;
|
|
800
574
|
expectedAmountOut: number;
|
|
801
575
|
route: SwapRouteResult;
|
|
802
|
-
} | {
|
|
803
|
-
toolName: 'claim_rewards';
|
|
804
|
-
rewards: PendingReward$1[];
|
|
805
|
-
} | {
|
|
806
|
-
toolName: 'harvest_rewards';
|
|
807
|
-
claimed: PendingReward$1[];
|
|
808
|
-
swaps: Array<{
|
|
809
|
-
fromSymbol: string;
|
|
810
|
-
fromCoinType: string;
|
|
811
|
-
toSymbol: 'USDC';
|
|
812
|
-
inputAmount: number;
|
|
813
|
-
expectedOutputUsdc: number;
|
|
814
|
-
}>;
|
|
815
|
-
skipped: Array<{
|
|
816
|
-
symbol: string;
|
|
817
|
-
coinType: string;
|
|
818
|
-
amount: number;
|
|
819
|
-
reason: 'untradeable' | 'dust' | 'no-route';
|
|
820
|
-
}>;
|
|
821
|
-
expectedUsdcDeposited: number;
|
|
822
576
|
};
|
|
823
577
|
interface ComposeTxResult {
|
|
824
578
|
tx: Transaction;
|
|
@@ -843,11 +597,10 @@ interface ComposeTxResult {
|
|
|
843
597
|
* fee config (Cetus swaps), and SPEC 13 Phase 1 chain-mode fields.
|
|
844
598
|
*/
|
|
845
599
|
interface AppenderContext {
|
|
846
|
-
client:
|
|
600
|
+
client: SuiCoreClient;
|
|
847
601
|
sender: string;
|
|
848
602
|
sponsoredContext: boolean;
|
|
849
603
|
overlayFee?: OverlayFeeConfig;
|
|
850
|
-
feeHooks?: ComposeTxFeeHooks;
|
|
851
604
|
/**
|
|
852
605
|
* [SPEC 13 Phase 1] When set, the consumer appender consumes this
|
|
853
606
|
* coin handle directly instead of pre-fetching from the wallet via
|
|
@@ -887,12 +640,12 @@ interface AppenderContext {
|
|
|
887
640
|
/**
|
|
888
641
|
* [SPEC 13 Phase 1] Appender return shape. Producers populate
|
|
889
642
|
* `outputCoin` so the orchestration loop can thread it into a
|
|
890
|
-
* downstream consumer's `chainedCoin`.
|
|
891
|
-
* (`
|
|
643
|
+
* downstream consumer's `chainedCoin`. The terminal consumer
|
|
644
|
+
* (`send_transfer`) omits it.
|
|
892
645
|
*
|
|
893
646
|
* `swap_execute` is the only dual-mode tool — it accepts `chainedCoin`
|
|
894
|
-
* AND populates `outputCoin`. (
|
|
895
|
-
*
|
|
647
|
+
* AND populates `outputCoin`. (Pre-S.444 the DeFi tools
|
|
648
|
+
* save/withdraw/borrow/repay were also producers/consumers; removed with NAVI.)
|
|
896
649
|
*/
|
|
897
650
|
interface AppenderResult<TPreview extends StepPreview> {
|
|
898
651
|
preview: TPreview;
|
|
@@ -925,34 +678,18 @@ declare function getSponsoredSwapProviders(): Promise<string[]>;
|
|
|
925
678
|
/**
|
|
926
679
|
* The typed registry. Each entry is a wallet-mode dispatcher that takes
|
|
927
680
|
* (tx, input, ctx) and returns a per-step preview. Compile-time check
|
|
928
|
-
* that all
|
|
681
|
+
* that all `WriteToolName` values have an entry — TypeScript will
|
|
929
682
|
* fail the build if a tool is missing.
|
|
683
|
+
*
|
|
684
|
+
* [S.444] Narrowed to send_transfer + swap_execute after the NAVI/DeFi cut.
|
|
930
685
|
*/
|
|
931
686
|
declare const WRITE_APPENDER_REGISTRY: {
|
|
932
|
-
save_deposit: AppenderFn<SaveDepositInput, Extract<StepPreview, {
|
|
933
|
-
toolName: 'save_deposit';
|
|
934
|
-
}>>;
|
|
935
|
-
withdraw: AppenderFn<WithdrawInput, Extract<StepPreview, {
|
|
936
|
-
toolName: 'withdraw';
|
|
937
|
-
}>>;
|
|
938
|
-
borrow: AppenderFn<BorrowInput, Extract<StepPreview, {
|
|
939
|
-
toolName: 'borrow';
|
|
940
|
-
}>>;
|
|
941
|
-
repay_debt: AppenderFn<RepayDebtInput, Extract<StepPreview, {
|
|
942
|
-
toolName: 'repay_debt';
|
|
943
|
-
}>>;
|
|
944
687
|
send_transfer: AppenderFn<SendTransferInput, Extract<StepPreview, {
|
|
945
688
|
toolName: 'send_transfer';
|
|
946
689
|
}>>;
|
|
947
690
|
swap_execute: AppenderFn<SwapExecuteInput, Extract<StepPreview, {
|
|
948
691
|
toolName: 'swap_execute';
|
|
949
692
|
}>>;
|
|
950
|
-
claim_rewards: AppenderFn<ClaimRewardsInput, Extract<StepPreview, {
|
|
951
|
-
toolName: 'claim_rewards';
|
|
952
|
-
}>>;
|
|
953
|
-
harvest_rewards: AppenderFn<HarvestRewardsInput, Extract<StepPreview, {
|
|
954
|
-
toolName: 'harvest_rewards';
|
|
955
|
-
}>>;
|
|
956
693
|
};
|
|
957
694
|
/**
|
|
958
695
|
* Walks the assembled PTB's command list and extracts every recipient
|
|
@@ -982,255 +719,6 @@ declare function deriveAllowedAddressesFromPtb(tx: Transaction): string[];
|
|
|
982
719
|
*/
|
|
983
720
|
declare function composeTx(opts: ComposeTxOptions): Promise<ComposeTxResult>;
|
|
984
721
|
|
|
985
|
-
declare const HF_WARN_THRESHOLD = 1.8;
|
|
986
|
-
declare const HF_CRITICAL_THRESHOLD = 1.3;
|
|
987
|
-
type FinancialSummaryOptions = Record<string, never>;
|
|
988
|
-
/**
|
|
989
|
-
* Fetch a complete financial snapshot for one wallet in parallel.
|
|
990
|
-
* Designed for the indexer HF hook + chain-memory cron.
|
|
991
|
-
*
|
|
992
|
-
* Every sub-call has a fallback so a single RPC failure doesn't
|
|
993
|
-
* crash the entire batch. Callers can check individual zero values
|
|
994
|
-
* to detect degraded data.
|
|
995
|
-
*/
|
|
996
|
-
declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: string, _options?: FinancialSummaryOptions): Promise<FinancialSummary>;
|
|
997
|
-
|
|
998
|
-
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
999
|
-
/**
|
|
1000
|
-
* [Track B follow-up / 2026-05-08] Stateless wrapper around `getPendingRewards`
|
|
1001
|
-
* that creates its own `SuiJsonRpcClient`. Used by the engine's
|
|
1002
|
-
* `pending_rewards` tool — engine doesn't import `@mysten/sui` directly
|
|
1003
|
-
* (would expand its dep surface), so this helper accepts just `(address,
|
|
1004
|
-
* suiRpcUrl?)` and instantiates the client internally.
|
|
1005
|
-
*
|
|
1006
|
-
* **Why this exists.** Pre-fix the engine tool went through
|
|
1007
|
-
* `requireAgent(context).getPendingRewards()`, which threw
|
|
1008
|
-
* "Tool requires a T2000 agent instance — pass `agent` in EngineConfig"
|
|
1009
|
-
* in audric prod (audric uses sponsored-tx flow, never instantiates a
|
|
1010
|
-
* T2000 agent). Live mainnet smoke on funkii's wallet 2026-05-08 caught
|
|
1011
|
-
* this immediately when the LLM correctly called pending_rewards before
|
|
1012
|
-
* harvest_rewards. This helper makes the audric/CLI paths symmetric
|
|
1013
|
-
* (both work, neither requires an agent).
|
|
1014
|
-
*
|
|
1015
|
-
* Defaults `suiRpcUrl` to mainnet fullnode for CLI / standalone callers
|
|
1016
|
-
* that don't pass one. Errors propagate with the same `T2000Error`
|
|
1017
|
-
* shape as the underlying `getPendingRewards` (PROTOCOL_UNAVAILABLE on
|
|
1018
|
-
* NAVI degradation, etc.) so the engine tool's catch path is unchanged.
|
|
1019
|
-
*/
|
|
1020
|
-
declare function getPendingRewardsByAddress(address: string, suiRpcUrl?: string): Promise<PendingReward$1[]>;
|
|
1021
|
-
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
1022
|
-
declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
1023
|
-
/**
|
|
1024
|
-
* Standalone builder for the `claim_rewards` tool. Wraps the existing
|
|
1025
|
-
* `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
|
|
1026
|
-
* `composeTx` registry adapter has a single-step builder it can dispatch
|
|
1027
|
-
* to when `claim_rewards` is invoked alone (the chain-mode path uses
|
|
1028
|
-
* `addClaimRewardsToTx` directly inside a multi-step PTB).
|
|
1029
|
-
*
|
|
1030
|
-
* Multi-protocol claim flows (e.g. NAVI + Suilend in a future world)
|
|
1031
|
-
* still go through the `T2000` class's `claimRewards()` method, which
|
|
1032
|
-
* iterates every registered lending adapter via the adapter registry —
|
|
1033
|
-
* this standalone builder is intentionally NAVI-only to keep the shape
|
|
1034
|
-
* symmetric with the rest of SPEC 7's Layer 1 builders.
|
|
1035
|
-
*
|
|
1036
|
-
* Returns `{ tx, rewards }`:
|
|
1037
|
-
* - `tx` — built PTB with sender set; if no rewards are claimable, no
|
|
1038
|
-
* move calls are appended (caller should skip executing).
|
|
1039
|
-
* - `rewards` — what WILL be claimed by `tx`. Empty array means nothing
|
|
1040
|
-
* to claim.
|
|
1041
|
-
*/
|
|
1042
|
-
declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string): Promise<{
|
|
1043
|
-
tx: Transaction;
|
|
1044
|
-
rewards: PendingReward$1[];
|
|
1045
|
-
}>;
|
|
1046
|
-
/**
|
|
1047
|
-
* Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
|
|
1048
|
-
* structural rather than imported so the tests don't have to reproduce
|
|
1049
|
-
* the full upstream type and the function works for any future caller
|
|
1050
|
-
* that has the same fields.
|
|
1051
|
-
*/
|
|
1052
|
-
interface ClaimableRewardLike {
|
|
1053
|
-
userClaimableReward: number | string;
|
|
1054
|
-
rewardCoinType: string;
|
|
1055
|
-
assetId?: number | string;
|
|
1056
|
-
}
|
|
1057
|
-
/**
|
|
1058
|
-
* Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
|
|
1059
|
-
* the engine surfaces to the LLM and the UI. Aggregates by reward coin
|
|
1060
|
-
* type so a user with rewards from multiple pools (e.g. USDC pool + SUI
|
|
1061
|
-
* pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
|
|
1062
|
-
* than three separate dust entries. Filters out non-finite / non-positive
|
|
1063
|
-
* amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
|
|
1064
|
-
*/
|
|
1065
|
-
declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
|
|
1066
|
-
|
|
1067
|
-
/**
|
|
1068
|
-
* NAVI rewards harvest — single-PTB compound flow.
|
|
1069
|
-
*
|
|
1070
|
-
* **Goal.** Bundle the three-step "claim → swap → save" reward-cycling
|
|
1071
|
-
* routine into ONE atomic Programmable Transaction Block so the user
|
|
1072
|
-
* sees ONE confirm card instead of three sequential ones, and so the
|
|
1073
|
-
* legs settle together (or revert together — no half-claimed-but-
|
|
1074
|
-
* unsaved drift).
|
|
1075
|
-
*
|
|
1076
|
-
* **Flow.**
|
|
1077
|
-
* 1. Read pending rewards via NAVI's `getUserAvailableLendingRewards`
|
|
1078
|
-
* (same source as `getPendingRewards` + `addClaimRewardsToTx`, so
|
|
1079
|
-
* what the user sees in `pending_rewards` is exactly what gets
|
|
1080
|
-
* harvested — no drift).
|
|
1081
|
-
* 2. Append `claimLendingRewardsPTB(... { customCoinReceive: { type: 'skip' }})`
|
|
1082
|
-
* so the claimed coin handles are returned as `TransactionObjectArgument`
|
|
1083
|
-
* handles instead of being transferred to the wallet — they stay
|
|
1084
|
-
* consumable inside the same PTB.
|
|
1085
|
-
* 3. For each claimed handle:
|
|
1086
|
-
* • If the reward IS USDC, hold the handle for the deposit step.
|
|
1087
|
-
* • If the reward is in `COIN_REGISTRY` AND tradeable on Cetus
|
|
1088
|
-
* (any tier-2 token effectively), append `addSwapToTx` in chain
|
|
1089
|
-
* mode using the claimed coin as `inputCoin`. Collect the USDC
|
|
1090
|
-
* output handle.
|
|
1091
|
-
* • Else (untradeable / non-registry), transfer the claimed coin
|
|
1092
|
-
* back to the user's wallet — preserves the reward but skips
|
|
1093
|
-
* the auto-deposit (the user keeps it as a wallet asset).
|
|
1094
|
-
* 4. Merge all collected USDC handles via `tx.mergeCoins`, then deposit
|
|
1095
|
-
* via `addSaveToTx`.
|
|
1096
|
-
*
|
|
1097
|
-
* **Atomicity.** Single PTB = single transaction = single sponsored-gas
|
|
1098
|
-
* envelope. Either ALL legs settle (claim + swap(s) + deposit) or none
|
|
1099
|
-
* do. No partial-state recovery code needed.
|
|
1100
|
-
*
|
|
1101
|
-
* **Sponsored-gas posture.** This builder appends ONLY chained move
|
|
1102
|
-
* calls — no `tx.gas` reads, no Pyth fee writes, no oracle Pyth updates.
|
|
1103
|
-
* Cetus chain-mode swaps with `slippage` ≤ 5% don't require Pyth either
|
|
1104
|
-
* (Cetus aggregator routes around Pyth-dependent providers when callers
|
|
1105
|
-
* pass `providers: getProvidersExcluding(...)`). Audric's host wires
|
|
1106
|
-
* the provider exclusion automatically for Enoki sponsorship — see
|
|
1107
|
-
* `cetus-swap.ts` JSDoc.
|
|
1108
|
-
*
|
|
1109
|
-
* **Dust filter.** Rewards with `amount * priceCache.get(symbol) <
|
|
1110
|
-
* minRewardUsd` are skipped from the swap leg AND from the deposit —
|
|
1111
|
-
* not worth the gas to swap dust. They get transferred back to the
|
|
1112
|
-
* wallet (preserving on-chain truth: the claim happened, the swap
|
|
1113
|
-
* didn't). Default minRewardUsd = $0.01.
|
|
1114
|
-
*
|
|
1115
|
-
* **Failure modes.**
|
|
1116
|
-
* - PROTOCOL_UNAVAILABLE — NAVI rewards lookup or claim PTB build failed.
|
|
1117
|
-
* Engine surfaces "NAVI is degraded right now."
|
|
1118
|
-
* - SWAP_NO_ROUTE — a reward asset has no Cetus route. Logged + that
|
|
1119
|
-
* leg is skipped (rewards transferred to wallet). Other legs proceed.
|
|
1120
|
-
* - INVALID_AMOUNT — rewards array empty after dust filter (nothing
|
|
1121
|
-
* worth harvesting). Throws so the engine narrates "nothing to
|
|
1122
|
-
* harvest right now" instead of building a no-op PTB.
|
|
1123
|
-
*
|
|
1124
|
-
* **Why a separate file (not inside `navi.ts`).** This composition
|
|
1125
|
-
* crosses two protocols (NAVI + Cetus) — keeping it out of `navi.ts`
|
|
1126
|
-
* preserves the single-protocol-per-file invariant the rest of the SDK
|
|
1127
|
-
* follows. Mirrors how `cetus-swap.ts` already lives separately even
|
|
1128
|
-
* though it composes through `composeTx.ts`.
|
|
1129
|
-
*/
|
|
1130
|
-
|
|
1131
|
-
interface HarvestSwapLeg {
|
|
1132
|
-
/** Reward symbol pre-swap (e.g. 'vSUI', 'NAVX'). */
|
|
1133
|
-
fromSymbol: string;
|
|
1134
|
-
/** Reward coinType pre-swap. */
|
|
1135
|
-
fromCoinType: string;
|
|
1136
|
-
/** Always 'USDC' — this builder only deposits to the USDC pool. */
|
|
1137
|
-
toSymbol: 'USDC';
|
|
1138
|
-
/** Display-units input amount (the entire claimed reward for that coin). */
|
|
1139
|
-
inputAmount: number;
|
|
1140
|
-
/** Display-units USDC the swap quote estimated. Actual on-chain may differ within slippage. */
|
|
1141
|
-
expectedOutputUsdc: number;
|
|
1142
|
-
}
|
|
1143
|
-
interface HarvestSkippedLeg {
|
|
1144
|
-
/** Reward symbol skipped (untradeable, dust, or no-route). */
|
|
1145
|
-
symbol: string;
|
|
1146
|
-
coinType: string;
|
|
1147
|
-
/** Display-units claimed amount (still credited to user's wallet — just not auto-deposited). */
|
|
1148
|
-
amount: number;
|
|
1149
|
-
/** 'untradeable' | 'dust' | 'no-route' */
|
|
1150
|
-
reason: 'untradeable' | 'dust' | 'no-route';
|
|
1151
|
-
}
|
|
1152
|
-
interface HarvestPlan {
|
|
1153
|
-
/** Every reward that WILL be claimed by this PTB. */
|
|
1154
|
-
claimed: PendingReward$1[];
|
|
1155
|
-
/** Each non-USDC reward that WILL be swapped to USDC inline. */
|
|
1156
|
-
swaps: HarvestSwapLeg[];
|
|
1157
|
-
/** Rewards claimed but transferred back to wallet (no auto-deposit). */
|
|
1158
|
-
skipped: HarvestSkippedLeg[];
|
|
1159
|
-
/** Display-units USDC that will be deposited to the NAVI USDC pool. */
|
|
1160
|
-
expectedUsdcDeposited: number;
|
|
1161
|
-
}
|
|
1162
|
-
/**
|
|
1163
|
-
* Callback invoked right before the harvest's internal `addSaveToTx`.
|
|
1164
|
-
* Mirrors the shape of `composeTx`'s `feeHooks.save_deposit` so audric's
|
|
1165
|
-
* existing hook can be threaded straight through without adapters. The
|
|
1166
|
-
* SDK never invents a fee — the host decides whether to skim from
|
|
1167
|
-
* `coin` and to where. See CLAUDE.md rule #9 (fees are a host concern).
|
|
1168
|
-
*/
|
|
1169
|
-
type HarvestSaveFeeHook = (ctx: {
|
|
1170
|
-
tx: Transaction;
|
|
1171
|
-
coin: TransactionObjectArgument;
|
|
1172
|
-
input: {
|
|
1173
|
-
asset: 'USDC';
|
|
1174
|
-
amount: number;
|
|
1175
|
-
};
|
|
1176
|
-
sender: string;
|
|
1177
|
-
}) => void | Promise<void>;
|
|
1178
|
-
interface BuildHarvestRewardsTxOptions {
|
|
1179
|
-
/** Per-swap slippage tolerance (0.001–0.05). Defaults to 0.01 (1%). */
|
|
1180
|
-
slippage?: number;
|
|
1181
|
-
/**
|
|
1182
|
-
* USD floor for "is this worth swapping?". Rewards below this threshold
|
|
1183
|
-
* get transferred back to the wallet instead of swapped. Default $0.01.
|
|
1184
|
-
* Pass 0 to disable the filter (always swap; useful for tests).
|
|
1185
|
-
*/
|
|
1186
|
-
minRewardUsd?: number;
|
|
1187
|
-
/**
|
|
1188
|
-
* Symbol → USD price map. Sourced from the engine's `ToolContext.priceCache`
|
|
1189
|
-
* in production; tests can pass a literal Map. When undefined, the dust
|
|
1190
|
-
* filter degrades to "skip nothing" (every reward is swapped) so we don't
|
|
1191
|
-
* accidentally drop large rewards just because we couldn't price them.
|
|
1192
|
-
*/
|
|
1193
|
-
priceCache?: Map<string, number>;
|
|
1194
|
-
/**
|
|
1195
|
-
* Cetus provider allow-list. Sponsored callers (Enoki) pass
|
|
1196
|
-
* `getProvidersExcluding(['pyth-dependent-list'])` to keep the PTB
|
|
1197
|
-
* Pyth-free. Non-sponsored callers omit this.
|
|
1198
|
-
*/
|
|
1199
|
-
providers?: string[];
|
|
1200
|
-
/**
|
|
1201
|
-
* [v1.24.2 fee wiring] Overlay fee forwarded to EACH internal
|
|
1202
|
-
* `addSwapToTx` call. When set, every swap leg charges the rate to
|
|
1203
|
-
* the receiver (typically `T2000_OVERLAY_FEE_WALLET` for audric).
|
|
1204
|
-
* Omit for fee-free harvests (CLI / direct SDK callers).
|
|
1205
|
-
*/
|
|
1206
|
-
overlayFee?: OverlayFeeConfig;
|
|
1207
|
-
/**
|
|
1208
|
-
* [v1.24.2 fee wiring] Fired immediately before the internal
|
|
1209
|
-
* `addSaveToTx` consumes the merged USDC deposit coin. The hook
|
|
1210
|
-
* receives the deposit handle so it can split a fee off via
|
|
1211
|
-
* `addFeeTransfer(...)` (host's call). Audric threads its
|
|
1212
|
-
* `feeHooks.save_deposit` straight through here so a harvest's
|
|
1213
|
-
* deposit leg pays the same `SAVE_FEE_BPS` as a single-op `save`.
|
|
1214
|
-
*
|
|
1215
|
-
* Order is load-bearing: this hook fires AFTER all USDC handles
|
|
1216
|
-
* are merged into one and BEFORE the NAVI deposit consumes it.
|
|
1217
|
-
* Fee receiver gets recorded as a top-level transferObjects, so
|
|
1218
|
-
* it's automatically picked up by `derivedAllowedAddresses`.
|
|
1219
|
-
*/
|
|
1220
|
-
saveFeeHook?: HarvestSaveFeeHook;
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* Standalone harvest builder — creates a fresh PTB, sets the sender,
|
|
1224
|
-
* appends the full harvest flow, and returns both the tx and the plan.
|
|
1225
|
-
* Used by CLI / direct SDK callers (smoke tests, scripts). The audric
|
|
1226
|
-
* host goes through `composeTx({ steps: [{ toolName: 'harvest_rewards' }] })`
|
|
1227
|
-
* which wires the appender + Enoki sponsorship.
|
|
1228
|
-
*/
|
|
1229
|
-
declare function buildHarvestRewardsTx(client: SuiJsonRpcClient, address: string, options?: BuildHarvestRewardsTxOptions): Promise<{
|
|
1230
|
-
tx: Transaction;
|
|
1231
|
-
plan: HarvestPlan;
|
|
1232
|
-
}>;
|
|
1233
|
-
|
|
1234
722
|
declare function getSwapQuote(params: {
|
|
1235
723
|
walletAddress: string;
|
|
1236
724
|
from: string;
|
|
@@ -1400,4 +888,4 @@ declare function fullHandle(label: string): string;
|
|
|
1400
888
|
*/
|
|
1401
889
|
declare function displayHandle(label: string): string;
|
|
1402
890
|
|
|
1403
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type
|
|
891
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BuildAddLeafParams, type BuildRevokeLeafParams, type ComposeTxOptions, type ComposeTxResult, DepositInfo, InvalidAddressError, type LabelValidationResult, type NormalizedAddress, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, SPONSORED_PYTH_DEPENDENT_PROVIDERS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SafeguardConfig, SafeguardEnforcer, SendResult, type SendTransferInput, SendableAsset, type StepPreview, SuinsNotRegisteredError, SuinsRpcError, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, WRITE_APPENDER_REGISTRY, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, buildAddLeafTx, buildRevokeLeafTx, buildSendTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fullHandle, generateKeypair, getAddress, getSponsoredSwapProviders, getSwapQuote, keypairFromPrivateKey, loadKey, looksLikeSuiNs, normalizeAddressInput, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, saveBech32, saveKey, validateLabel, walletExists };
|