@t2000/sdk 0.45.0 → 0.46.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/browser.js CHANGED
@@ -513,6 +513,172 @@ function truncateAddress(address) {
513
513
  return `${address.slice(0, 6)}...${address.slice(-4)}`;
514
514
  }
515
515
 
516
+ // src/token-registry.ts
517
+ var COIN_REGISTRY = {
518
+ // ── Tier 1 — Financial layer ──────────────────────────────────────────
519
+ USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
520
+ // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
521
+ SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
522
+ wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
523
+ ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
524
+ GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
525
+ DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
526
+ WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
527
+ NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
528
+ IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
529
+ CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
530
+ NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
531
+ vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
532
+ haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
533
+ afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
534
+ LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
535
+ MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
536
+ // ── Legacy — no tier, kept for display accuracy on existing positions ──
537
+ USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
538
+ USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
539
+ USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
540
+ };
541
+ var BY_TYPE = /* @__PURE__ */ new Map();
542
+ for (const meta of Object.values(COIN_REGISTRY)) {
543
+ BY_TYPE.set(meta.type, meta);
544
+ }
545
+ function isTier1(coinType) {
546
+ const meta = BY_TYPE.get(coinType);
547
+ return meta?.tier === 1;
548
+ }
549
+ function isTier2(coinType) {
550
+ const meta = BY_TYPE.get(coinType);
551
+ return meta?.tier === 2;
552
+ }
553
+ function isSupported(coinType) {
554
+ const meta = BY_TYPE.get(coinType);
555
+ return meta?.tier !== void 0;
556
+ }
557
+ function getTier(coinType) {
558
+ return BY_TYPE.get(coinType)?.tier;
559
+ }
560
+ function getDecimalsForCoinType(coinType) {
561
+ const direct = BY_TYPE.get(coinType);
562
+ if (direct) return direct.decimals;
563
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
564
+ if (suffix) {
565
+ for (const meta of BY_TYPE.values()) {
566
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
567
+ if (metaSuffix === suffix) return meta.decimals;
568
+ }
569
+ }
570
+ return 9;
571
+ }
572
+ function resolveSymbol(coinType) {
573
+ const direct = BY_TYPE.get(coinType);
574
+ if (direct) return direct.symbol;
575
+ const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
576
+ if (suffix) {
577
+ for (const meta of BY_TYPE.values()) {
578
+ const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
579
+ if (metaSuffix === suffix) return meta.symbol;
580
+ }
581
+ }
582
+ return coinType.split("::").pop() ?? coinType;
583
+ }
584
+ var TOKEN_MAP = (() => {
585
+ const map = {};
586
+ for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
587
+ map[name] = meta.type;
588
+ map[name.toUpperCase()] = meta.type;
589
+ }
590
+ return map;
591
+ })();
592
+ function resolveTokenType(nameOrType) {
593
+ if (nameOrType.includes("::")) return nameOrType;
594
+ return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
595
+ }
596
+ var SUI_TYPE = COIN_REGISTRY.SUI.type;
597
+ var USDC_TYPE = COIN_REGISTRY.USDC.type;
598
+ var USDT_TYPE = COIN_REGISTRY.USDT.type;
599
+ var USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
600
+ var USDE_TYPE = COIN_REGISTRY.USDe.type;
601
+ var ETH_TYPE = COIN_REGISTRY.ETH.type;
602
+ var WBTC_TYPE = COIN_REGISTRY.wBTC.type;
603
+ var WAL_TYPE = COIN_REGISTRY.WAL.type;
604
+ var NAVX_TYPE = COIN_REGISTRY.NAVX.type;
605
+ var IKA_TYPE = COIN_REGISTRY.IKA.type;
606
+ var LOFI_TYPE = COIN_REGISTRY.LOFI.type;
607
+ var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
608
+
609
+ // src/wallet/classify.ts
610
+ var KNOWN_TARGETS = [
611
+ [/::suilend|::obligation/, "lending"],
612
+ [/::navi|::lending_core|::incentive_v\d+|::oracle_pro/, "lending"],
613
+ [/::cetus|::pool/, "swap"],
614
+ [/::deepbook/, "swap"],
615
+ [/::transfer::public_transfer/, "send"]
616
+ ];
617
+ var LABEL_PATTERNS = [
618
+ [/::pay(?:ment_kit|_kit)?::|::create_payment_link|::pay_link/, "payment_link"],
619
+ [/::create_invoice|::invoice::/, "invoice"],
620
+ [/::deposit|::supply|::mint_ctokens/, "deposit"],
621
+ [/::withdraw|::redeem|::redeem_ctokens/, "withdraw"],
622
+ [/::borrow/, "borrow"],
623
+ [/::repay/, "repay"],
624
+ [/::claim_reward|::claim::|::claim_incentive/, "claim"],
625
+ [/::stake/, "stake"],
626
+ [/::unstake|::burn::/, "unstake"],
627
+ [/::liquidate/, "liquidate"]
628
+ ];
629
+ function resolveOwner(owner) {
630
+ if (typeof owner === "object" && owner.AddressOwner) return owner.AddressOwner;
631
+ if (typeof owner === "string") return owner;
632
+ return null;
633
+ }
634
+ function classifyAction(targets, commandTypes) {
635
+ for (const target of targets) {
636
+ for (const [pattern, label] of KNOWN_TARGETS) {
637
+ if (pattern.test(target)) return label;
638
+ }
639
+ }
640
+ if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
641
+ return "transaction";
642
+ }
643
+ function fallbackLabel(targets) {
644
+ if (!targets.length) return "on-chain";
645
+ const first = targets[0];
646
+ const parts = first.split("::");
647
+ if (parts.length >= 2 && parts[1]) return parts[1].toLowerCase();
648
+ return "on-chain";
649
+ }
650
+ function classifyLabel(targets, commandTypes) {
651
+ for (const target of targets) {
652
+ for (const [pattern, label] of LABEL_PATTERNS) {
653
+ if (pattern.test(target)) return label;
654
+ }
655
+ }
656
+ if (commandTypes.includes("TransferObjects") && !commandTypes.includes("MoveCall")) return "send";
657
+ return fallbackLabel(targets);
658
+ }
659
+ function refineLendingLabel(currentAction, currentLabel, moveCallTargets, changes, address) {
660
+ if (currentAction !== "lending") return currentLabel;
661
+ const labelMatchedSpecific = LABEL_PATTERNS.some(
662
+ ([p]) => moveCallTargets.some((t) => p.test(t))
663
+ );
664
+ if (labelMatchedSpecific) return currentLabel;
665
+ const userNonSuiOutflow = changes.find(
666
+ (c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) < 0n
667
+ );
668
+ if (userNonSuiOutflow) return "deposit";
669
+ const userNonSuiInflow = changes.find(
670
+ (c) => resolveOwner(c.owner) === address && c.coinType !== SUI_TYPE && BigInt(c.amount) > 0n
671
+ );
672
+ if (userNonSuiInflow) return "withdraw";
673
+ return currentLabel;
674
+ }
675
+ function classifyTransaction(moveCallTargets, commandTypes, balanceChanges, address) {
676
+ const action = classifyAction(moveCallTargets, commandTypes);
677
+ const baseLabel = classifyLabel(moveCallTargets, commandTypes);
678
+ const label = refineLendingLabel(action, baseLabel, moveCallTargets, balanceChanges, address);
679
+ return { action, label };
680
+ }
681
+
516
682
  // src/utils/format.ts
517
683
  function mistToSui(mist) {
518
684
  return Number(mist) / Number(MIST_PER_SUI);
@@ -635,99 +801,6 @@ var DEFAULT_SAFEGUARD_CONFIG = {
635
801
  dailyResetDate: ""
636
802
  };
637
803
 
638
- // src/token-registry.ts
639
- var COIN_REGISTRY = {
640
- // ── Tier 1 — Financial layer ──────────────────────────────────────────
641
- USDC: { type: "0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7::usdc::USDC", decimals: 6, symbol: "USDC", tier: 1 },
642
- // ── Tier 2 — Swap assets (15 tokens) ──────────────────────────────────
643
- SUI: { type: "0x2::sui::SUI", decimals: 9, symbol: "SUI", tier: 2 },
644
- wBTC: { type: "0x0041f9f9344cac094454cd574e333c4fdb132d7bcc9379bcd4aab485b2a63942::wbtc::WBTC", decimals: 8, symbol: "wBTC", tier: 2 },
645
- ETH: { type: "0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH", decimals: 8, symbol: "ETH", tier: 2 },
646
- GOLD: { type: "0x9d297676e7a4b771ab023291377b2adfaa4938fb9080b8d12430e4b108b836a9::xaum::XAUM", decimals: 9, symbol: "GOLD", tier: 2 },
647
- DEEP: { type: "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP", decimals: 6, symbol: "DEEP", tier: 2 },
648
- WAL: { type: "0x356a26eb9e012a68958082340d4c4116e7f55615cf27affcff209cf0ae544f59::wal::WAL", decimals: 9, symbol: "WAL", tier: 2 },
649
- NS: { type: "0x5145494a5f5100e645e4b0aa950fa6b68f614e8c59e17bc5ded3495123a79178::ns::NS", decimals: 6, symbol: "NS", tier: 2 },
650
- IKA: { type: "0x7262fb2f7a3a14c888c438a3cd9b912469a58cf60f367352c46584262e8299aa::ika::IKA", decimals: 9, symbol: "IKA", tier: 2 },
651
- CETUS: { type: "0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b::cetus::CETUS", decimals: 9, symbol: "CETUS", tier: 2 },
652
- NAVX: { type: "0xa99b8952d4f7d947ea77fe0ecdcc9e5fc0bcab2841d6e2a5aa00c3044e5544b5::navx::NAVX", decimals: 9, symbol: "NAVX", tier: 2 },
653
- vSUI: { type: "0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55::cert::CERT", decimals: 9, symbol: "vSUI", tier: 2 },
654
- haSUI: { type: "0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d::hasui::HASUI", decimals: 9, symbol: "haSUI", tier: 2 },
655
- afSUI: { type: "0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc::afsui::AFSUI", decimals: 9, symbol: "afSUI", tier: 2 },
656
- LOFI: { type: "0xf22da9a24ad027cccb5f2d496cbe91de953d363513db08a3a734d361c7c17503::LOFI::LOFI", decimals: 9, symbol: "LOFI", tier: 2 },
657
- MANIFEST: { type: "0xc466c28d87b3d5cd34f3d5c088751532d71a38d93a8aae4551dd56272cfb4355::manifest::MANIFEST", decimals: 9, symbol: "MANIFEST", tier: 2 },
658
- // ── Legacy — no tier, kept for display accuracy on existing positions ──
659
- USDT: { type: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT", decimals: 6, symbol: "USDT" },
660
- USDe: { type: "0x41d587e5336f1c86cad50d38a7136db99333bb9bda91cea4ba69115defeb1402::sui_usde::SUI_USDE", decimals: 6, symbol: "USDe" },
661
- USDSUI: { type: "0x44f838219cf67b058f3b37907b655f226153c18e33dfcd0da559a844fea9b1c1::usdsui::USDSUI", decimals: 6, symbol: "USDsui" }
662
- };
663
- var BY_TYPE = /* @__PURE__ */ new Map();
664
- for (const meta of Object.values(COIN_REGISTRY)) {
665
- BY_TYPE.set(meta.type, meta);
666
- }
667
- function isTier1(coinType) {
668
- const meta = BY_TYPE.get(coinType);
669
- return meta?.tier === 1;
670
- }
671
- function isTier2(coinType) {
672
- const meta = BY_TYPE.get(coinType);
673
- return meta?.tier === 2;
674
- }
675
- function isSupported(coinType) {
676
- const meta = BY_TYPE.get(coinType);
677
- return meta?.tier !== void 0;
678
- }
679
- function getTier(coinType) {
680
- return BY_TYPE.get(coinType)?.tier;
681
- }
682
- function getDecimalsForCoinType(coinType) {
683
- const direct = BY_TYPE.get(coinType);
684
- if (direct) return direct.decimals;
685
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
686
- if (suffix) {
687
- for (const meta of BY_TYPE.values()) {
688
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
689
- if (metaSuffix === suffix) return meta.decimals;
690
- }
691
- }
692
- return 9;
693
- }
694
- function resolveSymbol(coinType) {
695
- const direct = BY_TYPE.get(coinType);
696
- if (direct) return direct.symbol;
697
- const suffix = coinType.split("::").slice(1).join("::").toUpperCase();
698
- if (suffix) {
699
- for (const meta of BY_TYPE.values()) {
700
- const metaSuffix = meta.type.split("::").slice(1).join("::").toUpperCase();
701
- if (metaSuffix === suffix) return meta.symbol;
702
- }
703
- }
704
- return coinType.split("::").pop() ?? coinType;
705
- }
706
- var TOKEN_MAP = (() => {
707
- const map = {};
708
- for (const [name, meta] of Object.entries(COIN_REGISTRY)) {
709
- map[name] = meta.type;
710
- map[name.toUpperCase()] = meta.type;
711
- }
712
- return map;
713
- })();
714
- function resolveTokenType(nameOrType) {
715
- if (nameOrType.includes("::")) return nameOrType;
716
- return TOKEN_MAP[nameOrType] ?? TOKEN_MAP[nameOrType.toUpperCase()] ?? null;
717
- }
718
- var SUI_TYPE = COIN_REGISTRY.SUI.type;
719
- var USDC_TYPE = COIN_REGISTRY.USDC.type;
720
- var USDT_TYPE = COIN_REGISTRY.USDT.type;
721
- var USDSUI_TYPE = COIN_REGISTRY.USDSUI.type;
722
- var USDE_TYPE = COIN_REGISTRY.USDe.type;
723
- var ETH_TYPE = COIN_REGISTRY.ETH.type;
724
- var WBTC_TYPE = COIN_REGISTRY.wBTC.type;
725
- var WAL_TYPE = COIN_REGISTRY.WAL.type;
726
- var NAVX_TYPE = COIN_REGISTRY.NAVX.type;
727
- var IKA_TYPE = COIN_REGISTRY.IKA.type;
728
- var LOFI_TYPE = COIN_REGISTRY.LOFI.type;
729
- var MANIFEST_TYPE = COIN_REGISTRY.MANIFEST.type;
730
-
731
- export { ALL_NAVI_ASSETS, BPS_DENOMINATOR, CLOCK_ID, COIN_REGISTRY, DEFAULT_NETWORK, DEFAULT_SAFEGUARD_CONFIG, ETH_TYPE, GAS_RESERVE_MIN, IKA_TYPE, KeypairSigner, LOFI_TYPE, MANIFEST_TYPE, MIST_PER_SUI, NAVX_TYPE, OUTBOUND_OPS, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, calculateFee, executeAutoTopUp, executeWithGas, formatAssetAmount, formatSui, formatUsd, fromBase64, getDecimals, getDecimalsForCoinType, getGasStatus, getTier, isSupported, isTier1, isTier2, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, resolveSymbol, resolveTokenType, shouldAutoTopUp, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
804
+ export { ALL_NAVI_ASSETS, 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, STABLE_ASSETS, SUI_DECIMALS, SUI_TYPE, SUPPORTED_ASSETS, SafeguardError, T2000Error, TOKEN_MAP, USDC_DECIMALS, USDC_TYPE, USDE_TYPE, USDSUI_TYPE, USDT_TYPE, WAL_TYPE, WBTC_TYPE, ZkLoginSigner, addCollectFeeToTx, calculateFee, classifyAction, classifyLabel, classifyTransaction, executeAutoTopUp, executeWithGas, fallbackLabel, formatAssetAmount, formatSui, formatUsd, fromBase64, getDecimals, getDecimalsForCoinType, getGasStatus, getTier, isSupported, isTier1, isTier2, mapMoveAbortCode, mapWalletError, mistToSui, rawToStable, rawToUsdc, refineLendingLabel, resolveSymbol, resolveTokenType, shouldAutoTopUp, stableToRaw, suiToMist, toBase64, truncateAddress, usdcToRaw, validateAddress };
732
805
  //# sourceMappingURL=browser.js.map
733
806
  //# sourceMappingURL=browser.js.map