@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.js CHANGED
@@ -101,6 +101,104 @@ var init_errors = __esm({
101
101
  }
102
102
  });
103
103
 
104
+ // src/token-registry.ts
105
+ function isTier1(coinType) {
106
+ const meta = BY_TYPE.get(coinType);
107
+ return meta?.tier === 1;
108
+ }
109
+ function isTier2(coinType) {
110
+ const meta = BY_TYPE.get(coinType);
111
+ return meta?.tier === 2;
112
+ }
113
+ function isSupported(coinType) {
114
+ const meta = BY_TYPE.get(coinType);
115
+ return meta?.tier !== void 0;
116
+ }
117
+ function getTier(coinType) {
118
+ return BY_TYPE.get(coinType)?.tier;
119
+ }
120
+ function getDecimalsForCoinType(coinType) {
121
+ const direct = BY_TYPE.get(coinType);
122
+ if (direct) return direct.decimals;
123
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
124
+ if (suffix) {
125
+ for (const meta of BY_TYPE.values()) {
126
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
127
+ if (metaSuffix === suffix) return meta.decimals;
128
+ }
129
+ }
130
+ return 9;
131
+ }
132
+ function resolveSymbol(coinType) {
133
+ const direct = BY_TYPE.get(coinType);
134
+ if (direct) return direct.symbol;
135
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
136
+ if (suffix) {
137
+ for (const meta of BY_TYPE.values()) {
138
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
139
+ if (metaSuffix === suffix) return meta.symbol;
140
+ }
141
+ }
142
+ return coinType.split("::").pop() ?? coinType;
143
+ }
144
+ function resolveTokenType(nameOrType) {
145
+ if (nameOrType.includes("::")) return nameOrType;
146
+ return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
147
+ }
148
+ var COIN_REGISTRY, BY_TYPE, TOKEN_MAP, SUI_TYPE, USDC_TYPE, USDT_TYPE, USDSUI_TYPE, USDE_TYPE, ETH_TYPE, WBTC_TYPE, WAL_TYPE, NAVX_TYPE, IKA_TYPE, LOFI_TYPE, MANIFEST_TYPE;
149
+ var init_token_registry = __esm({
150
+ "src/token-registry.ts"() {
151
+ COIN_REGISTRY = {
152
+ // ── Tier 1 — Financial layer ──────────────────────────────────────────
153
+ USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
154
+ // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
155
+ SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
156
+ wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
157
+ ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
158
+ GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
159
+ DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
160
+ WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
161
+ NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
162
+ IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
163
+ CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
164
+ NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
165
+ vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
166
+ haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
167
+ afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
168
+ LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
169
+ MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
170
+ // ── Legacy — no tier, kept for display accuracy on existing positions ──
171
+ USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
172
+ USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
173
+ USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
174
+ };
175
+ BY_TYPE = /* @__PURE__ */ new Map();
176
+ for (const meta of Object.values(COIN_REGISTRY)) {
177
+ BY_TYPE.set(meta.type, meta);
178
+ }
179
+ TOKEN_MAP = (() => {
180
+ const map = {};
181
+ for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
182
+ map[name] = meta.type;
183
+ map[name.toUpperCase()] = meta.type;
184
+ }
185
+ return map;
186
+ })();
187
+ SUI_TYPE = COIN_REGISTRY.SUI.type;
188
+ USDC_TYPE = COIN_REGISTRY.USDC.type;
189
+ USDT_TYPE = COIN_REGISTRY.USDT.type;
190
+ USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
191
+ USDE_TYPE = COIN_REGISTRY.USDe.type;
192
+ ETH_TYPE = COIN_REGISTRY.ETH.type;
193
+ WBTC_TYPE = COIN_REGISTRY.wBTC.type;
194
+ WAL_TYPE = COIN_REGISTRY.WAL.type;
195
+ NAVX_TYPE = COIN_REGISTRY.NAVX.type;
196
+ IKA_TYPE = COIN_REGISTRY.IKA.type;
197
+ LOFI_TYPE = COIN_REGISTRY.LOFI.type;
198
+ MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
199
+ }
200
+ });
201
+
104
202
  // src/wallet/keypairSigner.ts
105
203
  var KeypairSigner = class {
106
204
  constructor(keypair) {
@@ -232,100 +330,8 @@ function truncateAddress(address) {
232
330
  return `${address.slice(0, 6)}...${address.slice(-4)}`;
233
331
  }
234
332
 
235
- // src/token-registry.ts
236
- var COIN_REGISTRY = {
237
- // ── Tier 1 — Financial layer ──────────────────────────────────────────
238
- USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
239
- // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
240
- SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
241
- wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
242
- ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
243
- GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
244
- DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
245
- WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
246
- NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
247
- IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
248
- CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
249
- NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
250
- vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
251
- haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
252
- afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
253
- LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
254
- MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
255
- // ── Legacy — no tier, kept for display accuracy on existing positions ──
256
- USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
257
- USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
258
- USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
259
- };
260
- var BY_TYPE = /* @__PURE__ */ new Map();
261
- for (const meta of Object.values(COIN_REGISTRY)) {
262
- BY_TYPE.set(meta.type, meta);
263
- }
264
- function isTier1(coinType) {
265
- const meta = BY_TYPE.get(coinType);
266
- return meta?.tier === 1;
267
- }
268
- function isTier2(coinType) {
269
- const meta = BY_TYPE.get(coinType);
270
- return meta?.tier === 2;
271
- }
272
- function isSupported(coinType) {
273
- const meta = BY_TYPE.get(coinType);
274
- return meta?.tier !== void 0;
275
- }
276
- function getTier(coinType) {
277
- return BY_TYPE.get(coinType)?.tier;
278
- }
279
- function getDecimalsForCoinType(coinType) {
280
- const direct = BY_TYPE.get(coinType);
281
- if (direct) return direct.decimals;
282
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
283
- if (suffix) {
284
- for (const meta of BY_TYPE.values()) {
285
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
286
- if (metaSuffix === suffix) return meta.decimals;
287
- }
288
- }
289
- return 9;
290
- }
291
- function resolveSymbol(coinType) {
292
- const direct = BY_TYPE.get(coinType);
293
- if (direct) return direct.symbol;
294
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
295
- if (suffix) {
296
- for (const meta of BY_TYPE.values()) {
297
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
298
- if (metaSuffix === suffix) return meta.symbol;
299
- }
300
- }
301
- return coinType.split("::").pop() ?? coinType;
302
- }
303
- var TOKEN_MAP = (() => {
304
- const map = {};
305
- for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
306
- map[name] = meta.type;
307
- map[name.toUpperCase()] = meta.type;
308
- }
309
- return map;
310
- })();
311
- function resolveTokenType(nameOrType) {
312
- if (nameOrType.includes("::")) return nameOrType;
313
- return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
314
- }
315
- var SUI_TYPE = COIN_REGISTRY.SUI.type;
316
- var USDC_TYPE = COIN_REGISTRY.USDC.type;
317
- var USDT_TYPE = COIN_REGISTRY.USDT.type;
318
- var USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
319
- var USDE_TYPE = COIN_REGISTRY.USDe.type;
320
- var ETH_TYPE = COIN_REGISTRY.ETH.type;
321
- var WBTC_TYPE = COIN_REGISTRY.wBTC.type;
322
- var WAL_TYPE = COIN_REGISTRY.WAL.type;
323
- var NAVX_TYPE = COIN_REGISTRY.NAVX.type;
324
- var IKA_TYPE = COIN_REGISTRY.IKA.type;
325
- var LOFI_TYPE = COIN_REGISTRY.LOFI.type;
326
- var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
327
-
328
333
  // src/wallet/classify.ts
334
+ init_token_registry();
329
335
  var KNOWN_TARGETS = [
330
336
  [/::suilend|::obligation/, "lending"],
331
337
  [/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
@@ -599,6 +605,10 @@ function addFeeTransfer(tx, paymentCoin, feeBps, receiver, amount) {
599
605
  const [feeCoin] = tx.splitCoins(paymentCoin, [tx.pure.u64(rawFee)]);
600
606
  tx.transferObjects([feeCoin], tx.pure.address(receiver));
601
607
  }
608
+
609
+ // src/protocols/cetus-swap.ts
610
+ init_token_registry();
611
+ init_token_registry();
602
612
  var OVERLAY_FEE_RATE = 1e-3;
603
613
  var clientCache = /* @__PURE__ */ new Map();
604
614
  function getClient(walletAddress, overlayFee) {
@@ -710,6 +720,9 @@ var DEFAULT_SAFEGUARD_CONFIG = {
710
720
  dailyResetDate: ""
711
721
  };
712
722
 
723
+ // src/browser.ts
724
+ init_token_registry();
725
+
713
726
  export { ALL_NAVI_ASSETS, BORROW_FEE_BPS, BPS_DENOMINATOR, CLOCK_ID, COIN_REGISTRY, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, KNOWN_TARGETS, KeypairSigner, LABEL_PATTERNS, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OUTBOUND_OPS, OVERLAY_FEE_RATE, SAVE_FEE_BPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, T2000_OVERLAY_FEE_WALLET, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addFeeTransfer, buildSwapTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, extractTransferDetails, extractTxCommands, extractTxSender, fallbackLabel, findSwapRoute, formatAssetAmount, formatSui, formatUsd, fromBase64, getDecimals, getDecimalsForCoinType, getTier, isSupported, isTier1, isTier2, mapMoveAbortCode, mapWalletError, mistToSui, parseSuiRpcTx, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
714
727
  //# sourceMappingURL=browser.js.map
715
728
  //# sourceMappingURL=browser.js.map