@swapkit/core 1.0.0-rc.5 → 1.0.0-rc.51

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.es.js CHANGED
@@ -1,16 +1,16 @@
1
- var Ce = Object.defineProperty;
2
- var Ne = (e, t, n) => t in e ? Ce(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var T = (e, t, n) => (Ne(e, typeof t != "symbol" ? t + "" : t, n), n), De = (e, t, n) => {
1
+ var qe = Object.defineProperty;
2
+ var We = (e, t, n) => t in e ? qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var T = (e, t, n) => (We(e, typeof t != "symbol" ? t + "" : t, n), n), je = (e, t, n) => {
4
4
  if (!t.has(e))
5
5
  throw TypeError("Cannot " + n);
6
6
  };
7
- var A = (e, t, n) => (De(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
7
+ var f = (e, t, n) => (je(e, t, "read from private field"), n ? n.call(e) : t.get(e)), P = (e, t, n) => {
8
8
  if (t.has(e))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
10
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
11
11
  };
12
- var xe = Object.defineProperty, Pe = (e, t, n) => t in e ? xe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Pe(e, typeof t != "symbol" ? t + "" : t, n), n);
13
- const Lt = [
12
+ var Ke = Object.defineProperty, Ye = (e, t, n) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, C = (e, t, n) => (Ye(e, typeof t != "symbol" ? t + "" : t, n), n);
13
+ const fn = [
14
14
  { inputs: [], stateMutability: "nonpayable", type: "constructor" },
15
15
  {
16
16
  anonymous: !1,
@@ -108,7 +108,7 @@ const Lt = [
108
108
  stateMutability: "nonpayable",
109
109
  type: "function"
110
110
  }
111
- ], Be = [
111
+ ], Xe = [
112
112
  {
113
113
  inputs: [{ internalType: "address", name: "rune", type: "address" }],
114
114
  stateMutability: "nonpayable",
@@ -283,7 +283,7 @@ const Lt = [
283
283
  stateMutability: "view",
284
284
  type: "function"
285
285
  }
286
- ], Ve = [
286
+ ], Je = [
287
287
  { inputs: [], stateMutability: "nonpayable", type: "constructor" },
288
288
  {
289
289
  anonymous: !1,
@@ -447,7 +447,7 @@ const Lt = [
447
447
  stateMutability: "view",
448
448
  type: "function"
449
449
  }
450
- ], Le = [
450
+ ], Qe = [
451
451
  { inputs: [], stateMutability: "nonpayable", type: "constructor" },
452
452
  {
453
453
  anonymous: !1,
@@ -600,13 +600,13 @@ const Lt = [
600
600
  type: "function"
601
601
  }
602
602
  ];
603
- var Ue = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(Ue || {});
604
- const He = [
603
+ var ze = /* @__PURE__ */ ((e) => (e.TC_SUPPORTED_TO_TC_SUPPORTED = "TC-TC", e.TC_SUPPORTED_TO_ETH = "TC-ERC20", e.TC_SUPPORTED_TO_AVAX = "TC-ARC20", e.TC_SUPPORTED_TO_BSC = "TC-BEP20", e.ETH_TO_TC_SUPPORTED = "ERC20-TC", e.ETH_TO_ETH = "ERC20-ERC20", e.ETH_TO_AVAX = "ERC20-ARC20", e.ETH_TO_BSC = "ERC20-BEP20", e.AVAX_TO_TC_SUPPORTED = "ARC20-TC", e.AVAX_TO_ETH = "ARC20-ERC20", e.AVAX_TO_AVAX = "ARC20-ARC20", e.AVAX_TO_BSC = "ARC20-BEP20", e.BSC_TO_TC_SUPPORTED = "BEP20-TC", e.BSC_TO_ETH = "BEP20-ERC20", e.BSC_TO_AVAX = "BEP20-ARC20", e.BSC_TO_BSC = "BEP20-BEP20", e))(ze || {});
604
+ const Ze = [
605
605
  "ERC20-ERC20",
606
606
  "ARC20-ARC20",
607
607
  "BEP20-BEP20"
608
608
  /* BSC_TO_BSC */
609
- ], $e = [
609
+ ], et = [
610
610
  "ERC20-TC",
611
611
  "ERC20-ARC20",
612
612
  "ERC20-BEP20",
@@ -617,95 +617,95 @@ const He = [
617
617
  "BEP20-ERC20",
618
618
  "BEP20-ARC20"
619
619
  /* BSC_TO_AVAX */
620
- ], ke = [
620
+ ], tt = [
621
621
  "TC-TC",
622
622
  "TC-ERC20",
623
623
  "TC-ARC20",
624
624
  "TC-BEP20"
625
625
  /* TC_SUPPORTED_TO_BSC */
626
626
  ];
627
- var Ae = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(Ae || {}), Fe = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(Fe || {}), o = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(o || {});
628
- const Ge = {
629
- [o.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
630
- [o.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
631
- [o.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
632
- [o.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
633
- [o.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
634
- [o.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
635
- [o.INVALID_TYPE_GENERIC]: "Invalid type",
636
- [o.INVALID_NUMBER_STRING]: "Invalid number string.",
637
- [o.INVALID_NUMBER]: "Invalid number.",
638
- [o.INVALID_BOOLEAN]: "Invalid boolean.",
639
- [o.INVALID_OBJECT]: "Invalid object.",
640
- [o.INVALID_ARRAY]: "Invalid array.",
641
- [o.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
642
- [o.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
643
- [o.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
644
- [o.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
645
- [o.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
646
- [o.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
647
- [o.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
648
- [o.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
649
- [o.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
650
- [o.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
651
- [o.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
652
- [o.INVALID_PROVIDER]: "Invalid provider {0}.",
653
- [o.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
654
- [o.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
655
- [o.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
656
- [o.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
657
- [o.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
658
- [o.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
659
- [o.INVALID_CHAIN]: "Invalid chain {0}.",
660
- [o.INVALID_ASSET]: "Invalid asset {0}.",
661
- [o.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
662
- [o.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
663
- [o.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
664
- [o.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
665
- [o.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
666
- [o.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
667
- [o.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
668
- [o.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
669
- [o.INVALID_QUOTE_MODE]: "Invalid quote mode.",
670
- [o.NO_QUOTES]: "No quotes to service this request.",
671
- [o.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
672
- [o.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
673
- [o.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
674
- [o.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
675
- [o.NO_PRICE]: "No price for asset {0}.",
676
- [o.PRICE_IS_STALE]: "Price is stale for asset {0}.",
677
- [o.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
678
- [o.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
679
- }, ae = (e, t) => {
680
- let n = Ge[e];
627
+ var ve = /* @__PURE__ */ ((e) => (e.VALIDATION_ERROR = "VALIDATION_ERROR", e.REQUEST_PARAMETER_ERROR = "REQUEST_PARAMETER_ERROR", e.RESPONSE_PARSING_ERROR = "RESPONSE_PARSING_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.NOT_IMPLEMENTED = "NOT_IMPLEMENTED", e.INCOMPATIBLE_ASSETS_OPERATIONS = "INCOMPATIBLE_ASSETS_OPERATIONS", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.DOWN_FOR_MAINTENANCE = "DOWN_FOR_MAINTENANCE", e.MISSING_INBOUND_INFO = "MISSING_INBOUND_INFO", e.QUOTE_FETCHING_ERROR = "QUOTE_FETCHING_ERROR", e.AIRDROP_ERROR = "AIRDROP_ERROR", e.UNHANDLED_ERROR = "UNHANDLED_ERROR", e))(ve || {}), nt = /* @__PURE__ */ ((e) => (e.HEALTH_CONTROLLER = "1000", e.LIQUIDITY_CONTROLLER = "1001", e.PROVIDER_CONTROLLER = "1002", e.QUOTE_CONTROLLER = "1003", e.SWAP_CONTROLLER = "1004", e.UTIL_CONTROLLER = "1005", e.AIRDROP_CONTROLLER = "1006", e.PROVIDER = "2000", e.ASSET = "2001", e.TOKEN_LIST = "2002", e.QUOTE = "2100", e.QUOTE_TXN_DETAILS = "2101", e.THORCHAIN_PROVIDER = "3000", e.UNISWAPV2_ETH_PROVIDER = "3001", e.UNISWAPV3_ETH_PROVIDER = "3002", e.SUSHISWAP_ETH_PROVIDER = "3003", e.PANCAKESWAP_BSC_PROVIDER = "3004", e.PANCAKESWAP_ETH_PROVIDER = "3005", e.ONEINCH_ETH_PROVIDER = "3006", e.ONEINCH_BSC_PROVIDER = "3007", e.ONEINCH_AVAX_PROVIDER = "3008", e.ZEROX_ETH_PROVIDER = "3009", e.WOOFI_AVAX_PROVIDER = "3010", e.PANGOLIN_AVAX_PROVIDER = "3011", e.TRADERJOE_AVAX_PROVIDER = "3012", e.KYBER_ETH_PROVIDER = "3013", e.KYBER_AVAX_PROVIDER = "3014", e.WOOFI_BSC_PROVIDER = "3015", e.STARGATE_PROVIDER = "3016", e.PROVIDER_UTIL = "4000", e.TXN_DETAILS = "5000", e.AIRDROP_UTIL = "6000", e))(nt || {}), y = /* @__PURE__ */ ((e) => (e.INVALID_INPUT_PARAMETERS = "1000", e.UNKNOWN_PROVIDERS = "1001", e.CANNOT_FIND_INBOUND_ADDRESS = "1002", e.NO_INBOUND_ADDRESSES = "1003", e.CHAIN_HALTED_OR_UNSUPPORTED = "1004", e.MISSING_INPUT_PARAMETER = "1005", e.INVALID_TYPE_GENERIC = "1100", e.INVALID_NUMBER_STRING = "1101", e.INVALID_NUMBER = "1102", e.INVALID_BOOLEAN = "1103", e.INVALID_OBJECT = "1104", e.INVALID_ARRAY = "1105", e.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2000", e.SELL_BUY_ASSETS_ARE_THE_SAME = "2001", e.MISSING_SOURCE_ADDRESS_FOR_SYNTH = "2002", e.AFF_ADDRESS_AND_BPS_OR_NEITHER = "2003", e.AFF_ADDRESS_TOO_LONG = "2004", e.AFF_BPS_INTEGER_0_100 = "2005", e.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN = "2006", e.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN = "2007", e.PREFERRED_PROFVIDER_NOT_SUPPORTED = "2008", e.DESTINATION_ADDRESS_SMART_CONTRACT = "2009", e.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER = "2010", e.SOURCE_ADDRESS_SMART_CONTRACT = "2011", e.INVALID_PROVIDER = "2100", e.MISSING_CROSS_CHAIN_PROVIDER = "2101", e.MISSING_AVAX_PROVIDER = "2102", e.MISSING_BSC_PROVIDER = "2103", e.MISSING_ETH_PROVIDER = "2104", e.INVALID_PROVIDER_FOR_SWAP_OUT = "2105", e.MISSING_ARB_PROVIDER = "2106", e.INVALID_CHAIN = "2200", e.INVALID_ASSET = "2201", e.INVALID_ASSET_IDENTIFIER = "2202", e.UNSUPPORTED_CHAIN = "2204", e.UNSUPPORTED_ASSET = "2203", e.UNSUPPORTED_ASSET_FOR_SWAPOUT = "2205", e.INVALID_SOURCE_ADDRESS = "2300", e.INVALID_DESTINATION_ADDRESS = "2301", e.THORNODE_QUOTE_GENERIC_ERROR = "3000", e.NOT_ENOUGH_SYNTH_BALANCE = "3001", e.SYNTH_MINTING_CAP_REACHED = "3002", e.INVALID_QUOTE_MODE = "4000", e.NO_QUOTES = "4001", e.SERVICE_UNAVAILABLE_GENERIC = "5000", e.MISSING_GAS_DATA_GENERIC = "5100", e.MISSING_TOKEN_INFO_GENERIC = "5200", e.CANT_FIND_TOKEN_LIST = "5201", e.NO_PRICE = "5202", e.PRICE_IS_STALE = "5203", e.ADDRESS_NOT_WHITELISTED = "6000", e.ADDRESS_ALREADY_CLAIMED = "6001", e.TEMPORARY_ERROR = "9999", e))(y || {});
628
+ const at = {
629
+ [y.INVALID_INPUT_PARAMETERS]: "Invalid input parameters: {0}.",
630
+ [y.UNKNOWN_PROVIDERS]: "Unknown providers: {0}.",
631
+ [y.CANNOT_FIND_INBOUND_ADDRESS]: "Cannot find inbound address.",
632
+ [y.NO_INBOUND_ADDRESSES]: "No inbound addresses.",
633
+ [y.CHAIN_HALTED_OR_UNSUPPORTED]: "Chain {0} halted or unsupported.",
634
+ [y.MISSING_INPUT_PARAMETER]: "Missing input parameter: {0}.",
635
+ [y.INVALID_TYPE_GENERIC]: "Invalid type",
636
+ [y.INVALID_NUMBER_STRING]: "Invalid number string.",
637
+ [y.INVALID_NUMBER]: "Invalid number.",
638
+ [y.INVALID_BOOLEAN]: "Invalid boolean.",
639
+ [y.INVALID_OBJECT]: "Invalid object.",
640
+ [y.INVALID_ARRAY]: "Invalid array.",
641
+ [y.SELL_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Sell amount must be a positive integer.",
642
+ [y.SELL_BUY_ASSETS_ARE_THE_SAME]: "Sell and buy assets are the same.",
643
+ [y.MISSING_SOURCE_ADDRESS_FOR_SYNTH]: "Source address is required for synth quote.",
644
+ [y.AFF_ADDRESS_AND_BPS_OR_NEITHER]: "Must provide affiliateAddress and affiliateBasisPoints params, or neither.",
645
+ [y.AFF_ADDRESS_TOO_LONG]: "affiliateAddress too long: 3 characters max.",
646
+ [y.AFF_BPS_INTEGER_0_100]: "affiliateBasisPoints must be an integer between 0 and 100.",
647
+ [y.SOURCE_ADDRESS_INVALID_FOR_SELL_CHAIN]: "Source address {0} invalid for sell chain.",
648
+ [y.DESTINATION_ADDRESS_INVALID_FOR_BUY_CHAIN]: "Destination address {0} invalid for buy chain.",
649
+ [y.PREFERRED_PROFVIDER_NOT_SUPPORTED]: "Preferred provider not supported.",
650
+ [y.DESTINATION_ADDRESS_SMART_CONTRACT]: "Destination address is a smart contract.",
651
+ [y.BUY_AMOUNT_MUST_BE_POSITIVE_INTEGER]: "Buy amount must be a positive integer.",
652
+ [y.INVALID_PROVIDER]: "Invalid provider {0}.",
653
+ [y.MISSING_CROSS_CHAIN_PROVIDER]: "Missing cross-chain provider.",
654
+ [y.MISSING_AVAX_PROVIDER]: "Missing AVAX provider.",
655
+ [y.MISSING_BSC_PROVIDER]: "Missing BSC provider.",
656
+ [y.MISSING_ETH_PROVIDER]: "Missing ETH provider.",
657
+ [y.MISSING_ARB_PROVIDER]: "Missing ARB provider.",
658
+ [y.INVALID_PROVIDER_FOR_SWAP_OUT]: "Invalid provider for swap out.",
659
+ [y.INVALID_CHAIN]: "Invalid chain {0}.",
660
+ [y.INVALID_ASSET]: "Invalid asset {0}.",
661
+ [y.UNSUPPORTED_CHAIN]: "Unsupported chain {0}.",
662
+ [y.UNSUPPORTED_ASSET]: "Unsupported asset {0}.",
663
+ [y.UNSUPPORTED_ASSET_FOR_SWAPOUT]: "Unsupported asset {0} for swap out.",
664
+ [y.THORNODE_QUOTE_GENERIC_ERROR]: "ThorNode quote generic error.",
665
+ [y.INVALID_SOURCE_ADDRESS]: "Invalid source address {0}",
666
+ [y.INVALID_DESTINATION_ADDRESS]: "Invalid destination address {0}",
667
+ [y.NOT_ENOUGH_SYNTH_BALANCE]: "Source address doesn't have enough synth balance for this quote.",
668
+ [y.SYNTH_MINTING_CAP_REACHED]: "Synth minting cap reached.",
669
+ [y.INVALID_QUOTE_MODE]: "Invalid quote mode.",
670
+ [y.NO_QUOTES]: "No quotes to service this request.",
671
+ [y.SERVICE_UNAVAILABLE_GENERIC]: "Service unavailable.",
672
+ [y.MISSING_GAS_DATA_GENERIC]: "Missing gas data.",
673
+ [y.MISSING_TOKEN_INFO_GENERIC]: "Missing token info.",
674
+ [y.CANT_FIND_TOKEN_LIST]: "Can't find tokenlist {0}.",
675
+ [y.NO_PRICE]: "No price for asset {0}.",
676
+ [y.PRICE_IS_STALE]: "Price is stale for asset {0}.",
677
+ [y.ADDRESS_NOT_WHITELISTED]: "Address {0} not whitelisted for airdrop.",
678
+ [y.ADDRESS_ALREADY_CLAIMED]: "Address {0} already claimed the airdrop."
679
+ }, re = (e, t) => {
680
+ let n = at[e];
681
681
  for (let a = 0; a < t.length; a++)
682
682
  n = n.replace(`{${a}}`, t[a]);
683
683
  return t.length === 0 ? n.replace("{0}", "") : n;
684
684
  };
685
- let Ut = class we extends Error {
685
+ let bn = class Ce extends Error {
686
686
  constructor({
687
687
  status: t,
688
688
  revision: n,
689
689
  module: a,
690
- code: i,
690
+ code: s,
691
691
  message: r,
692
- type: p,
693
- options: { shouldLog: d, shouldThrow: l, shouldTrace: c } = {
692
+ type: o,
693
+ options: { shouldLog: p, shouldThrow: d, shouldTrace: l } = {
694
694
  shouldLog: !0,
695
695
  shouldThrow: !0,
696
696
  shouldTrace: !0
697
697
  },
698
- displayMessageParams: y
698
+ displayMessageParams: u
699
699
  }) {
700
- const u = r || ae(i, y || []) || "";
701
- super(u), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = u, this.display = ae(i, y || []), this.code = i, this.type = p || Ae.UNHANDLED_ERROR, this.options = {
702
- shouldLog: d || !0,
703
- shouldTrace: c || !0,
704
- shouldThrow: l || !1
705
- }, this.displayMessageParams = y || [], this.options.shouldTrace && Error.captureStackTrace(this);
700
+ const c = r || re(s, u || []) || "";
701
+ super(c), C(this, "status"), C(this, "revision"), C(this, "type"), C(this, "module"), C(this, "code"), C(this, "message"), C(this, "display"), C(this, "stack"), C(this, "options"), C(this, "displayMessageParams"), this.status = t, this.revision = n || "NO_REVISION", this.module = a, this.message = c, this.display = re(s, u || []), this.code = s, this.type = o || ve.UNHANDLED_ERROR, this.options = {
702
+ shouldLog: p || !0,
703
+ shouldTrace: l || !0,
704
+ shouldThrow: d || !1
705
+ }, this.displayMessageParams = u || [], this.options.shouldTrace && Error.captureStackTrace(this);
706
706
  }
707
707
  static fromErrorInfo(t) {
708
- return new we(t);
708
+ return new Ce(t);
709
709
  }
710
710
  toErrorInfo() {
711
711
  return { ...this, identifier: this.identifier };
@@ -714,7 +714,7 @@ let Ut = class we extends Error {
714
714
  return `${this.revision}-${this.type || "NO_TYPE"}-${this.module}-${this.code}`;
715
715
  }
716
716
  get displayMessage() {
717
- return ae(this.code, this.displayMessageParams || []);
717
+ return re(this.code, this.displayMessageParams || []);
718
718
  }
719
719
  handle() {
720
720
  const t = `[${this.identifier}]: ${this.message}`;
@@ -724,8 +724,8 @@ let Ut = class we extends Error {
724
724
  return this.toErrorInfo();
725
725
  }
726
726
  };
727
- var s = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(s || {}), We = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(We || {}), qe = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(qe || {});
728
- const Ht = {
727
+ var i = /* @__PURE__ */ ((e) => (e.Arbitrum = "ARB", e.Avalanche = "AVAX", e.Binance = "BNB", e.BinanceSmartChain = "BSC", e.Bitcoin = "BTC", e.BitcoinCash = "BCH", e.Cosmos = "GAIA", e.Dogecoin = "DOGE", e.Ethereum = "ETH", e.Kujira = "KUJI", e.Litecoin = "LTC", e.Maya = "MAYA", e.Optimism = "OP", e.Polygon = "MATIC", e.THORChain = "THOR", e))(i || {}), st = /* @__PURE__ */ ((e) => (e.ARB = "0x0000000000000000000000000000000000000000", e.AVAX = "0x0000000000000000000000000000000000000000", e.ETH = "0x0000000000000000000000000000000000000000", e.BSC = "0x0000000000000000000000000000000000000000", e.MATIC = "0x0000000000000000000000000000000000001010", e.OP = "0x4200000000000000000000000000000000000042", e))(st || {}), it = /* @__PURE__ */ ((e) => (e.ARB = "m/44'/60'/0'/0", e.AVAX = "m/44'/60'/0'/0", e.BCH = "m/44'/145'/0'/0", e.BNB = "m/44'/714'/0'/0", e.BSC = "m/44'/60'/0'/0", e.BTC = "m/84'/0'/0'/0", e.DOGE = "m/44'/3'/0'/0", e.ETH = "m/44'/60'/0'/0", e.GAIA = "m/44'/118'/0'/0", e.KUJI = "m/44'/118'/0'/0", e.LTC = "m/84'/2'/0'/0", e.MATIC = "m/44'/60'/0'/0", e.MAYA = "m/44'/931'/0'/0", e.OP = "m/44'/60'/0'/0", e.THOR = "m/44'/931'/0'/0", e))(it || {});
728
+ const wn = {
729
729
  ARB: [44, 60, 0, 0, 0],
730
730
  AVAX: [44, 60, 0, 0, 0],
731
731
  BCH: [44, 145, 0, 0, 0],
@@ -742,8 +742,8 @@ const Ht = {
742
742
  OP: [44, 60, 0, 0, 0],
743
743
  THOR: [44, 931, 0, 0, 0]
744
744
  };
745
- var E = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(E || {});
746
- const $t = [
745
+ var w = /* @__PURE__ */ ((e) => (e[e.ARB = 18] = "ARB", e[e.AVAX = 18] = "AVAX", e[e.BCH = 8] = "BCH", e[e.BNB = 8] = "BNB", e[e.BSC = 18] = "BSC", e[e.BTC = 8] = "BTC", e[e.DASH = 8] = "DASH", e[e.DOGE = 8] = "DOGE", e[e.ETH = 18] = "ETH", e[e.GAIA = 6] = "GAIA", e[e.KUJI = 6] = "KUJI", e[e.LTC = 8] = "LTC", e[e.MATIC = 18] = "MATIC", e[e.MAYA = 10] = "MAYA", e[e.OP = 18] = "OP", e[e.THOR = 8] = "THOR", e))(w || {});
746
+ const rt = [
747
747
  "ETH",
748
748
  "AVAX",
749
749
  "BSC",
@@ -751,38 +751,50 @@ const $t = [
751
751
  "OP",
752
752
  "MATIC"
753
753
  /* Polygon */
754
- ], kt = [
754
+ ], An = [
755
755
  "BTC",
756
756
  "BCH",
757
757
  "DOGE",
758
758
  "LTC"
759
759
  /* Litecoin */
760
- ], Ft = [
760
+ ], En = [
761
761
  "GAIA",
762
762
  "THOR",
763
763
  "BNB"
764
764
  /* Binance */
765
+ ], Rn = [
766
+ "AVAX",
767
+ "BNB",
768
+ "BSC",
769
+ "BTC",
770
+ "BCH",
771
+ "GAIA",
772
+ "DOGE",
773
+ "ETH",
774
+ "LTC",
775
+ "THOR"
776
+ /* THORChain */
765
777
  ];
766
- var ce = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(ce || {}), Ee = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Ee || {}), q = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(q || {});
767
- const te = Object.values(s), Ke = Object.keys(s), me = te.reduce(
778
+ var _e = /* @__PURE__ */ ((e) => (e.Arbitrum = "42161", e.ArbitrumHex = "0xa4b1", e.Avalanche = "43114", e.AvalancheHex = "0xa86a", e.Binance = "Binance-Chain-Tigris", e.BinanceSmartChain = "56", e.BinanceSmartChainHex = "0x38", e.Bitcoin = "bitcoin", e.BitcoinCash = "bitcoincash", e.Cosmos = "cosmoshub-4", e.Dogecoin = "dogecoin", e.Kujira = "kaiyo-1", e.Ethereum = "1", e.EthereumHex = "0x1", e.Litecoin = "litecoin", e.Maya = "mayachain-mainnet-v1", e.MayaStagenet = "mayachain-stagenet-v1", e.Optimism = "10", e.OptimismHex = "0xa", e.Polygon = "137", e.PolygonHex = "0x89", e.THORChain = "thorchain-mainnet-v1", e.THORChainStagenet = "thorchain-stagenet-v2", e))(_e || {}), Me = /* @__PURE__ */ ((e) => (e.Arbitrum = "https://arb1.arbitrum.io/rpc", e.Avalanche = "https://node-router.thorswap.net/avalanche-c", e.Binance = "", e.BinanceSmartChain = "https://bsc-dataseed.binance.org", e.Bitcoin = "https://node-router.thorswap.net/bitcoin", e.BitcoinCash = "https://node-router.thorswap.net/bitcoin-cash", e.Cosmos = "https://node-router.thorswap.net/cosmos/rpc", e.Kujira = "https://rpc-kujira.synergynodes.com/", e.Dogecoin = "https://node-router.thorswap.net/dogecoin", e.Ethereum = "https://node-router.thorswap.net/ethereum", e.Litecoin = "https://node-router.thorswap.net/litecoin", e.Maya = "https://tendermint.mayachain.info", e.MayaStagenet = "https://stagenet.tendermint.mayachain.info", e.Optimism = "https://mainnet.optimism.io", e.Polygon = "https://polygon-rpc.com", e.THORChain = "https://rpc.thorswap.net", e.THORChainStagenet = "https://stagenet-rpc.ninerealms.com", e))(Me || {}), q = /* @__PURE__ */ ((e) => (e.Cosmos = "https://node-router.thorswap.net/cosmos/rest", e.Kujira = "https://lcd-kujira.synergynodes.com/", e.MayanodeMainnet = "https://mayanode.mayachain.info", e.MayanodeStagenet = "https://stagenet.mayanode.mayachain.info", e.ThornodeMainnet = "https://thornode.thorswap.net", e.ThornodeStagenet = "https://stagenet-thornode.ninerealms.com", e.ThorswapApi = "https://api.thorswap.finance", e.ThorswapStatic = "https://static.thorswap.net", e))(q || {});
779
+ const ae = Object.values(i), ot = Object.keys(i), fe = ae.reduce(
768
780
  (e, t) => {
769
- const n = Ke.find((a) => s[a] === t);
781
+ const n = ot.find((a) => i[a] === t);
770
782
  return n && (e[t] = n), e;
771
783
  },
772
784
  {}
773
- ), Ye = te.reduce(
774
- (e, t) => (e[t] = ce[me[t]], e),
785
+ ), pt = ae.reduce(
786
+ (e, t) => (e[t] = _e[fe[t]], e),
775
787
  {}
776
- ), Xe = te.reduce(
777
- (e, t) => (e[t] = Ee[me[t]], e),
788
+ ), dt = ae.reduce(
789
+ (e, t) => (e[t] = Me[fe[t]], e),
778
790
  {}
779
- ), Gt = te.reduce(
791
+ ), gn = ae.reduce(
780
792
  (e, t) => {
781
- const n = `${me[t]}Hex`;
782
- return e[t] = ce[n], e;
793
+ const n = `${fe[t]}Hex`;
794
+ return e[t] = _e[n], e;
783
795
  },
784
796
  {}
785
- ), Wt = {
797
+ ), On = {
786
798
  "0xa4b1": "ARB",
787
799
  42161: "ARB",
788
800
  "0xa86a": "AVAX",
@@ -807,7 +819,7 @@ const te = Object.values(s), Ke = Object.keys(s), me = te.reduce(
807
819
  "thorchain-stagenet-v2": "THOR",
808
820
  "thorchain-mainnet-v1": "THOR"
809
821
  /* THORChain */
810
- }, Re = {
822
+ }, Ne = {
811
823
  ARB: "https://arbiscan.io",
812
824
  AVAX: "https://snowtrace.io",
813
825
  BSC: "https://bscscan.com",
@@ -822,308 +834,658 @@ const te = Object.values(s), Ke = Object.keys(s), me = te.reduce(
822
834
  MAYA: "https://www.mayascan.org",
823
835
  OP: "https://optimistic.etherscan.io",
824
836
  MATIC: "https://polygonscan.com",
825
- THOR: "https://viewblock.io/thorchain"
837
+ THOR: "https://runescan.io"
826
838
  };
827
- var je = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(je || {}), f = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(f || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), Je = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(Je || {}), Qe = Object.defineProperty, ze = (e, t, n) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, N = (e, t, n) => (ze(e, typeof t != "symbol" ? t + "" : t, n), n), Ze = (e, t, n) => {
839
+ var ut = /* @__PURE__ */ ((e) => (e[e.NoError = 36864] = "NoError", e))(ut || {}), h = /* @__PURE__ */ ((e) => (e.BOND = "BOND", e.DEPOSIT = "+", e.LEAVE = "LEAVE", e.THORNAME_REGISTER = "~", e.UNBOND = "UNBOND", e.WITHDRAW = "-", e.OPEN_LOAN = "$+", e.CLOSE_LOAN = "$-", e))(h || {}), F = /* @__PURE__ */ ((e) => (e.Average = "average", e.Fast = "fast", e.Fastest = "fastest", e))(F || {}), lt = /* @__PURE__ */ ((e) => (e.KEYSTORE = "KEYSTORE", e.XDEFI = "XDEFI", e.METAMASK = "METAMASK", e.COINBASE_WEB = "COINBASE_WEB", e.TREZOR = "TREZOR", e.TRUSTWALLET_WEB = "TRUSTWALLET_WEB", e.LEDGER = "LEDGER", e.KEPLR = "KEPLR", e.OKX = "OKX", e.BRAVE = "BRAVE", e.WALLETCONNECT = "WALLETCONNECT", e))(lt || {}), yt = Object.defineProperty, ct = (e, t, n) => t in e ? yt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, I = (e, t, n) => (ct(e, typeof t != "symbol" ? t + "" : t, n), n), mt = (e, t, n) => {
828
840
  if (!t.has(e))
829
841
  throw TypeError("Cannot " + n);
830
- }, B = (e, t, n) => {
842
+ }, $ = (e, t, n) => {
831
843
  if (t.has(e))
832
844
  throw TypeError("Cannot add the same private member more than once");
833
845
  t instanceof WeakSet ? t.add(e) : t.set(e, n);
834
- }, R = (e, t, n) => (Ze(e, t, "access private method"), n);
835
- const qt = (e) => {
836
- if (e < 0)
837
- throw new Error("Invalid number of year");
838
- return 10 + e;
839
- }, Kt = (e) => {
840
- if (e.length > 30)
841
- return !1;
842
- const t = /^[a-zA-Z0-9+_-]+$/g;
843
- return !!e.match(t);
844
- }, Yt = ([e, t, n, a, i]) => `${e}'/${t}'/${n}'/${a}${typeof i != "number" ? "" : `/${i}`}`, Oe = async (e, t) => {
845
- const n = Object.entries(t || {}).reduce(
846
- (a, [i, r]) => (r && (a[i] = r), a),
847
- {}
848
- );
849
- return (await fetch(
850
- `${e}${t ? `?${new URLSearchParams(n).toString()}` : ""}`,
851
- { method: "GET", mode: "cors", credentials: "omit", referrer: "https://sk.thorswap.net" }
852
- )).json();
853
- }, et = async (e, t, n, a = !1) => {
854
- const i = await fetch(`${e}`, {
855
- body: t,
856
- headers: n,
857
- method: "POST",
858
- referrer: "https://sk.thorswap.net"
859
- });
860
- return a ? i.text() : i.json();
861
- }, tt = "0x313ce567", Ie = async ({ chain: e, to: t }) => {
846
+ }, R = (e, t, n) => (mt(e, t, "access private method"), n);
847
+ const Tt = "0x313ce567", xe = async ({ chain: e, to: t }) => {
862
848
  try {
863
- const n = await et(
864
- Xe[e],
865
- JSON.stringify({
866
- method: "eth_call",
867
- params: [{ to: t.toLowerCase(), data: tt }, "latest"],
849
+ const { result: n } = await we.post(dt[e], {
850
+ headers: {
851
+ accept: "*/*",
852
+ "content-type": "application/json",
853
+ "cache-control": "no-cache"
854
+ },
855
+ body: JSON.stringify({
868
856
  id: 44,
869
- jsonrpc: "2.0"
870
- }),
871
- { accept: "*/*", "cache-control": "no-cache", "content-type": "application/json" },
872
- !0
873
- ), { result: a } = JSON.parse(n);
874
- return parseInt(BigInt(a).toString());
857
+ jsonrpc: "2.0",
858
+ method: "eth_call",
859
+ params: [{ to: t.toLowerCase(), data: Tt }, "latest"]
860
+ })
861
+ });
862
+ return parseInt(BigInt(n).toString());
875
863
  } catch (n) {
876
- return console.error(n), E[e];
864
+ return console.error(n), w[e];
877
865
  }
878
- }, nt = async (e) => {
879
- if (e === s.Ethereum)
880
- return E.ETH;
866
+ }, ht = async (e) => {
867
+ if (e === i.Ethereum)
868
+ return w.ETH;
881
869
  const [, t] = e.split("-");
882
- return t != null && t.startsWith("0x") ? Ie({ chain: s.Ethereum, to: t }) : E.ETH;
883
- }, at = async (e) => {
870
+ return t != null && t.startsWith("0x") ? xe({ chain: i.Ethereum, to: t }) : w.ETH;
871
+ }, _t = async (e) => {
884
872
  const [, t] = e.split("-");
885
- return t != null && t.startsWith("0x") ? Ie({ chain: s.Avalanche, to: t.toLowerCase() }) : E.AVAX;
886
- }, st = async (e) => (e === s.BinanceSmartChain, E.BSC), Se = async ({ chain: e, symbol: t }) => {
873
+ return t != null && t.startsWith("0x") ? xe({ chain: i.Avalanche, to: t.toLowerCase() }) : w.AVAX;
874
+ }, ft = async (e) => (e === i.BinanceSmartChain, w.BSC), bt = async ({ chain: e, symbol: t }) => {
887
875
  switch (e) {
888
- case s.Ethereum:
889
- return nt(t);
890
- case s.Avalanche:
891
- return at(t);
892
- case s.BinanceSmartChain:
893
- return st(t);
876
+ case i.Ethereum:
877
+ return ht(t);
878
+ case i.Avalanche:
879
+ return _t(t);
880
+ case i.BinanceSmartChain:
881
+ return ft(t);
894
882
  default:
895
- return E[e];
883
+ return w[e];
896
884
  }
897
- }, it = {
885
+ }, wt = {
898
886
  [F.Average]: 1.2,
899
887
  [F.Fast]: 1.5,
900
888
  [F.Fastest]: 2
901
- }, rt = ({ chain: e, symbol: t }) => {
889
+ }, De = ({ chain: e, symbol: t }) => {
902
890
  switch (e) {
903
- case s.Bitcoin:
904
- case s.BitcoinCash:
905
- case s.Litecoin:
906
- case s.Dogecoin:
907
- case s.Binance:
908
- case s.Ethereum:
909
- case s.Avalanche:
891
+ case i.Bitcoin:
892
+ case i.BitcoinCash:
893
+ case i.Litecoin:
894
+ case i.Dogecoin:
895
+ case i.Binance:
896
+ case i.Ethereum:
897
+ case i.Avalanche:
910
898
  return t === e;
911
- case s.Arbitrum:
912
- case s.Optimism:
899
+ case i.Arbitrum:
900
+ case i.Optimism:
913
901
  return t === "ETH";
914
- case s.Maya:
902
+ case i.Maya:
915
903
  return t === "CACAO";
916
- case s.Kujira:
904
+ case i.Kujira:
917
905
  return t === "KUJI";
918
- case s.Cosmos:
906
+ case i.Cosmos:
919
907
  return t === "ATOM";
920
- case s.Polygon:
908
+ case i.Polygon:
921
909
  return t === "MATIC";
922
- case s.BinanceSmartChain:
910
+ case i.BinanceSmartChain:
923
911
  return t === "BNB";
924
- case s.THORChain:
912
+ case i.THORChain:
925
913
  return t === "RUNE";
926
914
  }
927
- }, pt = (e) => {
915
+ }, At = (e) => {
928
916
  switch (e) {
929
917
  case "ETH.THOR":
930
918
  return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
931
919
  case "ETH.vTHOR":
932
920
  return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
933
- case s.Cosmos:
934
- return { identifier: "GAIA.ATOM", decimal: E[e] };
935
- case s.THORChain:
936
- return { identifier: "THOR.RUNE", decimal: E[e] };
937
- case s.BinanceSmartChain:
938
- return { identifier: "BSC.BNB", decimal: E[e] };
939
- case s.Maya:
940
- return { identifier: "MAYA.CACAO", decimal: E.MAYA };
921
+ case i.Cosmos:
922
+ return { identifier: "GAIA.ATOM", decimal: w[e] };
923
+ case i.THORChain:
924
+ return { identifier: "THOR.RUNE", decimal: w[e] };
925
+ case i.BinanceSmartChain:
926
+ return { identifier: "BSC.BNB", decimal: w[e] };
927
+ case i.Maya:
928
+ return { identifier: "MAYA.CACAO", decimal: w.MAYA };
941
929
  case "MAYA.MAYA":
942
930
  return { identifier: "MAYA.MAYA", decimal: 4 };
943
- case s.Kujira:
944
- case s.Arbitrum:
945
- case s.Optimism:
946
- case s.BitcoinCash:
947
- case s.Litecoin:
948
- case s.Dogecoin:
949
- case s.Binance:
950
- case s.Avalanche:
951
- case s.Polygon:
952
- case s.Bitcoin:
953
- case s.Ethereum:
954
- return { identifier: `${e}.${e}`, decimal: E[e] };
955
- }
956
- }, ot = ({ chain: e, symbol: t }) => {
931
+ case i.Kujira:
932
+ case i.Arbitrum:
933
+ case i.Optimism:
934
+ case i.BitcoinCash:
935
+ case i.Litecoin:
936
+ case i.Dogecoin:
937
+ case i.Binance:
938
+ case i.Avalanche:
939
+ case i.Polygon:
940
+ case i.Bitcoin:
941
+ case i.Ethereum:
942
+ return { identifier: `${e}.${e}`, decimal: w[e] };
943
+ }
944
+ }, Et = ({ chain: e, symbol: t }) => {
957
945
  if (t.includes("/"))
958
946
  return "Synth";
959
947
  switch (e) {
960
- case s.Bitcoin:
961
- case s.BitcoinCash:
962
- case s.Dogecoin:
963
- case s.Litecoin:
964
- case s.Maya:
965
- case s.THORChain:
948
+ case i.Bitcoin:
949
+ case i.BitcoinCash:
950
+ case i.Dogecoin:
951
+ case i.Litecoin:
952
+ case i.Maya:
953
+ case i.THORChain:
966
954
  return "Native";
967
- case s.Cosmos:
968
- return t === "ATOM" ? "Native" : "GAIA";
969
- case s.Kujira:
970
- return t === "KUJI" ? "Native" : "KUJI";
971
- case s.Binance:
972
- return t === s.Binance ? "Native" : "BEP2";
973
- case s.BinanceSmartChain:
974
- return t === s.Binance ? "Native" : "BEP20";
975
- case s.Ethereum:
976
- return t === s.Ethereum ? "Native" : "ERC20";
977
- case s.Avalanche:
978
- return t === s.Avalanche ? "Native" : "AVAX";
979
- case s.Polygon:
980
- return t === s.Polygon ? "Native" : "POLYGON";
981
- case s.Arbitrum:
982
- return [s.Ethereum, s.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
983
- case s.Optimism:
984
- return [s.Ethereum, s.Optimism].includes(t) ? "Native" : "OPTIMISM";
985
- }
986
- }, Xt = (e) => {
955
+ case i.Cosmos:
956
+ return t === "ATOM" ? "Native" : i.Cosmos;
957
+ case i.Kujira:
958
+ return t === i.Kujira ? "Native" : i.Kujira;
959
+ case i.Binance:
960
+ return t === i.Binance ? "Native" : "BEP2";
961
+ case i.BinanceSmartChain:
962
+ return t === i.Binance ? "Native" : "BEP20";
963
+ case i.Ethereum:
964
+ return t === i.Ethereum ? "Native" : "ERC20";
965
+ case i.Avalanche:
966
+ return t === i.Avalanche ? "Native" : i.Avalanche;
967
+ case i.Polygon:
968
+ return t === i.Polygon ? "Native" : "POLYGON";
969
+ case i.Arbitrum:
970
+ return [i.Ethereum, i.Arbitrum].includes(t) ? "Native" : "ARBITRUM";
971
+ case i.Optimism:
972
+ return [i.Ethereum, i.Optimism].includes(t) ? "Native" : "OPTIMISM";
973
+ }
974
+ }, Sn = (e) => {
987
975
  var t;
988
- const [n, ...a] = e.split("."), i = e.includes("/"), r = a.join("."), p = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
989
- return { chain: n, symbol: r, ticker: p, synth: i };
990
- }, dt = ({
976
+ const [n, ...a] = e.split("."), s = e.includes("/"), r = a.join("."), o = (t = r == null ? void 0 : r.split("-")) == null ? void 0 : t[0];
977
+ return { chain: n, symbol: r, ticker: o, synth: s };
978
+ }, Rt = new RegExp(
979
+ /(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,
980
+ "gmi"
981
+ ), gt = (e) => {
982
+ const [t, n] = e.split(".");
983
+ if (!rt.includes(t))
984
+ return !0;
985
+ const [, a] = n.split("-");
986
+ return De({ chain: t, symbol: n }) || !!a;
987
+ }, In = (e) => e.filter((t) => {
988
+ const n = `${t.chain}.${t.symbol}`;
989
+ return !Rt.test(n) && gt(n) && t.value !== "0";
990
+ }), Ot = ({
991
991
  liquidityUnits: e,
992
992
  poolUnits: t,
993
993
  runeDepth: n
994
994
  }) => {
995
- const a = w(e), i = w(t), r = w(n), p = a.mul(r), d = i.mul(i).mul(2), l = i.mul(a).mul(2), c = a.mul(a), y = i.mul(i).mul(i);
996
- return p.mul(d.sub(l).add(c)).div(y);
997
- }, ut = ({
995
+ const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = s.mul(s).mul(s);
996
+ return o.mul(p.sub(d).add(l)).div(u);
997
+ }, St = ({
998
998
  liquidityUnits: e,
999
999
  poolUnits: t,
1000
1000
  assetDepth: n
1001
1001
  }) => {
1002
- const a = w(e), i = w(t), r = w(n), p = a.mul(r), d = i.mul(i).mul(2), l = i.mul(a).mul(2), c = a.mul(a), y = p.mul(d.sub(l).add(c)), u = i.mul(i).mul(i);
1003
- return y.div(u);
1004
- }, jt = ({
1002
+ const a = g(e), s = g(t), r = g(n), o = a.mul(r), p = s.mul(s).mul(2), d = s.mul(a).mul(2), l = a.mul(a), u = o.mul(p.sub(d).add(l)), c = s.mul(s).mul(s);
1003
+ return u.div(c);
1004
+ }, vn = ({
1005
1005
  percent: e,
1006
1006
  runeDepth: t,
1007
1007
  liquidityUnits: n,
1008
1008
  poolUnits: a
1009
- }) => dt({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Jt = ({
1009
+ }) => Ot({ runeDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), Cn = ({
1010
1010
  percent: e,
1011
1011
  assetDepth: t,
1012
1012
  liquidityUnits: n,
1013
1013
  poolUnits: a
1014
- }) => ut({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), w = (e) => new le({ value: e, decimal: E.THOR }), yt = ({
1014
+ }) => St({ assetDepth: t, liquidityUnits: n, poolUnits: a }).mul(e), g = (e) => x.fromBigInt(BigInt(e), w.THOR), It = ({
1015
1015
  liquidityUnits: e,
1016
1016
  poolUnits: t,
1017
1017
  runeDepth: n,
1018
1018
  assetDepth: a
1019
1019
  }) => ({
1020
- assetAmount: w(a).mul(e).div(t),
1021
- runeAmount: w(n).mul(e).div(t)
1022
- }), Qt = ({
1020
+ assetAmount: g(a).mul(e).div(t),
1021
+ runeAmount: g(n).mul(e).div(t)
1022
+ }), Mn = ({
1023
1023
  liquidityUnits: e,
1024
1024
  poolUnits: t,
1025
1025
  runeDepth: n,
1026
1026
  assetDepth: a,
1027
- percent: i
1027
+ percent: s
1028
1028
  }) => Object.fromEntries(
1029
- Object.entries(yt({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
1030
- ([r, p]) => [r, p.mul(i)]
1029
+ Object.entries(It({ liquidityUnits: e, poolUnits: t, runeDepth: n, assetDepth: a })).map(
1030
+ ([r, o]) => [r, o.mul(s)]
1031
1031
  )
1032
- ), zt = ({
1032
+ ), Nn = ({
1033
1033
  runeDepth: e,
1034
1034
  poolUnits: t,
1035
1035
  assetDepth: n,
1036
1036
  liquidityUnits: a,
1037
- runeAmount: i,
1037
+ runeAmount: s,
1038
1038
  assetAmount: r
1039
1039
  }) => {
1040
- const p = w(e), d = w(n), l = w(t), c = w(i), y = w(r), u = c.mul(d), h = y.mul(p), _ = c.mul(y), O = p.mul(d), I = l.mul(u.add(h.add(_.mul(2)))), g = u.add(h.add(O.mul(2))), S = I.div(g), b = w(a).add(S);
1041
- if (S.baseValueNumber === 0)
1042
- return b.div(l).baseValueNumber;
1043
- const M = l.add(b);
1044
- return b.div(M).baseValueNumber;
1045
- }, Zt = ({
1040
+ const o = new x({ value: e, decimal: 8 }), p = new x({ value: n, decimal: 8 }), d = new x({ value: t, decimal: 8 }), l = new x({ value: s, decimal: 8 }), u = new x({ value: r, decimal: 8 }), c = l.mul(p), _ = u.mul(o), b = l.mul(u), A = o.mul(p), E = d.mul(c.add(_.add(b.mul(2)))), O = c.add(_.add(A.mul(2))), S = E.div(O), D = g(a).add(S);
1041
+ if (S.getBaseValue("number") === 0)
1042
+ return D.div(d).getBaseValue("number");
1043
+ const ie = d.add(D);
1044
+ return D.div(ie).getBaseValue("number");
1045
+ }, xn = ({
1046
1046
  runeAmount: e,
1047
1047
  assetAmount: t,
1048
1048
  runeDepth: n,
1049
1049
  assetDepth: a
1050
1050
  }) => {
1051
- const i = w(n), r = w(a), p = w(t), d = w(e), l = p.mul(i).sub(r.mul(d)), c = r.mul(d).add(i.mul(r));
1052
- return Math.abs(l.div(c).baseValueNumber);
1053
- }, lt = ({
1051
+ if (e === "0" || t === "0" || n === "0" || a === "0")
1052
+ return 0;
1053
+ const s = g(n), r = g(a), o = g(t), p = g(e), d = o.mul(s).sub(r.mul(p)), l = r.mul(p).add(s.mul(r));
1054
+ return Math.abs(d.div(l).getBaseValue("number"));
1055
+ }, vt = ({
1054
1056
  symbol: e,
1055
1057
  ticker: t,
1056
1058
  chain: n
1057
- }) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, x = (e, t) => {
1059
+ }) => n === "ETH" && t !== "ETH" ? `${t}-${e.slice(-3)}` : e, N = (e, t) => {
1058
1060
  switch (e) {
1059
- case f.LEAVE:
1060
- case f.BOND: {
1061
+ case h.LEAVE:
1062
+ case h.BOND: {
1061
1063
  const { address: n } = t;
1062
1064
  return `${e}:${n}`;
1063
1065
  }
1064
- case f.UNBOND: {
1066
+ case h.UNBOND: {
1065
1067
  const { address: n, unbondAmount: a } = t;
1066
1068
  return `${e}:${n}:${a * 10 ** 8}`;
1067
1069
  }
1068
- case f.THORNAME_REGISTER: {
1069
- const { name: n, chain: a, address: i, owner: r } = t;
1070
- return `${e}:${n}:${a}:${i}${r ? `:${r}` : ""}`;
1070
+ case h.THORNAME_REGISTER: {
1071
+ const { name: n, chain: a, address: s, owner: r } = t;
1072
+ return `${e}:${n}:${a}:${s}${r ? `:${r}` : ""}`;
1071
1073
  }
1072
- case f.DEPOSIT: {
1073
- const { chain: n, symbol: a, address: i, singleSide: r } = t;
1074
- return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${i || ""}:t:0`;
1074
+ case h.DEPOSIT: {
1075
+ const { chain: n, symbol: a, address: s, singleSide: r } = t;
1076
+ return r ? `${e}:${n}/${a}::t:0` : `${e}:${n}.${a}:${s || ""}:t:0`;
1075
1077
  }
1076
- case f.WITHDRAW: {
1077
- const { chain: n, ticker: a, symbol: i, basisPoints: r, targetAssetString: p, singleSide: d } = t, l = !d && p ? `:${p}` : "", c = lt({ chain: n, symbol: i, ticker: a });
1078
- return `${e}:${n}${d ? "/" : "."}${c}:${r}${l}`;
1078
+ case h.WITHDRAW: {
1079
+ const { chain: n, ticker: a, symbol: s, basisPoints: r, targetAssetString: o, singleSide: p } = t, d = !p && o ? `:${o}` : "", l = vt({ chain: n, symbol: s, ticker: a });
1080
+ return `${e}:${n}${p ? "/" : "."}${l}:${r}${d}`;
1079
1081
  }
1080
- case f.OPEN_LOAN:
1081
- case f.CLOSE_LOAN: {
1082
+ case h.OPEN_LOAN:
1083
+ case h.CLOSE_LOAN: {
1082
1084
  const { asset: n, address: a } = t;
1083
1085
  return `${e}:${n}:${a}`;
1084
1086
  }
1085
1087
  default:
1086
1088
  return "";
1087
1089
  }
1088
- }, K = 8, ge = ({
1089
- value: e,
1090
- bigIntDecimal: t = K,
1091
- decimal: n = K
1092
- }) => {
1093
- const a = e < 0n;
1094
- let i = e.toString().substring(a ? 1 : 0);
1095
- const r = n - (i.length - 1);
1096
- r > 0 && (i = "0".repeat(r) + i);
1097
- const p = i.length - n;
1098
- let d = i.slice(-n);
1099
- return parseInt(d[t]) >= 5 ? d = `${d.substring(0, t - 1)}${(parseInt(d[t - 1]) + 1).toString()}` : d = d.substring(0, t), `${a ? "-" : ""}${i.slice(0, p)}.${d}`.replace(
1100
- /\.?0*$/,
1101
- ""
1102
- );
1103
- }, Te = Object.values(s), ct = (e = "") => {
1090
+ }, Dn = (e) => {
1091
+ if (e < 0)
1092
+ throw new Error("Invalid number of year");
1093
+ return 10 + e;
1094
+ }, Pn = (e) => {
1095
+ if (e.length > 30)
1096
+ return !1;
1097
+ const t = /^[a-zA-Z0-9+_-]+$/g;
1098
+ return !!e.match(t);
1099
+ }, Bn = ([e, t, n, a, s]) => `${e}'/${t}'/${n}'/${a}${typeof s != "number" ? "" : `/${s}`}`;
1100
+ class Ae extends Error {
1101
+ constructor(t, n, a) {
1102
+ const s = t.status || t.status === 0 ? t.status : "", r = t.statusText || "", o = `${s} ${r}`.trim(), p = o ? `status code ${o}` : "an unknown error";
1103
+ super(`Request failed with ${p}`), Object.defineProperty(this, "response", {
1104
+ enumerable: !0,
1105
+ configurable: !0,
1106
+ writable: !0,
1107
+ value: void 0
1108
+ }), Object.defineProperty(this, "request", {
1109
+ enumerable: !0,
1110
+ configurable: !0,
1111
+ writable: !0,
1112
+ value: void 0
1113
+ }), Object.defineProperty(this, "options", {
1114
+ enumerable: !0,
1115
+ configurable: !0,
1116
+ writable: !0,
1117
+ value: void 0
1118
+ }), this.name = "HTTPError", this.response = t, this.request = n, this.options = a;
1119
+ }
1120
+ }
1121
+ class Pe extends Error {
1122
+ constructor(t) {
1123
+ super("Request timed out"), Object.defineProperty(this, "request", {
1124
+ enumerable: !0,
1125
+ configurable: !0,
1126
+ writable: !0,
1127
+ value: void 0
1128
+ }), this.name = "TimeoutError", this.request = t;
1129
+ }
1130
+ }
1131
+ const J = (e) => e !== null && typeof e == "object", X = (...e) => {
1132
+ for (const t of e)
1133
+ if ((!J(t) || Array.isArray(t)) && t !== void 0)
1134
+ throw new TypeError("The `options` argument must be an object");
1135
+ return be({}, ...e);
1136
+ }, Be = (e = {}, t = {}) => {
1137
+ const n = new globalThis.Headers(e), a = t instanceof globalThis.Headers, s = new globalThis.Headers(t);
1138
+ for (const [r, o] of s.entries())
1139
+ a && o === "undefined" || o === void 0 ? n.delete(r) : n.set(r, o);
1140
+ return n;
1141
+ }, be = (...e) => {
1142
+ let t = {}, n = {};
1143
+ for (const a of e)
1144
+ if (Array.isArray(a))
1145
+ Array.isArray(t) || (t = []), t = [...t, ...a];
1146
+ else if (J(a)) {
1147
+ for (let [s, r] of Object.entries(a))
1148
+ J(r) && s in t && (r = be(t[s], r)), t = { ...t, [s]: r };
1149
+ J(a.headers) && (n = Be(n, a.headers), t.headers = n);
1150
+ }
1151
+ return t;
1152
+ }, Ct = (() => {
1153
+ let e = !1, t = !1;
1154
+ const n = typeof globalThis.ReadableStream == "function", a = typeof globalThis.Request == "function";
1155
+ return n && a && (t = new globalThis.Request("https://empty.invalid", {
1156
+ body: new globalThis.ReadableStream(),
1157
+ method: "POST",
1158
+ // @ts-expect-error - Types are outdated.
1159
+ get duplex() {
1160
+ return e = !0, "half";
1161
+ }
1162
+ }).headers.has("Content-Type")), e && !t;
1163
+ })(), Mt = typeof globalThis.AbortController == "function", Nt = typeof globalThis.ReadableStream == "function", xt = typeof globalThis.FormData == "function", Le = ["get", "post", "put", "patch", "head", "delete"], Dt = {
1164
+ json: "application/json",
1165
+ text: "text/*",
1166
+ formData: "multipart/form-data",
1167
+ arrayBuffer: "*/*",
1168
+ blob: "*/*"
1169
+ }, oe = 2147483647, Ve = Symbol("stop"), Pt = {
1170
+ json: !0,
1171
+ parseJson: !0,
1172
+ searchParams: !0,
1173
+ prefixUrl: !0,
1174
+ retry: !0,
1175
+ timeout: !0,
1176
+ hooks: !0,
1177
+ throwHttpErrors: !0,
1178
+ onDownloadProgress: !0,
1179
+ fetch: !0
1180
+ }, Bt = {
1181
+ method: !0,
1182
+ headers: !0,
1183
+ body: !0,
1184
+ mode: !0,
1185
+ credentials: !0,
1186
+ cache: !0,
1187
+ redirect: !0,
1188
+ referrer: !0,
1189
+ referrerPolicy: !0,
1190
+ integrity: !0,
1191
+ keepalive: !0,
1192
+ signal: !0,
1193
+ window: !0,
1194
+ dispatcher: !0,
1195
+ duplex: !0
1196
+ }, Lt = (e) => Le.includes(e) ? e.toUpperCase() : e, Vt = ["get", "put", "head", "delete", "options", "trace"], Ut = [408, 413, 429, 500, 502, 503, 504], Ue = [413, 429, 503], Ee = {
1197
+ limit: 2,
1198
+ methods: Vt,
1199
+ statusCodes: Ut,
1200
+ afterStatusCodes: Ue,
1201
+ maxRetryAfter: Number.POSITIVE_INFINITY,
1202
+ backoffLimit: Number.POSITIVE_INFINITY,
1203
+ delay: (e) => 0.3 * 2 ** (e - 1) * 1e3
1204
+ }, Ht = (e = {}) => {
1205
+ if (typeof e == "number")
1206
+ return {
1207
+ ...Ee,
1208
+ limit: e
1209
+ };
1210
+ if (e.methods && !Array.isArray(e.methods))
1211
+ throw new Error("retry.methods must be an array");
1212
+ if (e.statusCodes && !Array.isArray(e.statusCodes))
1213
+ throw new Error("retry.statusCodes must be an array");
1214
+ return {
1215
+ ...Ee,
1216
+ ...e,
1217
+ afterStatusCodes: Ue
1218
+ };
1219
+ };
1220
+ async function $t(e, t, n, a) {
1221
+ return new Promise((s, r) => {
1222
+ const o = setTimeout(() => {
1223
+ n && n.abort(), r(new Pe(e));
1224
+ }, a.timeout);
1225
+ a.fetch(e, t).then(s).catch(r).then(() => {
1226
+ clearTimeout(o);
1227
+ });
1228
+ });
1229
+ }
1230
+ async function kt(e, { signal: t }) {
1231
+ return new Promise((n, a) => {
1232
+ t && (t.throwIfAborted(), t.addEventListener("abort", s, { once: !0 }));
1233
+ function s() {
1234
+ clearTimeout(r), a(t.reason);
1235
+ }
1236
+ const r = setTimeout(() => {
1237
+ t == null || t.removeEventListener("abort", s), n();
1238
+ }, e);
1239
+ });
1240
+ }
1241
+ const Ft = (e, t) => {
1242
+ const n = {};
1243
+ for (const a in t)
1244
+ !(a in Bt) && !(a in Pt) && !(a in e) && (n[a] = t[a]);
1245
+ return n;
1246
+ };
1247
+ class Z {
1248
+ static create(t, n) {
1249
+ const a = new Z(t, n), s = async () => {
1250
+ if (typeof a._options.timeout == "number" && a._options.timeout > oe)
1251
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${oe}`);
1252
+ await Promise.resolve();
1253
+ let o = await a._fetch();
1254
+ for (const p of a._options.hooks.afterResponse) {
1255
+ const d = await p(a.request, a._options, a._decorateResponse(o.clone()));
1256
+ d instanceof globalThis.Response && (o = d);
1257
+ }
1258
+ if (a._decorateResponse(o), !o.ok && a._options.throwHttpErrors) {
1259
+ let p = new Ae(o, a.request, a._options);
1260
+ for (const d of a._options.hooks.beforeError)
1261
+ p = await d(p);
1262
+ throw p;
1263
+ }
1264
+ if (a._options.onDownloadProgress) {
1265
+ if (typeof a._options.onDownloadProgress != "function")
1266
+ throw new TypeError("The `onDownloadProgress` option must be a function");
1267
+ if (!Nt)
1268
+ throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
1269
+ return a._stream(o.clone(), a._options.onDownloadProgress);
1270
+ }
1271
+ return o;
1272
+ }, r = a._options.retry.methods.includes(a.request.method.toLowerCase()) ? a._retry(s) : s();
1273
+ for (const [o, p] of Object.entries(Dt))
1274
+ r[o] = async () => {
1275
+ a.request.headers.set("accept", a.request.headers.get("accept") || p);
1276
+ const d = (await r).clone();
1277
+ if (o === "json") {
1278
+ if (d.status === 204 || (await d.clone().arrayBuffer()).byteLength === 0)
1279
+ return "";
1280
+ if (n.parseJson)
1281
+ return n.parseJson(await d.text());
1282
+ }
1283
+ return d[o]();
1284
+ };
1285
+ return r;
1286
+ }
1287
+ // eslint-disable-next-line complexity
1288
+ constructor(t, n = {}) {
1289
+ if (Object.defineProperty(this, "request", {
1290
+ enumerable: !0,
1291
+ configurable: !0,
1292
+ writable: !0,
1293
+ value: void 0
1294
+ }), Object.defineProperty(this, "abortController", {
1295
+ enumerable: !0,
1296
+ configurable: !0,
1297
+ writable: !0,
1298
+ value: void 0
1299
+ }), Object.defineProperty(this, "_retryCount", {
1300
+ enumerable: !0,
1301
+ configurable: !0,
1302
+ writable: !0,
1303
+ value: 0
1304
+ }), Object.defineProperty(this, "_input", {
1305
+ enumerable: !0,
1306
+ configurable: !0,
1307
+ writable: !0,
1308
+ value: void 0
1309
+ }), Object.defineProperty(this, "_options", {
1310
+ enumerable: !0,
1311
+ configurable: !0,
1312
+ writable: !0,
1313
+ value: void 0
1314
+ }), this._input = t, this._options = {
1315
+ // TODO: credentials can be removed when the spec change is implemented in all browsers. Context: https://www.chromestatus.com/feature/4539473312350208
1316
+ credentials: this._input.credentials || "same-origin",
1317
+ ...n,
1318
+ headers: Be(this._input.headers, n.headers),
1319
+ hooks: be({
1320
+ beforeRequest: [],
1321
+ beforeRetry: [],
1322
+ beforeError: [],
1323
+ afterResponse: []
1324
+ }, n.hooks),
1325
+ method: Lt(n.method ?? this._input.method),
1326
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
1327
+ prefixUrl: String(n.prefixUrl || ""),
1328
+ retry: Ht(n.retry),
1329
+ throwHttpErrors: n.throwHttpErrors !== !1,
1330
+ timeout: n.timeout ?? 1e4,
1331
+ fetch: n.fetch ?? globalThis.fetch.bind(globalThis)
1332
+ }, typeof this._input != "string" && !(this._input instanceof URL || this._input instanceof globalThis.Request))
1333
+ throw new TypeError("`input` must be a string, URL, or Request");
1334
+ if (this._options.prefixUrl && typeof this._input == "string") {
1335
+ if (this._input.startsWith("/"))
1336
+ throw new Error("`input` must not begin with a slash when using `prefixUrl`");
1337
+ this._options.prefixUrl.endsWith("/") || (this._options.prefixUrl += "/"), this._input = this._options.prefixUrl + this._input;
1338
+ }
1339
+ if (Mt) {
1340
+ if (this.abortController = new globalThis.AbortController(), this._options.signal) {
1341
+ const a = this._options.signal;
1342
+ this._options.signal.addEventListener("abort", () => {
1343
+ this.abortController.abort(a.reason);
1344
+ });
1345
+ }
1346
+ this._options.signal = this.abortController.signal;
1347
+ }
1348
+ if (Ct && (this._options.duplex = "half"), this.request = new globalThis.Request(this._input, this._options), this._options.searchParams) {
1349
+ const a = "?" + (typeof this._options.searchParams == "string" ? this._options.searchParams.replace(/^\?/, "") : new URLSearchParams(this._options.searchParams).toString()), s = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, a);
1350
+ (xt && this._options.body instanceof globalThis.FormData || this._options.body instanceof URLSearchParams) && !(this._options.headers && this._options.headers["content-type"]) && this.request.headers.delete("content-type"), this.request = new globalThis.Request(new globalThis.Request(s, { ...this.request }), this._options);
1351
+ }
1352
+ this._options.json !== void 0 && (this._options.body = JSON.stringify(this._options.json), this.request.headers.set("content-type", this._options.headers.get("content-type") ?? "application/json"), this.request = new globalThis.Request(this.request, { body: this._options.body }));
1353
+ }
1354
+ _calculateRetryDelay(t) {
1355
+ if (this._retryCount++, this._retryCount < this._options.retry.limit && !(t instanceof Pe)) {
1356
+ if (t instanceof Ae) {
1357
+ if (!this._options.retry.statusCodes.includes(t.response.status))
1358
+ return 0;
1359
+ const a = t.response.headers.get("Retry-After");
1360
+ if (a && this._options.retry.afterStatusCodes.includes(t.response.status)) {
1361
+ let s = Number(a);
1362
+ return Number.isNaN(s) ? s = Date.parse(a) - Date.now() : s *= 1e3, this._options.retry.maxRetryAfter !== void 0 && s > this._options.retry.maxRetryAfter ? 0 : s;
1363
+ }
1364
+ if (t.response.status === 413)
1365
+ return 0;
1366
+ }
1367
+ const n = this._options.retry.delay(this._retryCount);
1368
+ return Math.min(this._options.retry.backoffLimit, n);
1369
+ }
1370
+ return 0;
1371
+ }
1372
+ _decorateResponse(t) {
1373
+ return this._options.parseJson && (t.json = async () => this._options.parseJson(await t.text())), t;
1374
+ }
1375
+ async _retry(t) {
1376
+ try {
1377
+ return await t();
1378
+ } catch (n) {
1379
+ const a = Math.min(this._calculateRetryDelay(n), oe);
1380
+ if (a !== 0 && this._retryCount > 0) {
1381
+ await kt(a, { signal: this._options.signal });
1382
+ for (const s of this._options.hooks.beforeRetry)
1383
+ if (await s({
1384
+ request: this.request,
1385
+ options: this._options,
1386
+ error: n,
1387
+ retryCount: this._retryCount
1388
+ }) === Ve)
1389
+ return;
1390
+ return this._retry(t);
1391
+ }
1392
+ throw n;
1393
+ }
1394
+ }
1395
+ async _fetch() {
1396
+ for (const n of this._options.hooks.beforeRequest) {
1397
+ const a = await n(this.request, this._options);
1398
+ if (a instanceof Request) {
1399
+ this.request = a;
1400
+ break;
1401
+ }
1402
+ if (a instanceof Response)
1403
+ return a;
1404
+ }
1405
+ const t = Ft(this.request, this._options);
1406
+ return this._options.timeout === !1 ? this._options.fetch(this.request.clone(), t) : $t(this.request.clone(), t, this.abortController, this._options);
1407
+ }
1408
+ /* istanbul ignore next */
1409
+ _stream(t, n) {
1410
+ const a = Number(t.headers.get("content-length")) || 0;
1411
+ let s = 0;
1412
+ return t.status === 204 ? (n && n({ percent: 1, totalBytes: a, transferredBytes: s }, new Uint8Array()), new globalThis.Response(null, {
1413
+ status: t.status,
1414
+ statusText: t.statusText,
1415
+ headers: t.headers
1416
+ })) : new globalThis.Response(new globalThis.ReadableStream({
1417
+ async start(r) {
1418
+ const o = t.body.getReader();
1419
+ n && n({ percent: 0, transferredBytes: 0, totalBytes: a }, new Uint8Array());
1420
+ async function p() {
1421
+ const { done: d, value: l } = await o.read();
1422
+ if (d) {
1423
+ r.close();
1424
+ return;
1425
+ }
1426
+ if (n) {
1427
+ s += l.byteLength;
1428
+ const u = a === 0 ? 0 : s / a;
1429
+ n({ percent: u, transferredBytes: s, totalBytes: a }, l);
1430
+ }
1431
+ r.enqueue(l), await p();
1432
+ }
1433
+ await p();
1434
+ }
1435
+ }), {
1436
+ status: t.status,
1437
+ statusText: t.statusText,
1438
+ headers: t.headers
1439
+ });
1440
+ }
1441
+ }
1442
+ /*! MIT License © Sindre Sorhus */
1443
+ const ue = (e) => {
1444
+ const t = (n, a) => Z.create(n, X(e, a));
1445
+ for (const n of Le)
1446
+ t[n] = (a, s) => Z.create(a, X(e, s, { method: n }));
1447
+ return t.create = (n) => ue(X(n)), t.extend = (n) => ue(X(e, n)), t.stop = Ve, t;
1448
+ }, Gt = ue(), qt = Gt, Wt = typeof window < "u" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" }, Re = qt.create({ headers: Wt }), we = {
1449
+ get: (e, t) => Re.get(e, t).json(),
1450
+ post: (e, t) => Re.post(e, t).json()
1451
+ }, ge = Object.values(i), jt = (e = "") => {
1104
1452
  const t = e.toUpperCase(), [n] = t.split(".");
1105
- if (Te.includes(n))
1453
+ if (ge.includes(n))
1106
1454
  return !0;
1107
1455
  const [a] = t.split("/");
1108
- if (Te.includes(a))
1456
+ if (ge.includes(a))
1109
1457
  return !0;
1110
1458
  throw new Error(
1111
1459
  `Invalid identifier: ${e}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`
1112
1460
  );
1113
- }, U = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
1114
- var L, $, ie, ve, re, _e, z, pe, H, W, Z, oe, k, J;
1115
- const mt = class Q {
1461
+ }, W = 8, L = (e) => 10n ** BigInt(e), G = (e) => Math.log10(parseFloat(e.toString()));
1462
+ function se({
1463
+ value: e,
1464
+ bigIntDecimal: t = W,
1465
+ decimal: n = W
1466
+ }) {
1467
+ const a = e < 0n;
1468
+ let s = e.toString().substring(a ? 1 : 0);
1469
+ const r = n - (s.length - 1);
1470
+ r > 0 && (s = "0".repeat(r) + s);
1471
+ const o = s.length - n;
1472
+ let p = s.slice(-n);
1473
+ return parseInt(p[t]) >= 5 ? p = `${p.substring(0, t - 1)}${(parseInt(p[t - 1]) + 1).toString()}` : p = p.substring(0, t), `${a ? "-" : ""}${s.slice(0, o)}.${p}`.replace(
1474
+ /\.?0*$/,
1475
+ ""
1476
+ );
1477
+ }
1478
+ var U, k, B, H, le, He, Q, pe, ee, ye;
1479
+ const Kt = class $e {
1116
1480
  constructor(t) {
1117
- B(this, L), B(this, ie), B(this, re), B(this, z), B(this, H), B(this, Z), B(this, k), N(this, "decimalMultiplier", 10n ** 8n), N(this, "bigIntValue", 0n), N(this, "decimal");
1118
- const n = typeof t == "object", a = n ? t.value : t;
1119
- this.decimal = n ? t.decimal : void 0, this.decimalMultiplier = U(
1120
- Math.max(R(this, Z, oe).call(this, R(this, H, W).call(this, a)), this.decimal || 0)
1121
- ), R(this, ie, ve).call(this, a);
1481
+ $(this, U), $(this, B), $(this, le), $(this, Q), $(this, ee), I(this, "decimalMultiplier", 10n ** 8n), I(this, "bigIntValue", 0n), I(this, "decimal");
1482
+ const n = me(t), a = typeof t == "object";
1483
+ this.decimal = a ? t.decimal : void 0, this.decimalMultiplier = a && "decimalMultiplier" in t ? t.decimalMultiplier : L(Math.max(ke(te(n)), this.decimal || 0)), R(this, le, He).call(this, n);
1122
1484
  }
1123
1485
  static fromBigInt(t, n) {
1124
- return new Q({
1486
+ return new $e({
1125
1487
  decimal: n,
1126
- value: ge({ value: t, bigIntDecimal: n, decimal: n })
1488
+ value: se({ value: t, bigIntDecimal: n, decimal: n })
1127
1489
  });
1128
1490
  }
1129
1491
  static shiftDecimals({
@@ -1131,179 +1493,260 @@ const mt = class Q {
1131
1493
  from: n,
1132
1494
  to: a
1133
1495
  }) {
1134
- return Q.fromBigInt(
1135
- new Q(t).bigIntValue * U(a) / U(n),
1496
+ return this.fromBigInt(
1497
+ t.getBaseValue("bigint") * L(a) / L(n),
1136
1498
  a
1137
1499
  );
1138
1500
  }
1139
- get unsafeNumber() {
1140
- return parseFloat((this.bigIntValue / this.decimalMultiplier).toString());
1141
- }
1142
- get baseValue() {
1143
- return R(this, k, J).call(this, "string");
1144
- }
1145
- get baseValueNumber() {
1146
- return R(this, k, J).call(this, "number");
1147
- }
1148
- get baseValueBigInt() {
1149
- return R(this, k, J).call(this, "number");
1150
- }
1151
- get value() {
1152
- return this.formatBigIntToSafeValue(
1153
- this.bigIntValue,
1154
- this.decimal || G(this.decimalMultiplier)
1155
- );
1501
+ set(t) {
1502
+ return new this.constructor({ decimal: this.decimal, value: t, identifier: this.toString() });
1156
1503
  }
1157
1504
  add(...t) {
1158
- return R(this, L, $).call(this, "add", ...t);
1505
+ return R(this, U, k).call(this, "add", ...t);
1159
1506
  }
1160
1507
  sub(...t) {
1161
- return R(this, L, $).call(this, "sub", ...t);
1508
+ return R(this, U, k).call(this, "sub", ...t);
1162
1509
  }
1163
1510
  mul(...t) {
1164
- return R(this, L, $).call(this, "mul", ...t);
1511
+ return R(this, U, k).call(this, "mul", ...t);
1165
1512
  }
1166
1513
  div(...t) {
1167
- return R(this, L, $).call(this, "div", ...t);
1514
+ return R(this, U, k).call(this, "div", ...t);
1168
1515
  }
1169
1516
  gt(t) {
1170
- return this.bigIntValue > this.getBigIntValue(t);
1517
+ return R(this, B, H).call(this, "gt", t);
1171
1518
  }
1172
1519
  gte(t) {
1173
- return this.bigIntValue >= this.getBigIntValue(t);
1520
+ return R(this, B, H).call(this, "gte", t);
1174
1521
  }
1175
1522
  lt(t) {
1176
- return this.bigIntValue < this.getBigIntValue(t);
1523
+ return R(this, B, H).call(this, "lt", t);
1177
1524
  }
1178
1525
  lte(t) {
1179
- return this.bigIntValue <= this.getBigIntValue(t);
1526
+ return R(this, B, H).call(this, "lte", t);
1180
1527
  }
1181
1528
  eqValue(t) {
1182
- return this.bigIntValue === this.getBigIntValue(t);
1529
+ return R(this, B, H).call(this, "eqValue", t);
1530
+ }
1531
+ // @ts-expect-error False positive
1532
+ getValue(t) {
1533
+ const n = this.formatBigIntToSafeValue(
1534
+ this.bigIntValue,
1535
+ this.decimal || G(this.decimalMultiplier)
1536
+ );
1537
+ switch (t) {
1538
+ case "number":
1539
+ return Number(n);
1540
+ case "string":
1541
+ return n;
1542
+ case "bigint":
1543
+ return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
1544
+ }
1545
+ }
1546
+ // @ts-expect-error
1547
+ getBaseValue(t) {
1548
+ const n = this.decimalMultiplier / L(this.decimal || w.THOR), a = this.bigIntValue / n;
1549
+ switch (t) {
1550
+ case "number":
1551
+ return Number(a);
1552
+ case "string":
1553
+ return a.toString();
1554
+ case "bigint":
1555
+ return a;
1556
+ }
1183
1557
  }
1184
1558
  getBigIntValue(t, n) {
1185
- return !n && typeof t == "object" ? t.bigIntValue : (t = typeof t == "object" ? t.value : t, R(this, z, pe).call(this, R(this, H, W).call(this, t), n));
1559
+ if (!n && typeof t == "object")
1560
+ return t.bigIntValue;
1561
+ const a = me(t), s = te(a);
1562
+ return s === "0" || s === "undefined" ? 0n : R(this, ee, ye).call(this, s, n);
1563
+ }
1564
+ toSignificant(t = 6) {
1565
+ const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
1566
+ if ((parseInt(s) ? s.length + r.length : r.length) <= t)
1567
+ return this.getValue("string");
1568
+ if (s.length >= t)
1569
+ return s.slice(0, t).padEnd(s.length, "0");
1570
+ if (parseInt(s))
1571
+ return `${s}.${r.slice(0, t - s.length)}`.padEnd(
1572
+ t - s.length,
1573
+ "0"
1574
+ );
1575
+ const o = parseInt(r), p = `${o}`.slice(0, t);
1576
+ return `0.${p.padStart(
1577
+ r.length - `${o}`.length + p.length,
1578
+ "0"
1579
+ )}`;
1580
+ }
1581
+ toFixed(t = 6) {
1582
+ const [n, a] = this.getValue("string").split("."), s = n || "", r = a || "";
1583
+ if (parseInt(s))
1584
+ return `${s}.${r.slice(0, t)}`.padEnd(t, "0");
1585
+ const o = parseInt(r), p = `${o}`.slice(0, t);
1586
+ return `0.${p.padStart(
1587
+ r.length - `${o}`.length + p.length,
1588
+ "0"
1589
+ )}`;
1590
+ }
1591
+ toAbbreviation(t = 2) {
1592
+ const n = this.getValue("number"), a = ["", "K", "M", "B", "T", "Q", "Qi", "S"], s = Math.floor(Math.log10(Math.abs(n)) / 3), r = a[s];
1593
+ if (!r)
1594
+ return this.getValue("string");
1595
+ const o = 10 ** (s * 3);
1596
+ return `${(n / o).toFixed(t)}${r}`;
1597
+ }
1598
+ toCurrency(t = "$", {
1599
+ currencyPosition: n = "start",
1600
+ decimal: a = 2,
1601
+ decimalSeparator: s = ".",
1602
+ thousandSeparator: r = ","
1603
+ } = {}) {
1604
+ const o = this.getValue("number"), [p, d = ""] = o.toFixed(6).split("."), l = p.replace(/\B(?=(\d{3})+(?!\d))/g, r), u = !p && !d ? "0.00" : p === "0" ? `${parseFloat(`0.${d}`)}`.replace(".", s) : `${l}${parseInt(d) ? `${s}${d.slice(0, a)}` : ""}`;
1605
+ return `${n === "start" ? t : ""}${u}${n === "end" ? t : ""}`;
1186
1606
  }
1187
1607
  formatBigIntToSafeValue(t, n) {
1188
- const a = n || this.decimal || K, i = Math.max(
1608
+ const a = n || this.decimal || W, s = Math.max(
1189
1609
  a,
1190
1610
  G(this.decimalMultiplier)
1191
- ), r = t < 0n;
1192
- let p = t.toString().substring(r ? 1 : 0);
1193
- const d = i - (p.length - 1);
1194
- d > 0 && (p = "0".repeat(d) + p);
1195
- const l = p.length - i;
1196
- let c = p.slice(-i);
1197
- return parseInt(c[a]) >= 5 ? c = `${c.substring(0, a - 1)}${(parseInt(c[a - 1]) + 1).toString()}` : c = c.substring(0, a), `${r ? "-" : ""}${p.slice(0, l)}.${c}`.replace(
1198
- /\.?0*$/,
1199
- ""
1200
- );
1201
- }
1202
- toSignificant(t) {
1203
- const n = this.value.split("."), a = n[0], i = n[1];
1204
- return i ? `${a}.${i.slice(0, t || this.decimal)}`.replace(
1205
- /\.?0*$/,
1206
- ""
1207
- ) : a;
1611
+ ), r = t < 0n, o = t.toString().substring(r ? 1 : 0), p = s - (o.length - 1), d = p > 0 ? "0".repeat(p) + o : o, l = d.length - s;
1612
+ let u = d.slice(-s);
1613
+ return parseInt(u[a]) >= 5 ? u = `${u.substring(0, a - 1)}${(parseInt(u[a - 1]) + 1).toString()}` : u = u.substring(0, a), `${r ? "-" : ""}${d.slice(
1614
+ 0,
1615
+ l
1616
+ )}.${u}`.replace(/\.?0*$/, "");
1208
1617
  }
1209
1618
  };
1210
- L = /* @__PURE__ */ new WeakSet(), $ = function(e, ...t) {
1211
- const n = R(this, re, _e).call(this, this, ...t), a = U(n), i = t.reduce(
1619
+ U = /* @__PURE__ */ new WeakSet(), k = function(e, ...t) {
1620
+ const n = R(this, Q, pe).call(this, this, ...t), a = Math.max(n, G(this.decimalMultiplier)), s = L(a), r = t.reduce(
1212
1621
  (p, d) => {
1213
- const l = this.getBigIntValue(d, n);
1214
- if (e === "div" && l === 0n)
1215
- throw new RangeError("Division by zero");
1216
- return e === "add" ? p + l : e === "sub" ? p - l : e === "mul" ? p * l / a : p * a / l;
1622
+ const l = this.getBigIntValue(d, a);
1623
+ switch (e) {
1624
+ case "add":
1625
+ return p + l;
1626
+ case "sub":
1627
+ return p - l;
1628
+ case "mul":
1629
+ return p * l / s;
1630
+ case "div": {
1631
+ if (l === 0n)
1632
+ throw new RangeError("Division by zero");
1633
+ return p * s / l;
1634
+ }
1635
+ default:
1636
+ return p;
1637
+ }
1217
1638
  },
1218
1639
  //normalize is to precision multiplier base
1219
- this.bigIntValue * a / this.decimalMultiplier
1220
- ), r = ge({
1221
- bigIntDecimal: n,
1222
- decimal: Math.max(n, G(this.decimalMultiplier)),
1223
- value: i
1640
+ this.bigIntValue * s / this.decimalMultiplier
1641
+ ), o = se({
1642
+ bigIntDecimal: a,
1643
+ decimal: a,
1644
+ value: r
1224
1645
  });
1225
- return new this.constructor({ decimal: this.decimal, value: r, identifier: this.toString() });
1226
- }, ie = /* @__PURE__ */ new WeakSet(), ve = function(e, t) {
1227
- const n = R(this, H, W).call(this, e) || "0";
1228
- this.bigIntValue = t || R(this, z, pe).call(this, n);
1229
- }, re = /* @__PURE__ */ new WeakSet(), _e = function(...e) {
1230
- const t = e.map(
1231
- (n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : R(this, Z, oe).call(this, R(this, H, W).call(this, n))
1232
- ).filter(Boolean);
1233
- return Math.max(...t, K);
1234
- }, z = /* @__PURE__ */ new WeakSet(), pe = function(e, t) {
1235
- const n = t ? U(t) : this.decimalMultiplier, a = G(n), [i, r = ""] = e.split(".");
1236
- return BigInt(`${i}${r.padEnd(a, "0")}`);
1237
- }, H = /* @__PURE__ */ new WeakSet(), W = function(e) {
1238
- const t = `${typeof e == "number" ? Number(e).toLocaleString("fullwide", {
1239
- useGrouping: !1,
1240
- maximumFractionDigits: 20
1241
- }) : e}`.replaceAll(",", ".").split(".");
1242
- return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
1243
- }, Z = /* @__PURE__ */ new WeakSet(), oe = function(e) {
1244
- var t;
1245
- const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
1246
- return Math.max(n, K);
1247
- }, k = /* @__PURE__ */ new WeakSet(), J = function(e) {
1248
- const t = this.decimalMultiplier / U(this.decimal || 0), n = this.bigIntValue / t;
1646
+ return new this.constructor({
1647
+ decimalMultiplier: L(a),
1648
+ decimal: this.decimal,
1649
+ value: o,
1650
+ identifier: this.toString()
1651
+ });
1652
+ }, B = /* @__PURE__ */ new WeakSet(), H = function(e, ...t) {
1653
+ const n = R(this, Q, pe).call(this, this, ...t), a = this.getBigIntValue(t[0], n), s = this.getBigIntValue(this, n);
1249
1654
  switch (e) {
1250
- case "number":
1251
- return Number(n);
1252
- case "string":
1253
- return n.toString();
1254
- default:
1255
- return n;
1655
+ case "gt":
1656
+ return s > a;
1657
+ case "gte":
1658
+ return s >= a;
1659
+ case "lt":
1660
+ return s < a;
1661
+ case "lte":
1662
+ return s <= a;
1663
+ case "eqValue":
1664
+ return s === a;
1256
1665
  }
1666
+ }, le = /* @__PURE__ */ new WeakSet(), He = function(e) {
1667
+ const t = te(e) || "0";
1668
+ this.bigIntValue = R(this, ee, ye).call(this, t);
1669
+ }, Q = /* @__PURE__ */ new WeakSet(), pe = function(...e) {
1670
+ const t = e.map((n) => typeof n == "object" ? n.decimal || G(n.decimalMultiplier) : ke(te(n))).filter(Boolean);
1671
+ return Math.max(...t, W);
1672
+ }, ee = /* @__PURE__ */ new WeakSet(), ye = function(e, t) {
1673
+ const n = t ? L(t) : this.decimalMultiplier, a = G(n), [s = "", r = ""] = e.split(".");
1674
+ return BigInt(`${s}${r.padEnd(a, "0")}`);
1257
1675
  };
1258
- let de = mt, ue;
1259
- const se = (e) => {
1260
- if (!ue)
1676
+ let ce = Kt;
1677
+ const Yt = Intl.NumberFormat("fullwide", {
1678
+ useGrouping: !1,
1679
+ maximumFractionDigits: 20
1680
+ });
1681
+ function te(e) {
1682
+ const t = `${typeof e == "number" ? Yt.format(e) : me(e)}`.replaceAll(",", ".").split(".");
1683
+ return t.length > 1 ? `${t.slice(0, -1).join("")}.${t.at(-1)}` : t[0];
1684
+ }
1685
+ function ke(e) {
1686
+ var t;
1687
+ const n = ((t = e.split(".")[1]) == null ? void 0 : t.length) || 0;
1688
+ return Math.max(n, W);
1689
+ }
1690
+ function me(e) {
1691
+ return typeof e == "object" ? "getValue" in e ? e.getValue("string") : e.value : e;
1692
+ }
1693
+ const z = (e, t) => typeof e == "bigint" ? se({ value: e, bigIntDecimal: t, decimal: t }) : e;
1694
+ let Te;
1695
+ const Oe = (e) => {
1696
+ if (!Te)
1261
1697
  throw new Error("Static assets not loaded, call await AssetValue.loadStaticAssets() first");
1262
- return ue.get(e.toUpperCase()) || { decimal: E.THOR, identifier: "" };
1263
- }, he = async (e, t = 0) => {
1264
- ct(e);
1265
- const n = await Se(ye(e));
1266
- return new v({ decimal: n, value: t, identifier: e });
1698
+ return Te.get(e.toUpperCase()) || { decimal: w.THOR, identifier: "" };
1699
+ }, Se = async (e, t = 0) => {
1700
+ jt(e);
1701
+ const n = await bt(he(e)), a = z(t, n);
1702
+ return new M({ decimal: n, value: a, identifier: e });
1267
1703
  };
1268
- class v extends de {
1704
+ class M extends ce {
1269
1705
  constructor(t) {
1706
+ const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`;
1270
1707
  super(
1271
- t.value instanceof de ? t.value : { decimal: t.decimal, value: t.value }
1272
- ), N(this, "address"), N(this, "chain"), N(this, "isSynthetic", !1), N(this, "isGasAsset", !1), N(this, "symbol"), N(this, "ticker"), N(this, "type");
1273
- const n = "identifier" in t ? t.identifier : `${t.chain}.${t.symbol}`, a = ye(n);
1274
- this.type = ot(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset;
1708
+ t.value instanceof ce ? t.value : { decimal: t.decimal, value: t.value }
1709
+ ), I(this, "address"), I(this, "chain"), I(this, "isGasAsset", !1), I(this, "isSynthetic", !1), I(this, "symbol"), I(this, "tax"), I(this, "ticker"), I(this, "type");
1710
+ const a = he(n);
1711
+ this.type = Et(a), this.chain = a.chain, this.ticker = a.ticker, this.symbol = a.symbol, this.address = a.address, this.isSynthetic = a.isSynthetic, this.isGasAsset = a.isGasAsset, this.tax = t.tax;
1712
+ }
1713
+ toString(t = !1) {
1714
+ const n = this.isSynthetic ? this.symbol : this.ticker;
1715
+ return t ? (
1716
+ // ETH/THOR-0xa5f2211b9b8170f694421f2046281775e8468044 | USDT
1717
+ n
1718
+ ) : (
1719
+ // THOR.ETH/ETH | ETH.USDT-0x1234567890
1720
+ `${this.chain}.${this.symbol}`
1721
+ );
1722
+ }
1723
+ toUrl() {
1724
+ return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
1725
+ }
1726
+ eq({ chain: t, symbol: n }) {
1727
+ return this.chain === t && this.symbol === n;
1275
1728
  }
1276
1729
  static async fromString(t, n = 0) {
1277
- return he(t, n);
1730
+ return Se(t, n);
1278
1731
  }
1279
1732
  static fromStringSync(t, n = 0) {
1280
- const { decimal: a, identifier: i } = se(
1281
- t
1282
- );
1283
- return i ? new v({ decimal: a, identifier: i, value: n }) : void 0;
1733
+ const { isSynthetic: a } = he(t), {
1734
+ tax: s,
1735
+ decimal: r,
1736
+ identifier: o
1737
+ } = Oe(t), p = z(n, r);
1738
+ return o ? new M({ tax: s, decimal: r, identifier: o, value: p }) : a ? new M({ tax: s, decimal: 8, identifier: t, value: p }) : void 0;
1284
1739
  }
1285
1740
  static async fromIdentifier(t, n = 0) {
1286
- return he(t, n);
1741
+ return Se(t, n);
1287
1742
  }
1288
1743
  static fromIdentifierSync(t, n = 0) {
1289
- const { decimal: a, identifier: i } = se(t);
1290
- return new v({ decimal: a, identifier: i, value: n });
1744
+ const { decimal: a, identifier: s } = Oe(t), r = z(n, a);
1745
+ return new M({ decimal: a, identifier: s, value: r });
1291
1746
  }
1292
1747
  static fromChainOrSignature(t, n = 0) {
1293
- const { decimal: a, identifier: i } = pt(t);
1294
- return new v({ value: n, decimal: a, identifier: i });
1295
- }
1296
- static async fromTCQuote(t, n = 0) {
1297
- const a = await Se(ye(t)), i = this.shiftDecimals({ value: n, from: E.THOR, to: a });
1298
- return new v({ value: i, identifier: t, decimal: a });
1299
- }
1300
- static fromTCQuoteStatic(t, n = 0) {
1301
- const a = se(t), i = this.shiftDecimals({
1302
- value: n,
1303
- from: E.THOR,
1304
- to: a.decimal
1305
- });
1306
- return new v({ ...a, value: i });
1748
+ const { decimal: a, identifier: s } = At(t), r = z(n, a);
1749
+ return new M({ value: r, decimal: a, identifier: s });
1307
1750
  }
1308
1751
  static async loadStaticAssets() {
1309
1752
  return new Promise(
@@ -1313,14 +1756,14 @@ class v extends de {
1313
1756
  // Omit ThorchainList from import to avoid decimals conflict (TC uses 8 for all)
1314
1757
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
1315
1758
  ThorchainList: a,
1316
- NativeList: i,
1759
+ NativeList: s,
1317
1760
  ...r
1318
1761
  } = await import("@swapkit/tokens");
1319
- ue = [i, ...Object.values(r)].reduce(
1320
- (p, { tokens: d }) => (d.forEach(({ identifier: l, chain: c, ...y }) => {
1321
- const u = "decimals" in y ? y.decimals : E[c];
1322
- p.set(l, { identifier: l, decimal: u });
1323
- }), p),
1762
+ Te = [s, ...Object.values(r)].reduce(
1763
+ (o, { tokens: p }) => (p.forEach(({ identifier: d, chain: l, ...u }) => {
1764
+ const c = "decimals" in u ? u.decimals : w[l];
1765
+ o.set(d, { identifier: d, decimal: c });
1766
+ }), o),
1324
1767
  /* @__PURE__ */ new Map()
1325
1768
  ), t({ ok: !0 });
1326
1769
  } catch (a) {
@@ -1333,45 +1776,36 @@ class v extends de {
1333
1776
  }
1334
1777
  );
1335
1778
  }
1336
- get assetValue() {
1337
- return `${this.value} ${this.ticker}`;
1338
- }
1339
- toString() {
1340
- return `${this.chain}.${this.symbol}`;
1341
- }
1342
- eq({ chain: t, symbol: n }) {
1343
- return this.chain === t && this.symbol === n;
1344
- }
1345
1779
  }
1346
- const fe = (e) => {
1347
- const t = v.fromChainOrSignature(e);
1780
+ const de = (e) => {
1781
+ const t = M.fromChainOrSignature(e);
1348
1782
  switch (e) {
1349
- case s.Bitcoin:
1350
- case s.Litecoin:
1351
- case s.BitcoinCash:
1352
- return t.add(10001);
1353
- case s.Dogecoin:
1354
- return t.add(100000001);
1355
- case s.Avalanche:
1356
- case s.Ethereum:
1357
- return t.add(10 * 10 ** 9);
1358
- case s.THORChain:
1359
- case s.Maya:
1360
- return t.add(0);
1783
+ case i.Bitcoin:
1784
+ case i.Litecoin:
1785
+ case i.BitcoinCash:
1786
+ return t.set(10001e-8);
1787
+ case i.Dogecoin:
1788
+ return t.set(1.00000001);
1789
+ case i.Avalanche:
1790
+ case i.Ethereum:
1791
+ return t.set(1e-8);
1792
+ case i.THORChain:
1793
+ case i.Maya:
1794
+ return t.set(0);
1361
1795
  default:
1362
- return t.add(1);
1796
+ return t.set(1e-8);
1363
1797
  }
1364
- }, ye = (e) => {
1365
- const t = e.slice(0, 14).includes("/"), n = e.includes(".") ? e : `${s.THORChain}.${e}`, [a, i] = n.split("."), [r, p] = i.split("-");
1798
+ }, he = (e) => {
1799
+ const t = e.slice(0, 14).includes("/"), [n, a] = e.split(".").pop().split("/"), s = e.includes(".") && !t ? e : `${i.THORChain}.${a}`, [r, o] = s.split("."), [p, d] = (t ? a : o).split("-");
1366
1800
  return {
1367
- address: p == null ? void 0 : p.toLowerCase(),
1368
- chain: a,
1369
- isGasAsset: rt({ chain: a, symbol: i }),
1801
+ address: d == null ? void 0 : d.toLowerCase(),
1802
+ chain: r,
1803
+ isGasAsset: De({ chain: r, symbol: o }),
1370
1804
  isSynthetic: t,
1371
- symbol: p ? `${r}-${(p == null ? void 0 : p.toLowerCase()) ?? ""}` : i,
1372
- ticker: t ? i : r
1805
+ symbol: (t ? `${n}/` : "") + (d ? `${p}-${(d == null ? void 0 : d.toLowerCase()) ?? ""}` : o),
1806
+ ticker: p
1373
1807
  };
1374
- }, Tt = {
1808
+ }, Xt = {
1375
1809
  /**
1376
1810
  * Core
1377
1811
  */
@@ -1430,18 +1864,21 @@ const fe = (e) => {
1430
1864
  };
1431
1865
  class m extends Error {
1432
1866
  constructor(t, n) {
1433
- console.error(n), super(t, { cause: { code: Tt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
1867
+ console.error(n, { stack: n == null ? void 0 : n.stack, message: n == null ? void 0 : n.message }), super(t, { cause: { code: Xt[t], message: t } }), Object.setPrototypeOf(this, m.prototype);
1434
1868
  }
1435
1869
  }
1436
- class le extends de {
1870
+ class x extends ce {
1437
1871
  eq(t) {
1438
1872
  return this.eqValue(t);
1439
1873
  }
1440
- toString() {
1441
- return this.value;
1874
+ static fromBigInt(t, n) {
1875
+ return new x({
1876
+ decimal: n,
1877
+ value: se({ value: t, bigIntDecimal: n, decimal: n })
1878
+ });
1442
1879
  }
1443
1880
  }
1444
- const _t = [
1881
+ const Jt = [
1445
1882
  {
1446
1883
  inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
1447
1884
  stateMutability: "nonpayable",
@@ -1532,7 +1969,7 @@ const _t = [
1532
1969
  type: "function"
1533
1970
  },
1534
1971
  { stateMutability: "payable", type: "receive" }
1535
- ], ht = [
1972
+ ], Qt = [
1536
1973
  {
1537
1974
  inputs: [
1538
1975
  { internalType: "address", name: "_ttp", type: "address" },
@@ -1676,7 +2113,7 @@ const _t = [
1676
2113
  type: "function"
1677
2114
  },
1678
2115
  { stateMutability: "payable", type: "receive" }
1679
- ], ft = [
2116
+ ], zt = [
1680
2117
  {
1681
2118
  inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
1682
2119
  stateMutability: "nonpayable",
@@ -1781,7 +2218,7 @@ const _t = [
1781
2218
  type: "function"
1782
2219
  },
1783
2220
  { stateMutability: "payable", type: "receive" }
1784
- ], bt = [
2221
+ ], Zt = [
1785
2222
  {
1786
2223
  inputs: [{ internalType: "address", name: "_ttp", type: "address" }],
1787
2224
  stateMutability: "nonpayable",
@@ -1872,7 +2309,7 @@ const _t = [
1872
2309
  type: "function"
1873
2310
  },
1874
2311
  { stateMutability: "payable", type: "receive" }
1875
- ], At = [
2312
+ ], en = [
1876
2313
  {
1877
2314
  inputs: [
1878
2315
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2016,7 +2453,7 @@ const _t = [
2016
2453
  type: "function"
2017
2454
  },
2018
2455
  { stateMutability: "payable", type: "receive" }
2019
- ], wt = [
2456
+ ], tn = [
2020
2457
  {
2021
2458
  inputs: [
2022
2459
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2135,7 +2572,7 @@ const _t = [
2135
2572
  type: "function"
2136
2573
  },
2137
2574
  { stateMutability: "payable", type: "receive" }
2138
- ], Et = [
2575
+ ], nn = [
2139
2576
  {
2140
2577
  inputs: [
2141
2578
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2254,7 +2691,7 @@ const _t = [
2254
2691
  type: "function"
2255
2692
  },
2256
2693
  { stateMutability: "payable", type: "receive" }
2257
- ], Rt = [
2694
+ ], an = [
2258
2695
  {
2259
2696
  inputs: [
2260
2697
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2373,7 +2810,7 @@ const _t = [
2373
2810
  type: "function"
2374
2811
  },
2375
2812
  { stateMutability: "payable", type: "receive" }
2376
- ], Ot = [
2813
+ ], sn = [
2377
2814
  {
2378
2815
  inputs: [
2379
2816
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2492,7 +2929,7 @@ const _t = [
2492
2929
  type: "function"
2493
2930
  },
2494
2931
  { stateMutability: "payable", type: "receive" }
2495
- ], It = [
2932
+ ], rn = [
2496
2933
  {
2497
2934
  inputs: [
2498
2935
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2619,7 +3056,7 @@ const _t = [
2619
3056
  type: "function"
2620
3057
  },
2621
3058
  { stateMutability: "payable", type: "receive" }
2622
- ], St = [
3059
+ ], on = [
2623
3060
  {
2624
3061
  inputs: [
2625
3062
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2746,7 +3183,7 @@ const _t = [
2746
3183
  type: "function"
2747
3184
  },
2748
3185
  { stateMutability: "payable", type: "receive" }
2749
- ], gt = [
3186
+ ], pn = [
2750
3187
  {
2751
3188
  inputs: [
2752
3189
  { internalType: "address", name: "_ttp", type: "address" },
@@ -2873,7 +3310,7 @@ const _t = [
2873
3310
  type: "function"
2874
3311
  },
2875
3312
  { stateMutability: "payable", type: "receive" }
2876
- ], vt = [
3313
+ ], dn = [
2877
3314
  {
2878
3315
  inputs: [
2879
3316
  { internalType: "address", name: "_ttp", type: "address" },
@@ -3000,7 +3437,7 @@ const _t = [
3000
3437
  type: "function"
3001
3438
  },
3002
3439
  { stateMutability: "payable", type: "receive" }
3003
- ], Mt = [
3440
+ ], un = [
3004
3441
  {
3005
3442
  inputs: [
3006
3443
  { internalType: "address", name: "_ttp", type: "address" },
@@ -3127,236 +3564,240 @@ const _t = [
3127
3564
  type: "function"
3128
3565
  },
3129
3566
  { stateMutability: "payable", type: "receive" }
3130
- ], Me = {
3131
- ["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: _t,
3132
- ["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: ft,
3133
- ["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: bt
3134
- }, Ct = {
3135
- ...Me,
3567
+ ], Fe = {
3568
+ ["0x7C38b8B2efF28511ECc14a621e263857Fb5771d3".toLowerCase()]: Jt,
3569
+ ["0xB6fA6f1DcD686F4A573Fd243a6FABb4ba36Ba98c".toLowerCase()]: zt,
3570
+ ["0xd31f7e39afECEc4855fecc51b693F9A0Cec49fd2".toLowerCase()]: Zt
3571
+ }, ln = {
3572
+ ...Fe,
3136
3573
  // AVAX
3137
- ["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: wt,
3138
- ["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: ht,
3139
- ["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: Rt,
3574
+ ["0x942c6dA485FD6cEf255853ef83a149d43A73F18a".toLowerCase()]: tn,
3575
+ ["0x5505BE604dFA8A1ad402A71f8A357fba47F9bf5a".toLowerCase()]: Qt,
3576
+ ["0x3b7DbdD635B99cEa39D3d95Dbd0217F05e55B212".toLowerCase()]: an,
3140
3577
  // BSC
3141
- ["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: At,
3578
+ ["0x30912B38618D3D37De3191A4FFE982C65a9aEC2E".toLowerCase()]: en,
3142
3579
  // ETH
3143
- ["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: Et,
3144
- ["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: Ot,
3145
- ["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: It,
3146
- ["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: St,
3147
- ["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: gt,
3148
- ["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: vt,
3149
- ["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: Mt
3150
- }, Nt = ({
3580
+ ["0xbf365e79aA44A2164DA135100C57FDB6635ae870".toLowerCase()]: nn,
3581
+ ["0x86904Eb2b3c743400D03f929F2246EfA80B91215".toLowerCase()]: sn,
3582
+ ["0x3660dE6C56cFD31998397652941ECe42118375DA".toLowerCase()]: rn,
3583
+ ["0xBd68cBe6c247e2c3a0e36B8F0e24964914f26Ee8".toLowerCase()]: on,
3584
+ ["0xe4ddca21881bac219af7f217703db0475d2a9f02".toLowerCase()]: pn,
3585
+ ["0x11733abf0cdb43298f7e949c930188451a9a9ef2".toLowerCase()]: dn,
3586
+ ["0xb33874810e5395eb49d8bd7e912631db115d5a03".toLowerCase()]: un
3587
+ }, yn = ({
3151
3588
  streamSwap: e,
3152
3589
  contractAddress: t,
3153
3590
  recipient: n,
3154
3591
  toChecksumAddress: a,
3155
3592
  calldata: {
3156
- amount: i,
3593
+ amount: s,
3157
3594
  amountOutMin: r = "",
3158
- data: p = "",
3159
- deadline: d,
3160
- memo: l,
3161
- router: c,
3162
- memoStreamingSwap: y,
3163
- tcMemo: u,
3164
- tcRouter: h,
3165
- tcVault: _,
3166
- vault: O,
3167
- token: I
3595
+ data: o = "",
3596
+ deadline: p,
3597
+ memo: d,
3598
+ router: l,
3599
+ memoStreamingSwap: u,
3600
+ tcMemo: c,
3601
+ tcRouter: _,
3602
+ tcVault: b,
3603
+ vault: A,
3604
+ token: E
3168
3605
  }
3169
3606
  }) => {
3170
- const g = !!Me[t.toLowerCase()];
3171
- if (g && !c)
3607
+ const O = !!Fe[t.toLowerCase()];
3608
+ if (O && !l)
3172
3609
  throw new Error("Router is required on calldata for swapIn with GenericContract");
3173
- const S = u || l, b = e && y || S;
3174
- if (!_ && !O)
3610
+ const S = c || d, D = e && u || S;
3611
+ if (!b && !A)
3175
3612
  throw new Error("TC Vault is required on calldata");
3176
- if (!h && !c)
3613
+ if (!_ && !l)
3177
3614
  throw new Error("TC Router is required on calldata");
3178
- if (!b)
3615
+ if (!D)
3179
3616
  throw new Error("TC Memo is required on calldata");
3180
- if (!I)
3617
+ if (!E)
3181
3618
  throw new Error("Token is required on calldata");
3182
- const M = [
3619
+ const ie = [
3183
3620
  // v2 contracts don't have tcVault, tcRouter, tcMemo but vault, router, memo
3184
- a(h || c),
3185
- a(_ || O),
3186
- b.replace("{recipientAddress}", n),
3187
- a(I),
3188
- i
3189
- ], ne = g ? [a(c), p, d] : [r, d];
3190
- return [...M, ...ne];
3191
- }, Dt = ({ chain: e, txHash: t }) => {
3192
- const n = Re[e];
3621
+ a(_ || l),
3622
+ a(b || A),
3623
+ D.replace("{recipientAddress}", n),
3624
+ a(E),
3625
+ s
3626
+ ], Ge = O ? [a(l), o, p] : [r, p];
3627
+ return [...ie, ...Ge];
3628
+ }, cn = ({ chain: e, txHash: t }) => {
3629
+ const n = Ne[e];
3193
3630
  switch (e) {
3194
- case s.Binance:
3195
- case s.Bitcoin:
3196
- case s.BitcoinCash:
3197
- case s.Maya:
3198
- case s.Kujira:
3199
- case s.THORChain:
3200
- return `${n}/tx/${t}`;
3201
- case s.Arbitrum:
3202
- case s.Avalanche:
3203
- case s.BinanceSmartChain:
3204
- case s.Ethereum:
3205
- case s.Optimism:
3206
- case s.Polygon:
3631
+ case i.Binance:
3632
+ case i.Bitcoin:
3633
+ case i.BitcoinCash:
3634
+ case i.Maya:
3635
+ case i.Kujira:
3636
+ case i.THORChain:
3637
+ return `${n}/tx/${t.startsWith("0x") ? t.slice(2) : t}`;
3638
+ case i.Arbitrum:
3639
+ case i.Avalanche:
3640
+ case i.BinanceSmartChain:
3641
+ case i.Ethereum:
3642
+ case i.Optimism:
3643
+ case i.Polygon:
3207
3644
  return `${n}/tx/${t.startsWith("0x") ? t : `0x${t}`}`;
3208
- case s.Cosmos:
3645
+ case i.Cosmos:
3209
3646
  return `${n}/transactions/${t}`;
3210
- case s.Dogecoin:
3647
+ case i.Dogecoin:
3211
3648
  return `${n}/transaction/${t.toLowerCase()}`;
3212
- case s.Litecoin:
3649
+ case i.Litecoin:
3213
3650
  return `${n}/${t}`;
3214
3651
  default:
3215
3652
  throw new Error(`Unsupported chain: ${e}`);
3216
3653
  }
3217
- }, xt = ({ chain: e, address: t }) => {
3218
- const n = Re[e];
3654
+ }, mn = ({ chain: e, address: t }) => {
3655
+ const n = Ne[e];
3219
3656
  switch (e) {
3220
- case s.Arbitrum:
3221
- case s.Avalanche:
3222
- case s.Binance:
3223
- case s.BinanceSmartChain:
3224
- case s.Bitcoin:
3225
- case s.BitcoinCash:
3226
- case s.Dogecoin:
3227
- case s.Ethereum:
3228
- case s.Maya:
3229
- case s.Optimism:
3230
- case s.Polygon:
3231
- case s.Kujira:
3232
- case s.THORChain:
3657
+ case i.Arbitrum:
3658
+ case i.Avalanche:
3659
+ case i.Binance:
3660
+ case i.BinanceSmartChain:
3661
+ case i.Bitcoin:
3662
+ case i.BitcoinCash:
3663
+ case i.Dogecoin:
3664
+ case i.Ethereum:
3665
+ case i.Maya:
3666
+ case i.Optimism:
3667
+ case i.Polygon:
3668
+ case i.Kujira:
3669
+ case i.THORChain:
3233
3670
  return `${n}/address/${t}`;
3234
- case s.Cosmos:
3671
+ case i.Cosmos:
3235
3672
  return `${n}/account/${t}`;
3236
- case s.Litecoin:
3673
+ case i.Litecoin:
3237
3674
  return `${n}/${t}`;
3238
3675
  default:
3239
3676
  throw new Error(`Unsupported chain: ${e}`);
3240
3677
  }
3241
- }, Pt = (e) => {
3678
+ }, Tn = (e) => {
3242
3679
  const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
3243
- return Oe(`${t}/thorchain/inbound_addresses`);
3244
- }, Bt = (e) => {
3680
+ return we.get(`${t}/thorchain/inbound_addresses`);
3681
+ }, hn = (e) => {
3245
3682
  const t = e ? q.ThornodeStagenet : q.ThornodeMainnet;
3246
- return Oe(`${t}/thorchain/mimir`);
3247
- }, be = () => Object.values(s).reduce(
3683
+ return we.get(`${t}/thorchain/mimir`);
3684
+ }, Ie = () => Object.values(i).reduce(
3248
3685
  (e, t) => (e[t] = null, e),
3249
3686
  {}
3250
3687
  );
3251
- var V, ee, Y, D, X, j;
3252
- class en {
3688
+ var V, ne, j, v, K, Y;
3689
+ class Ln {
3253
3690
  constructor({ stagenet: t } = {}) {
3254
- T(this, "connectedChains", be());
3255
- T(this, "connectedWallets", be());
3691
+ T(this, "connectedChains", Ie());
3692
+ T(this, "connectedWallets", Ie());
3256
3693
  T(this, "stagenet", !1);
3257
3694
  T(this, "getAddress", (t) => {
3258
3695
  var n;
3259
3696
  return ((n = this.connectedChains[t]) == null ? void 0 : n.address) || "";
3260
3697
  });
3261
- T(this, "getExplorerTxUrl", (t, n) => Dt({ chain: t, txHash: n }));
3698
+ T(this, "getExplorerTxUrl", (t, n) => cn({ chain: t, txHash: n }));
3262
3699
  T(this, "getWallet", (t) => this.connectedWallets[t]);
3263
- T(this, "getExplorerAddressUrl", (t, n) => xt({ chain: t, address: n }));
3700
+ T(this, "getExplorerAddressUrl", (t, n) => mn({ chain: t, address: n }));
3264
3701
  T(this, "getBalance", async (t, n) => {
3265
- var i;
3266
- if (!n)
3267
- return ((i = this.connectedChains[t]) == null ? void 0 : i.balance) || [];
3268
- const a = await this.getWalletByChain(t);
3702
+ const a = await this.getWalletByChain(t, n);
3269
3703
  return (a == null ? void 0 : a.balance) || [];
3270
3704
  });
3271
- T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: i }) => {
3272
- var d, l, c, y;
3273
- const { quoteMode: r } = a.meta, p = r.startsWith("ERC20-") ? s.Ethereum : r.startsWith("ARC20-") ? s.Avalanche : s.BinanceSmartChain;
3705
+ T(this, "swap", async ({ streamSwap: t, recipient: n, route: a, feeOptionKey: s }) => {
3706
+ var p, d;
3707
+ const { quoteMode: r } = a.meta, o = r.startsWith("ERC20-") ? i.Ethereum : r.startsWith("ARC20-") ? i.Avalanche : i.BinanceSmartChain;
3274
3708
  if (!a.complete)
3275
3709
  throw new m("core_swap_route_not_complete");
3276
3710
  try {
3277
- if (He.includes(r)) {
3278
- const u = this.connectedWallets[p];
3279
- if (!(u != null && u.sendTransaction))
3711
+ if (Ze.includes(r)) {
3712
+ const l = this.connectedWallets[o];
3713
+ if (!(l != null && l.sendTransaction))
3280
3714
  throw new m("core_wallet_connection_not_found");
3281
- if (!(t ? (d = a == null ? void 0 : a.streamingSwap) == null ? void 0 : d.transaction : a == null ? void 0 : a.transaction))
3715
+ if (!(t ? (p = a == null ? void 0 : a.streamingSwap) == null ? void 0 : p.transaction : a == null ? void 0 : a.transaction))
3282
3716
  throw new m("core_swap_route_transaction_not_found");
3283
- const { isHexString: _, parseUnits: O } = await import("./index-cf1865cd.js"), { data: I, from: g, to: S, value: b } = a.transaction, M = {
3284
- data: I,
3285
- from: g,
3286
- to: S.toLowerCase(),
3287
- chainId: BigInt(Ye[p]),
3288
- value: b ? new le({
3289
- value: _(b) ? b : O(b, "wei").toString(16)
3290
- }).baseValueBigInt : 0n
3717
+ const { data: c, from: _, to: b, value: A } = a.transaction, E = {
3718
+ data: c,
3719
+ from: _,
3720
+ to: b.toLowerCase(),
3721
+ chainId: BigInt(pt[o]),
3722
+ value: A ? BigInt(A) : 0n
3291
3723
  };
3292
- return u.sendTransaction(M, i);
3724
+ return l.sendTransaction(E, s);
3293
3725
  }
3294
- if (ke.includes(r)) {
3726
+ if (tt.includes(r)) {
3295
3727
  if (!a.calldata.fromAsset)
3296
3728
  throw new m("core_swap_asset_not_recognized");
3297
- const u = await v.fromString(a.calldata.fromAsset);
3298
- if (!u)
3729
+ const l = await M.fromString(a.calldata.fromAsset);
3730
+ if (!l)
3299
3731
  throw new m("core_swap_asset_not_recognized");
3300
- const { address: h } = await A(this, V).call(this, u.chain), {
3301
- contract: _,
3302
- calldata: { amountIn: O, memo: I, memoStreamingSwap: g }
3303
- } = a, S = u.add(le.fromBigInt(BigInt(O), u.decimal)), b = t && g || I;
3304
- return this.deposit({ assetValue: S, memo: b, feeOptionKey: i, router: _, recipient: h });
3732
+ const { address: u } = await f(this, V).call(this, l.chain), {
3733
+ contract: c,
3734
+ calldata: { expiration: _, amountIn: b, memo: A, memoStreamingSwap: E }
3735
+ } = a, O = l.add(x.fromBigInt(BigInt(b), l.decimal)), S = t && E || A;
3736
+ return this.deposit({
3737
+ expiration: _,
3738
+ assetValue: O,
3739
+ memo: S,
3740
+ feeOptionKey: s,
3741
+ router: c,
3742
+ recipient: u
3743
+ });
3305
3744
  }
3306
- if ($e.includes(r)) {
3307
- const { calldata: u, contract: h } = a;
3308
- if (!h)
3745
+ if (et.includes(r)) {
3746
+ const { calldata: l, contract: u } = a;
3747
+ if (!u)
3309
3748
  throw new m("core_swap_contract_not_found");
3310
- const _ = this.connectedWallets[p], O = this.getAddress(p);
3311
- if (!(_ != null && _.sendTransaction) || !O)
3749
+ const c = this.connectedWallets[o], _ = this.getAddress(o);
3750
+ if (!(c != null && c.sendTransaction) || !_)
3312
3751
  throw new m("core_wallet_connection_not_found");
3313
- const { getProvider: I, toChecksumAddress: g } = await import("@swapkit/toolbox-evm"), S = I(p), b = Ct[h.toLowerCase()];
3314
- if (!b)
3315
- throw new m("core_swap_contract_not_supported", { contractAddress: h });
3316
- const ne = await ((y = (c = (await ((l = _.createContract) == null ? void 0 : l.call(_, h, b, S))).populateTransaction).swapIn) == null ? void 0 : y.call(
3317
- c,
3318
- ...Nt({
3752
+ const { getProvider: b, toChecksumAddress: A } = await import("@swapkit/toolbox-evm"), E = b(o), O = ln[u.toLowerCase()];
3753
+ if (!O)
3754
+ throw new m("core_swap_contract_not_supported", { contractAddress: u });
3755
+ const D = await (await ((d = c.createContract) == null ? void 0 : d.call(c, u, O, E))).getFunction("swapIn").populateTransaction(
3756
+ ...yn({
3319
3757
  streamSwap: t,
3320
- toChecksumAddress: g,
3321
- contractAddress: h,
3758
+ toChecksumAddress: A,
3759
+ contractAddress: u,
3322
3760
  recipient: n,
3323
- calldata: u
3761
+ calldata: l
3324
3762
  }),
3325
- { from: O }
3326
- ));
3327
- return _.sendTransaction(ne, i);
3763
+ { from: _ }
3764
+ );
3765
+ return c.sendTransaction(D, s);
3328
3766
  }
3329
3767
  throw new m("core_swap_quote_mode_not_supported", { quoteMode: r });
3330
- } catch (u) {
3331
- throw new m("core_swap_transaction_error", u);
3768
+ } catch (l) {
3769
+ throw new m("core_swap_transaction_error", l);
3332
3770
  }
3333
3771
  });
3334
- T(this, "getWalletByChain", async (t) => {
3335
- var i, r;
3336
- const n = this.getAddress(t);
3337
- if (!n)
3772
+ T(this, "getWalletByChain", async (t, n) => {
3773
+ var o, p;
3774
+ const a = this.getAddress(t);
3775
+ if (!a)
3338
3776
  return null;
3339
- const a = await ((i = this.getWallet(t)) == null ? void 0 : i.getBalance(n)) ?? [
3340
- v.fromChainOrSignature(t)
3341
- ];
3342
- return this.connectedChains[t] = {
3343
- address: n,
3344
- balance: a,
3345
- walletType: (r = this.connectedChains[t]) == null ? void 0 : r.walletType
3346
- }, { ...this.connectedChains[t] };
3777
+ const s = [M.fromChainOrSignature(t)], r = (o = this.connectedChains[t]) == null ? void 0 : o.walletType;
3778
+ try {
3779
+ const d = await ((p = this.getWallet(t)) == null ? void 0 : p.getBalance(a, n));
3780
+ return this.connectedChains[t] = {
3781
+ address: a,
3782
+ balance: d != null && d.length ? d : s,
3783
+ walletType: r
3784
+ }, { ...this.connectedChains[t] };
3785
+ } catch (d) {
3786
+ return console.error(d), { address: a, balance: s, walletType: r };
3787
+ }
3347
3788
  });
3348
- T(this, "approveAssetValue", (t, n) => A(this, Y).call(this, { assetValue: t, type: "approve", contractAddress: n }));
3349
- T(this, "isAssetValueApproved", (t, n) => A(this, Y).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
3789
+ T(this, "approveAssetValue", (t, n) => f(this, j).call(this, { assetValue: t, type: "approve", contractAddress: n }));
3790
+ T(this, "isAssetValueApproved", (t, n) => f(this, j).call(this, { assetValue: t, contractAddress: n, type: "checkOnly" }));
3350
3791
  T(this, "validateAddress", ({ address: t, chain: n }) => {
3351
- var a, i;
3352
- return (i = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : i.call(a, t);
3792
+ var a, s;
3793
+ return (s = (a = this.getWallet(n)) == null ? void 0 : a.validateAddress) == null ? void 0 : s.call(a, t);
3353
3794
  });
3354
3795
  T(this, "transfer", async (t) => {
3355
3796
  const n = this.connectedWallets[t.assetValue.chain];
3356
3797
  if (!n)
3357
3798
  throw new m("core_wallet_connection_not_found");
3358
3799
  try {
3359
- return await n.transfer(A(this, j).call(this, t));
3800
+ return await n.transfer(f(this, Y).call(this, t));
3360
3801
  } catch (a) {
3361
3802
  throw new m("core_swap_transaction_error", a);
3362
3803
  }
@@ -3365,43 +3806,45 @@ class en {
3365
3806
  assetValue: t,
3366
3807
  recipient: n,
3367
3808
  router: a,
3368
- ...i
3809
+ ...s
3369
3810
  }) => {
3370
- const { chain: r, symbol: p, ticker: d } = t, l = this.connectedWallets[r];
3371
- if (!l)
3811
+ const { chain: r, symbol: o, ticker: p } = t, d = this.connectedWallets[r];
3812
+ if (!d)
3372
3813
  throw new m("core_wallet_connection_not_found");
3373
- const c = A(this, j).call(this, { assetValue: t, recipient: n, router: a, ...i });
3814
+ const l = f(this, Y).call(this, { assetValue: t, recipient: n, router: a, ...s });
3374
3815
  try {
3375
3816
  switch (r) {
3376
- case s.THORChain: {
3377
- const y = l;
3378
- return await (n === "" ? y.deposit(c) : y.transfer(c));
3817
+ case i.THORChain: {
3818
+ const u = d;
3819
+ return await (n === "" ? u.deposit(l) : u.transfer(l));
3379
3820
  }
3380
- case s.Ethereum:
3381
- case s.BinanceSmartChain:
3382
- case s.Avalanche: {
3383
- const { getChecksumAddressFromAsset: y } = await import("@swapkit/toolbox-evm"), u = r === s.Avalanche ? Ve : r === s.BinanceSmartChain ? Le : Be;
3384
- return await l.call({
3385
- abi: u,
3386
- contractAddress: a || (await A(this, V).call(this, r)).router,
3821
+ case i.Ethereum:
3822
+ case i.BinanceSmartChain:
3823
+ case i.Avalanche: {
3824
+ const { getChecksumAddressFromAsset: u } = await import("@swapkit/toolbox-evm"), c = r === i.Avalanche ? Je : r === i.BinanceSmartChain ? Qe : Xe;
3825
+ return await d.call({
3826
+ abi: c,
3827
+ contractAddress: a || (await f(this, V).call(this, r)).router,
3387
3828
  funcName: "depositWithExpiry",
3388
3829
  funcParams: [
3389
3830
  n,
3390
- y({ chain: r, symbol: p, ticker: d }, r),
3391
- // TODO: (@Towan) Re-Check on that conversion 🙏
3392
- t.baseValueBigInt.toString(),
3393
- c.memo,
3394
- i.expiration
3831
+ u({ chain: r, symbol: o, ticker: p }, r),
3832
+ t.getBaseValue("string"),
3833
+ l.memo,
3834
+ s.expiration || parseInt(`${((/* @__PURE__ */ new Date()).getTime() + 15 * 60 * 1e3) / 1e3}`)
3395
3835
  ],
3396
- txOverrides: { from: c.from, value: t.baseValueBigInt }
3836
+ txOverrides: {
3837
+ from: l.from,
3838
+ value: t.isGasAsset ? t.getBaseValue("bigint") : void 0
3839
+ }
3397
3840
  });
3398
3841
  }
3399
3842
  default:
3400
- return await l.transfer(c);
3843
+ return await d.transfer(l);
3401
3844
  }
3402
- } catch (y) {
3403
- const u = ((y == null ? void 0 : y.message) || (y == null ? void 0 : y.toString())).toLowerCase(), h = u == null ? void 0 : u.includes("insufficient funds"), _ = u == null ? void 0 : u.includes("gas"), O = u == null ? void 0 : u.includes("server"), I = h ? "core_transaction_deposit_insufficient_funds_error" : _ ? "core_transaction_deposit_gas_error" : O ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3404
- throw new m(I, y);
3845
+ } catch (u) {
3846
+ const c = ((u == null ? void 0 : u.message) || (u == null ? void 0 : u.toString())).toLowerCase(), _ = c == null ? void 0 : c.includes("insufficient funds"), b = c == null ? void 0 : c.includes("gas"), A = c == null ? void 0 : c.includes("server"), E = _ ? "core_transaction_deposit_insufficient_funds_error" : b ? "core_transaction_deposit_gas_error" : A ? "core_transaction_deposit_server_error" : "core_transaction_deposit_error";
3847
+ throw new m(E, u);
3405
3848
  }
3406
3849
  });
3407
3850
  /**
@@ -3413,11 +3856,11 @@ class en {
3413
3856
  }) => {
3414
3857
  if (t.lte(0) || n.lte(0))
3415
3858
  throw new m("core_transaction_create_liquidity_invalid_params");
3416
- let a = "", i = "";
3859
+ let a = "", s = "";
3417
3860
  try {
3418
- a = await A(this, D).call(this, {
3861
+ a = await f(this, v).call(this, {
3419
3862
  assetValue: t,
3420
- memo: x(f.DEPOSIT, {
3863
+ memo: N(h.DEPOSIT, {
3421
3864
  ...n,
3422
3865
  address: this.getAddress(n.chain)
3423
3866
  })
@@ -3426,101 +3869,103 @@ class en {
3426
3869
  throw new m("core_transaction_create_liquidity_rune_error", r);
3427
3870
  }
3428
3871
  try {
3429
- i = await A(this, D).call(this, {
3872
+ s = await f(this, v).call(this, {
3430
3873
  assetValue: n,
3431
- memo: x(f.DEPOSIT, {
3874
+ memo: N(h.DEPOSIT, {
3432
3875
  ...n,
3433
- address: this.getAddress(s.THORChain)
3876
+ address: this.getAddress(i.THORChain)
3434
3877
  })
3435
3878
  });
3436
3879
  } catch (r) {
3437
3880
  throw new m("core_transaction_create_liquidity_asset_error", r);
3438
3881
  }
3439
- return { runeTx: a, assetTx: i };
3882
+ return { runeTx: a, assetTx: s };
3440
3883
  });
3441
3884
  T(this, "addLiquidity", async ({
3442
- poolIdentifier: t,
3443
- runeAssetValue: n,
3444
- assetValue: a,
3445
- runeAddr: i,
3446
- assetAddr: r,
3447
- isPendingSymmAsset: p,
3448
- mode: d = "sym"
3885
+ runeAssetValue: t,
3886
+ assetValue: n,
3887
+ runeAddr: a,
3888
+ assetAddr: s,
3889
+ isPendingSymmAsset: r,
3890
+ mode: o = "sym"
3449
3891
  }) => {
3450
- const [l, ...c] = t.split("."), y = d === "sym", u = (n == null ? void 0 : n.gt(0)) && (y || d === "rune"), h = (a == null ? void 0 : a.gt(0)) && (y || d === "asset"), _ = p || u, O = _ ? i || this.getAddress(s.THORChain) : "", I = y || d === "asset" ? r || this.getAddress(l) : "";
3451
- if (!u && !h)
3892
+ const { chain: p, symbol: d } = n, l = o === "sym", u = (t == null ? void 0 : t.gt(0)) && (l || o === "rune"), c = (n == null ? void 0 : n.gt(0)) && (l || o === "asset"), _ = r || u, b = _ ? a || this.getAddress(i.THORChain) : "", A = l || o === "asset" ? s || this.getAddress(p) : "";
3893
+ if (!u && !c)
3452
3894
  throw new m("core_transaction_add_liquidity_invalid_params");
3453
- if (_ && !O)
3895
+ if (_ && !b)
3454
3896
  throw new m("core_transaction_add_liquidity_no_rune_address");
3455
- let g, S;
3456
- const b = { chain: l, symbol: c.join(".") };
3457
- if (u && n)
3897
+ let E, O;
3898
+ if (u && t)
3458
3899
  try {
3459
- g = await A(this, D).call(this, {
3460
- assetValue: n,
3461
- memo: x(f.DEPOSIT, { ...b, address: I })
3900
+ E = await f(this, v).call(this, {
3901
+ assetValue: t,
3902
+ memo: N(h.DEPOSIT, { chain: p, symbol: d, address: A })
3462
3903
  });
3463
- } catch (M) {
3464
- throw new m("core_transaction_add_liquidity_rune_error", M);
3904
+ } catch (S) {
3905
+ throw new m("core_transaction_add_liquidity_rune_error", S);
3465
3906
  }
3466
- if (h && a)
3907
+ if (c && n)
3467
3908
  try {
3468
- S = await A(this, D).call(this, {
3469
- assetValue: a,
3470
- memo: x(f.DEPOSIT, { ...b, address: O })
3909
+ O = await f(this, v).call(this, {
3910
+ assetValue: n,
3911
+ memo: N(h.DEPOSIT, { chain: p, symbol: d, address: b })
3471
3912
  });
3472
- } catch (M) {
3473
- throw new m("core_transaction_add_liquidity_asset_error", M);
3913
+ } catch (S) {
3914
+ throw new m("core_transaction_add_liquidity_asset_error", S);
3474
3915
  }
3475
- return { runeTx: g, assetTx: S };
3916
+ return { runeTx: E, assetTx: O };
3917
+ });
3918
+ T(this, "addLiquidityPart", ({
3919
+ assetValue: t,
3920
+ poolAddress: n,
3921
+ address: a,
3922
+ symmetric: s
3923
+ }) => {
3924
+ if (s && !a)
3925
+ throw new m("core_transaction_add_liquidity_invalid_params");
3926
+ const r = s && a || "";
3927
+ return f(this, v).call(this, { assetValue: t, memo: `+:${n}:${r}:t:0` });
3476
3928
  });
3477
3929
  T(this, "withdraw", async ({
3478
3930
  memo: t,
3479
3931
  assetValue: n,
3480
3932
  percent: a,
3481
- from: i,
3933
+ from: s,
3482
3934
  to: r
3483
3935
  }) => {
3484
- const p = r === "rune" ? v.fromChainOrSignature(s.THORChain) : i === "sym" && r === "sym" || i === "rune" || i === "asset" ? void 0 : n;
3485
- try {
3486
- return await A(this, D).call(this, {
3487
- assetValue: fe(i === "asset" ? n.chain : s.THORChain),
3488
- memo: t || x(f.WITHDRAW, {
3489
- symbol: n.symbol,
3490
- chain: n.chain,
3491
- ticker: n.ticker,
3492
- basisPoints: Math.max(1e4, Math.round(a * 100)),
3493
- targetAssetString: p == null ? void 0 : p.toString(),
3494
- singleSide: !1
3495
- })
3496
- });
3497
- } catch (d) {
3498
- throw new m("core_transaction_withdraw_error", d);
3499
- }
3936
+ const o = r === "rune" ? M.fromChainOrSignature(i.THORChain) : s === "sym" && r === "sym" || s === "rune" || s === "asset" ? void 0 : n, p = de(s === "asset" ? n.chain : i.THORChain), d = t || N(h.WITHDRAW, {
3937
+ symbol: n.symbol,
3938
+ chain: n.chain,
3939
+ ticker: n.ticker,
3940
+ basisPoints: Math.max(1e4, Math.round(a * 100)),
3941
+ targetAssetString: o == null ? void 0 : o.toString(),
3942
+ singleSide: !1
3943
+ });
3944
+ return f(this, v).call(this, { assetValue: p, memo: d });
3500
3945
  });
3501
3946
  T(this, "savings", async ({
3502
3947
  assetValue: t,
3503
3948
  memo: n,
3504
3949
  percent: a,
3505
- type: i
3950
+ type: s
3506
3951
  }) => {
3507
- const r = i === "add" ? f.DEPOSIT : f.WITHDRAW, p = n || x(r, {
3952
+ const r = s === "add" ? h.DEPOSIT : h.WITHDRAW, o = n || N(r, {
3508
3953
  ticker: t.ticker,
3509
3954
  symbol: t.symbol,
3510
3955
  chain: t.chain,
3511
3956
  singleSide: !0,
3512
- basisPoints: a ? Math.max(1e4, Math.round(a * 100)) : void 0
3513
- });
3514
- return A(this, D).call(this, { assetValue: t, memo: p });
3957
+ basisPoints: a ? Math.min(1e4, Math.round(a * 100)) : void 0
3958
+ }), p = r === h.DEPOSIT ? t : de(t.chain);
3959
+ return f(this, v).call(this, { memo: o, assetValue: p });
3515
3960
  });
3516
3961
  T(this, "loan", ({
3517
3962
  assetValue: t,
3518
3963
  memo: n,
3519
3964
  minAmount: a,
3520
- type: i
3521
- }) => A(this, D).call(this, {
3965
+ type: s
3966
+ }) => f(this, v).call(this, {
3522
3967
  assetValue: t,
3523
- memo: n || x(i === "open" ? f.OPEN_LOAN : f.CLOSE_LOAN, {
3968
+ memo: n || N(s === "open" ? h.OPEN_LOAN : h.CLOSE_LOAN, {
3524
3969
  asset: t.toString(),
3525
3970
  minAmount: a.toString(),
3526
3971
  address: this.getAddress(t.chain)
@@ -3531,27 +3976,27 @@ class en {
3531
3976
  assetValue: n,
3532
3977
  address: a
3533
3978
  }) => {
3534
- const i = t === "bond" ? f.BOND : t === "unbond" ? f.UNBOND : f.LEAVE, r = x(i, {
3979
+ const s = t === "bond" ? h.BOND : t === "unbond" ? h.UNBOND : h.LEAVE, r = N(s, {
3535
3980
  address: a,
3536
- unbondAmount: t === "unbond" ? n.baseValueNumber : void 0
3981
+ unbondAmount: t === "unbond" ? n.getBaseValue("number") : void 0
3537
3982
  });
3538
- return A(this, X).call(this, {
3983
+ return f(this, K).call(this, {
3539
3984
  memo: r,
3540
- assetValue: t === "bond" ? n : fe(s.THORChain)
3985
+ assetValue: t === "bond" ? n : de(i.THORChain)
3541
3986
  });
3542
3987
  });
3543
3988
  T(this, "registerThorname", ({
3544
3989
  assetValue: t,
3545
3990
  ...n
3546
- }) => A(this, X).call(this, { assetValue: t, memo: x(f.THORNAME_REGISTER, n) }));
3547
- T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: i = {} }) => {
3991
+ }) => f(this, K).call(this, { assetValue: t, memo: N(h.THORNAME_REGISTER, n) }));
3992
+ T(this, "extend", ({ wallets: t, config: n, apis: a = {}, rpcUrls: s = {} }) => {
3548
3993
  try {
3549
3994
  t.forEach((r) => {
3550
3995
  this[r.connectMethodName] = r.connect({
3551
- addChain: A(this, ee),
3996
+ addChain: f(this, ne),
3552
3997
  config: n || {},
3553
3998
  apis: a,
3554
- rpcUrls: i
3999
+ rpcUrls: s
3555
4000
  });
3556
4001
  });
3557
4002
  } catch (r) {
@@ -3564,28 +4009,28 @@ class en {
3564
4009
  }) => {
3565
4010
  const a = this.getWallet(t);
3566
4011
  switch (t) {
3567
- case s.Arbitrum:
3568
- case s.Avalanche:
3569
- case s.BinanceSmartChain:
3570
- case s.Ethereum:
3571
- case s.Optimism:
3572
- case s.Polygon: {
3573
- const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-evm");
3574
- return i({
4012
+ case i.Arbitrum:
4013
+ case i.Avalanche:
4014
+ case i.BinanceSmartChain:
4015
+ case i.Ethereum:
4016
+ case i.Optimism:
4017
+ case i.Polygon: {
4018
+ const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-evm");
4019
+ return s({
3575
4020
  ...n,
3576
4021
  toolbox: a
3577
4022
  });
3578
4023
  }
3579
- case s.Bitcoin:
3580
- case s.BitcoinCash:
3581
- case s.Dogecoin:
3582
- case s.Litecoin:
4024
+ case i.Bitcoin:
4025
+ case i.BitcoinCash:
4026
+ case i.Dogecoin:
4027
+ case i.Litecoin:
3583
4028
  return a.estimateMaxSendableAmount(n);
3584
- case s.Binance:
3585
- case s.THORChain:
3586
- case s.Cosmos: {
3587
- const { estimateMaxSendableAmount: i } = await import("@swapkit/toolbox-cosmos");
3588
- return i({
4029
+ case i.Binance:
4030
+ case i.THORChain:
4031
+ case i.Cosmos: {
4032
+ const { estimateMaxSendableAmount: s } = await import("@swapkit/toolbox-cosmos");
4033
+ return s({
3589
4034
  ...n,
3590
4035
  toolbox: a
3591
4036
  });
@@ -3625,71 +4070,71 @@ class en {
3625
4070
  this.connectedChains[t] = null, this.connectedWallets[t] = null;
3626
4071
  });
3627
4072
  P(this, V, async (t) => {
3628
- if (t === s.THORChain)
4073
+ if (t === i.THORChain)
3629
4074
  return {
3630
4075
  gas_rate: "0",
3631
4076
  router: "0",
3632
4077
  address: "",
3633
4078
  halted: !1,
3634
- chain: s.THORChain
4079
+ chain: i.THORChain
3635
4080
  };
3636
- const a = (await Pt(this.stagenet)).find((i) => i.chain === t);
4081
+ const a = (await Tn(this.stagenet)).find((s) => s.chain === t);
3637
4082
  if (!a)
3638
4083
  throw new m("core_inbound_data_not_found");
3639
4084
  if (a != null && a.halted)
3640
4085
  throw new m("core_chain_halted");
3641
4086
  return a;
3642
4087
  });
3643
- P(this, ee, ({ chain: t, wallet: n, walletMethods: a }) => {
4088
+ P(this, ne, ({ chain: t, wallet: n, walletMethods: a }) => {
3644
4089
  this.connectedChains[t] = n, this.connectedWallets[t] = a;
3645
4090
  });
3646
- P(this, Y, async ({
3647
- assetValue: { baseValueBigInt: t, address: n, chain: a, isGasAsset: i, isSynthetic: r },
3648
- type: p = "checkOnly",
3649
- contractAddress: d
4091
+ P(this, j, async ({
4092
+ assetValue: t,
4093
+ type: n = "checkOnly",
4094
+ contractAddress: a
3650
4095
  }) => {
3651
- const l = [s.Ethereum, s.Avalanche, s.BinanceSmartChain].includes(a);
3652
- if (l && i || !l || r)
4096
+ const { address: s, chain: r, isGasAsset: o, isSynthetic: p } = t, d = [i.Ethereum, i.Avalanche, i.BinanceSmartChain].includes(r);
4097
+ if (d && o || !d || p)
3653
4098
  return !0;
3654
- const y = this.connectedWallets[a], u = p === "checkOnly" ? y == null ? void 0 : y.isApproved : y == null ? void 0 : y.approve;
3655
- if (!u)
4099
+ const u = this.connectedWallets[r], c = n === "checkOnly" ? u == null ? void 0 : u.isApproved : u == null ? void 0 : u.approve;
4100
+ if (!c)
3656
4101
  throw new m("core_wallet_connection_not_found");
3657
- const h = this.getAddress(a);
3658
- if (!n || !h)
4102
+ const _ = this.getAddress(r);
4103
+ if (!s || !_)
3659
4104
  throw new m("core_approve_asset_address_or_from_not_found");
3660
- const _ = d || (await A(this, V).call(this, a)).router;
3661
- return u({
3662
- amount: t,
3663
- assetAddress: n,
3664
- from: h,
3665
- spenderAddress: _
4105
+ const b = a || (await f(this, V).call(this, r)).router;
4106
+ return c({
4107
+ amount: t.getBaseValue("bigint"),
4108
+ assetAddress: s,
4109
+ from: _,
4110
+ spenderAddress: b
3666
4111
  });
3667
4112
  });
3668
- P(this, D, async ({
4113
+ P(this, v, async ({
3669
4114
  assetValue: t,
3670
4115
  memo: n,
3671
4116
  feeOptionKey: a = F.Fast
3672
4117
  }) => {
3673
4118
  const {
3674
- gas_rate: i,
4119
+ gas_rate: s,
3675
4120
  router: r,
3676
- address: p
3677
- } = await A(this, V).call(this, t.chain), d = (parseInt(i) || 0) * it[a];
4121
+ address: o
4122
+ } = await f(this, V).call(this, t.chain), p = (parseInt(s) || 0) * wt[a];
3678
4123
  return this.deposit({
3679
4124
  assetValue: t,
3680
- recipient: p,
4125
+ recipient: o,
3681
4126
  memo: n,
3682
4127
  router: r,
3683
- feeRate: d
4128
+ feeRate: p
3684
4129
  });
3685
4130
  });
3686
- P(this, X, async ({ memo: t, assetValue: n }) => {
3687
- const a = await Bt(this.stagenet);
4131
+ P(this, K, async ({ memo: t, assetValue: n }) => {
4132
+ const a = await hn(this.stagenet);
3688
4133
  if (a.HALTCHAINGLOBAL >= 1 || a.HALTTHORCHAIN >= 1)
3689
4134
  throw new m("core_chain_halted");
3690
4135
  return this.deposit({ assetValue: n, recipient: "", memo: t });
3691
4136
  });
3692
- P(this, j, ({ assetValue: t, ...n }) => ({
4137
+ P(this, Y, ({ assetValue: t, ...n }) => ({
3693
4138
  ...n,
3694
4139
  memo: n.memo || "",
3695
4140
  from: this.getAddress(t.chain),
@@ -3698,65 +4143,66 @@ class en {
3698
4143
  this.stagenet = !!t;
3699
4144
  }
3700
4145
  }
3701
- V = new WeakMap(), ee = new WeakMap(), Y = new WeakMap(), D = new WeakMap(), X = new WeakMap(), j = new WeakMap();
4146
+ V = new WeakMap(), ne = new WeakMap(), j = new WeakMap(), v = new WeakMap(), K = new WeakMap(), Y = new WeakMap();
3702
4147
  export {
3703
- He as AGG_SWAP,
3704
- Ut as ApiError,
4148
+ Ze as AGG_SWAP,
4149
+ bn as ApiError,
3705
4150
  q as ApiUrl,
3706
- v as AssetValue,
3707
- E as BaseDecimal,
3708
- s as Chain,
3709
- ce as ChainId,
3710
- Wt as ChainIdToChain,
3711
- Ye as ChainToChainId,
3712
- Re as ChainToExplorerUrl,
3713
- Gt as ChainToHexChainId,
3714
- Xe as ChainToRPC,
3715
- We as ContractAddress,
3716
- Ft as CosmosChainList,
3717
- K as DEFAULT_DECIMAL,
3718
- qe as DerivationPath,
3719
- o as ERROR_CODE,
3720
- Fe as ERROR_MODULE,
3721
- Ae as ERROR_TYPE,
3722
- $t as EVMChainList,
3723
- je as ErrorCode,
4151
+ M as AssetValue,
4152
+ w as BaseDecimal,
4153
+ ce as BigIntArithmetics,
4154
+ i as Chain,
4155
+ _e as ChainId,
4156
+ On as ChainIdToChain,
4157
+ pt as ChainToChainId,
4158
+ Ne as ChainToExplorerUrl,
4159
+ gn as ChainToHexChainId,
4160
+ dt as ChainToRPC,
4161
+ st as ContractAddress,
4162
+ En as CosmosChainList,
4163
+ it as DerivationPath,
4164
+ y as ERROR_CODE,
4165
+ nt as ERROR_MODULE,
4166
+ ve as ERROR_TYPE,
4167
+ rt as EVMChainList,
4168
+ ut as ErrorCode,
3724
4169
  F as FeeOption,
3725
- f as MemoType,
3726
- Ht as NetworkDerivationPath,
3727
- Ue as QuoteMode,
3728
- Ee as RPCUrl,
3729
- $e as SWAP_IN,
3730
- ke as SWAP_OUT,
3731
- en as SwapKitCore,
4170
+ h as MemoType,
4171
+ wn as NetworkDerivationPath,
4172
+ ze as QuoteMode,
4173
+ Me as RPCUrl,
4174
+ we as RequestClient,
4175
+ et as SWAP_IN,
4176
+ tt as SWAP_OUT,
4177
+ Ln as SwapKitCore,
3732
4178
  m as SwapKitError,
3733
- le as SwapKitNumber,
3734
- Ve as TCAvalancheDepositABI,
3735
- Le as TCBscDepositABI,
3736
- Be as TCEthereumVaultAbi,
3737
- kt as UTXOChainList,
3738
- Je as WalletOption,
3739
- Xt as assetFromString,
3740
- Yt as derivationPathToString,
3741
- Lt as erc20ABI,
3742
- ge as formatBigIntToSafeValue,
3743
- it as gasFeeMultiplier,
3744
- ot as getAssetType,
3745
- ut as getAsymmetricAssetShare,
3746
- Jt as getAsymmetricAssetWithdrawAmount,
3747
- dt as getAsymmetricRuneShare,
3748
- jt as getAsymmetricRuneWithdrawAmount,
3749
- pt as getCommonAssetInfo,
3750
- Se as getDecimal,
3751
- zt as getEstimatedPoolShare,
3752
- Zt as getLiquiditySlippage,
3753
- x as getMemoFor,
3754
- fe as getMinAmountByChain,
3755
- Oe as getRequest,
3756
- yt as getSymmetricPoolShare,
3757
- Qt as getSymmetricWithdraw,
3758
- qt as getTHORNameCost,
3759
- rt as isGasAsset,
3760
- et as postRequest,
3761
- Kt as validateTHORName
4179
+ x as SwapKitNumber,
4180
+ Je as TCAvalancheDepositABI,
4181
+ Qe as TCBscDepositABI,
4182
+ Xe as TCEthereumVaultAbi,
4183
+ Rn as TCSupportedChainList,
4184
+ An as UTXOChainList,
4185
+ lt as WalletOption,
4186
+ Sn as assetFromString,
4187
+ Bn as derivationPathToString,
4188
+ fn as erc20ABI,
4189
+ In as filterAssets,
4190
+ se as formatBigIntToSafeValue,
4191
+ wt as gasFeeMultiplier,
4192
+ Et as getAssetType,
4193
+ St as getAsymmetricAssetShare,
4194
+ Cn as getAsymmetricAssetWithdrawAmount,
4195
+ Ot as getAsymmetricRuneShare,
4196
+ vn as getAsymmetricRuneWithdrawAmount,
4197
+ At as getCommonAssetInfo,
4198
+ bt as getDecimal,
4199
+ Nn as getEstimatedPoolShare,
4200
+ xn as getLiquiditySlippage,
4201
+ N as getMemoFor,
4202
+ de as getMinAmountByChain,
4203
+ It as getSymmetricPoolShare,
4204
+ Mn as getSymmetricWithdraw,
4205
+ Dn as getTHORNameCost,
4206
+ De as isGasAsset,
4207
+ Pn as validateTHORName
3762
4208
  };