@t2000/sdk 1.24.1 → 1.24.3

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.d.cts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { V as TxMetadata, q as SafeguardConfig, T as T2000Error, R as TransactionSigner, a1 as ZkLoginProof, x as SupportedAsset, l as OverlayFeeConfig, y as SwapRouteResult } from './types-D03bON1v.cjs';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, k as OVERLAY_FEE_RATE, aD as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, m as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SuiRpcTxBlock, z as T2000ErrorCode, H as T2000ErrorData, J as T2000_OVERLAY_FEE_WALLET, Q as TOKEN_MAP, U as TxDirection, W as USDC_DECIMALS, X as USDC_TYPE, Y as USDE_TYPE, Z as USDSUI_TYPE, _ as USDT_TYPE, $ as WAL_TYPE, a0 as WBTC_TYPE, a2 as ZkLoginSigner, a3 as addFeeTransfer, aE as addSwapToTx, aF as assertAllowedAsset, a4 as buildSwapTx, a5 as calculateFee, a6 as classifyAction, a7 as classifyLabel, a8 as classifyTransaction, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as findSwapRoute, ae as formatAssetAmount, af as formatSui, ag as formatUsd, aG as getCoinMeta, ah as getDecimals, ai as getDecimalsForCoinType, aj as getTier, aH as isAllowedAsset, aI as isInRegistry, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aJ as normalizeAsset, aK as normalizeCoinType, aq as parseSuiRpcTx, aL as queryHistory, aM as queryTransaction, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aN as simulateTransaction, aw as stableToRaw, ax as suiToMist, aO as throwIfSimulationFailed, ay as truncateAddress, az as usdcToRaw, aA as validateAddress } from './types-D03bON1v.cjs';
4
+ import { V as TxMetadata, q as SafeguardConfig, T as T2000Error, R as TransactionSigner, a1 as ZkLoginProof, x as SupportedAsset, l as OverlayFeeConfig, y as SwapRouteResult } from './types-DvNhsBbN.cjs';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, k as OVERLAY_FEE_RATE, aD as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, m as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SuiRpcTxBlock, z as T2000ErrorCode, H as T2000ErrorData, J as T2000_OVERLAY_FEE_WALLET, Q as TOKEN_MAP, U as TxDirection, W as USDC_DECIMALS, X as USDC_TYPE, Y as USDE_TYPE, Z as USDSUI_TYPE, _ as USDT_TYPE, $ as WAL_TYPE, a0 as WBTC_TYPE, a2 as ZkLoginSigner, a3 as addFeeTransfer, aE as addSwapToTx, aF as assertAllowedAsset, a4 as buildSwapTx, a5 as calculateFee, a6 as classifyAction, a7 as classifyLabel, a8 as classifyTransaction, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as findSwapRoute, ae as formatAssetAmount, af as formatSui, ag as formatUsd, aG as getCoinMeta, ah as getDecimals, ai as getDecimalsForCoinType, aj as getTier, aH as isAllowedAsset, aI as isInRegistry, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aJ as normalizeAsset, aK as normalizeCoinType, aq as parseSuiRpcTx, aL as queryHistory, aM as queryTransaction, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aN as simulateTransaction, aw as stableToRaw, ax as suiToMist, aO as throwIfSimulationFailed, ay as truncateAddress, az as usdcToRaw, aA as validateAddress } from './types-DvNhsBbN.cjs';
6
6
  import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-BnbL3xN8.cjs';
7
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-BnbL3xN8.cjs';
8
8
  import { i as T2000Options, P as PayOptions, c as PayResult, j as StakeVSuiResult, U as UnstakeVSuiResult, k as SwapResult, l as SwapQuoteResult, h as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, m as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, g as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, d as PendingReward, C as ClaimRewardsResult, n as CompoundRewardsResult, f as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, o as FinancialSummary } from './types-jAD-e7Pq.cjs';
@@ -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
@@ -1,8 +1,8 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
2
  import { SuiJsonRpcClient } from '@mysten/sui/jsonRpc';
3
3
  import { Ed25519Keypair } from '@mysten/sui/keypairs/ed25519';
4
- import { V as TxMetadata, q as SafeguardConfig, T as T2000Error, R as TransactionSigner, a1 as ZkLoginProof, x as SupportedAsset, l as OverlayFeeConfig, y as SwapRouteResult } from './types-DCb8Xt_q.js';
5
- export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, k as OVERLAY_FEE_RATE, aD as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, m as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SuiRpcTxBlock, z as T2000ErrorCode, H as T2000ErrorData, J as T2000_OVERLAY_FEE_WALLET, Q as TOKEN_MAP, U as TxDirection, W as USDC_DECIMALS, X as USDC_TYPE, Y as USDE_TYPE, Z as USDSUI_TYPE, _ as USDT_TYPE, $ as WAL_TYPE, a0 as WBTC_TYPE, a2 as ZkLoginSigner, a3 as addFeeTransfer, aE as addSwapToTx, aF as assertAllowedAsset, a4 as buildSwapTx, a5 as calculateFee, a6 as classifyAction, a7 as classifyLabel, a8 as classifyTransaction, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as findSwapRoute, ae as formatAssetAmount, af as formatSui, ag as formatUsd, aG as getCoinMeta, ah as getDecimals, ai as getDecimalsForCoinType, aj as getTier, aH as isAllowedAsset, aI as isInRegistry, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aJ as normalizeAsset, aK as normalizeCoinType, aq as parseSuiRpcTx, aL as queryHistory, aM as queryTransaction, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aN as simulateTransaction, aw as stableToRaw, ax as suiToMist, aO as throwIfSimulationFailed, ay as truncateAddress, az as usdcToRaw, aA as validateAddress } from './types-DCb8Xt_q.js';
4
+ import { V as TxMetadata, q as SafeguardConfig, T as T2000Error, R as TransactionSigner, a1 as ZkLoginProof, x as SupportedAsset, l as OverlayFeeConfig, y as SwapRouteResult } from './types-D1-rO-J4.js';
5
+ export { A as ALL_NAVI_ASSETS, B as BORROW_FEE_BPS, a as BPS_DENOMINATOR, aB as CETUS_USDC_SUI_POOL, C as CLOCK_ID, b as COIN_REGISTRY, c as ClassifyBalanceChange, d as ClassifyResult, e as CoinMeta, D as DEFAULT_NETWORK, f as DEFAULT_SAFEGUARD_CONFIG, E as ETH_TYPE, g as ExtractedTransfer, F as FeeOperation, 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, aC as OPERATION_ASSETS, O as OUTBOUND_OPS, k as OVERLAY_FEE_RATE, aD as Operation, P as ProtocolFeeInfo, S as SAVE_FEE_BPS, m as STABLE_ASSETS, n as SUI_DECIMALS, o as SUI_TYPE, p as SUPPORTED_ASSETS, r as SafeguardError, s as SafeguardErrorDetails, t as SafeguardRule, u as SimulationResult, v as StableAsset, w as SuiRpcTxBlock, z as T2000ErrorCode, H as T2000ErrorData, J as T2000_OVERLAY_FEE_WALLET, Q as TOKEN_MAP, U as TxDirection, W as USDC_DECIMALS, X as USDC_TYPE, Y as USDE_TYPE, Z as USDSUI_TYPE, _ as USDT_TYPE, $ as WAL_TYPE, a0 as WBTC_TYPE, a2 as ZkLoginSigner, a3 as addFeeTransfer, aE as addSwapToTx, aF as assertAllowedAsset, a4 as buildSwapTx, a5 as calculateFee, a6 as classifyAction, a7 as classifyLabel, a8 as classifyTransaction, a9 as extractTransferDetails, aa as extractTxCommands, ab as extractTxSender, ac as fallbackLabel, ad as findSwapRoute, ae as formatAssetAmount, af as formatSui, ag as formatUsd, aG as getCoinMeta, ah as getDecimals, ai as getDecimalsForCoinType, aj as getTier, aH as isAllowedAsset, aI as isInRegistry, ak as isSupported, al as isTier1, am as isTier2, an as mapMoveAbortCode, ao as mapWalletError, ap as mistToSui, aJ as normalizeAsset, aK as normalizeCoinType, aq as parseSuiRpcTx, aL as queryHistory, aM as queryTransaction, ar as rawToStable, as as rawToUsdc, at as refineLendingLabel, au as resolveSymbol, av as resolveTokenType, aN as simulateTransaction, aw as stableToRaw, ax as suiToMist, aO as throwIfSimulationFailed, ay as truncateAddress, az as usdcToRaw, aA as validateAddress } from './types-D1-rO-J4.js';
6
6
  import { L as LendingAdapter, a as LendingRates, P as PendingReward$1 } from './descriptors-BnbL3xN8.js';
7
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-BnbL3xN8.js';
8
8
  import { i as T2000Options, P as PayOptions, c as PayResult, j as StakeVSuiResult, U as UnstakeVSuiResult, k as SwapResult, l as SwapQuoteResult, h as SendResult, B as BalanceResponse, T as TransactionRecord, D as DepositInfo, m as PaymentRequest, S as SaveResult, W as WithdrawResult, b as MaxWithdrawResult, a as BorrowResult, g as RepayResult, M as MaxBorrowResult, H as HealthFactorResult, d as PendingReward, C as ClaimRewardsResult, n as CompoundRewardsResult, f as PositionsResult, R as RatesResult, E as EarningsResult, F as FundStatusResult, o as FinancialSummary } from './types-jAD-e7Pq.js';
@@ -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
@@ -5886,14 +5886,35 @@ var naviDescriptor = {
5886
5886
  packages: [],
5887
5887
  dynamicPackageId: true,
5888
5888
  actionMap: {
5889
+ // Deposit variants (entry_deposit / deposit + account-cap form for
5890
+ // harvest's internal save leg)
5889
5891
  "incentive_v3::entry_deposit": "save",
5890
5892
  "incentive_v3::deposit": "save",
5893
+ "incentive_v3::deposit_with_account_cap": "save",
5894
+ // Withdraw variants
5891
5895
  "incentive_v3::withdraw_v2": "withdraw",
5892
5896
  "incentive_v3::entry_withdraw": "withdraw",
5897
+ "incentive_v3::withdraw_with_account_cap": "withdraw",
5898
+ "incentive_v3::withdraw_with_account_cap_v": "withdraw",
5899
+ "incentive_v3::withdraw": "withdraw",
5900
+ "incentive_v3::withdraw_v": "withdraw",
5901
+ // Borrow variants
5893
5902
  "incentive_v3::borrow_v2": "borrow",
5894
5903
  "incentive_v3::entry_borrow": "borrow",
5904
+ "incentive_v3::borrow": "borrow",
5905
+ "incentive_v3::borrow_v": "borrow",
5906
+ "incentive_v3::borrow_with_account_cap": "borrow",
5907
+ "incentive_v3::borrow_with_account_cap_v": "borrow",
5908
+ // Repay variants
5895
5909
  "incentive_v3::entry_repay": "repay",
5896
- "incentive_v3::repay": "repay"
5910
+ "incentive_v3::repay": "repay",
5911
+ "incentive_v3::repay_with_account_cap": "repay",
5912
+ // Claim-reward variants — required for `claim_rewards` tagging AND for
5913
+ // `harvest` compound-op detection in the indexer (paired with a save
5914
+ // target, classified as `harvest` instead of `claim`).
5915
+ "incentive_v3::claim_reward": "claim",
5916
+ "incentive_v3::claim_reward_entry": "claim",
5917
+ "incentive_v3::claim_reward_with_account_cap": "claim"
5897
5918
  }
5898
5919
  };
5899
5920
  var allDescriptors = [
@@ -7566,7 +7587,8 @@ async function addHarvestToTx(tx, client, address, options = {}) {
7566
7587
  amount: aggRow.amount,
7567
7588
  slippage,
7568
7589
  inputCoin: coin,
7569
- providers: options.providers
7590
+ providers: options.providers,
7591
+ overlayFee: options.overlayFee
7570
7592
  });
7571
7593
  usdcHandles.push(swapResult.coin);
7572
7594
  expectedUsdcDeposited += swapResult.expectedAmountOut;
@@ -7600,6 +7622,14 @@ async function addHarvestToTx(tx, client, address, options = {}) {
7600
7622
  tx.mergeCoins(primary, rest);
7601
7623
  depositCoin = primary;
7602
7624
  }
7625
+ if (options.saveFeeHook) {
7626
+ await options.saveFeeHook({
7627
+ tx,
7628
+ coin: depositCoin,
7629
+ input: { asset: "USDC", amount: expectedUsdcDeposited },
7630
+ sender: address
7631
+ });
7632
+ }
7603
7633
  try {
7604
7634
  await addSaveToTx(tx, client, address, depositCoin, { asset: "USDC" });
7605
7635
  } catch (err) {
@@ -7837,7 +7867,9 @@ var WRITE_APPENDER_REGISTRY = {
7837
7867
  const plan = await addHarvestToTx(tx, ctx.client, ctx.sender, {
7838
7868
  slippage: input.slippage,
7839
7869
  minRewardUsd: input.minRewardUsd,
7840
- providers
7870
+ providers,
7871
+ overlayFee: ctx.overlayFee,
7872
+ saveFeeHook: ctx.feeHooks?.save_deposit
7841
7873
  });
7842
7874
  return {
7843
7875
  preview: {
@@ -8003,7 +8035,7 @@ var FEE_RATES = {
8003
8035
  function calculateFee(operation, amount) {
8004
8036
  const bps = FEE_RATES[operation];
8005
8037
  const feeAmount = amount * Number(bps) / Number(BPS_DENOMINATOR);
8006
- const rawAmount = usdcToRaw(feeAmount);
8038
+ const rawAmount = stableToRaw(feeAmount, USDC_DECIMALS);
8007
8039
  return {
8008
8040
  amount: feeAmount,
8009
8041
  asset: "USDC",
@@ -8011,11 +8043,11 @@ function calculateFee(operation, amount) {
8011
8043
  rawAmount
8012
8044
  };
8013
8045
  }
8014
- function addFeeTransfer(tx, paymentCoin, feeBps, receiver, amount) {
8046
+ function addFeeTransfer(tx, paymentCoin, feeBps, receiver, amount, decimals = USDC_DECIMALS) {
8015
8047
  if (feeBps <= 0n) return;
8016
8048
  if (amount <= 0) return;
8017
8049
  const feeAmount = amount * Number(feeBps) / Number(BPS_DENOMINATOR);
8018
- const rawFee = usdcToRaw(feeAmount);
8050
+ const rawFee = stableToRaw(feeAmount, decimals);
8019
8051
  if (rawFee <= 0n) return;
8020
8052
  const [feeCoin] = tx.splitCoins(paymentCoin, [tx.pure.u64(rawFee)]);
8021
8053
  tx.transferObjects([feeCoin], tx.pure.address(receiver));