@t2000/sdk 1.24.1 → 1.24.2
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 +13 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +13 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -992,6 +992,22 @@ interface HarvestPlan {
|
|
|
992
992
|
/** Display-units USDC that will be deposited to the NAVI USDC pool. */
|
|
993
993
|
expectedUsdcDeposited: number;
|
|
994
994
|
}
|
|
995
|
+
/**
|
|
996
|
+
* Callback invoked right before the harvest's internal `addSaveToTx`.
|
|
997
|
+
* Mirrors the shape of `composeTx`'s `feeHooks.save_deposit` so audric's
|
|
998
|
+
* existing hook can be threaded straight through without adapters. The
|
|
999
|
+
* SDK never invents a fee — the host decides whether to skim from
|
|
1000
|
+
* `coin` and to where. See CLAUDE.md rule #9 (fees are a host concern).
|
|
1001
|
+
*/
|
|
1002
|
+
type HarvestSaveFeeHook = (ctx: {
|
|
1003
|
+
tx: Transaction;
|
|
1004
|
+
coin: TransactionObjectArgument;
|
|
1005
|
+
input: {
|
|
1006
|
+
asset: 'USDC';
|
|
1007
|
+
amount: number;
|
|
1008
|
+
};
|
|
1009
|
+
sender: string;
|
|
1010
|
+
}) => void | Promise<void>;
|
|
995
1011
|
interface BuildHarvestRewardsTxOptions {
|
|
996
1012
|
/** Per-swap slippage tolerance (0.001–0.05). Defaults to 0.01 (1%). */
|
|
997
1013
|
slippage?: number;
|
|
@@ -1014,6 +1030,27 @@ interface BuildHarvestRewardsTxOptions {
|
|
|
1014
1030
|
* Pyth-free. Non-sponsored callers omit this.
|
|
1015
1031
|
*/
|
|
1016
1032
|
providers?: string[];
|
|
1033
|
+
/**
|
|
1034
|
+
* [v1.24.2 fee wiring] Overlay fee forwarded to EACH internal
|
|
1035
|
+
* `addSwapToTx` call. When set, every swap leg charges the rate to
|
|
1036
|
+
* the receiver (typically `T2000_OVERLAY_FEE_WALLET` for audric).
|
|
1037
|
+
* Omit for fee-free harvests (CLI / direct SDK callers).
|
|
1038
|
+
*/
|
|
1039
|
+
overlayFee?: OverlayFeeConfig;
|
|
1040
|
+
/**
|
|
1041
|
+
* [v1.24.2 fee wiring] Fired immediately before the internal
|
|
1042
|
+
* `addSaveToTx` consumes the merged USDC deposit coin. The hook
|
|
1043
|
+
* receives the deposit handle so it can split a fee off via
|
|
1044
|
+
* `addFeeTransfer(...)` (host's call). Audric threads its
|
|
1045
|
+
* `feeHooks.save_deposit` straight through here so a harvest's
|
|
1046
|
+
* deposit leg pays the same `SAVE_FEE_BPS` as a single-op `save`.
|
|
1047
|
+
*
|
|
1048
|
+
* Order is load-bearing: this hook fires AFTER all USDC handles
|
|
1049
|
+
* are merged into one and BEFORE the NAVI deposit consumes it.
|
|
1050
|
+
* Fee receiver gets recorded as a top-level transferObjects, so
|
|
1051
|
+
* it's automatically picked up by `derivedAllowedAddresses`.
|
|
1052
|
+
*/
|
|
1053
|
+
saveFeeHook?: HarvestSaveFeeHook;
|
|
1017
1054
|
}
|
|
1018
1055
|
/**
|
|
1019
1056
|
* Standalone harvest builder — creates a fresh PTB, sets the sender,
|
package/dist/index.d.ts
CHANGED
|
@@ -992,6 +992,22 @@ interface HarvestPlan {
|
|
|
992
992
|
/** Display-units USDC that will be deposited to the NAVI USDC pool. */
|
|
993
993
|
expectedUsdcDeposited: number;
|
|
994
994
|
}
|
|
995
|
+
/**
|
|
996
|
+
* Callback invoked right before the harvest's internal `addSaveToTx`.
|
|
997
|
+
* Mirrors the shape of `composeTx`'s `feeHooks.save_deposit` so audric's
|
|
998
|
+
* existing hook can be threaded straight through without adapters. The
|
|
999
|
+
* SDK never invents a fee — the host decides whether to skim from
|
|
1000
|
+
* `coin` and to where. See CLAUDE.md rule #9 (fees are a host concern).
|
|
1001
|
+
*/
|
|
1002
|
+
type HarvestSaveFeeHook = (ctx: {
|
|
1003
|
+
tx: Transaction;
|
|
1004
|
+
coin: TransactionObjectArgument;
|
|
1005
|
+
input: {
|
|
1006
|
+
asset: 'USDC';
|
|
1007
|
+
amount: number;
|
|
1008
|
+
};
|
|
1009
|
+
sender: string;
|
|
1010
|
+
}) => void | Promise<void>;
|
|
995
1011
|
interface BuildHarvestRewardsTxOptions {
|
|
996
1012
|
/** Per-swap slippage tolerance (0.001–0.05). Defaults to 0.01 (1%). */
|
|
997
1013
|
slippage?: number;
|
|
@@ -1014,6 +1030,27 @@ interface BuildHarvestRewardsTxOptions {
|
|
|
1014
1030
|
* Pyth-free. Non-sponsored callers omit this.
|
|
1015
1031
|
*/
|
|
1016
1032
|
providers?: string[];
|
|
1033
|
+
/**
|
|
1034
|
+
* [v1.24.2 fee wiring] Overlay fee forwarded to EACH internal
|
|
1035
|
+
* `addSwapToTx` call. When set, every swap leg charges the rate to
|
|
1036
|
+
* the receiver (typically `T2000_OVERLAY_FEE_WALLET` for audric).
|
|
1037
|
+
* Omit for fee-free harvests (CLI / direct SDK callers).
|
|
1038
|
+
*/
|
|
1039
|
+
overlayFee?: OverlayFeeConfig;
|
|
1040
|
+
/**
|
|
1041
|
+
* [v1.24.2 fee wiring] Fired immediately before the internal
|
|
1042
|
+
* `addSaveToTx` consumes the merged USDC deposit coin. The hook
|
|
1043
|
+
* receives the deposit handle so it can split a fee off via
|
|
1044
|
+
* `addFeeTransfer(...)` (host's call). Audric threads its
|
|
1045
|
+
* `feeHooks.save_deposit` straight through here so a harvest's
|
|
1046
|
+
* deposit leg pays the same `SAVE_FEE_BPS` as a single-op `save`.
|
|
1047
|
+
*
|
|
1048
|
+
* Order is load-bearing: this hook fires AFTER all USDC handles
|
|
1049
|
+
* are merged into one and BEFORE the NAVI deposit consumes it.
|
|
1050
|
+
* Fee receiver gets recorded as a top-level transferObjects, so
|
|
1051
|
+
* it's automatically picked up by `derivedAllowedAddresses`.
|
|
1052
|
+
*/
|
|
1053
|
+
saveFeeHook?: HarvestSaveFeeHook;
|
|
1017
1054
|
}
|
|
1018
1055
|
/**
|
|
1019
1056
|
* Standalone harvest builder — creates a fresh PTB, sets the sender,
|
package/dist/index.js
CHANGED
|
@@ -7566,7 +7566,8 @@ async function addHarvestToTx(tx, client, address, options = {}) {
|
|
|
7566
7566
|
amount: aggRow.amount,
|
|
7567
7567
|
slippage,
|
|
7568
7568
|
inputCoin: coin,
|
|
7569
|
-
providers: options.providers
|
|
7569
|
+
providers: options.providers,
|
|
7570
|
+
overlayFee: options.overlayFee
|
|
7570
7571
|
});
|
|
7571
7572
|
usdcHandles.push(swapResult.coin);
|
|
7572
7573
|
expectedUsdcDeposited += swapResult.expectedAmountOut;
|
|
@@ -7600,6 +7601,14 @@ async function addHarvestToTx(tx, client, address, options = {}) {
|
|
|
7600
7601
|
tx.mergeCoins(primary, rest);
|
|
7601
7602
|
depositCoin = primary;
|
|
7602
7603
|
}
|
|
7604
|
+
if (options.saveFeeHook) {
|
|
7605
|
+
await options.saveFeeHook({
|
|
7606
|
+
tx,
|
|
7607
|
+
coin: depositCoin,
|
|
7608
|
+
input: { asset: "USDC", amount: expectedUsdcDeposited },
|
|
7609
|
+
sender: address
|
|
7610
|
+
});
|
|
7611
|
+
}
|
|
7603
7612
|
try {
|
|
7604
7613
|
await addSaveToTx(tx, client, address, depositCoin, { asset: "USDC" });
|
|
7605
7614
|
} catch (err) {
|
|
@@ -7837,7 +7846,9 @@ var WRITE_APPENDER_REGISTRY = {
|
|
|
7837
7846
|
const plan = await addHarvestToTx(tx, ctx.client, ctx.sender, {
|
|
7838
7847
|
slippage: input.slippage,
|
|
7839
7848
|
minRewardUsd: input.minRewardUsd,
|
|
7840
|
-
providers
|
|
7849
|
+
providers,
|
|
7850
|
+
overlayFee: ctx.overlayFee,
|
|
7851
|
+
saveFeeHook: ctx.feeHooks?.save_deposit
|
|
7841
7852
|
});
|
|
7842
7853
|
return {
|
|
7843
7854
|
preview: {
|