@t2000/sdk 1.23.0 → 1.24.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/dist/adapters/index.cjs +45 -48
- package/dist/adapters/index.cjs.map +1 -1
- package/dist/adapters/index.js +45 -48
- package/dist/adapters/index.js.map +1 -1
- package/dist/index.cjs +208 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +191 -4
- package/dist/index.d.ts +191 -4
- package/dist/index.js +206 -49
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -433,14 +433,15 @@ declare function selectSuiCoin(tx: Transaction, client: SuiJsonRpcClient, owner:
|
|
|
433
433
|
*/
|
|
434
434
|
|
|
435
435
|
/**
|
|
436
|
-
* Canonical write tools. The
|
|
436
|
+
* Canonical write tools. The 10 tools that can be composed into a PTB
|
|
437
|
+
* (Track B 2026-05-08 added `harvest_rewards`).
|
|
437
438
|
*
|
|
438
439
|
* Excluded by design:
|
|
439
440
|
* - `pay_api` — recipient/amount unknown at compose time; the on-chain
|
|
440
441
|
* leg uses `send_transfer` after the gateway 402 challenge resolves.
|
|
441
442
|
* - `save_contact` — no on-chain leg (Prisma-only).
|
|
442
443
|
*/
|
|
443
|
-
type WriteToolName = 'save_deposit' | 'withdraw' | 'borrow' | 'repay_debt' | 'send_transfer' | 'swap_execute' | 'claim_rewards' | 'volo_stake' | 'volo_unstake';
|
|
444
|
+
type WriteToolName = 'save_deposit' | 'withdraw' | 'borrow' | 'repay_debt' | 'send_transfer' | 'swap_execute' | 'claim_rewards' | 'harvest_rewards' | 'volo_stake' | 'volo_unstake';
|
|
444
445
|
interface SaveDepositInput {
|
|
445
446
|
amount: number;
|
|
446
447
|
asset?: 'USDC' | 'USDsui';
|
|
@@ -474,6 +475,18 @@ interface SwapExecuteInput {
|
|
|
474
475
|
providers?: string[];
|
|
475
476
|
}
|
|
476
477
|
type ClaimRewardsInput = Record<string, never>;
|
|
478
|
+
/**
|
|
479
|
+
* [Track B] `harvest_rewards` accepts only optional tunables — no required
|
|
480
|
+
* inputs, since the user's choice is binary ("harvest now" or not). Default
|
|
481
|
+
* slippage 1%, default dust floor $0.01. The audric host's HARVEST chip
|
|
482
|
+
* passes literal `{}` and gets sensible defaults.
|
|
483
|
+
*/
|
|
484
|
+
interface HarvestRewardsInput {
|
|
485
|
+
/** Per-swap slippage tolerance (0.001–0.05). Default 0.01 (1%). */
|
|
486
|
+
slippage?: number;
|
|
487
|
+
/** USD floor for "is this worth swapping?" — dust below transfers to wallet. Default $0.01. */
|
|
488
|
+
minRewardUsd?: number;
|
|
489
|
+
}
|
|
477
490
|
interface VoloStakeInput {
|
|
478
491
|
amountSui: number;
|
|
479
492
|
}
|
|
@@ -522,6 +535,9 @@ type WriteStep = {
|
|
|
522
535
|
} | {
|
|
523
536
|
toolName: 'claim_rewards';
|
|
524
537
|
input: ClaimRewardsInput;
|
|
538
|
+
} | {
|
|
539
|
+
toolName: 'harvest_rewards';
|
|
540
|
+
input: HarvestRewardsInput;
|
|
525
541
|
} | {
|
|
526
542
|
toolName: 'volo_stake';
|
|
527
543
|
input: VoloStakeInput;
|
|
@@ -641,6 +657,23 @@ type StepPreview = {
|
|
|
641
657
|
} | {
|
|
642
658
|
toolName: 'claim_rewards';
|
|
643
659
|
rewards: PendingReward$1[];
|
|
660
|
+
} | {
|
|
661
|
+
toolName: 'harvest_rewards';
|
|
662
|
+
claimed: PendingReward$1[];
|
|
663
|
+
swaps: Array<{
|
|
664
|
+
fromSymbol: string;
|
|
665
|
+
fromCoinType: string;
|
|
666
|
+
toSymbol: 'USDC';
|
|
667
|
+
inputAmount: number;
|
|
668
|
+
expectedOutputUsdc: number;
|
|
669
|
+
}>;
|
|
670
|
+
skipped: Array<{
|
|
671
|
+
symbol: string;
|
|
672
|
+
coinType: string;
|
|
673
|
+
amount: number;
|
|
674
|
+
reason: 'untradeable' | 'dust' | 'no-route';
|
|
675
|
+
}>;
|
|
676
|
+
expectedUsdcDeposited: number;
|
|
644
677
|
} | {
|
|
645
678
|
toolName: 'volo_stake';
|
|
646
679
|
effectiveAmountMist: bigint;
|
|
@@ -719,7 +752,7 @@ type AppenderFn<TInput, TPreview extends StepPreview> = (tx: Transaction, input:
|
|
|
719
752
|
/**
|
|
720
753
|
* The typed registry. Each entry is a wallet-mode dispatcher that takes
|
|
721
754
|
* (tx, input, ctx) and returns a per-step preview. Compile-time check
|
|
722
|
-
* that all
|
|
755
|
+
* that all 10 `WriteToolName` values have an entry — TypeScript will
|
|
723
756
|
* fail the build if a tool is missing.
|
|
724
757
|
*/
|
|
725
758
|
declare const WRITE_APPENDER_REGISTRY: {
|
|
@@ -744,6 +777,9 @@ declare const WRITE_APPENDER_REGISTRY: {
|
|
|
744
777
|
claim_rewards: AppenderFn<ClaimRewardsInput, Extract<StepPreview, {
|
|
745
778
|
toolName: 'claim_rewards';
|
|
746
779
|
}>>;
|
|
780
|
+
harvest_rewards: AppenderFn<HarvestRewardsInput, Extract<StepPreview, {
|
|
781
|
+
toolName: 'harvest_rewards';
|
|
782
|
+
}>>;
|
|
747
783
|
volo_stake: AppenderFn<VoloStakeInput, Extract<StepPreview, {
|
|
748
784
|
toolName: 'volo_stake';
|
|
749
785
|
}>>;
|
|
@@ -794,6 +830,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
|
|
|
794
830
|
|
|
795
831
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
796
832
|
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
833
|
+
declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
834
|
/**
|
|
798
835
|
* Standalone builder for the `claim_rewards` tool. Wraps the existing
|
|
799
836
|
* `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
|
|
@@ -817,6 +854,156 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
|
|
|
817
854
|
tx: Transaction;
|
|
818
855
|
rewards: PendingReward$1[];
|
|
819
856
|
}>;
|
|
857
|
+
/**
|
|
858
|
+
* Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
|
|
859
|
+
* structural rather than imported so the tests don't have to reproduce
|
|
860
|
+
* the full upstream type and the function works for any future caller
|
|
861
|
+
* that has the same fields.
|
|
862
|
+
*/
|
|
863
|
+
interface ClaimableRewardLike {
|
|
864
|
+
userClaimableReward: number | string;
|
|
865
|
+
rewardCoinType: string;
|
|
866
|
+
assetId?: number | string;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
|
|
870
|
+
* the engine surfaces to the LLM and the UI. Aggregates by reward coin
|
|
871
|
+
* type so a user with rewards from multiple pools (e.g. USDC pool + SUI
|
|
872
|
+
* pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
|
|
873
|
+
* than three separate dust entries. Filters out non-finite / non-positive
|
|
874
|
+
* amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
|
|
875
|
+
*/
|
|
876
|
+
declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* NAVI rewards harvest — single-PTB compound flow.
|
|
880
|
+
*
|
|
881
|
+
* **Goal.** Bundle the three-step "claim → swap → save" reward-cycling
|
|
882
|
+
* routine into ONE atomic Programmable Transaction Block so the user
|
|
883
|
+
* sees ONE confirm card instead of three sequential ones, and so the
|
|
884
|
+
* legs settle together (or revert together — no half-claimed-but-
|
|
885
|
+
* unsaved drift).
|
|
886
|
+
*
|
|
887
|
+
* **Flow.**
|
|
888
|
+
* 1. Read pending rewards via NAVI's `getUserAvailableLendingRewards`
|
|
889
|
+
* (same source as `getPendingRewards` + `addClaimRewardsToTx`, so
|
|
890
|
+
* what the user sees in `pending_rewards` is exactly what gets
|
|
891
|
+
* harvested — no drift).
|
|
892
|
+
* 2. Append `claimLendingRewardsPTB(... { customCoinReceive: { type: 'skip' }})`
|
|
893
|
+
* so the claimed coin handles are returned as `TransactionObjectArgument`
|
|
894
|
+
* handles instead of being transferred to the wallet — they stay
|
|
895
|
+
* consumable inside the same PTB.
|
|
896
|
+
* 3. For each claimed handle:
|
|
897
|
+
* • If the reward IS USDC, hold the handle for the deposit step.
|
|
898
|
+
* • If the reward is in `COIN_REGISTRY` AND tradeable on Cetus
|
|
899
|
+
* (any tier-2 token effectively), append `addSwapToTx` in chain
|
|
900
|
+
* mode using the claimed coin as `inputCoin`. Collect the USDC
|
|
901
|
+
* output handle.
|
|
902
|
+
* • Else (untradeable / non-registry), transfer the claimed coin
|
|
903
|
+
* back to the user's wallet — preserves the reward but skips
|
|
904
|
+
* the auto-deposit (the user keeps it as a wallet asset).
|
|
905
|
+
* 4. Merge all collected USDC handles via `tx.mergeCoins`, then deposit
|
|
906
|
+
* via `addSaveToTx`.
|
|
907
|
+
*
|
|
908
|
+
* **Atomicity.** Single PTB = single transaction = single sponsored-gas
|
|
909
|
+
* envelope. Either ALL legs settle (claim + swap(s) + deposit) or none
|
|
910
|
+
* do. No partial-state recovery code needed.
|
|
911
|
+
*
|
|
912
|
+
* **Sponsored-gas posture.** This builder appends ONLY chained move
|
|
913
|
+
* calls — no `tx.gas` reads, no Pyth fee writes, no oracle Pyth updates.
|
|
914
|
+
* Cetus chain-mode swaps with `slippage` ≤ 5% don't require Pyth either
|
|
915
|
+
* (Cetus aggregator routes around Pyth-dependent providers when callers
|
|
916
|
+
* pass `providers: getProvidersExcluding(...)`). Audric's host wires
|
|
917
|
+
* the provider exclusion automatically for Enoki sponsorship — see
|
|
918
|
+
* `cetus-swap.ts` JSDoc.
|
|
919
|
+
*
|
|
920
|
+
* **Dust filter.** Rewards with `amount * priceCache.get(symbol) <
|
|
921
|
+
* minRewardUsd` are skipped from the swap leg AND from the deposit —
|
|
922
|
+
* not worth the gas to swap dust. They get transferred back to the
|
|
923
|
+
* wallet (preserving on-chain truth: the claim happened, the swap
|
|
924
|
+
* didn't). Default minRewardUsd = $0.01.
|
|
925
|
+
*
|
|
926
|
+
* **Failure modes.**
|
|
927
|
+
* - PROTOCOL_UNAVAILABLE — NAVI rewards lookup or claim PTB build failed.
|
|
928
|
+
* Engine surfaces "NAVI is degraded right now."
|
|
929
|
+
* - SWAP_NO_ROUTE — a reward asset has no Cetus route. Logged + that
|
|
930
|
+
* leg is skipped (rewards transferred to wallet). Other legs proceed.
|
|
931
|
+
* - INVALID_AMOUNT — rewards array empty after dust filter (nothing
|
|
932
|
+
* worth harvesting). Throws so the engine narrates "nothing to
|
|
933
|
+
* harvest right now" instead of building a no-op PTB.
|
|
934
|
+
*
|
|
935
|
+
* **Why a separate file (not inside `navi.ts`).** This composition
|
|
936
|
+
* crosses two protocols (NAVI + Cetus) — keeping it out of `navi.ts`
|
|
937
|
+
* preserves the single-protocol-per-file invariant the rest of the SDK
|
|
938
|
+
* follows. Mirrors how `cetus-swap.ts` already lives separately even
|
|
939
|
+
* though it composes through `composeTx.ts`.
|
|
940
|
+
*/
|
|
941
|
+
|
|
942
|
+
interface HarvestSwapLeg {
|
|
943
|
+
/** Reward symbol pre-swap (e.g. 'vSUI', 'NAVX'). */
|
|
944
|
+
fromSymbol: string;
|
|
945
|
+
/** Reward coinType pre-swap. */
|
|
946
|
+
fromCoinType: string;
|
|
947
|
+
/** Always 'USDC' — this builder only deposits to the USDC pool. */
|
|
948
|
+
toSymbol: 'USDC';
|
|
949
|
+
/** Display-units input amount (the entire claimed reward for that coin). */
|
|
950
|
+
inputAmount: number;
|
|
951
|
+
/** Display-units USDC the swap quote estimated. Actual on-chain may differ within slippage. */
|
|
952
|
+
expectedOutputUsdc: number;
|
|
953
|
+
}
|
|
954
|
+
interface HarvestSkippedLeg {
|
|
955
|
+
/** Reward symbol skipped (untradeable, dust, or no-route). */
|
|
956
|
+
symbol: string;
|
|
957
|
+
coinType: string;
|
|
958
|
+
/** Display-units claimed amount (still credited to user's wallet — just not auto-deposited). */
|
|
959
|
+
amount: number;
|
|
960
|
+
/** 'untradeable' | 'dust' | 'no-route' */
|
|
961
|
+
reason: 'untradeable' | 'dust' | 'no-route';
|
|
962
|
+
}
|
|
963
|
+
interface HarvestPlan {
|
|
964
|
+
/** Every reward that WILL be claimed by this PTB. */
|
|
965
|
+
claimed: PendingReward$1[];
|
|
966
|
+
/** Each non-USDC reward that WILL be swapped to USDC inline. */
|
|
967
|
+
swaps: HarvestSwapLeg[];
|
|
968
|
+
/** Rewards claimed but transferred back to wallet (no auto-deposit). */
|
|
969
|
+
skipped: HarvestSkippedLeg[];
|
|
970
|
+
/** Display-units USDC that will be deposited to the NAVI USDC pool. */
|
|
971
|
+
expectedUsdcDeposited: number;
|
|
972
|
+
}
|
|
973
|
+
interface BuildHarvestRewardsTxOptions {
|
|
974
|
+
/** Per-swap slippage tolerance (0.001–0.05). Defaults to 0.01 (1%). */
|
|
975
|
+
slippage?: number;
|
|
976
|
+
/**
|
|
977
|
+
* USD floor for "is this worth swapping?". Rewards below this threshold
|
|
978
|
+
* get transferred back to the wallet instead of swapped. Default $0.01.
|
|
979
|
+
* Pass 0 to disable the filter (always swap; useful for tests).
|
|
980
|
+
*/
|
|
981
|
+
minRewardUsd?: number;
|
|
982
|
+
/**
|
|
983
|
+
* Symbol → USD price map. Sourced from the engine's `ToolContext.priceCache`
|
|
984
|
+
* in production; tests can pass a literal Map. When undefined, the dust
|
|
985
|
+
* filter degrades to "skip nothing" (every reward is swapped) so we don't
|
|
986
|
+
* accidentally drop large rewards just because we couldn't price them.
|
|
987
|
+
*/
|
|
988
|
+
priceCache?: Map<string, number>;
|
|
989
|
+
/**
|
|
990
|
+
* Cetus provider allow-list. Sponsored callers (Enoki) pass
|
|
991
|
+
* `getProvidersExcluding(['pyth-dependent-list'])` to keep the PTB
|
|
992
|
+
* Pyth-free. Non-sponsored callers omit this.
|
|
993
|
+
*/
|
|
994
|
+
providers?: string[];
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Standalone harvest builder — creates a fresh PTB, sets the sender,
|
|
998
|
+
* appends the full harvest flow, and returns both the tx and the plan.
|
|
999
|
+
* Used by CLI / direct SDK callers (smoke tests, scripts). The audric
|
|
1000
|
+
* host goes through `composeTx({ steps: [{ toolName: 'harvest_rewards' }] })`
|
|
1001
|
+
* which wires the appender + Enoki sponsorship.
|
|
1002
|
+
*/
|
|
1003
|
+
declare function buildHarvestRewardsTx(client: SuiJsonRpcClient, address: string, options?: BuildHarvestRewardsTxOptions): Promise<{
|
|
1004
|
+
tx: Transaction;
|
|
1005
|
+
plan: HarvestPlan;
|
|
1006
|
+
}>;
|
|
820
1007
|
|
|
821
1008
|
declare function getSwapQuote(params: {
|
|
822
1009
|
walletAddress: string;
|
|
@@ -1055,4 +1242,4 @@ declare function fullHandle(label: string): string;
|
|
|
1055
1242
|
*/
|
|
1056
1243
|
declare function displayHandle(label: string): string;
|
|
1057
1244
|
|
|
1058
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
|
1245
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -433,14 +433,15 @@ declare function selectSuiCoin(tx: Transaction, client: SuiJsonRpcClient, owner:
|
|
|
433
433
|
*/
|
|
434
434
|
|
|
435
435
|
/**
|
|
436
|
-
* Canonical write tools. The
|
|
436
|
+
* Canonical write tools. The 10 tools that can be composed into a PTB
|
|
437
|
+
* (Track B 2026-05-08 added `harvest_rewards`).
|
|
437
438
|
*
|
|
438
439
|
* Excluded by design:
|
|
439
440
|
* - `pay_api` — recipient/amount unknown at compose time; the on-chain
|
|
440
441
|
* leg uses `send_transfer` after the gateway 402 challenge resolves.
|
|
441
442
|
* - `save_contact` — no on-chain leg (Prisma-only).
|
|
442
443
|
*/
|
|
443
|
-
type WriteToolName = 'save_deposit' | 'withdraw' | 'borrow' | 'repay_debt' | 'send_transfer' | 'swap_execute' | 'claim_rewards' | 'volo_stake' | 'volo_unstake';
|
|
444
|
+
type WriteToolName = 'save_deposit' | 'withdraw' | 'borrow' | 'repay_debt' | 'send_transfer' | 'swap_execute' | 'claim_rewards' | 'harvest_rewards' | 'volo_stake' | 'volo_unstake';
|
|
444
445
|
interface SaveDepositInput {
|
|
445
446
|
amount: number;
|
|
446
447
|
asset?: 'USDC' | 'USDsui';
|
|
@@ -474,6 +475,18 @@ interface SwapExecuteInput {
|
|
|
474
475
|
providers?: string[];
|
|
475
476
|
}
|
|
476
477
|
type ClaimRewardsInput = Record<string, never>;
|
|
478
|
+
/**
|
|
479
|
+
* [Track B] `harvest_rewards` accepts only optional tunables — no required
|
|
480
|
+
* inputs, since the user's choice is binary ("harvest now" or not). Default
|
|
481
|
+
* slippage 1%, default dust floor $0.01. The audric host's HARVEST chip
|
|
482
|
+
* passes literal `{}` and gets sensible defaults.
|
|
483
|
+
*/
|
|
484
|
+
interface HarvestRewardsInput {
|
|
485
|
+
/** Per-swap slippage tolerance (0.001–0.05). Default 0.01 (1%). */
|
|
486
|
+
slippage?: number;
|
|
487
|
+
/** USD floor for "is this worth swapping?" — dust below transfers to wallet. Default $0.01. */
|
|
488
|
+
minRewardUsd?: number;
|
|
489
|
+
}
|
|
477
490
|
interface VoloStakeInput {
|
|
478
491
|
amountSui: number;
|
|
479
492
|
}
|
|
@@ -522,6 +535,9 @@ type WriteStep = {
|
|
|
522
535
|
} | {
|
|
523
536
|
toolName: 'claim_rewards';
|
|
524
537
|
input: ClaimRewardsInput;
|
|
538
|
+
} | {
|
|
539
|
+
toolName: 'harvest_rewards';
|
|
540
|
+
input: HarvestRewardsInput;
|
|
525
541
|
} | {
|
|
526
542
|
toolName: 'volo_stake';
|
|
527
543
|
input: VoloStakeInput;
|
|
@@ -641,6 +657,23 @@ type StepPreview = {
|
|
|
641
657
|
} | {
|
|
642
658
|
toolName: 'claim_rewards';
|
|
643
659
|
rewards: PendingReward$1[];
|
|
660
|
+
} | {
|
|
661
|
+
toolName: 'harvest_rewards';
|
|
662
|
+
claimed: PendingReward$1[];
|
|
663
|
+
swaps: Array<{
|
|
664
|
+
fromSymbol: string;
|
|
665
|
+
fromCoinType: string;
|
|
666
|
+
toSymbol: 'USDC';
|
|
667
|
+
inputAmount: number;
|
|
668
|
+
expectedOutputUsdc: number;
|
|
669
|
+
}>;
|
|
670
|
+
skipped: Array<{
|
|
671
|
+
symbol: string;
|
|
672
|
+
coinType: string;
|
|
673
|
+
amount: number;
|
|
674
|
+
reason: 'untradeable' | 'dust' | 'no-route';
|
|
675
|
+
}>;
|
|
676
|
+
expectedUsdcDeposited: number;
|
|
644
677
|
} | {
|
|
645
678
|
toolName: 'volo_stake';
|
|
646
679
|
effectiveAmountMist: bigint;
|
|
@@ -719,7 +752,7 @@ type AppenderFn<TInput, TPreview extends StepPreview> = (tx: Transaction, input:
|
|
|
719
752
|
/**
|
|
720
753
|
* The typed registry. Each entry is a wallet-mode dispatcher that takes
|
|
721
754
|
* (tx, input, ctx) and returns a per-step preview. Compile-time check
|
|
722
|
-
* that all
|
|
755
|
+
* that all 10 `WriteToolName` values have an entry — TypeScript will
|
|
723
756
|
* fail the build if a tool is missing.
|
|
724
757
|
*/
|
|
725
758
|
declare const WRITE_APPENDER_REGISTRY: {
|
|
@@ -744,6 +777,9 @@ declare const WRITE_APPENDER_REGISTRY: {
|
|
|
744
777
|
claim_rewards: AppenderFn<ClaimRewardsInput, Extract<StepPreview, {
|
|
745
778
|
toolName: 'claim_rewards';
|
|
746
779
|
}>>;
|
|
780
|
+
harvest_rewards: AppenderFn<HarvestRewardsInput, Extract<StepPreview, {
|
|
781
|
+
toolName: 'harvest_rewards';
|
|
782
|
+
}>>;
|
|
747
783
|
volo_stake: AppenderFn<VoloStakeInput, Extract<StepPreview, {
|
|
748
784
|
toolName: 'volo_stake';
|
|
749
785
|
}>>;
|
|
@@ -794,6 +830,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
|
|
|
794
830
|
|
|
795
831
|
declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
|
|
796
832
|
declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
833
|
+
declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
|
|
797
834
|
/**
|
|
798
835
|
* Standalone builder for the `claim_rewards` tool. Wraps the existing
|
|
799
836
|
* `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
|
|
@@ -817,6 +854,156 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
|
|
|
817
854
|
tx: Transaction;
|
|
818
855
|
rewards: PendingReward$1[];
|
|
819
856
|
}>;
|
|
857
|
+
/**
|
|
858
|
+
* Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
|
|
859
|
+
* structural rather than imported so the tests don't have to reproduce
|
|
860
|
+
* the full upstream type and the function works for any future caller
|
|
861
|
+
* that has the same fields.
|
|
862
|
+
*/
|
|
863
|
+
interface ClaimableRewardLike {
|
|
864
|
+
userClaimableReward: number | string;
|
|
865
|
+
rewardCoinType: string;
|
|
866
|
+
assetId?: number | string;
|
|
867
|
+
}
|
|
868
|
+
/**
|
|
869
|
+
* Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
|
|
870
|
+
* the engine surfaces to the LLM and the UI. Aggregates by reward coin
|
|
871
|
+
* type so a user with rewards from multiple pools (e.g. USDC pool + SUI
|
|
872
|
+
* pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
|
|
873
|
+
* than three separate dust entries. Filters out non-finite / non-positive
|
|
874
|
+
* amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
|
|
875
|
+
*/
|
|
876
|
+
declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* NAVI rewards harvest — single-PTB compound flow.
|
|
880
|
+
*
|
|
881
|
+
* **Goal.** Bundle the three-step "claim → swap → save" reward-cycling
|
|
882
|
+
* routine into ONE atomic Programmable Transaction Block so the user
|
|
883
|
+
* sees ONE confirm card instead of three sequential ones, and so the
|
|
884
|
+
* legs settle together (or revert together — no half-claimed-but-
|
|
885
|
+
* unsaved drift).
|
|
886
|
+
*
|
|
887
|
+
* **Flow.**
|
|
888
|
+
* 1. Read pending rewards via NAVI's `getUserAvailableLendingRewards`
|
|
889
|
+
* (same source as `getPendingRewards` + `addClaimRewardsToTx`, so
|
|
890
|
+
* what the user sees in `pending_rewards` is exactly what gets
|
|
891
|
+
* harvested — no drift).
|
|
892
|
+
* 2. Append `claimLendingRewardsPTB(... { customCoinReceive: { type: 'skip' }})`
|
|
893
|
+
* so the claimed coin handles are returned as `TransactionObjectArgument`
|
|
894
|
+
* handles instead of being transferred to the wallet — they stay
|
|
895
|
+
* consumable inside the same PTB.
|
|
896
|
+
* 3. For each claimed handle:
|
|
897
|
+
* • If the reward IS USDC, hold the handle for the deposit step.
|
|
898
|
+
* • If the reward is in `COIN_REGISTRY` AND tradeable on Cetus
|
|
899
|
+
* (any tier-2 token effectively), append `addSwapToTx` in chain
|
|
900
|
+
* mode using the claimed coin as `inputCoin`. Collect the USDC
|
|
901
|
+
* output handle.
|
|
902
|
+
* • Else (untradeable / non-registry), transfer the claimed coin
|
|
903
|
+
* back to the user's wallet — preserves the reward but skips
|
|
904
|
+
* the auto-deposit (the user keeps it as a wallet asset).
|
|
905
|
+
* 4. Merge all collected USDC handles via `tx.mergeCoins`, then deposit
|
|
906
|
+
* via `addSaveToTx`.
|
|
907
|
+
*
|
|
908
|
+
* **Atomicity.** Single PTB = single transaction = single sponsored-gas
|
|
909
|
+
* envelope. Either ALL legs settle (claim + swap(s) + deposit) or none
|
|
910
|
+
* do. No partial-state recovery code needed.
|
|
911
|
+
*
|
|
912
|
+
* **Sponsored-gas posture.** This builder appends ONLY chained move
|
|
913
|
+
* calls — no `tx.gas` reads, no Pyth fee writes, no oracle Pyth updates.
|
|
914
|
+
* Cetus chain-mode swaps with `slippage` ≤ 5% don't require Pyth either
|
|
915
|
+
* (Cetus aggregator routes around Pyth-dependent providers when callers
|
|
916
|
+
* pass `providers: getProvidersExcluding(...)`). Audric's host wires
|
|
917
|
+
* the provider exclusion automatically for Enoki sponsorship — see
|
|
918
|
+
* `cetus-swap.ts` JSDoc.
|
|
919
|
+
*
|
|
920
|
+
* **Dust filter.** Rewards with `amount * priceCache.get(symbol) <
|
|
921
|
+
* minRewardUsd` are skipped from the swap leg AND from the deposit —
|
|
922
|
+
* not worth the gas to swap dust. They get transferred back to the
|
|
923
|
+
* wallet (preserving on-chain truth: the claim happened, the swap
|
|
924
|
+
* didn't). Default minRewardUsd = $0.01.
|
|
925
|
+
*
|
|
926
|
+
* **Failure modes.**
|
|
927
|
+
* - PROTOCOL_UNAVAILABLE — NAVI rewards lookup or claim PTB build failed.
|
|
928
|
+
* Engine surfaces "NAVI is degraded right now."
|
|
929
|
+
* - SWAP_NO_ROUTE — a reward asset has no Cetus route. Logged + that
|
|
930
|
+
* leg is skipped (rewards transferred to wallet). Other legs proceed.
|
|
931
|
+
* - INVALID_AMOUNT — rewards array empty after dust filter (nothing
|
|
932
|
+
* worth harvesting). Throws so the engine narrates "nothing to
|
|
933
|
+
* harvest right now" instead of building a no-op PTB.
|
|
934
|
+
*
|
|
935
|
+
* **Why a separate file (not inside `navi.ts`).** This composition
|
|
936
|
+
* crosses two protocols (NAVI + Cetus) — keeping it out of `navi.ts`
|
|
937
|
+
* preserves the single-protocol-per-file invariant the rest of the SDK
|
|
938
|
+
* follows. Mirrors how `cetus-swap.ts` already lives separately even
|
|
939
|
+
* though it composes through `composeTx.ts`.
|
|
940
|
+
*/
|
|
941
|
+
|
|
942
|
+
interface HarvestSwapLeg {
|
|
943
|
+
/** Reward symbol pre-swap (e.g. 'vSUI', 'NAVX'). */
|
|
944
|
+
fromSymbol: string;
|
|
945
|
+
/** Reward coinType pre-swap. */
|
|
946
|
+
fromCoinType: string;
|
|
947
|
+
/** Always 'USDC' — this builder only deposits to the USDC pool. */
|
|
948
|
+
toSymbol: 'USDC';
|
|
949
|
+
/** Display-units input amount (the entire claimed reward for that coin). */
|
|
950
|
+
inputAmount: number;
|
|
951
|
+
/** Display-units USDC the swap quote estimated. Actual on-chain may differ within slippage. */
|
|
952
|
+
expectedOutputUsdc: number;
|
|
953
|
+
}
|
|
954
|
+
interface HarvestSkippedLeg {
|
|
955
|
+
/** Reward symbol skipped (untradeable, dust, or no-route). */
|
|
956
|
+
symbol: string;
|
|
957
|
+
coinType: string;
|
|
958
|
+
/** Display-units claimed amount (still credited to user's wallet — just not auto-deposited). */
|
|
959
|
+
amount: number;
|
|
960
|
+
/** 'untradeable' | 'dust' | 'no-route' */
|
|
961
|
+
reason: 'untradeable' | 'dust' | 'no-route';
|
|
962
|
+
}
|
|
963
|
+
interface HarvestPlan {
|
|
964
|
+
/** Every reward that WILL be claimed by this PTB. */
|
|
965
|
+
claimed: PendingReward$1[];
|
|
966
|
+
/** Each non-USDC reward that WILL be swapped to USDC inline. */
|
|
967
|
+
swaps: HarvestSwapLeg[];
|
|
968
|
+
/** Rewards claimed but transferred back to wallet (no auto-deposit). */
|
|
969
|
+
skipped: HarvestSkippedLeg[];
|
|
970
|
+
/** Display-units USDC that will be deposited to the NAVI USDC pool. */
|
|
971
|
+
expectedUsdcDeposited: number;
|
|
972
|
+
}
|
|
973
|
+
interface BuildHarvestRewardsTxOptions {
|
|
974
|
+
/** Per-swap slippage tolerance (0.001–0.05). Defaults to 0.01 (1%). */
|
|
975
|
+
slippage?: number;
|
|
976
|
+
/**
|
|
977
|
+
* USD floor for "is this worth swapping?". Rewards below this threshold
|
|
978
|
+
* get transferred back to the wallet instead of swapped. Default $0.01.
|
|
979
|
+
* Pass 0 to disable the filter (always swap; useful for tests).
|
|
980
|
+
*/
|
|
981
|
+
minRewardUsd?: number;
|
|
982
|
+
/**
|
|
983
|
+
* Symbol → USD price map. Sourced from the engine's `ToolContext.priceCache`
|
|
984
|
+
* in production; tests can pass a literal Map. When undefined, the dust
|
|
985
|
+
* filter degrades to "skip nothing" (every reward is swapped) so we don't
|
|
986
|
+
* accidentally drop large rewards just because we couldn't price them.
|
|
987
|
+
*/
|
|
988
|
+
priceCache?: Map<string, number>;
|
|
989
|
+
/**
|
|
990
|
+
* Cetus provider allow-list. Sponsored callers (Enoki) pass
|
|
991
|
+
* `getProvidersExcluding(['pyth-dependent-list'])` to keep the PTB
|
|
992
|
+
* Pyth-free. Non-sponsored callers omit this.
|
|
993
|
+
*/
|
|
994
|
+
providers?: string[];
|
|
995
|
+
}
|
|
996
|
+
/**
|
|
997
|
+
* Standalone harvest builder — creates a fresh PTB, sets the sender,
|
|
998
|
+
* appends the full harvest flow, and returns both the tx and the plan.
|
|
999
|
+
* Used by CLI / direct SDK callers (smoke tests, scripts). The audric
|
|
1000
|
+
* host goes through `composeTx({ steps: [{ toolName: 'harvest_rewards' }] })`
|
|
1001
|
+
* which wires the appender + Enoki sponsorship.
|
|
1002
|
+
*/
|
|
1003
|
+
declare function buildHarvestRewardsTx(client: SuiJsonRpcClient, address: string, options?: BuildHarvestRewardsTxOptions): Promise<{
|
|
1004
|
+
tx: Transaction;
|
|
1005
|
+
plan: HarvestPlan;
|
|
1006
|
+
}>;
|
|
820
1007
|
|
|
821
1008
|
declare function getSwapQuote(params: {
|
|
822
1009
|
walletAddress: string;
|
|
@@ -1055,4 +1242,4 @@ declare function fullHandle(label: string): string;
|
|
|
1055
1242
|
*/
|
|
1056
1243
|
declare function displayHandle(label: string): string;
|
|
1057
1244
|
|
|
1058
|
-
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|
|
1245
|
+
export { AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type BuildAddLeafParams, type BuildHarvestRewardsTxOptions, type BuildRevokeLeafParams, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxFeeHookContext, type ComposeTxFeeHooks, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, type HarvestPlan, type HarvestSkippedLeg, type HarvestSwapLeg, HealthFactorResult, type LabelValidationResult, LendingAdapter, LendingRates, MaxBorrowResult, MaxWithdrawResult, OverlayFeeConfig, PayOptions, PayResult, PaymentRequest, PendingReward, PositionsResult, RatesResult, type RepayDebtInput, RepayResult, SafeguardConfig, SafeguardEnforcer, type SaveDepositInput, SaveResult, type SelectAndSplitResult, SendResult, type SendTransferInput, StakeVSuiResult, type StepPreview, SupportedAsset, type SwapExecuteInput, SwapQuoteResult, SwapResult, SwapRouteResult, T2000, T2000Error, T2000Options, TransactionRecord, TransactionSigner, TxMetadata, UnstakeVSuiResult, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, type VoloStakeInput, type VoloStats, type VoloUnstakeInput, WRITE_APPENDER_REGISTRY, type WithdrawInput, WithdrawResult, type WriteStep, type WriteToolName, ZkLoginProof, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, fetchAllCoins, fullHandle, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, validateLabel, walletExists };
|