@t2000/sdk 3.1.1 → 3.2.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 CHANGED
@@ -1145,6 +1145,65 @@ var init_cetus_swap = __esm({
1145
1145
  }
1146
1146
  });
1147
1147
 
1148
+ // src/swap-quote.ts
1149
+ var swap_quote_exports = {};
1150
+ __export(swap_quote_exports, {
1151
+ getSwapQuote: () => getSwapQuote
1152
+ });
1153
+ async function getSwapQuote(params) {
1154
+ const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
1155
+ const fromType = resolveTokenType2(params.from);
1156
+ const toType = resolveTokenType2(params.to);
1157
+ if (!fromType) {
1158
+ throw new exports.T2000Error(
1159
+ "ASSET_NOT_SUPPORTED",
1160
+ `Unknown token: ${params.from}. Provide the symbol (USDC, SUI, ...) or full coin type.`
1161
+ );
1162
+ }
1163
+ if (!toType) {
1164
+ throw new exports.T2000Error(
1165
+ "ASSET_NOT_SUPPORTED",
1166
+ `Unknown token: ${params.to}. Provide the symbol (USDC, SUI, ...) or full coin type.`
1167
+ );
1168
+ }
1169
+ const byAmountIn = params.byAmountIn ?? true;
1170
+ const fromDecimals = getDecimalsForCoinType(fromType);
1171
+ const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
1172
+ const route = await findSwapRoute2({
1173
+ walletAddress: params.walletAddress,
1174
+ from: fromType,
1175
+ to: toType,
1176
+ amount: rawAmount,
1177
+ byAmountIn,
1178
+ providers: params.providers
1179
+ });
1180
+ if (!route) throw new exports.T2000Error("SWAP_FAILED", `No swap route found for ${params.from} -> ${params.to}.`);
1181
+ if (route.insufficientLiquidity) {
1182
+ throw new exports.T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
1183
+ }
1184
+ const toDecimals = getDecimalsForCoinType(toType);
1185
+ const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
1186
+ const toAmount = Number(route.amountOut) / 10 ** toDecimals;
1187
+ const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
1188
+ const { serializeCetusRoute: serializeCetusRoute2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
1189
+ const serializedRoute = serializeCetusRoute2(route, { fromCoinType: fromType, toCoinType: toType });
1190
+ return {
1191
+ fromToken: params.from,
1192
+ toToken: params.to,
1193
+ fromAmount,
1194
+ toAmount,
1195
+ priceImpact: route.priceImpact,
1196
+ route: routeDesc,
1197
+ serializedRoute
1198
+ };
1199
+ }
1200
+ var init_swap_quote = __esm({
1201
+ "src/swap-quote.ts"() {
1202
+ init_errors();
1203
+ init_token_registry();
1204
+ }
1205
+ });
1206
+
1148
1207
  // src/constants.ts
1149
1208
  init_errors();
1150
1209
  var MIST_PER_SUI = 1000000000n;
@@ -1210,7 +1269,8 @@ var SUPPORTED_ASSETS = {
1210
1269
  displayName: "XAUM"
1211
1270
  }
1212
1271
  };
1213
- var STABLE_ASSETS = ["USDC"];
1272
+ var STABLE_ASSETS = ["USDC", "USDsui"];
1273
+ var SAVEABLE_ASSETS = ["USDC", "USDsui"];
1214
1274
  var ALL_NAVI_ASSETS = Object.keys(SUPPORTED_ASSETS);
1215
1275
  var OPERATION_ASSETS = {
1216
1276
  save: ["USDC", "USDsui"],
@@ -6015,7 +6075,7 @@ var ProtocolRegistry = class {
6015
6075
  }
6016
6076
  async bestSaveRateAcrossAssets() {
6017
6077
  const candidates = [];
6018
- for (const asset of STABLE_ASSETS) {
6078
+ for (const asset of SAVEABLE_ASSETS) {
6019
6079
  for (const adapter of this.lending.values()) {
6020
6080
  if (!adapter.supportedAssets.includes(asset)) continue;
6021
6081
  if (!adapter.capabilities.includes("save")) continue;
@@ -6035,7 +6095,7 @@ var ProtocolRegistry = class {
6035
6095
  async allRatesAcrossAssets() {
6036
6096
  const results = [];
6037
6097
  const seen = /* @__PURE__ */ new Set();
6038
- for (const asset of STABLE_ASSETS) {
6098
+ for (const asset of SAVEABLE_ASSETS) {
6039
6099
  if (seen.has(asset)) continue;
6040
6100
  seen.add(asset);
6041
6101
  for (const adapter of this.lending.values()) {
@@ -6797,36 +6857,24 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
6797
6857
  gasCost: gasResult.gasCostSui
6798
6858
  };
6799
6859
  }
6860
+ /**
6861
+ * [SPEC_AGENTIC_STACK P1 / SDK F2 — 2026-05-25]
6862
+ * Thin wrapper around the standalone `getSwapQuote()`. Pre-Phase 1 this method
6863
+ * was ~50 LoC duplicating `swap-quote.ts` — missing `serializedRoute` (SPEC 20.2
6864
+ * fast-path) and the `providers` allow-list (Bug A fix / Pyth-dependent
6865
+ * provider filter for sponsored callers). Routing both API surfaces through
6866
+ * one implementation ensures fixes land for both.
6867
+ */
6800
6868
  async swapQuote(params) {
6801
- const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
6802
- const fromType = resolveTokenType2(params.from);
6803
- const toType = resolveTokenType2(params.to);
6804
- if (!fromType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.from}. Provide the full coin type.`);
6805
- if (!toType) throw new exports.T2000Error("ASSET_NOT_SUPPORTED", `Unknown token: ${params.to}. Provide the full coin type.`);
6806
- const byAmountIn = params.byAmountIn ?? true;
6807
- const fromDecimals = getDecimalsForCoinType(fromType);
6808
- const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
6809
- const route = await findSwapRoute2({
6869
+ const { getSwapQuote: getSwapQuote2 } = await Promise.resolve().then(() => (init_swap_quote(), swap_quote_exports));
6870
+ return getSwapQuote2({
6810
6871
  walletAddress: this._address,
6811
- from: fromType,
6812
- to: toType,
6813
- amount: rawAmount,
6814
- byAmountIn
6872
+ from: params.from,
6873
+ to: params.to,
6874
+ amount: params.amount,
6875
+ byAmountIn: params.byAmountIn,
6876
+ providers: params.providers
6815
6877
  });
6816
- if (!route) throw new exports.T2000Error("SWAP_NO_ROUTE", `No swap route found for ${params.from} -> ${params.to}.`);
6817
- if (route.insufficientLiquidity) throw new exports.T2000Error("SWAP_NO_ROUTE", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
6818
- const toDecimals = getDecimalsForCoinType(toType);
6819
- const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
6820
- const toAmount = Number(route.amountOut) / 10 ** toDecimals;
6821
- const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
6822
- return {
6823
- fromToken: params.from,
6824
- toToken: params.to,
6825
- fromAmount,
6826
- toAmount,
6827
- priceImpact: route.priceImpact,
6828
- route: routeDesc
6829
- };
6830
6878
  }
6831
6879
  // -- Wallet --
6832
6880
  address() {
@@ -6957,6 +7005,16 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
6957
7005
  ].join("\n")
6958
7006
  };
6959
7007
  }
7008
+ /**
7009
+ * [SPEC_AGENTIC_STACK P1 / SDK F2 (CLI rename support) — 2026-05-25]
7010
+ * Preferred alias of `deposit()`. The CLI surface is `t2000 fund` post-Phase 1
7011
+ * (more intuitive than "deposit" which sounds like a NAVI lending action).
7012
+ * `deposit()` stays as the canonical method name for back-compat; it is NOT
7013
+ * deprecated. This wrapper exists so SDK consumers can mirror CLI naming.
7014
+ */
7015
+ async fund() {
7016
+ return this.deposit();
7017
+ }
6960
7018
  receive(params) {
6961
7019
  const amount = params?.amount ?? null;
6962
7020
  const currency = params?.currency ?? "USDC";
@@ -7671,7 +7729,7 @@ var T2000 = class _T2000 extends eventemitter3.EventEmitter {
7671
7729
  this.emit("yield", {
7672
7730
  earned: result.dailyEarning,
7673
7731
  total: result.totalYieldEarned,
7674
- apy: result.currentApy / 100,
7732
+ apy: result.currentApy,
7675
7733
  timestamp: Date.now()
7676
7734
  });
7677
7735
  }
@@ -8453,58 +8511,8 @@ function parseMoveAbort(errorStr) {
8453
8511
  return { reason: errorStr };
8454
8512
  }
8455
8513
 
8456
- // src/swap-quote.ts
8457
- init_errors();
8458
- init_token_registry();
8459
- async function getSwapQuote(params) {
8460
- const { findSwapRoute: findSwapRoute2, resolveTokenType: resolveTokenType2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
8461
- const fromType = resolveTokenType2(params.from);
8462
- const toType = resolveTokenType2(params.to);
8463
- if (!fromType) {
8464
- throw new exports.T2000Error(
8465
- "ASSET_NOT_SUPPORTED",
8466
- `Unknown token: ${params.from}. Provide the symbol (USDC, SUI, ...) or full coin type.`
8467
- );
8468
- }
8469
- if (!toType) {
8470
- throw new exports.T2000Error(
8471
- "ASSET_NOT_SUPPORTED",
8472
- `Unknown token: ${params.to}. Provide the symbol (USDC, SUI, ...) or full coin type.`
8473
- );
8474
- }
8475
- const byAmountIn = params.byAmountIn ?? true;
8476
- const fromDecimals = getDecimalsForCoinType(fromType);
8477
- const rawAmount = BigInt(Math.floor(params.amount * 10 ** fromDecimals));
8478
- const route = await findSwapRoute2({
8479
- walletAddress: params.walletAddress,
8480
- from: fromType,
8481
- to: toType,
8482
- amount: rawAmount,
8483
- byAmountIn,
8484
- providers: params.providers
8485
- });
8486
- if (!route) throw new exports.T2000Error("SWAP_FAILED", `No swap route found for ${params.from} -> ${params.to}.`);
8487
- if (route.insufficientLiquidity) {
8488
- throw new exports.T2000Error("SWAP_FAILED", `Insufficient liquidity for ${params.from} -> ${params.to}.`);
8489
- }
8490
- const toDecimals = getDecimalsForCoinType(toType);
8491
- const fromAmount = Number(route.amountIn) / 10 ** fromDecimals;
8492
- const toAmount = Number(route.amountOut) / 10 ** toDecimals;
8493
- const routeDesc = route.routerData.paths?.map((p) => p.provider).filter(Boolean).slice(0, 3).join(" + ") ?? "Cetus Aggregator";
8494
- const { serializeCetusRoute: serializeCetusRoute2 } = await Promise.resolve().then(() => (init_cetus_swap(), cetus_swap_exports));
8495
- const serializedRoute = serializeCetusRoute2(route, { fromCoinType: fromType, toCoinType: toType });
8496
- return {
8497
- fromToken: params.from,
8498
- toToken: params.to,
8499
- fromAmount,
8500
- toAmount,
8501
- priceImpact: route.priceImpact,
8502
- route: routeDesc,
8503
- serializedRoute
8504
- };
8505
- }
8506
-
8507
8514
  // src/index.ts
8515
+ init_swap_quote();
8508
8516
  init_cetus_swap();
8509
8517
  init_token_registry();
8510
8518
  init_volo();
@@ -8597,6 +8605,7 @@ exports.NaviAdapter = NaviAdapter;
8597
8605
  exports.OPERATION_ASSETS = OPERATION_ASSETS;
8598
8606
  exports.OUTBOUND_OPS = OUTBOUND_OPS;
8599
8607
  exports.ProtocolRegistry = ProtocolRegistry;
8608
+ exports.SAVEABLE_ASSETS = SAVEABLE_ASSETS;
8600
8609
  exports.SAVE_FEE_BPS = SAVE_FEE_BPS;
8601
8610
  exports.SPONSORED_PYTH_DEPENDENT_PROVIDERS = SPONSORED_PYTH_DEPENDENT_PROVIDERS;
8602
8611
  exports.STABLE_ASSETS = STABLE_ASSETS;