@t2000/sdk 1.23.0 → 1.23.1

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
@@ -794,6 +794,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
794
794
 
795
795
  declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
796
796
  declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
797
+ declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
797
798
  /**
798
799
  * Standalone builder for the `claim_rewards` tool. Wraps the existing
799
800
  * `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
@@ -817,6 +818,26 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
817
818
  tx: Transaction;
818
819
  rewards: PendingReward$1[];
819
820
  }>;
821
+ /**
822
+ * Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
823
+ * structural rather than imported so the tests don't have to reproduce
824
+ * the full upstream type and the function works for any future caller
825
+ * that has the same fields.
826
+ */
827
+ interface ClaimableRewardLike {
828
+ userClaimableReward: number | string;
829
+ rewardCoinType: string;
830
+ assetId?: number | string;
831
+ }
832
+ /**
833
+ * Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
834
+ * the engine surfaces to the LLM and the UI. Aggregates by reward coin
835
+ * type so a user with rewards from multiple pools (e.g. USDC pool + SUI
836
+ * pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
837
+ * than three separate dust entries. Filters out non-finite / non-positive
838
+ * amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
839
+ */
840
+ declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
820
841
 
821
842
  declare function getSwapQuote(params: {
822
843
  walletAddress: string;
@@ -1055,4 +1076,4 @@ declare function fullHandle(label: string): string;
1055
1076
  */
1056
1077
  declare function displayHandle(label: string): string;
1057
1078
 
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 };
1079
+ 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, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, 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 };
package/dist/index.d.ts CHANGED
@@ -794,6 +794,7 @@ declare function getFinancialSummary(client: SuiJsonRpcClient, walletAddress: st
794
794
 
795
795
  declare function getRates(client: SuiJsonRpcClient): Promise<RatesResult>;
796
796
  declare function getPendingRewards(client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
797
+ declare function addClaimRewardsToTx(tx: Transaction, client: SuiJsonRpcClient, address: string): Promise<PendingReward$1[]>;
797
798
  /**
798
799
  * Standalone builder for the `claim_rewards` tool. Wraps the existing
799
800
  * `addClaimRewardsToTx` appender into a complete PTB so the SPEC 7
@@ -817,6 +818,26 @@ declare function buildClaimRewardsTx(client: SuiJsonRpcClient, address: string):
817
818
  tx: Transaction;
818
819
  rewards: PendingReward$1[];
819
820
  }>;
821
+ /**
822
+ * Minimal shape we read off the NAVI SDK's `LendingReward` rows. Kept
823
+ * structural rather than imported so the tests don't have to reproduce
824
+ * the full upstream type and the function works for any future caller
825
+ * that has the same fields.
826
+ */
827
+ interface ClaimableRewardLike {
828
+ userClaimableReward: number | string;
829
+ rewardCoinType: string;
830
+ assetId?: number | string;
831
+ }
832
+ /**
833
+ * Aggregate raw NAVI `claimable` rows into the `PendingReward[]` shape
834
+ * the engine surfaces to the LLM and the UI. Aggregates by reward coin
835
+ * type so a user with rewards from multiple pools (e.g. USDC pool + SUI
836
+ * pool both rewarding vSUI) sees a single "0.0165 vSUI" line rather
837
+ * than three separate dust entries. Filters out non-finite / non-positive
838
+ * amounts so dust noise can't sneak in as "$0.00 REWARD" rows.
839
+ */
840
+ declare function aggregateClaimableRewards(claimable: ClaimableRewardLike[]): PendingReward$1[];
820
841
 
821
842
  declare function getSwapQuote(params: {
822
843
  walletAddress: string;
@@ -1055,4 +1076,4 @@ declare function fullHandle(label: string): string;
1055
1076
  */
1056
1077
  declare function displayHandle(label: string): string;
1057
1078
 
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 };
1079
+ 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, addClaimRewardsToTx, addSendToTx, addStakeVSuiToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, 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 };
package/dist/index.js CHANGED
@@ -5099,35 +5099,6 @@ async function vt(e, n) {
5099
5099
  );
5100
5100
  return await De(e, t, n);
5101
5101
  }
5102
- function wt(e) {
5103
- const n = /* @__PURE__ */ new Map();
5104
- e.forEach((r) => {
5105
- const t = r.assetId, a = r.option, s = `${t}-${a}-${r.rewardCoinType}-${r.market}`;
5106
- n.has(s) ? n.get(s).total += r.userClaimableReward : n.set(s, {
5107
- assetId: t,
5108
- rewardType: a,
5109
- coinType: r.rewardCoinType,
5110
- total: Number(r.userClaimableReward),
5111
- market: r.market
5112
- });
5113
- });
5114
- const o = /* @__PURE__ */ new Map();
5115
- for (const { assetId: r, rewardType: t, coinType: a, total: s, market: i } of n.values()) {
5116
- const c = `${r}-${t}-${i}`;
5117
- o.has(c) || o.set(c, { assetId: r, rewardType: t, market: i, rewards: /* @__PURE__ */ new Map() });
5118
- const u = o.get(c);
5119
- u.rewards.set(a, (u.rewards.get(a) || 0) + s);
5120
- }
5121
- return Array.from(o.values()).map((r) => ({
5122
- assetId: r.assetId,
5123
- rewardType: r.rewardType,
5124
- market: r.market,
5125
- rewards: Array.from(r.rewards.entries()).map(([t, a]) => ({
5126
- coinType: t,
5127
- available: a.toFixed(6)
5128
- }))
5129
- }));
5130
- }
5131
5102
  async function Ct(e, n, o) {
5132
5103
  const r = await R({
5133
5104
  ...o,
@@ -5305,6 +5276,7 @@ async function Ct(e, n, o) {
5305
5276
 
5306
5277
  // src/protocols/navi.ts
5307
5278
  init_errors();
5279
+ init_token_registry();
5308
5280
  var MIN_HEALTH_FACTOR = 1.5;
5309
5281
  function sdkOptions(client) {
5310
5282
  return { env: "prod", client, cacheTime: 0, disableCache: true };
@@ -5679,24 +5651,8 @@ async function getPendingRewards(client, address) {
5679
5651
  );
5680
5652
  }
5681
5653
  if (!rewards || rewards.length === 0) return [];
5682
- const summary = wt(rewards);
5683
- const result = [];
5684
- for (const s of summary) {
5685
- for (const rw of s.rewards) {
5686
- const available = Number(rw.available);
5687
- if (available <= 0) continue;
5688
- const symbol = rw.coinType.split("::").pop() ?? "UNKNOWN";
5689
- result.push({
5690
- protocol: "navi",
5691
- asset: String(s.assetId),
5692
- coinType: rw.coinType,
5693
- symbol,
5694
- amount: available,
5695
- estimatedValueUsd: 0
5696
- });
5697
- }
5698
- }
5699
- return result;
5654
+ const claimable = rewards.filter((r) => Number(r.userClaimableReward) > 0);
5655
+ return aggregateClaimableRewards(claimable);
5700
5656
  }
5701
5657
  async function addClaimRewardsToTx(tx, client, address) {
5702
5658
  let rewards;
@@ -5746,7 +5702,8 @@ function aggregateClaimableRewards(claimable) {
5746
5702
  for (const c of claimable) {
5747
5703
  const coinType = c.rewardCoinType;
5748
5704
  if (!coinType) continue;
5749
- const symbol = coinType.split("::").pop() ?? "REWARD";
5705
+ const meta = getCoinMeta(coinType);
5706
+ const symbol = meta?.symbol ?? coinType.split("::").pop() ?? "REWARD";
5750
5707
  const amount = Number(c.userClaimableReward);
5751
5708
  if (!Number.isFinite(amount) || amount <= 0) continue;
5752
5709
  const existing = aggregated.get(coinType);
@@ -8099,6 +8056,6 @@ function displayHandle(label) {
8099
8056
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
8100
8057
  */
8101
8058
 
8102
- export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVE_FEE_BPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addFeeTransfer, addSendToTx, addStakeVSuiToTx, addSwapToTx, addUnstakeVSuiToTx, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, walletExists };
8059
+ export { ALL_NAVI_ASSETS, AUDRIC_PARENT_NAME, AUDRIC_PARENT_NFT_ID, BORROW_FEE_BPS, BPS_DENOMINATOR, CETUS_USDC_SUI_POOL, CLOCK_ID, COIN_REGISTRY, ContactManager, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, HF_CRITICAL_THRESHOLD, HF_WARN_THRESHOLD, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVE_FEE_BPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, VOLO_METADATA, VOLO_PKG, VOLO_POOL, VSUI_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addClaimRewardsToTx, addFeeTransfer, addSendToTx, addStakeVSuiToTx, addSwapToTx, addUnstakeVSuiToTx, aggregateClaimableRewards, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, displayHandle, exportPrivateKey, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getRates, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, walletExists };
8103
8060
  //# sourceMappingURL=index.js.map
8104
8061
  //# sourceMappingURL=index.js.map