@swapkit/helpers 4.0.20 → 4.0.21
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/api/index.cjs +2 -2
- package/dist/api/index.cjs.map +4 -4
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +4 -4
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +19 -19
- package/dist/index.js +3 -3
- package/dist/index.js.map +19 -19
- package/dist/types/api/index.d.ts +7 -7
- package/dist/types/api/midgard/endpoints.d.ts.map +1 -1
- package/dist/types/api/swapkitApi/endpoints.d.ts +5 -5
- package/dist/types/api/swapkitApi/types.d.ts +2 -1
- package/dist/types/api/swapkitApi/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/modules/assetValue.d.ts +1 -1
- package/dist/types/modules/assetValue.d.ts.map +1 -1
- package/dist/types/modules/bigIntArithmetics.d.ts.map +1 -1
- package/dist/types/modules/swapKitConfig.d.ts +10 -4
- package/dist/types/modules/swapKitConfig.d.ts.map +1 -1
- package/dist/types/types/chains.d.ts +25 -185
- package/dist/types/types/chains.d.ts.map +1 -1
- package/dist/types/types/commonTypes.d.ts +3 -3
- package/dist/types/types/commonTypes.d.ts.map +1 -1
- package/dist/types/types/derivationPath.d.ts +1 -1
- package/dist/types/types/derivationPath.d.ts.map +1 -1
- package/dist/types/types/wallet.d.ts +6 -3
- package/dist/types/types/wallet.d.ts.map +1 -1
- package/dist/types/utils/asset.d.ts +4 -4
- package/dist/types/utils/asset.d.ts.map +1 -1
- package/dist/types/utils/chains.d.ts +1 -1
- package/dist/types/utils/chains.d.ts.map +1 -1
- package/dist/types/utils/derivationPath.d.ts +2 -1
- package/dist/types/utils/derivationPath.d.ts.map +1 -1
- package/dist/types/utils/explorerUrls.d.ts +1 -1
- package/dist/types/utils/explorerUrls.d.ts.map +1 -1
- package/dist/types/utils/liquidity.d.ts.map +1 -1
- package/dist/types/utils/memo.d.ts +1 -1
- package/dist/types/utils/memo.d.ts.map +1 -1
- package/dist/types/utils/others.d.ts +1 -1
- package/dist/types/utils/others.d.ts.map +1 -1
- package/dist/types/utils/wallets.d.ts +2 -1
- package/dist/types/utils/wallets.d.ts.map +1 -1
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{a as wF,c as IF}from"./chunk-mvp796yg.js";export*from"@swapkit/tokens";import{getAddress as fF}from"ethers";import{match as BF}from"ts-pattern";var L;((G)=>{G.Arbitrum="ARB";G.Aurora="AURORA";G.Avalanche="AVAX";G.Base="BASE";G.Berachain="BERA";G.BinanceSmartChain="BSC";G.Bitcoin="BTC";G.BitcoinCash="BCH";G.Cosmos="GAIA";G.Dash="DASH";G.Dogecoin="DOGE";G.Ethereum="ETH";G.Fiat="FIAT";G.Gnosis="GNO";G.Kujira="KUJI";G.Litecoin="LTC";G.Maya="MAYA";G.Near="NEAR";G.Noble="NOBLE";G.Optimism="OP";G.Polkadot="DOT";G.Chainflip="FLIP";G.Polygon="POL";G.Radix="XRD";G.Ripple="XRP";G.THORChain="THOR";G.Solana="SOL";G.Tron="TRON";G.Zcash="ZEC"})(L||={});var YF;((N)=>{N.THORChain="THOR_STAGENET";N.Maya="MAYA_STAGENET"})(YF||={});var NF;((B)=>{B.Arbitrum="42161";B.ArbitrumHex="0xa4b1";B.Aurora="1313161554";B.AuroraHex="0x4e454152";B.Avalanche="43114";B.AvalancheHex="0xa86a";B.Base="8453";B.BaseHex="0x2105";B.Berachain="80094";B.BerachainHex="0x138de";B.BinanceSmartChain="56";B.BinanceSmartChainHex="0x38";B.Bitcoin="bitcoin";B.BitcoinCash="bitcoincash";B.Chainflip="chainflip";B.Cosmos="cosmoshub-4";B.Dash="dash";B.Dogecoin="dogecoin";B.Ethereum="1";B.EthereumHex="0x1";B.Fiat="fiat";B.Gnosis="100";B.GnosisHex="0x64";B.Kujira="kaiyo-1";B.Litecoin="litecoin";B.Maya="mayachain-mainnet-v1";B.MayaStagenet="mayachain-stagenet-v1";B.Near="near";B.Noble="noble-1";B.Optimism="10";B.OptimismHex="0xa";B.Polkadot="polkadot";B.Polygon="137";B.PolygonHex="0x89";B.Radix="radix-mainnet";B.Ripple="ripple";B.THORChain="thorchain-1";B.THORChainStagenet="thorchain-stagenet-v2";B.Solana="solana";B.Tron="728126428";B.TronHex="0x2b6653dc";B.Zcash="zcash"})(NF||={});var v$={["0xa4b1"]:"ARB",["42161"]:"ARB",["0x4e454152"]:"AURORA",["1313161554"]:"AURORA",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x138de"]:"BERA",["80094"]:"BERA",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["0x64"]:"GNO",["100"]:"GNO",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["noble-1"]:"NOBLE",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"POL",["137"]:"POL",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["728126428"]:"TRON",["0x2b6653dc"]:"TRON",["zcash"]:"ZEC"},oF=Object.keys(L),h=Object.values(L),X={ARB:18,AURORA:18,AVAX:18,BASE:18,BCH:8,BERA:18,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,GNO:18,KUJI:6,LTC:8,MAYA:8,NEAR:24,NOBLE:6,OP:18,POL:18,SOL:9,THOR:8,TRON:6,XRD:18,XRP:6,ZEC:8},f$={["ARB"]:0.3,["AURORA"]:1,["AVAX"]:3,["BASE"]:2,["BERA"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:60,["ETH"]:12.5,["FIAT"]:60,["GNO"]:5.2,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["NOBLE"]:1.3,["OP"]:2,["DOT"]:6,["POL"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6,["TRON"]:3,["ZEC"]:75},b$=["DOT","FLIP"],k=["ARB","AURORA","AVAX","BASE","BERA","BSC","ETH","GNO","OP","POL"],c=["BTC","BCH","DASH","DOGE","LTC","ZEC"],JF=["GAIA","THOR","MAYA","KUJI","NOBLE"],E$={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira",["NOBLE"]:"noble"},MF={["ARB"]:"https://arb1.arbitrum.io/rpc",["AURORA"]:"https://aurora-rpc.publicnode.com",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-rpc.publicnode.com",["BERA"]:"https://berachain-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["BTC"]:"https://bitcoin-rpc.publicnode.com",["FLIP"]:"wss://mainnet-archive.chainflip.io",["GAIA"]:"https://cosmos-rpc.publicnode.com:443",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["GNO"]:"https://gnosis-rpc.publicnode.com",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.mainnet.near.org",["NOBLE"]:"https://noble-rpc.polkachu.com",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["POL"]:"https://polygon-rpc.com",["XRD"]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",["XRP"]:"wss://xrpl.ws/",["SOL"]:"https://solana-rpc.publicnode.com",["THOR"]:"https://rpc.ninerealms.com",["TRON"]:"https://tron-rpc.publicnode.com",["ZEC"]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",["MAYA_STAGENET"]:"",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},o={["THOR"]:"https://thornode.ninerealms.com",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},XF={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AURORA"]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BERA"]:["https://rpc.berachain.com","https://berachain.drpc.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],["FIAT"]:[],["GNO"]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],["KUJI"]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["NEAR"]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],["NOBLE"]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["POL"]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],["XRD"]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],["XRP"]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],["THOR"]:["https://thornode.ninerealms.com",o.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],["TRON"]:["https://api.tronstack.io","https://api.tron.network"],["ZEC"]:[]},PF={["ARB"]:"https://arbiscan.io",["AURORA"]:"https://explorer.mainnet.aurora.dev",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["BERA"]:"https://berascan.com",["BSC"]:"https://bscscan.com",["BTC"]:"https://blockchair.com/bitcoin",["BCH"]:"https://www.blockchair.com/bitcoin-cash",["FLIP"]:"https://explorer.polkascan.io/polkadot",["GAIA"]:"https://www.mintscan.io/cosmos",["DASH"]:"https://blockchair.com/dash",["DOGE"]:"https://blockchair.com/dogecoin",["ETH"]:"https://etherscan.io",["FIAT"]:"",["GNO"]:"https://gnosisscan.io",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["NOBLE"]:"https://www.mintscan.io/noble",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["POL"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io",["TRON"]:"https://tronscan.org",["ZEC"]:"https://blockchair.com/zcash"},LF=h.reduce((F,$)=>{let N=oF.find((P)=>L[P]===$);if(N)F[$]=N;return F},{}),jF=h.reduce((F,$)=>{return F[$]=NF[LF[$]],F},{}),HF=h.reduce((F,$)=>{let N=`${LF[$]}Hex`;return F[$]=NF[N],F},{}),y$=h.reduce((F,$)=>{return F[$]=PF[$],F},{});import{match as t}from"ts-pattern";import{createStore as iF}from"zustand/vanilla";var hF;((J)=>{J.ARB="0x0000000000000000000000000000000000000000";J.AURORA="0x0000000000000000000000000000000000000000";J.AVAX="0x0000000000000000000000000000000000000000";J.BASE="0x0000000000000000000000000000000000000000";J.BERA="0x0000000000000000000000000000000000000000";J.ETH="0x0000000000000000000000000000000000000000";J.BSC="0x0000000000000000000000000000000000000000";J.GNO="0x0000000000000000000000000000000000000000";J.MATIC="0x0000000000000000000000000000000000001010";J.OP="0x4200000000000000000000000000000000000042"})(hF||={});var b={ARB:[44,60,0,0,0],AURORA:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BERA:[44,60,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],DOT:[0,0,0,0,0],ETH:[44,60,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],GAIA:[44,118,0,0,0],GNO:[44,60,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],POL:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[44,195,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0],ZEC:[44,133,0,0,0]};var cF;((R)=>{R.unknownError="unknownError";R.test_error="test_error";R.providerDetailsError="providerDetailsError";R.blockHeaderNotFound="blockHeaderNotFound";R.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";R.blockHashNotFoundAtHash="blockHashNotFoundAtHash";R.txHashMissing="txHashMissing";R.assetValueMissingInfo="assetValueMissingInfo";R.invalidAsset="invalidAsset";R.blockIsRequired="blockIsRequired";R.currentBlockHeaderNotFound="currentBlockHeaderNotFound";R.failedToRetrieveBalance="failedToRetrieveBalance";R.failedToRetrieveBlock="failedToRetrieveBlock";R.failedToRetrieveFees="failedToRetrieveFees";R.notImplementedBCH="notImplementedBCH";R.notImplementedDoge="notImplementedDoge";R.noPoolsFound="noPoolsFound";R.noVaultsFound="noVaultsFound";R.noTxFound="noTxFound";R.noInputCoinFound="noInputCoinFound";R.noBlockDataFound="noBlockDataFound";R.multipleCosmosMessages="multipleCosmosMessages";R.heightOrHashNotProvided="heightOrHashNotProvided";R.unknownDenom="unknownDenom";R.invalidBlockHeight="invalidBlockHeight";R.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";R.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";R.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";R.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";R.txMemoUndefined="txMemoUndefined";R.txMemoIncorrect="txMemoIncorrect";R.txTypeNotFound="txTypeNotFound";R.txNoMessage="txNoMessage";R.txNotFound="txNotFound";R.txReceiptNotFound="txReceiptNotFound";R.txParsingError="txParsingError";R.txLogsParsingError="txLogsParsingError";R.blockNotFound="blockNotFound";R.balanceNotFound="balanceNotFound";R.configError="configError";R.synthSwapDisallowed="synthSwapDisallowed";R.providerQuoteTimeout="providerQuoteTimeout";R.noQuoteResponse="noQuoteResponse";R.noPoolAssetsFound="noPoolAssetsFound";R.noThorchainPools="noThorchainPools";R.noMayachainPools="noMayachainPools";R.noThorchainNetworkInfo="noThorchainNetworkInfo";R.invalidAffiliateFee="invalidAffiliateFee";R.invalidBuyAssetAddress="invalidBuyAssetAddress";R.invalidSellAssetAddress="invalidSellAssetAddress";R.invalidSourceAddress="invalidSourceAddress";R.invalidDestinationAddress="invalidDestinationAddress";R.sourceAddressIsSmartContract="sourceAddressIsSmartContract";R.destinationAddressIsSmartContract="destinationAddressIsSmartContract";R.invalidChainId="invalidChainId";R.unsupportedChainId="unsupportedChainId";R.unsupportedEVMChainId="unsupportedEVMChainId";R.unsupportedMethod="unsupportedMethod";R.unsupportedProvider="unsupportedProvider";R.invalidParamsForMethod="invalidParamsForMethod";R.unsupportedAdapter="unsupportedAdapter";R.noWhitelistTokens="noWhitelistTokens";R.failedFetchGasPrice="failedFetchGasPrice";R.failedToCreateDepositChannel="failedToCreateDepositChannel";R.noProviderDetailsFound="noProviderDetailsFound";R.noTokenListsFound="noTokenListsFound";R.tokenNotFound="tokenNotFound";R.tokenPriceNotFound="tokenPriceNotFound";R.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";R.swapAmountTooSmall="swapAmountTooSmall";R.legsArrayIsEmpty="legsArrayIsEmpty";R.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";R.noBlockHeaderFound="noBlockHeaderFound";R.failedToSimulateSwap="failedToSimulateSwap";R.addressScreeningFailed="addressScreeningFailed";R.noLiquidtyProvidersFound="noLiquidtyProvidersFound";R.insufficientLiquidity="insufficientLiquidity";R.noInboundDataFound="noInbounDataFound";R.noInboundAddressesFound="noInboundAddressesFound";R.noInboundAddressFoundForChain="noInboundAddressFoundForChain";R.noLastBlocksFound="noLastBlocksFound";R.noVersionFound="noVersionFound";R.noConstantsFound="noConstantsFound";R.noMimirsFound="noMimirsFound";R.noRoutesFound="noRoutesFound";R.quoteNotFound="quoteNotFound";R.ledgerSignFailed="ledgerSignFailed";R.ledgerWrongPayload="ledgerWrongPayload";R.ledgerFetchSwapFailed="ledgerFetchSwapFailed";R.failedToFetchTx="failedToFetchTx";R.failedBuildTransactionDetails="failedBuildTransactionDetails";R.noLegsForRoute="noLegsForRoute";R.noRouterAddressFound="noRouterAddressFound";R.noAggregatorAddressFound="noAggregatorAddressFound";R.noContractInstanceFound="noContractInstanceFound";R.noContractAddressFound="noContractAddressFound";R.invalidAffiliate="invalidAffiliate";R.thornameAffiliate="thornameAffiliate";R.providerNotfound="No provider found";R.noRecordFound="No Record found";R.slippageTooLow="Slippage too low";R.tradingHalted="tradingHalted";R.noWrappedGasAsset="noWrappedGasAsset";R.aggregatorAddressNotFound="aggregatorAddressNotFound";R.routerAddressNotFound="routerAddressNotFound";R.dummyAddressNotFound="dummyAddressNotFound";R.trackerError="trackerError";R.thorchainPoolUnavailable="thorchainPoolUnavailable";R.noOhlcvDataFound="noOhlcvDataFound";R.noTradingPairs="noTradingPairs";R.noLendingAvailability="noLendingAvailability";R.lendingRepayTooSmall="lendingRepayTooSmall";R.missingState="missingState";R.ledgerSwapNotFound="ledgerSwapNotFound";R.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";R.errorEstimatingGas="errorEstimatingGas";R.apiKeyInvalid="apiKeyInvalid";R.apiKeyFailedToUpdate="apiKeyFailedToUpdate";R.apiKeyExpired="apiKeyExpired";R.unauthorized="unauthorized";R.failedToCreateMemo="failedToCreateMemo";R.radixIncorrectInstructions="radixIncorrectInstructions";R.radixTxMissedParam="radixTxMissedParam";R.radixTxMissedAccount="radixTxMissedAccount";R.radixManifestParseError="radixManifestParseError";R.radixManifestBuildError="radixManifestBuildError";R.invalidAddressForChain="invalidAddressForChain";R.riskyAddress="riskyAddress";R.noRoutesToProcess="noRoutesToProcess";R.sellAssetAmountTooSmall="sellAssetAmountTooSmall";R.missingPrivateKey="missingPrivateKey";R.noMemoPriceProtection="noMemoPriceProtection"})(cF||={});var lF;((N)=>{N.highSlippage="highSlippage";N.highPriceImpact="highPriceImpact"})(lF||={});var nF;((Y)=>{Y.CAVIAR_V1="CAVIAR_V1";Y.CAMELOT_V3="CAMELOT_V3";Y.CHAINFLIP="CHAINFLIP";Y.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";Y.JUPITER="JUPITER";Y.MAYACHAIN="MAYACHAIN";Y.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";Y.OCISWAP_V1="OCISWAP_V1";Y.ONEINCH="ONEINCH";Y.OPENOCEAN_V2="OPENOCEAN_V2";Y.PANCAKESWAP="PANCAKESWAP";Y.PANGOLIN_V1="PANGOLIN_V1";Y.SUSHISWAP_V2="SUSHISWAP_V2";Y.THORCHAIN="THORCHAIN";Y.THORCHAIN_STREAMING="THORCHAIN_STREAMING";Y.TRADERJOE_V2="TRADERJOE_V2";Y.UNISWAP_V2="UNISWAP_V2";Y.UNISWAP_V3="UNISWAP_V3";Y.NEAR="NEAR"})(nF||={});var sF;((_)=>{_.LIQUIDITY="liquidity";_.NETWORK="network";_.INBOUND="inbound";_.OUTBOUND="outbound";_.AFFILIATE="affiliate";_.TAX="tax";_.PRIORITY="priority"})(sF||={});var WF;((P)=>{P.Average="average";P.Fast="fast";P.Fastest="fastest"})(WF||={});var tF;((N)=>{N.Approve="approve";N.CheckOnly="checkOnly"})(tF||={});var qF;((Z)=>{Z.NAME_REGISTER="~";Z.BOND="BOND";Z.DEPOSIT="+";Z.LEAVE="LEAVE";Z.UNBOND="UNBOND";Z.WITHDRAW="-";Z.RUNEPOOL_DEPOSIT="POOL+";Z.RUNEPOOL_WITHDRAW="POOL-";Z.CLAIM_TCY="tcy";Z.STAKE_TCY="tcy+";Z.UNSTAKE_TCY="tcy-"})(qF||={});var l;((G)=>{G.BITGET="BITGET";G.BRAVE="BRAVE";G.COINBASE_MOBILE="COINBASE_MOBILE";G.COINBASE_WEB="COINBASE_WEB";G.COSMOSTATION="COSMOSTATION";G.CTRL="CTRL";G.EIP6963="EIP6963";G.EXODUS="EXODUS";G.KEEPKEY="KEEPKEY";G.KEEPKEY_BEX="KEEPKEY_BEX";G.KEPLR="KEPLR";G.KEYSTORE="KEYSTORE";G.LEAP="LEAP";G.LEDGER="LEDGER";G.LEDGER_LIVE="LEDGER_LIVE";G.METAMASK="METAMASK";G.OKX="OKX";G.OKX_MOBILE="OKX_MOBILE";G.ONEKEY="ONEKEY";G.PHANTOM="PHANTOM";G.POLKADOT_JS="POLKADOT_JS";G.RADIX_WALLET="RADIX_WALLET";G.TREZOR="TREZOR";G.TALISMAN="TALISMAN";G.TRONLINK="TRONLINK";G.TRUSTWALLET_WEB="TRUSTWALLET_WEB";G.VULTISIG="VULTISIG";G.WALLETCONNECT="WALLETCONNECT";G.XAMAN="XAMAN"})(l||={});var rF;((P)=>{P[P.NoError=36864]="NoError";P[P.LockedDevice=21781]="LockedDevice";P[P.TC_NotFound=65535]="TC_NotFound"})(rF||={});var aF={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:Object.values(L),envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},explorerUrls:PF,fallbackRpcUrls:XF,feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},nodeUrls:o,requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:MF,wallets:Object.values(l)},W=iF((F)=>({...aF,setApiKey:($,N)=>F((P)=>({apiKeys:{...P.apiKeys,[$]:N}})),setConfig:($)=>F((N)=>({apiKeys:{...N.apiKeys,...$.apiKeys},chains:N.chains.concat($.chains||[]),envs:{...N.envs,...$.envs},explorerUrls:{...N.explorerUrls,...$.explorerUrls},feeMultipliers:$.feeMultipliers||N.feeMultipliers,integrations:{...N.integrations,...$.integrations},nodeUrls:{...N.nodeUrls,...$.nodeUrls},rpcUrls:{...N.rpcUrls,...$.rpcUrls},wallets:N.wallets.concat($.wallets||[])})),setEnv:($,N)=>F((P)=>({envs:{...P.envs,[$]:N}})),setExplorerUrl:($,N)=>F((P)=>({explorerUrls:{...P.explorerUrls,[$]:N}})),setFallbackRpcUrls:($,N)=>F((P)=>({fallbackRpcUrls:{...P.fallbackRpcUrls,[$]:N}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,N)=>F((P)=>({integrations:{...P.integrations,[$]:N}})),setNodeUrl:($,N)=>F((P)=>({nodeUrls:{...P.nodeUrls,[$]:N}})),setRequestOptions:($)=>F((N)=>({requestOptions:{retry:{...N.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||N.requestOptions.timeoutMs}})),setRpcUrl:($,N)=>F((P)=>({rpcUrls:{...P.rpcUrls,[$]:N}}))})),q={get:(F)=>W.getState()[F],getState:W.getState,set:(F)=>W.getState().setConfig(F),setApiKey:(F,$)=>W.getState().setApiKey(F,$),setEnv:(F,$)=>W.getState().setEnv(F,$),setExplorerUrl:(F,$)=>W.getState().setExplorerUrl(F,$),setFallbackRpcUrls:(F,$)=>W.getState().setFallbackRpcUrls(F,$),setFeeMultipliers:(F)=>W.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>W.getState().setIntegrationConfig(F,$),setNodeUrl:(F,$)=>W.getState().setNodeUrl(F,$),setRequestOptions:(F)=>W.getState().setRequestOptions(F),setRpcUrl:(F,$)=>W.getState().setRpcUrl(F,$)};var eF={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,wallet_tronlink_request_accounts_failed:24001,wallet_tronlink_locked:24002,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_substrate_transfer_error:50502,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class M extends Error{static ErrorCode=eF;constructor(F,$){let N=typeof F==="string",P=N?F:F.errorKey,H=N?void 0:F.info,A=`${P}${H?`: ${JSON.stringify(H)}`:""}`;super(A);if(Object.setPrototypeOf(this,M.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${P}]:`,$);else if(H)console.error(`SwapKitError [${P}]:`,H)}}var F$=(F)=>new Promise(($)=>setTimeout($,F)),$$=(F,{baseDelay:$,backoffMultiplier:N,maxDelay:P})=>Math.min($*N**F,P),N$=async(F,$)=>{let N=await fetch(F,$);if(!N.ok){let H={message:await N.text(),status:N.status,statusText:N.statusText};throw new M({errorKey:"helpers_invalid_response",info:H},H)}return N.json()};function n(F,$={}){return async function(P,H={}){let{searchParams:A,json:x,body:_,headers:T,dynamicHeader:Q,retry:J,timeoutMs:Z,abortController:I,onError:V,onSuccess:K,responseHandler:p,...O}={...$,...H},f=q.get("requestOptions"),D={...f.retry,...J},Y=!!x||P.endsWith(".json"),CF=H$(P,A),mF=P$(Y,{...T,...Q?.()}),dF=Y?JSON.stringify(x):_,$F;for(let d=0;d<=D.maxRetries;d++){let zF=I||new AbortController,ZF=setTimeout(()=>zF.abort(),Z||f.timeoutMs);try{let S=await N$(CF,{...O,body:dF,headers:mF,method:F,signal:zF.signal});return clearTimeout(ZF),K?.(S)||p?.(S)||S}catch(S){if(clearTimeout(ZF),$F=S,d>=D.maxRetries)return V?V(S):Promise.reject(S);await F$($$(d,D))}}return V?V($F):Promise.reject($F)}}function P$(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function H$(F,$){let N=new URL(F);if($)N.search=new URLSearchParams($).toString();return N.toString()}var s={extend:(F)=>({extend:($)=>s.extend({...F,...$}),get:n("GET",F),post:n("POST",F)}),get:n("GET"),post:n("POST")};import{match as UF}from"ts-pattern";function xN(F){if(F<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function AN(F){if(F<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function _N(F,$){try{return F()}catch(N){if($)throw new M($,N);return}}function GN(F){switch(F){case"THOR":return`${F}.RUNE`;case"GAIA":return`${F}.ATOM`;case"BSC":return`${F}`;default:return`${F}.${F}`}}var VF=new Set;function E({condition:F,id:$,warning:N}){if(F){if(VF.has($))return;console.warn(N),VF.add($)}}function R$(F){return UF(F).with(...k,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...c,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...JF,"MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT","FLIP",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("TRON","XRD","FIAT",()=>"").with("NEAR",()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with("XRP",()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new M("helpers_chain_not_supported",{chain:F})})}function x$(F){return UF(F).with("XRD",()=>"/status/network-configuration").with("TRON",()=>"/wallet/getnowblock").otherwise(()=>"")}async function kF(F,$){try{let N=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${N}${x$(F)}`,{body:JSON.stringify(R$(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var RF=new Map,A$=120000;async function xF(F){let{isStagenet:$}=q.get("envs"),N=q.get("rpcUrls"),P=q.get("fallbackRpcUrls");if($)return N[F];let H=RF.get(F);if(H&&Date.now()-H.timestamp<A$)return H.url;let A=N[F];if(!await kF(F,A)){for(let _ of P[F])if(await kF(F,_))return RF.set(F,{timestamp:Date.now(),url:_}),_}return RF.set(F,{timestamp:Date.now(),url:A}),A}function JN(F){E({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var qN=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],KF=["ARB","AURORA","BASE","ETH","OP"];async function _$({chain:F,to:$}){try{let P=await xF(F),{result:H}=await s.post(P,{body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{data:"0x313ce567",to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}});return Number.parseInt(BigInt(H||X[F]).toString(),10)}catch(P){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,P),X[F]}}async function G$(F){if(F==="XRD")return X.XRD;try{let $=F.split("-")[1]?.toLowerCase(),N=await xF("XRD"),{manager:P}=await s.post(`${N}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:$}),headers:{Accept:"*/*","Content-Type":"application/json"}});return P.divisibility.value.divisibility}catch($){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,$),X["XRD"]}}async function T$({chain:F,symbol:$}){if(k.includes($))return X[$];let N=$.split("-"),P=N.length===1?void 0:N[N.length-1]?.toLowerCase();return await(P?.startsWith("0x")?_$({chain:F,to:P}):X[F])}function OF({chain:F,symbol:$}){return t(F).with(...k,(N)=>T$({chain:N,symbol:$})).with("XRD",()=>G$($)).otherwise(()=>X[F])}function DF({chain:F,symbol:$}){return t(F).with(...KF,()=>$==="ETH").with("AVAX",()=>$==="AVAX").with("BERA",()=>$==="BERA").with("BSC",()=>$==="BNB").with("GNO",()=>$==="XDAI").with("MAYA",()=>$==="CACAO").with("GAIA",()=>$==="ATOM").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").with("XRD",()=>`${F}.${$}`===r(F).identifier).otherwise(()=>$===F)}var r=(F)=>{let $=X[F];return t(F.toUpperCase()).with(...KF,(P)=>({decimal:$,identifier:`${P}.ETH`})).with("THOR",(P)=>({decimal:$,identifier:`${P}.RUNE`})).with("GAIA",(P)=>({decimal:$,identifier:`${P}.ATOM`})).with("MAYA",(P)=>({decimal:10,identifier:`${P}.CACAO`})).with("BSC",(P)=>({decimal:$,identifier:`${P}.BNB`})).with("AVAX",(P)=>({decimal:$,identifier:`${P}.AVAX`})).with("GNO",(P)=>({decimal:$,identifier:`${P}.XDAI`})).with("BERA",(P)=>({decimal:$,identifier:`${P}.BERA`})).with("TRON",(P)=>({decimal:$,identifier:`${P}.TRX`})).with(...c,"SOL","FLIP","KUJI","XRP","DOT","NEAR",(P)=>({decimal:$,identifier:`${P}.${P}`})).with("XRD","XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with("POL","POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(P)=>({decimal:6,identifier:P})).with("ETH.FLIP",()=>({decimal:X.ETH,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:X.ETH,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:X.ETH,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(P)=>({decimal:10,identifier:P})).with("MAYA.MAYA",(P)=>({decimal:4,identifier:P})).otherwise(()=>({decimal:$,identifier:F}))};function AF({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return t(F).with("XRD",()=>$==="XRD"||`${F}.${$}`===r(F).identifier).with("ARB","OP","BASE","AURORA",()=>$==="ETH").with("GAIA",()=>$==="ATOM").with("BSC",()=>$==="BNB").with("MAYA",()=>$==="CACAO").with("THOR",()=>$==="RUNE").with("TRON",()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var _F=(F)=>{let[$,...N]=F.split("."),P=F.includes("/"),H=N.join("."),A=H?.split("-"),x=A?.length?A.length===1?A[0]:A.slice(0,-1).join("-"):void 0;return{chain:$,symbol:H,synth:P,ticker:x}};async function VN(F){let{loadTokenLists:$}=await import("./tokens.js"),N=await $();for(let P of Object.values(N))for(let{identifier:H,chain:A,...x}of P.tokens){if("identifier"in F&&H===F.identifier)return H;if("address"in x&&"chain"in F&&A===F.chain&&x.address&&x.address.toLowerCase()===F.contract.toLowerCase())return H}return}var SF=["TERRA",...q.get("chains")];function gF(F=""){let $=F.toUpperCase(),[N]=$.split(".");if(SF.includes(N))return!0;let[P]=$.split("/");if(SF.includes(P))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function IN(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var m=8,g=(F)=>10n**BigInt(F),C=(F)=>Math.log10(Number.parseFloat(F.toString()));function y({value:F,bigIntDecimal:$=m,decimal:N=m}){if(N===0)return F.toString();let P=F<0n,H=F.toString().substring(P?1:0),A=N-(H.length-1);if(A>0)H="0".repeat(A)+H;let x=H.length-N,_=H.slice(-N);if(Number.parseInt(_[$]||"0",10)>=5)_=`${_.substring(0,$-1)}${(Number.parseInt(_[$-1]||"0",10)+1).toString()}`;else _=_.substring(0,$);return`${P?"-":""}${H.slice(0,x)}.${_}`.replace(/\.?0*$/,"")}function B$(F,$){if($===0n)throw Error("Cannot divide by zero");let N=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+N)/$;return(F-N)/$}class w{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new w({decimal:$,value:y({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:N}){return w.fromBigInt(F.getBaseValue("bigint")*g(N)/g($),N)}constructor(F){let $=GF(F),N=typeof F==="object";this.decimal=N?F.decimal:void 0,this.decimalMultiplier=N&&"decimalMultiplier"in F?F.decimalMultiplier:g(Math.max(vF(i($)),this.decimal||0)),this.#H($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let N=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||C(this.decimalMultiplier));switch(F){case"number":return Number(N);case"string":return N;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return N}}getBaseValue(F,$){let N=this.decimalMultiplier/g($||this.decimal||X.THOR),P=B$(this.bigIntValue,N);switch(F){case"number":return Number(P);case"string":return P.toString();case"bigint":return P;default:return P}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let N=GF(F),P=i(N);if(P==="0"||P==="undefined")return 0n;return this.#P(P,$)}toSignificant(F=6){let[$,N]=this.getValue("string").split("."),P=$||"",H=N||"";if((Number.parseInt(P,10)?P.length+H.length:H.length)<=F)return this.getValue("string");if(P.length>=F)return P.slice(0,F).padEnd(P.length,"0");if(Number.parseInt(P,10))return`${P}.${H.slice(0,F-P.length)}`.padEnd(F-P.length,"0");let x=Number.parseInt(H,10),_=`${x}`.slice(0,F);return`0.${_.padStart(H.length-`${x}`.length+_.length,"0")}`}toFixed(F=6){let[$,N]=this.getValue("string").split("."),P=$||"",H=N||"";if(Number.parseInt(P,10))return`${P}.${H.slice(0,F)}`.padEnd(F,"0");let A=Number.parseInt(H,10),x=`${A}`.slice(0,F);return`0.${x.padStart(H.length-`${A}`.length+x.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),N=["","K","M","B","T","Q","Qi","S"],P=Math.floor(Math.log10(Math.abs($))/3),H=N[P];if(!H)return this.getValue("string");let A=10**(P*3);return`${($/A).toFixed(F)}${H}`}toCurrency(F="$",{currencyPosition:$="start",decimal:N=2,decimalSeparator:P=".",thousandSeparator:H=","}={}){let A=this.getValue("number"),[x="",_=""]=A.toFixed(6).split("."),T=x.replace(/\B(?=(\d{3})+(?!\d))/g,H),Q=x||_?x==="0"?`${Number.parseFloat(`0.${_}`)}`.replace(".",P):`${T}${Number.parseInt(_,10)?`${P}${_.slice(0,N)}`:""}`:"0.00";return`${$==="start"?F:""}${Q}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let N=$||this.decimal||m,P=Math.max(N,C(this.decimalMultiplier)),H=F<0n,A=F.toString().substring(H?1:0),x=P-(A.length-1),_=x>0?"0".repeat(x)+A:A,T=_.length-P,Q=_.slice(-P);if(Number.parseInt(Q[N]||"0",10)>=5)Q=`${Q.substring(0,N-1)}${(Number.parseInt(Q[N-1]||"0",10)+1).toString()}`;else Q=Q.substring(0,N);return`${H?"-":""}${_.slice(0,T)}.${Q}`.replace(/\.?0*$/,"")}#$(F,...$){let N=this.#N(this,...$),P=Math.max(N,C(this.decimalMultiplier)),H=g(P),A=$.reduce((_,T)=>{let Q=this.getBigIntValue(T,P);switch(F){case"add":return _+Q;case"sub":return _-Q;case"mul":return _*Q/H;case"div":{if(Q===0n)throw RangeError("Division by zero");return _*H/Q}default:return _}},this.bigIntValue*H/this.decimalMultiplier),x=y({bigIntDecimal:P,decimal:P,value:A});return new this.constructor({decimal:this.decimal,decimalMultiplier:g(P),identifier:this.toString(),value:x})}#F(F,...$){let N=this.#N(this,...$),P=this.getBigIntValue($[0]||"0",N),H=this.getBigIntValue(this,N);switch(F){case"gt":return H>P;case"gte":return H>=P;case"lt":return H<P;case"lte":return H<=P;case"eqValue":return H===P;default:return!1}}#H(F){let $=i(F)||"0";this.bigIntValue=this.#P($)}#N(...F){let $=F.map((N)=>{return typeof N==="object"?N.decimal||C(N.decimalMultiplier):vF(i(N))}).filter(Boolean);return Math.max(...$,m)}#P(F,$){let N=$?g($):this.decimalMultiplier,P=C(N),[H="",A=""]=F.split(".");return BigInt(`${H}${A.padEnd(P,"0")}`)}}var Q$=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function i(F){let N=`${typeof F==="number"?Q$.format(F):GF(F)}`.replaceAll(",",".").split(".");return N.length>1?`${N.slice(0,-1).join("")}.${N.at(-1)}`:N[0]||"0"}function vF(F){let $=F.split(".")[1]?.length||0;return Math.max($,m)}function GF(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var a=["SOL","TRON","NEAR"],v=new Map;class u extends w{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:N,chain:P,symbol:H,identifier:A}){super(typeof F==="object"?F:{decimal:$,value:F});let x=TF(A||`${P}.${H}`);this.type=AF(x),this.tax=N,this.chain=x.chain,this.ticker=x.ticker,this.symbol=x.symbol,this.address=x.address,this.isSynthetic=x.isSynthetic,this.isTradeAsset=x.isTradeAsset,this.isGasAsset=x.isGasAsset,this.chainId=jF[x.chain]}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){if(this.isSynthetic)return`${this.chain}.${this.symbol.replace(/\//g,".")}`;if(this.isTradeAsset)return`${this.chain}.${this.symbol.replace(/~/g,"..")}`;let F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return v.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let N=F.indexOf(".");if(N===-1)throw new M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let P=F.slice(0,N),H=F.slice(N+1),A=BF({chain:P,rest:H}).when(({rest:x})=>x.includes(".."),({chain:x,rest:_})=>`${x}.${_.replace(/\.\./g,"~")}`).when(({chain:x,rest:_})=>["THOR","MAYA"].includes(x)&&_.includes("."),({chain:x,rest:_})=>`${x}.${_.replace(/\./g,"/")}`).otherwise(({chain:x,rest:_})=>`${x}.${_.replace(/__/g,".")}`);return u.from({asset:A,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:N,...P}){let H=F instanceof w?F.getValue("string"):F,A=J$(P),{identifier:x,decimal:_}=r(A),{chain:T,isSynthetic:Q,isTradeAsset:J}=TF(x),Z=v.get(a.includes(T)?x:x.toUpperCase()),I=Z?.decimal||_;E({condition:!(N||I),id:`assetValue_static_decimal_not_found_${T}`,warning:`Couldn't find static decimal for one or more tokens on ${T} (Using default ${X[T]} decimal as fallback).
|
|
1
|
+
import{a as q0,c as U0}from"./chunk-mvp796yg.js";export*from"@swapkit/tokens";export*from"@swapkit/types";import{Chain as X,EVMChains as JF,getChainConfig as B0}from"@swapkit/types";import{getAddress as v0}from"ethers";import{match as _0}from"ts-pattern";import{Chain as _,EVMChains as V0,getChainConfig as w,UTXOChains as LF}from"@swapkit/types";import{match as n}from"ts-pattern";import{Chain as r0}from"@swapkit/types";import{createStore as i0}from"zustand/vanilla";import{Chain as B,StagenetChain as f}from"@swapkit/types";var Z0={[B.Arbitrum]:"https://arb1.arbitrum.io/rpc",[B.Aurora]:"https://aurora-rpc.publicnode.com",[B.Avalanche]:"https://api.avax.network/ext/bc/C/rpc",[B.Base]:"https://base-rpc.publicnode.com",[B.Berachain]:"https://berachain-rpc.publicnode.com",[B.BinanceSmartChain]:"https://bsc-dataseed.binance.org",[B.BitcoinCash]:"https://node-router.thorswap.net/bitcoin-cash",[B.Bitcoin]:"https://bitcoin-rpc.publicnode.com",[B.Chainflip]:"wss://mainnet-archive.chainflip.io",[B.Cosmos]:"https://cosmos-rpc.publicnode.com:443",[B.Dash]:"https://dash-rpc.publicnode.com",[B.Dogecoin]:"https://node-router.thorswap.net/dogecoin",[B.Ethereum]:"https://ethereum-rpc.publicnode.com",[B.Gnosis]:"https://gnosis-rpc.publicnode.com",[B.Kujira]:"https://kujira-rpc.ibs.team",[B.Litecoin]:"https://node-router.thorswap.net/litecoin",[B.Maya]:"https://tendermint.mayachain.info",[B.Near]:"https://rpc.mainnet.near.org",[B.Noble]:"https://noble-rpc.polkachu.com",[B.Optimism]:"https://mainnet.optimism.io",[B.Polkadot]:"wss://rpc.polkadot.io",[B.Polygon]:"https://polygon-rpc.com",[B.Radix]:"https://radix-mainnet.rpc.grove.city/v1/326002fc/core",[B.Ripple]:"wss://xrpl.ws/",[B.Solana]:"https://solana-rpc.publicnode.com",[B.THORChain]:"https://rpc.ninerealms.com",[B.Tron]:"https://tron-rpc.publicnode.com",[B.Zcash]:"https://api.tatum.io/v3/blockchain/node/zcash-mainnet/t-6894a2ae7fc90cccfd3ce71b-2fce88aa7f4a41a5b1e93874",[f.Maya]:"",[f.THORChain]:"https://stagenet-rpc.ninerealms.com"},$0={[B.THORChain]:"https://thornode.ninerealms.com",[B.Maya]:"https://mayanode.mayachain.info",[f.THORChain]:"https://stagenet-thornode.ninerealms.com",[f.Maya]:"https://stagenet.mayanode.mayachain.info"},z0={[B.Arbitrum]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],[B.Aurora]:["https://1rpc.io/aurora","https://mainnet.aurora.dev"],[B.Avalanche]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],[B.Base]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],[B.BinanceSmartChain]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],[B.Berachain]:["https://rpc.berachain.com","https://berachain.drpc.org"],[B.Bitcoin]:["https://bitcoin.publicnode.com"],[B.BitcoinCash]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],[B.Chainflip]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],[B.Cosmos]:["https://cosmos-rpc.publicnode.com"],[B.Dash]:["https://dash-rpc.publicnode.com"],[B.Dogecoin]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],[B.Ethereum]:["https://eth.llamarpc.com","https://cloudflare-eth.com"],[B.Gnosis]:["https://gnosis.drpc.org","https://rpc.ankr.com/gnosis"],[B.Kujira]:["https://kujira-rpc.polkachu.com","https://rpc-kujira.synergynodes.com/"],[B.Litecoin]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],[B.Maya]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],[f.Maya]:[],[B.Near]:["https://1rpc.io/near","https://near.lava.build","https://near-mainnet.infura.io/v3/3cbfcafa5e1e48b7bb0ea41f2fbc4abf"],[B.Noble]:["https://rpc.noble.xyz","https://rpc.cosmos.directory/noble"],[B.Optimism]:["https://optimism.llamarpc.com","https://1rpc.io/op"],[B.Polkadot]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],[B.Polygon]:["https://polygon.llamarpc.com","https://polygon-bor-rpc.publicnode.com"],[B.Radix]:["https://mainnet.radixdlt.com","https://radix-mainnet.rpc.grove.city/v1"],[B.Ripple]:["wss://s1.ripple.com/","wss://s2.ripple.com/"],[B.THORChain]:["https://thornode.ninerealms.com",$0[B.THORChain]],[f.THORChain]:[],[B.Solana]:["https://api.mainnet-beta.solana.com","https://solana-mainnet.rpc.extrnode.com"],[B.Tron]:["https://api.tronstack.io","https://api.tron.network"],[B.Zcash]:[]},Y0={[B.Arbitrum]:"https://arbiscan.io",[B.Aurora]:"https://explorer.mainnet.aurora.dev",[B.Avalanche]:"https://snowtrace.io",[B.Base]:"https://basescan.org",[B.Berachain]:"https://berascan.com",[B.BinanceSmartChain]:"https://bscscan.com",[B.Bitcoin]:"https://blockchair.com/bitcoin",[B.BitcoinCash]:"https://www.blockchair.com/bitcoin-cash",[B.Chainflip]:"https://explorer.polkascan.io/polkadot",[B.Cosmos]:"https://www.mintscan.io/cosmos",[B.Dash]:"https://blockchair.com/dash",[B.Dogecoin]:"https://blockchair.com/dogecoin",[B.Ethereum]:"https://etherscan.io",[B.Gnosis]:"https://gnosisscan.io",[B.Kujira]:"https://finder.kujira.network/kaiyo-1",[B.Litecoin]:"https://blockchair.com/litecoin",[B.Maya]:"https://www.mayascan.org",[B.Near]:"https://nearblocks.io",[B.Noble]:"https://www.mintscan.io/noble",[B.Optimism]:"https://optimistic.etherscan.io",[B.Polkadot]:"https://polkadot.subscan.io",[B.Polygon]:"https://polygonscan.com",[B.Radix]:"https://dashboard.radixdlt.com",[B.Ripple]:"https://livenet.xrpl.org/",[B.THORChain]:"https://runescan.io",[B.Solana]:"https://solscan.io",[B.Tron]:"https://tronscan.org",[B.Zcash]:"https://blockchair.com/zcash"};var o0;((Y)=>{Y.ARB="0x0000000000000000000000000000000000000000";Y.AURORA="0x0000000000000000000000000000000000000000";Y.AVAX="0x0000000000000000000000000000000000000000";Y.BASE="0x0000000000000000000000000000000000000000";Y.BERA="0x0000000000000000000000000000000000000000";Y.ETH="0x0000000000000000000000000000000000000000";Y.BSC="0x0000000000000000000000000000000000000000";Y.GNO="0x0000000000000000000000000000000000000000";Y.MATIC="0x0000000000000000000000000000000000001010";Y.OP="0x4200000000000000000000000000000000000042"})(o0||={});var y={ARB:[44,60,0,0,0],AURORA:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BERA:[44,60,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],DOT:[0,0,0,0,0],ETH:[44,60,0,0,0],FLIP:[0,0,0,0,0],GAIA:[44,118,0,0,0],GNO:[44,60,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],NOBLE:[44,118,0,0,0],OP:[44,60,0,0,0],POL:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],TRON:[44,195,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0],ZEC:[44,133,0,0,0]};var c0;((x)=>{x.unknownError="unknownError";x.test_error="test_error";x.providerDetailsError="providerDetailsError";x.blockHeaderNotFound="blockHeaderNotFound";x.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";x.blockHashNotFoundAtHash="blockHashNotFoundAtHash";x.txHashMissing="txHashMissing";x.assetValueMissingInfo="assetValueMissingInfo";x.invalidAsset="invalidAsset";x.blockIsRequired="blockIsRequired";x.currentBlockHeaderNotFound="currentBlockHeaderNotFound";x.failedToRetrieveBalance="failedToRetrieveBalance";x.failedToRetrieveBlock="failedToRetrieveBlock";x.failedToRetrieveFees="failedToRetrieveFees";x.notImplementedBCH="notImplementedBCH";x.notImplementedDoge="notImplementedDoge";x.noPoolsFound="noPoolsFound";x.noVaultsFound="noVaultsFound";x.noTxFound="noTxFound";x.noInputCoinFound="noInputCoinFound";x.noBlockDataFound="noBlockDataFound";x.multipleCosmosMessages="multipleCosmosMessages";x.heightOrHashNotProvided="heightOrHashNotProvided";x.unknownDenom="unknownDenom";x.invalidBlockHeight="invalidBlockHeight";x.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";x.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";x.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";x.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";x.txMemoUndefined="txMemoUndefined";x.txMemoIncorrect="txMemoIncorrect";x.txTypeNotFound="txTypeNotFound";x.txNoMessage="txNoMessage";x.txNotFound="txNotFound";x.txReceiptNotFound="txReceiptNotFound";x.txParsingError="txParsingError";x.txLogsParsingError="txLogsParsingError";x.blockNotFound="blockNotFound";x.balanceNotFound="balanceNotFound";x.configError="configError";x.synthSwapDisallowed="synthSwapDisallowed";x.providerQuoteTimeout="providerQuoteTimeout";x.noQuoteResponse="noQuoteResponse";x.noPoolAssetsFound="noPoolAssetsFound";x.noThorchainPools="noThorchainPools";x.noMayachainPools="noMayachainPools";x.noThorchainNetworkInfo="noThorchainNetworkInfo";x.invalidAffiliateFee="invalidAffiliateFee";x.invalidBuyAssetAddress="invalidBuyAssetAddress";x.invalidSellAssetAddress="invalidSellAssetAddress";x.invalidSourceAddress="invalidSourceAddress";x.invalidDestinationAddress="invalidDestinationAddress";x.sourceAddressIsSmartContract="sourceAddressIsSmartContract";x.destinationAddressIsSmartContract="destinationAddressIsSmartContract";x.invalidChainId="invalidChainId";x.unsupportedChainId="unsupportedChainId";x.unsupportedEVMChainId="unsupportedEVMChainId";x.unsupportedMethod="unsupportedMethod";x.unsupportedProvider="unsupportedProvider";x.invalidParamsForMethod="invalidParamsForMethod";x.unsupportedAdapter="unsupportedAdapter";x.noWhitelistTokens="noWhitelistTokens";x.failedFetchGasPrice="failedFetchGasPrice";x.failedToCreateDepositChannel="failedToCreateDepositChannel";x.noProviderDetailsFound="noProviderDetailsFound";x.noTokenListsFound="noTokenListsFound";x.tokenNotFound="tokenNotFound";x.tokenPriceNotFound="tokenPriceNotFound";x.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";x.swapAmountTooSmall="swapAmountTooSmall";x.legsArrayIsEmpty="legsArrayIsEmpty";x.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";x.noBlockHeaderFound="noBlockHeaderFound";x.failedToSimulateSwap="failedToSimulateSwap";x.addressScreeningFailed="addressScreeningFailed";x.noLiquidtyProvidersFound="noLiquidtyProvidersFound";x.insufficientLiquidity="insufficientLiquidity";x.noInboundDataFound="noInbounDataFound";x.noInboundAddressesFound="noInboundAddressesFound";x.noInboundAddressFoundForChain="noInboundAddressFoundForChain";x.noLastBlocksFound="noLastBlocksFound";x.noVersionFound="noVersionFound";x.noConstantsFound="noConstantsFound";x.noMimirsFound="noMimirsFound";x.noRoutesFound="noRoutesFound";x.quoteNotFound="quoteNotFound";x.ledgerSignFailed="ledgerSignFailed";x.ledgerWrongPayload="ledgerWrongPayload";x.ledgerFetchSwapFailed="ledgerFetchSwapFailed";x.failedToFetchTx="failedToFetchTx";x.failedBuildTransactionDetails="failedBuildTransactionDetails";x.noLegsForRoute="noLegsForRoute";x.noRouterAddressFound="noRouterAddressFound";x.noAggregatorAddressFound="noAggregatorAddressFound";x.noContractInstanceFound="noContractInstanceFound";x.noContractAddressFound="noContractAddressFound";x.invalidAffiliate="invalidAffiliate";x.thornameAffiliate="thornameAffiliate";x.providerNotfound="No provider found";x.noRecordFound="No Record found";x.slippageTooLow="Slippage too low";x.tradingHalted="tradingHalted";x.noWrappedGasAsset="noWrappedGasAsset";x.aggregatorAddressNotFound="aggregatorAddressNotFound";x.routerAddressNotFound="routerAddressNotFound";x.dummyAddressNotFound="dummyAddressNotFound";x.trackerError="trackerError";x.thorchainPoolUnavailable="thorchainPoolUnavailable";x.noOhlcvDataFound="noOhlcvDataFound";x.noTradingPairs="noTradingPairs";x.noLendingAvailability="noLendingAvailability";x.lendingRepayTooSmall="lendingRepayTooSmall";x.missingState="missingState";x.ledgerSwapNotFound="ledgerSwapNotFound";x.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";x.errorEstimatingGas="errorEstimatingGas";x.apiKeyInvalid="apiKeyInvalid";x.apiKeyFailedToUpdate="apiKeyFailedToUpdate";x.apiKeyExpired="apiKeyExpired";x.unauthorized="unauthorized";x.failedToCreateMemo="failedToCreateMemo";x.radixIncorrectInstructions="radixIncorrectInstructions";x.radixTxMissedParam="radixTxMissedParam";x.radixTxMissedAccount="radixTxMissedAccount";x.radixManifestParseError="radixManifestParseError";x.radixManifestBuildError="radixManifestBuildError";x.invalidAddressForChain="invalidAddressForChain";x.riskyAddress="riskyAddress";x.noRoutesToProcess="noRoutesToProcess";x.sellAssetAmountTooSmall="sellAssetAmountTooSmall";x.missingPrivateKey="missingPrivateKey";x.noMemoPriceProtection="noMemoPriceProtection"})(c0||={});var h0;((A)=>{A.highSlippage="highSlippage";A.highPriceImpact="highPriceImpact"})(h0||={});var l0;((z)=>{z.CAVIAR_V1="CAVIAR_V1";z.CAMELOT_V3="CAMELOT_V3";z.CHAINFLIP="CHAINFLIP";z.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";z.JUPITER="JUPITER";z.MAYACHAIN="MAYACHAIN";z.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";z.OCISWAP_V1="OCISWAP_V1";z.ONEINCH="ONEINCH";z.OPENOCEAN_V2="OPENOCEAN_V2";z.PANCAKESWAP="PANCAKESWAP";z.PANGOLIN_V1="PANGOLIN_V1";z.SUSHISWAP_V2="SUSHISWAP_V2";z.THORCHAIN="THORCHAIN";z.THORCHAIN_STREAMING="THORCHAIN_STREAMING";z.TRADERJOE_V2="TRADERJOE_V2";z.UNISWAP_V2="UNISWAP_V2";z.UNISWAP_V3="UNISWAP_V3";z.NEAR="NEAR"})(l0||={});var n0;((T)=>{T.LIQUIDITY="liquidity";T.NETWORK="network";T.INBOUND="inbound";T.OUTBOUND="outbound";T.AFFILIATE="affiliate";T.TAX="tax";T.PRIORITY="priority"})(n0||={});var J0;((R)=>{R.Average="average";R.Fast="fast";R.Fastest="fastest"})(J0||={});var s0;((A)=>{A.Approve="approve";A.CheckOnly="checkOnly"})(s0||={});var X0;((Z)=>{Z.NAME_REGISTER="~";Z.BOND="BOND";Z.DEPOSIT="+";Z.LEAVE="LEAVE";Z.UNBOND="UNBOND";Z.WITHDRAW="-";Z.RUNEPOOL_DEPOSIT="POOL+";Z.RUNEPOOL_WITHDRAW="POOL-";Z.CLAIM_TCY="tcy";Z.STAKE_TCY="tcy+";Z.UNSTAKE_TCY="tcy-"})(X0||={});var c;((Q)=>{Q.BITGET="BITGET";Q.BRAVE="BRAVE";Q.COINBASE_MOBILE="COINBASE_MOBILE";Q.COINBASE_WEB="COINBASE_WEB";Q.COSMOSTATION="COSMOSTATION";Q.CTRL="CTRL";Q.EIP6963="EIP6963";Q.EXODUS="EXODUS";Q.KEEPKEY="KEEPKEY";Q.KEEPKEY_BEX="KEEPKEY_BEX";Q.KEPLR="KEPLR";Q.KEYSTORE="KEYSTORE";Q.LEAP="LEAP";Q.LEDGER="LEDGER";Q.LEDGER_LIVE="LEDGER_LIVE";Q.METAMASK="METAMASK";Q.OKX="OKX";Q.OKX_MOBILE="OKX_MOBILE";Q.ONEKEY="ONEKEY";Q.PHANTOM="PHANTOM";Q.POLKADOT_JS="POLKADOT_JS";Q.RADIX_WALLET="RADIX_WALLET";Q.TREZOR="TREZOR";Q.TALISMAN="TALISMAN";Q.TRONLINK="TRONLINK";Q.TRUSTWALLET_WEB="TRUSTWALLET_WEB";Q.VULTISIG="VULTISIG";Q.WALLETCONNECT="WALLETCONNECT";Q.XAMAN="XAMAN"})(c||={});var t0;((R)=>{R[R.NoError=36864]="NoError";R[R.LockedDevice=21781]="LockedDevice";R[R.TC_NotFound=65535]="TC_NotFound"})(t0||={});var a0={apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:"",xaman:""},apis:{},chains:Object.values(r0),envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},explorerUrls:Y0,fallbackRpcUrls:z0,feeMultipliers:void 0,integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}},nodeUrls:$0,requestOptions:{retry:{backoffMultiplier:2,baseDelay:300,maxDelay:5000,maxRetries:3},timeoutMs:30000},rpcUrls:Z0,wallets:Object.values(c)},j=i0((F)=>({...a0,setApiKey:($,A)=>F((R)=>({apiKeys:{...R.apiKeys,[$]:A}})),setConfig:($)=>F((A)=>({apiKeys:{...A.apiKeys,...$.apiKeys},chains:A.chains.concat($.chains||[]),envs:{...A.envs,...$.envs},explorerUrls:{...A.explorerUrls,...$.explorerUrls},feeMultipliers:$.feeMultipliers||A.feeMultipliers,integrations:{...A.integrations,...$.integrations},nodeUrls:{...A.nodeUrls,...$.nodeUrls},rpcUrls:{...A.rpcUrls,...$.rpcUrls},wallets:A.wallets.concat($.wallets||[])})),setEnv:($,A)=>F((R)=>({envs:{...R.envs,[$]:A}})),setExplorerUrl:($,A)=>F((R)=>({explorerUrls:{...R.explorerUrls,[$]:A}})),setFallbackRpcUrls:($,A)=>F((R)=>({fallbackRpcUrls:{...R.fallbackRpcUrls,[$]:A}})),setFeeMultipliers:($)=>F(()=>({feeMultipliers:$})),setIntegrationConfig:($,A)=>F((R)=>({integrations:{...R.integrations,[$]:A}})),setNodeUrl:($,A)=>F((R)=>({nodeUrls:{...R.nodeUrls,[$]:A}})),setRequestOptions:($)=>F((A)=>({requestOptions:{retry:{...A.requestOptions.retry,...$.retry},timeoutMs:$.timeoutMs||A.requestOptions.timeoutMs}})),setRpcUrl:($,A)=>F((R)=>({rpcUrls:{...R.rpcUrls,[$]:A}}))})),W={get:(F)=>j.getState()[F],getState:j.getState,set:(F)=>j.getState().setConfig(F),setApiKey:(F,$)=>j.getState().setApiKey(F,$),setEnv:(F,$)=>j.getState().setEnv(F,$),setExplorerUrl:(F,$)=>j.getState().setExplorerUrl(F,$),setFallbackRpcUrls:(F,$)=>j.getState().setFallbackRpcUrls(F,$),setFeeMultipliers:(F)=>j.getState().setFeeMultipliers(F),setIntegrationConfig:(F,$)=>j.getState().setIntegrationConfig(F,$),setNodeUrl:(F,$)=>j.getState().setNodeUrl(F,$),setRequestOptions:(F)=>j.getState().setRequestOptions(F),setRpcUrl:(F,$)=>j.getState().setRpcUrl(F,$)};var e0={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,wallet_near_extensions_failed_to_switch_network:22001,wallet_near_extensions_no_provider:22002,wallet_near_extensions_not_found:22003,wallet_near_method_not_supported:22003,wallet_vultisig_not_found:22101,wallet_vultisig_contract_address_not_provided:22102,wallet_vultisig_asset_not_defined:22103,wallet_vultisig_send_transaction_no_address:22104,wallet_xaman_not_configured:23001,wallet_xaman_not_connected:23002,wallet_xaman_auth_failed:23003,wallet_xaman_connection_failed:23004,wallet_xaman_transaction_failed:23005,wallet_xaman_monitoring_failed:23006,wallet_tronlink_request_accounts_failed:24001,wallet_tronlink_locked:24002,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_asset_is_not_tcy:40003,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_substrate_transfer_error:50502,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_tron_transaction_creation_failed:50804,toolbox_tron_fee_estimation_failed:50805,toolbox_tron_trongrid_api_error:50806,toolbox_tron_approve_failed:50807,toolbox_tron_invalid_token_contract:50808,toolbox_tron_allowance_check_failed:50809,toolbox_near_no_signer:90601,toolbox_near_invalid_address:90602,toolbox_near_invalid_amount:90603,toolbox_near_transfer_failed:90604,toolbox_near_access_key_error:90605,toolbox_near_no_rpc_url:90606,toolbox_near_empty_batch:90607,toolbox_near_balance_failed:90608,toolbox_near_invalid_name:90609,toolbox_near_missing_contract_address:90610,toolbox_near_no_account:90611,toolbox_near_invalid_gas_params:90612,toolbox_not_supported:59901,plugin_near_invalid_name:41001,plugin_near_no_connection:41002,plugin_near_name_unavailable:41003,plugin_near_registration_failed:41004,plugin_near_transfer_failed:41005,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class J extends Error{static ErrorCode=e0;constructor(F,$){let A=typeof F==="string",R=A?F:F.errorKey,P=A?void 0:F.info,N=`${R}${P?`: ${JSON.stringify(P)}`:""}`;super(N);if(Object.setPrototypeOf(this,J.prototype),this.name="SwapKitError",this.cause=$,$)console.error(`SwapKitError [${R}]:`,$);else if(P)console.error(`SwapKitError [${R}]:`,P)}}var FF=(F)=>new Promise(($)=>setTimeout($,F)),$F=(F,{baseDelay:$,backoffMultiplier:A,maxDelay:R})=>Math.min($*A**F,R),AF=async(F,$)=>{let A=await fetch(F,$);if(!A.ok){let P={message:await A.text(),status:A.status,statusText:A.statusText};throw new J({errorKey:"helpers_invalid_response",info:P},P)}return A.json()};function h(F,$={}){return async function(R,P={}){let{searchParams:N,json:H,body:T,headers:G,dynamicHeader:L,retry:Y,timeoutMs:Z,abortController:D,onError:q,onSuccess:b,responseHandler:S,...m}={...$,...P},U=W.get("requestOptions"),K={...U.retry,...Y},z=!!H||R.endsWith(".json"),d0=PF(R,N),m0=RF(z,{...G,...L?.()}),C0=z?JSON.stringify(H):T,F0;for(let o=0;o<=K.maxRetries;o++){let Q0=D||new AbortController,M0=setTimeout(()=>Q0.abort(),Z||U.timeoutMs);try{let v=await AF(d0,{...m,body:C0,headers:m0,method:F,signal:Q0.signal});return clearTimeout(M0),b?.(v)||S?.(v)||v}catch(v){if(clearTimeout(M0),F0=v,o>=K.maxRetries)return q?q(v):Promise.reject(v);await FF($F(o,K))}}return q?q(F0):Promise.reject(F0)}}function RF(F,$){return{...$,...F&&{"Content-Type":"application/json"}}}function PF(F,$){let A=new URL(F);if($)A.search=new URLSearchParams($).toString();return A.toString()}var l={extend:(F)=>({extend:($)=>l.extend({...F,...$}),get:h("GET",F),post:h("POST",F)}),get:h("GET"),post:h("POST")};import{Chain as V,CosmosChains as xF,EVMChains as NF,StagenetChains as HF,UTXOChains as BF}from"@swapkit/types";import{match as W0}from"ts-pattern";import{Chain as A0}from"@swapkit/types";function L$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return 10+F}function Q$(F){if(F<0)throw new J({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:F}});return Math.round((10+F*1.0512)*10000000000)/10000000000}function M$(F,$){try{return F()}catch(A){if($)throw new J($,A);return}}function Z$(F){switch(F){case A0.THORChain:return`${F}.RUNE`;case A0.Cosmos:return`${F}.ATOM`;case A0.BinanceSmartChain:return`${F}`;default:return`${F}.${F}`}}var I0=new Set;function u({condition:F,id:$,warning:A}){if(F){if(I0.has($))return;console.warn(A),I0.add($)}}function TF(F){return W0(F).with(...NF,()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with(...BF,()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with(...xF,...HF,()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with(V.Polkadot,V.Chainflip,()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with(V.Solana,()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with(V.Tron,V.Radix,()=>"").with(V.Near,()=>({id:"dontcare",jsonrpc:"2.0",method:"status",params:[]})).with(V.Ripple,()=>({id:1,jsonrpc:"2.0",method:"ping",params:[{}]})).otherwise(()=>{throw new J("helpers_chain_not_supported",{chain:F})})}function _F(F){return W0(F).with(V.Radix,()=>"/status/network-configuration").with(V.Tron,()=>"/wallet/getnowblock").otherwise(()=>"")}async function j0(F,$){try{let A=$.startsWith("wss")?$.replace("wss","https"):$;return(await fetch(`${A}${_F(F)}`,{body:JSON.stringify(TF(F)),headers:{"Content-Type":"application/json"},method:"POST",signal:AbortSignal.timeout(3000)})).ok}catch{return!1}}var R0=new Map,GF=120000;async function P0(F){let{isStagenet:$}=W.get("envs"),A=W.get("rpcUrls"),R=W.get("fallbackRpcUrls");if($)return A[F];let P=R0.get(F);if(P&&Date.now()-P.timestamp<GF)return P.url;let N=A[F];if(!await j0(F,N)){for(let T of R[F])if(await j0(F,T))return R0.set(F,{timestamp:Date.now(),url:T}),T}return R0.set(F,{timestamp:Date.now(),url:N}),N}function W$(F){u({condition:!0,id:"initializeRPCUrlsWithFallback",warning:"initializeRPCUrlsWithFallback is deprecated. Use static { rpcUrls, fallbackRpcUrls } SwapKit init config or dynamic SKConfig.setRpcUrl/setFallbackRpcUrl to configure RPC endpoints."})}var w$=[`${_.Maya}.MAYA`,`${_.Maya}.CACAO`,`${_.Ethereum}.THOR`,`${_.Ethereum}.vTHOR`,`${_.Kujira}.USK`,`${_.Ethereum}.FLIP`,`${_.Radix}.XRD`],k0=[_.Arbitrum,_.Aurora,_.Base,_.Ethereum,_.Optimism];async function QF({chain:F,to:$}){let{baseDecimal:R}=w(F);try{let P=await P0(F),{result:N}=await l.post(P,{body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{data:"0x313ce567",to:$.toLowerCase()},"latest"]}),headers:{accept:"*/*","cache-control":"no-cache","content-type":"application/json"}});return Number.parseInt(BigInt(N||R).toString(),10)}catch(P){return console.error(`Failed to fetch contract decimals for ${$} on ${F}:`,P),R}}async function MF(F){let{baseDecimal:$}=w(_.Radix);if(F===_.Radix)return $;try{let A=F.split("-")[1]?.toLowerCase(),R=await P0(_.Radix),{manager:P}=await l.post(`${R}/state/resource`,{body:JSON.stringify({network:"mainnet",resource_address:A}),headers:{Accept:"*/*","Content-Type":"application/json"}});return P.divisibility.value.divisibility}catch(A){return console.error(`Failed to fetch Radix asset decimal for ${F}:`,A),$}}async function ZF({chain:F,symbol:$}){let{baseDecimal:A}=w(F);if(V0.includes($))return A;let R=$.split("-"),P=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(P?.startsWith("0x")?QF({chain:F,to:P}):A)}function K0({chain:F,symbol:$}){let{baseDecimal:A}=w(F);return n(F).with(...V0,(R)=>ZF({chain:R,symbol:$})).with(_.Radix,()=>MF($)).otherwise(()=>A)}function w0({chain:F,symbol:$}){return n(F).with(...k0,()=>$==="ETH").with(_.Avalanche,()=>$==="AVAX").with(_.Berachain,()=>$==="BERA").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Gnosis,()=>$==="XDAI").with(_.Maya,()=>$==="CACAO").with(_.Cosmos,()=>$==="ATOM").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").with(_.Radix,()=>`${F}.${$}`===s(F).identifier).otherwise(()=>$===F)}var s=(F)=>{let{baseDecimal:$}=w(F);return n(F.toUpperCase()).with(...k0,(R)=>({decimal:$,identifier:`${R}.ETH`})).with(_.THORChain,(R)=>({decimal:$,identifier:`${R}.RUNE`})).with(_.Cosmos,(R)=>({decimal:$,identifier:`${R}.ATOM`})).with(_.Maya,(R)=>({decimal:10,identifier:`${R}.CACAO`})).with(_.BinanceSmartChain,(R)=>({decimal:$,identifier:`${R}.BNB`})).with(_.Avalanche,(R)=>({decimal:$,identifier:`${R}.AVAX`})).with(_.Gnosis,(R)=>({decimal:$,identifier:`${R}.XDAI`})).with(_.Berachain,(R)=>({decimal:$,identifier:`${R}.BERA`})).with(_.Tron,(R)=>({decimal:$,identifier:`${R}.TRX`})).with(_.Solana,_.Chainflip,_.Kujira,_.Ripple,_.Polkadot,_.Near,...LF,(R)=>({decimal:$,identifier:`${R}.${R}`})).with(_.Radix,"XRD.XRD",()=>({decimal:$,identifier:"XRD.XRD"})).with(_.Polygon,"POL.POL",()=>({decimal:$,identifier:"POL.POL"})).with("KUJI.USK",(R)=>({decimal:6,identifier:R})).with("ETH.FLIP",()=>({decimal:w(_.Ethereum).baseDecimal,identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A"})).with("ETH.THOR",()=>({decimal:w(_.Ethereum).baseDecimal,identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044"})).with("ETH.vTHOR",()=>({decimal:w(_.Ethereum).baseDecimal,identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d"})).with("MAYA.CACAO",(R)=>({decimal:10,identifier:R})).with("MAYA.MAYA",(R)=>({decimal:4,identifier:R})).otherwise(()=>({decimal:$,identifier:F}))};function x0({chain:F,symbol:$}){if($.includes("/"))return"Synth";if($.includes("~"))return"Trade";return n(F).with(_.Radix,()=>$===_.Radix||`${F}.${$}`===s(F).identifier).with(_.Arbitrum,_.Optimism,_.Base,_.Aurora,()=>$===_.Ethereum).with(_.Cosmos,()=>$==="ATOM").with(_.BinanceSmartChain,()=>$==="BNB").with(_.Maya,()=>$==="CACAO").with(_.THORChain,()=>$==="RUNE").with(_.Tron,()=>$==="TRX").otherwise(()=>$===F)?"Native":F}var N0=(F)=>{let[$,...A]=F.split("."),R=F.includes("/"),P=A.join("."),N=P?.split("-"),H=N?.length?N.length===1?N[0]:N.slice(0,-1).join("-"):void 0;return{chain:$,symbol:P,synth:R,ticker:H}};async function O$(F){let{loadTokenLists:$}=await import("./tokens.js"),A=await $();for(let R of Object.values(A))for(let{identifier:P,chain:N,...H}of R.tokens){if("identifier"in F&&P===F.identifier)return P;if("address"in H&&"chain"in F&&N===F.chain&&H.address&&H.address.toLowerCase()===F.contract.toLowerCase())return P}return}var O0=["TERRA",...W.get("chains")];function D0(F=""){let $=F.toUpperCase(),[A]=$.split(".");if(O0.includes(A))return!0;let[R]=$.split("/");if(O0.includes(R))return!0;throw new J({errorKey:"helpers_invalid_identifier",info:{identifier:F,message:`Invalid identifier: ${F}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`}})}function E$(F){if(F.length>30)return!1;let $=/^[a-zA-Z0-9+_-]+$/g;return!!F.match($)}var E=(F)=>10n**BigInt(F),C=(F)=>Math.log10(Number.parseFloat(F.toString()));function p({value:F,bigIntDecimal:$=8,decimal:A=8}){if(A===0)return F.toString();let R=F<0n,P=F.toString().substring(R?1:0),N=A-(P.length-1);if(N>0)P="0".repeat(N)+P;let H=P.length-A,T=P.slice(-A);if(Number.parseInt(T[$]||"0",10)>=5)T=`${T.substring(0,$-1)}${(Number.parseInt(T[$-1]||"0",10)+1).toString()}`;else T=T.substring(0,$);return`${R?"-":""}${P.slice(0,H)}.${T}`.replace(/\.?0*$/,"")}function zF(F,$){if($===0n)throw Error("Cannot divide by zero");let A=$/2n;if(F>=0n&&$>=0n||F<0n&&$<0n)return(F+A)/$;return(F-A)/$}class O{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(F,$){return new O({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}static shiftDecimals({value:F,from:$,to:A}){return O.fromBigInt(F.getBaseValue("bigint")*E(A)/E($),A)}constructor(F){let $=H0(F),A=typeof F==="object";this.decimal=A?F.decimal:void 0,this.decimalMultiplier=A&&"decimalMultiplier"in F?F.decimalMultiplier:E(Math.max(S0(t($)),this.decimal||0)),this.#P($)}set(F){return new this.constructor({decimal:this.decimal,identifier:this.toString({includeSynthProtocol:!0}),value:F})}add(...F){return this.#$("add",...F)}sub(...F){return this.#$("sub",...F)}mul(...F){return this.#$("mul",...F)}div(...F){return this.#$("div",...F)}gt(F){return this.#F("gt",F)}gte(F){return this.#F("gte",F)}lt(F){return this.#F("lt",F)}lte(F){return this.#F("lte",F)}eqValue(F){return this.#F("eqValue",F)}getValue(F,$){let A=this.formatBigIntToSafeValue(this.bigIntValue,$||this.decimal||C(this.decimalMultiplier));switch(F){case"number":return Number(A);case"string":return A;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return A}}getBaseValue(F,$){let A=this.decimalMultiplier/E($||this.decimal||8),R=zF(this.bigIntValue,A);switch(F){case"number":return Number(R);case"string":return R.toString();case"bigint":return R;default:return R}}getBigIntValue(F,$){if(!$&&typeof F==="object")return F.bigIntValue;let A=H0(F),R=t(A);if(R==="0"||R==="undefined")return 0n;return this.#R(R,$)}toSignificant(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",P=A||"";if((Number.parseInt(R,10)?R.length+P.length:P.length)<=F)return this.getValue("string");if(R.length>=F)return R.slice(0,F).padEnd(R.length,"0");if(Number.parseInt(R,10))return`${R}.${P.slice(0,F-R.length)}`.padEnd(F-R.length,"0");let H=Number.parseInt(P,10),T=`${H}`.slice(0,F);return`0.${T.padStart(P.length-`${H}`.length+T.length,"0")}`}toFixed(F=6){let[$,A]=this.getValue("string").split("."),R=$||"",P=A||"";if(Number.parseInt(R,10))return`${R}.${P.slice(0,F)}`.padEnd(F,"0");let N=Number.parseInt(P,10),H=`${N}`.slice(0,F);return`0.${H.padStart(P.length-`${N}`.length+H.length,"0")}`}toAbbreviation(F=2){let $=this.getValue("number"),A=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs($))/3),P=A[R];if(!P)return this.getValue("string");let N=10**(R*3);return`${($/N).toFixed(F)}${P}`}toCurrency(F="$",{currencyPosition:$="start",decimal:A=2,decimalSeparator:R=".",thousandSeparator:P=","}={}){let N=this.getValue("number"),[H="",T=""]=N.toFixed(6).split("."),G=H.replace(/\B(?=(\d{3})+(?!\d))/g,P),L=H||T?H==="0"?`${Number.parseFloat(`0.${T}`)}`.replace(".",R):`${G}${Number.parseInt(T,10)?`${R}${T.slice(0,A)}`:""}`:"0.00";return`${$==="start"?F:""}${L}${$==="end"?F:""}`}formatBigIntToSafeValue(F,$){let A=$||this.decimal||8,R=Math.max(A,C(this.decimalMultiplier)),P=F<0n,N=F.toString().substring(P?1:0),H=R-(N.length-1),T=H>0?"0".repeat(H)+N:N,G=T.length-R,L=T.slice(-R);if(Number.parseInt(L[A]||"0",10)>=5)L=`${L.substring(0,A-1)}${(Number.parseInt(L[A-1]||"0",10)+1).toString()}`;else L=L.substring(0,A);return`${P?"-":""}${T.slice(0,G)}.${L}`.replace(/\.?0*$/,"")}#$(F,...$){let A=this.#A(this,...$),R=Math.max(A,C(this.decimalMultiplier)),P=E(R),N=$.reduce((T,G)=>{let L=this.getBigIntValue(G,R);switch(F){case"add":return T+L;case"sub":return T-L;case"mul":return T*L/P;case"div":{if(L===0n)throw RangeError("Division by zero");return T*P/L}default:return T}},this.bigIntValue*P/this.decimalMultiplier),H=p({bigIntDecimal:R,decimal:R,value:N});return new this.constructor({decimal:this.decimal,decimalMultiplier:E(R),identifier:this.toString(),value:H})}#F(F,...$){let A=this.#A(this,...$),R=this.getBigIntValue($[0]||"0",A),P=this.getBigIntValue(this,A);switch(F){case"gt":return P>R;case"gte":return P>=R;case"lt":return P<R;case"lte":return P<=R;case"eqValue":return P===R;default:return!1}}#P(F){let $=t(F)||"0";this.bigIntValue=this.#R($)}#A(...F){let $=F.map((A)=>{return typeof A==="object"?A.decimal||C(A.decimalMultiplier):S0(t(A))}).filter(Boolean);return Math.max(...$,8)}#R(F,$){let A=$?E($):this.decimalMultiplier,R=C(A),[P="",N=""]=F.split(".");return BigInt(`${P}${N.padEnd(R,"0")}`)}}var YF=Intl.NumberFormat("fullwide",{maximumFractionDigits:20,useGrouping:!1});function t(F){let A=`${typeof F==="number"?YF.format(F):H0(F)}`.replaceAll(",",".").split(".");return A.length>1?`${A.slice(0,-1).join("")}.${A.at(-1)}`:A[0]||"0"}function S0(F){let $=F.split(".")[1]?.length||0;return Math.max($,8)}function H0(F){return typeof F==="object"?"getValue"in F?F.getValue("string"):F.value:F}var r=[X.Solana,X.Tron,X.Near],G0=[X.THORChain,X.Maya],g=new Map;class d extends O{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:F,decimal:$,tax:A,chain:R,symbol:P,identifier:N}){super(typeof F==="object"?F:{decimal:$,value:F});let H=T0(N||`${R}.${P}`);this.type=x0(H),this.tax=A,this.chain=H.chain,this.ticker=H.ticker,this.symbol=H.symbol,this.address=H.address,this.isSynthetic=H.isSynthetic,this.isTradeAsset=H.isTradeAsset,this.isGasAsset=H.isGasAsset,this.chainId=B0(H.chain).chainId}toString({includeSynthProtocol:F}={}){return(this.isSynthetic||this.isTradeAsset)&&!F?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){if(this.isSynthetic)return`${this.chain}.${this.symbol.replace(/\//g,".")}`;if(this.isTradeAsset)return`${this.chain}.${this.symbol.replace(/~/g,"..")}`;let F=this.symbol.replace(/\./g,"__");return`${this.chain}.${F}`}getIconUrl(){return g.get(this.toString())?.logoURI}eqAsset({chain:F,symbol:$}){return this.chain===F&&this.symbol===$}eq(F){return this.eqAsset(F)&&this.eqValue(F)}static fromUrl(F,$=0){let A=F.indexOf(".");if(A===-1)throw new J({errorKey:"helpers_invalid_asset_url",info:{urlAsset:F}});let R=F.slice(0,A),P=F.slice(A+1),N=_0({chain:R,rest:P}).when(({rest:H})=>H.includes(".."),({chain:H,rest:T})=>`${H}.${T.replace(/\.\./g,"~")}`).when(({chain:H,rest:T})=>G0.includes(H)&&T.includes("."),({chain:H,rest:T})=>`${H}.${T.replace(/\./g,"/")}`).otherwise(({chain:H,rest:T})=>`${H}.${T.replace(/__/g,".")}`);return d.from({asset:N,value:$})}static from({value:F=0,fromBaseDecimal:$,asyncTokenLookup:A,...R}){let P=F instanceof O?F.getValue("string"):F,N=WF(R),{identifier:H,decimal:T}=s(N),{chain:G,isSynthetic:L,isTradeAsset:Y}=T0(H),{baseDecimal:Z}=B0(G),D=g.get(r.includes(G)?H:H.toUpperCase()),q=D?.decimal||T;u({condition:!(A||q),id:`assetValue_static_decimal_not_found_${G}`,warning:`Couldn't find static decimal for one or more tokens on ${G} (Using default ${Z} decimal as fallback).
|
|
2
2
|
This can result in incorrect calculations and mess with amount sent on transactions.
|
|
3
3
|
You can load static assets by installing @swapkit/tokens package and calling AssetValue.loadStaticAssets()
|
|
4
|
-
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`});let{decimal:V,identifier:K,tax:p}=Z||{decimal:I||X[T],identifier:x},O=$?e(BigInt(H),$):e(H,V);return N?z$(K,$?O:H):Q||J?Z$(K,O):new u({decimal:V,identifier:K,tax:p,value:O})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),N=await $(F);for(let{tokens:P}of Object.values(N))for(let{identifier:H,chain:A,...x}of P){let _=a.includes(A)?H:H.toUpperCase(),T="decimals"in x?x.decimals:X[A];v.set(_,{decimal:T,identifier:H})}return!0}static setStaticAssets(F){v.clear();for(let[$,N]of F.entries()){let P=a.includes(N.chain)?N.identifier:N.identifier.toUpperCase(),H="decimals"in N?N.decimals:N.decimal;v.set($,{...N,decimal:H,identifier:P})}return!0}}function pN(F){let $=u.from({chain:F});return BF(F).with("BTC","LTC","BCH","DASH",()=>$.set(0.00010001)).with("DOGE",()=>$.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>$.set(0.00000001)).with("THOR","MAYA",()=>$.set(0)).with("GAIA","KUJI",()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function z$(F,$=0){gF(F);let P=F.includes("SOL.")?F:F.toUpperCase(),H=v.get(P),A=H?.decimal||await OF(TF(F));if(!H)v.set(P,{decimal:A,identifier:F});return new u({decimal:A,identifier:F,value:e($,A)})}function Z$(F,$=0){let N=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,P=N?["MAYA","THOR"].includes(N):!1,H=F.slice(0,14).includes("~")?"~":"/",[A,x]=P?F.split(".").slice(1).join().split(H):F.split(H);if(!(A&&x))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new u({decimal:8,identifier:`${N||"THOR"}.${A}${H}${x}`,value:e($,8)})}function e(F,$){return typeof F==="bigint"?y({bigIntDecimal:$,decimal:$,value:F}):F}function Y$(F){let $=BF(F).when((N)=>("chain"in N)&&N.chain!==void 0,({chain:N})=>N).otherwise((N)=>{let P=_F(N.asset);return P.synth?"THOR":P.chain});if(!Object.values(L).includes($.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function J$(F){if(Y$(F),"chain"in F)return F.chain;let{chain:$,symbol:N}=_F(F.asset);return AF({chain:$,symbol:N})==="Native"?$:F.asset}function M$(F,$,N){let P=F.split("."),H=P[0]?.toUpperCase(),A=["THOR","MAYA"].includes(H),x=N?"~":"/",[_,T=""]=A?P.slice(1).join(".").split(x):F.split(x);if(!(_&&T))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:Q,address:J}=bF({chain:_,symbol:T}),Z=`${_}${x}${T}`;return{address:J,chain:H,isGasAsset:!1,isSynthetic:$,isTradeAsset:N,symbol:Z,ticker:Q}}function X$(F){let $=F.indexOf("."),N=($===-1?F:F.slice(0,$)).toUpperCase(),P=$===-1?F:F.slice($+1),{address:H,ticker:A}=bF({chain:N,symbol:P}),x;try{x=H&&k.includes(N)&&fF(H)?fF(H):H}catch(T){x=H}let _=x?`${A}-${x}`:P;return{address:x,chain:N,isGasAsset:DF({chain:N,symbol:P}),isSynthetic:!1,isTradeAsset:!1,symbol:_,ticker:A}}function TF(F){let $=F.slice(0,14),N=$.includes("/"),P=$.includes("~");if(N||P)return M$(F,N,P);return X$(F)}function L$(F,$=!1){let N=$?F.indexOf("-"):F.lastIndexOf("-");if(N===-1)return{address:void 0,ticker:F};let P=F.slice(0,N);return{address:F.slice(N+1),ticker:P}}function bF({symbol:F,chain:$}){let{ticker:N,address:P}=L$(F,$==="NEAR");return{address:P&&!a.includes($)?P.toLowerCase():P,ticker:N}}var j$={average:1,fast:1.5,fastest:2};function EF(F="average"){let $=q.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return j$[F]}function W$(F="average"){let $=EF(F),N=10n,P=BigInt(Math.round($*10));return{denominator:N,numerator:P}}function oN(F,$="average"){let{numerator:N,denominator:P}=W$($);return F*N/P}function hN(F,$="average",N=!1){let P=EF($),H=F*P;return N?Math.floor(H):H}class U extends w{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new U({decimal:$,value:y({bigIntDecimal:$,decimal:$,value:F})})}}function QF(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[N,P,H,,A]=F;return[N,P,H,$.change,A]}if("account"in $){let[N,P,,H,A]=F;return[N,P,$.account,H,A]}return F}function q$([F,$,N,P,H]){let A=typeof H!=="number";if(typeof P!=="number")return`m/${F}'/${$}'/${N}'`;return`m/${F}'/${$}'/${N}'/${P}${A?"":`/${H}`}`}function tN({chain:F,index:$,addressIndex:N=0,type:P}){if(k.includes(F)){if(P&&["legacy","account"].includes(P))return[44,60,0,$];if(P==="ledgerLive")return[44,60,$,0,N];return QF(b[F],{index:$})}if(F==="SOL"){if(P==="account")return[44,501,0,$];return QF(b[F],{index:$})}let H=F==="LTC"?2:0;switch(P){case"nativeSegwitMiddleAccount":return[84,H,$,0,N];case"segwit":return[49,H,0,0,$];case"legacy":return[44,H,0,0,$];default:return QF(b[F],{index:$})}}function rN(F){let[$,N,P]=F.split("/").map((H)=>Number.parseInt(H,10));switch(N){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var iN=Object.keys(b).reduce((F,$)=>{return F[$]=q$(b[$]),F},{});import{Chain as z,ChainToExplorerUrl as yF}from"@swapkit/helpers";import{match as uF}from"ts-pattern";function $P({chain:F,txHash:$}){let N=yF[F];return uF(F).with(z.Maya,z.Kujira,z.Noble,z.Cosmos,z.THORChain,z.Solana,()=>`${N}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(z.Arbitrum,z.Aurora,z.Avalanche,z.BinanceSmartChain,z.Base,z.Berachain,z.Ethereum,z.Gnosis,z.Optimism,z.Polkadot,z.Polygon,()=>`${N}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(z.Litecoin,z.Bitcoin,z.BitcoinCash,z.Dogecoin,z.Zcash,z.Radix,()=>`${N}/transaction/${$.toLowerCase()}`).with(z.Near,()=>`${N}/txns/${$}`).with(z.Ripple,()=>`${N}/transactions/${$}`).with(z.Tron,()=>`${N}/#/transaction/${$}`).otherwise(()=>"")}function NP({chain:F,address:$}){let N=yF[F];return uF(F).with(z.Solana,z.Radix,()=>`${N}/account/${$}`).with(z.Tron,()=>`${N}/#/address/${$}`).otherwise(()=>`${N}/address/${$}`)}function V$({liquidityUnits:F,poolUnits:$,runeDepth:N}){let P=j(F),H=j($),A=j(N),x=P.mul(A),_=H.mul(H).mul(2),T=H.mul(P).mul(2),Q=P.mul(P),J=H.mul(H).mul(H);return x.mul(_.sub(T).add(Q)).div(J)}function k$({liquidityUnits:F,poolUnits:$,assetDepth:N}){let P=j(F),H=j($),A=j(N),x=P.mul(A),_=H.mul(H).mul(2),T=H.mul(P).mul(2),Q=P.mul(P),J=x.mul(_.sub(T).add(Q)),Z=H.mul(H).mul(H);return J.div(Z)}function xP({percent:F,runeDepth:$,liquidityUnits:N,poolUnits:P}){return V$({liquidityUnits:N,poolUnits:P,runeDepth:$}).mul(F)}function AP({percent:F,assetDepth:$,liquidityUnits:N,poolUnits:P}){return k$({assetDepth:$,liquidityUnits:N,poolUnits:P}).mul(F)}function j(F){return U.fromBigInt(BigInt(F),X.THOR)}function U$({liquidityUnits:F,poolUnits:$,runeDepth:N,assetDepth:P}){return{assetAmount:j(P).mul(F).div($),runeAmount:j(N).mul(F).div($)}}function _P({liquidityUnits:F,poolUnits:$,runeDepth:N,assetDepth:P,percent:H}){return Object.fromEntries(Object.entries(U$({assetDepth:P,liquidityUnits:F,poolUnits:$,runeDepth:N})).map(([A,x])=>[A,x.mul(H)]))}function GP({runeDepth:F,poolUnits:$,assetDepth:N,liquidityUnits:P,runeAmount:H,assetAmount:A}){let x=new U({decimal:8,value:F}),_=new U({decimal:8,value:N}),T=new U({decimal:8,value:$}),Q=new U({decimal:8,value:H}),J=new U({decimal:8,value:A}),Z=Q.mul(_),I=J.mul(x),V=Q.mul(J),K=x.mul(_),p=T.mul(Z.add(I.add(V.mul(2)))),O=Z.add(I.add(K.mul(2))),f=p.div(O),D=j(P).add(f);if(f.getBaseValue("number")===0)return D.div(T).getBaseValue("number");let Y=T.add(D);return D.div(Y).getBaseValue("number")}function TP({runeAmount:F,assetAmount:$,runeDepth:N,assetDepth:P}){if(F==="0"||$==="0"||N==="0"||P==="0")return 0;let H=j(N),A=j(P),x=j($),_=j(F),T=x.mul(H).sub(A.mul(_)),Q=A.mul(_).add(H.mul(A));return Math.abs(T.div(Q).getBaseValue("number"))}import{match as w$}from"ts-pattern";function YP({type:F,address:$}){return`${F}:${$}`}function JP({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function MP(F){return FF("POOL+",F)}function XP({chain:F,symbol:$,address:N,...P}){let H=I$({chain:F,symbol:$}),A=N?`:${N}:`:":";return FF(`${"+"}:${H}${A}`,P)}function LP({chain:F,symbol:$,ticker:N,basisPoints:P,targetAsset:H}){let A=F==="ETH"&&N!=="ETH"?`${N}-${$.slice(-3)}`:$,x=H?`:${H}`:"";return`${"-"}:${F}.${A}:${P}${x}`}function jP({basisPoints:F,...$}){return FF(`${"POOL-"}:${F}`,$)}function WP({name:F,chain:$,address:N,owner:P}){let H=`${"~"}:${F}:${$}:${N}`,A=P?`:${P}`:"";return`${H}${A}`}function qP({name:F,chain:$,asset:N,payout:P,owner:H}){return`${"~"}:${F}:${$}:${P}:${H}:${N}`}function VP(F,{address:$}){return`${F}:${$}`}function kP(F,{unstakeBps:$,...N}){let P=$?`:${$}`:"",H=`${F}${P}`;return FF(`${H}`,N)}function FF(F,{affiliateAddress:$,affiliateBasisPoints:N}={}){let P=`${F}${$?`:${$}:${N||0}`:""}`;return P.endsWith(":")?P.slice(0,-1):P}function I$({chain:F,symbol:$}){return w$(F).with("BTC","DOGE","LTC",()=>F.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${F}.${$}`)}function OP(){return typeof window.ethereum<"u"}function DP(F){return K$().includes(F)}function K$(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,N=window?.vultisig,P=window?.ethereum?.isBraveWallet,H=window?.ethereum?.isTrust||window?.trustwallet,A=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,x=window?.bitkeep?.ethereum,_=window?.$onekey?.ethereum,T=[];if(F)T.push("METAMASK");if($)T.push("CTRL");if(N)T.push("VULTISIG");if(P)T.push("BRAVE");if(H)T.push("TRUSTWALLET_WEB");if(A)T.push("COINBASE_WEB");if(g$())T.push("OKX_MOBILE");if(x)T.push("BITGET");if(_)T.push("ONEKEY");return T}async function O$(F,$,N){try{await pF({method:"wallet_switchEthereumChain",params:[{chainId:HF[$]}],provider:F})}catch(P){if(!N)throw new M("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await S$(F,N)}}function SP({chains:F,supportedChains:$,walletType:N}){let P=F.filter((A)=>!A||$.includes(A));if(P.length===0)throw new M("wallet_chain_not_supported",{chain:F.join(", "),wallet:N});let H=F.filter((A)=>!$.includes(A));return E({condition:H.length>0,id:`wallet_chain_not_supported_${N}`,warning:`${N} wallet does not support the following chains: ${H.join(", ")}. These chains will be ignored.`}),P}function D$(F,$,N){return async(...P)=>{if((await $.getNetwork()).chainId.toString()===HF[N])return F(...P);try{await O$($,N)}catch(H){throw new M({errorKey:"helpers_failed_to_switch_network",info:{error:H}})}return F(...P)}}function gP({toolbox:F,chain:$,provider:N=window.ethereum,methodNames:P=[]}){let A=[...P,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,_)=>{if(!F[_])return x;let T=F[_];if(typeof T!=="function")return x;let Q=D$(T,N,$);return{...x,[_]:Q}},{});return{...F,...A}}function S$(F,$){return pF({method:"wallet_addEthereumChain",params:[$],provider:F})}function vP(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function fP(){let{isTrust:F,isBraveWallet:$,__XDEFI:N,overrideIsMetaMask:P,selectedProvider:H}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(P&&H?.isCoinbaseWallet)return"COINBASE_WEB";if(N)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function bP(){let F=[];function $(P){if(F.map((H)=>H.info.uuid).includes(P.detail.info.uuid))return;F.push(P.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function N(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:N}}function g$(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),N=/android|XiaoMi|MiuiBrowser/i.test(F),P=$||N,H=/OKApp/i.test(F);return P&&H}function pF({provider:F,params:$,method:N}){if(!F?.send)throw new M("helpers_not_found_provider");let P=$?Array.isArray($)?$:[$]:[];return F.send(N,P)}export{_N as wrapWithThrow,D$ as wrapMethodWithNetworkSwitch,E as warnOnce,IN as validateTNS,gF as validateIdentifier,QF as updateDerivationPath,O$ as switchEVMWalletNetwork,pF as providerRequest,gP as prepareNetworkSwitch,g$ as okxMobileEnabled,K$ as listWeb3EVMWallets,OP as isWeb3Detected,DF as isGasAsset,DP as isDetected,JN as initializeRPCUrlsWithFallback,rN as getWalletFormatFor,xN as getTHORNameCost,_P as getSymmetricWithdraw,U$ as getSymmetricPoolShare,xF as getRPCUrl,pN as getMinAmountByChain,LP as getMemoForWithdraw,JP as getMemoForUnbond,kP as getMemoForTcyStake,VP as getMemoForTcyClaim,jP as getMemoForRunePoolWithdraw,MP as getMemoForRunePoolDeposit,WP as getMemoForNameRegister,qP as getMemoForNamePreferredAssetRegister,YP as getMemoForLeaveAndBond,XP as getMemoForDeposit,AN as getMAYANameCost,TP as getLiquiditySlippage,W$ as getFeeMultiplierAsBigInt,EF as getFeeMultiplier,$P as getExplorerTxUrl,NP as getExplorerAddressUrl,GP as getEstimatedPoolShare,fP as getETHDefaultWallet,bP as getEIP6963Wallets,tN as getDerivationPathFor,OF as getDecimal,r as getCommonAssetInfo,GN as getChainIdentifier,xP as getAsymmetricRuneWithdrawAmount,V$ as getAsymmetricRuneShare,AP as getAsymmetricAssetWithdrawAmount,k$ as getAsymmetricAssetShare,AF as getAssetType,y as formatBigIntToSafeValue,VN as findAssetBy,SP as filterSupportedChains,q$ as derivationPathToString,_F as assetFromString,oN as applyFeeMultiplierToBigInt,hN as applyFeeMultiplier,S$ as addEVMWalletNetwork,vP as addAccountsChangedCallback,lF as WarningCodeEnum,l as WalletOption,c as UTXOChains,U as SwapKitNumber,M as SwapKitError,b$ as SubstrateChains,YF as StagenetChain,q as SKConfig,s as RequestClient,MF as RPC_URLS,nF as ProviderName,b as NetworkDerivationPath,o as NODE_URLS,qF as MemoType,rF as LedgerErrorCode,sF as FeeTypeEnum,WF as FeeOption,XF as FALLBACK_URLS,cF as ErrorCode,PF as EXPLORER_URLS,k as EVMChains,iN as DerivationPath,j$ as DEFAULT_FEE_MULTIPLIERS,JF as CosmosChains,E$ as CosmosChainPrefixes,hF as ContractAddress,qN as CommonAssetStrings,HF as ChainToHexChainId,y$ as ChainToExplorerUrl,jF as ChainToChainId,v$ as ChainIdToChain,NF as ChainId,L as Chain,f$ as BlockTimes,w as BigIntArithmetics,X as BaseDecimal,u as AssetValue,tF as ApproveMode};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`});let{decimal:b,identifier:S,tax:m}=D||{decimal:q||Z,identifier:H},U=$?i(BigInt(P),$):i(P,b);return A?XF(S,$?U:P):L||Y?IF(S,U):new d({decimal:b,identifier:S,tax:m,value:U})}static async loadStaticAssets(F){let{loadTokenLists:$}=await import("@swapkit/tokens"),A=await $(F);for(let{tokens:R}of Object.values(A))for(let{identifier:P,chain:N,...H}of R){let T=B0(N),G=r.includes(T.chain)?P:P.toUpperCase(),L="decimals"in H?H.decimals:T.baseDecimal;g.set(G,{decimal:L,identifier:P})}return!0}static setStaticAssets(F){g.clear();for(let[$,A]of F.entries()){let R=r.includes(A.chain)?A.identifier:A.identifier.toUpperCase(),P="decimals"in A?A.decimals:A.decimal;g.set($,{...A,decimal:P,identifier:R})}return!0}}function c$(F){let $=d.from({chain:F});return _0(F).with(X.Bitcoin,X.Litecoin,X.BitcoinCash,X.Dash,()=>$.set(0.00010001)).with(X.Dogecoin,()=>$.set(1.00000001)).with(X.Avalanche,X.Ethereum,X.Arbitrum,X.BinanceSmartChain,()=>$.set(0.00000001)).with(X.THORChain,X.Maya,()=>$.set(0)).with(X.Cosmos,X.Kujira,()=>$.set(0.000001)).otherwise(()=>$.set(0.00000001))}async function XF(F,$=0){D0(F);let R=F.includes("SOL.")?F:F.toUpperCase(),P=g.get(R),N=P?.decimal||await K0(T0(F));if(!P)g.set(R,{decimal:N,identifier:F});return new d({decimal:N,identifier:F,value:i($,N)})}function IF(F,$=0){let A=F.includes(".")?F.split(".")?.[0]?.toUpperCase():void 0,R=A?G0.includes(A):!1,P=F.slice(0,14).includes("~")?"~":"/",[N,H]=R?F.split(".").slice(1).join().split(P):F.split(P);if(!(N&&H))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});return new d({decimal:8,identifier:`${A||X.THORChain}.${N}${P}${H}`,value:i($,8)})}function i(F,$){return typeof F==="bigint"?p({bigIntDecimal:$,decimal:$,value:F}):F}function jF(F){let $=_0(F).when((A)=>("chain"in A)&&A.chain!==void 0,({chain:A})=>A).otherwise((A)=>{let R=N0(A.asset);return R.synth?X.THORChain:R.chain});if(!Object.values(X).includes($.toUpperCase()))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function WF(F){if(jF(F),"chain"in F)return F.chain;let{chain:$,symbol:A}=N0(F.asset);return x0({chain:$,symbol:A})==="Native"?$:F.asset}function qF(F,$,A){let R=F.split("."),P=R[0]?.toUpperCase(),N=G0.includes(P),H=A?"~":"/",[T,G=""]=N?R.slice(1).join(".").split(H):F.split(H);if(!(T&&G))throw new J({errorKey:"helpers_invalid_asset_identifier",info:{identifier:F}});let{ticker:L,address:Y}=E0({chain:T,symbol:G}),Z=`${T}${H}${G}`;return{address:Y,chain:P,isGasAsset:!1,isSynthetic:$,isTradeAsset:A,symbol:Z,ticker:L}}function UF(F){let $=F.indexOf("."),A=($===-1?F:F.slice(0,$)).toUpperCase(),R=$===-1?F:F.slice($+1),{address:P,ticker:N}=E0({chain:A,symbol:R}),H;try{H=P&&JF.includes(A)&&v0(P)?v0(P):P}catch(G){H=P}let T=H?`${N}-${H}`:R;return{address:H,chain:A,isGasAsset:w0({chain:A,symbol:R}),isSynthetic:!1,isTradeAsset:!1,symbol:T,ticker:N}}function T0(F){let $=F.slice(0,14),A=$.includes("/"),R=$.includes("~");if(A||R)return qF(F,A,R);return UF(F)}function VF(F,$=!1){let A=$?F.indexOf("-"):F.lastIndexOf("-");if(A===-1)return{address:void 0,ticker:F};let R=F.slice(0,A);return{address:F.slice(A+1),ticker:R}}function E0({symbol:F,chain:$}){let{ticker:A,address:R}=VF(F,$===X.Near);return{address:R&&!r.includes($)?R.toLowerCase():R,ticker:A}}var kF={average:1,fast:1.5,fastest:2};function g0(F="average"){let $=W.get("feeMultipliers");if($&&$[F]!==void 0)return $[F];return kF[F]}function KF(F="average"){let $=g0(F),A=10n,R=BigInt(Math.round($*10));return{denominator:A,numerator:R}}function s$(F,$="average"){let{numerator:A,denominator:R}=KF($);return F*A/R}function t$(F,$="average",A=!1){let R=g0($),P=F*R;return A?Math.floor(P):P}class k extends O{eq(F){return this.eqValue(F)}static fromBigInt(F,$){return new k({decimal:$,value:p({bigIntDecimal:$,decimal:$,value:F})})}}import{Chain as b0,EVMChains as wF}from"@swapkit/types";function L0(F,$){if("index"in $)return[...F.slice(0,F.length-1),$.index];if("change"in $){let[A,R,P,,N]=F;return[A,R,P,$.change,N]}if("account"in $){let[A,R,,P,N]=F;return[A,R,$.account,P,N]}return F}function OF([F,$,A,R,P]){let N=typeof P!=="number";if(typeof R!=="number")return`m/${F}'/${$}'/${A}'`;return`m/${F}'/${$}'/${A}'/${R}${N?"":`/${P}`}`}function $A({chain:F,index:$,addressIndex:A=0,type:R}){if(wF.includes(F)){if(R&&["legacy","account"].includes(R))return[44,60,0,$];if(R==="ledgerLive")return[44,60,$,0,A];return L0(y[F],{index:$})}if(F===b0.Solana){if(R==="account")return[44,501,0,$];return L0(y[F],{index:$})}let P=F===b0.Litecoin?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,P,$,0,A];case"segwit":return[49,P,0,0,$];case"legacy":return[44,P,0,0,$];default:return L0(y[F],{index:$})}}function AA(F){let[$,A,R]=F.split("/").map((P)=>Number.parseInt(P,10));switch(A){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var RA=Object.keys(y).reduce((F,$)=>{return F[$]=OF(y[$]),F},{});import{Chain as M,getChainConfig as f0}from"@swapkit/types";import{match as y0}from"ts-pattern";function HA({chain:F,txHash:$}){let{blockExplorerUrl:A}=f0(F);return y0(F).with(M.Maya,M.Kujira,M.Noble,M.Cosmos,M.THORChain,M.Solana,()=>`${A}/tx/${$.startsWith("0x")?$.slice(2):$}`).with(M.Arbitrum,M.Aurora,M.Avalanche,M.BinanceSmartChain,M.Base,M.Berachain,M.Ethereum,M.Gnosis,M.Optimism,M.Polkadot,M.Polygon,()=>`${A}/tx/${$.startsWith("0x")?$:`0x${$}`}`).with(M.Litecoin,M.Bitcoin,M.BitcoinCash,M.Dogecoin,M.Zcash,M.Radix,()=>`${A}/transaction/${$.toLowerCase()}`).with(M.Near,()=>`${A}/txns/${$}`).with(M.Ripple,()=>`${A}/transactions/${$}`).with(M.Tron,()=>`${A}/#/transaction/${$}`).otherwise(()=>"")}function BA({chain:F,address:$}){let{blockExplorerUrl:A}=f0(F);return y0(F).with(M.Solana,M.Radix,()=>`${A}/account/${$}`).with(M.Tron,()=>`${A}/#/address/${$}`).otherwise(()=>`${A}/address/${$}`)}import{Chain as DF,getChainConfig as SF}from"@swapkit/types";function vF({liquidityUnits:F,poolUnits:$,runeDepth:A}){let R=I(F),P=I($),N=I(A),H=R.mul(N),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=P.mul(P).mul(P);return H.mul(T.sub(G).add(L)).div(Y)}function EF({liquidityUnits:F,poolUnits:$,assetDepth:A}){let R=I(F),P=I($),N=I(A),H=R.mul(N),T=P.mul(P).mul(2),G=P.mul(R).mul(2),L=R.mul(R),Y=H.mul(T.sub(G).add(L)),Z=P.mul(P).mul(P);return Y.div(Z)}function LA({percent:F,runeDepth:$,liquidityUnits:A,poolUnits:R}){return vF({liquidityUnits:A,poolUnits:R,runeDepth:$}).mul(F)}function QA({percent:F,assetDepth:$,liquidityUnits:A,poolUnits:R}){return EF({assetDepth:$,liquidityUnits:A,poolUnits:R}).mul(F)}function I(F){return k.fromBigInt(BigInt(F),SF(DF.THORChain).baseDecimal)}function gF({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R}){return{assetAmount:I(R).mul(F).div($),runeAmount:I(A).mul(F).div($)}}function MA({liquidityUnits:F,poolUnits:$,runeDepth:A,assetDepth:R,percent:P}){return Object.fromEntries(Object.entries(gF({assetDepth:R,liquidityUnits:F,poolUnits:$,runeDepth:A})).map(([N,H])=>[N,H.mul(P)]))}function ZA({runeDepth:F,poolUnits:$,assetDepth:A,liquidityUnits:R,runeAmount:P,assetAmount:N}){let H=new k({decimal:8,value:F}),T=new k({decimal:8,value:A}),G=new k({decimal:8,value:$}),L=new k({decimal:8,value:P}),Y=new k({decimal:8,value:N}),Z=L.mul(T),D=Y.mul(H),q=L.mul(Y),b=H.mul(T),S=G.mul(Z.add(D.add(q.mul(2)))),m=Z.add(D.add(b.mul(2))),U=S.div(m),K=I(R).add(U);if(U.getBaseValue("number")===0)return K.div(G).getBaseValue("number");let z=G.add(K);return K.div(z).getBaseValue("number")}function zA({runeAmount:F,assetAmount:$,runeDepth:A,assetDepth:R}){if(F==="0"||$==="0"||A==="0"||R==="0")return 0;let P=I(A),N=I(R),H=I($),T=I(F),G=H.mul(P).sub(N.mul(T)),L=N.mul(T).add(P.mul(N));return Math.abs(G.div(L).getBaseValue("number"))}import{Chain as a}from"@swapkit/types";import{match as bF}from"ts-pattern";function jA({type:F,address:$}){return`${F}:${$}`}function WA({address:F,unbondAmount:$}){return`${"UNBOND"}:${F}:${$}`}function qA(F){return e("POOL+",F)}function UA({chain:F,symbol:$,address:A,...R}){let P=fF({chain:F,symbol:$}),N=A?`:${A}:`:":";return e(`${"+"}:${P}${N}`,R)}function VA({chain:F,symbol:$,ticker:A,basisPoints:R,targetAsset:P}){let N=F==="ETH"&&A!=="ETH"?`${A}-${$.slice(-3)}`:$,H=P?`:${P}`:"";return`${"-"}:${F}.${N}:${R}${H}`}function kA({basisPoints:F,...$}){return e(`${"POOL-"}:${F}`,$)}function KA({name:F,chain:$,address:A,owner:R}){let P=`${"~"}:${F}:${$}:${A}`,N=R?`:${R}`:"";return`${P}${N}`}function wA({name:F,chain:$,asset:A,payout:R,owner:P}){return`${"~"}:${F}:${$}:${R}:${P}:${A}`}function OA(F,{address:$}){return`${F}:${$}`}function DA(F,{unstakeBps:$,...A}){let R=$?`:${$}`:"",P=`${F}${R}`;return e(`${P}`,A)}function e(F,{affiliateAddress:$,affiliateBasisPoints:A}={}){let R=`${F}${$?`:${$}:${A||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function fF({chain:F,symbol:$}){return bF(F).with(a.Bitcoin,a.Dogecoin,a.Litecoin,()=>F.slice(0,1).toLowerCase()).with(a.BitcoinCash,()=>"c").otherwise(()=>`${F}.${$}`)}import{getChainConfig as u0}from"@swapkit/types";function fA(){return typeof window.ethereum<"u"}function yA(F){return yF().includes(F)}function yF(){let F=window?.ethereum&&!window.ethereum?.isBraveWallet,$=window?.xfi||window?.ethereum?.__XDEFI,A=window?.vultisig,R=window?.ethereum?.isBraveWallet,P=window?.ethereum?.isTrust||window?.trustwallet,N=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,H=window?.bitkeep?.ethereum,T=window?.$onekey?.ethereum,G=[];if(F)G.push("METAMASK");if($)G.push("CTRL");if(A)G.push("VULTISIG");if(R)G.push("BRAVE");if(P)G.push("TRUSTWALLET_WEB");if(N)G.push("COINBASE_WEB");if(mF())G.push("OKX_MOBILE");if(H)G.push("BITGET");if(T)G.push("ONEKEY");return G}async function uF(F,$,A){let R=u0($);try{await p0({method:"wallet_switchEthereumChain",params:[{chainId:R.chainId}],provider:F})}catch(P){if(!A)throw new J("helpers_failed_to_switch_network",{error:P,reason:"networkParams not provided"});await dF(F,A)}}function uA({chains:F,supportedChains:$,walletType:A}){let R=F.filter((N)=>!N||$.includes(N));if(R.length===0)throw new J("wallet_chain_not_supported",{chain:F.join(", "),wallet:A});let P=F.filter((N)=>!$.includes(N));return u({condition:P.length>0,id:`wallet_chain_not_supported_${A}`,warning:`${A} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`}),R}function pF(F,$,A){return async(...R)=>{let{chainIdHex:P}=u0(A);if((await $.getNetwork()).chainId.toString()===P)return F(...R);try{await uF($,A)}catch(N){throw new J({errorKey:"helpers_failed_to_switch_network",info:{error:N}})}return F(...R)}}function pA({toolbox:F,chain:$,provider:A=window.ethereum,methodNames:R=[]}){let N=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((H,T)=>{if(!F[T])return H;let G=F[T];if(typeof G!=="function")return H;let L=pF(G,A,$);return{...H,[T]:L}},{});return{...F,...N}}function dF(F,$){return p0({method:"wallet_addEthereumChain",params:[$],provider:F})}function dA(F){window.ethereum?.on("accountsChanged",()=>F()),window.xfi?.ethereum.on("accountsChanged",()=>F())}function mA(){let{isTrust:F,isBraveWallet:$,__XDEFI:A,overrideIsMetaMask:R,selectedProvider:P}=window?.ethereum||{};if(F)return"TRUSTWALLET_WEB";if($)return"BRAVE";if(R&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(A)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function CA(){let F=[];function $(R){if(F.map((P)=>P.info.uuid).includes(R.detail.info.uuid))return;F.push(R.detail)}window.addEventListener("eip6963:announceProvider",$),window.dispatchEvent(new Event("eip6963:requestProvider"));function A(){window.removeEventListener("eip6963:announceProvider",$)}return{providers:F,removeEIP6963EventListener:A}}function mF(){let F=navigator.userAgent,$=/iphone|ipad|ipod|ios/i.test(F),A=/android|XiaoMi|MiuiBrowser/i.test(F),R=$||A,P=/OKApp/i.test(F);return R&&P}function p0({provider:F,params:$,method:A}){if(!F?.send)throw new J("helpers_not_found_provider");let R=$?Array.isArray($)?$:[$]:[];return F.send(A,R)}export{M$ as wrapWithThrow,pF as wrapMethodWithNetworkSwitch,u as warnOnce,E$ as validateTNS,D0 as validateIdentifier,L0 as updateDerivationPath,uF as switchEVMWalletNetwork,p0 as providerRequest,pA as prepareNetworkSwitch,mF as okxMobileEnabled,yF as listWeb3EVMWallets,fA as isWeb3Detected,w0 as isGasAsset,yA as isDetected,W$ as initializeRPCUrlsWithFallback,AA as getWalletFormatFor,L$ as getTHORNameCost,MA as getSymmetricWithdraw,gF as getSymmetricPoolShare,P0 as getRPCUrl,c$ as getMinAmountByChain,VA as getMemoForWithdraw,WA as getMemoForUnbond,DA as getMemoForTcyStake,OA as getMemoForTcyClaim,kA as getMemoForRunePoolWithdraw,qA as getMemoForRunePoolDeposit,KA as getMemoForNameRegister,wA as getMemoForNamePreferredAssetRegister,jA as getMemoForLeaveAndBond,UA as getMemoForDeposit,Q$ as getMAYANameCost,zA as getLiquiditySlippage,KF as getFeeMultiplierAsBigInt,g0 as getFeeMultiplier,HA as getExplorerTxUrl,BA as getExplorerAddressUrl,ZA as getEstimatedPoolShare,mA as getETHDefaultWallet,CA as getEIP6963Wallets,$A as getDerivationPathFor,K0 as getDecimal,s as getCommonAssetInfo,Z$ as getChainIdentifier,LA as getAsymmetricRuneWithdrawAmount,vF as getAsymmetricRuneShare,QA as getAsymmetricAssetWithdrawAmount,EF as getAsymmetricAssetShare,x0 as getAssetType,p as formatBigIntToSafeValue,O$ as findAssetBy,uA as filterSupportedChains,OF as derivationPathToString,N0 as assetFromString,s$ as applyFeeMultiplierToBigInt,t$ as applyFeeMultiplier,dF as addEVMWalletNetwork,dA as addAccountsChangedCallback,h0 as WarningCodeEnum,c as WalletOption,k as SwapKitNumber,J as SwapKitError,W as SKConfig,l as RequestClient,Z0 as RPC_URLS,l0 as ProviderName,y as NetworkDerivationPath,$0 as NODE_URLS,X0 as MemoType,t0 as LedgerErrorCode,n0 as FeeTypeEnum,J0 as FeeOption,z0 as FALLBACK_URLS,c0 as ErrorCode,Y0 as EXPLORER_URLS,RA as DerivationPath,kF as DEFAULT_FEE_MULTIPLIERS,o0 as ContractAddress,w$ as CommonAssetStrings,O as BigIntArithmetics,d as AssetValue,s0 as ApproveMode};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=B76BB8A6C357BA2B64756E2164756E21
|
|
7
7
|
//# sourceMappingURL=index.js.map
|