@t2000/sdk 1.11.0 → 1.11.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/browser.cjs CHANGED
@@ -103,6 +103,104 @@ var init_errors = __esm({
103
103
  }
104
104
  });
105
105
 
106
+ // src/token-registry.ts
107
+ function isTier1(coinType) {
108
+ const meta = BY_TYPE.get(coinType);
109
+ return meta?.tier === 1;
110
+ }
111
+ function isTier2(coinType) {
112
+ const meta = BY_TYPE.get(coinType);
113
+ return meta?.tier === 2;
114
+ }
115
+ function isSupported(coinType) {
116
+ const meta = BY_TYPE.get(coinType);
117
+ return meta?.tier !== void 0;
118
+ }
119
+ function getTier(coinType) {
120
+ return BY_TYPE.get(coinType)?.tier;
121
+ }
122
+ function getDecimalsForCoinType(coinType) {
123
+ const direct = BY_TYPE.get(coinType);
124
+ if (direct) return direct.decimals;
125
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
126
+ if (suffix) {
127
+ for (const meta of BY_TYPE.values()) {
128
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
129
+ if (metaSuffix === suffix) return meta.decimals;
130
+ }
131
+ }
132
+ return 9;
133
+ }
134
+ function resolveSymbol(coinType) {
135
+ const direct = BY_TYPE.get(coinType);
136
+ if (direct) return direct.symbol;
137
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
138
+ if (suffix) {
139
+ for (const meta of BY_TYPE.values()) {
140
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
141
+ if (metaSuffix === suffix) return meta.symbol;
142
+ }
143
+ }
144
+ return coinType.split("::").pop() ?? coinType;
145
+ }
146
+ function resolveTokenType(nameOrType) {
147
+ if (nameOrType.includes("::")) return nameOrType;
148
+ return exports.TOKEN_MAP[nameOrType] ?? exports.TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
149
+ }
150
+ exports.COIN_REGISTRY = void 0; var BY_TYPE; exports.TOKEN_MAP = void 0; exports.SUI_TYPE = void 0; exports.USDC_TYPE = void 0; exports.USDT_TYPE = void 0; exports.USDSUI_TYPE = void 0; exports.USDE_TYPE = void 0; exports.ETH_TYPE = void 0; exports.WBTC_TYPE = void 0; exports.WAL_TYPE = void 0; exports.NAVX_TYPE = void 0; exports.IKA_TYPE = void 0; exports.LOFI_TYPE = void 0; exports.MANIFEST_TYPE = void 0;
151
+ var init_token_registry = __esm({
152
+ "src/token-registry.ts"() {
153
+ exports.COIN_REGISTRY = {
154
+ // ── Tier 1 — Financial layer ──────────────────────────────────────────
155
+ USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
156
+ // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
157
+ SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
158
+ wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
159
+ ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
160
+ GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
161
+ DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
162
+ WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
163
+ NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
164
+ IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
165
+ CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
166
+ NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
167
+ vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
168
+ haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
169
+ afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
170
+ LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
171
+ MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
172
+ // ── Legacy — no tier, kept for display accuracy on existing positions ──
173
+ USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
174
+ USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
175
+ USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
176
+ };
177
+ BY_TYPE = /* @__PURE__ */ new Map();
178
+ for (const meta of Object.values(exports.COIN_REGISTRY)) {
179
+ BY_TYPE.set(meta.type, meta);
180
+ }
181
+ exports.TOKEN_MAP = (() => {
182
+ const map = {};
183
+ for (const [name, meta] of Object.entries(exports.COIN_REGISTRY)) {
184
+ map[name] = meta.type;
185
+ map[name.toUpperCase()] = meta.type;
186
+ }
187
+ return map;
188
+ })();
189
+ exports.SUI_TYPE = exports.COIN_REGISTRY.SUI.type;
190
+ exports.USDC_TYPE = exports.COIN_REGISTRY.USDC.type;
191
+ exports.USDT_TYPE = exports.COIN_REGISTRY.USDT.type;
192
+ exports.USDSUI_TYPE = exports.COIN_REGISTRY.USDSUI.type;
193
+ exports.USDE_TYPE = exports.COIN_REGISTRY.USDe.type;
194
+ exports.ETH_TYPE = exports.COIN_REGISTRY.ETH.type;
195
+ exports.WBTC_TYPE = exports.COIN_REGISTRY.wBTC.type;
196
+ exports.WAL_TYPE = exports.COIN_REGISTRY.WAL.type;
197
+ exports.NAVX_TYPE = exports.COIN_REGISTRY.NAVX.type;
198
+ exports.IKA_TYPE = exports.COIN_REGISTRY.IKA.type;
199
+ exports.LOFI_TYPE = exports.COIN_REGISTRY.LOFI.type;
200
+ exports.MANIFEST_TYPE = exports.COIN_REGISTRY.MANIFEST.type;
201
+ }
202
+ });
203
+
106
204
  // src/wallet/keypairSigner.ts
107
205
  var KeypairSigner = class {
108
206
  constructor(keypair) {
@@ -234,100 +332,8 @@ function truncateAddress(address) {
234
332
  return `${address.slice(0, 6)}...${address.slice(-4)}`;
235
333
  }
236
334
 
237
- // src/token-registry.ts
238
- var COIN_REGISTRY = {
239
- // ── Tier 1 — Financial layer ──────────────────────────────────────────
240
- USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
241
- // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
242
- SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
243
- wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
244
- ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
245
- GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
246
- DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
247
- WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
248
- NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
249
- IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
250
- CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
251
- NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
252
- vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
253
- haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
254
- afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
255
- LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
256
- MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
257
- // ── Legacy — no tier, kept for display accuracy on existing positions ──
258
- USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
259
- USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
260
- USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
261
- };
262
- var BY_TYPE = /* @__PURE__ */ new Map();
263
- for (const meta of Object.values(COIN_REGISTRY)) {
264
- BY_TYPE.set(meta.type, meta);
265
- }
266
- function isTier1(coinType) {
267
- const meta = BY_TYPE.get(coinType);
268
- return meta?.tier === 1;
269
- }
270
- function isTier2(coinType) {
271
- const meta = BY_TYPE.get(coinType);
272
- return meta?.tier === 2;
273
- }
274
- function isSupported(coinType) {
275
- const meta = BY_TYPE.get(coinType);
276
- return meta?.tier !== void 0;
277
- }
278
- function getTier(coinType) {
279
- return BY_TYPE.get(coinType)?.tier;
280
- }
281
- function getDecimalsForCoinType(coinType) {
282
- const direct = BY_TYPE.get(coinType);
283
- if (direct) return direct.decimals;
284
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
285
- if (suffix) {
286
- for (const meta of BY_TYPE.values()) {
287
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
288
- if (metaSuffix === suffix) return meta.decimals;
289
- }
290
- }
291
- return 9;
292
- }
293
- function resolveSymbol(coinType) {
294
- const direct = BY_TYPE.get(coinType);
295
- if (direct) return direct.symbol;
296
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
297
- if (suffix) {
298
- for (const meta of BY_TYPE.values()) {
299
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
300
- if (metaSuffix === suffix) return meta.symbol;
301
- }
302
- }
303
- return coinType.split("::").pop() ?? coinType;
304
- }
305
- var TOKEN_MAP = (() => {
306
- const map = {};
307
- for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
308
- map[name] = meta.type;
309
- map[name.toUpperCase()] = meta.type;
310
- }
311
- return map;
312
- })();
313
- function resolveTokenType(nameOrType) {
314
- if (nameOrType.includes("::")) return nameOrType;
315
- return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
316
- }
317
- var SUI_TYPE = COIN_REGISTRY.SUI.type;
318
- var USDC_TYPE = COIN_REGISTRY.USDC.type;
319
- var USDT_TYPE = COIN_REGISTRY.USDT.type;
320
- var USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
321
- var USDE_TYPE = COIN_REGISTRY.USDe.type;
322
- var ETH_TYPE = COIN_REGISTRY.ETH.type;
323
- var WBTC_TYPE = COIN_REGISTRY.wBTC.type;
324
- var WAL_TYPE = COIN_REGISTRY.WAL.type;
325
- var NAVX_TYPE = COIN_REGISTRY.NAVX.type;
326
- var IKA_TYPE = COIN_REGISTRY.IKA.type;
327
- var LOFI_TYPE = COIN_REGISTRY.LOFI.type;
328
- var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
329
-
330
335
  // src/wallet/classify.ts
336
+ init_token_registry();
331
337
  var KNOWN_TARGETS = [
332
338
  [/::suilend|::obligation/, "lending"],
333
339
  [/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
@@ -401,11 +407,11 @@ function refineLendingLabel(currentAction, currentLabel, moveCallTargets, change
401
407
  );
402
408
  if (labelMatchedSpecific) return currentLabel;
403
409
  const userNonSuiOutflow = changes.find(
404
- (c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) < 0n
410
+ (c) => resolveOwner(c.owner) === address && c.coinType !== exports.SUI_TYPE && BigInt(c.amount) < 0n
405
411
  );
406
412
  if (userNonSuiOutflow) return "deposit";
407
413
  const userNonSuiInflow = changes.find(
408
- (c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) > 0n
414
+ (c) => resolveOwner(c.owner) === address && c.coinType !== exports.SUI_TYPE && BigInt(c.amount) > 0n
409
415
  );
410
416
  if (userNonSuiInflow) return "withdraw";
411
417
  return currentLabel;
@@ -420,7 +426,7 @@ function extractTransferDetails(changes, sender) {
420
426
  if (!changes || changes.length === 0) return {};
421
427
  const userChanges = changes.filter((c) => resolveOwner(c.owner) === sender);
422
428
  if (userChanges.length === 0) return {};
423
- const userNonSui = userChanges.filter((c) => c.coinType !== SUI_TYPE);
429
+ const userNonSui = userChanges.filter((c) => c.coinType !== exports.SUI_TYPE);
424
430
  const pool = userNonSui.length > 0 ? userNonSui : userChanges;
425
431
  let primary = pool[0];
426
432
  let primaryAbs = bigintAbs(BigInt(primary.amount));
@@ -601,6 +607,10 @@ function addFeeTransfer(tx, paymentCoin, feeBps, receiver, amount) {
601
607
  const [feeCoin] = tx.splitCoins(paymentCoin, [tx.pure.u64(rawFee)]);
602
608
  tx.transferObjects([feeCoin], tx.pure.address(receiver));
603
609
  }
610
+
611
+ // src/protocols/cetus-swap.ts
612
+ init_token_registry();
613
+ init_token_registry();
604
614
  var OVERLAY_FEE_RATE = 1e-3;
605
615
  var clientCache = /* @__PURE__ */ new Map();
606
616
  function getClient(walletAddress, overlayFee) {
@@ -712,40 +722,29 @@ var DEFAULT_SAFEGUARD_CONFIG = {
712
722
  dailyResetDate: ""
713
723
  };
714
724
 
725
+ // src/browser.ts
726
+ init_token_registry();
727
+
715
728
  exports.ALL_NAVI_ASSETS = ALL_NAVI_ASSETS;
716
729
  exports.BORROW_FEE_BPS = BORROW_FEE_BPS;
717
730
  exports.BPS_DENOMINATOR = BPS_DENOMINATOR;
718
731
  exports.CLOCK_ID = CLOCK_ID;
719
- exports.COIN_REGISTRY = COIN_REGISTRY;
720
732
  exports.DEFAULT_NETWORK = DEFAULT_NETWORK;
721
733
  exports.DEFAULT_SAFEGUARD_CONFIG = DEFAULT_SAFEGUARD_CONFIG;
722
- exports.ETH_TYPE = ETH_TYPE;
723
734
  exports.GAS_RESERVE_MIN = GAS_RESERVE_MIN;
724
- exports.IKA_TYPE = IKA_TYPE;
725
735
  exports.KNOWN_TARGETS = KNOWN_TARGETS;
726
736
  exports.KeypairSigner = KeypairSigner;
727
737
  exports.LABEL_PATTERNS = LABEL_PATTERNS;
728
- exports.LOFI_TYPE = LOFI_TYPE;
729
- exports.MANIFEST_TYPE = MANIFEST_TYPE;
730
738
  exports.MIST_PER_SUI = MIST_PER_SUI;
731
- exports.NAVX_TYPE = NAVX_TYPE;
732
739
  exports.OUTBOUND_OPS = OUTBOUND_OPS;
733
740
  exports.OVERLAY_FEE_RATE = OVERLAY_FEE_RATE;
734
741
  exports.SAVE_FEE_BPS = SAVE_FEE_BPS;
735
742
  exports.STABLE_ASSETS = STABLE_ASSETS;
736
743
  exports.SUI_DECIMALS = SUI_DECIMALS;
737
- exports.SUI_TYPE = SUI_TYPE;
738
744
  exports.SUPPORTED_ASSETS = SUPPORTED_ASSETS;
739
745
  exports.SafeguardError = SafeguardError;
740
746
  exports.T2000_OVERLAY_FEE_WALLET = T2000_OVERLAY_FEE_WALLET;
741
- exports.TOKEN_MAP = TOKEN_MAP;
742
747
  exports.USDC_DECIMALS = USDC_DECIMALS;
743
- exports.USDC_TYPE = USDC_TYPE;
744
- exports.USDE_TYPE = USDE_TYPE;
745
- exports.USDSUI_TYPE = USDSUI_TYPE;
746
- exports.USDT_TYPE = USDT_TYPE;
747
- exports.WAL_TYPE = WAL_TYPE;
748
- exports.WBTC_TYPE = WBTC_TYPE;
749
748
  exports.ZkLoginSigner = ZkLoginSigner;
750
749
  exports.addFeeTransfer = addFeeTransfer;
751
750
  exports.buildSwapTx = buildSwapTx;