@swapkit/helpers 3.0.0-beta.11 → 3.0.0-beta.12
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 +5 -5
- package/dist/api/index.js +2 -2
- package/dist/api/index.js.map +5 -5
- package/dist/{chunk-kr69v1tm.js → chunk-2vqx8ecy.js} +1 -1
- package/dist/{chunk-fr86y3rx.js → chunk-3ts9cha8.js} +1 -1
- package/dist/{chunk-wrjh857m.js → chunk-4edjz16h.js} +1 -1
- package/dist/{chunk-mmwvr2y8.js → chunk-4mz4n5jc.js} +1 -1
- package/dist/{chunk-kdcsgh3q.js → chunk-c4ndre32.js} +1 -1
- package/dist/{chunk-ekd1k975.js → chunk-frkpmajq.js} +1 -1
- package/dist/{chunk-3wnfcm30.js → chunk-ganzk321.js} +1 -1
- package/dist/{chunk-3wnfcm30.js.map → chunk-ganzk321.js.map} +1 -1
- package/dist/{chunk-ahpfxkx0.js → chunk-hbnf5tky.js} +1 -1
- package/dist/{chunk-6vvdbb6s.js → chunk-hk0jx7rp.js} +1 -1
- package/dist/{chunk-dbsrwnw2.js → chunk-k2m9hvag.js} +1 -1
- package/dist/{chunk-wmxwvv8c.js → chunk-mt3sdnfg.js} +1 -1
- package/dist/{chunk-tq87xn7m.js → chunk-prm0g9b0.js} +1 -1
- package/dist/{chunk-q8xy3739.js → chunk-qkreqkaa.js} +1 -1
- package/dist/{chunk-xyczdrny.js → chunk-qpz3c078.js} +1 -1
- package/dist/{chunk-z8emzpyc.js → chunk-zv69dnwn.js} +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +6 -6
- package/dist/index.js +3 -3
- package/dist/index.js.map +6 -6
- package/dist/tokens/index.js +1 -1
- package/package.json +2 -2
- package/src/api/microgard/types.ts +0 -3
- package/src/api/midgard/endpoints.ts +48 -71
- package/src/api/midgard/types.ts +0 -49
- package/src/api/swapkitApi/endpoints.ts +24 -8
- package/src/api/thornode/endpoints.ts +26 -8
- package/src/modules/swapKitConfig.ts +29 -1
- package/src/types/quotes.ts +0 -2
- package/src/types/sdk.ts +0 -2
- package/src/utils/__tests__/memo.test.ts +0 -20
- package/src/utils/memo.ts +0 -31
- /package/dist/{chunk-kr69v1tm.js.map → chunk-2vqx8ecy.js.map} +0 -0
- /package/dist/{chunk-fr86y3rx.js.map → chunk-3ts9cha8.js.map} +0 -0
- /package/dist/{chunk-wrjh857m.js.map → chunk-4edjz16h.js.map} +0 -0
- /package/dist/{chunk-mmwvr2y8.js.map → chunk-4mz4n5jc.js.map} +0 -0
- /package/dist/{chunk-kdcsgh3q.js.map → chunk-c4ndre32.js.map} +0 -0
- /package/dist/{chunk-ekd1k975.js.map → chunk-frkpmajq.js.map} +0 -0
- /package/dist/{chunk-ahpfxkx0.js.map → chunk-hbnf5tky.js.map} +0 -0
- /package/dist/{chunk-6vvdbb6s.js.map → chunk-hk0jx7rp.js.map} +0 -0
- /package/dist/{chunk-dbsrwnw2.js.map → chunk-k2m9hvag.js.map} +0 -0
- /package/dist/{chunk-wmxwvv8c.js.map → chunk-mt3sdnfg.js.map} +0 -0
- /package/dist/{chunk-tq87xn7m.js.map → chunk-prm0g9b0.js.map} +0 -0
- /package/dist/{chunk-q8xy3739.js.map → chunk-qkreqkaa.js.map} +0 -0
- /package/dist/{chunk-xyczdrny.js.map → chunk-qpz3c078.js.map} +0 -0
- /package/dist/{chunk-z8emzpyc.js.map → chunk-zv69dnwn.js.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{o as G,q as X}from"./chunk-3wnfcm30.js";var g;((O)=>{O.Arbitrum="ARB";O.Avalanche="AVAX";O.Base="BASE";O.BinanceSmartChain="BSC";O.Bitcoin="BTC";O.BitcoinCash="BCH";O.Cosmos="GAIA";O.Dash="DASH";O.Dogecoin="DOGE";O.Ethereum="ETH";O.Fiat="FIAT";O.Kujira="KUJI";O.Litecoin="LTC";O.Maya="MAYA";O.Near="NEAR";O.Optimism="OP";O.Polkadot="DOT";O.Chainflip="FLIP";O.Polygon="MATIC";O.Radix="XRD";O.Ripple="XRP";O.THORChain="THOR";O.Solana="SOL"})(g||={});var on;((o)=>{o.THORChain="THOR_STAGENET";o.Maya="MAYA_STAGENET"})(on||={});var v;((H)=>{H.Arbitrum="42161";H.ArbitrumHex="0xa4b1";H.Avalanche="43114";H.AvalancheHex="0xa86a";H.Base="8453";H.BaseHex="0x2105";H.BinanceSmartChain="56";H.BinanceSmartChainHex="0x38";H.Bitcoin="bitcoin";H.BitcoinCash="bitcoincash";H.Chainflip="chainflip";H.Cosmos="cosmoshub-4";H.Dash="dash";H.Dogecoin="dogecoin";H.Kujira="kaiyo-1";H.Ethereum="1";H.EthereumHex="0x1";H.Fiat="fiat";H.Litecoin="litecoin";H.Maya="mayachain-mainnet-v1";H.MayaStagenet="mayachain-stagenet-v1";H.Near="near";H.Optimism="10";H.OptimismHex="0xa";H.Polkadot="polkadot";H.Polygon="137";H.PolygonHex="0x89";H.Radix="radix-mainnet";H.Ripple="ripple";H.THORChain="thorchain-1";H.THORChainStagenet="thorchain-stagenet-v2";H.Solana="solana"})(v||={});var Bh={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR"},Un=Object.keys(g),m=Object.values(g),L={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,XRD:18,XRP:6},Nh={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6},$h=["DOT","FLIP"],V=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Hn=["BTC","BCH","DASH","DOGE","LTC"],Oh=["GAIA","THOR","MAYA","KUJI"],ph={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},Lh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Mh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],a={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-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://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.ankr.com/near",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"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.thorswap.net",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},y={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},Qn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["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"],["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.quickapi.com","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://rpc.ankr.com/eth"],["FIAT"]:[],["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"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["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",y.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Tn={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["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"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},Fn=a,Jn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{id:1,jsonrpc:"2.0",method:"system_health",params:[]};case"SOL":return{id:1,jsonrpc:"2.0",method:"getHealth"};case"XRD":return"";default:throw new Error(`Unsupported chain: ${n}`)}};function zn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var xn=async(n,h)=>{try{let o=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${o}${zn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Jn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},cn=async(n)=>{let h=a[n];if(await xn(n,h))return h;for(let o of Qn[n])if(await xn(n,o))return o;return h},kh=async(n=[...Object.values(g),...Object.values(on)])=>{let h={};await Promise.all(n.map(async(o)=>{let T=await cn(o);h[o]=T})),Fn={...Fn,...h}},_n=m.reduce((n,h)=>{let o=Un.find((T)=>g[T]===h);if(o)n[h]=o;return n},{}),Bn=m.reduce((n,h)=>{return n[h]=v[_n[h]],n},{}),Nn=m.reduce((n,h)=>{let o=`${_n[h]}Hex`;return n[h]=v[o],n},{}),Ih=m.reduce((n,h)=>{return n[h]=Tn[h],n},{});import{match as d}from"ts-pattern";import{createStore as bn}from"zustand/vanilla";var Zn;((B)=>{B.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";B.TC_SUPPORTED_TO_ETH="TC-ERC20";B.TC_SUPPORTED_TO_AVAX="TC-ARC20";B.TC_SUPPORTED_TO_BSC="TC-BEP20";B.ETH_TO_TC_SUPPORTED="ERC20-TC";B.ETH_TO_ETH="ERC20-ERC20";B.ETH_TO_AVAX="ERC20-ARC20";B.ETH_TO_BSC="ERC20-BEP20";B.AVAX_TO_TC_SUPPORTED="ARC20-TC";B.AVAX_TO_ETH="ARC20-ERC20";B.AVAX_TO_AVAX="ARC20-ARC20";B.AVAX_TO_BSC="ARC20-BEP20";B.BSC_TO_TC_SUPPORTED="BEP20-TC";B.BSC_TO_ETH="BEP20-ERC20";B.BSC_TO_AVAX="BEP20-ARC20";B.BSC_TO_BSC="BEP20-BEP20"})(Zn||={});var Gh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Xh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],gh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function Rn(n,h){if("index"in h)return[...n.slice(0,n.length-1),h.index];if("change"in h){let[o,T,R,,A]=n;return[o,T,R,h.change,A]}if("account"in h){let[o,T,,R,A]=n;return[o,T,h.account,R,A]}return n}function $n([n,h,o,T,R]){return`m/${n}'/${h}'/${o}'/${T}${typeof R!=="number"?"":`/${R}`}`}function Uh({chain:n,index:h,addressIndex:o=0,type:T}){if(V.includes(n)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,o];return Rn(u[n],{index:h})}if(n==="SOL"){if(T==="account")return[44,501,0,h];return Rn(u[n],{index:h})}let R=n==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,R,h,0,o];case"segwit":return[49,R,0,0,h];case"legacy":return[44,R,0,0,h];default:return Rn(u[n],{index:h})}}function Qh(n){let[h,o,T]=n.split("/").map((R)=>Number.parseInt(R,10));switch(o){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Yn;((P)=>{P.ARB="0x0000000000000000000000000000000000000000";P.AVAX="0x0000000000000000000000000000000000000000";P.BASE="0x0000000000000000000000000000000000000000";P.ETH="0x0000000000000000000000000000000000000000";P.BSC="0x0000000000000000000000000000000000000000";P.MATIC="0x0000000000000000000000000000000000001010";P.OP="0x4200000000000000000000000000000000000042"})(Yn||={});var u={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},ch=Object.keys(u).reduce((n,h)=>{return n[h]=$n(u[h]),n},{});var Vn;((C)=>{C.unknownError="unknownError";C.test_error="test_error";C.providerDetailsError="providerDetailsError";C.blockHeaderNotFound="blockHeaderNotFound";C.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";C.blockHashNotFoundAtHash="blockHashNotFoundAtHash";C.txHashMissing="txHashMissing";C.assetValueMissingInfo="assetValueMissingInfo";C.invalidAsset="invalidAsset";C.blockIsRequired="blockIsRequired";C.currentBlockHeaderNotFound="currentBlockHeaderNotFound";C.failedToRetrieveBalance="failedToRetrieveBalance";C.failedToRetrieveBlock="failedToRetrieveBlock";C.failedToRetrieveFees="failedToRetrieveFees";C.notImplementedBCH="notImplementedBCH";C.notImplementedDoge="notImplementedDoge";C.noPoolsFound="noPoolsFound";C.noVaultsFound="noVaultsFound";C.noTxFound="noTxFound";C.noInputCoinFound="noInputCoinFound";C.noBlockDataFound="noBlockDataFound";C.multipleCosmosMessages="multipleCosmosMessages";C.heightOrHashNotProvided="heightOrHashNotProvided";C.unknownDenom="unknownDenom";C.invalidBlockHeight="invalidBlockHeight";C.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";C.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";C.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";C.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";C.txMemoUndefined="txMemoUndefined";C.txMemoIncorrect="txMemoIncorrect";C.txTypeNotFound="txTypeNotFound";C.txNoMessage="txNoMessage";C.txNotFound="txNotFound";C.txReceiptNotFound="txReceiptNotFound";C.txParsingError="txParsingError";C.txLogsParsingError="txLogsParsingError";C.blockNotFound="blockNotFound";C.balanceNotFound="balanceNotFound";C.configError="configError";C.synthSwapDisallowed="synthSwapDisallowed";C.providerQuoteTimeout="providerQuoteTimeout";C.noQuoteResponse="noQuoteResponse";C.noPoolAssetsFound="noPoolAssetsFound";C.noThorchainPools="noThorchainPools";C.noMayachainPools="noMayachainPools";C.noThorchainNetworkInfo="noThorchainNetworkInfo";C.invalidAffiliateFee="invalidAffiliateFee";C.invalidBuyAssetAddress="invalidBuyAssetAddress";C.invalidSellAssetAddress="invalidSellAssetAddress";C.invalidSourceAddress="invalidSourceAddress";C.invalidDestinationAddress="invalidDestinationAddress";C.sourceAddressIsSmartContract="sourceAddressIsSmartContract";C.destinationAddressIsSmartContract="destinationAddressIsSmartContract";C.invalidChainId="invalidChainId";C.unsupportedChainId="unsupportedChainId";C.unsupportedEVMChainId="unsupportedEVMChainId";C.unsupportedMethod="unsupportedMethod";C.unsupportedProvider="unsupportedProvider";C.invalidParamsForMethod="invalidParamsForMethod";C.unsupportedAdapter="unsupportedAdapter";C.noWhitelistTokens="noWhitelistTokens";C.failedFetchGasPrice="failedFetchGasPrice";C.failedToCreateDepositChannel="failedToCreateDepositChannel";C.noProviderDetailsFound="noProviderDetailsFound";C.noTokenListsFound="noTokenListsFound";C.tokenNotFound="tokenNotFound";C.tokenPriceNotFound="tokenPriceNotFound";C.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";C.swapAmountTooSmall="swapAmountTooSmall";C.legsArrayIsEmpty="legsArrayIsEmpty";C.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";C.noBlockHeaderFound="noBlockHeaderFound";C.failedToSimulateSwap="failedToSimulateSwap";C.addressScreeningFailed="addressScreeningFailed";C.noLiquidtyProvidersFound="noLiquidtyProvidersFound";C.insufficientLiquidity="insufficientLiquidity";C.noSaversFound="noSaversFound";C.noInboundDataFound="noInbounDataFound";C.noInboundAddressesFound="noInboundAddressesFound";C.noInboundAddressFoundForChain="noInboundAddressFoundForChain";C.noLastBlocksFound="noLastBlocksFound";C.noVersionFound="noVersionFound";C.noConstantsFound="noConstantsFound";C.noMimirsFound="noMimirsFound";C.noRoutesFound="noRoutesFound";C.quoteNotFound="quoteNotFound";C.ledgerSignFailed="ledgerSignFailed";C.ledgerWrongPayload="ledgerWrongPayload";C.ledgerFetchSwapFailed="ledgerFetchSwapFailed";C.failedToFetchTx="failedToFetchTx";C.failedBuildTransactionDetails="failedBuildTransactionDetails";C.noLegsForRoute="noLegsForRoute";C.noRouterAddressFound="noRouterAddressFound";C.noAggregatorAddressFound="noAggregatorAddressFound";C.noContractInstanceFound="noContractInstanceFound";C.noContractAddressFound="noContractAddressFound";C.invalidAffiliate="invalidAffiliate";C.thornameAffiliate="thornameAffiliate";C.providerNotfound="No provider found";C.noRecordFound="No Record found";C.slippageTooLow="Slippage too low";C.tradingHalted="tradingHalted";C.noWrappedGasAsset="noWrappedGasAsset";C.aggregatorAddressNotFound="aggregatorAddressNotFound";C.routerAddressNotFound="routerAddressNotFound";C.dummyAddressNotFound="dummyAddressNotFound";C.trackerError="trackerError";C.thorchainPoolUnavailable="thorchainPoolUnavailable";C.noOhlcvDataFound="noOhlcvDataFound";C.noTradingPairs="noTradingPairs";C.noLoanPositionFound="noLoanPositionFound";C.noLendingAvailability="noLendingAvailability";C.lendingRepayTooSmall="lendingRepayTooSmall";C.missingState="missingState";C.ledgerSwapNotFound="ledgerSwapNotFound";C.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";C.errorEstimatingGas="errorEstimatingGas";C.apiKeyInvalid="apiKeyInvalid";C.apiKeyFailedToUpdate="apiKeyFailedToUpdate";C.apiKeyExpired="apiKeyExpired";C.unauthorized="unauthorized";C.failedToCreateMemo="failedToCreateMemo";C.radixIncorrectInstructions="radixIncorrectInstructions";C.radixTxMissedParam="radixTxMissedParam";C.radixTxMissedAccount="radixTxMissedAccount";C.radixManifestParseError="radixManifestParseError";C.radixManifestBuildError="radixManifestBuildError";C.invalidAddressForChain="invalidAddressForChain";C.riskyAddress="riskyAddress";C.noRoutesToProcess="noRoutesToProcess";C.sellAssetAmountTooSmall="sellAssetAmountTooSmall";C.missingPrivateKey="missingPrivateKey";C.noMemoPriceProtection="noMemoPriceProtection"})(Vn||={});var Wn;((o)=>{o.highSlippage="highSlippage";o.highPriceImpact="highPriceImpact"})(Wn||={});var un;((p)=>{p.CAVIAR_V1="CAVIAR_V1";p.CAMELOT_V3="CAMELOT_V3";p.CHAINFLIP="CHAINFLIP";p.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";p.JUPITER="JUPITER";p.MAYACHAIN="MAYACHAIN";p.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";p.OCISWAP_V1="OCISWAP_V1";p.ONEINCH="ONEINCH";p.OPENOCEAN_V2="OPENOCEAN_V2";p.PANCAKESWAP="PANCAKESWAP";p.PANGOLIN_V1="PANGOLIN_V1";p.SUSHISWAP_V2="SUSHISWAP_V2";p.THORCHAIN="THORCHAIN";p.THORCHAIN_STREAMING="THORCHAIN_STREAMING";p.TRADERJOE_V2="TRADERJOE_V2";p.UNISWAP_V2="UNISWAP_V2";p.UNISWAP_V3="UNISWAP_V3";p.KADO="KADO";p.NEAR="NEAR"})(un||={});var wn;((P)=>{P.LIQUIDITY="liquidity";P.NETWORK="network";P.INBOUND="inbound";P.OUTBOUND="outbound";P.AFFILIATE="affiliate";P.TAX="tax";P.PRIORITY="priority"})(wn||={});var fn;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(fn||={});var qn;((o)=>{o.Approve="approve";o.CheckOnly="checkOnly"})(qn||={});var On;(($)=>{$.NAME_REGISTER="~";$.BOND="BOND";$.DEPOSIT="+";$.LEAVE="LEAVE";$.UNBOND="UNBOND";$.WITHDRAW="-";$.OPEN_LOAN="$+";$.CLOSE_LOAN="$-";$.RUNEPOOL_DEPOSIT="POOL+";$.RUNEPOOL_WITHDRAW="POOL-"})(On||={});var i;((N)=>{N.BITGET="BITGET";N.BRAVE="BRAVE";N.COINBASE_MOBILE="COINBASE_MOBILE";N.COINBASE_WEB="COINBASE_WEB";N.COSMOSTATION="COSMOSTATION";N.CTRL="CTRL";N.EIP6963="EIP6963";N.EXODUS="EXODUS";N.KEEPKEY="KEEPKEY";N.KEEPKEY_BEX="KEEPKEY_BEX";N.KEPLR="KEPLR";N.KEYSTORE="KEYSTORE";N.LEAP="LEAP";N.LEDGER="LEDGER";N.LEDGER_LIVE="LEDGER_LIVE";N.METAMASK="METAMASK";N.OKX="OKX";N.OKX_MOBILE="OKX_MOBILE";N.ONEKEY="ONEKEY";N.PHANTOM="PHANTOM";N.POLKADOT_JS="POLKADOT_JS";N.RADIX_WALLET="RADIX_WALLET";N.TREZOR="TREZOR";N.TALISMAN="TALISMAN";N.TRUSTWALLET_WEB="TRUSTWALLET_WEB";N.WALLETCONNECT="WALLETCONNECT"})(i||={});var Dn;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(Dn||={});var Kn={apis:{},chains:Object.values(g),wallets:Object.values(i),explorerUrls:Tn,nodeUrls:y,rpcUrls:a,apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}}},U=bn((n)=>({...Kn,setApiKey:(h,o)=>n((T)=>({apiKeys:{...T.apiKeys,[h]:o}})),setEnv:(h,o)=>n((T)=>({envs:{...T.envs,[h]:o}})),setExplorerUrl:(h,o)=>n((T)=>({explorerUrls:{...T.explorerUrls,[h]:o}})),setNodeUrl:(h,o)=>n((T)=>({nodeUrls:{...T.nodeUrls,[h]:o}})),setRpcUrl:(h,o)=>n((T)=>({rpcUrls:{...T.rpcUrls,[h]:o}})),setIntegrationConfig:(h,o)=>n((T)=>({integrations:{...T.integrations,[h]:o}})),setConfig:(h)=>n((o)=>({apiKeys:{...o.apiKeys,...h.apiKeys},envs:{...o.envs,...h.envs},explorerUrls:{...o.explorerUrls,...h.explorerUrls},integrations:{...o.integrations,...h.integrations},nodeUrls:{...o.nodeUrls,...h.nodeUrls},rpcUrls:{...o.rpcUrls,...h.rpcUrls},chains:o.chains.concat(h.chains||[]),wallets:o.wallets.concat(h.wallets||[])}))})),Q={getState:U.getState,get:(n)=>U.getState()[n],set:(n)=>U.getState().setConfig(n),setApiKey:(n,h)=>U.getState().setApiKey(n,h),setEnv:(n,h)=>U.getState().setEnv(n,h),setExplorerUrl:(n,h)=>U.getState().setExplorerUrl(n,h),setNodeUrl:(n,h)=>U.getState().setNodeUrl(n,h),setRpcUrl:(n,h)=>U.getState().setRpcUrl(n,h),setIntegrationConfig:(n,h)=>U.getState().setIntegrationConfig(n,h)};var w={get:s("GET"),post:s("POST"),extend:(n)=>({get:s("GET",n),post:s("POST",n),extend:(h)=>w.extend({...n,...h})})};function s(n,h={}){return async(o,T={})=>{let{searchParams:R,json:A,body:F,headers:P}={...h,...T},{swapKit:_}=Q.get("apiKeys"),x=A||o.endsWith(".json"),$=x?JSON.stringify(A):F,I=new URL(o);if(R)I.search=new URLSearchParams(R).toString();let j={...P,...x?{"Content-Type":"application/json"}:{},..._?{"x-api-key":_}:{}};try{let k=await fetch(I.toString(),{...T,method:n,body:$,headers:j});if(!k.ok){let z=await k.text();throw new Error(`${k.statusText}(${k.status}): ${z}`)}let S=await k.json();return T.onSuccess?.(S)||T.responseHandler?.(S)||S}catch(k){return T.onError?.(k)||console.error(k)}}}var ho=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],pn=["ARB","BASE","ETH","OP","MATIC"];async function En({chain:n,to:h}){try{let{result:T}=await w.post(Q.get("rpcUrls")[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(T||L[n]).toString())}catch(T){return console.error(T),L[n]}}async function yn(n){if(n==="XRD")return L.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:o}=await w.post(`${Q.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return o.divisibility.value.divisibility}catch(h){return console.error(h),L["XRD"]}}async function vn({chain:n,symbol:h}){if(V.includes(h))return L[h];let o=h.split("-"),T=o.length===1?void 0:o[o.length-1]?.toLowerCase();return await(T?.startsWith("0x")?En({chain:n,to:T}):L[n])}function Ln({chain:n,symbol:h}){return d(n).with(...V,(o)=>vn({chain:o,symbol:h})).with("XRD",()=>yn(h)).otherwise(()=>L[n])}function oo({chain:n}){return Z.from({chain:n})}function Mn({chain:n,symbol:h}){return d(n).with(...pn,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${n}.${h}`===l(n).identifier).otherwise(()=>h===n)}var l=(n)=>{let h=L[n];return d(n.toUpperCase()).with(...pn,(T)=>({identifier:`${T}.ETH`,decimal:h})).with("THOR",(T)=>({identifier:`${T}.RUNE`,decimal:h})).with("GAIA",(T)=>({identifier:`${T}.ATOM`,decimal:h})).with("MAYA",(T)=>({identifier:`${T}.CACAO`,decimal:10})).with("BSC",(T)=>({identifier:`${T}.BNB`,decimal:h})).with("AVAX",(T)=>({identifier:`${T}.AVAX`,decimal:h})).with(...Hn,"SOL","FLIP","KUJI","XRP","DOT",(T)=>({identifier:`${T}.${T}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",(T)=>({identifier:T,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:L.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:L.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:L.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function Cn({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return d(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===l(n).identifier).with("ARB","OP","BASE",()=>h==="ETH").with("GAIA",()=>h==="ATOM").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("THOR",()=>h==="RUNE").otherwise(()=>h===n)?"Native":n}var r=(n)=>{let[h,...o]=n.split("."),T=n.includes("/"),R=o.join("."),A=R?.split("-"),F=A?.length?A.length===1?A[0]:A.slice(0,-1).join("-"):void 0;return{chain:h,symbol:R,ticker:F,synth:T}};async function To(n){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let o of Object.values(h))for(let{identifier:T,chain:R,...A}of o.tokens){if("identifier"in n&&T===n.identifier)return T;if("address"in A&&"chain"in n&&R===n.chain&&A.address.toLowerCase()===n.contract.toLowerCase())return T}return}var mn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_wallet_connection_failed:10112,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,wallet_exodus_sign_transaction_error:21100,wallet_keystore_invalid_password:29900,wallet_keystore_unsupported_version:29901,wallet_onekey_not_found:21200,wallet_onekey_sign_transaction_error:21201,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_cosmos_validate_address_prefix_not_found:90104,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,toolbox_solana_no_signer:90401,toolbox_solana_fee_estimation_failed:90402,toolbox_ripple_rpc_not_configured:90501,toolbox_ripple_signer_not_found:90502,toolbox_ripple_asset_not_supported:90503,toolbox_ripple_broadcast_error:90504,toolbox_ripple_get_balance_error:90505,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class M extends Error{static ErrorCode=mn;constructor(n,h){let o=typeof n==="string",T=o?n:n.errorKey,R=`${T}${o?"":`: ${JSON.stringify(n.info)}`}`;if(h)console.error(h);console.error(T,{code:M.ErrorCode[T],message:R});super(T);Object.setPrototypeOf(this,M.prototype)}}function Ho(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function _o(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function Bo(n,h){try{return n()}catch(o){if(h)throw new M(h,o);return console.error(o)}}function No(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var kn=new Set;function e(n,h){if(n){if(kn.has(h))return;kn.add(h),console.warn(h)}}async function $o(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=Q.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await w.get(`${h}/status`)).result.node_info.network}catch(h){return n}}import{match as an}from"ts-pattern";var sn=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function In(n){let h=n||sn,o={};for(let T of h){let R=await dn(T);o[T]=R}return o}async function dn(n){let{list:h}=await an(n).with("camelot",()=>import("./chunk-mmwvr2y8.js")).with("caviar",()=>import("./chunk-dbsrwnw2.js")).with("chainflip",()=>import("./chunk-kr69v1tm.js")).with("jupiter",()=>import("./chunk-6vvdbb6s.js")).with("mayachain",()=>import("./chunk-q8xy3739.js")).with("oneinch",()=>import("./chunk-z8emzpyc.js")).with("openocean",()=>import("./chunk-fr86y3rx.js")).with("pancakeswap",()=>import("./chunk-tq87xn7m.js")).with("pangolin",()=>import("./chunk-wmxwvv8c.js")).with("sushiswap",()=>import("./chunk-wrjh857m.js")).with("thorchain",()=>import("./chunk-kdcsgh3q.js")).with("traderjoe",()=>import("./chunk-ekd1k975.js")).with("uniswap",()=>import("./chunk-ahpfxkx0.js")).with("uniswapv3",()=>import("./chunk-xyczdrny.js")).exhaustive();return h}var Sn=["TERRA",...Q.get("chains")];function Gn(n=""){let h=n.toUpperCase(),[o]=h.split(".");if(Sn.includes(o))return!0;let[T]=h.split("/");if(Sn.includes(T))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function Io(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}import{getAddress as gn}from"ethers";var K=8,W=(n)=>10n**BigInt(n),b=(n)=>Math.log10(Number.parseFloat(n.toString()));function f({value:n,bigIntDecimal:h=K,decimal:o=K}){if(o===0)return n.toString();let T=n<0n,R=n.toString().substring(T?1:0),A=o-(R.length-1);if(A>0)R="0".repeat(A)+R;let F=R.length-o,P=R.slice(-o);if(Number.parseInt(P[h]||"0")>=5)P=`${P.substring(0,h-1)}${(Number.parseInt(P[h-1]||"0")+1).toString()}`;else P=P.substring(0,h);return`${T?"-":""}${R.slice(0,F)}.${P}`.replace(/\.?0*$/,"")}class Y{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new Y({decimal:h,value:f({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:o}){return Y.fromBigInt(n.getBaseValue("bigint")*W(o)/W(h),o)}constructor(n){let h=An(n),o=typeof n==="object";this.decimal=o?n.decimal:void 0,this.decimalMultiplier=o&&"decimalMultiplier"in n?n.decimalMultiplier:W(Math.max(Xn(nn(h)),this.decimal||0)),this.#R(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let o=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||b(this.decimalMultiplier));switch(n){case"number":return Number(o);case"string":return o;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return o}}getBaseValue(n,h){let o=this.decimalMultiplier/W(h||this.decimal||L.THOR),T=this.bigIntValue/o;switch(n){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let o=An(n),T=nn(o);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",R=o||"";if((Number.parseInt(T)?T.length+R.length:R.length)<=n)return this.getValue("string");if(T.length>=n)return T.slice(0,n).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${R.slice(0,n-T.length)}`.padEnd(n-T.length,"0");let F=Number.parseInt(R),P=`${F}`.slice(0,n);return`0.${P.padStart(R.length-`${F}`.length+P.length,"0")}`}toFixed(n=6){let[h,o]=this.getValue("string").split("."),T=h||"",R=o||"";if(Number.parseInt(T))return`${T}.${R.slice(0,n)}`.padEnd(n,"0");let A=Number.parseInt(R),F=`${A}`.slice(0,n);return`0.${F.padStart(R.length-`${A}`.length+F.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),o=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),R=o[T];if(!R)return this.getValue("string");let A=10**(T*3);return`${(h/A).toFixed(n)}${R}`}toCurrency(n="$",{currencyPosition:h="start",decimal:o=2,decimalSeparator:T=".",thousandSeparator:R=","}={}){let A=this.getValue("number"),[F="",P=""]=A.toFixed(6).split("."),_=F.replace(/\B(?=(\d{3})+(?!\d))/g,R),x=F||P?F==="0"?`${Number.parseFloat(`0.${P}`)}`.replace(".",T):`${_}${Number.parseInt(P)?`${T}${P.slice(0,o)}`:""}`:"0.00";return`${h==="start"?n:""}${x}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let o=h||this.decimal||K,T=Math.max(o,b(this.decimalMultiplier)),R=n<0n,A=n.toString().substring(R?1:0),F=T-(A.length-1),P=F>0?"0".repeat(F)+A:A,_=P.length-T,x=P.slice(-T);if(Number.parseInt(x[o]||"0")>=5)x=`${x.substring(0,o-1)}${(Number.parseInt(x[o-1]||"0")+1).toString()}`;else x=x.substring(0,o);return`${R?"-":""}${P.slice(0,_)}.${x}`.replace(/\.?0*$/,"")}#h(n,...h){let o=this.#o(this,...h),T=Math.max(o,b(this.decimalMultiplier)),R=W(T),A=h.reduce((P,_)=>{let x=this.getBigIntValue(_,T);switch(n){case"add":return P+x;case"sub":return P-x;case"mul":return P*x/R;case"div":{if(x===0n)throw new RangeError("Division by zero");return P*R/x}default:return P}},this.bigIntValue*R/this.decimalMultiplier),F=f({bigIntDecimal:T,decimal:T,value:A});return new this.constructor({decimalMultiplier:W(T),decimal:this.decimal,value:F,identifier:this.toString()})}#n(n,...h){let o=this.#o(this,...h),T=this.getBigIntValue(h[0]||"0",o),R=this.getBigIntValue(this,o);switch(n){case"gt":return R>T;case"gte":return R>=T;case"lt":return R<T;case"lte":return R<=T;case"eqValue":return R===T;default:return!1}}#R(n){let h=nn(n)||"0";this.bigIntValue=this.#T(h)}#o(...n){let h=n.map((o)=>{return typeof o==="object"?o.decimal||b(o.decimalMultiplier):Xn(nn(o))}).filter(Boolean);return Math.max(...h,K)}#T(n,h){let o=h?W(h):this.decimalMultiplier,T=b(o),[R="",A=""]=n.split(".");return BigInt(`${R}${A.padEnd(T,"0")}`)}}var ln=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(n){let o=`${typeof n==="number"?ln.format(n):An(n)}`.replaceAll(",",".").split(".");return o.length>1?`${o.slice(0,-1).join("")}.${o.at(-1)}`:o[0]||"0"}function Xn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,K)}function An(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var q=new Map;class Z extends Y{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:o,chain:T,symbol:R,identifier:A}){super(typeof n==="object"?n:{decimal:h,value:n});let F=Pn(A||`${T}.${R}`);this.type=Cn(F),this.tax=o,this.chain=F.chain,this.ticker=F.ticker,this.symbol=F.symbol,this.address=F.address,this.isSynthetic=F.isSynthetic,this.isTradeAsset=F.isTradeAsset,this.isGasAsset=F.isGasAsset,this.chainId=Bn[F.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[o,T,R]=n.split(".");if(!(o&&T))throw new M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let A=o==="THOR"&&R?`${o}.${T}/${R}`:n;return Z.from({asset:A,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:o,...T}){let R=n instanceof Y?n.getValue("string"):n,A=hh(T),{identifier:F,decimal:P}=l(A),{chain:_,isSynthetic:x,isTradeAsset:$}=Pn(F),I=q.get(_==="SOL"?F:F.toUpperCase()),j=I?.decimal||P;e(!(o||j),`Couldn't find static decimal for one or more tokens on ${_} (Using default ${L[_]} decimal as fallback).
|
|
1
|
+
import{o as G,q as X}from"./chunk-ganzk321.js";var S;((O)=>{O.Arbitrum="ARB";O.Avalanche="AVAX";O.Base="BASE";O.BinanceSmartChain="BSC";O.Bitcoin="BTC";O.BitcoinCash="BCH";O.Cosmos="GAIA";O.Dash="DASH";O.Dogecoin="DOGE";O.Ethereum="ETH";O.Fiat="FIAT";O.Kujira="KUJI";O.Litecoin="LTC";O.Maya="MAYA";O.Near="NEAR";O.Optimism="OP";O.Polkadot="DOT";O.Chainflip="FLIP";O.Polygon="MATIC";O.Radix="XRD";O.Ripple="XRP";O.THORChain="THOR";O.Solana="SOL"})(S||={});var y;((T)=>{T.THORChain="THOR_STAGENET";T.Maya="MAYA_STAGENET"})(y||={});var v;((_)=>{_.Arbitrum="42161";_.ArbitrumHex="0xa4b1";_.Avalanche="43114";_.AvalancheHex="0xa86a";_.Base="8453";_.BaseHex="0x2105";_.BinanceSmartChain="56";_.BinanceSmartChainHex="0x38";_.Bitcoin="bitcoin";_.BitcoinCash="bitcoincash";_.Chainflip="chainflip";_.Cosmos="cosmoshub-4";_.Dash="dash";_.Dogecoin="dogecoin";_.Kujira="kaiyo-1";_.Ethereum="1";_.EthereumHex="0x1";_.Fiat="fiat";_.Litecoin="litecoin";_.Maya="mayachain-mainnet-v1";_.MayaStagenet="mayachain-stagenet-v1";_.Near="near";_.Optimism="10";_.OptimismHex="0xa";_.Polkadot="polkadot";_.Polygon="137";_.PolygonHex="0x89";_.Radix="radix-mainnet";_.Ripple="ripple";_.THORChain="thorchain-1";_.THORChainStagenet="thorchain-stagenet-v2";_.Solana="solana"})(v||={});var Bh={["0xa4b1"]:"ARB",["42161"]:"ARB",["0xa86a"]:"AVAX",["43114"]:"AVAX",["0x2105"]:"BASE",["8453"]:"BASE",["0x38"]:"BSC",["56"]:"BSC",["bitcoincash"]:"BCH",["bitcoin"]:"BTC",["chainflip"]:"FLIP",["cosmoshub-4"]:"GAIA",["dash"]:"DASH",["dogecoin"]:"DOGE",["0x1"]:"ETH",["1"]:"ETH",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["near"]:"NEAR",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["ripple"]:"XRP",["solana"]:"SOL",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR"},gn=Object.keys(S),m=Object.values(S),$={ARB:18,AVAX:18,BASE:18,BCH:8,BSC:18,BTC:8,DASH:8,DOGE:8,DOT:10,ETH:18,FIAT:2,FLIP:18,GAIA:6,KUJI:6,LTC:8,MATIC:18,MAYA:8,NEAR:24,OP:18,SOL:9,THOR:8,XRD:18,XRP:6},Nh={["ARB"]:0.3,["AVAX"]:3,["BASE"]:2,["BSC"]:3,["BTC"]:600,["BCH"]:600,["FLIP"]:5,["GAIA"]:2,["DASH"]:150,["DOGE"]:600,["ETH"]:12.5,["FIAT"]:60,["KUJI"]:2.2,["LTC"]:150,["MAYA"]:6,["NEAR"]:1,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["XRP"]:5,["SOL"]:0.4,["THOR"]:6},Oh=["DOT","FLIP"],c=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Hn=["BTC","BCH","DASH","DOGE","LTC"],ph=["GAIA","THOR","MAYA","KUJI"],$h={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},Mh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Lh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],a={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://api.avax.network/ext/bc/C/rpc",["BASE"]:"https://base-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://node-router.thorswap.net/cosmos/rpc",["DASH"]:"https://dash-rpc.publicnode.com",["DOGE"]:"https://node-router.thorswap.net/dogecoin",["ETH"]:"https://ethereum-rpc.publicnode.com",["FIAT"]:"",["KUJI"]:"https://kujira-rpc.ibs.team",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["NEAR"]:"https://rpc.ankr.com/near",["OP"]:"https://mainnet.optimism.io",["DOT"]:"wss://rpc.polkadot.io",["MATIC"]:"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.thorswap.net",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},E={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},Jn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["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"],["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.quickapi.com","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://rpc.ankr.com/eth"],["FIAT"]:[],["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"],["OP"]:["https://optimism.llamarpc.com","https://1rpc.io/op"],["DOT"]:["wss://polkadot-rpc.dwellir.com","wss://polkadot.api.onfinality.io/public-ws"],["MATIC"]:["https://polygon.llamarpc.com","https://rpc.ankr.com/polygon"],["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",E.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Tn={["ARB"]:"https://arbiscan.io",["AVAX"]:"https://snowtrace.io",["BASE"]:"https://basescan.org",["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"]:"",["KUJI"]:"https://finder.kujira.network/kaiyo-1",["LTC"]:"https://blockchair.com/litecoin",["MAYA"]:"https://www.mayascan.org",["NEAR"]:"https://nearblocks.io",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["XRP"]:"https://livenet.xrpl.org/",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},xn=a,zn=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]};case"GAIA":case"KUJI":case"MAYA":case"THOR":case"MAYA_STAGENET":case"THOR_STAGENET":return{id:1,jsonrpc:"2.0",method:"status",params:{}};case"DOT":return{id:1,jsonrpc:"2.0",method:"system_health",params:[]};case"SOL":return{id:1,jsonrpc:"2.0",method:"getHealth"};case"XRD":return"";default:throw new Error(`Unsupported chain: ${n}`)}};function Zn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var Fn=async(n,h)=>{try{let T=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${T}${Zn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(zn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Yn=async(n)=>{let h=a[n];if(await Fn(n,h))return h;for(let T of Jn[n])if(await Fn(n,T))return T;return h},kh=async(n=[...Object.values(S),...Object.values(y)])=>{let h={};await Promise.all(n.map(async(T)=>{let R=await Yn(T);h[T]=R})),xn={...xn,...h}},_n=m.reduce((n,h)=>{let T=gn.find((R)=>S[R]===h);if(T)n[h]=T;return n},{}),Bn=m.reduce((n,h)=>{return n[h]=v[_n[h]],n},{}),Nn=m.reduce((n,h)=>{let T=`${_n[h]}Hex`;return n[h]=v[T],n},{}),Ih=m.reduce((n,h)=>{return n[h]=Tn[h],n},{});import{match as s}from"ts-pattern";import{createStore as bn}from"zustand/vanilla";var Vn;((B)=>{B.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";B.TC_SUPPORTED_TO_ETH="TC-ERC20";B.TC_SUPPORTED_TO_AVAX="TC-ARC20";B.TC_SUPPORTED_TO_BSC="TC-BEP20";B.ETH_TO_TC_SUPPORTED="ERC20-TC";B.ETH_TO_ETH="ERC20-ERC20";B.ETH_TO_AVAX="ERC20-ARC20";B.ETH_TO_BSC="ERC20-BEP20";B.AVAX_TO_TC_SUPPORTED="ARC20-TC";B.AVAX_TO_ETH="ARC20-ERC20";B.AVAX_TO_AVAX="ARC20-ARC20";B.AVAX_TO_BSC="ARC20-BEP20";B.BSC_TO_TC_SUPPORTED="BEP20-TC";B.BSC_TO_ETH="BEP20-ERC20";B.BSC_TO_AVAX="BEP20-ARC20";B.BSC_TO_BSC="BEP20-BEP20"})(Vn||={});var Xh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],jh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Sh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function Rn(n,h){if("index"in h)return[...n.slice(0,n.length-1),h.index];if("change"in h){let[T,R,C,,P]=n;return[T,R,C,h.change,P]}if("account"in h){let[T,R,,C,P]=n;return[T,R,h.account,C,P]}return n}function On([n,h,T,R,C]){return`m/${n}'/${h}'/${T}'/${R}${typeof C!=="number"?"":`/${C}`}`}function gh({chain:n,index:h,addressIndex:T=0,type:R}){if(c.includes(n)){if(R&&["legacy","account"].includes(R))return[44,60,0,h];if(R==="ledgerLive")return[44,60,h,0,T];return Rn(w[n],{index:h})}if(n==="SOL"){if(R==="account")return[44,501,0,h];return Rn(w[n],{index:h})}let C=n==="LTC"?2:0;switch(R){case"nativeSegwitMiddleAccount":return[84,C,h,0,T];case"segwit":return[49,C,0,0,h];case"legacy":return[44,C,0,0,h];default:return Rn(w[n],{index:h})}}function Jh(n){let[h,T,R]=n.split("/").map((C)=>Number.parseInt(C,10));switch(T){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var Wn;((o)=>{o.ARB="0x0000000000000000000000000000000000000000";o.AVAX="0x0000000000000000000000000000000000000000";o.BASE="0x0000000000000000000000000000000000000000";o.ETH="0x0000000000000000000000000000000000000000";o.BSC="0x0000000000000000000000000000000000000000";o.MATIC="0x0000000000000000000000000000000000001010";o.OP="0x4200000000000000000000000000000000000042"})(Wn||={});var w={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,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],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],NEAR:[44,397,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],DOT:[0,0,0,0,0],FIAT:[0,0,0,0,0],FLIP:[0,0,0,0,0],XRD:[0,0,0,0,0],XRP:[44,144,0,0,0]},Yh=Object.keys(w).reduce((n,h)=>{return n[h]=On(w[h]),n},{});var cn;((A)=>{A.unknownError="unknownError";A.test_error="test_error";A.providerDetailsError="providerDetailsError";A.blockHeaderNotFound="blockHeaderNotFound";A.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";A.blockHashNotFoundAtHash="blockHashNotFoundAtHash";A.txHashMissing="txHashMissing";A.assetValueMissingInfo="assetValueMissingInfo";A.invalidAsset="invalidAsset";A.blockIsRequired="blockIsRequired";A.currentBlockHeaderNotFound="currentBlockHeaderNotFound";A.failedToRetrieveBalance="failedToRetrieveBalance";A.failedToRetrieveBlock="failedToRetrieveBlock";A.failedToRetrieveFees="failedToRetrieveFees";A.notImplementedBCH="notImplementedBCH";A.notImplementedDoge="notImplementedDoge";A.noPoolsFound="noPoolsFound";A.noVaultsFound="noVaultsFound";A.noTxFound="noTxFound";A.noInputCoinFound="noInputCoinFound";A.noBlockDataFound="noBlockDataFound";A.multipleCosmosMessages="multipleCosmosMessages";A.heightOrHashNotProvided="heightOrHashNotProvided";A.unknownDenom="unknownDenom";A.invalidBlockHeight="invalidBlockHeight";A.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";A.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";A.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";A.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";A.txMemoUndefined="txMemoUndefined";A.txMemoIncorrect="txMemoIncorrect";A.txTypeNotFound="txTypeNotFound";A.txNoMessage="txNoMessage";A.txNotFound="txNotFound";A.txReceiptNotFound="txReceiptNotFound";A.txParsingError="txParsingError";A.txLogsParsingError="txLogsParsingError";A.blockNotFound="blockNotFound";A.balanceNotFound="balanceNotFound";A.configError="configError";A.synthSwapDisallowed="synthSwapDisallowed";A.providerQuoteTimeout="providerQuoteTimeout";A.noQuoteResponse="noQuoteResponse";A.noPoolAssetsFound="noPoolAssetsFound";A.noThorchainPools="noThorchainPools";A.noMayachainPools="noMayachainPools";A.noThorchainNetworkInfo="noThorchainNetworkInfo";A.invalidAffiliateFee="invalidAffiliateFee";A.invalidBuyAssetAddress="invalidBuyAssetAddress";A.invalidSellAssetAddress="invalidSellAssetAddress";A.invalidSourceAddress="invalidSourceAddress";A.invalidDestinationAddress="invalidDestinationAddress";A.sourceAddressIsSmartContract="sourceAddressIsSmartContract";A.destinationAddressIsSmartContract="destinationAddressIsSmartContract";A.invalidChainId="invalidChainId";A.unsupportedChainId="unsupportedChainId";A.unsupportedEVMChainId="unsupportedEVMChainId";A.unsupportedMethod="unsupportedMethod";A.unsupportedProvider="unsupportedProvider";A.invalidParamsForMethod="invalidParamsForMethod";A.unsupportedAdapter="unsupportedAdapter";A.noWhitelistTokens="noWhitelistTokens";A.failedFetchGasPrice="failedFetchGasPrice";A.failedToCreateDepositChannel="failedToCreateDepositChannel";A.noProviderDetailsFound="noProviderDetailsFound";A.noTokenListsFound="noTokenListsFound";A.tokenNotFound="tokenNotFound";A.tokenPriceNotFound="tokenPriceNotFound";A.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";A.swapAmountTooSmall="swapAmountTooSmall";A.legsArrayIsEmpty="legsArrayIsEmpty";A.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";A.noBlockHeaderFound="noBlockHeaderFound";A.failedToSimulateSwap="failedToSimulateSwap";A.addressScreeningFailed="addressScreeningFailed";A.noLiquidtyProvidersFound="noLiquidtyProvidersFound";A.insufficientLiquidity="insufficientLiquidity";A.noInboundDataFound="noInbounDataFound";A.noInboundAddressesFound="noInboundAddressesFound";A.noInboundAddressFoundForChain="noInboundAddressFoundForChain";A.noLastBlocksFound="noLastBlocksFound";A.noVersionFound="noVersionFound";A.noConstantsFound="noConstantsFound";A.noMimirsFound="noMimirsFound";A.noRoutesFound="noRoutesFound";A.quoteNotFound="quoteNotFound";A.ledgerSignFailed="ledgerSignFailed";A.ledgerWrongPayload="ledgerWrongPayload";A.ledgerFetchSwapFailed="ledgerFetchSwapFailed";A.failedToFetchTx="failedToFetchTx";A.failedBuildTransactionDetails="failedBuildTransactionDetails";A.noLegsForRoute="noLegsForRoute";A.noRouterAddressFound="noRouterAddressFound";A.noAggregatorAddressFound="noAggregatorAddressFound";A.noContractInstanceFound="noContractInstanceFound";A.noContractAddressFound="noContractAddressFound";A.invalidAffiliate="invalidAffiliate";A.thornameAffiliate="thornameAffiliate";A.providerNotfound="No provider found";A.noRecordFound="No Record found";A.slippageTooLow="Slippage too low";A.tradingHalted="tradingHalted";A.noWrappedGasAsset="noWrappedGasAsset";A.aggregatorAddressNotFound="aggregatorAddressNotFound";A.routerAddressNotFound="routerAddressNotFound";A.dummyAddressNotFound="dummyAddressNotFound";A.trackerError="trackerError";A.thorchainPoolUnavailable="thorchainPoolUnavailable";A.noOhlcvDataFound="noOhlcvDataFound";A.noTradingPairs="noTradingPairs";A.noLendingAvailability="noLendingAvailability";A.lendingRepayTooSmall="lendingRepayTooSmall";A.missingState="missingState";A.ledgerSwapNotFound="ledgerSwapNotFound";A.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";A.errorEstimatingGas="errorEstimatingGas";A.apiKeyInvalid="apiKeyInvalid";A.apiKeyFailedToUpdate="apiKeyFailedToUpdate";A.apiKeyExpired="apiKeyExpired";A.unauthorized="unauthorized";A.failedToCreateMemo="failedToCreateMemo";A.radixIncorrectInstructions="radixIncorrectInstructions";A.radixTxMissedParam="radixTxMissedParam";A.radixTxMissedAccount="radixTxMissedAccount";A.radixManifestParseError="radixManifestParseError";A.radixManifestBuildError="radixManifestBuildError";A.invalidAddressForChain="invalidAddressForChain";A.riskyAddress="riskyAddress";A.noRoutesToProcess="noRoutesToProcess";A.sellAssetAmountTooSmall="sellAssetAmountTooSmall";A.missingPrivateKey="missingPrivateKey";A.noMemoPriceProtection="noMemoPriceProtection"})(cn||={});var qn;((T)=>{T.highSlippage="highSlippage";T.highPriceImpact="highPriceImpact"})(qn||={});var wn;((p)=>{p.CAVIAR_V1="CAVIAR_V1";p.CAMELOT_V3="CAMELOT_V3";p.CHAINFLIP="CHAINFLIP";p.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";p.JUPITER="JUPITER";p.MAYACHAIN="MAYACHAIN";p.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";p.OCISWAP_V1="OCISWAP_V1";p.ONEINCH="ONEINCH";p.OPENOCEAN_V2="OPENOCEAN_V2";p.PANCAKESWAP="PANCAKESWAP";p.PANGOLIN_V1="PANGOLIN_V1";p.SUSHISWAP_V2="SUSHISWAP_V2";p.THORCHAIN="THORCHAIN";p.THORCHAIN_STREAMING="THORCHAIN_STREAMING";p.TRADERJOE_V2="TRADERJOE_V2";p.UNISWAP_V2="UNISWAP_V2";p.UNISWAP_V3="UNISWAP_V3";p.KADO="KADO";p.NEAR="NEAR"})(wn||={});var tn;((o)=>{o.LIQUIDITY="liquidity";o.NETWORK="network";o.INBOUND="inbound";o.OUTBOUND="outbound";o.AFFILIATE="affiliate";o.TAX="tax";o.PRIORITY="priority"})(tn||={});var fn;((R)=>{R.Average="average";R.Fast="fast";R.Fastest="fastest"})(fn||={});var un;((T)=>{T.Approve="approve";T.CheckOnly="checkOnly"})(un||={});var pn;((F)=>{F.NAME_REGISTER="~";F.BOND="BOND";F.DEPOSIT="+";F.LEAVE="LEAVE";F.UNBOND="UNBOND";F.WITHDRAW="-";F.RUNEPOOL_DEPOSIT="POOL+";F.RUNEPOOL_WITHDRAW="POOL-"})(pn||={});var d;((N)=>{N.BITGET="BITGET";N.BRAVE="BRAVE";N.COINBASE_MOBILE="COINBASE_MOBILE";N.COINBASE_WEB="COINBASE_WEB";N.COSMOSTATION="COSMOSTATION";N.CTRL="CTRL";N.EIP6963="EIP6963";N.EXODUS="EXODUS";N.KEEPKEY="KEEPKEY";N.KEEPKEY_BEX="KEEPKEY_BEX";N.KEPLR="KEPLR";N.KEYSTORE="KEYSTORE";N.LEAP="LEAP";N.LEDGER="LEDGER";N.LEDGER_LIVE="LEDGER_LIVE";N.METAMASK="METAMASK";N.OKX="OKX";N.OKX_MOBILE="OKX_MOBILE";N.ONEKEY="ONEKEY";N.PHANTOM="PHANTOM";N.POLKADOT_JS="POLKADOT_JS";N.RADIX_WALLET="RADIX_WALLET";N.TREZOR="TREZOR";N.TALISMAN="TALISMAN";N.TRUSTWALLET_WEB="TRUSTWALLET_WEB";N.WALLETCONNECT="WALLETCONNECT"})(d||={});var Dn;((R)=>{R[R.NoError=36864]="NoError";R[R.LockedDevice=21781]="LockedDevice";R[R.TC_NotFound=65535]="TC_NotFound"})(Dn||={});var Kn={apis:{},chains:Object.values(S),wallets:Object.values(d),explorerUrls:Tn,nodeUrls:E,rpcUrls:a,midgardUrls:{THOR:"https://midgard.ninerealms.com",MAYA:"https://midgard.mayachain.info",THOR_STAGENET:"https://stagenet-midgard.ninerealms.com",MAYA_STAGENET:"https://stagenet-midgard.mayachain.info"},apiHeaders:{},apiKeys:{blockchair:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}}},Q=bn((n)=>({...Kn,setApiKey:(h,T)=>n((R)=>({apiKeys:{...R.apiKeys,[h]:T}})),setApiHeaders:(h,T)=>n((R)=>({apiHeaders:{...R.apiHeaders,[h]:T}})),setEnv:(h,T)=>n((R)=>({envs:{...R.envs,[h]:T}})),setExplorerUrl:(h,T)=>n((R)=>({explorerUrls:{...R.explorerUrls,[h]:T}})),setMidgardUrl:(h,T)=>n((R)=>({midgardUrls:{...R.midgardUrls,[h]:T}})),setNodeUrl:(h,T)=>n((R)=>({nodeUrls:{...R.nodeUrls,[h]:T}})),setRpcUrl:(h,T)=>n((R)=>({rpcUrls:{...R.rpcUrls,[h]:T}})),setIntegrationConfig:(h,T)=>n((R)=>({integrations:{...R.integrations,[h]:T}})),setConfig:(h)=>n((T)=>({apiKeys:{...T.apiKeys,...h.apiKeys},apiHeaders:{...T.apiHeaders,...h.apiHeaders},envs:{...T.envs,...h.envs},explorerUrls:{...T.explorerUrls,...h.explorerUrls},integrations:{...T.integrations,...h.integrations},midgardUrls:{...T.midgardUrls,...h.midgardUrls},nodeUrls:{...T.nodeUrls,...h.nodeUrls},rpcUrls:{...T.rpcUrls,...h.rpcUrls},chains:T.chains.concat(h.chains||[]),wallets:T.wallets.concat(h.wallets||[])}))})),J={getState:Q.getState,get:(n)=>Q.getState()[n],set:(n)=>Q.getState().setConfig(n),setApiKey:(n,h)=>Q.getState().setApiKey(n,h),setApiHeaders:(n,h)=>Q.getState().setApiHeaders(n,h),setEnv:(n,h)=>Q.getState().setEnv(n,h),setExplorerUrl:(n,h)=>Q.getState().setExplorerUrl(n,h),setMidgardUrl:(n,h)=>Q.getState().setMidgardUrl(n,h),setNodeUrl:(n,h)=>Q.getState().setNodeUrl(n,h),setRpcUrl:(n,h)=>Q.getState().setRpcUrl(n,h),setIntegrationConfig:(n,h)=>Q.getState().setIntegrationConfig(n,h)};var t={get:i("GET"),post:i("POST"),extend:(n)=>({get:i("GET",n),post:i("POST",n),extend:(h)=>t.extend({...n,...h})})};function i(n,h={}){return async(T,R={})=>{let{searchParams:C,json:P,body:x,headers:o}={...h,...R},{swapKit:F}=J.get("apiKeys"),H=P||T.endsWith(".json"),j=H?JSON.stringify(P):x,k=new URL(T);if(C)k.search=new URLSearchParams(C).toString();let g={...o,...H?{"Content-Type":"application/json"}:{},...F?{"x-api-key":F}:{}};try{let L=await fetch(k.toString(),{...R,method:n,body:j,headers:g});if(!L.ok){let Z=await L.text();throw new Error(`${L.statusText}(${L.status}): ${Z}`)}let I=await L.json();return R.onSuccess?.(I)||R.responseHandler?.(I)||I}catch(L){return R.onError?.(L)||console.error(L)}}}var hT=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],$n=["ARB","BASE","ETH","OP","MATIC"];async function En({chain:n,to:h}){try{let{result:R}=await t.post(J.get("rpcUrls")[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:h.toLowerCase(),data:"0x313ce567"},"latest"]})});return Number.parseInt(BigInt(R||$[n]).toString())}catch(R){return console.error(R),$[n]}}async function yn(n){if(n==="XRD")return $.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:T}=await t.post(`${J.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return T.divisibility.value.divisibility}catch(h){return console.error(h),$["XRD"]}}async function vn({chain:n,symbol:h}){if(c.includes(h))return $[h];let T=h.split("-"),R=T.length===1?void 0:T[T.length-1]?.toLowerCase();return await(R?.startsWith("0x")?En({chain:n,to:R}):$[n])}function Mn({chain:n,symbol:h}){return s(n).with(...c,(T)=>vn({chain:T,symbol:h})).with("XRD",()=>yn(h)).otherwise(()=>$[n])}function TT({chain:n}){return V.from({chain:n})}function Ln({chain:n,symbol:h}){return s(n).with(...$n,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${n}.${h}`===l(n).identifier).otherwise(()=>h===n)}var l=(n)=>{let h=$[n];return s(n.toUpperCase()).with(...$n,(R)=>({identifier:`${R}.ETH`,decimal:h})).with("THOR",(R)=>({identifier:`${R}.RUNE`,decimal:h})).with("GAIA",(R)=>({identifier:`${R}.ATOM`,decimal:h})).with("MAYA",(R)=>({identifier:`${R}.CACAO`,decimal:10})).with("BSC",(R)=>({identifier:`${R}.BNB`,decimal:h})).with("AVAX",(R)=>({identifier:`${R}.AVAX`,decimal:h})).with(...Hn,"SOL","FLIP","KUJI","XRP","DOT",(R)=>({identifier:`${R}.${R}`,decimal:h})).with("XRD","XRD.XRD",()=>({identifier:"XRD.XRD",decimal:h})).with("KUJI.USK",(R)=>({identifier:R,decimal:6})).with("ETH.FLIP",()=>({identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:$.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:$.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:$.ETH})).with("MAYA.CACAO",(R)=>({identifier:R,decimal:10})).with("MAYA.MAYA",(R)=>({identifier:R,decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function Cn({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return s(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===l(n).identifier).with("ARB","OP","BASE",()=>h==="ETH").with("GAIA",()=>h==="ATOM").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("THOR",()=>h==="RUNE").otherwise(()=>h===n)?"Native":n}var r=(n)=>{let[h,...T]=n.split("."),R=n.includes("/"),C=T.join("."),P=C?.split("-"),x=P?.length?P.length===1?P[0]:P.slice(0,-1).join("-"):void 0;return{chain:h,symbol:C,ticker:x,synth:R}};async function RT(n){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let T of Object.values(h))for(let{identifier:R,chain:C,...P}of T.tokens){if("identifier"in n&&R===n.identifier)return R;if("address"in P&&"chain"in n&&C===n.chain&&P.address.toLowerCase()===n.contract.toLowerCase())return R}return}var mn={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_verify_message_not_supported:10010,core_chain_halted:10099,core_wallet_connection_not_found:10100,core_wallet_ctrl_not_installed:10101,core_wallet_evmwallet_not_installed:10102,core_wallet_walletconnect_not_installed:10103,core_wallet_keystore_not_installed:10104,core_wallet_ledger_not_installed:10105,core_wallet_trezor_not_installed:10106,core_wallet_keplr_not_installed:10107,core_wallet_okx_not_installed:10108,core_wallet_keepkey_not_installed:10109,core_wallet_talisman_not_installed:10110,core_wallet_not_keypair_wallet:10111,core_wallet_sign_message_not_supported:10110,core_wallet_connection_failed:10112,core_swap_invalid_params:10200,core_swap_route_not_complete:10201,core_swap_asset_not_recognized:10202,core_swap_contract_not_found:10203,core_swap_route_transaction_not_found:10204,core_swap_contract_not_supported:10205,core_swap_transaction_error:10206,core_swap_quote_mode_not_supported:10207,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:20000,wallet_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,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_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_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,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_keepkey_not_found:20900,wallet_keepkey_asset_not_defined:20901,wallet_keepkey_contract_address_not_provided:20902,wallet_keepkey_send_transaction_no_address:20903,wallet_bitkeep_not_found:21001,wallet_exodus_sign_transaction_error:21100,wallet_keystore_invalid_password:29900,wallet_keystore_unsupported_version:29901,wallet_onekey_not_found:21200,wallet_onekey_sign_transaction_error:21201,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,thorchain_preferred_asset_payout_required:40104,api_v2_invalid_response:50001,api_v2_server_error:50002,api_v2_invalid_method_key_hash:50003,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,toolbox_cosmos_verify_signature_no_pubkey:90103,toolbox_cosmos_validate_address_prefix_not_found:90104,toolbox_evm_no_abi_fragment:90201,toolbox_evm_no_signer:90202,toolbox_evm_no_signer_address:90203,toolbox_evm_no_from_address:90204,toolbox_evm_no_contract_address:90205,toolbox_evm_no_fee_data:90206,toolbox_evm_no_gas_price:90207,toolbox_evm_no_to_address:90208,toolbox_evm_invalid_gas_asset_address:90209,toolbox_evm_provider_not_eip1193_compatible:90210,toolbox_evm_error_estimating_gas_limit:90211,toolbox_evm_error_sending_transaction:90212,toolbox_radix_signer_not_defined:90301,toolbox_solana_no_signer:90401,toolbox_solana_fee_estimation_failed:90402,toolbox_ripple_rpc_not_configured:90501,toolbox_ripple_signer_not_found:90502,toolbox_ripple_asset_not_supported:90503,toolbox_ripple_broadcast_error:90504,toolbox_ripple_get_balance_error:90505,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200,not_implemented:99999};class M extends Error{static ErrorCode=mn;constructor(n,h){let T=typeof n==="string",R=T?n:n.errorKey,C=`${R}${T?"":`: ${JSON.stringify(n.info)}`}`;if(h)console.error(h);console.error(R,{code:M.ErrorCode[R],message:C});super(R);Object.setPrototypeOf(this,M.prototype)}}function HT(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function _T(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function BT(n,h){try{return n()}catch(T){if(h)throw new M(h,T);return console.error(T)}}function NT(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var kn=new Set;function e(n,h){if(n){if(kn.has(h))return;kn.add(h),console.warn(h)}}async function OT(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=J.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await t.get(`${h}/status`)).result.node_info.network}catch(h){return n}}import{match as an}from"ts-pattern";var dn=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function In(n){let h=n||dn,T={};for(let R of h){let C=await sn(R);T[R]=C}return T}async function sn(n){let{list:h}=await an(n).with("camelot",()=>import("./chunk-4mz4n5jc.js")).with("caviar",()=>import("./chunk-k2m9hvag.js")).with("chainflip",()=>import("./chunk-2vqx8ecy.js")).with("jupiter",()=>import("./chunk-hk0jx7rp.js")).with("mayachain",()=>import("./chunk-qkreqkaa.js")).with("oneinch",()=>import("./chunk-zv69dnwn.js")).with("openocean",()=>import("./chunk-3ts9cha8.js")).with("pancakeswap",()=>import("./chunk-prm0g9b0.js")).with("pangolin",()=>import("./chunk-mt3sdnfg.js")).with("sushiswap",()=>import("./chunk-4edjz16h.js")).with("thorchain",()=>import("./chunk-c4ndre32.js")).with("traderjoe",()=>import("./chunk-frkpmajq.js")).with("uniswap",()=>import("./chunk-hbnf5tky.js")).with("uniswapv3",()=>import("./chunk-qpz3c078.js")).exhaustive();return h}var Gn=["TERRA",...J.get("chains")];function Xn(n=""){let h=n.toUpperCase(),[T]=h.split(".");if(Gn.includes(T))return!0;let[R]=h.split("/");if(Gn.includes(R))return!0;throw new M({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function IT(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}import{getAddress as Sn}from"ethers";var K=8,q=(n)=>10n**BigInt(n),b=(n)=>Math.log10(Number.parseFloat(n.toString()));function f({value:n,bigIntDecimal:h=K,decimal:T=K}){if(T===0)return n.toString();let R=n<0n,C=n.toString().substring(R?1:0),P=T-(C.length-1);if(P>0)C="0".repeat(P)+C;let x=C.length-T,o=C.slice(-T);if(Number.parseInt(o[h]||"0")>=5)o=`${o.substring(0,h-1)}${(Number.parseInt(o[h-1]||"0")+1).toString()}`;else o=o.substring(0,h);return`${R?"-":""}${C.slice(0,x)}.${o}`.replace(/\.?0*$/,"")}class W{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new W({decimal:h,value:f({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:T}){return W.fromBigInt(n.getBaseValue("bigint")*q(T)/q(h),T)}constructor(n){let h=An(n),T=typeof n==="object";this.decimal=T?n.decimal:void 0,this.decimalMultiplier=T&&"decimalMultiplier"in n?n.decimalMultiplier:q(Math.max(jn(nn(h)),this.decimal||0)),this.#C(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let T=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||b(this.decimalMultiplier));switch(n){case"number":return Number(T);case"string":return T;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return T}}getBaseValue(n,h){let T=this.decimalMultiplier/q(h||this.decimal||$.THOR),R=this.bigIntValue/T;switch(n){case"number":return Number(R);case"string":return R.toString();case"bigint":return R;default:return R}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let T=An(n),R=nn(T);if(R==="0"||R==="undefined")return 0n;return this.#R(R,h)}toSignificant(n=6){let[h,T]=this.getValue("string").split("."),R=h||"",C=T||"";if((Number.parseInt(R)?R.length+C.length:C.length)<=n)return this.getValue("string");if(R.length>=n)return R.slice(0,n).padEnd(R.length,"0");if(Number.parseInt(R))return`${R}.${C.slice(0,n-R.length)}`.padEnd(n-R.length,"0");let x=Number.parseInt(C),o=`${x}`.slice(0,n);return`0.${o.padStart(C.length-`${x}`.length+o.length,"0")}`}toFixed(n=6){let[h,T]=this.getValue("string").split("."),R=h||"",C=T||"";if(Number.parseInt(R))return`${R}.${C.slice(0,n)}`.padEnd(n,"0");let P=Number.parseInt(C),x=`${P}`.slice(0,n);return`0.${x.padStart(C.length-`${P}`.length+x.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),T=["","K","M","B","T","Q","Qi","S"],R=Math.floor(Math.log10(Math.abs(h))/3),C=T[R];if(!C)return this.getValue("string");let P=10**(R*3);return`${(h/P).toFixed(n)}${C}`}toCurrency(n="$",{currencyPosition:h="start",decimal:T=2,decimalSeparator:R=".",thousandSeparator:C=","}={}){let P=this.getValue("number"),[x="",o=""]=P.toFixed(6).split("."),F=x.replace(/\B(?=(\d{3})+(?!\d))/g,C),H=x||o?x==="0"?`${Number.parseFloat(`0.${o}`)}`.replace(".",R):`${F}${Number.parseInt(o)?`${R}${o.slice(0,T)}`:""}`:"0.00";return`${h==="start"?n:""}${H}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let T=h||this.decimal||K,R=Math.max(T,b(this.decimalMultiplier)),C=n<0n,P=n.toString().substring(C?1:0),x=R-(P.length-1),o=x>0?"0".repeat(x)+P:P,F=o.length-R,H=o.slice(-R);if(Number.parseInt(H[T]||"0")>=5)H=`${H.substring(0,T-1)}${(Number.parseInt(H[T-1]||"0")+1).toString()}`;else H=H.substring(0,T);return`${C?"-":""}${o.slice(0,F)}.${H}`.replace(/\.?0*$/,"")}#h(n,...h){let T=this.#T(this,...h),R=Math.max(T,b(this.decimalMultiplier)),C=q(R),P=h.reduce((o,F)=>{let H=this.getBigIntValue(F,R);switch(n){case"add":return o+H;case"sub":return o-H;case"mul":return o*H/C;case"div":{if(H===0n)throw new RangeError("Division by zero");return o*C/H}default:return o}},this.bigIntValue*C/this.decimalMultiplier),x=f({bigIntDecimal:R,decimal:R,value:P});return new this.constructor({decimalMultiplier:q(R),decimal:this.decimal,value:x,identifier:this.toString()})}#n(n,...h){let T=this.#T(this,...h),R=this.getBigIntValue(h[0]||"0",T),C=this.getBigIntValue(this,T);switch(n){case"gt":return C>R;case"gte":return C>=R;case"lt":return C<R;case"lte":return C<=R;case"eqValue":return C===R;default:return!1}}#C(n){let h=nn(n)||"0";this.bigIntValue=this.#R(h)}#T(...n){let h=n.map((T)=>{return typeof T==="object"?T.decimal||b(T.decimalMultiplier):jn(nn(T))}).filter(Boolean);return Math.max(...h,K)}#R(n,h){let T=h?q(h):this.decimalMultiplier,R=b(T),[C="",P=""]=n.split(".");return BigInt(`${C}${P.padEnd(R,"0")}`)}}var ln=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function nn(n){let T=`${typeof n==="number"?ln.format(n):An(n)}`.replaceAll(",",".").split(".");return T.length>1?`${T.slice(0,-1).join("")}.${T.at(-1)}`:T[0]||"0"}function jn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,K)}function An(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var u=new Map;class V extends W{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:T,chain:R,symbol:C,identifier:P}){super(typeof n==="object"?n:{decimal:h,value:n});let x=Pn(P||`${R}.${C}`);this.type=Cn(x),this.tax=T,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=Bn[x.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[T,R,C]=n.split(".");if(!(T&&R))throw new M({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let P=T==="THOR"&&C?`${T}.${R}/${C}`:n;return V.from({asset:P,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:T,...R}){let C=n instanceof W?n.getValue("string"):n,P=hh(R),{identifier:x,decimal:o}=l(P),{chain:F,isSynthetic:H,isTradeAsset:j}=Pn(x),k=u.get(F==="SOL"?x:x.toUpperCase()),g=k?.decimal||o;e(!(T||g),`Couldn't find static decimal for one or more tokens on ${F} (Using default ${$[F]} 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:k,identifier:S,tax:z}=I||{decimal:j||L[_],identifier:F},B=x||$,c=h?hn(BigInt(R),h):hn(R,k);return o?rn(S,h?c:R):B?en(S,c):new Z({tax:z,decimal:k,identifier:S,value:c})}static async loadStaticAssets(n){let h=await In(n);for(let{tokens:o}of Object.values(h))for(let{identifier:T,chain:R,...A}of o){let F=R==="SOL"?T:T.toUpperCase(),P="decimals"in A?A.decimals:L[R];q.set(F,{identifier:T,decimal:P})}return!0}static setStaticAssets(n){q.clear();for(let[h,o]of n.entries()){let T=o.chain==="SOL"?o.identifier:o.identifier.toUpperCase(),R="decimals"in o?o.decimals:o.decimal;q.set(h,{...o,decimal:R,identifier:T})}return!0}}function Zo(n){let h=Z.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function rn(n,h=0){Gn(n);let T=n.includes("SOL.")?n:n.toUpperCase(),R=q.get(T),A=R?.decimal||await Ln(Pn(n));if(!R)q.set(T,{identifier:n,decimal:A});return new Z({decimal:A,value:hn(h,A),identifier:n})}function en(n,h=0){let o=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,T=o?["MAYA","THOR"].includes(o):!1,R=n.slice(0,14).includes("~")?"~":"/",[A,F]=T?n.split(".").slice(1).join().split(R):n.split(R);if(!(A&&F))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new Z({decimal:8,value:hn(h,8),identifier:`${o||"THOR"}.${A}${R}${F}`})}function hn(n,h){return typeof n==="bigint"?f({value:n,bigIntDecimal:h,decimal:h}):n}function nh(n){let h="chain"in n?n.chain:r(n.asset).synth?"THOR":r(n.asset).chain;if(!Object.values(g).includes(h.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function hh(n){if(nh(n),"chain"in n)return n.chain;let{chain:h,symbol:o}=r(n.asset);return Cn({chain:h,symbol:o})==="Native"?h:n.asset}function Pn(n){let h=n.slice(0,14),o=n.split("."),T=o[0]?.toUpperCase(),R=["THOR","MAYA"].includes(T),A=h.includes("/"),F=h.includes("~"),P=A||F,_=F?"~":"/",[x,$=""]=R?o.slice(1).join().split(_):n.split(_);if(P&&!(x&&$))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let[I,...j]=(n.includes(".")&&!P?n:`${T}.${$}`).split("."),k=P?$:j.join("."),{address:S,ticker:z}=oh({symbol:k,chain:I}),B;try{B=S&&V.includes(I)&&gn(S)?gn(S):S}catch(D){B=S}let c=(P?`${x}${_}`:"")+(B?`${z}-${B??""}`:k);return{address:B,chain:I,isSynthOrTrade:P,isSynthetic:A,isTradeAsset:F,ticker:z,symbol:c,isGasAsset:Mn({chain:I,symbol:k})}}function oh({symbol:n,chain:h}){let o=n.split("-"),T=o.length===1?void 0:o[o.length-1],R=h==="SOL"?T:T?.toLowerCase(),A=o.length===1?o[0]:o.slice(0,-1).join("-");return{address:R,ticker:A}}class J extends Y{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new J({decimal:h,value:f({value:n,bigIntDecimal:h,decimal:h})})}}function Th({liquidityUnits:n,poolUnits:h,runeDepth:o}){let T=t(n),R=t(h),A=t(o),F=T.mul(A),P=R.mul(R).mul(2),_=R.mul(T).mul(2),x=T.mul(T),$=R.mul(R).mul(R);return F.mul(P.sub(_).add(x)).div($)}function Rh({liquidityUnits:n,poolUnits:h,assetDepth:o}){let T=t(n),R=t(h),A=t(o),F=T.mul(A),P=R.mul(R).mul(2),_=R.mul(T).mul(2),x=T.mul(T),$=F.mul(P.sub(_).add(x)),I=R.mul(R).mul(R);return $.div(I)}function fo({percent:n,runeDepth:h,liquidityUnits:o,poolUnits:T}){return Th({runeDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function qo({percent:n,assetDepth:h,liquidityUnits:o,poolUnits:T}){return Rh({assetDepth:h,liquidityUnits:o,poolUnits:T}).mul(n)}function t(n){return J.fromBigInt(BigInt(n),L.THOR)}function Ch({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T}){return{assetAmount:t(T).mul(n).div(h),runeAmount:t(o).mul(n).div(h)}}function Do({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T,percent:R}){return Object.fromEntries(Object.entries(Ch({liquidityUnits:n,poolUnits:h,runeDepth:o,assetDepth:T})).map(([A,F])=>[A,F.mul(R)]))}function bo({runeDepth:n,poolUnits:h,assetDepth:o,liquidityUnits:T,runeAmount:R,assetAmount:A}){let F=new J({value:n,decimal:8}),P=new J({value:o,decimal:8}),_=new J({value:h,decimal:8}),x=new J({value:R,decimal:8}),$=new J({value:A,decimal:8}),I=x.mul(P),j=$.mul(F),k=x.mul($),S=F.mul(P),z=_.mul(I.add(j.add(k.mul(2)))),B=I.add(j.add(S.mul(2))),c=z.div(B),D=t(T).add(c);if(c.getBaseValue("number")===0)return D.div(_).getBaseValue("number");let jn=_.add(D);return D.div(jn).getBaseValue("number")}function Ko({runeAmount:n,assetAmount:h,runeDepth:o,assetDepth:T}){if(n==="0"||h==="0"||o==="0"||T==="0")return 0;let R=t(o),A=t(T),F=t(h),P=t(n),_=F.mul(R).sub(A.mul(P)),x=A.mul(P).add(R.mul(A));return Math.abs(_.div(x).getBaseValue("number"))}function mo({type:n,address:h}){return`${n}:${h}`}function ao({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function io(n){return E("POOL+",n)}function so({chain:n,symbol:h,...o}){return E(`${"+"}:${n}/${h}`,o)}function lo({chain:n,symbol:h,address:o,...T}){let R=Ah({chain:n,symbol:h}),A=o?`:${o}:`:":";return E(`${"+"}:${R}${A}`,T)}function ro({chain:n,symbol:h,basisPoints:o}){return`${"-"}:${n}/${h}:${o}`}function eo({chain:n,symbol:h,ticker:o,basisPoints:T,targetAsset:R}){let A=n==="ETH"&&o!=="ETH"?`${o}-${h.slice(-3)}`:h,F=R?`:${R}`:"";return`${"-"}:${n}.${A}:${T}${F}`}function nT({basisPoints:n,...h}){return E(`${"POOL-"}:${n}`,h)}function hT({name:n,chain:h,address:o,owner:T}){let R=`${"~"}:${n}:${h}:${o}`,A=T?`:${T}`:"";return`${R}${A}`}function oT({name:n,chain:h,asset:o,payout:T,owner:R}){return`${"~"}:${n}:${h}:${T}:${R}:${o}`}function TT(n,{asset:h,address:o,minAmount:T,...R}){let A=`${n}:${h}:${o}`,F=T?`:${T}`:"";return E(`${A}${F}`,R)}function E(n,{affiliateAddress:h,affiliateBasisPoints:o}={}){let T=`${n}${h?`:${h}:${o||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function Ah({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}function CT({name:n,properties:h,methods:o}){function T(R){return{...o(R),...h}}return{[n]:T}}function HT(){return typeof window.ethereum!=="undefined"}function _T(n){return Ph().includes(n)}function Ph(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,o=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,R=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,A=window?.bitkeep?.ethereum,F=window?.$onekey?.ethereum,P=[];if(n)P.push("METAMASK");if(h)P.push("CTRL");if(o)P.push("BRAVE");if(T)P.push("TRUSTWALLET_WEB");if(R)P.push("COINBASE_WEB");if(_h())P.push("OKX_MOBILE");if(A)P.push("BITGET");if(F)P.push("ONEKEY");return P}async function Fh(n,h,o){try{await tn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:Nn[h]}]})}catch(T){if(!o)throw new Error("Failed to switch network, networkParams not provided");await Hh(n,o)}}function BT({chains:n,supportedChains:h,walletType:o}){let T=n.filter((A)=>h.includes(A));if(T.length===0)throw new M("wallet_chain_not_supported",{wallet:o,chain:n.join(", ")});let R=n.filter((A)=>!h.includes(A));return e(R.length>0,`${o} wallet does not support the following chains: ${R.join(", ")}. These chains will be ignored.`),T}function xh(n,h,o){}function NT({toolbox:n,chain:h,provider:o=window.ethereum,methodNames:T=[]}){let A=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((F,P)=>{if(!n[P])return F;let _=n[P];if(typeof _!=="function")return F;let x=xh(_,o,h);return{...F,[P]:x}},{});return{...n,...A}}function Hh(n,h){return tn({provider:n,method:"wallet_addEthereumChain",params:[h]})}function $T(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function OT(){let{isTrust:n,isBraveWallet:h,__XDEFI:o,overrideIsMetaMask:T,selectedProvider:R}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&R?.isCoinbaseWallet)return"COINBASE_WEB";if(o)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function pT(){let n=[];function h(T){if(n.map((R)=>R.info.uuid).includes(T.detail.info.uuid))return;n.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function o(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:o}}function _h(){let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),o=/android|XiaoMi|MiuiBrowser/i.test(n),T=h||o,R=/OKApp/i.test(n);return T&&R}function LT({connect:n,name:h,supportedChains:o,walletType:T}){function R(A){return n({...A,walletType:T,supportedChains:o})}return{[h]:{supportedChains:o,connectWallet:R}}}function tn({provider:n,params:h,method:o}){if(!n?.send)throw new M("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return n.send(o,T)}export{Bo as wrapWithThrow,xh as wrapMethodWithNetworkSwitch,e as warnOnce,Io as validateTNS,Gn as validateIdentifier,Rn as updateDerivationPath,Fh as switchEVMWalletNetwork,tn as providerRequest,NT as prepareNetworkSwitch,_h as okxMobileEnabled,In as loadTokenLists,Ph as listWeb3EVMWallets,HT as isWeb3Detected,Mn as isGasAsset,_T as isDetected,kh as initializeRPCUrlsWithFallback,Qh as getWalletFormatFor,Ho as getTHORNameCost,Do as getSymmetricWithdraw,Ch as getSymmetricPoolShare,Zo as getMinAmountByChain,eo as getMemoForWithdraw,ao as getMemoForUnbond,ro as getMemoForSaverWithdraw,so as getMemoForSaverDeposit,nT as getMemoForRunePoolWithdraw,io as getMemoForRunePoolDeposit,hT as getMemoForNameRegister,oT as getMemoForNamePreferredAssetRegister,TT as getMemoForLoan,mo as getMemoForLeaveAndBond,lo as getMemoForDeposit,_o as getMAYANameCost,Ko as getLiquiditySlippage,oo as getGasAsset,bo as getEstimatedPoolShare,OT as getETHDefaultWallet,pT as getEIP6963Wallets,$o as getDynamicChainId,Uh as getDerivationPathFor,Ln as getDecimal,l as getCommonAssetInfo,No as getChainIdentifier,fo as getAsymmetricRuneWithdrawAmount,Th as getAsymmetricRuneShare,qo as getAsymmetricAssetWithdrawAmount,Rh as getAsymmetricAssetShare,Cn as getAssetType,f as formatBigIntToSafeValue,To as findAssetBy,BT as filterSupportedChains,$n as derivationPathToString,LT as createWallet,CT as createPlugin,r as assetFromString,Hh as addEVMWalletNetwork,$T as addAccountsChangedCallback,Wn as WarningCodeEnum,i as WalletOption,Hn as UTXOChains,Lh as TCSupportedChains,J as SwapKitNumber,M as SwapKitError,$h as SubstrateChains,on as StagenetChain,gh as SWAP_OUT,Xh as SWAP_IN,Q as SKConfig,w as RequestClient,a as RPC_URLS,Zn as QuoteMode,un as ProviderName,u as NetworkDerivationPath,y as NODE_URLS,On as MemoType,Mh as MAYASupportedChains,Dn as LedgerErrorCode,wn as FeeTypeEnum,fn as FeeOption,Qn as FALLBACK_URLS,Vn as ErrorCode,Tn as EXPLORER_URLS,V as EVMChains,ch as DerivationPath,Oh as CosmosChains,ph as CosmosChainPrefixes,Yn as ContractAddress,ho as CommonAssetStrings,Nn as ChainToHexChainId,Ih as ChainToExplorerUrl,Bn as ChainToChainId,Bh as ChainIdToChain,v as ChainId,g as Chain,Nh as BlockTimes,Y as BigIntArithmetics,L as BaseDecimal,Z as AssetValue,qn as ApproveMode,Gh as AGG_SWAP};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:L,identifier:I,tax:Z}=k||{decimal:g||$[F],identifier:x},B=H||j,Y=h?hn(BigInt(C),h):hn(C,L);return T?rn(I,h?Y:C):B?en(I,Y):new V({tax:Z,decimal:L,identifier:I,value:Y})}static async loadStaticAssets(n){let h=await In(n);for(let{tokens:T}of Object.values(h))for(let{identifier:R,chain:C,...P}of T){let x=C==="SOL"?R:R.toUpperCase(),o="decimals"in P?P.decimals:$[C];u.set(x,{identifier:R,decimal:o})}return!0}static setStaticAssets(n){u.clear();for(let[h,T]of n.entries()){let R=T.chain==="SOL"?T.identifier:T.identifier.toUpperCase(),C="decimals"in T?T.decimals:T.decimal;u.set(h,{...T,decimal:C,identifier:R})}return!0}}function VT(n){let h=V.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function rn(n,h=0){Xn(n);let R=n.includes("SOL.")?n:n.toUpperCase(),C=u.get(R),P=C?.decimal||await Mn(Pn(n));if(!C)u.set(R,{identifier:n,decimal:P});return new V({decimal:P,value:hn(h,P),identifier:n})}function en(n,h=0){let T=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,R=T?["MAYA","THOR"].includes(T):!1,C=n.slice(0,14).includes("~")?"~":"/",[P,x]=R?n.split(".").slice(1).join().split(C):n.split(C);if(!(P&&x))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new V({decimal:8,value:hn(h,8),identifier:`${T||"THOR"}.${P}${C}${x}`})}function hn(n,h){return typeof n==="bigint"?f({value:n,bigIntDecimal:h,decimal:h}):n}function nh(n){let h="chain"in n?n.chain:r(n.asset).synth?"THOR":r(n.asset).chain;if(!Object.values(S).includes(h.toUpperCase()))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function hh(n){if(nh(n),"chain"in n)return n.chain;let{chain:h,symbol:T}=r(n.asset);return Cn({chain:h,symbol:T})==="Native"?h:n.asset}function Pn(n){let h=n.slice(0,14),T=n.split("."),R=T[0]?.toUpperCase(),C=["THOR","MAYA"].includes(R),P=h.includes("/"),x=h.includes("~"),o=P||x,F=x?"~":"/",[H,j=""]=C?T.slice(1).join().split(F):n.split(F);if(o&&!(H&&j))throw new M({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let[k,...g]=(n.includes(".")&&!o?n:`${R}.${j}`).split("."),L=o?j:g.join("."),{address:I,ticker:Z}=Th({symbol:L,chain:k}),B;try{B=I&&c.includes(k)&&Sn(I)?Sn(I):I}catch(D){B=I}let Y=(o?`${H}${F}`:"")+(B?`${Z}-${B??""}`:L);return{address:B,chain:k,isSynthOrTrade:o,isSynthetic:P,isTradeAsset:x,ticker:Z,symbol:Y,isGasAsset:Ln({chain:k,symbol:L})}}function Th({symbol:n,chain:h}){let T=n.split("-"),R=T.length===1?void 0:T[T.length-1],C=h==="SOL"?R:R?.toLowerCase(),P=T.length===1?T[0]:T.slice(0,-1).join("-");return{address:C,ticker:P}}class z extends W{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new z({decimal:h,value:f({value:n,bigIntDecimal:h,decimal:h})})}}function Rh({liquidityUnits:n,poolUnits:h,runeDepth:T}){let R=U(n),C=U(h),P=U(T),x=R.mul(P),o=C.mul(C).mul(2),F=C.mul(R).mul(2),H=R.mul(R),j=C.mul(C).mul(C);return x.mul(o.sub(F).add(H)).div(j)}function Ch({liquidityUnits:n,poolUnits:h,assetDepth:T}){let R=U(n),C=U(h),P=U(T),x=R.mul(P),o=C.mul(C).mul(2),F=C.mul(R).mul(2),H=R.mul(R),j=x.mul(o.sub(F).add(H)),k=C.mul(C).mul(C);return j.div(k)}function fT({percent:n,runeDepth:h,liquidityUnits:T,poolUnits:R}){return Rh({runeDepth:h,liquidityUnits:T,poolUnits:R}).mul(n)}function uT({percent:n,assetDepth:h,liquidityUnits:T,poolUnits:R}){return Ch({assetDepth:h,liquidityUnits:T,poolUnits:R}).mul(n)}function U(n){return z.fromBigInt(BigInt(n),$.THOR)}function Ah({liquidityUnits:n,poolUnits:h,runeDepth:T,assetDepth:R}){return{assetAmount:U(R).mul(n).div(h),runeAmount:U(T).mul(n).div(h)}}function DT({liquidityUnits:n,poolUnits:h,runeDepth:T,assetDepth:R,percent:C}){return Object.fromEntries(Object.entries(Ah({liquidityUnits:n,poolUnits:h,runeDepth:T,assetDepth:R})).map(([P,x])=>[P,x.mul(C)]))}function bT({runeDepth:n,poolUnits:h,assetDepth:T,liquidityUnits:R,runeAmount:C,assetAmount:P}){let x=new z({value:n,decimal:8}),o=new z({value:T,decimal:8}),F=new z({value:h,decimal:8}),H=new z({value:C,decimal:8}),j=new z({value:P,decimal:8}),k=H.mul(o),g=j.mul(x),L=H.mul(j),I=x.mul(o),Z=F.mul(k.add(g.add(L.mul(2)))),B=k.add(g.add(I.mul(2))),Y=Z.div(B),D=U(R).add(Y);if(Y.getBaseValue("number")===0)return D.div(F).getBaseValue("number");let Qn=F.add(D);return D.div(Qn).getBaseValue("number")}function KT({runeAmount:n,assetAmount:h,runeDepth:T,assetDepth:R}){if(n==="0"||h==="0"||T==="0"||R==="0")return 0;let C=U(T),P=U(R),x=U(h),o=U(n),F=x.mul(C).sub(P.mul(o)),H=P.mul(o).add(C.mul(P));return Math.abs(F.div(H).getBaseValue("number"))}function mT({type:n,address:h}){return`${n}:${h}`}function aT({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function dT(n){return on("POOL+",n)}function iT({chain:n,symbol:h,address:T,...R}){let C=Ph({chain:n,symbol:h}),P=T?`:${T}:`:":";return on(`${"+"}:${C}${P}`,R)}function sT({chain:n,symbol:h,ticker:T,basisPoints:R,targetAsset:C}){let P=n==="ETH"&&T!=="ETH"?`${T}-${h.slice(-3)}`:h,x=C?`:${C}`:"";return`${"-"}:${n}.${P}:${R}${x}`}function lT({basisPoints:n,...h}){return on(`${"POOL-"}:${n}`,h)}function rT({name:n,chain:h,address:T,owner:R}){let C=`${"~"}:${n}:${h}:${T}`,P=R?`:${R}`:"";return`${C}${P}`}function eT({name:n,chain:h,asset:T,payout:R,owner:C}){return`${"~"}:${n}:${h}:${R}:${C}:${T}`}function on(n,{affiliateAddress:h,affiliateBasisPoints:T}={}){let R=`${n}${h?`:${h}:${T||0}`:""}`;return R.endsWith(":")?R.slice(0,-1):R}function Ph({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}function hR({name:n,properties:h,methods:T}){function R(C){return{...T(C),...h}}return{[n]:R}}function PR(){return typeof window.ethereum!=="undefined"}function oR(n){return oh().includes(n)}function oh(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,T=window?.ethereum?.isBraveWallet,R=window?.ethereum?.isTrust||window?.trustwallet,C=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,P=window?.bitkeep?.ethereum,x=window?.$onekey?.ethereum,o=[];if(n)o.push("METAMASK");if(h)o.push("CTRL");if(T)o.push("BRAVE");if(R)o.push("TRUSTWALLET_WEB");if(C)o.push("COINBASE_WEB");if(_h())o.push("OKX_MOBILE");if(P)o.push("BITGET");if(x)o.push("ONEKEY");return o}async function xh(n,h,T){try{await Un({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:Nn[h]}]})}catch(R){if(!T)throw new Error("Failed to switch network, networkParams not provided");await Hh(n,T)}}function xR({chains:n,supportedChains:h,walletType:T}){let R=n.filter((P)=>h.includes(P));if(R.length===0)throw new M("wallet_chain_not_supported",{wallet:T,chain:n.join(", ")});let C=n.filter((P)=>!h.includes(P));return e(C.length>0,`${T} wallet does not support the following chains: ${C.join(", ")}. These chains will be ignored.`),R}function Fh(n,h,T){}function FR({toolbox:n,chain:h,provider:T=window.ethereum,methodNames:R=[]}){let P=[...R,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((x,o)=>{if(!n[o])return x;let F=n[o];if(typeof F!=="function")return x;let H=Fh(F,T,h);return{...x,[o]:H}},{});return{...n,...P}}function Hh(n,h){return Un({provider:n,method:"wallet_addEthereumChain",params:[h]})}function HR(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function _R(){let{isTrust:n,isBraveWallet:h,__XDEFI:T,overrideIsMetaMask:R,selectedProvider:C}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(R&&C?.isCoinbaseWallet)return"COINBASE_WEB";if(T)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function BR(){let n=[];function h(R){if(n.map((C)=>C.info.uuid).includes(R.detail.info.uuid))return;n.push(R.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function T(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:T}}function _h(){let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),T=/android|XiaoMi|MiuiBrowser/i.test(n),R=h||T,C=/OKApp/i.test(n);return R&&C}function NR({connect:n,name:h,supportedChains:T,walletType:R}){function C(P){return n({...P,walletType:R,supportedChains:T})}return{[h]:{supportedChains:T,connectWallet:C}}}function Un({provider:n,params:h,method:T}){if(!n?.send)throw new M("helpers_not_found_provider");let R=h?Array.isArray(h)?h:[h]:[];return n.send(T,R)}export{BT as wrapWithThrow,Fh as wrapMethodWithNetworkSwitch,e as warnOnce,IT as validateTNS,Xn as validateIdentifier,Rn as updateDerivationPath,xh as switchEVMWalletNetwork,Un as providerRequest,FR as prepareNetworkSwitch,_h as okxMobileEnabled,In as loadTokenLists,oh as listWeb3EVMWallets,PR as isWeb3Detected,Ln as isGasAsset,oR as isDetected,kh as initializeRPCUrlsWithFallback,Jh as getWalletFormatFor,HT as getTHORNameCost,DT as getSymmetricWithdraw,Ah as getSymmetricPoolShare,VT as getMinAmountByChain,sT as getMemoForWithdraw,aT as getMemoForUnbond,lT as getMemoForRunePoolWithdraw,dT as getMemoForRunePoolDeposit,rT as getMemoForNameRegister,eT as getMemoForNamePreferredAssetRegister,mT as getMemoForLeaveAndBond,iT as getMemoForDeposit,_T as getMAYANameCost,KT as getLiquiditySlippage,TT as getGasAsset,bT as getEstimatedPoolShare,_R as getETHDefaultWallet,BR as getEIP6963Wallets,OT as getDynamicChainId,gh as getDerivationPathFor,Mn as getDecimal,l as getCommonAssetInfo,NT as getChainIdentifier,fT as getAsymmetricRuneWithdrawAmount,Rh as getAsymmetricRuneShare,uT as getAsymmetricAssetWithdrawAmount,Ch as getAsymmetricAssetShare,Cn as getAssetType,f as formatBigIntToSafeValue,RT as findAssetBy,xR as filterSupportedChains,On as derivationPathToString,NR as createWallet,hR as createPlugin,r as assetFromString,Hh as addEVMWalletNetwork,HR as addAccountsChangedCallback,qn as WarningCodeEnum,d as WalletOption,Hn as UTXOChains,Mh as TCSupportedChains,z as SwapKitNumber,M as SwapKitError,Oh as SubstrateChains,y as StagenetChain,Sh as SWAP_OUT,jh as SWAP_IN,J as SKConfig,t as RequestClient,a as RPC_URLS,Vn as QuoteMode,wn as ProviderName,w as NetworkDerivationPath,E as NODE_URLS,pn as MemoType,Lh as MAYASupportedChains,Dn as LedgerErrorCode,tn as FeeTypeEnum,fn as FeeOption,Jn as FALLBACK_URLS,cn as ErrorCode,Tn as EXPLORER_URLS,c as EVMChains,Yh as DerivationPath,ph as CosmosChains,$h as CosmosChainPrefixes,Wn as ContractAddress,hT as CommonAssetStrings,Nn as ChainToHexChainId,Ih as ChainToExplorerUrl,Bn as ChainToChainId,Bh as ChainIdToChain,v as ChainId,S as Chain,Nh as BlockTimes,W as BigIntArithmetics,$ as BaseDecimal,V as AssetValue,un as ApproveMode,Xh as AGG_SWAP};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=46E686D105A11D0264756E2164756E21
|