@t2000/sdk 3.2.0 → 3.3.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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Transaction, coinWithBalance } from '@mysten/sui/transactions';
1
+ import { coinWithBalance, Transaction } from '@mysten/sui/transactions';
2
2
  import { AggregatorClient, Env } from '@cetusprotocol/aggregator-sdk';
3
3
  import BN from 'bn.js';
4
4
  import { EventEmitter } from 'eventemitter3';
@@ -645,155 +645,6 @@ var require_lodash = __commonJS({
645
645
  }
646
646
  });
647
647
 
648
- // src/protocols/volo.ts
649
- var volo_exports = {};
650
- __export(volo_exports, {
651
- MIN_STAKE_MIST: () => MIN_STAKE_MIST,
652
- SUI_SYSTEM_STATE: () => SUI_SYSTEM_STATE,
653
- VOLO_METADATA: () => VOLO_METADATA,
654
- VOLO_PKG: () => VOLO_PKG,
655
- VOLO_POOL: () => VOLO_POOL,
656
- VSUI_TYPE: () => VSUI_TYPE,
657
- addStakeVSuiToTx: () => addStakeVSuiToTx,
658
- addUnstakeVSuiToTx: () => addUnstakeVSuiToTx,
659
- buildStakeVSuiTx: () => buildStakeVSuiTx,
660
- buildUnstakeVSuiTx: () => buildUnstakeVSuiTx,
661
- getVoloStats: () => getVoloStats
662
- });
663
- async function getVoloStats() {
664
- const res = await fetch(VOLO_STATS_URL, {
665
- signal: AbortSignal.timeout(8e3)
666
- });
667
- if (!res.ok) {
668
- throw new Error(`VOLO stats API error: HTTP ${res.status}`);
669
- }
670
- const data = await res.json();
671
- const d = data.data ?? data;
672
- return {
673
- apy: d.apy ?? 0,
674
- exchangeRate: d.exchange_rate ?? d.exchangeRate ?? 1,
675
- tvl: d.tvl ?? 0
676
- };
677
- }
678
- async function buildStakeVSuiTx(_client, address, amountMist) {
679
- if (amountMist < MIN_STAKE_MIST) {
680
- throw new Error(`Minimum stake is 1 SUI (${MIN_STAKE_MIST} MIST). Got: ${amountMist}`);
681
- }
682
- const tx = new Transaction();
683
- tx.setSender(address);
684
- const [suiCoin] = tx.splitCoins(tx.gas, [amountMist]);
685
- const [vSuiCoin] = tx.moveCall({
686
- target: `${VOLO_PKG}::stake_pool::stake`,
687
- arguments: [
688
- tx.object(VOLO_POOL),
689
- tx.object(VOLO_METADATA),
690
- tx.object(SUI_SYSTEM_STATE),
691
- suiCoin
692
- ]
693
- });
694
- tx.transferObjects([vSuiCoin], address);
695
- return tx;
696
- }
697
- async function buildUnstakeVSuiTx(client, address, amountMist) {
698
- const balResp = await client.getBalance({ owner: address, coinType: VSUI_TYPE });
699
- const totalBalance = BigInt(balResp.totalBalance);
700
- if (totalBalance === 0n) {
701
- throw new Error("No vSUI found in wallet.");
702
- }
703
- const tx = new Transaction();
704
- tx.setSender(address);
705
- const requested = amountMist === "all" ? totalBalance : amountMist;
706
- if (requested > totalBalance) {
707
- throw new Error(`Insufficient vSUI: need ${requested} MIST, have ${totalBalance}`);
708
- }
709
- const vSuiCoin = coinWithBalance({ type: VSUI_TYPE, balance: requested })(tx);
710
- const [suiCoin] = tx.moveCall({
711
- target: `${VOLO_PKG}::stake_pool::unstake`,
712
- arguments: [
713
- tx.object(VOLO_POOL),
714
- tx.object(VOLO_METADATA),
715
- tx.object(SUI_SYSTEM_STATE),
716
- vSuiCoin
717
- ]
718
- });
719
- tx.transferObjects([suiCoin], address);
720
- return tx;
721
- }
722
- async function addStakeVSuiToTx(tx, client, address, input) {
723
- if (input.amountMist < MIN_STAKE_MIST) {
724
- throw new Error(`Minimum stake is 1 SUI (${MIN_STAKE_MIST} MIST). Got: ${input.amountMist}`);
725
- }
726
- let suiCoin;
727
- if (input.inputCoin) {
728
- suiCoin = input.inputCoin;
729
- } else {
730
- const balResp = await client.getBalance({ owner: address, coinType: SUI_TYPE });
731
- const totalBalance = BigInt(balResp.totalBalance);
732
- if (totalBalance < input.amountMist) {
733
- throw new Error(`Insufficient SUI: need ${input.amountMist} MIST, have ${totalBalance}`);
734
- }
735
- suiCoin = coinWithBalance({
736
- type: SUI_TYPE,
737
- balance: input.amountMist,
738
- useGasCoin: false
739
- })(tx);
740
- }
741
- const [vSuiCoin] = tx.moveCall({
742
- target: `${VOLO_PKG}::stake_pool::stake`,
743
- arguments: [
744
- tx.object(VOLO_POOL),
745
- tx.object(VOLO_METADATA),
746
- tx.object(SUI_SYSTEM_STATE),
747
- suiCoin
748
- ]
749
- });
750
- return { coin: vSuiCoin, effectiveAmountMist: input.amountMist };
751
- }
752
- async function addUnstakeVSuiToTx(tx, client, address, input) {
753
- let vSuiCoin;
754
- if (input.inputCoin) {
755
- if (input.amountMist === "all") {
756
- vSuiCoin = input.inputCoin;
757
- } else {
758
- [vSuiCoin] = tx.splitCoins(input.inputCoin, [input.amountMist]);
759
- }
760
- } else {
761
- const balResp = await client.getBalance({ owner: address, coinType: VSUI_TYPE });
762
- const totalBalance = BigInt(balResp.totalBalance);
763
- if (totalBalance === 0n) {
764
- throw new Error("No vSUI found in wallet.");
765
- }
766
- const requested = input.amountMist === "all" ? totalBalance : input.amountMist;
767
- if (requested > totalBalance) {
768
- throw new Error(`Insufficient vSUI: need ${requested} MIST, have ${totalBalance}`);
769
- }
770
- vSuiCoin = coinWithBalance({ type: VSUI_TYPE, balance: requested })(tx);
771
- }
772
- const [suiCoin] = tx.moveCall({
773
- target: `${VOLO_PKG}::stake_pool::unstake`,
774
- arguments: [
775
- tx.object(VOLO_POOL),
776
- tx.object(VOLO_METADATA),
777
- tx.object(SUI_SYSTEM_STATE),
778
- vSuiCoin
779
- ]
780
- });
781
- return { coin: suiCoin, effectiveAmountMist: input.amountMist };
782
- }
783
- var VOLO_PKG, VOLO_POOL, VOLO_METADATA, VSUI_TYPE, SUI_SYSTEM_STATE, MIN_STAKE_MIST, VOLO_STATS_URL;
784
- var init_volo = __esm({
785
- "src/protocols/volo.ts"() {
786
- init_token_registry();
787
- VOLO_PKG = "0x68d22cf8bdbcd11ecba1e094922873e4080d4d11133e2443fddda0bfd11dae20";
788
- VOLO_POOL = "0x2d914e23d82fedef1b5f56a32d5c64bdcc3087ccfea2b4d6ea51a71f587840e5";
789
- VOLO_METADATA = "0x680cd26af32b2bde8d3361e804c53ec1d1cfe24c7f039eb7f549e8dfde389a60";
790
- VSUI_TYPE = "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT";
791
- SUI_SYSTEM_STATE = "0x05";
792
- MIN_STAKE_MIST = 1000000000n;
793
- VOLO_STATS_URL = "https://open-api.naviprotocol.io/api/volo/stats";
794
- }
795
- });
796
-
797
648
  // src/wallet/coinSelection.ts
798
649
  var coinSelection_exports = {};
799
650
  __export(coinSelection_exports, {
@@ -6699,51 +6550,14 @@ var T2000 = class _T2000 extends EventEmitter {
6699
6550
  receipt: paymentDigest ? { reference: paymentDigest, timestamp: (/* @__PURE__ */ new Date()).toISOString() } : void 0
6700
6551
  };
6701
6552
  }
6702
- // -- VOLO vSUI Staking --
6703
- async stakeVSui(params) {
6704
- this.enforcer.assertNotLocked();
6705
- const { buildStakeVSuiTx: buildStakeVSuiTx2, getVoloStats: getVoloStats2 } = await Promise.resolve().then(() => (init_volo(), volo_exports));
6706
- const amountMist = BigInt(Math.floor(params.amount * Number(MIST_PER_SUI)));
6707
- const stats = await getVoloStats2();
6708
- const gasResult = await executeTx(this.client, this._signer, async () => {
6709
- return buildStakeVSuiTx2(this.client, this._address, amountMist);
6710
- });
6711
- const vSuiReceived = params.amount / stats.exchangeRate;
6712
- return {
6713
- success: true,
6714
- tx: gasResult.digest,
6715
- amountSui: params.amount,
6716
- vSuiReceived,
6717
- apy: stats.apy,
6718
- gasCost: gasResult.gasCostSui
6719
- };
6720
- }
6721
- async unstakeVSui(params) {
6722
- this.enforcer.assertNotLocked();
6723
- const { buildUnstakeVSuiTx: buildUnstakeVSuiTx2, getVoloStats: getVoloStats2, VSUI_TYPE: VSUI_TYPE2 } = await Promise.resolve().then(() => (init_volo(), volo_exports));
6724
- let amountMist;
6725
- let vSuiAmount;
6726
- if (params.amount === "all") {
6727
- amountMist = "all";
6728
- const bal = await this.client.getBalance({ owner: this._address, coinType: VSUI_TYPE2 });
6729
- vSuiAmount = Number(bal.totalBalance) / 1e9;
6730
- } else {
6731
- amountMist = BigInt(Math.floor(params.amount * 1e9));
6732
- vSuiAmount = params.amount;
6733
- }
6734
- const stats = await getVoloStats2();
6735
- const gasResult = await executeTx(this.client, this._signer, async () => {
6736
- return buildUnstakeVSuiTx2(this.client, this._address, amountMist);
6737
- });
6738
- const suiReceived = vSuiAmount * stats.exchangeRate;
6739
- return {
6740
- success: true,
6741
- tx: gasResult.digest,
6742
- vSuiAmount,
6743
- suiReceived,
6744
- gasCost: gasResult.gasCostSui
6745
- };
6746
- }
6553
+ // [S.323 / 2026-05-25] VOLO vSUI staking surfaces removed (full cut).
6554
+ // Engine cut Volo in S.277; SDK + CLI + MCP followed in S.323 because the
6555
+ // product surface (five products: Passport / Intelligence / Finance / Pay
6556
+ // / Store) doesn't include a staking primitive. vSUI still appears in the
6557
+ // codebase as a passive token (NAVI reward rewards, Cetus swap routing),
6558
+ // but there is no longer any way to MINT or REDEEM vSUI through t2000.
6559
+ // History: see spec/archive/v07e/AUDIT_V07E_EARNS_ITS_KEEP_2026-05-23.md
6560
+ // and the S.323 build-tracker entry.
6747
6561
  // -- Swap --
6748
6562
  async swap(params) {
6749
6563
  this.enforcer.assertNotLocked();
@@ -7970,7 +7784,6 @@ async function buildHarvestRewardsTx(client, address, options = {}) {
7970
7784
 
7971
7785
  // src/composeTx.ts
7972
7786
  init_cetus_swap();
7973
- init_volo();
7974
7787
  init_coinSelection();
7975
7788
  init_token_registry();
7976
7789
  init_errors();
@@ -8194,41 +8007,8 @@ var WRITE_APPENDER_REGISTRY = {
8194
8007
  expectedUsdcDeposited: plan.expectedUsdcDeposited
8195
8008
  }
8196
8009
  };
8197
- },
8198
- volo_stake: async (tx, input, ctx) => {
8199
- if (input.amountSui <= 0) {
8200
- throw new T2000Error("INVALID_AMOUNT", "Stake amount must be greater than zero");
8201
- }
8202
- const amountMist = BigInt(Math.floor(input.amountSui * 1e9));
8203
- const result = await addStakeVSuiToTx(tx, ctx.client, ctx.sender, {
8204
- amountMist,
8205
- inputCoin: ctx.chainedCoin
8206
- });
8207
- if (!ctx.isOutputConsumed) {
8208
- tx.transferObjects([result.coin], ctx.sender);
8209
- }
8210
- return {
8211
- preview: { toolName: "volo_stake", effectiveAmountMist: result.effectiveAmountMist },
8212
- outputCoin: result.coin
8213
- };
8214
- },
8215
- volo_unstake: async (tx, input, ctx) => {
8216
- const amountMist = input.amountVSui === "all" ? "all" : BigInt(Math.floor(input.amountVSui * 1e9));
8217
- if (amountMist !== "all" && amountMist <= 0n) {
8218
- throw new T2000Error("INVALID_AMOUNT", "Unstake amount must be greater than zero");
8219
- }
8220
- const result = await addUnstakeVSuiToTx(tx, ctx.client, ctx.sender, {
8221
- amountMist,
8222
- inputCoin: ctx.chainedCoin
8223
- });
8224
- if (!ctx.isOutputConsumed) {
8225
- tx.transferObjects([result.coin], ctx.sender);
8226
- }
8227
- return {
8228
- preview: { toolName: "volo_unstake", effectiveAmountMist: result.effectiveAmountMist },
8229
- outputCoin: result.coin
8230
- };
8231
8010
  }
8011
+ // [S.323 / 2026-05-25] volo_stake / volo_unstake appenders removed.
8232
8012
  };
8233
8013
  function deriveAllowedAddressesFromPtb(tx) {
8234
8014
  const addresses = /* @__PURE__ */ new Set();
@@ -8289,7 +8069,7 @@ async function composeTx(opts) {
8289
8069
  if (producer.toolName === "save_deposit" || producer.toolName === "repay_debt" || producer.toolName === "send_transfer" || producer.toolName === "claim_rewards") {
8290
8070
  throw new T2000Error(
8291
8071
  "CHAIN_MODE_INVALID",
8292
- `Step ${i} (${step.toolName}) references step ${idx} (${producer.toolName}) as producer, but '${producer.toolName}' is a terminal consumer that does not produce a chainable coin handle. Allowed producers: withdraw, borrow, swap_execute, volo_stake, volo_unstake.`
8072
+ `Step ${i} (${step.toolName}) references step ${idx} (${producer.toolName}) as producer, but '${producer.toolName}' is a terminal consumer that does not produce a chainable coin handle. Allowed producers: withdraw, borrow, swap_execute.`
8293
8073
  );
8294
8074
  }
8295
8075
  consumedSteps.add(idx);
@@ -8509,7 +8289,6 @@ function parseMoveAbort(errorStr) {
8509
8289
  init_swap_quote();
8510
8290
  init_cetus_swap();
8511
8291
  init_token_registry();
8512
- init_volo();
8513
8292
  var AUDRIC_PARENT_NAME = "audric.sui";
8514
8293
  var AUDRIC_PARENT_NFT_ID = "0x070456e283ec988b6302bdd6cc5172bbdcb709998cf116586fb98d19b0870198";
8515
8294
  var LABEL_PATTERN = /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/;
@@ -8577,6 +8356,6 @@ function displayHandle(label) {
8577
8356
  (*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
8578
8357
  */
8579
8358
 
8580
- 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, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVEABLE_ASSETS, SAVE_FEE_BPS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, SuinsNotRegisteredError, SuinsRpcError, 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, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildStakeVSuiTx, buildSwapTx, buildUnstakeVSuiTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, getTier, getVoloStats, isAllowedAsset, isCetusRouteFresh, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists };
8359
+ 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, InvalidAddressError, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, NaviAdapter, OPERATION_ASSETS, OUTBOUND_OPS, OVERLAY_FEE_RATE, ProtocolRegistry, SAVEABLE_ASSETS, SAVE_FEE_BPS, SPONSORED_PYTH_DEPENDENT_PROVIDERS, STABLE_ASSETS, SUINS_NAME_REGEX, SUI_ADDRESS_REGEX, SUI_ADDRESS_STRICT_REGEX, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardEnforcer, SafeguardError, SuinsNotRegisteredError, SuinsRpcError, T2000, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, WRITE_APPENDER_REGISTRY, ZkLoginSigner, addClaimRewardsToTx, addFeeTransfer, addSendToTx, addSwapToTx, aggregateClaimableRewards, allDescriptors, assertAllowedAsset, buildAddLeafTx, buildClaimRewardsTx, buildHarvestRewardsTx, buildRevokeLeafTx, buildSendTx, buildSwapTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, composeTx, deriveAllowedAddressesFromPtb, deserializeCetusRoute, displayHandle, exportPrivateKey, extractAllUserLegs, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, fetchAllCoins, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fullHandle, generateKeypair, getAddress, getCoinMeta, getDecimals, getDecimalsForCoinType, getFinancialSummary, getPendingRewards, getPendingRewardsByAddress, getRates, getSponsoredSwapProviders, getSwapQuote, getTier, isAllowedAsset, isCetusRouteFresh, isInRegistry, isSupported, isTier1, isTier2, keypairFromPrivateKey, loadKey, looksLikeSuiNs, mapMoveAbortCode, mapWalletError, mistToSui, naviDescriptor, normalizeAddressInput, normalizeAsset, normalizeCoinType, parseSuiRpcTx, queryHistory, queryTransaction, rawToStable, rawToUsdc, refineLendingLabel, resolveAddressToSuinsViaRpc, resolveSuinsViaRpc, resolveSymbol, resolveTokenType, saveKey, selectAndSplitCoin, selectSuiCoin, serializeCetusRoute, simulateTransaction, stableToRaw, suiToMist, throwIfSimulationFailed, truncateAddress, usdcToRaw, validateAddress, validateLabel, verifyCetusRouteCoinMatch, walletExists };
8581
8360
  //# sourceMappingURL=index.js.map
8582
8361
  //# sourceMappingURL=index.js.map