@t2000/sdk 1.6.0 → 1.8.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/index.cjs +8 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +52 -1
- package/dist/index.d.ts +52 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -536,6 +536,56 @@ interface ComposeTxOptions {
|
|
|
536
536
|
* `addSwapToTx`'s `input.overlayFee`.
|
|
537
537
|
*/
|
|
538
538
|
overlayFee?: OverlayFeeConfig;
|
|
539
|
+
/**
|
|
540
|
+
* Optional fee-injection hooks for save_deposit + borrow. Fires inside
|
|
541
|
+
* the appender at the exact moment the user's coin is in hand and BEFORE
|
|
542
|
+
* the protocol step consumes (save) or the canonical transferObjects
|
|
543
|
+
* finalizes (borrow). Audric host uses this to inline `addFeeTransfer`
|
|
544
|
+
* for USDC SAVE_FEE_BPS / BORROW_FEE_BPS without ever leaving the
|
|
545
|
+
* canonical write contract — keeps the SDK fee-free per CLAUDE.md
|
|
546
|
+
* rule #9 while letting hosts charge their own overlay fees.
|
|
547
|
+
*
|
|
548
|
+
* Hooks are fire-and-forget (no return value). They mutate `tx` directly
|
|
549
|
+
* (e.g., `addFeeTransfer(tx, coin, ...)` splits the fee chunk off and
|
|
550
|
+
* appends a top-level `transferObjects` to the host's fee wallet — that
|
|
551
|
+
* recipient automatically appears in `derivedAllowedAddresses`).
|
|
552
|
+
*/
|
|
553
|
+
feeHooks?: ComposeTxFeeHooks;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Per-tool fee-injection callbacks. Each hook fires at a tool-specific
|
|
557
|
+
* moment in the appender flow (see field JSDoc). Currently scoped to
|
|
558
|
+
* the 2 fee-eligible tools — extend if/when new ones land.
|
|
559
|
+
*/
|
|
560
|
+
interface ComposeTxFeeHooks {
|
|
561
|
+
/**
|
|
562
|
+
* Fires inside the `save_deposit` appender AFTER the user's USDC/USDsui
|
|
563
|
+
* coin is split into the deposit amount, BEFORE NAVI's `deposit` move
|
|
564
|
+
* call consumes the coin. Order matters: the `coin` reference passed in
|
|
565
|
+
* is the SAME `TransactionObjectArgument` that flows into the deposit,
|
|
566
|
+
* so any `splitCoins(coin, [feeAmount])` inside the hook reduces the
|
|
567
|
+
* deposit by exactly that fee.
|
|
568
|
+
*/
|
|
569
|
+
save_deposit?: (ctx: ComposeTxFeeHookContext<SaveDepositInput>) => void | Promise<void>;
|
|
570
|
+
/**
|
|
571
|
+
* Fires inside the `borrow` appender AFTER NAVI returns the borrowed
|
|
572
|
+
* coin, BEFORE the canonical `transferObjects(coin, sender)` finalizes.
|
|
573
|
+
* The `coin` reference is the borrowed-and-not-yet-transferred output;
|
|
574
|
+
* splitting a fee here means the user receives the remainder.
|
|
575
|
+
*/
|
|
576
|
+
borrow?: (ctx: ComposeTxFeeHookContext<BorrowInput>) => void | Promise<void>;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Context object passed to every fee hook. Carries the `tx` (mutate it),
|
|
580
|
+
* the in-flight `coin` (split fees off it), the resolved tool input
|
|
581
|
+
* (asset/amount for fee-policy decisions), and the sender (rarely needed
|
|
582
|
+
* but kept for symmetry with `AppenderContext`).
|
|
583
|
+
*/
|
|
584
|
+
interface ComposeTxFeeHookContext<TInput> {
|
|
585
|
+
tx: Transaction;
|
|
586
|
+
coin: TransactionObjectArgument;
|
|
587
|
+
input: TInput;
|
|
588
|
+
sender: string;
|
|
539
589
|
}
|
|
540
590
|
/** Per-step preview returned by each registry appender. Tool-specific shape. */
|
|
541
591
|
type StepPreview = {
|
|
@@ -601,6 +651,7 @@ interface AppenderContext {
|
|
|
601
651
|
sender: string;
|
|
602
652
|
sponsoredContext: boolean;
|
|
603
653
|
overlayFee?: OverlayFeeConfig;
|
|
654
|
+
feeHooks?: ComposeTxFeeHooks;
|
|
604
655
|
}
|
|
605
656
|
type AppenderFn<TInput, TPreview extends StepPreview> = (tx: Transaction, input: TInput, ctx: AppenderContext) => Promise<TPreview>;
|
|
606
657
|
/**
|
|
@@ -803,4 +854,4 @@ declare function addUnstakeVSuiToTx(tx: Transaction, client: SuiJsonRpcClient, a
|
|
|
803
854
|
effectiveAmountMist: bigint | 'all';
|
|
804
855
|
}>;
|
|
805
856
|
|
|
806
|
-
export { type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, 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, buildClaimRewardsTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, walletExists };
|
|
857
|
+
export { type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, 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, 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, buildClaimRewardsTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, walletExists };
|
package/dist/index.d.ts
CHANGED
|
@@ -536,6 +536,56 @@ interface ComposeTxOptions {
|
|
|
536
536
|
* `addSwapToTx`'s `input.overlayFee`.
|
|
537
537
|
*/
|
|
538
538
|
overlayFee?: OverlayFeeConfig;
|
|
539
|
+
/**
|
|
540
|
+
* Optional fee-injection hooks for save_deposit + borrow. Fires inside
|
|
541
|
+
* the appender at the exact moment the user's coin is in hand and BEFORE
|
|
542
|
+
* the protocol step consumes (save) or the canonical transferObjects
|
|
543
|
+
* finalizes (borrow). Audric host uses this to inline `addFeeTransfer`
|
|
544
|
+
* for USDC SAVE_FEE_BPS / BORROW_FEE_BPS without ever leaving the
|
|
545
|
+
* canonical write contract — keeps the SDK fee-free per CLAUDE.md
|
|
546
|
+
* rule #9 while letting hosts charge their own overlay fees.
|
|
547
|
+
*
|
|
548
|
+
* Hooks are fire-and-forget (no return value). They mutate `tx` directly
|
|
549
|
+
* (e.g., `addFeeTransfer(tx, coin, ...)` splits the fee chunk off and
|
|
550
|
+
* appends a top-level `transferObjects` to the host's fee wallet — that
|
|
551
|
+
* recipient automatically appears in `derivedAllowedAddresses`).
|
|
552
|
+
*/
|
|
553
|
+
feeHooks?: ComposeTxFeeHooks;
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Per-tool fee-injection callbacks. Each hook fires at a tool-specific
|
|
557
|
+
* moment in the appender flow (see field JSDoc). Currently scoped to
|
|
558
|
+
* the 2 fee-eligible tools — extend if/when new ones land.
|
|
559
|
+
*/
|
|
560
|
+
interface ComposeTxFeeHooks {
|
|
561
|
+
/**
|
|
562
|
+
* Fires inside the `save_deposit` appender AFTER the user's USDC/USDsui
|
|
563
|
+
* coin is split into the deposit amount, BEFORE NAVI's `deposit` move
|
|
564
|
+
* call consumes the coin. Order matters: the `coin` reference passed in
|
|
565
|
+
* is the SAME `TransactionObjectArgument` that flows into the deposit,
|
|
566
|
+
* so any `splitCoins(coin, [feeAmount])` inside the hook reduces the
|
|
567
|
+
* deposit by exactly that fee.
|
|
568
|
+
*/
|
|
569
|
+
save_deposit?: (ctx: ComposeTxFeeHookContext<SaveDepositInput>) => void | Promise<void>;
|
|
570
|
+
/**
|
|
571
|
+
* Fires inside the `borrow` appender AFTER NAVI returns the borrowed
|
|
572
|
+
* coin, BEFORE the canonical `transferObjects(coin, sender)` finalizes.
|
|
573
|
+
* The `coin` reference is the borrowed-and-not-yet-transferred output;
|
|
574
|
+
* splitting a fee here means the user receives the remainder.
|
|
575
|
+
*/
|
|
576
|
+
borrow?: (ctx: ComposeTxFeeHookContext<BorrowInput>) => void | Promise<void>;
|
|
577
|
+
}
|
|
578
|
+
/**
|
|
579
|
+
* Context object passed to every fee hook. Carries the `tx` (mutate it),
|
|
580
|
+
* the in-flight `coin` (split fees off it), the resolved tool input
|
|
581
|
+
* (asset/amount for fee-policy decisions), and the sender (rarely needed
|
|
582
|
+
* but kept for symmetry with `AppenderContext`).
|
|
583
|
+
*/
|
|
584
|
+
interface ComposeTxFeeHookContext<TInput> {
|
|
585
|
+
tx: Transaction;
|
|
586
|
+
coin: TransactionObjectArgument;
|
|
587
|
+
input: TInput;
|
|
588
|
+
sender: string;
|
|
539
589
|
}
|
|
540
590
|
/** Per-step preview returned by each registry appender. Tool-specific shape. */
|
|
541
591
|
type StepPreview = {
|
|
@@ -601,6 +651,7 @@ interface AppenderContext {
|
|
|
601
651
|
sender: string;
|
|
602
652
|
sponsoredContext: boolean;
|
|
603
653
|
overlayFee?: OverlayFeeConfig;
|
|
654
|
+
feeHooks?: ComposeTxFeeHooks;
|
|
604
655
|
}
|
|
605
656
|
type AppenderFn<TInput, TPreview extends StepPreview> = (tx: Transaction, input: TInput, ctx: AppenderContext) => Promise<TPreview>;
|
|
606
657
|
/**
|
|
@@ -803,4 +854,4 @@ declare function addUnstakeVSuiToTx(tx: Transaction, client: SuiJsonRpcClient, a
|
|
|
803
854
|
effectiveAmountMist: bigint | 'all';
|
|
804
855
|
}>;
|
|
805
856
|
|
|
806
|
-
export { type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, type ClaimRewardsInput, ClaimRewardsResult, type CoinPage, type ComposeTxOptions, type ComposeTxResult, CompoundRewardsResult, ContactManager, DepositInfo, EarningsResult, FinancialSummary, type FinancialSummaryOptions, FundStatusResult, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, HealthFactorResult, 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, buildClaimRewardsTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, walletExists };
|
|
857
|
+
export { type AppenderContext, BalanceResponse, type BorrowInput, BorrowResult, 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, 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, buildClaimRewardsTx, buildSendTx, buildStakeVSuiTx, buildUnstakeVSuiTx, composeTx, deriveAllowedAddressesFromPtb, exportPrivateKey, fetchAllCoins, generateKeypair, getAddress, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getVoloStats, keypairFromPrivateKey, loadKey, saveKey, selectAndSplitCoin, selectSuiCoin, walletExists };
|
package/dist/index.js
CHANGED
|
@@ -7466,6 +7466,9 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
7466
7466
|
assetInfo.type,
|
|
7467
7467
|
rawAmount
|
|
7468
7468
|
);
|
|
7469
|
+
if (ctx.feeHooks?.save_deposit) {
|
|
7470
|
+
await ctx.feeHooks.save_deposit({ tx, coin, input, sender: ctx.sender });
|
|
7471
|
+
}
|
|
7469
7472
|
await addSaveToTx(tx, ctx.client, ctx.sender, coin, { asset });
|
|
7470
7473
|
return {
|
|
7471
7474
|
toolName: "save_deposit",
|
|
@@ -7500,6 +7503,9 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
7500
7503
|
input.amount,
|
|
7501
7504
|
{ asset, skipPythUpdate: ctx.sponsoredContext }
|
|
7502
7505
|
);
|
|
7506
|
+
if (ctx.feeHooks?.borrow) {
|
|
7507
|
+
await ctx.feeHooks.borrow({ tx, coin, input, sender: ctx.sender });
|
|
7508
|
+
}
|
|
7503
7509
|
tx.transferObjects([coin], ctx.sender);
|
|
7504
7510
|
return { toolName: "borrow", effectiveAmount: input.amount, asset };
|
|
7505
7511
|
},
|
|
@@ -7647,7 +7653,8 @@ async function composeTx(opts) {
|
|
|
7647
7653
|
client: opts.client,
|
|
7648
7654
|
sender: opts.sender,
|
|
7649
7655
|
sponsoredContext: opts.sponsoredContext ?? false,
|
|
7650
|
-
overlayFee: opts.overlayFee
|
|
7656
|
+
overlayFee: opts.overlayFee,
|
|
7657
|
+
feeHooks: opts.feeHooks
|
|
7651
7658
|
};
|
|
7652
7659
|
const previews = [];
|
|
7653
7660
|
for (const step of opts.steps) {
|