@swapkit/helpers 3.0.0-beta.11 → 3.0.0-beta.13
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-6vvdbb6s.js → chunk-7shcm26h.js} +3 -3
- package/dist/{chunk-6vvdbb6s.js.map → chunk-7shcm26h.js.map} +1 -1
- package/dist/chunk-8fdws4se.js +4 -0
- package/dist/chunk-8fdws4se.js.map +10 -0
- package/dist/{chunk-dbsrwnw2.js → chunk-b8hashv0.js} +3 -3
- package/dist/{chunk-dbsrwnw2.js.map → chunk-b8hashv0.js.map} +1 -1
- package/dist/{chunk-kdcsgh3q.js → chunk-bf0ph1bk.js} +3 -3
- package/dist/{chunk-kdcsgh3q.js.map → chunk-bf0ph1bk.js.map} +1 -1
- package/dist/{chunk-mmwvr2y8.js → chunk-bh986mnf.js} +3 -3
- package/dist/{chunk-mmwvr2y8.js.map → chunk-bh986mnf.js.map} +1 -1
- package/dist/{chunk-ahpfxkx0.js → chunk-dzypg9sp.js} +3 -3
- package/dist/{chunk-ahpfxkx0.js.map → chunk-dzypg9sp.js.map} +1 -1
- package/dist/{chunk-wmxwvv8c.js → chunk-ghdhtvtt.js} +3 -3
- package/dist/{chunk-wmxwvv8c.js.map → chunk-ghdhtvtt.js.map} +1 -1
- package/dist/{chunk-fr86y3rx.js → chunk-jhmhh7ax.js} +3 -3
- package/dist/{chunk-fr86y3rx.js.map → chunk-jhmhh7ax.js.map} +1 -1
- package/dist/{chunk-ekd1k975.js → chunk-nm1av1e6.js} +3 -3
- package/dist/{chunk-ekd1k975.js.map → chunk-nm1av1e6.js.map} +1 -1
- package/dist/{chunk-wrjh857m.js → chunk-rarep8vg.js} +3 -3
- package/dist/{chunk-wrjh857m.js.map → chunk-rarep8vg.js.map} +1 -1
- package/dist/{chunk-kr69v1tm.js → chunk-rr043vwc.js} +3 -3
- package/dist/{chunk-kr69v1tm.js.map → chunk-rr043vwc.js.map} +1 -1
- package/dist/{chunk-3wnfcm30.js → chunk-s82pm7xc.js} +2 -2
- package/dist/{chunk-3wnfcm30.js.map → chunk-s82pm7xc.js.map} +1 -1
- package/dist/chunk-sb9hymk1.js +3 -0
- package/dist/chunk-sb9hymk1.js.map +10 -0
- package/dist/{chunk-tq87xn7m.js → chunk-tn4e7zrk.js} +3 -3
- package/dist/{chunk-tq87xn7m.js.map → chunk-tn4e7zrk.js.map} +1 -1
- package/dist/{chunk-z8emzpyc.js → chunk-vadspc46.js} +3 -3
- package/dist/{chunk-z8emzpyc.js.map → chunk-vadspc46.js.map} +1 -1
- package/dist/{chunk-xyczdrny.js → chunk-vgg88vt8.js} +3 -3
- package/dist/{chunk-xyczdrny.js.map → chunk-vgg88vt8.js.map} +1 -1
- package/dist/{chunk-q8xy3739.js → chunk-wssz50sc.js} +3 -3
- package/dist/{chunk-q8xy3739.js.map → chunk-wssz50sc.js.map} +1 -1
- package/dist/contracts/index.js +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +15 -16
- package/dist/index.js +3 -3
- package/dist/index.js.map +15 -16
- package/dist/tokens/index.js +2 -2
- package/dist/tokens/index.js.map +2 -2
- package/package.json +2 -2
- package/src/api/microgard/types.ts +0 -3
- package/src/api/midgard/endpoints.ts +1 -65
- package/src/api/midgard/types.ts +0 -49
- package/src/api/swapkitApi/endpoints.ts +1 -2
- package/src/api/swapkitApi/types.ts +1 -1
- package/src/modules/__tests__/assetValue.test.ts +42 -0
- package/src/modules/__tests__/swapKitNumber.test.ts +4 -5
- package/src/modules/assetValue.ts +12 -28
- package/src/modules/bigIntArithmetics.ts +12 -1
- package/src/modules/requestClient.ts +36 -22
- package/src/modules/swapKitError.ts +294 -105
- package/src/types/chains.ts +45 -37
- package/src/types/derivationPath.ts +1 -0
- package/src/types/quotes.ts +0 -2
- package/src/types/sdk.ts +0 -2
- package/src/types/wallet.ts +2 -0
- package/src/utils/__tests__/memo.test.ts +0 -20
- package/src/utils/asset.ts +3 -2
- package/src/utils/memo.ts +5 -42
- package/src/utils/others.ts +1 -2
- package/src/utils/wallets.ts +4 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var xo={};Fo(xo,{wrapWithThrow:()=>Gh,wrapMethodWithNetworkSwitch:()=>Kn,warnOnce:()=>a,validateTNS:()=>Uh,validateIdentifier:()=>Nn,updateDerivationPath:()=>nn,switchEVMWalletNetwork:()=>bn,providerRequest:()=>Ln,prepareNetworkSwitch:()=>oo,okxMobileEnabled:()=>yn,loadTokenLists:()=>Bn,listWeb3EVMWallets:()=>Dn,isWeb3Detected:()=>eh,isGasAsset:()=>_n,isDetected:()=>no,initializeRPCUrlsWithFallback:()=>Rh,getWalletFormatFor:()=>Hh,getTHORNameCost:()=>Ih,getSymmetricWithdraw:()=>wh,getSymmetricPoolShare:()=>qn,getMinAmountByChain:()=>Jh,getMemoForWithdraw:()=>mh,getMemoForUnbond:()=>bh,getMemoForSaverWithdraw:()=>vh,getMemoForSaverDeposit:()=>Eh,getMemoForRunePoolWithdraw:()=>ah,getMemoForRunePoolDeposit:()=>Kh,getMemoForNameRegister:()=>ih,getMemoForNamePreferredAssetRegister:()=>sh,getMemoForLoan:()=>dh,getMemoForLeaveAndBond:()=>Dh,getMemoForDeposit:()=>yh,getMAYANameCost:()=>Sh,getLiquiditySlippage:()=>qh,getGasAsset:()=>Lh,getEstimatedPoolShare:()=>fh,getETHDefaultWallet:()=>Ro,getEIP6963Wallets:()=>Co,getDynamicChainId:()=>gh,getDerivationPathFor:()=>xh,getDecimal:()=>Hn,getCommonAssetInfo:()=>v,getChainIdentifier:()=>Xh,getAsymmetricRuneWithdrawAmount:()=>Wh,getAsymmetricRuneShare:()=>wn,getAsymmetricAssetWithdrawAmount:()=>uh,getAsymmetricAssetShare:()=>fn,getAssetType:()=>on,formatBigIntToSafeValue:()=>w,findAssetBy:()=>Mh,filterSupportedChains:()=>ho,derivationPathToString:()=>Fn,createWallet:()=>Ao,createPlugin:()=>rh,assetFromString:()=>m,addEVMWalletNetwork:()=>En,addAccountsChangedCallback:()=>To,WarningCodeEnum:()=>tn,WalletOption:()=>E,UTXOChains:()=>Cn,TCSupportedChains:()=>en,SwapKitNumber:()=>j,SwapKitError:()=>M,SubstrateChains:()=>dn,StagenetChain:()=>l,SWAP_OUT:()=>Fh,SWAP_IN:()=>Ph,SKConfig:()=>t,RequestClient:()=>W,RPC_URLS:()=>K,QuoteMode:()=>Gn,ProviderName:()=>jn,NetworkDerivationPath:()=>V,NODE_URLS:()=>D,MemoType:()=>xn,MAYASupportedChains:()=>nh,LedgerErrorCode:()=>zn,FeeTypeEnum:()=>Un,FeeOption:()=>Qn,FALLBACK_URLS:()=>In,ErrorCode:()=>gn,EXPLORER_URLS:()=>e,EVMChains:()=>Y,DerivationPath:()=>_h,CosmosChains:()=>ln,CosmosChainPrefixes:()=>rn,ContractAddress:()=>Xn,CommonAssetStrings:()=>Nh,ChainToHexChainId:()=>Pn,ChainToExplorerUrl:()=>Ch,ChainToChainId:()=>An,ChainIdToChain:()=>mn,ChainId:()=>b,Chain:()=>X,BlockTimes:()=>sn,BigIntArithmetics:()=>z,BaseDecimal:()=>p,AssetValue:()=>J,ApproveMode:()=>Jn,AGG_SWAP:()=>Ah});module.exports=Po(xo);var X;((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"})(X||={});var l;((o)=>{o.THORChain="THOR_STAGENET";o.Maya="MAYA_STAGENET"})(l||={});var b;((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"})(b||={});var mn={["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"},an=Object.keys(X),r=Object.values(X),p={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},sn={["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},dn=["DOT","FLIP"],Y=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Cn=["BTC","BCH","DASH","DOGE","LTC"],ln=["GAIA","THOR","MAYA","KUJI"],rn={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},en=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],nh=["ARB","DASH","ETH","KUJI","MAYA","THOR"],K={["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"},D={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},In={["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",D.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},e={["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"},Mn=K,hh=(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 oh(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var kn=async(n,h)=>{try{let o=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${o}${oh(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(hh(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Th=async(n)=>{let h=K[n];if(await kn(n,h))return h;for(let o of In[n])if(await kn(n,o))return o;return h},Rh=async(n=[...Object.values(X),...Object.values(l)])=>{let h={};await Promise.all(n.map(async(o)=>{let T=await Th(o);h[o]=T})),Mn={...Mn,...h}},Sn=r.reduce((n,h)=>{let o=an.find((T)=>X[T]===h);if(o)n[h]=o;return n},{}),An=r.reduce((n,h)=>{return n[h]=b[Sn[h]],n},{}),Pn=r.reduce((n,h)=>{let o=`${Sn[h]}Hex`;return n[h]=b[o],n},{}),Ch=r.reduce((n,h)=>{return n[h]=e[h],n},{});var y=require("ts-pattern");var cn=require("zustand/vanilla");var Gn;((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"})(Gn||={});var Ah=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Ph=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Fh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function nn(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 Fn([n,h,o,T,R]){return`m/${n}'/${h}'/${o}'/${T}${typeof R!=="number"?"":`/${R}`}`}function xh({chain:n,index:h,addressIndex:o=0,type:T}){if(Y.includes(n)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,o];return nn(V[n],{index:h})}if(n==="SOL"){if(T==="account")return[44,501,0,h];return nn(V[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 nn(V[n],{index:h})}}function Hh(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 Xn;((P)=>{P.ARB="0x0000000000000000000000000000000000000000";P.AVAX="0x0000000000000000000000000000000000000000";P.BASE="0x0000000000000000000000000000000000000000";P.ETH="0x0000000000000000000000000000000000000000";P.BSC="0x0000000000000000000000000000000000000000";P.MATIC="0x0000000000000000000000000000000000001010";P.OP="0x4200000000000000000000000000000000000042"})(Xn||={});var V={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]},_h=Object.keys(V).reduce((n,h)=>{return n[h]=Fn(V[h]),n},{});var gn;((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"})(gn||={});var tn;((o)=>{o.highSlippage="highSlippage";o.highPriceImpact="highPriceImpact"})(tn||={});var jn;((L)=>{L.CAVIAR_V1="CAVIAR_V1";L.CAMELOT_V3="CAMELOT_V3";L.CHAINFLIP="CHAINFLIP";L.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";L.JUPITER="JUPITER";L.MAYACHAIN="MAYACHAIN";L.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";L.OCISWAP_V1="OCISWAP_V1";L.ONEINCH="ONEINCH";L.OPENOCEAN_V2="OPENOCEAN_V2";L.PANCAKESWAP="PANCAKESWAP";L.PANGOLIN_V1="PANGOLIN_V1";L.SUSHISWAP_V2="SUSHISWAP_V2";L.THORCHAIN="THORCHAIN";L.THORCHAIN_STREAMING="THORCHAIN_STREAMING";L.TRADERJOE_V2="TRADERJOE_V2";L.UNISWAP_V2="UNISWAP_V2";L.UNISWAP_V3="UNISWAP_V3";L.KADO="KADO";L.NEAR="NEAR"})(jn||={});var Un;((P)=>{P.LIQUIDITY="liquidity";P.NETWORK="network";P.INBOUND="inbound";P.OUTBOUND="outbound";P.AFFILIATE="affiliate";P.TAX="tax";P.PRIORITY="priority"})(Un||={});var Qn;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(Qn||={});var Jn;((o)=>{o.Approve="approve";o.CheckOnly="checkOnly"})(Jn||={});var xn;(($)=>{$.NAME_REGISTER="~";$.BOND="BOND";$.DEPOSIT="+";$.LEAVE="LEAVE";$.UNBOND="UNBOND";$.WITHDRAW="-";$.OPEN_LOAN="$+";$.CLOSE_LOAN="$-";$.RUNEPOOL_DEPOSIT="POOL+";$.RUNEPOOL_WITHDRAW="POOL-"})(xn||={});var E;((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"})(E||={});var zn;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(zn||={});var Bh={apis:{},chains:Object.values(X),wallets:Object.values(E),explorerUrls:e,nodeUrls:D,rpcUrls:K,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=cn.createStore((n)=>({...Bh,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||[])}))})),t={getState:Q.getState,get:(n)=>Q.getState()[n],set:(n)=>Q.getState().setConfig(n),setApiKey:(n,h)=>Q.getState().setApiKey(n,h),setEnv:(n,h)=>Q.getState().setEnv(n,h),setExplorerUrl:(n,h)=>Q.getState().setExplorerUrl(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 W={get:hn("GET"),post:hn("POST"),extend:(n)=>({get:hn("GET",n),post:hn("POST",n),extend:(h)=>W.extend({...n,...h})})};function hn(n,h={}){return async(o,T={})=>{let{searchParams:R,json:A,body:F,headers:P}={...h,...T},{swapKit:_}=t.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 U={...P,...x?{"Content-Type":"application/json"}:{},..._?{"x-api-key":_}:{}};try{let k=await fetch(I.toString(),{...T,method:n,body:$,headers:U});if(!k.ok){let c=await k.text();throw new Error(`${k.statusText}(${k.status}): ${c}`)}let S=await k.json();return T.onSuccess?.(S)||T.responseHandler?.(S)||S}catch(k){return T.onError?.(k)||console.error(k)}}}var Nh=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],Zn=["ARB","BASE","ETH","OP","MATIC"];async function $h({chain:n,to:h}){try{let{result:T}=await W.post(t.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||p[n]).toString())}catch(T){return console.error(T),p[n]}}async function Oh(n){if(n==="XRD")return p.XRD;try{let h=n.split("-")[1]?.toLowerCase(),{manager:o}=await W.post(`${t.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),p["XRD"]}}async function ph({chain:n,symbol:h}){if(Y.includes(h))return p[h];let o=h.split("-"),T=o.length===1?void 0:o[o.length-1]?.toLowerCase();return await(T?.startsWith("0x")?$h({chain:n,to:T}):p[n])}function Hn({chain:n,symbol:h}){return y.match(n).with(...Y,(o)=>ph({chain:o,symbol:h})).with("XRD",()=>Oh(h)).otherwise(()=>p[n])}function Lh({chain:n}){return J.from({chain:n})}function _n({chain:n,symbol:h}){return y.match(n).with(...Zn,()=>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}`===v(n).identifier).otherwise(()=>h===n)}var v=(n)=>{let h=p[n];return y.match(n.toUpperCase()).with(...Zn,(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(...Cn,"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:p.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:p.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:p.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:n,decimal:h}))};function on({chain:n,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return y.match(n).with("XRD",()=>h==="XRD"||`${n}.${h}`===v(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 m=(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 Mh(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 kh={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=kh;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 Ih(n){if(n<0)throw new M({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Sh(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 Gh(n,h){try{return n()}catch(o){if(h)throw new M(h,o);return console.error(o)}}function Xh(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Yn=new Set;function a(n,h){if(n){if(Yn.has(h))return;Yn.add(h),console.warn(h)}}async function gh(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let h=t.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await W.get(`${h}/status`)).result.node_info.network}catch(h){return n}}var Vn=require("ts-pattern"),th=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function Bn(n){let h=n||th,o={};for(let T of h){let R=await jh(T);o[T]=R}return o}async function jh(n){let{list:h}=await Vn.match(n).with("camelot",()=>import("./chunk-bz1hfk9z.js")).with("caviar",()=>import("./chunk-8pft100q.js")).with("chainflip",()=>import("./chunk-qr6hqr2f.js")).with("jupiter",()=>import("./chunk-509k5s4y.js")).with("mayachain",()=>import("./chunk-s3f27t8q.js")).with("oneinch",()=>import("./chunk-mjavf655.js")).with("openocean",()=>import("./chunk-a6bjd9ar.js")).with("pancakeswap",()=>import("./chunk-j2emm8jm.js")).with("pangolin",()=>import("./chunk-z80467hm.js")).with("sushiswap",()=>import("./chunk-abwjsvdg.js")).with("thorchain",()=>import("./chunk-zsakm9d3.js")).with("traderjoe",()=>import("./chunk-cs1sv94g.js")).with("uniswap",()=>import("./chunk-rqj9janq.js")).with("uniswapv3",()=>import("./chunk-hqs6577q.js")).exhaustive();return h}var Wn=["TERRA",...t.get("chains")];function Nn(n=""){let h=n.toUpperCase(),[o]=h.split(".");if(Wn.includes(o))return!0;let[T]=h.split("/");if(Wn.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 Uh(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var On=require("ethers");var s=8,u=(n)=>10n**BigInt(n),i=(n)=>Math.log10(Number.parseFloat(n.toString()));function w({value:n,bigIntDecimal:h=s,decimal:o=s}){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 z{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new z({decimal:h,value:w({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:o}){return z.fromBigInt(n.getBaseValue("bigint")*u(o)/u(h),o)}constructor(n){let h=$n(n),o=typeof n==="object";this.decimal=o?n.decimal:void 0,this.decimalMultiplier=o&&"decimalMultiplier"in n?n.decimalMultiplier:u(Math.max(un(Tn(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||i(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/u(h||this.decimal||p.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=$n(n),T=Tn(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||s,T=Math.max(o,i(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,i(this.decimalMultiplier)),R=u(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=w({bigIntDecimal:T,decimal:T,value:A});return new this.constructor({decimalMultiplier:u(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=Tn(n)||"0";this.bigIntValue=this.#T(h)}#o(...n){let h=n.map((o)=>{return typeof o==="object"?o.decimal||i(o.decimalMultiplier):un(Tn(o))}).filter(Boolean);return Math.max(...h,s)}#T(n,h){let o=h?u(h):this.decimalMultiplier,T=i(o),[R="",A=""]=n.split(".");return BigInt(`${R}${A.padEnd(T,"0")}`)}}var Qh=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function Tn(n){let o=`${typeof n==="number"?Qh.format(n):$n(n)}`.replaceAll(",",".").split(".");return o.length>1?`${o.slice(0,-1).join("")}.${o.at(-1)}`:o[0]||"0"}function un(n){let h=n.split(".")[1]?.length||0;return Math.max(h,s)}function $n(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var f=new Map;class J extends z{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=on(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=An[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 J.from({asset:A,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:o,...T}){let R=n instanceof z?n.getValue("string"):n,A=Yh(T),{identifier:F,decimal:P}=v(A),{chain:_,isSynthetic:x,isTradeAsset:$}=pn(F),I=f.get(_==="SOL"?F:F.toUpperCase()),U=I?.decimal||P;a(!(o||U),`Couldn't find static decimal for one or more tokens on ${_} (Using default ${p[_]} decimal as fallback).
|
|
1
|
+
var $R={};PR($R,{wrapWithThrow:()=>Zh,wrapMethodWithNetworkSwitch:()=>yC,warnOnce:()=>u,validateTNS:()=>Uh,validateIdentifier:()=>EC,updateDerivationPath:()=>s,switchEVMWalletNetwork:()=>gC,providerRequest:()=>GC,prepareNetworkSwitch:()=>lh,okxMobileEnabled:()=>fC,loadTokenLists:()=>$C,listWeb3EVMWallets:()=>oC,isWeb3Detected:()=>ah,isGasAsset:()=>HC,isDetected:()=>ih,initializeRPCUrlsWithFallback:()=>hh,getWalletFormatFor:()=>Bh,getTHORNameCost:()=>zh,getSymmetricWithdraw:()=>bh,getSymmetricPoolShare:()=>IC,getMinAmountByChain:()=>Wh,getMemoForWithdraw:()=>ch,getMemoForUnbond:()=>nh,getMemoForRunePoolWithdraw:()=>mh,getMemoForRunePoolDeposit:()=>fh,getMemoForNameRegister:()=>uh,getMemoForNamePreferredAssetRegister:()=>th,getMemoForLeaveAndBond:()=>yh,getMemoForDeposit:()=>vh,getMAYANameCost:()=>Fh,getLiquiditySlippage:()=>gh,getGasAsset:()=>Lh,getEstimatedPoolShare:()=>oh,getETHDefaultWallet:()=>CR,getEIP6963Wallets:()=>hR,getDynamicChainId:()=>Jh,getDerivationPathFor:()=>xh,getDecimal:()=>BC,getCommonAssetInfo:()=>c,getChainIdentifier:()=>Qh,getAsymmetricRuneWithdrawAmount:()=>Dh,getAsymmetricRuneShare:()=>KC,getAsymmetricAssetWithdrawAmount:()=>Ih,getAsymmetricAssetShare:()=>DC,getAssetType:()=>e,formatBigIntToSafeValue:()=>D,findAssetBy:()=>Nh,filterSupportedChains:()=>sh,derivationPathToString:()=>_C,createWallet:()=>RR,createPlugin:()=>dh,assetFromString:()=>m,addEVMWalletNetwork:()=>nC,addAccountsChangedCallback:()=>eh,WarningCodeEnum:()=>xR,WalletOption:()=>f,UTXOChains:()=>RC,TCSupportedChains:()=>iC,SwapKitNumber:()=>U,SwapKitError:()=>j,SubstrateChains:()=>rC,StagenetChain:()=>d,SWAP_OUT:()=>_h,SWAP_IN:()=>Ph,SKConfig:()=>Y,RequestClient:()=>V,RPC_URLS:()=>n,QuoteMode:()=>QC,ProviderName:()=>BR,NetworkDerivationPath:()=>p,NODE_URLS:()=>g,MemoType:()=>xC,MAYASupportedChains:()=>sC,LedgerErrorCode:()=>UC,FeeTypeEnum:()=>HR,FeeOption:()=>MC,FALLBACK_URLS:()=>FC,ErrorCode:()=>_R,EXPLORER_URLS:()=>i,EVMChains:()=>S,DerivationPath:()=>Hh,CosmosChains:()=>dC,CosmosChainPrefixes:()=>aC,ContractAddress:()=>JC,CommonAssetStrings:()=>Ah,ChainToHexChainId:()=>PC,ChainToExplorerUrl:()=>Rh,ChainToChainId:()=>TC,ChainIdToChain:()=>mC,ChainId:()=>y,Chain:()=>F,BlockTimes:()=>tC,BigIntArithmetics:()=>W,BaseDecimal:()=>G,AssetValue:()=>q,ApproveMode:()=>YC,AGG_SWAP:()=>Th});module.exports=TR($R);var AC=require("ethers"),VC=require("ts-pattern");var zC=require("ts-pattern");var cC={core_estimated_max_spendable_chain_not_supported:10001,core_extend_error:10002,core_inbound_data_not_found:10003,core_approve_asset_address_or_from_not_found:10004,core_plugin_not_found:10005,core_plugin_swap_not_found:10006,core_approve_asset_target_invalid:10007,core_explorer_unsupported_chain:10008,core_verify_message_not_supported:10009,core_chain_halted:10010,core_wallet_connection_not_found:10101,core_wallet_ctrl_not_installed:10102,core_wallet_evmwallet_not_installed:10103,core_wallet_walletconnect_not_installed:10104,core_wallet_keystore_not_installed:10105,core_wallet_ledger_not_installed:10106,core_wallet_trezor_not_installed:10107,core_wallet_keplr_not_installed:10108,core_wallet_okx_not_installed:10109,core_wallet_keepkey_not_installed:10110,core_wallet_talisman_not_installed:10111,core_wallet_not_keypair_wallet:10112,core_wallet_sign_message_not_supported:10113,core_wallet_connection_failed:10114,core_swap_invalid_params:10201,core_swap_route_not_complete:10202,core_swap_asset_not_recognized:10203,core_swap_contract_not_found:10204,core_swap_route_transaction_not_found:10205,core_swap_contract_not_supported:10206,core_swap_transaction_error:10207,core_swap_quote_mode_not_supported:10208,core_transaction_deposit_error:10301,core_transaction_create_liquidity_base_error:10302,core_transaction_create_liquidity_asset_error:10303,core_transaction_create_liquidity_invalid_params:10304,core_transaction_add_liquidity_invalid_params:10305,core_transaction_add_liquidity_base_address:10306,core_transaction_add_liquidity_base_error:10307,core_transaction_add_liquidity_asset_error:10308,core_transaction_withdraw_error:10309,core_transaction_deposit_to_pool_error:10310,core_transaction_deposit_insufficient_funds_error:10311,core_transaction_deposit_gas_error:10312,core_transaction_invalid_sender_address:10313,core_transaction_deposit_server_error:10314,core_transaction_user_rejected:10315,core_transaction_failed:10316,core_transaction_invalid_recipient_address:10317,wallet_connection_rejected_by_user:20001,wallet_missing_api_key:20002,wallet_chain_not_supported:20003,wallet_missing_params:20004,wallet_provider_not_found:20005,wallet_failed_to_add_or_switch_network:20006,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_ledger_transport_error:20106,wallet_ledger_public_key_error:20107,wallet_ledger_derivation_path_error:20108,wallet_ledger_signing_error:20109,wallet_ledger_app_not_open:20110,wallet_ledger_invalid_response:20111,wallet_ledger_method_not_supported:20112,wallet_ledger_invalid_params:20113,wallet_ledger_invalid_signature:20114,wallet_ledger_no_provider:20115,wallet_ledger_pubkey_not_found:20116,wallet_ledger_transport_not_defined:20117,wallet_ledger_webusb_not_supported:20118,wallet_ledger_chain_not_supported:20119,wallet_ledger_invalid_asset:20120,wallet_ledger_invalid_account:20121,wallet_ledger_address_not_found:20122,wallet_ledger_failed_to_get_address:20123,wallet_phantom_not_found:20201,wallet_ctrl_not_found:20301,wallet_ctrl_send_transaction_no_address:20302,wallet_ctrl_contract_address_not_provided:20303,wallet_ctrl_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_walletconnect_chain_not_supported:20404,wallet_walletconnect_invalid_method:20405,wallet_walletconnect_method_not_supported:20406,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_trezor_transport_error:20504,wallet_trezor_method_not_supported:20505,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,wallet_polkadot_not_found:20701,wallet_radix_not_found:20801,wallet_radix_transaction_failed:20802,wallet_radix_invalid_manifest:20803,wallet_radix_method_not_supported:20804,wallet_radix_no_account:20805,wallet_keepkey_not_found:20901,wallet_keepkey_asset_not_defined:20902,wallet_keepkey_contract_address_not_provided:20903,wallet_keepkey_send_transaction_no_address:20904,wallet_keepkey_derivation_path_error:20905,wallet_keepkey_signing_error:20906,wallet_keepkey_transport_error:20907,wallet_keepkey_unsupported_chain:20908,wallet_keepkey_invalid_response:20909,wallet_keepkey_chain_not_supported:20910,wallet_keepkey_signer_not_found:20911,wallet_keepkey_no_accounts:20912,wallet_keepkey_method_not_supported:20913,wallet_keepkey_invalid_params:20914,wallet_keepkey_config_not_found:20915,wallet_keepkey_no_provider:20916,wallet_keepkey_account_not_found:20917,wallet_bitkeep_not_found:21001,wallet_bitkeep_failed_to_switch_network:21002,wallet_bitkeep_no_accounts:21003,wallet_exodus_sign_transaction_error:21101,wallet_exodus_not_found:21102,wallet_exodus_no_address:21103,wallet_exodus_request_canceled:21104,wallet_exodus_signature_canceled:21105,wallet_exodus_failed_to_switch_network:21106,wallet_exodus_chain_not_supported:21107,wallet_exodus_instance_missing:21108,wallet_onekey_not_found:21201,wallet_onekey_sign_transaction_error:21202,wallet_okx_not_found:21301,wallet_okx_chain_not_supported:21302,wallet_okx_failed_to_switch_network:21303,wallet_okx_no_accounts:21304,wallet_keplr_not_found:21401,wallet_keplr_chain_not_supported:21402,wallet_keplr_signer_not_found:21403,wallet_keplr_no_accounts:21404,wallet_cosmostation_not_found:21501,wallet_cosmostation_chain_not_supported:21502,wallet_cosmostation_evm_provider_not_found:21503,wallet_cosmostation_keplr_provider_not_found:21504,wallet_cosmostation_no_accounts:21505,wallet_cosmostation_no_evm_accounts:21506,wallet_cosmostation_no_evm_address:21507,wallet_cosmostation_signer_not_found:21508,wallet_xdefi_not_found:21601,wallet_xdefi_chain_not_supported:21602,wallet_coinbase_not_found:21701,wallet_coinbase_chain_not_supported:21702,wallet_coinbase_method_not_supported:21703,wallet_coinbase_no_accounts:21704,wallet_evm_extensions_failed_to_switch_network:21801,wallet_evm_extensions_no_provider:21802,wallet_evm_extensions_not_found:21803,wallet_keystore_invalid_password:21901,wallet_keystore_unsupported_version:21902,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30101,chainflip_broker_recipient_error:30102,chainflip_broker_register:30103,chainflip_broker_tx_error:30104,chainflip_broker_withdraw:30105,chainflip_broker_fund_only_flip_supported:30106,chainflip_broker_fund_invalid_address:30107,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40101,thorchain_swapin_vault_required:40102,thorchain_swapin_memo_required:40103,thorchain_swapin_token_required:40104,thorchain_preferred_asset_payout_required:40105,toolbox_cosmos_account_not_found:50101,toolbox_cosmos_invalid_fee:50102,toolbox_cosmos_invalid_params:50103,toolbox_cosmos_no_signer:50104,toolbox_cosmos_not_supported:50105,toolbox_cosmos_signer_not_defined:50106,toolbox_cosmos_validate_address_prefix_not_found:50107,toolbox_cosmos_verify_signature_no_pubkey:50108,toolbox_evm_error_estimating_gas_limit:50201,toolbox_evm_error_sending_transaction:50202,toolbox_evm_gas_estimation_error:50203,toolbox_evm_invalid_gas_asset_address:50204,toolbox_evm_invalid_params:50205,toolbox_evm_invalid_transaction:50206,toolbox_evm_no_abi_fragment:50207,toolbox_evm_no_contract_address:50208,toolbox_evm_no_fee_data:50209,toolbox_evm_no_from_address:50210,toolbox_evm_no_gas_price:50211,toolbox_evm_no_signer_address:50212,toolbox_evm_no_signer:50213,toolbox_evm_no_to_address:50214,toolbox_evm_not_supported:50215,toolbox_evm_provider_not_eip1193_compatible:50216,toolbox_utxo_api_error:50301,toolbox_utxo_broadcast_failed:50302,toolbox_utxo_insufficient_balance:50303,toolbox_utxo_invalid_address:50304,toolbox_utxo_invalid_params:50305,toolbox_utxo_invalid_transaction:50306,toolbox_utxo_no_signer:50307,toolbox_utxo_not_supported:50308,toolbox_solana_no_signer:50401,toolbox_solana_fee_estimation_failed:50402,toolbox_substrate_not_supported:50501,toolbox_radix_method_not_supported:50601,toolbox_ripple_get_balance_error:50701,toolbox_ripple_rpc_not_configured:50702,toolbox_ripple_signer_not_found:50703,toolbox_ripple_asset_not_supported:50704,toolbox_ripple_broadcast_error:50705,toolbox_tron_no_signer:50801,toolbox_tron_invalid_token_identifier:50802,toolbox_tron_token_transfer_failed:50803,toolbox_not_supported:50801,api_v2_invalid_response:60001,api_v2_server_error:60002,api_v2_invalid_method_key_hash:60003,helpers_invalid_number_different_decimals:70001,helpers_invalid_number_of_years:70002,helpers_invalid_identifier:70003,helpers_invalid_asset_url:70004,helpers_invalid_asset_identifier:70005,helpers_invalid_memo_type:70006,helpers_failed_to_switch_network:70007,helpers_not_found_provider:70008,helpers_chain_not_supported:70009,helpers_invalid_params:70010,helpers_invalid_response:70011,not_implemented:99999};class j extends Error{static ErrorCode=cC;constructor(C,h){let R=typeof C==="string",T=R?C:C.errorKey,P=R?void 0:C.info,_=`${T}${P?`: ${JSON.stringify(P)}`:""}`;super(_);if(Object.setPrototypeOf(this,j.prototype),this.name="SwapKitError",this.cause=h,h)console.error(`SwapKitError [${T}]:`,h);else if(P)console.error(`SwapKitError [${T}]:`,P)}}var F;((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";O.Tron="TRX"})(F||={});var d;((R)=>{R.THORChain="THOR_STAGENET";R.Maya="MAYA_STAGENET"})(d||={});var y;((E)=>{E.Arbitrum="42161";E.ArbitrumHex="0xa4b1";E.Avalanche="43114";E.AvalancheHex="0xa86a";E.Base="8453";E.BaseHex="0x2105";E.BinanceSmartChain="56";E.BinanceSmartChainHex="0x38";E.Bitcoin="bitcoin";E.BitcoinCash="bitcoincash";E.Chainflip="chainflip";E.Cosmos="cosmoshub-4";E.Dash="dash";E.Dogecoin="dogecoin";E.Kujira="kaiyo-1";E.Ethereum="1";E.EthereumHex="0x1";E.Fiat="fiat";E.Litecoin="litecoin";E.Maya="mayachain-mainnet-v1";E.MayaStagenet="mayachain-stagenet-v1";E.Near="near";E.Optimism="10";E.OptimismHex="0xa";E.Polkadot="polkadot";E.Polygon="137";E.PolygonHex="0x89";E.Radix="radix-mainnet";E.Ripple="ripple";E.THORChain="thorchain-1";E.THORChainStagenet="thorchain-stagenet-v2";E.Solana="solana";E.Tron="tron"})(y||={});var mC={["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",["tron"]:"TRX"},uC=Object.keys(F),a=Object.values(F),G={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,TRX:6,XRD:18,XRP:6},tC={["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,["TRX"]:3},rC=["DOT","FLIP"],S=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],RC=["BTC","BCH","DASH","DOGE","LTC"],dC=["GAIA","THOR","MAYA","KUJI"],aC={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},iC=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],sC=["ARB","DASH","ETH","KUJI","MAYA","THOR"],n={["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",["TRX"]:"https://api.trongrid.io",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com"},g={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},FC={["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",g.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"],["TRX"]:["https://api.tronstack.io","https://api.tron.network"]},i={["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",["TRX"]:"https://tronscan.org"},LC=n,lC=(C)=>{return zC.match(C).with("ARB","AVAX","BASE","BSC","ETH","OP","MATIC","TRX",()=>({id:1,jsonrpc:"2.0",method:"eth_blockNumber",params:[]})).with("BTC","DOGE","BCH","DASH","LTC",()=>({id:"test",jsonrpc:"1.0",method:"getblockchaininfo",params:[]})).with("GAIA","KUJI","MAYA","THOR","MAYA_STAGENET","THOR_STAGENET",()=>({id:1,jsonrpc:"2.0",method:"status",params:{}})).with("DOT",()=>({id:1,jsonrpc:"2.0",method:"system_health",params:[]})).with("SOL",()=>({id:1,jsonrpc:"2.0",method:"getHealth"})).with("XRD",()=>"").otherwise(()=>{throw new j("helpers_chain_not_supported",{chain:C})})};function eC(C){return C==="XRD"?"/status/network-configuration":""}var NC=async(C,h)=>{try{let R=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${R}${eC(C)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(lC(C)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},Ch=async(C)=>{let h=n[C];if(await NC(C,h))return h;for(let R of FC[C])if(await NC(C,R))return R;return h},hh=async(C=[...Object.values(F),...Object.values(d)])=>{let h={};await Promise.all(C.map(async(R)=>{let T=await Ch(R);h[R]=T})),LC={...LC,...h}},ZC=a.reduce((C,h)=>{let R=uC.find((T)=>F[T]===h);if(R)C[h]=R;return C},{}),TC=a.reduce((C,h)=>{return C[h]=y[ZC[h]],C},{}),PC=a.reduce((C,h)=>{let R=`${ZC[h]}Hex`;return C[h]=y[R],C},{}),Rh=a.reduce((C,h)=>{return C[h]=i[h],C},{});var v=require("ts-pattern");var kC=require("zustand/vanilla");var QC;((X)=>{X.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";X.TC_SUPPORTED_TO_ETH="TC-ERC20";X.TC_SUPPORTED_TO_AVAX="TC-ARC20";X.TC_SUPPORTED_TO_BSC="TC-BEP20";X.ETH_TO_TC_SUPPORTED="ERC20-TC";X.ETH_TO_ETH="ERC20-ERC20";X.ETH_TO_AVAX="ERC20-ARC20";X.ETH_TO_BSC="ERC20-BEP20";X.AVAX_TO_TC_SUPPORTED="ARC20-TC";X.AVAX_TO_ETH="ARC20-ERC20";X.AVAX_TO_AVAX="ARC20-ARC20";X.AVAX_TO_BSC="ARC20-BEP20";X.BSC_TO_TC_SUPPORTED="BEP20-TC";X.BSC_TO_ETH="BEP20-ERC20";X.BSC_TO_AVAX="BEP20-ARC20";X.BSC_TO_BSC="BEP20-BEP20"})(QC||={});var Th=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Ph=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],_h=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];function s(C,h){if("index"in h)return[...C.slice(0,C.length-1),h.index];if("change"in h){let[R,T,P,,_]=C;return[R,T,P,h.change,_]}if("account"in h){let[R,T,,P,_]=C;return[R,T,h.account,P,_]}return C}function _C([C,h,R,T,P]){return`m/${C}'/${h}'/${R}'/${T}${typeof P!=="number"?"":`/${P}`}`}function xh({chain:C,index:h,addressIndex:R=0,type:T}){if(S.includes(C)){if(T&&["legacy","account"].includes(T))return[44,60,0,h];if(T==="ledgerLive")return[44,60,h,0,R];return s(p[C],{index:h})}if(C==="SOL"){if(T==="account")return[44,501,0,h];return s(p[C],{index:h})}let P=C==="LTC"?2:0;switch(T){case"nativeSegwitMiddleAccount":return[84,P,h,0,R];case"segwit":return[49,P,0,0,h];case"legacy":return[44,P,0,0,h];default:return s(p[C],{index:h})}}function Bh(C){let[h,R,T]=C.split("/").map((P)=>Number.parseInt(P,10));switch(R){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var JC;((x)=>{x.ARB="0x0000000000000000000000000000000000000000";x.AVAX="0x0000000000000000000000000000000000000000";x.BASE="0x0000000000000000000000000000000000000000";x.ETH="0x0000000000000000000000000000000000000000";x.BSC="0x0000000000000000000000000000000000000000";x.MATIC="0x0000000000000000000000000000000000001010";x.OP="0x4200000000000000000000000000000000000042"})(JC||={});var p={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],TRX:[44,195,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]},Hh=Object.keys(p).reduce((C,h)=>{return C[h]=_C(p[h]),C},{});var MC;((T)=>{T.Average="average";T.Fast="fast";T.Fastest="fastest"})(MC||={});var YC;((R)=>{R.Approve="approve";R.CheckOnly="checkOnly"})(YC||={});var xC;((H)=>{H.NAME_REGISTER="~";H.BOND="BOND";H.DEPOSIT="+";H.LEAVE="LEAVE";H.UNBOND="UNBOND";H.WITHDRAW="-";H.RUNEPOOL_DEPOSIT="POOL+";H.RUNEPOOL_WITHDRAW="POOL-"})(xC||={});var f;((A)=>{A.BITGET="BITGET";A.BRAVE="BRAVE";A.COINBASE_MOBILE="COINBASE_MOBILE";A.COINBASE_WEB="COINBASE_WEB";A.COSMOSTATION="COSMOSTATION";A.CTRL="CTRL";A.EIP6963="EIP6963";A.EXODUS="EXODUS";A.KEEPKEY="KEEPKEY";A.KEEPKEY_BEX="KEEPKEY_BEX";A.KEPLR="KEPLR";A.KEYSTORE="KEYSTORE";A.LEAP="LEAP";A.LEDGER="LEDGER";A.LEDGER_LIVE="LEDGER_LIVE";A.METAMASK="METAMASK";A.OKX="OKX";A.OKX_MOBILE="OKX_MOBILE";A.ONEKEY="ONEKEY";A.PHANTOM="PHANTOM";A.POLKADOT_JS="POLKADOT_JS";A.RADIX_WALLET="RADIX_WALLET";A.TREZOR="TREZOR";A.TALISMAN="TALISMAN";A.TRUSTWALLET_WEB="TRUSTWALLET_WEB";A.WALLETCONNECT="WALLETCONNECT"})(f||={});var UC;((T)=>{T[T.NoError=36864]="NoError";T[T.LockedDevice=21781]="LockedDevice";T[T.TC_NotFound=65535]="TC_NotFound"})(UC||={});var $h={apis:{},chains:Object.values(F),wallets:Object.values(f),explorerUrls:i,nodeUrls:g,rpcUrls:n,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"}}}},k=kC.createStore((C)=>({...$h,setApiKey:(h,R)=>C((T)=>({apiKeys:{...T.apiKeys,[h]:R}})),setEnv:(h,R)=>C((T)=>({envs:{...T.envs,[h]:R}})),setExplorerUrl:(h,R)=>C((T)=>({explorerUrls:{...T.explorerUrls,[h]:R}})),setNodeUrl:(h,R)=>C((T)=>({nodeUrls:{...T.nodeUrls,[h]:R}})),setRpcUrl:(h,R)=>C((T)=>({rpcUrls:{...T.rpcUrls,[h]:R}})),setIntegrationConfig:(h,R)=>C((T)=>({integrations:{...T.integrations,[h]:R}})),setConfig:(h)=>C((R)=>({apiKeys:{...R.apiKeys,...h.apiKeys},envs:{...R.envs,...h.envs},explorerUrls:{...R.explorerUrls,...h.explorerUrls},integrations:{...R.integrations,...h.integrations},nodeUrls:{...R.nodeUrls,...h.nodeUrls},rpcUrls:{...R.rpcUrls,...h.rpcUrls},chains:R.chains.concat(h.chains||[]),wallets:R.wallets.concat(h.wallets||[])}))})),Y={getState:k.getState,get:(C)=>k.getState()[C],set:(C)=>k.getState().setConfig(C),setApiKey:(C,h)=>k.getState().setApiKey(C,h),setEnv:(C,h)=>k.getState().setEnv(C,h),setExplorerUrl:(C,h)=>k.getState().setExplorerUrl(C,h),setNodeUrl:(C,h)=>k.getState().setNodeUrl(C,h),setRpcUrl:(C,h)=>k.getState().setRpcUrl(C,h),setIntegrationConfig:(C,h)=>k.getState().setIntegrationConfig(C,h)};var V={get:l("GET"),post:l("POST"),extend:(C)=>({get:l("GET",C),post:l("POST",C),extend:(h)=>V.extend({...C,...h})})};function l(C,h={}){return async(R,T={})=>{let{searchParams:P,json:_,body:B,headers:x}={...h,...T},H=!!_||R.endsWith(".json"),$=H?JSON.stringify(_):B;try{let L=Xh(R,P),N=Eh(H,x),Z=await fetch(L,{...T,method:C,body:$,headers:N});if(!Z.ok){let Q=await Z.text();throw new j("helpers_invalid_response",{status:Z.status,statusText:Z.statusText,message:Q})}let M=await Z.json();return T.onSuccess?.(M)||T.responseHandler?.(M)||M}catch(L){if(T.onError)return T.onError(L);throw L}}}function Eh(C,h){let{swapKit:R}=Y.get("apiKeys");return{...h,...C?{"Content-Type":"application/json"}:{},...R?{"x-api-key":R}:{}}}function Xh(C,h){let R=new URL(C);if(h)R.search=new URLSearchParams(h).toString();return R.toString()}var Ah=[`${"MAYA"}.MAYA`,`${"MAYA"}.CACAO`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],qC=["ARB","BASE","ETH","OP","MATIC"];async function Oh({chain:C,to:h}){try{let{result:T}=await V.post(Y.get("rpcUrls")[C],{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||G[C]).toString())}catch(T){return console.error(`Failed to fetch contract decimals for ${h} on ${C}:`,T),G[C]}}async function jh(C){if(C==="XRD")return G.XRD;try{let h=C.split("-")[1]?.toLowerCase(),{manager:R}=await V.post(`${Y.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return R.divisibility.value.divisibility}catch(h){return console.error(`Failed to fetch Radix asset decimal for ${C}:`,h),G["XRD"]}}async function Gh({chain:C,symbol:h}){if(S.includes(h))return G[h];let R=h.split("-"),T=R.length===1?void 0:R[R.length-1]?.toLowerCase();return await(T?.startsWith("0x")?Oh({chain:C,to:T}):G[C])}function BC({chain:C,symbol:h}){return v.match(C).with(...S,(R)=>Gh({chain:R,symbol:h})).with("XRD",()=>jh(h)).otherwise(()=>G[C])}function Lh({chain:C}){return q.from({chain:C})}function HC({chain:C,symbol:h}){return v.match(C).with(...qC,()=>h==="ETH").with("AVAX",()=>h==="AVAX").with("BSC",()=>h==="BNB").with("MAYA",()=>h==="CACAO").with("GAIA",()=>h==="ATOM").with("THOR",()=>h==="RUNE").with("XRD",()=>`${C}.${h}`===c(C).identifier).otherwise(()=>h===C)}var c=(C)=>{let h=G[C];return v.match(C.toUpperCase()).with(...qC,(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(...RC,"SOL","FLIP","KUJI","XRP","DOT","TRX",(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:G.ETH})).with("ETH.THOR",()=>({identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:G.ETH})).with("ETH.vTHOR",()=>({identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:G.ETH})).with("MAYA.CACAO",(T)=>({identifier:T,decimal:10})).with("MAYA.MAYA",(T)=>({identifier:T,decimal:4})).otherwise(()=>({identifier:C,decimal:h}))};function e({chain:C,symbol:h}){if(h.includes("/"))return"Synth";if(h.includes("~"))return"Trade";return v.match(C).with("XRD",()=>h==="XRD"||`${C}.${h}`===c(C).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===C)?"Native":C}var m=(C)=>{let[h,...R]=C.split("."),T=C.includes("/"),P=R.join("."),_=P?.split("-"),B=_?.length?_.length===1?_[0]:_.slice(0,-1).join("-"):void 0;return{chain:h,symbol:P,ticker:B,synth:T}};async function Nh(C){let{tokenLists:h}=await import("@swapkit/helpers/tokens");for(let R of Object.values(h))for(let{identifier:T,chain:P,..._}of R.tokens){if("identifier"in C&&T===C.identifier)return T;if("address"in _&&"chain"in C&&P===C.chain&&_.address.toLowerCase()===C.contract.toLowerCase())return T}return}function zh(C){if(C<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return 10+C}function Fh(C){if(C<0)throw new j({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:C}});return Math.round((10+C*1.0512)*10000000000)/10000000000}function Zh(C,h){try{return C()}catch(R){if(h)throw new j(h,R);return}}function Qh(C){switch(C){case"THOR":return`${C}.RUNE`;case"GAIA":return`${C}.ATOM`;case"BSC":return`${C}`;default:return`${C}.${C}`}}var WC=new Set;function u(C,h){if(C){if(WC.has(h))return;WC.add(h)}}async function Jh(C="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(C))return C;try{let h=Y.get("rpcUrls")[C!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await V.get(`${h}/status`)).result.node_info.network}catch(h){return C}}var wC=require("ts-pattern"),Mh=["camelot","caviar","chainflip","jupiter","mayachain","oneinch","openocean","pancakeswap","pangolin","sushiswap","thorchain","traderjoe","uniswap","uniswapv3"];async function $C(C){let h=C||Mh,R={};for(let T of h){let P=await Yh(T);R[T]=P}return R}async function Yh(C){let{list:h}=await wC.match(C).with("camelot",()=>import("./chunk-bz1hfk9z.js")).with("caviar",()=>import("./chunk-8pft100q.js")).with("chainflip",()=>import("./chunk-qr6hqr2f.js")).with("jupiter",()=>import("./chunk-509k5s4y.js")).with("mayachain",()=>import("./chunk-s3f27t8q.js")).with("oneinch",()=>import("./chunk-mjavf655.js")).with("openocean",()=>import("./chunk-a6bjd9ar.js")).with("pancakeswap",()=>import("./chunk-j2emm8jm.js")).with("pangolin",()=>import("./chunk-z80467hm.js")).with("sushiswap",()=>import("./chunk-abwjsvdg.js")).with("thorchain",()=>import("./chunk-zsakm9d3.js")).with("traderjoe",()=>import("./chunk-cs1sv94g.js")).with("uniswap",()=>import("./chunk-rqj9janq.js")).with("uniswapv3",()=>import("./chunk-hqs6577q.js")).exhaustive();return h}var SC=["TERRA",...Y.get("chains")];function EC(C=""){let h=C.toUpperCase(),[R]=h.split(".");if(SC.includes(R))return!0;let[T]=h.split("/");if(SC.includes(T))return!0;throw new j({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${C}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:C}})}function Uh(C){if(C.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!C.match(h)}var r=8,K=(C)=>10n**BigInt(C),t=(C)=>Math.log10(Number.parseFloat(C.toString()));function D({value:C,bigIntDecimal:h=r,decimal:R=r}){if(R===0)return C.toString();let T=C<0n,P=C.toString().substring(T?1:0),_=R-(P.length-1);if(_>0)P="0".repeat(_)+P;let B=P.length-R,x=P.slice(-R);if(Number.parseInt(x[h]||"0")>=5)x=`${x.substring(0,h-1)}${(Number.parseInt(x[h-1]||"0")+1).toString()}`;else x=x.substring(0,h);return`${T?"-":""}${P.slice(0,B)}.${x}`.replace(/\.?0*$/,"")}function kh(C,h){if(h===0n)throw new Error("Cannot divide by zero");let R=h/2n;if(C>=0n&&h>=0n||C<0n&&h<0n)return(C+R)/h;return(C-R)/h}class W{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(C,h){return new W({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:C,from:h,to:R}){return W.fromBigInt(C.getBaseValue("bigint")*K(R)/K(h),R)}constructor(C){let h=XC(C),R=typeof C==="object";this.decimal=R?C.decimal:void 0,this.decimalMultiplier=R&&"decimalMultiplier"in C?C.decimalMultiplier:K(Math.max(pC(CC(h)),this.decimal||0)),this.#P(h)}set(C){return new this.constructor({decimal:this.decimal,value:C,identifier:this.toString({includeSynthProtocol:!0})})}add(...C){return this.#h("add",...C)}sub(...C){return this.#h("sub",...C)}mul(...C){return this.#h("mul",...C)}div(...C){return this.#h("div",...C)}gt(C){return this.#C("gt",C)}gte(C){return this.#C("gte",C)}lt(C){return this.#C("lt",C)}lte(C){return this.#C("lte",C)}eqValue(C){return this.#C("eqValue",C)}getValue(C,h){let R=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||t(this.decimalMultiplier));switch(C){case"number":return Number(R);case"string":return R;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier;default:return R}}getBaseValue(C,h){let R=this.decimalMultiplier/K(h||this.decimal||G.THOR),T=kh(this.bigIntValue,R);switch(C){case"number":return Number(T);case"string":return T.toString();case"bigint":return T;default:return T}}getBigIntValue(C,h){if(!h&&typeof C==="object")return C.bigIntValue;let R=XC(C),T=CC(R);if(T==="0"||T==="undefined")return 0n;return this.#T(T,h)}toSignificant(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if((Number.parseInt(T)?T.length+P.length:P.length)<=C)return this.getValue("string");if(T.length>=C)return T.slice(0,C).padEnd(T.length,"0");if(Number.parseInt(T))return`${T}.${P.slice(0,C-T.length)}`.padEnd(C-T.length,"0");let B=Number.parseInt(P),x=`${B}`.slice(0,C);return`0.${x.padStart(P.length-`${B}`.length+x.length,"0")}`}toFixed(C=6){let[h,R]=this.getValue("string").split("."),T=h||"",P=R||"";if(Number.parseInt(T))return`${T}.${P.slice(0,C)}`.padEnd(C,"0");let _=Number.parseInt(P),B=`${_}`.slice(0,C);return`0.${B.padStart(P.length-`${_}`.length+B.length,"0")}`}toAbbreviation(C=2){let h=this.getValue("number"),R=["","K","M","B","T","Q","Qi","S"],T=Math.floor(Math.log10(Math.abs(h))/3),P=R[T];if(!P)return this.getValue("string");let _=10**(T*3);return`${(h/_).toFixed(C)}${P}`}toCurrency(C="$",{currencyPosition:h="start",decimal:R=2,decimalSeparator:T=".",thousandSeparator:P=","}={}){let _=this.getValue("number"),[B="",x=""]=_.toFixed(6).split("."),H=B.replace(/\B(?=(\d{3})+(?!\d))/g,P),$=B||x?B==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",T):`${H}${Number.parseInt(x)?`${T}${x.slice(0,R)}`:""}`:"0.00";return`${h==="start"?C:""}${$}${h==="end"?C:""}`}formatBigIntToSafeValue(C,h){let R=h||this.decimal||r,T=Math.max(R,t(this.decimalMultiplier)),P=C<0n,_=C.toString().substring(P?1:0),B=T-(_.length-1),x=B>0?"0".repeat(B)+_:_,H=x.length-T,$=x.slice(-T);if(Number.parseInt($[R]||"0")>=5)$=`${$.substring(0,R-1)}${(Number.parseInt($[R-1]||"0")+1).toString()}`;else $=$.substring(0,R);return`${P?"-":""}${x.slice(0,H)}.${$}`.replace(/\.?0*$/,"")}#h(C,...h){let R=this.#R(this,...h),T=Math.max(R,t(this.decimalMultiplier)),P=K(T),_=h.reduce((x,H)=>{let $=this.getBigIntValue(H,T);switch(C){case"add":return x+$;case"sub":return x-$;case"mul":return x*$/P;case"div":{if($===0n)throw new RangeError("Division by zero");return x*P/$}default:return x}},this.bigIntValue*P/this.decimalMultiplier),B=D({bigIntDecimal:T,decimal:T,value:_});return new this.constructor({decimalMultiplier:K(T),decimal:this.decimal,value:B,identifier:this.toString()})}#C(C,...h){let R=this.#R(this,...h),T=this.getBigIntValue(h[0]||"0",R),P=this.getBigIntValue(this,R);switch(C){case"gt":return P>T;case"gte":return P>=T;case"lt":return P<T;case"lte":return P<=T;case"eqValue":return P===T;default:return!1}}#P(C){let h=CC(C)||"0";this.bigIntValue=this.#T(h)}#R(...C){let h=C.map((R)=>{return typeof R==="object"?R.decimal||t(R.decimalMultiplier):pC(CC(R))}).filter(Boolean);return Math.max(...h,r)}#T(C,h){let R=h?K(h):this.decimalMultiplier,T=t(R),[P="",_=""]=C.split(".");return BigInt(`${P}${_.padEnd(T,"0")}`)}}var qh=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function CC(C){let R=`${typeof C==="number"?qh.format(C):XC(C)}`.replaceAll(",",".").split(".");return R.length>1?`${R.slice(0,-1).join("")}.${R.at(-1)}`:R[0]||"0"}function pC(C){let h=C.split(".")[1]?.length||0;return Math.max(h,r)}function XC(C){return typeof C==="object"?"getValue"in C?C.getValue("string"):C.value:C}var b=new Map;class q extends W{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:C,decimal:h,tax:R,chain:T,symbol:P,identifier:_}){super(typeof C==="object"?C:{decimal:h,value:C});let B=OC(_||`${T}.${P}`);this.type=e(B),this.tax=R,this.chain=B.chain,this.ticker=B.ticker,this.symbol=B.symbol,this.address=B.address,this.isSynthetic=B.isSynthetic,this.isTradeAsset=B.isTradeAsset,this.isGasAsset=B.isGasAsset,this.chainId=TC[B.chain]}toString({includeSynthProtocol:C}={}){return(this.isSynthetic||this.isTradeAsset)&&!C?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:C,symbol:h}){return this.chain===C&&this.symbol===h}eq(C){return this.eqAsset(C)&&this.eqValue(C)}static fromUrl(C,h=0){let[R,T,P]=C.split(".");if(!(R&&T))throw new j({errorKey:"helpers_invalid_asset_url",info:{urlAsset:C}});let _=R==="THOR"&&P?`${R}.${T}/${P}`:C;return q.from({asset:_,value:h})}static from({value:C=0,fromBaseDecimal:h,asyncTokenLookup:R,...T}){let P=C instanceof W?C.getValue("string"):C,_=Vh(T),{identifier:B,decimal:x}=c(_),{chain:H,isSynthetic:$,isTradeAsset:L}=OC(B),N=b.get(H==="SOL"?B:B.toUpperCase()),Z=N?.decimal||x;u(!(R||Z),`Couldn't find static decimal for one or more tokens on ${H} (Using default ${G[H]} 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:
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:M,identifier:Q,tax:I}=N||{decimal:Z||G[H],identifier:B},X=$||L,w=h?hC(BigInt(P),h):hC(P,M);return R?wh(Q,h?w:P):X?Sh(Q,w):new q({tax:I,decimal:M,identifier:Q,value:w})}static async loadStaticAssets(C){let h=await $C(C);for(let{tokens:R}of Object.values(h))for(let{identifier:T,chain:P,..._}of R){let B=P==="SOL"?T:T.toUpperCase(),x="decimals"in _?_.decimals:G[P];b.set(B,{identifier:T,decimal:x})}return!0}static setStaticAssets(C){b.clear();for(let[h,R]of C.entries()){let T=R.chain==="SOL"?R.identifier:R.identifier.toUpperCase(),P="decimals"in R?R.decimals:R.decimal;b.set(h,{...R,decimal:P,identifier:T})}return!0}}function Wh(C){let h=q.from({chain:C});return VC.match(C).with("BTC","LTC","BCH","DASH",()=>h.set(0.00010001)).with("DOGE",()=>h.set(1.00000001)).with("AVAX","ETH","ARB","BSC",()=>h.set(0.00000001)).with("THOR","MAYA",()=>h.set(0)).with("GAIA","KUJI",()=>h.set(0.000001)).otherwise(()=>h.set(0.00000001))}async function wh(C,h=0){EC(C);let T=C.includes("SOL.")?C:C.toUpperCase(),P=b.get(T),_=P?.decimal||await BC(OC(C));if(!P)b.set(T,{identifier:C,decimal:_});return new q({decimal:_,value:hC(h,_),identifier:C})}function Sh(C,h=0){let R=C.includes(".")?C.split(".")?.[0]?.toUpperCase():void 0,T=R?["MAYA","THOR"].includes(R):!1,P=C.slice(0,14).includes("~")?"~":"/",[_,B]=T?C.split(".").slice(1).join().split(P):C.split(P);if(!(_&&B))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});return new q({decimal:8,value:hC(h,8),identifier:`${R||"THOR"}.${_}${P}${B}`})}function hC(C,h){return typeof C==="bigint"?D({value:C,bigIntDecimal:h,decimal:h}):C}function ph(C){let h="chain"in C?C.chain:m(C.asset).synth?"THOR":m(C.asset).chain;if(!Object.values(F).includes(h.toUpperCase()))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{message:"Please use the AssetValue constructor for unsupported chains"}})}function Vh(C){if(ph(C),"chain"in C)return C.chain;let{chain:h,symbol:R}=m(C.asset);return e({chain:h,symbol:R})==="Native"?h:C.asset}function OC(C){let h=C.slice(0,14),R=C.split("."),T=R[0]?.toUpperCase(),P=["THOR","MAYA"].includes(T),_=h.includes("/"),B=h.includes("~"),x=_||B,H=B?"~":"/",[$,L=""]=P?R.slice(1).join().split(H):C.split(H);if(x&&!($&&L))throw new j({errorKey:"helpers_invalid_asset_identifier",info:{identifier:C}});let[N,...Z]=(C.includes(".")&&!x?C:`${T}.${L}`).split("."),M=x?L:Z.join("."),{address:Q,ticker:I}=Kh({symbol:M,chain:N}),X;try{X=Q&&S.includes(N)&&AC.getAddress(Q)?AC.getAddress(Q):Q}catch(o){X=Q}let w=(x?`${$}${H}`:"")+(X?`${I}-${X??""}`:M);return{address:X,chain:N,isSynthOrTrade:x,isSynthetic:_,isTradeAsset:B,ticker:I,symbol:w,isGasAsset:HC({chain:N,symbol:M})}}function Kh({symbol:C,chain:h}){let R=C.split("-"),T=R.length===1?void 0:R[R.length-1],P=h==="SOL"?T:T?.toLowerCase(),_=R.length===1?R[0]:R.slice(0,-1).join("-");return{address:P,ticker:_}}class U extends W{eq(C){return this.eqValue(C)}static fromBigInt(C,h){return new U({decimal:h,value:D({value:C,bigIntDecimal:h,decimal:h})})}}function KC({liquidityUnits:C,poolUnits:h,runeDepth:R}){let T=J(C),P=J(h),_=J(R),B=T.mul(_),x=P.mul(P).mul(2),H=P.mul(T).mul(2),$=T.mul(T),L=P.mul(P).mul(P);return B.mul(x.sub(H).add($)).div(L)}function DC({liquidityUnits:C,poolUnits:h,assetDepth:R}){let T=J(C),P=J(h),_=J(R),B=T.mul(_),x=P.mul(P).mul(2),H=P.mul(T).mul(2),$=T.mul(T),L=B.mul(x.sub(H).add($)),N=P.mul(P).mul(P);return L.div(N)}function Dh({percent:C,runeDepth:h,liquidityUnits:R,poolUnits:T}){return KC({runeDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function Ih({percent:C,assetDepth:h,liquidityUnits:R,poolUnits:T}){return DC({assetDepth:h,liquidityUnits:R,poolUnits:T}).mul(C)}function J(C){return U.fromBigInt(BigInt(C),G.THOR)}function IC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T}){return{assetAmount:J(T).mul(C).div(h),runeAmount:J(R).mul(C).div(h)}}function bh({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T,percent:P}){return Object.fromEntries(Object.entries(IC({liquidityUnits:C,poolUnits:h,runeDepth:R,assetDepth:T})).map(([_,B])=>[_,B.mul(P)]))}function oh({runeDepth:C,poolUnits:h,assetDepth:R,liquidityUnits:T,runeAmount:P,assetAmount:_}){let B=new U({value:C,decimal:8}),x=new U({value:R,decimal:8}),H=new U({value:h,decimal:8}),$=new U({value:P,decimal:8}),L=new U({value:_,decimal:8}),N=$.mul(x),Z=L.mul(B),M=$.mul(L),Q=B.mul(x),I=H.mul(N.add(Z.add(M.mul(2)))),X=N.add(Z.add(Q.mul(2))),w=I.div(X),o=J(T).add(w);if(w.getBaseValue("number")===0)return o.div(H).getBaseValue("number");let vC=H.add(o);return o.div(vC).getBaseValue("number")}function gh({runeAmount:C,assetAmount:h,runeDepth:R,assetDepth:T}){if(C==="0"||h==="0"||R==="0"||T==="0")return 0;let P=J(R),_=J(T),B=J(h),x=J(C),H=B.mul(P).sub(_.mul(x)),$=_.mul(x).add(P.mul(_));return Math.abs(H.div($).getBaseValue("number"))}var bC=require("ts-pattern");function yh({type:C,address:h}){return`${C}:${h}`}function nh({address:C,unbondAmount:h}){return`${"UNBOND"}:${C}:${h}`}function fh(C){return jC("POOL+",C)}function vh({chain:C,symbol:h,address:R,...T}){let P=rh({chain:C,symbol:h}),_=R?`:${R}:`:":";return jC(`${"+"}:${P}${_}`,T)}function ch({chain:C,symbol:h,ticker:R,basisPoints:T,targetAsset:P}){let _=C==="ETH"&&R!=="ETH"?`${R}-${h.slice(-3)}`:h,B=P?`:${P}`:"";return`${"-"}:${C}.${_}:${T}${B}`}function mh({basisPoints:C,...h}){return jC(`${"POOL-"}:${C}`,h)}function uh({name:C,chain:h,address:R,owner:T}){let P=`${"~"}:${C}:${h}:${R}`,_=T?`:${T}`:"";return`${P}${_}`}function th({name:C,chain:h,asset:R,payout:T,owner:P}){return`${"~"}:${C}:${h}:${T}:${P}:${R}`}function jC(C,{affiliateAddress:h,affiliateBasisPoints:R}={}){let T=`${C}${h?`:${h}:${R||0}`:""}`;return T.endsWith(":")?T.slice(0,-1):T}function rh({chain:C,symbol:h}){return bC.match(C).with("BTC","DOGE","LTC",()=>C.slice(0,1).toLowerCase()).with("BCH",()=>"c").otherwise(()=>`${C}.${h}`)}function dh({name:C,properties:h,methods:R}){function T(P){return{...R(P),...h}}return{[C]:T}}function ah(){return typeof window.ethereum!=="undefined"}function ih(C){return oC().includes(C)}function oC(){let C=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,R=window?.ethereum?.isBraveWallet,T=window?.ethereum?.isTrust||window?.trustwallet,P=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,_=window?.bitkeep?.ethereum,B=window?.$onekey?.ethereum,x=[];if(C)x.push("METAMASK");if(h)x.push("CTRL");if(R)x.push("BRAVE");if(T)x.push("TRUSTWALLET_WEB");if(P)x.push("COINBASE_WEB");if(fC())x.push("OKX_MOBILE");if(_)x.push("BITGET");if(B)x.push("ONEKEY");return x}async function gC(C,h,R){try{await GC({provider:C,method:"wallet_switchEthereumChain",params:[{chainId:PC[h]}]})}catch(T){if(!R)throw new j("helpers_failed_to_switch_network",{error:T,reason:"networkParams not provided"});await nC(C,R)}}function sh({chains:C,supportedChains:h,walletType:R}){let T=C.filter((_)=>h.includes(_));if(T.length===0)throw new j("wallet_chain_not_supported",{wallet:R,chain:C.join(", ")});let P=C.filter((_)=>!h.includes(_));return u(P.length>0,`${R} wallet does not support the following chains: ${P.join(", ")}. These chains will be ignored.`),T}function yC(C,h,R){}function lh({toolbox:C,chain:h,provider:R=window.ethereum,methodNames:T=[]}){let _=[...T,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((B,x)=>{if(!C[x])return B;let H=C[x];if(typeof H!=="function")return B;let $=yC(H,R,h);return{...B,[x]:$}},{});return{...C,..._}}function nC(C,h){return GC({provider:C,method:"wallet_addEthereumChain",params:[h]})}function eh(C){window.ethereum?.on("accountsChanged",()=>C()),window.xfi?.ethereum.on("accountsChanged",()=>C())}function CR(){let{isTrust:C,isBraveWallet:h,__XDEFI:R,overrideIsMetaMask:T,selectedProvider:P}=window?.ethereum||{};if(C)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(T&&P?.isCoinbaseWallet)return"COINBASE_WEB";if(R)"CTRL";if(window?.$onekey?.ethereum)return"ONEKEY";return"METAMASK"}function hR(){let C=[];function h(T){if(C.map((P)=>P.info.uuid).includes(T.detail.info.uuid))return;C.push(T.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function R(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:C,removeEIP6963EventListener:R}}function fC(){let C=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(C),R=/android|XiaoMi|MiuiBrowser/i.test(C),T=h||R,P=/OKApp/i.test(C);return T&&P}function RR({connect:C,name:h,supportedChains:R,walletType:T}){function P(_){return C({..._,walletType:T,supportedChains:R})}return{[h]:{supportedChains:R,connectWallet:P}}}function GC({provider:C,params:h,method:R}){if(!C?.send)throw new j("helpers_not_found_provider");let T=h?Array.isArray(h)?h:[h]:[];return C.send(R,T)}
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=7FC2508615AFA92564756E2164756E21
|