@swapkit/helpers 2.5.0 → 3.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +3 -0
- package/dist/api/index.cjs.map +16 -0
- package/dist/api/index.js +3 -0
- package/dist/api/index.js.map +16 -0
- package/dist/chunk-fazw0jvt.js +3 -0
- package/dist/chunk-fazw0jvt.js.map +9 -0
- package/dist/chunk-nm00d52v.js +4 -0
- package/dist/chunk-nm00d52v.js.map +9 -0
- package/dist/contracts/index.cjs +3 -0
- package/dist/contracts/index.cjs.map +38 -0
- package/dist/contracts/index.js +3 -0
- package/dist/contracts/index.js.map +38 -0
- package/dist/index.cjs +6 -0
- package/dist/index.cjs.map +29 -0
- package/dist/index.js +3 -3
- package/dist/index.js.map +19 -20
- package/dist/tokens/index.cjs +3 -0
- package/dist/tokens/index.cjs.map +23 -0
- package/dist/tokens/index.js +3 -0
- package/dist/tokens/index.js.map +23 -0
- package/package.json +31 -15
- package/src/api/index.ts +19 -0
- package/src/api/microgard/endpoints.ts +83 -0
- package/src/api/microgard/types.ts +60 -0
- package/src/api/midgard/endpoints.ts +166 -0
- package/src/api/midgard/types.ts +155 -0
- package/src/api/swapkitApi/endpoints.ts +266 -0
- package/src/api/swapkitApi/types.ts +772 -0
- package/src/api/thornode/endpoints.ts +78 -0
- package/src/api/thornode/types.ts +241 -0
- package/src/api/thorswapStatic/endpoints.ts +30 -0
- package/src/api/thorswapStatic/types.ts +18 -0
- package/src/contracts/abis/avaxGeneric.ts +92 -0
- package/src/contracts/abis/avaxWoofi.ts +145 -0
- package/src/contracts/abis/bscGeneric.ts +106 -0
- package/src/contracts/abis/chainflipGateway.ts +330 -0
- package/src/contracts/abis/erc20.ts +99 -0
- package/src/contracts/abis/ethGeneric.ts +92 -0
- package/src/contracts/abis/mayaEvmVaults.ts +331 -0
- package/src/contracts/abis/pancakeV2.ts +145 -0
- package/src/contracts/abis/pangolin.ts +120 -0
- package/src/contracts/abis/sushiswap.ts +120 -0
- package/src/contracts/abis/tcEthVault.ts +650 -0
- package/src/contracts/abis/traderJoe.ts +120 -0
- package/src/contracts/abis/uniswapV2.ts +120 -0
- package/src/contracts/abis/uniswapV2Leg.ts +128 -0
- package/src/contracts/abis/uniswapV3_100.ts +128 -0
- package/src/contracts/abis/uniswapV3_10000.ts +128 -0
- package/src/contracts/abis/uniswapV3_3000.ts +128 -0
- package/src/contracts/abis/uniswapV3_500.ts +128 -0
- package/src/contracts/index.ts +95 -0
- package/src/contracts/routers/index.ts +58 -0
- package/src/contracts/routers/kyber.ts +402 -0
- package/src/contracts/routers/oneinch.ts +2188 -0
- package/src/contracts/routers/pancakeswap.ts +340 -0
- package/src/contracts/routers/pangolin.ts +340 -0
- package/src/contracts/routers/sushiswap.ts +340 -0
- package/src/contracts/routers/traderJoe.ts +340 -0
- package/src/contracts/routers/uniswapv2.ts +340 -0
- package/src/contracts/routers/uniswapv3.ts +254 -0
- package/src/contracts/routers/woofi.ts +171 -0
- package/src/index.ts +11 -12
- package/src/modules/__tests__/assetValue.test.ts +0 -2
- package/src/modules/__tests__/swapKitConfig.test.ts +37 -0
- package/src/modules/assetValue.ts +26 -92
- package/src/modules/bigIntArithmetics.ts +6 -2
- package/src/modules/requestClient.ts +26 -35
- package/src/modules/swapKitConfig.ts +131 -0
- package/src/modules/swapKitError.ts +6 -6
- package/src/tokens/index.ts +15 -0
- package/src/tokens/lists/camelot_v3.ts +15920 -0
- package/src/tokens/lists/caviar_v1.ts +1694 -0
- package/src/tokens/lists/chainflip.ts +104 -0
- package/src/tokens/lists/index.ts +13 -0
- package/src/tokens/lists/jupiter.ts +29606 -0
- package/src/tokens/lists/mayachain.ts +513 -0
- package/src/tokens/lists/oneinch.ts +14238 -0
- package/src/tokens/lists/openocean_v2.ts +11514 -0
- package/src/tokens/lists/pancakeswap.ts +4296 -0
- package/src/tokens/lists/pangolin_v1.ts +175 -0
- package/src/tokens/lists/sushiswap_v2.ts +965 -0
- package/src/tokens/lists/thorchain.ts +669 -0
- package/src/tokens/lists/traderjoe_v2.ts +1384 -0
- package/src/tokens/lists/uniswap_v2.ts +5596 -0
- package/src/tokens/lists/uniswap_v3.ts +5946 -0
- package/src/types/chains.ts +26 -46
- package/src/types/commonTypes.ts +3 -90
- package/src/types/index.ts +3 -4
- package/src/types/sdk.ts +0 -30
- package/src/types/tokens.ts +2 -2
- package/src/types/wallet.ts +37 -21
- package/src/{helpers → utils}/asset.ts +49 -19
- package/src/{helpers → utils}/derivationPath.ts +7 -2
- package/src/{helpers → utils}/memo.ts +0 -65
- package/src/{helpers → utils}/others.ts +12 -5
- package/src/utils/plugin.ts +13 -0
- package/src/{helpers/web3wallets.ts → utils/wallets.ts} +175 -139
- package/src/modules/walletUtils.ts +0 -30
- package/src/types/network.ts +0 -49
- /package/src/{helpers → utils}/__tests__/asset.test.ts +0 -0
- /package/src/{helpers/__tests__/derivationPath.ts → utils/__tests__/derivationPath.test.ts} +0 -0
- /package/src/{helpers → utils}/__tests__/memo.test.ts +0 -0
- /package/src/{helpers → utils}/__tests__/others.test.ts +0 -0
- /package/src/{helpers → utils}/__tests__/validators.test.ts +0 -0
- /package/src/{helpers → utils}/liquidity.ts +0 -0
- /package/src/{helpers → utils}/validators.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var yn=Object.create;var{getPrototypeOf:_n,defineProperty:tn,getOwnPropertyNames:$n}=Object;var Ln=Object.prototype.hasOwnProperty;var on=(n,h,t)=>{t=n!=null?yn(_n(n)):{};let o=h||!n||!n.__esModule?tn(t,"default",{value:n,enumerable:!0}):t;for(let c of $n(n))if(!Ln.call(o,c))tn(o,c,{get:()=>n[c],enumerable:!0});return o};var cn=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(h,t)=>(typeof require!=="undefined"?require:h)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});export*from"@swapkit/contracts";var y;((p)=>{p.Arbitrum="ARB";p.Avalanche="AVAX";p.Base="BASE";p.BinanceSmartChain="BSC";p.Bitcoin="BTC";p.BitcoinCash="BCH";p.Cosmos="GAIA";p.Dash="DASH";p.Dogecoin="DOGE";p.Ethereum="ETH";p.Fiat="FIAT";p.Kujira="KUJI";p.Litecoin="LTC";p.Maya="MAYA";p.Optimism="OP";p.Polkadot="DOT";p.Chainflip="FLIP";p.Polygon="MATIC";p.Radix="XRD";p.THORChain="THOR";p.Solana="SOL"})(y||={});var v;((t)=>{t.THORChain="THOR_STAGENET";t.Maya="MAYA_STAGENET"})(v||={});var J;((R)=>{R.Arbitrum="42161";R.ArbitrumHex="0xa4b1";R.Avalanche="43114";R.AvalancheHex="0xa86a";R.Base="8453";R.BaseHex="0x2105";R.BinanceSmartChain="56";R.BinanceSmartChainHex="0x38";R.Bitcoin="bitcoin";R.BitcoinCash="bitcoincash";R.Chainflip="chainflip";R.Cosmos="cosmoshub-4";R.Dash="dash";R.Dogecoin="dogecoin";R.Kujira="kaiyo-1";R.Ethereum="1";R.EthereumHex="0x1";R.Fiat="fiat";R.Litecoin="litecoin";R.Maya="mayachain-mainnet-v1";R.MayaStagenet="mayachain-stagenet-v1";R.Optimism="10";R.OptimismHex="0xa";R.Polkadot="polkadot";R.Polygon="137";R.PolygonHex="0x89";R.Radix="radix-mainnet";R.THORChain="thorchain-1";R.THORChainStagenet="thorchain-stagenet-v2";R.Solana="solana"})(J||={});var _h={["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",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},Pn=Object.keys(y),z=Object.values(y),H={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,OP:18,SOL:9,THOR:8,XRD:18},$h={["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,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["SOL"]:0.4,["THOR"]:6},Lh=["DOT","FLIP"],Q=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],Ph=["BTC","BCH","DASH","DOGE","LTC"],jh=["GAIA","THOR","MAYA","KUJI"],Gh=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],Ih=["ARB","DASH","ETH","KUJI","MAYA","THOR"],Cn={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://avalanche-c-chain-rpc.publicnode.com",["BASE"]:"https://base-rpc.publicnode.com",["BSC"]:"https://bsc-dataseed.binance.org",["BTC"]:"https://bitcoin-rpc.publicnode.com",["BCH"]:"https://node-router.thorswap.net/bitcoin-cash",["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://rpc-kujira.synergynodes.com/",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["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",["THOR"]:"https://rpc.thorswap.net",["THOR_STAGENET"]:"https://stagenet-rpc.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.tendermint.mayachain.info",["SOL"]:"https://solana-rpc.publicnode.com"},jn={["ARB"]:["https://arb-mainnet.g.alchemy.com/v2/demo","https://arbitrum.blockpi.network/v1/rpc/public"],["AVAX"]:["https://api.avax.network/ext/bc/C/rpc","https://avalanche-c-chain-rpc.publicnode.com"],["BASE"]:["https://base.blockpi.network/v1/rpc/public","https://1rpc.io/base"],["BSC"]:["https://bsc-rpc.gateway.pokt.network","https://bsc-dataseed2.binance.org"],["BTC"]:["https://bitcoin.publicnode.com"],["BCH"]:["https://bch-dataseed.binance.org","https://bch.getblock.io/mainnet"],["FLIP"]:["wss://archive-1.mainnet.chainflip.io","wss://archive-2.mainnet.chainflip.io"],["GAIA"]:["https://cosmos-rpc.quickapi.com","https://cosmos-rpc.publicnode.com"],["DASH"]:["https://dash-rpc.publicnode.com"],["DOGE"]:["https://doge.getblock.io/mainnet","https://dogecoin.publicnode.com"],["ETH"]:["https://eth.llamarpc.com","https://rpc.ankr.com/eth"],["FIAT"]:[],["KUJI"]:["https://kujira-rpc.polkachu.com","https://kujira-rpc.ibs.team"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["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"],["THOR"]:["https://thornode.ninerealms.com","https://thornode.thorswap.net"],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},Gn={["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",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},d=Cn,K=(n)=>{return d[n]},In=(n)=>{switch(n){case"ARB":case"AVAX":case"BASE":case"BSC":case"ETH":case"OP":case"MATIC":return{jsonrpc:"2.0",method:"eth_blockNumber",params:[],id:1};case"BTC":case"DOGE":case"BCH":case"DASH":case"LTC":return{jsonrpc:"1.0",id:"test",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{jsonrpc:"2.0",id:1,method:"system_health",params:[]};case"XRD":return"";case"SOL":return{jsonrpc:"2.0",id:1,method:"getHealth"};default:throw new Error(`Unsupported chain: ${n}`)}};function wn(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var sn=async(n,h)=>{try{let t=h.startsWith("wss")?h.replace("wss","https"):h;return(await fetch(`${t}${wn(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(In(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},fn=async(n)=>{let h=Cn[n];if(await sn(n,h))return h;for(let t of jn[n])if(await sn(n,t))return t;return h},wh=async(n=[...Object.values(y),...Object.values(v)])=>{let h={};await Promise.all(n.map(async(t)=>{let o=await fn(t);h[t]=o})),d={...d,...h}},an=z.reduce((n,h)=>{let t=Pn.find((o)=>y[o]===h);if(t)n[h]=t;return n},{}),pn=z.reduce((n,h)=>{return n[h]=J[an[h]],n},{}),E=z.reduce((n,h)=>{return n[h]=K(h),n},{}),fh=z.reduce((n,h)=>{let t=`${an[h]}Hex`;return n[h]=J[t],n},{}),bh=z.reduce((n,h)=>{return n[h]=Gn[h],n},{});var bn;((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"})(bn||={});var Jh=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],zh=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],Zh=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var Xn;((i)=>{i.ARB="0x0000000000000000000000000000000000000000";i.AVAX="0x0000000000000000000000000000000000000000";i.BASE="0x0000000000000000000000000000000000000000";i.ETH="0x0000000000000000000000000000000000000000";i.BSC="0x0000000000000000000000000000000000000000";i.MATIC="0x0000000000000000000000000000000000001010";i.OP="0x4200000000000000000000000000000000000042"})(Xn||={});var Jn;((p)=>{p.ARB="m/44'/60'/0'/0";p.AVAX="m/44'/60'/0'/0";p.BASE="m/44'/60'/0'/0";p.BCH="m/44'/145'/0'/0";p.BSC="m/44'/60'/0'/0";p.BTC="m/84'/0'/0'/0";p.DASH="m/44'/5'/0'/0";p.DOGE="m/44'/3'/0'/0";p.DOT="////";p.ETH="m/44'/60'/0'/0";p.FLIP="////";p.GAIA="m/44'/118'/0'/0";p.KUJI="m/44'/118'/0'/0";p.LTC="m/84'/2'/0'/0";p.MATIC="m/44'/60'/0'/0";p.MAYA="m/44'/931'/0'/0";p.OP="m/44'/60'/0'/0";p.SOL="m/44'/501'/0'/0";p.THOR="m/44'/931'/0'/0";p.XRD="////";p.FIAT="////"})(Jn||={});var W={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BASE:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],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]};var zn;((k)=>{k.Arbitrum="https://arb1.arbitrum.io/rpc";k.Avalanche="https://avalanche-c-chain-rpc.publicnode.com";k.Base="https://base.llamarpc.com";k.BinanceSmartChain="https://bsc-dataseed.binance.org";k.Bitcoin="https://bitcoin-rpc.publicnode.com";k.BitcoinCash="https://node-router.thorswap.net/bitcoin-cash";k.Chainflip="wss://mainnet-archive.chainflip.io";k.Cosmos="https://node-router.thorswap.net/cosmos/rpc";k.Dash="https://dash-rpc.publicnode.com";k.Dogecoin="https://node-router.thorswap.net/dogecoin";k.Ethereum="https://ethereum-rpc.publicnode.com";k.Kujira="https://rpc-kujira.synergynodes.com/";k.Litecoin="https://node-router.thorswap.net/litecoin";k.Maya="https://tendermint.mayachain.info";k.MayaStagenet="https://stagenet.tendermint.mayachain.info";k.Optimism="https://mainnet.optimism.io";k.Polkadot="wss://rpc.polkadot.io";k.Polygon="https://polygon-rpc.com";k.Radix="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";k.THORChain="https://rpc.thorswap.net";k.THORChainStagenet="https://stagenet-rpc.ninerealms.com";k.Solana="https://solana-rpc.publicnode.com"})(zn||={});var Zn;((O)=>{O.Arbitrum="https://arbiscan.io";O.Avalanche="https://snowtrace.io";O.Base="https://basescan.org";O.BinanceSmartChain="https://bscscan.com";O.Bitcoin="https://blockchair.com/bitcoin";O.BitcoinCash="https://www.blockchair.com/bitcoin-cash";O.Chainflip="https://explorer.polkascan.io/polkadot";O.Cosmos="https://www.mintscan.io/cosmos";O.Dash="https://blockchair.com/dash";O.Dogecoin="https://blockchair.com/dogecoin";O.Ethereum="https://etherscan.io";O.Kujira="https://finder.kujira.network/kaiyo-1";O.Litecoin="https://blockchair.com/litecoin";O.Maya="https://www.mayascan.org";O.Optimism="https://optimistic.etherscan.io";O.Polkadot="https://polkadot.subscan.io";O.Polygon="https://polygonscan.com";O.Radix="https://dashboard.radixdlt.com";O.THORChain="https://runescan.io";O.Solana="https://solscan.io"})(Zn||={});var xn;((T)=>{T.BITGET="BITGET";T.BRAVE="BRAVE";T.COINBASE_MOBILE="COINBASE_MOBILE";T.COINBASE_WEB="COINBASE_WEB";T.CTRL="CTRL";T.EIP6963="EIP6963";T.EXODUS="EXODUS";T.KEEPKEY="KEEPKEY";T.KEEPKEY_BEX="KEEPKEY_BEX";T.KEPLR="KEPLR";T.KEYSTORE="KEYSTORE";T.LEAP="LEAP";T.LEDGER="LEDGER";T.LEDGER_LIVE="LEDGER_LIVE";T.METAMASK="METAMASK";T.OKX="OKX";T.OKX_MOBILE="OKX_MOBILE";T.PHANTOM="PHANTOM";T.POLKADOT_JS="POLKADOT_JS";T.RADIX_WALLET="RADIX_WALLET";T.TREZOR="TREZOR";T.TALISMAN="TALISMAN";T.TRUSTWALLET_WEB="TRUSTWALLET_WEB";T.WALLETCONNECT="WALLETCONNECT"})(xn||={});var Yn;((o)=>{o[o.NoError=36864]="NoError";o[o.LockedDevice=21781]="LockedDevice";o[o.TC_NotFound=65535]="TC_NotFound"})(Yn||={});var Mn;((o)=>{o.Average="average";o.Fast="fast";o.Fastest="fastest"})(Mn||={});var qn;((t)=>{t.Approve="approve";t.CheckOnly="checkOnly"})(qn||={});var Rn;((A)=>{A.NAME_REGISTER="~";A.BOND="BOND";A.DEPOSIT="+";A.LEAVE="LEAVE";A.UNBOND="UNBOND";A.WITHDRAW="-";A.OPEN_LOAN="$+";A.CLOSE_LOAN="$-";A.RUNEPOOL_DEPOSIT="POOL+";A.RUNEPOOL_WITHDRAW="POOL-"})(Rn||={});var Qn;((s)=>{s.unknownError="unknownError";s.test_error="test_error";s.providerDetailsError="providerDetailsError";s.blockHeaderNotFound="blockHeaderNotFound";s.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";s.blockHashNotFoundAtHash="blockHashNotFoundAtHash";s.txHashMissing="txHashMissing";s.assetValueMissingInfo="assetValueMissingInfo";s.invalidAsset="invalidAsset";s.blockIsRequired="blockIsRequired";s.currentBlockHeaderNotFound="currentBlockHeaderNotFound";s.failedToRetrieveBalance="failedToRetrieveBalance";s.failedToRetrieveBlock="failedToRetrieveBlock";s.failedToRetrieveFees="failedToRetrieveFees";s.notImplementedBCH="notImplementedBCH";s.notImplementedDoge="notImplementedDoge";s.noPoolsFound="noPoolsFound";s.noVaultsFound="noVaultsFound";s.noTxFound="noTxFound";s.noInputCoinFound="noInputCoinFound";s.noBlockDataFound="noBlockDataFound";s.multipleCosmosMessages="multipleCosmosMessages";s.heightOrHashNotProvided="heightOrHashNotProvided";s.unknownDenom="unknownDenom";s.invalidBlockHeight="invalidBlockHeight";s.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";s.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";s.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";s.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";s.txMemoUndefined="txMemoUndefined";s.txMemoIncorrect="txMemoIncorrect";s.txTypeNotFound="txTypeNotFound";s.txNoMessage="txNoMessage";s.txNotFound="txNotFound";s.txReceiptNotFound="txReceiptNotFound";s.txParsingError="txParsingError";s.txLogsParsingError="txLogsParsingError";s.blockNotFound="blockNotFound";s.balanceNotFound="balanceNotFound";s.configError="configError";s.synthSwapDisallowed="synthSwapDisallowed";s.providerQuoteTimeout="providerQuoteTimeout";s.noQuoteResponse="noQuoteResponse";s.noPoolAssetsFound="noPoolAssetsFound";s.noThorchainPools="noThorchainPools";s.noMayachainPools="noMayachainPools";s.noThorchainNetworkInfo="noThorchainNetworkInfo";s.invalidAffiliateFee="invalidAffiliateFee";s.invalidBuyAssetAddress="invalidBuyAssetAddress";s.invalidSellAssetAddress="invalidSellAssetAddress";s.invalidSourceAddress="invalidSourceAddress";s.invalidDestinationAddress="invalidDestinationAddress";s.sourceAddressIsSmartContract="sourceAddressIsSmartContract";s.destinationAddressIsSmartContract="destinationAddressIsSmartContract";s.invalidChainId="invalidChainId";s.unsupportedChainId="unsupportedChainId";s.unsupportedEVMChainId="unsupportedEVMChainId";s.unsupportedMethod="unsupportedMethod";s.unsupportedProvider="unsupportedProvider";s.invalidParamsForMethod="invalidParamsForMethod";s.unsupportedAdapter="unsupportedAdapter";s.noWhitelistTokens="noWhitelistTokens";s.failedFetchGasPrice="failedFetchGasPrice";s.failedToCreateDepositChannel="failedToCreateDepositChannel";s.noProviderDetailsFound="noProviderDetailsFound";s.noTokenListsFound="noTokenListsFound";s.tokenNotFound="tokenNotFound";s.tokenPriceNotFound="tokenPriceNotFound";s.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";s.swapAmountTooSmall="swapAmountTooSmall";s.legsArrayIsEmpty="legsArrayIsEmpty";s.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";s.noBlockHeaderFound="noBlockHeaderFound";s.failedToSimulateSwap="failedToSimulateSwap";s.addressScreeningFailed="addressScreeningFailed";s.noLiquidtyProvidersFound="noLiquidtyProvidersFound";s.insufficientLiquidity="insufficientLiquidity";s.noSaversFound="noSaversFound";s.noInboundDataFound="noInbounDataFound";s.noInboundAddressesFound="noInboundAddressesFound";s.noInboundAddressFoundForChain="noInboundAddressFoundForChain";s.noLastBlocksFound="noLastBlocksFound";s.noVersionFound="noVersionFound";s.noConstantsFound="noConstantsFound";s.noMimirsFound="noMimirsFound";s.noRoutesFound="noRoutesFound";s.quoteNotFound="quoteNotFound";s.ledgerSignFailed="ledgerSignFailed";s.ledgerWrongPayload="ledgerWrongPayload";s.ledgerFetchSwapFailed="ledgerFetchSwapFailed";s.failedToFetchTx="failedToFetchTx";s.failedBuildTransactionDetails="failedBuildTransactionDetails";s.noLegsForRoute="noLegsForRoute";s.noRouterAddressFound="noRouterAddressFound";s.noAggregatorAddressFound="noAggregatorAddressFound";s.noContractInstanceFound="noContractInstanceFound";s.noContractAddressFound="noContractAddressFound";s.invalidAffiliate="invalidAffiliate";s.thornameAffiliate="thornameAffiliate";s.providerNotfound="No provider found";s.noRecordFound="No Record found";s.slippageTooLow="Slippage too low";s.tradingHalted="tradingHalted";s.noWrappedGasAsset="noWrappedGasAsset";s.aggregatorAddressNotFound="aggregatorAddressNotFound";s.routerAddressNotFound="routerAddressNotFound";s.dummyAddressNotFound="dummyAddressNotFound";s.trackerError="trackerError";s.thorchainPoolUnavailable="thorchainPoolUnavailable";s.noOhlcvDataFound="noOhlcvDataFound";s.noTradingPairs="noTradingPairs";s.noLoanPositionFound="noLoanPositionFound";s.noLendingAvailability="noLendingAvailability";s.lendingRepayTooSmall="lendingRepayTooSmall";s.missingState="missingState";s.ledgerSwapNotFound="ledgerSwapNotFound";s.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";s.errorEstimatingGas="errorEstimatingGas";s.apiKeyInvalid="apiKeyInvalid";s.apiKeyFailedToUpdate="apiKeyFailedToUpdate";s.apiKeyExpired="apiKeyExpired";s.unauthorized="unauthorized";s.failedToCreateMemo="failedToCreateMemo";s.radixIncorrectInstructions="radixIncorrectInstructions";s.radixTxMissedParam="radixTxMissedParam";s.radixTxMissedAccount="radixTxMissedAccount";s.radixManifestParseError="radixManifestParseError";s.radixManifestBuildError="radixManifestBuildError";s.invalidAddressForChain="invalidAddressForChain";s.riskyAddress="riskyAddress";s.noRoutesToProcess="noRoutesToProcess";s.sellAssetAmountTooSmall="sellAssetAmountTooSmall";s.missingPrivateKey="missingPrivateKey";s.noMemoPriceProtection="noMemoPriceProtection"})(Qn||={});var Kn;((t)=>{t.highSlippage="highSlippage";t.highPriceImpact="highPriceImpact"})(Kn||={});var Wn;((N)=>{N.CAVIAR_V1="CAVIAR_V1";N.CAMELOT_V3="CAMELOT_V3";N.CHAINFLIP="CHAINFLIP";N.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";N.JUPITER="JUPITER";N.MAYACHAIN="MAYACHAIN";N.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";N.OCISWAP_V1="OCISWAP_V1";N.ONEINCH="ONEINCH";N.OPENOCEAN_V2="OPENOCEAN_V2";N.PANCAKESWAP="PANCAKESWAP";N.PANGOLIN_V1="PANGOLIN_V1";N.SUSHISWAP_V2="SUSHISWAP_V2";N.THORCHAIN="THORCHAIN";N.THORCHAIN_STREAMING="THORCHAIN_STREAMING";N.TRADERJOE_V2="TRADERJOE_V2";N.UNISWAP_V2="UNISWAP_V2";N.UNISWAP_V3="UNISWAP_V3";N.KADO="KADO"})(Wn||={});var mn;((i)=>{i.LIQUIDITY="liquidity";i.NETWORK="network";i.INBOUND="inbound";i.OUTBOUND="outbound";i.AFFILIATE="affiliate";i.TAX="tax";i.PRIORITY="priority"})(mn||={});var l={},Vn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};function nt({apiKey:n,...h}){l={...h,apiKey:n}}async function m(n,h){let{apiKey:t,...o}=l,{searchParams:c,json:C,body:a}=h,i={...Vn,...o.headers,...h.headers,...C?{"Content-Type":"application/json"}:{}},F=C?JSON.stringify(C):a,x=new URL(n);if(c)x.search=new URLSearchParams(c).toString();if(t)i["x-api-key"]=t;try{let S=await(await fetch(x.toString(),{...o,...h,body:F,headers:i})).json();if(h.responseHandler)return h.responseHandler(S);return S}catch(A){if(h.onError)return h.onError(A);console.error(A)}}var b={get:async(n,h)=>m(n,{...h,method:"GET"}),post:async(n,h)=>m(n,{...h,method:"POST"}),extend:(n)=>{let h={...l,...n};return{get:async(t,o)=>m(t,{...h,...o,method:"GET"}),post:async(t,o)=>m(t,{...h,...o,method:"POST"}),extend:(t)=>b.extend({...h,...t})}}};var Un={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_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,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_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,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 u extends Error{static ErrorCode=Un;constructor(n,h){let t=typeof n==="string",o=t?n:n.errorKey;if(h)console.error(h,{stack:h?.stack,message:h?.message});super(o,{cause:{code:u.ErrorCode[o],message:`${o}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,u.prototype)}}function Ct(n){if(n<0)throw new u({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function at(n){if(n<0)throw new u({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function it(n,h){try{return n()}catch(t){if(h)throw new u(h,t);return console.error(t)}}function pt(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Dn=["production","test"].includes("development"),An=new Set;function Hn(n,h){if(!Dn&&n){if(An.has(h))return;An.add(h),console.warn(h)}}async function xt(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{return(await b.get(`${n!=="thorchain-1"?K("THOR_STAGENET"):K("THOR")}/status`)).result.node_info.network}catch(h){return n}}var Fn=[...Object.values(y),"TERRA"];function Tn(n=""){let h=n.toUpperCase(),[t]=h.split(".");if(Fn.includes(t))return!0;let[o]=h.split("/");if(Fn.includes(o))return!0;throw new u({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function Ft(n){if(n.length>30)return!1;let h=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(h)}var Y=8,f=(n)=>10n**BigInt(n),Z=(n)=>Math.log10(Number.parseFloat(n.toString()));function X({value:n,bigIntDecimal:h=Y,decimal:t=Y}){if(t===0)return n.toString();let o=n<0n,c=n.toString().substring(o?1:0),C=t-(c.length-1);if(C>0)c="0".repeat(C)+c;let a=c.length-t,i=c.slice(-t);if(Number.parseInt(i[h]||"0")>=5)i=`${i.substring(0,h-1)}${(Number.parseInt(i[h-1]||"0")+1).toString()}`;else i=i.substring(0,h);return`${o?"-":""}${c.slice(0,a)}.${i}`.replace(/\.?0*$/,"")}class j{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,h){return new j({decimal:h,value:X({value:n,bigIntDecimal:h,decimal:h})})}static shiftDecimals({value:n,from:h,to:t}){return j.fromBigInt(n.getBaseValue("bigint")*f(t)/f(h),t)}constructor(n){let h=r(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:f(Math.max(Bn(V(h)),this.decimal||0)),this.#c(h)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#h("add",...n)}sub(...n){return this.#h("sub",...n)}mul(...n){return this.#h("mul",...n)}div(...n){return this.#h("div",...n)}gt(n){return this.#n("gt",n)}gte(n){return this.#n("gte",n)}lt(n){return this.#n("lt",n)}lte(n){return this.#n("lte",n)}eqValue(n){return this.#n("eqValue",n)}getValue(n,h){let t=this.formatBigIntToSafeValue(this.bigIntValue,h||this.decimal||Z(this.decimalMultiplier));switch(n){case"number":return Number(t);case"string":return t;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n,h){let t=this.decimalMultiplier/f(h||this.decimal||H.THOR),o=this.bigIntValue/t;switch(n){case"number":return Number(o);case"string":return o.toString();case"bigint":return o}}getBigIntValue(n,h){if(!h&&typeof n==="object")return n.bigIntValue;let t=r(n),o=V(t);if(o==="0"||o==="undefined")return 0n;return this.#o(o,h)}toSignificant(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if((Number.parseInt(o)?o.length+c.length:c.length)<=n)return this.getValue("string");if(o.length>=n)return o.slice(0,n).padEnd(o.length,"0");if(Number.parseInt(o))return`${o}.${c.slice(0,n-o.length)}`.padEnd(n-o.length,"0");let a=Number.parseInt(c),i=`${a}`.slice(0,n);return`0.${i.padStart(c.length-`${a}`.length+i.length,"0")}`}toFixed(n=6){let[h,t]=this.getValue("string").split("."),o=h||"",c=t||"";if(Number.parseInt(o))return`${o}.${c.slice(0,n)}`.padEnd(n,"0");let C=Number.parseInt(c),a=`${C}`.slice(0,n);return`0.${a.padStart(c.length-`${C}`.length+a.length,"0")}`}toAbbreviation(n=2){let h=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],o=Math.floor(Math.log10(Math.abs(h))/3),c=t[o];if(!c)return this.getValue("string");let C=10**(o*3);return`${(h/C).toFixed(n)}${c}`}toCurrency(n="$",{currencyPosition:h="start",decimal:t=2,decimalSeparator:o=".",thousandSeparator:c=","}={}){let C=this.getValue("number"),[a="",i=""]=C.toFixed(6).split("."),F=a.replace(/\B(?=(\d{3})+(?!\d))/g,c),x=a||i?a==="0"?`${Number.parseFloat(`0.${i}`)}`.replace(".",o):`${F}${Number.parseInt(i)?`${o}${i.slice(0,t)}`:""}`:"0.00";return`${h==="start"?n:""}${x}${h==="end"?n:""}`}formatBigIntToSafeValue(n,h){let t=h||this.decimal||Y,o=Math.max(t,Z(this.decimalMultiplier)),c=n<0n,C=n.toString().substring(c?1:0),a=o-(C.length-1),i=a>0?"0".repeat(a)+C:C,F=i.length-o,x=i.slice(-o);if(Number.parseInt(x[t]||"0")>=5)x=`${x.substring(0,t-1)}${(Number.parseInt(x[t-1]||"0")+1).toString()}`;else x=x.substring(0,t);return`${c?"-":""}${i.slice(0,F)}.${x}`.replace(/\.?0*$/,"")}#h(n,...h){let t=this.#t(this,...h),o=Math.max(t,Z(this.decimalMultiplier)),c=f(o),C=h.reduce((i,F)=>{let x=this.getBigIntValue(F,o);switch(n){case"add":return i+x;case"sub":return i-x;case"mul":return i*x/c;case"div":{if(x===0n)throw new RangeError("Division by zero");return i*c/x}default:return i}},this.bigIntValue*c/this.decimalMultiplier),a=X({bigIntDecimal:o,decimal:o,value:C});return new this.constructor({decimalMultiplier:f(o),decimal:this.decimal,value:a,identifier:this.toString()})}#n(n,...h){let t=this.#t(this,...h),o=this.getBigIntValue(h[0]||"0",t),c=this.getBigIntValue(this,t);switch(n){case"gt":return c>o;case"gte":return c>=o;case"lt":return c<o;case"lte":return c<=o;case"eqValue":return c===o}}#c(n){let h=V(n)||"0";this.bigIntValue=this.#o(h)}#t(...n){let h=n.map((t)=>{return typeof t==="object"?t.decimal||Z(t.decimalMultiplier):Bn(V(t))}).filter(Boolean);return Math.max(...h,Y)}#o(n,h){let t=h?f(h):this.decimalMultiplier,o=Z(t),[c="",C=""]=n.split(".");return BigInt(`${c}${C.padEnd(o,"0")}`)}}var dn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function V(n){let t=`${typeof n==="number"?dn.format(n):r(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"}function Bn(n){let h=n.split(".")[1]?.length||0;return Math.max(h,Y)}function r(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var U=new Map;class g extends j{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:h,tax:t,chain:o,symbol:c,identifier:C}){super(typeof n==="object"?n:{decimal:h,value:n});let a=e(C||`${o}.${c}`);this.type=On(a),this.tax=t,this.chain=a.chain,this.ticker=a.ticker,this.symbol=a.symbol,this.address=a.address,this.isSynthetic=a.isSynthetic,this.isTradeAsset=a.isTradeAsset,this.isGasAsset=a.isGasAsset,this.chainId=pn[a.chain]}toString({includeSynthProtocol:n}={}){return(this.isSynthetic||this.isTradeAsset)&&!n?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.isTradeAsset?`${this.chain}.${this.symbol.replace("~","..")}`:this.toString()}eqAsset({chain:n,symbol:h}){return this.chain===n&&this.symbol===h}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,h=0){let[t,o,c]=n.split(".");if(!(t&&o))throw new u({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let C=t==="THOR"&&c?`${t}.${o}/${c}`:n;return g.from({asset:C,value:h})}static from({value:n=0,fromBaseDecimal:h,asyncTokenLookup:t,...o}){let c=n instanceof j?n.getValue("string"):n,C="chain"in o,a=C?o.chain:o.asset,i=C||Nn.includes(a),{identifier:F,decimal:x}=i?gn(a):{identifier:a,decimal:void 0},{chain:A,isSynthetic:S,isTradeAsset:$}=e(F),G=U.get(A==="SOL"?F:F.toUpperCase()),I=G?.decimal||x;Hn(!(t||I),`Couldn't find static decimal for a token on chain (Using default ${H[A]} decimal as fallback).
|
|
1
|
+
import{a as Pn,c as Hn}from"./chunk-nm00d52v.js";var g;((T)=>{T.Arbitrum="ARB";T.Avalanche="AVAX";T.Base="BASE";T.BinanceSmartChain="BSC";T.Bitcoin="BTC";T.BitcoinCash="BCH";T.Cosmos="GAIA";T.Dash="DASH";T.Dogecoin="DOGE";T.Ethereum="ETH";T.Fiat="FIAT";T.Kujira="KUJI";T.Litecoin="LTC";T.Maya="MAYA";T.Optimism="OP";T.Polkadot="DOT";T.Chainflip="FLIP";T.Polygon="MATIC";T.Radix="XRD";T.THORChain="THOR";T.Solana="SOL"})(g||={});var K;((o)=>{o.THORChain="THOR_STAGENET";o.Maya="MAYA_STAGENET"})(K||={});var U;((R)=>{R.Arbitrum="42161";R.ArbitrumHex="0xa4b1";R.Avalanche="43114";R.AvalancheHex="0xa86a";R.Base="8453";R.BaseHex="0x2105";R.BinanceSmartChain="56";R.BinanceSmartChainHex="0x38";R.Bitcoin="bitcoin";R.BitcoinCash="bitcoincash";R.Chainflip="chainflip";R.Cosmos="cosmoshub-4";R.Dash="dash";R.Dogecoin="dogecoin";R.Kujira="kaiyo-1";R.Ethereum="1";R.EthereumHex="0x1";R.Fiat="fiat";R.Litecoin="litecoin";R.Maya="mayachain-mainnet-v1";R.MayaStagenet="mayachain-stagenet-v1";R.Optimism="10";R.OptimismHex="0xa";R.Polkadot="polkadot";R.Polygon="137";R.PolygonHex="0x89";R.Radix="radix-mainnet";R.THORChain="thorchain-1";R.THORChainStagenet="thorchain-stagenet-v2";R.Solana="solana"})(U||={});var ct={["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",["fiat"]:"FIAT",["kaiyo-1"]:"KUJI",["1"]:"ETH",["litecoin"]:"LTC",["mayachain-stagenet-v1"]:"MAYA",["mayachain-mainnet-v1"]:"MAYA",["0xa"]:"OP",["10"]:"OP",["polkadot"]:"DOT",["0x89"]:"MATIC",["137"]:"MATIC",["radix-mainnet"]:"XRD",["thorchain-stagenet-v2"]:"THOR",["thorchain-1"]:"THOR",["solana"]:"SOL"},gn=Object.keys(g),J=Object.values(g),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,OP:18,SOL:9,THOR:8,XRD:18},Ct={["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,["OP"]:2,["DOT"]:6,["MATIC"]:2.1,["XRD"]:5,["SOL"]:0.4,["THOR"]:6},Tt=["DOT","FLIP"],W=["ARB","AVAX","BASE","BSC","ETH","OP","MATIC"],At=["BTC","BCH","DASH","DOGE","LTC"],Rt=["GAIA","THOR","MAYA","KUJI"],xt={["GAIA"]:"cosmos",["THOR"]:"thor",["MAYA"]:"maya",["KUJI"]:"kujira"},pt=["AVAX","BSC","BTC","BCH","GAIA","DOGE","ETH","LTC","THOR"],et=["ARB","DASH","ETH","KUJI","MAYA","THOR"],Q={["ARB"]:"https://arb1.arbitrum.io/rpc",["AVAX"]:"https://avalanche-c-chain-rpc.publicnode.com",["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://rpc-kujira.synergynodes.com/",["LTC"]:"https://node-router.thorswap.net/litecoin",["MAYA"]:"https://tendermint.mayachain.info",["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",["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"},w={["THOR"]:"https://thornode.thorswap.net",["MAYA"]:"https://mayanode.mayachain.info",["THOR_STAGENET"]:"https://stagenet-thornode.ninerealms.com",["MAYA_STAGENET"]:"https://stagenet.mayanode.mayachain.info"},mn={["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://kujira-rpc.ibs.team"],["LTC"]:["https://ltc.getblock.io/mainnet","https://litecoin.publicnode.com"],["MAYA"]:["https://tendermint.mayachain.info","https://maya-tendermint.publicnode.com"],["MAYA_STAGENET"]:[],["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"],["THOR"]:["https://thornode.ninerealms.com",w.THOR],["THOR_STAGENET"]:[],["SOL"]:["https://api.mainnet-beta.solana.com","https://rpc.ankr.com/solana"]},v={["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",["OP"]:"https://optimistic.etherscan.io",["DOT"]:"https://polkadot.subscan.io",["MATIC"]:"https://polygonscan.com",["XRD"]:"https://dashboard.radixdlt.com",["THOR"]:"https://runescan.io",["SOL"]:"https://solscan.io"},sn=Q,Nn=(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 $n(n){switch(n){case"XRD":return"/status/network-configuration";default:return""}}var an=async(n,t)=>{try{let o=t.startsWith("wss")?t.replace("wss","https"):t;return(await fetch(`${o}${$n(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Nn(n)),signal:AbortSignal.timeout(3000)})).ok}catch{return!1}},fn=async(n)=>{let t=Q[n];if(await an(n,t))return t;for(let o of mn[n])if(await an(n,o))return o;return t},Pt=async(n=[...Object.values(g),...Object.values(K)])=>{let t={};await Promise.all(n.map(async(o)=>{let s=await fn(o);t[o]=s})),sn={...sn,...t}},hn=J.reduce((n,t)=>{let o=gn.find((s)=>g[s]===t);if(o)n[t]=o;return n},{}),cn=J.reduce((n,t)=>{return n[t]=U[hn[t]],n},{}),Cn=J.reduce((n,t)=>{let o=`${hn[t]}Hex`;return n[t]=U[o],n},{}),Ht=J.reduce((n,t)=>{return n[t]=v[t],n},{});import{createStore as Xn}from"zustand/vanilla";var Sn;((H)=>{H.TC_SUPPORTED_TO_TC_SUPPORTED="TC-TC";H.TC_SUPPORTED_TO_ETH="TC-ERC20";H.TC_SUPPORTED_TO_AVAX="TC-ARC20";H.TC_SUPPORTED_TO_BSC="TC-BEP20";H.ETH_TO_TC_SUPPORTED="ERC20-TC";H.ETH_TO_ETH="ERC20-ERC20";H.ETH_TO_AVAX="ERC20-ARC20";H.ETH_TO_BSC="ERC20-BEP20";H.AVAX_TO_TC_SUPPORTED="ARC20-TC";H.AVAX_TO_ETH="ARC20-ERC20";H.AVAX_TO_AVAX="ARC20-ARC20";H.AVAX_TO_BSC="ARC20-BEP20";H.BSC_TO_TC_SUPPORTED="BEP20-TC";H.BSC_TO_ETH="BEP20-ERC20";H.BSC_TO_AVAX="BEP20-ARC20";H.BSC_TO_BSC="BEP20-BEP20"})(Sn||={});var Ft=["ERC20-ERC20","ARC20-ARC20","BEP20-BEP20"],Ot=["ERC20-TC","ERC20-ARC20","ERC20-BEP20","ARC20-TC","ARC20-ERC20","ARC20-BEP20","BEP20-TC","BEP20-ERC20","BEP20-ARC20"],ut=["TC-TC","TC-ERC20","TC-ARC20","TC-BEP20"];var yn;((C)=>{C.ARB="0x0000000000000000000000000000000000000000";C.AVAX="0x0000000000000000000000000000000000000000";C.BASE="0x0000000000000000000000000000000000000000";C.ETH="0x0000000000000000000000000000000000000000";C.BSC="0x0000000000000000000000000000000000000000";C.MATIC="0x0000000000000000000000000000000000001010";C.OP="0x4200000000000000000000000000000000000042"})(yn||={});var kn;((T)=>{T.ARB="m/44'/60'/0'/0";T.AVAX="m/44'/60'/0'/0";T.BASE="m/44'/60'/0'/0";T.BCH="m/44'/145'/0'/0";T.BSC="m/44'/60'/0'/0";T.BTC="m/84'/0'/0'/0";T.DASH="m/44'/5'/0'/0";T.DOGE="m/44'/3'/0'/0";T.DOT="////";T.ETH="m/44'/60'/0'/0";T.FLIP="////";T.GAIA="m/44'/118'/0'/0";T.KUJI="m/44'/118'/0'/0";T.LTC="m/84'/2'/0'/0";T.MATIC="m/44'/60'/0'/0";T.MAYA="m/44'/931'/0'/0";T.OP="m/44'/60'/0'/0";T.SOL="m/44'/501'/0'/0";T.THOR="m/44'/931'/0'/0";T.XRD="////";T.FIAT="////"})(kn||={});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],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]};var Mn;((a)=>{a.unknownError="unknownError";a.test_error="test_error";a.providerDetailsError="providerDetailsError";a.blockHeaderNotFound="blockHeaderNotFound";a.blockHashNotFoundAtHeight="blockHashNotFoundAtHeight";a.blockHashNotFoundAtHash="blockHashNotFoundAtHash";a.txHashMissing="txHashMissing";a.assetValueMissingInfo="assetValueMissingInfo";a.invalidAsset="invalidAsset";a.blockIsRequired="blockIsRequired";a.currentBlockHeaderNotFound="currentBlockHeaderNotFound";a.failedToRetrieveBalance="failedToRetrieveBalance";a.failedToRetrieveBlock="failedToRetrieveBlock";a.failedToRetrieveFees="failedToRetrieveFees";a.notImplementedBCH="notImplementedBCH";a.notImplementedDoge="notImplementedDoge";a.noPoolsFound="noPoolsFound";a.noVaultsFound="noVaultsFound";a.noTxFound="noTxFound";a.noInputCoinFound="noInputCoinFound";a.noBlockDataFound="noBlockDataFound";a.multipleCosmosMessages="multipleCosmosMessages";a.heightOrHashNotProvided="heightOrHashNotProvided";a.unknownDenom="unknownDenom";a.invalidBlockHeight="invalidBlockHeight";a.timestampExtrinsicNoArgumentsForBlock="timestampExtrinsicNoArgumentsForBlock";a.timestampExtrinsicNoTimestampForBlock="timestampExtrinsicNoTimestampForBlock";a.noTimestampExtrinsicForHash="noTimestampExtrinsicForHash";a.timestampExtrinsicNoArgumentsForHash="timestampExtrinsicNoArgumentsForHash";a.txMemoUndefined="txMemoUndefined";a.txMemoIncorrect="txMemoIncorrect";a.txTypeNotFound="txTypeNotFound";a.txNoMessage="txNoMessage";a.txNotFound="txNotFound";a.txReceiptNotFound="txReceiptNotFound";a.txParsingError="txParsingError";a.txLogsParsingError="txLogsParsingError";a.blockNotFound="blockNotFound";a.balanceNotFound="balanceNotFound";a.configError="configError";a.synthSwapDisallowed="synthSwapDisallowed";a.providerQuoteTimeout="providerQuoteTimeout";a.noQuoteResponse="noQuoteResponse";a.noPoolAssetsFound="noPoolAssetsFound";a.noThorchainPools="noThorchainPools";a.noMayachainPools="noMayachainPools";a.noThorchainNetworkInfo="noThorchainNetworkInfo";a.invalidAffiliateFee="invalidAffiliateFee";a.invalidBuyAssetAddress="invalidBuyAssetAddress";a.invalidSellAssetAddress="invalidSellAssetAddress";a.invalidSourceAddress="invalidSourceAddress";a.invalidDestinationAddress="invalidDestinationAddress";a.sourceAddressIsSmartContract="sourceAddressIsSmartContract";a.destinationAddressIsSmartContract="destinationAddressIsSmartContract";a.invalidChainId="invalidChainId";a.unsupportedChainId="unsupportedChainId";a.unsupportedEVMChainId="unsupportedEVMChainId";a.unsupportedMethod="unsupportedMethod";a.unsupportedProvider="unsupportedProvider";a.invalidParamsForMethod="invalidParamsForMethod";a.unsupportedAdapter="unsupportedAdapter";a.noWhitelistTokens="noWhitelistTokens";a.failedFetchGasPrice="failedFetchGasPrice";a.failedToCreateDepositChannel="failedToCreateDepositChannel";a.noProviderDetailsFound="noProviderDetailsFound";a.noTokenListsFound="noTokenListsFound";a.tokenNotFound="tokenNotFound";a.tokenPriceNotFound="tokenPriceNotFound";a.tokenPriceFailedToUpdate="tokenPriceFailedToUpdate";a.swapAmountTooSmall="swapAmountTooSmall";a.legsArrayIsEmpty="legsArrayIsEmpty";a.failedToFetchQuoteForLeg="failedToFetchQuoteForLeg";a.noBlockHeaderFound="noBlockHeaderFound";a.failedToSimulateSwap="failedToSimulateSwap";a.addressScreeningFailed="addressScreeningFailed";a.noLiquidtyProvidersFound="noLiquidtyProvidersFound";a.insufficientLiquidity="insufficientLiquidity";a.noSaversFound="noSaversFound";a.noInboundDataFound="noInbounDataFound";a.noInboundAddressesFound="noInboundAddressesFound";a.noInboundAddressFoundForChain="noInboundAddressFoundForChain";a.noLastBlocksFound="noLastBlocksFound";a.noVersionFound="noVersionFound";a.noConstantsFound="noConstantsFound";a.noMimirsFound="noMimirsFound";a.noRoutesFound="noRoutesFound";a.quoteNotFound="quoteNotFound";a.ledgerSignFailed="ledgerSignFailed";a.ledgerWrongPayload="ledgerWrongPayload";a.ledgerFetchSwapFailed="ledgerFetchSwapFailed";a.failedToFetchTx="failedToFetchTx";a.failedBuildTransactionDetails="failedBuildTransactionDetails";a.noLegsForRoute="noLegsForRoute";a.noRouterAddressFound="noRouterAddressFound";a.noAggregatorAddressFound="noAggregatorAddressFound";a.noContractInstanceFound="noContractInstanceFound";a.noContractAddressFound="noContractAddressFound";a.invalidAffiliate="invalidAffiliate";a.thornameAffiliate="thornameAffiliate";a.providerNotfound="No provider found";a.noRecordFound="No Record found";a.slippageTooLow="Slippage too low";a.tradingHalted="tradingHalted";a.noWrappedGasAsset="noWrappedGasAsset";a.aggregatorAddressNotFound="aggregatorAddressNotFound";a.routerAddressNotFound="routerAddressNotFound";a.dummyAddressNotFound="dummyAddressNotFound";a.trackerError="trackerError";a.thorchainPoolUnavailable="thorchainPoolUnavailable";a.noOhlcvDataFound="noOhlcvDataFound";a.noTradingPairs="noTradingPairs";a.noLoanPositionFound="noLoanPositionFound";a.noLendingAvailability="noLendingAvailability";a.lendingRepayTooSmall="lendingRepayTooSmall";a.missingState="missingState";a.ledgerSwapNotFound="ledgerSwapNotFound";a.ledgerSwapNotReadyForTracking="ledgerSwapNotReadyForTracking";a.errorEstimatingGas="errorEstimatingGas";a.apiKeyInvalid="apiKeyInvalid";a.apiKeyFailedToUpdate="apiKeyFailedToUpdate";a.apiKeyExpired="apiKeyExpired";a.unauthorized="unauthorized";a.failedToCreateMemo="failedToCreateMemo";a.radixIncorrectInstructions="radixIncorrectInstructions";a.radixTxMissedParam="radixTxMissedParam";a.radixTxMissedAccount="radixTxMissedAccount";a.radixManifestParseError="radixManifestParseError";a.radixManifestBuildError="radixManifestBuildError";a.invalidAddressForChain="invalidAddressForChain";a.riskyAddress="riskyAddress";a.noRoutesToProcess="noRoutesToProcess";a.sellAssetAmountTooSmall="sellAssetAmountTooSmall";a.missingPrivateKey="missingPrivateKey";a.noMemoPriceProtection="noMemoPriceProtection"})(Mn||={});var bn;((o)=>{o.highSlippage="highSlippage";o.highPriceImpact="highPriceImpact"})(bn||={});var dn;((B)=>{B.CAVIAR_V1="CAVIAR_V1";B.CAMELOT_V3="CAMELOT_V3";B.CHAINFLIP="CHAINFLIP";B.CHAINFLIP_STREAMING="CHAINFLIP_STREAMING";B.JUPITER="JUPITER";B.MAYACHAIN="MAYACHAIN";B.MAYACHAIN_STREAMING="MAYACHAIN_STREAMING";B.OCISWAP_V1="OCISWAP_V1";B.ONEINCH="ONEINCH";B.OPENOCEAN_V2="OPENOCEAN_V2";B.PANCAKESWAP="PANCAKESWAP";B.PANGOLIN_V1="PANGOLIN_V1";B.SUSHISWAP_V2="SUSHISWAP_V2";B.THORCHAIN="THORCHAIN";B.THORCHAIN_STREAMING="THORCHAIN_STREAMING";B.TRADERJOE_V2="TRADERJOE_V2";B.UNISWAP_V2="UNISWAP_V2";B.UNISWAP_V3="UNISWAP_V3";B.KADO="KADO"})(dn||={});var Ln;((C)=>{C.LIQUIDITY="liquidity";C.NETWORK="network";C.INBOUND="inbound";C.OUTBOUND="outbound";C.AFFILIATE="affiliate";C.TAX="tax";C.PRIORITY="priority"})(Ln||={});var In;((s)=>{s.Average="average";s.Fast="fast";s.Fastest="fastest"})(In||={});var jn;((o)=>{o.Approve="approve";o.CheckOnly="checkOnly"})(jn||={});var Tn;((x)=>{x.NAME_REGISTER="~";x.BOND="BOND";x.DEPOSIT="+";x.LEAVE="LEAVE";x.UNBOND="UNBOND";x.WITHDRAW="-";x.OPEN_LOAN="$+";x.CLOSE_LOAN="$-";x.RUNEPOOL_DEPOSIT="POOL+";x.RUNEPOOL_WITHDRAW="POOL-"})(Tn||={});var An;((P)=>{P.BITGET="BITGET";P.BRAVE="BRAVE";P.COINBASE_MOBILE="COINBASE_MOBILE";P.COINBASE_WEB="COINBASE_WEB";P.CTRL="CTRL";P.EIP6963="EIP6963";P.EXODUS="EXODUS";P.KEEPKEY="KEEPKEY";P.KEEPKEY_BEX="KEEPKEY_BEX";P.KEPLR="KEPLR";P.KEYSTORE="KEYSTORE";P.LEAP="LEAP";P.LEDGER="LEDGER";P.LEDGER_LIVE="LEDGER_LIVE";P.METAMASK="METAMASK";P.OKX="OKX";P.OKX_MOBILE="OKX_MOBILE";P.PHANTOM="PHANTOM";P.POLKADOT_JS="POLKADOT_JS";P.RADIX_WALLET="RADIX_WALLET";P.TREZOR="TREZOR";P.TALISMAN="TALISMAN";P.TRUSTWALLET_WEB="TRUSTWALLET_WEB";P.WALLETCONNECT="WALLETCONNECT"})(An||={});var Gn;((s)=>{s[s.NoError=36864]="NoError";s[s.LockedDevice=21781]="LockedDevice";s[s.TC_NotFound=65535]="TC_NotFound"})(Gn||={});var rn={apis:{},explorerUrls:v,nodeUrls:w,rpcUrls:Q,apiKeys:{blockchair:"",covalent:"",ethplorer:"freekey",kado:"",keepKey:"",swapKit:"",walletConnectProjectId:""},envs:{apiUrl:"https://api.swapkit.dev",devApiUrl:"https://dev-api.swapkit.dev",isDev:!1,isStagenet:!1,referer:"https://swapkit.dev"},integrations:{radix:{applicationName:"Swapkit Playground",applicationVersion:"0.0.1",dAppDefinitionAddress:"account_rdx128r289p58222hcvev7frs6kue76pl7pdcnw8725aw658v0zggkh9ws",network:{dashboardBase:"https://dashboard.radixdlt.com",networkId:1,networkName:"mainnet"}}}},N=Xn((n)=>({...rn,setApiKey:(t,o)=>n((s)=>({apiKeys:{...s.apiKeys,[t]:o}})),setEnv:(t,o)=>n((s)=>({envs:{...s.envs,[t]:o}})),setExplorerUrl:(t,o)=>n((s)=>({explorerUrls:{...s.explorerUrls,[t]:o}})),setNodeUrl:(t,o)=>n((s)=>({nodeUrls:{...s.nodeUrls,[t]:o}})),setRpcUrl:(t,o)=>n((s)=>({rpcUrls:{...s.rpcUrls,[t]:o}})),setIntegrationConfig:(t,o)=>n((s)=>({integrations:{...s.integrations,[t]:o}})),setConfig:(t)=>n((o)=>({apiKeys:{...o.apiKeys,...t.apiKeys},envs:{...o.envs,...t.envs},explorerUrls:{...o.explorerUrls,...t.explorerUrls},nodeUrls:{...o.nodeUrls,...t.nodeUrls},rpcUrls:{...o.rpcUrls,...t.rpcUrls},integrations:{...o.integrations,...t.integrations}}))})),S={getState:N.getState,get:(n)=>N.getState()[n],set:(n)=>N.getState().setConfig(n),setApiKey:(n,t)=>N.getState().setApiKey(n,t),setEnv:(n,t)=>N.getState().setEnv(n,t),setExplorerUrl:(n,t)=>N.getState().setExplorerUrl(n,t),setNodeUrl:(n,t)=>N.getState().setNodeUrl(n,t),setRpcUrl:(n,t)=>N.getState().setRpcUrl(n,t),setIntegrationConfig:(n,t)=>N.getState().setIntegrationConfig(n,t)};var wn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"};async function z({url:n,method:t},o={}){let{searchParams:s,json:h,body:i}=o,c=new URL(n),C=h||n.endsWith(".json"),e=C?JSON.stringify(h):i,A={...wn,...o.headers,...C?{"Content-Type":"application/json"}:{}};if(s)c.search=new URLSearchParams(s).toString();if(S.get("apiKeys").swapKit)A["x-api-key"]=S.get("apiKeys").swapKit;try{let O=await(await fetch(c.toString(),{...o,method:t,body:e,headers:A})).json();return o.responseHandler?.(O)||O}catch(x){return o.onError?.(x)||console.error(x)}}var L={get:async(n,t)=>z({url:n,method:"GET"},t),post:async(n,t)=>z({url:n,method:"POST"},t),extend:(n)=>({get:async(t,o)=>z({url:t,method:"GET"},{...n,...o}),post:async(t,o)=>z({url:t,method:"POST"},{...n,...o}),extend:(t)=>L.extend({...n,...t})})};var Un={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_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,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,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 F extends Error{static ErrorCode=Un;constructor(n,t){let o=typeof n==="string",s=o?n:n.errorKey;super(s);if(t)console.error(t,{stack:t?.stack,message:t?.message});console.error(s,{code:F.ErrorCode[s],message:`${s}${o?"":`: ${JSON.stringify(n.info)}`}`}),Object.setPrototypeOf(this,F.prototype)}}function zt(n){if(n<0)throw new F({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function Zt(n){if(n<0)throw new F({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function Yt(n,t){try{return n()}catch(o){if(t)throw new F(t,o);return console.error(o)}}function Et(n){switch(n){case"THOR":return`${n}.RUNE`;case"GAIA":return`${n}.ATOM`;case"BSC":return`${n}`;default:return`${n}.${n}`}}var Rn=new Set;function Z(n,t){if(n){if(Rn.has(t))return;Rn.add(t),console.warn(t)}}async function Dt(n="thorchain-1"){if(!["thorchain-stagenet-v2","thorchain-1","thorchain-mainnet-v1"].includes(n))return n;try{let t=S.get("rpcUrls")[n!=="thorchain-1"?"THOR_STAGENET":"THOR"];return(await L.get(`${t}/status`)).result.node_info.network}catch(t){return n}}var xn=[...Object.values(g),"TERRA"];function pn(n=""){let t=n.toUpperCase(),[o]=t.split(".");if(xn.includes(o))return!0;let[s]=t.split("/");if(xn.includes(s))return!0;throw new F({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function lt(n){if(n.length>30)return!1;let t=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(t)}var G=8,d=(n)=>10n**BigInt(n),j=(n)=>Math.log10(Number.parseFloat(n.toString()));function I({value:n,bigIntDecimal:t=G,decimal:o=G}){if(o===0)return n.toString();let s=n<0n,h=n.toString().substring(s?1:0),i=o-(h.length-1);if(i>0)h="0".repeat(i)+h;let c=h.length-o,C=h.slice(-o);if(Number.parseInt(C[t]||"0")>=5)C=`${C.substring(0,t-1)}${(Number.parseInt(C[t-1]||"0")+1).toString()}`;else C=C.substring(0,t);return`${s?"-":""}${h.slice(0,c)}.${C}`.replace(/\.?0*$/,"")}class y{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,t){return new y({decimal:t,value:I({value:n,bigIntDecimal:t,decimal:t})})}static shiftDecimals({value:n,from:t,to:o}){return y.fromBigInt(n.getBaseValue("bigint")*d(o)/d(t),o)}constructor(n){let t=l(n),o=typeof n==="object";this.decimal=o?n.decimal:void 0,this.decimalMultiplier=o&&"decimalMultiplier"in n?n.decimalMultiplier:d(Math.max(en(Y(t)),this.decimal||0)),this.#a(t)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString({includeSynthProtocol:!0})})}add(...n){return this.#t("add",...n)}sub(...n){return this.#t("sub",...n)}mul(...n){return this.#t("mul",...n)}div(...n){return this.#t("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,t){let o=this.formatBigIntToSafeValue(this.bigIntValue,t||this.decimal||j(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,t){let o=this.decimalMultiplier/d(t||this.decimal||p.THOR),s=this.bigIntValue/o;switch(n){case"number":return Number(s);case"string":return s.toString();case"bigint":return s;default:return s}}getBigIntValue(n,t){if(!t&&typeof n==="object")return n.bigIntValue;let o=l(n),s=Y(o);if(s==="0"||s==="undefined")return 0n;return this.#s(s,t)}toSignificant(n=6){let[t,o]=this.getValue("string").split("."),s=t||"",h=o||"";if((Number.parseInt(s)?s.length+h.length:h.length)<=n)return this.getValue("string");if(s.length>=n)return s.slice(0,n).padEnd(s.length,"0");if(Number.parseInt(s))return`${s}.${h.slice(0,n-s.length)}`.padEnd(n-s.length,"0");let c=Number.parseInt(h),C=`${c}`.slice(0,n);return`0.${C.padStart(h.length-`${c}`.length+C.length,"0")}`}toFixed(n=6){let[t,o]=this.getValue("string").split("."),s=t||"",h=o||"";if(Number.parseInt(s))return`${s}.${h.slice(0,n)}`.padEnd(n,"0");let i=Number.parseInt(h),c=`${i}`.slice(0,n);return`0.${c.padStart(h.length-`${i}`.length+c.length,"0")}`}toAbbreviation(n=2){let t=this.getValue("number"),o=["","K","M","B","T","Q","Qi","S"],s=Math.floor(Math.log10(Math.abs(t))/3),h=o[s];if(!h)return this.getValue("string");let i=10**(s*3);return`${(t/i).toFixed(n)}${h}`}toCurrency(n="$",{currencyPosition:t="start",decimal:o=2,decimalSeparator:s=".",thousandSeparator:h=","}={}){let i=this.getValue("number"),[c="",C=""]=i.toFixed(6).split("."),e=c.replace(/\B(?=(\d{3})+(?!\d))/g,h),A=c||C?c==="0"?`${Number.parseFloat(`0.${C}`)}`.replace(".",s):`${e}${Number.parseInt(C)?`${s}${C.slice(0,o)}`:""}`:"0.00";return`${t==="start"?n:""}${A}${t==="end"?n:""}`}formatBigIntToSafeValue(n,t){let o=t||this.decimal||G,s=Math.max(o,j(this.decimalMultiplier)),h=n<0n,i=n.toString().substring(h?1:0),c=s-(i.length-1),C=c>0?"0".repeat(c)+i:i,e=C.length-s,A=C.slice(-s);if(Number.parseInt(A[o]||"0")>=5)A=`${A.substring(0,o-1)}${(Number.parseInt(A[o-1]||"0")+1).toString()}`;else A=A.substring(0,o);return`${h?"-":""}${C.slice(0,e)}.${A}`.replace(/\.?0*$/,"")}#t(n,...t){let o=this.#o(this,...t),s=Math.max(o,j(this.decimalMultiplier)),h=d(s),i=t.reduce((C,e)=>{let A=this.getBigIntValue(e,s);switch(n){case"add":return C+A;case"sub":return C-A;case"mul":return C*A/h;case"div":{if(A===0n)throw new RangeError("Division by zero");return C*h/A}default:return C}},this.bigIntValue*h/this.decimalMultiplier),c=I({bigIntDecimal:s,decimal:s,value:i});return new this.constructor({decimalMultiplier:d(s),decimal:this.decimal,value:c,identifier:this.toString()})}#n(n,...t){let o=this.#o(this,...t),s=this.getBigIntValue(t[0]||"0",o),h=this.getBigIntValue(this,o);switch(n){case"gt":return h>s;case"gte":return h>=s;case"lt":return h<s;case"lte":return h<=s;case"eqValue":return h===s;default:return!1}}#a(n){let t=Y(n)||"0";this.bigIntValue=this.#s(t)}#o(...n){let t=n.map((o)=>{return typeof o==="object"?o.decimal||j(o.decimalMultiplier):en(Y(o))}).filter(Boolean);return Math.max(...t,G)}#s(n,t){let o=t?d(t):this.decimalMultiplier,s=j(o),[h="",i=""]=n.split(".");return BigInt(`${h}${i.padEnd(s,"0")}`)}}var Jn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function Y(n){let o=`${typeof n==="number"?Jn.format(n):l(n)}`.replaceAll(",",".").split(".");return o.length>1?`${o.slice(0,-1).join("")}.${o.at(-1)}`:o[0]||"0"}function en(n){let t=n.split(".")[1]?.length||0;return Math.max(t,G)}function l(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n}var E=new Map;class u extends y{address;chain;isGasAsset=!1;isSynthetic=!1;isTradeAsset=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:t,tax:o,chain:s,symbol:h,identifier:i}){super(typeof n==="object"?n:{decimal:t,value:n});let c=nn(i||`${s}.${h}`);this.type=On(c),this.tax=o,this.chain=c.chain,this.ticker=c.ticker,this.symbol=c.symbol,this.address=c.address,this.isSynthetic=c.isSynthetic,this.isTradeAsset=c.isTradeAsset,this.isGasAsset=c.isGasAsset,this.chainId=cn[c.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:t}){return this.chain===n&&this.symbol===t}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,t=0){let[o,s,h]=n.split(".");if(!(o&&s))throw new F({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});let i=o==="THOR"&&h?`${o}.${s}/${h}`:n;return u.from({asset:i,value:t})}static from({value:n=0,fromBaseDecimal:t,asyncTokenLookup:o,...s}){let h=n instanceof y?n.getValue("string"):n,i="chain"in s,c=i?s.chain:s.asset,C=i||Bn.includes(c),{identifier:e,decimal:A}=C?q(c):{identifier:c,decimal:void 0},{chain:x,isSynthetic:O,isTradeAsset:m}=nn(e),k=E.get(x==="SOL"?e:e.toUpperCase()),M=k?.decimal||A;Z(!(o||M),`Couldn't find static decimal for one or more tokens on ${x} (Using default ${p[x]} 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:P,identifier:B,tax:q}=G||{decimal:I||H[A],identifier:F},w=h?D(BigInt(c),h):D(c,P);return t?vn(B,h?w:c):S||$?En(B,w):new g({tax:q,decimal:P,identifier:B,value:w})}static loadStaticAssets(){return new Promise((n,h)=>{try{import("@swapkit/tokens").then((t)=>{for(let o of Object.values(t.tokenLists))for(let{identifier:c,chain:C,...a}of o.tokens)U.set(C==="SOL"?c:c.toUpperCase(),{identifier:c,decimal:"decimals"in a?a.decimals:H[C]});n({ok:!0})})}catch(t){console.error(t),h({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}static fromString(n,h=0){return g.from({asset:n,value:h,asyncTokenLookup:!0})}static fromIdentifier(n,h=0){return g.from({asset:n,value:h,asyncTokenLookup:!0})}static fromStringSync(n,h=0){return g.from({asset:n,value:h})}static fromStringWithBase(n,h=0n,t=H.THOR){return g.from({asyncTokenLookup:!0,asset:n,value:h,fromBaseDecimal:t})}static fromStringWithBaseSync(n,h=0n,t=H.THOR){return g.from({asset:n,value:h,fromBaseDecimal:t})}static fromIdentifierSync(n,h=0){return g.from({asset:n,value:h})}static fromChainOrSignature(n,h=0){if(Object.values(y).includes(n))return g.from({chain:n,value:h});return g.from({asset:n,value:h})}}function _t(n){let h=g.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return h.set(0.00010001);case"DOGE":return h.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return h.set(0.00000001);case"THOR":case"MAYA":return h.set(0);case"GAIA":case"KUJI":return h.set(0.000001);default:return h.set(0.00000001)}}async function vn(n,h=0){Tn(n);let o=n.includes("SOL.")?n:n.toUpperCase(),c=U.get(o),C=c?.decimal||await kn(e(n));if(!c)U.set(o,{identifier:n,decimal:C});return new g({decimal:C,value:D(h,C),identifier:n})}function En(n,h=0){let t=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,o=t?["MAYA","THOR"].includes(t):!1,c=n.slice(0,14).includes("~")?"~":"/",[C,a]=o?n.split(".").slice(1).join().split(c):n.split(c);if(!(C&&a))throw new u({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new g({decimal:8,value:D(h,8),identifier:`${t||"THOR"}.${C}${c}${a}`})}function D(n,h){return typeof n==="bigint"?X({value:n,bigIntDecimal:h,decimal:h}):n}function e(n){let h=n.slice(0,14).includes("/"),t=n.slice(0,14).includes("~"),o=t?"~":"/",c=n.split(".")?.[0]?.toUpperCase()==="THOR",C=n.split(".")?.[0]?.toUpperCase()==="MAYA",[a,i=""]=c||C?n.split(".").slice(1).join().split(o):n.split(o);if((h||t)&&!(a&&i))throw new u({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let F=n.includes(".")&&!h&&!t?n:`${C?"MAYA":"THOR"}.${i}`,[x,...A]=F.split("."),S=h||t?i:A.join("."),$=S.split("-"),G=$.length===1?$[0]:$.slice(0,-1).join("-"),I=$.length===1?void 0:$[$.length-1],P=x==="SOL"?I:I?.toLowerCase();return{address:P,chain:x,isGasAsset:nn({chain:x,symbol:S}),isSynthetic:h,isTradeAsset:t,ticker:G,symbol:(h||t?`${a}${o}`:"")+(P?`${G}-${P??""}`:S)}}var ln="0x313ce567",Nn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`],un=async({chain:n,to:h})=>{try{let{result:t}=await b.post(E[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:ln},"latest"]})});return Number.parseInt(BigInt(t||H[n]).toString())}catch(t){return console.error(t),H[n]}},rn=async({symbol:n})=>{try{let h=n.split("-")[1]?.toLowerCase(),{manager:t}=await b.post(`${E["XRD"]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:h})});return t.divisibility.value.divisibility}catch(h){return console.error(h),H["XRD"]}},en=(n)=>{if(n==="ETH")return H.ETH;let h=n.split("-"),t=h.length===1?void 0:h[h.length-1]?.toLowerCase();return t?.startsWith("0x")?un({chain:"ETH",to:t}):H.ETH},nh=(n)=>{let h=n.split("-"),t=h.length===1?void 0:h[h.length-1];return t?.startsWith("0x")?un({chain:"AVAX",to:t.toLowerCase()}):H.AVAX},hh=(n)=>{if(n==="BSC")return H.BSC;return H.BSC},th=(n)=>{if(n==="XRD")return H.XRD;return rn({symbol:n})},kn=({chain:n,symbol:h})=>{switch(n){case"ETH":return en(h);case"AVAX":return nh(h);case"BSC":return hh(h);case"XRD":return th(h);default:return H[n]}},Gt=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return g.from({asset:`${n}.ETH`});case"MAYA":return g.from({asset:`${n}.CACAO`});case"GAIA":return g.from({asset:`${n}.ATOM`});case"BSC":return g.from({asset:`${n}.BNB`});case"THOR":return g.from({asset:`${n}.RUNE`});default:return g.from({asset:`${n}.${n}`})}},nn=({chain:n,symbol:h})=>{switch(n){case"ARB":case"BASE":case"OP":return h==="ETH";case"MAYA":return h==="CACAO";case"GAIA":return h==="ATOM";case"BSC":return h==="BNB";case"THOR":return h==="RUNE";default:return h===n}},gn=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:H[n]};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case"GAIA":return{identifier:`${n}.ATOM`,decimal:H[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:H[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:H[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case"XRD":return{identifier:`${"XRD"}.XRD`,decimal:H[n]};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:H[n]}}},On=({chain:n,symbol:h})=>{if(h.includes("/"))return"Synth";switch(n){case"ARB":case"OP":case"BASE":return h==="ETH"?"Native":n;case"GAIA":return h==="ATOM"?"Native":n;case"BSC":return h==="BNB"?"Native":n;case"MAYA":return h==="CACAO"?"Native":n;case"THOR":return h==="RUNE"?"Native":n;default:return h===n?"Native":n}},It=(n)=>{let[h,...t]=n.split("."),o=n.includes("/"),c=t.join("."),C=c?.split("-"),a=C?.length?C.length===1?C[0]:C.slice(0,-1).join("-"):void 0;return{chain:h,symbol:c,ticker:a,synth:o}},oh=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),ch=(n)=>{let[h,t]=n.split(".");if(!Q.includes(h))return!0;let o=t.split("-"),c=o.length===1?void 0:o[o.length-1];return nn({chain:h,symbol:t})||!!c},wt=(n)=>n.filter(({chain:h,value:t,symbol:o})=>{let c=`${h}.${o}`;return!oh.test(c)&&ch(c)&&t!=="0"});async function ft(n){let{tokenLists:h}=await import("@swapkit/tokens");for(let t of Object.values(h))for(let{identifier:o,chain:c,...C}of t.tokens){if("identifier"in n&&o===n.identifier)return o;if("address"in C&&"chain"in n&&c===n.chain&&C.address.toLowerCase()===n.contract.toLowerCase())return o}return}var bt={ARB:1,AVAX:3,BASE:1,BSC:3,BTC:600,BCH:600,FLIP:5,GAIA:1.5,DASH:150,DOGE:600,ETH:12.5,FIAT:60,KUJI:2.2,LTC:150,MAYA:6,OP:1,DOT:6,MATIC:2.1,XRD:5,SOL:1,THOR:6};var hn=(n,h)=>{return[...n.slice(0,n.length-1),h]};function zt([n,h,t,o,c]){return`m/${n}'/${h}'/${t}'/${o}${typeof c!=="number"?"":`/${c}`}`}function Zt({chain:n,index:h,addressIndex:t=0,type:o}){if(Q.includes(n)){if(o&&["legacy","account"].includes(o))return[44,60,0,h];if(o==="ledgerLive")return[44,60,h,0,t];return hn(W[n],h)}if(n==="SOL"){if(o==="account")return[44,501,0,h];return hn(W[n],h)}let c=n==="LTC"?2:0;switch(o){case"nativeSegwitMiddleAccount":return[84,c,h,0,t];case"segwit":return[49,c,0,0,h];case"legacy":return[44,c,0,0,h];default:return hn(W[n],h)}}function Yt(n){let[h,t,o]=n.split("/").map((c)=>Number.parseInt(c,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function sh({liquidityUnits:n,poolUnits:h,runeDepth:t}){let o=_(n),c=_(h),C=_(t),a=o.mul(C),i=c.mul(c).mul(2),F=c.mul(o).mul(2),x=o.mul(o),A=c.mul(c).mul(c);return a.mul(i.sub(F).add(x)).div(A)}function Ch({liquidityUnits:n,poolUnits:h,assetDepth:t}){let o=_(n),c=_(h),C=_(t),a=o.mul(C),i=c.mul(c).mul(2),F=c.mul(o).mul(2),x=o.mul(o),A=a.mul(i.sub(F).add(x)),S=c.mul(c).mul(c);return A.div(S)}function Kt({percent:n,runeDepth:h,liquidityUnits:t,poolUnits:o}){return sh({runeDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function Wt({percent:n,assetDepth:h,liquidityUnits:t,poolUnits:o}){return Ch({assetDepth:h,liquidityUnits:t,poolUnits:o}).mul(n)}function _(n){return L.fromBigInt(BigInt(n),H.THOR)}function ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o}){return{assetAmount:_(o).mul(n).div(h),runeAmount:_(t).mul(n).div(h)}}function mt({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o,percent:c}){return Object.fromEntries(Object.entries(ah({liquidityUnits:n,poolUnits:h,runeDepth:t,assetDepth:o})).map(([C,a])=>[C,a.mul(c)]))}function Vt({runeDepth:n,poolUnits:h,assetDepth:t,liquidityUnits:o,runeAmount:c,assetAmount:C}){let a=new L({value:n,decimal:8}),i=new L({value:t,decimal:8}),F=new L({value:h,decimal:8}),x=new L({value:c,decimal:8}),A=new L({value:C,decimal:8}),S=x.mul(i),$=A.mul(a),G=x.mul(A),I=a.mul(i),P=F.mul(S.add($.add(G.mul(2)))),B=S.add($.add(I.mul(2))),q=P.div(B),w=_(o).add(q);if(q.getBaseValue("number")===0)return w.div(F).getBaseValue("number");let N=F.add(w);return w.div(N).getBaseValue("number")}function Ut({runeAmount:n,assetAmount:h,runeDepth:t,assetDepth:o}){if(n==="0"||h==="0"||t==="0"||o==="0")return 0;let c=_(t),C=_(o),a=_(h),i=_(n),F=a.mul(c).sub(C.mul(i)),x=C.mul(i).add(c.mul(C));return Math.abs(F.div(x).getBaseValue("number"))}function ih({type:n,address:h}){return`${n}:${h}`}function ph({address:n,unbondAmount:h}){return`${"UNBOND"}:${n}:${h}`}function lt(n){return M("POOL+",n)}function xh({chain:n,symbol:h,...t}){return M(`${"+"}:${n}/${h}`,t)}function Rh({chain:n,symbol:h,address:t,...o}){let c=Bh({chain:n,symbol:h}),C=t?`:${t}:`:":";return M(`${"+"}:${c}${C}`,o)}function Ah({chain:n,symbol:h,basisPoints:t}){return`${"-"}:${n}/${h}:${t}`}function Hh({chain:n,symbol:h,ticker:t,basisPoints:o,targetAsset:c}){let C=n==="ETH"&&t!=="ETH"?`${t}-${h.slice(-3)}`:h,a=c?`:${c}`:"";return`${"-"}:${n}.${C}:${o}${a}`}function rt({basisPoints:n,...h}){return M(`${"POOL-"}:${n}`,h)}function Fh({name:n,chain:h,address:t,owner:o}){let c=`${"~"}:${n}:${h}:${t}`,C=o?`:${o}`:"";return`${c}${C}`}function et({name:n,chain:h,asset:t,payout:o,owner:c}){return`${"~"}:${n}:${h}:${o}:${c}:${t}`}function Th(n,{asset:h,address:t,minAmount:o,...c}){let C=`${n}:${h}:${t}`,a=o?`:${o}`:"";return M(`${C}${a}`,c)}function M(n,{affiliateAddress:h,affiliateBasisPoints:t}={}){let o=`${n}${h?`:${h}:${t||0}`:""}`;return o.endsWith(":")?o.slice(0,-1):o}function Bh({chain:n,symbol:h}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${h}`}}var no=(n,h)=>{switch(n){case"LEAVE":case"BOND":return ih({type:n,address:h?.address});case"UNBOND":return ph({address:h?.address,unbondAmount:h?.unbondAmount});case"~":return Fh(h);case"$+":case"$-":return Th(n,h);case"+":{let{chain:t,symbol:o,address:c,singleSide:C}=h;if(C)return xh({chain:t,symbol:o});return Rh({chain:t,symbol:o,address:c})}case"-":{let{chain:t,ticker:o,symbol:c,basisPoints:C,targetAssetString:a,singleSide:i}=h;if(i)return Ah({chain:t,symbol:c,basisPoints:C});return Hh({chain:t,ticker:o,symbol:c,basisPoints:C,targetAsset:a})}default:throw new u({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};var Nh=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],kh=(n,h,t)=>async(...o)=>{try{await Oh(h,t)}catch(c){throw new u({errorKey:"helpers_failed_to_switch_network",info:{error:c}})}return n(...o)},Sn=({provider:n,params:h,method:t})=>{if(!n?.send)throw new u("helpers_not_found_provider");let o=h?Array.isArray(h)?h:[h]:[];return n.send(t,o)},co=({toolbox:n,chainId:h,provider:t=window.ethereum})=>{let o=Nh.reduce((c,C)=>{if(!n[C])return c;let a=n[C];if(typeof a!=="function")return c;return{...c,[C]:kh(a,t,h)}},{});return{...n,...o}},gh=(n,h)=>Sn({provider:n,method:"wallet_addEthereumChain",params:[h]}),Oh=(n,h="0x1",t)=>{try{Sn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:h}]})}catch(o){if(!t)throw new Error("Failed to switch network, networkParams not provided");gh(n,t)}},so=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},Co=()=>{let{isTrust:n,isBraveWallet:h,__XDEFI:t,overrideIsMetaMask:o,selectedProvider:c}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(h)return"BRAVE";if(o&&c?.isCoinbaseWallet)return"COINBASE_WEB";if(t)"CTRL";return"METAMASK"},ao=(n)=>{return uh().includes(n)},uh=()=>{let n=window?.ethereum&&!window.ethereum?.isBraveWallet,h=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,o=window?.ethereum?.isTrust||window?.trustwallet,c=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,C=window?.bitkeep?.ethereum,a=[];if(n)a.push("METAMASK");if(h)a.push("CTRL");if(t)a.push("BRAVE");if(o)a.push("TRUSTWALLET_WEB");if(c)a.push("COINBASE_WEB");if(Sh())a.push("OKX_MOBILE");if(C)a.push("BITGET");return a};function io({chain:n,nonEthApiKey:h,ethApiKey:t}){return n==="ETH"?t:h}function po(){let n=[];function h(o){if(n.map((c)=>c.info.uuid).includes(o.detail.info.uuid))return;n.push(o.detail)}window.addEventListener("eip6963:announceProvider",h),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",h)}return{providers:n,removeEIP6963EventListener:t}}var Sh=()=>{let n=navigator.userAgent,h=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),o=h||t,c=/OKApp/i.test(n);return o&&c},xo=()=>typeof window.ethereum!=="undefined";class L extends j{eq(n){return this.eqValue(n)}static fromBigInt(n,h){return new L({decimal:h,value:X({value:n,bigIntDecimal:h,decimal:h})})}}function To(n,h,t){let o=n.filter((C)=>h.includes(C));if(o.length===0)throw new u("wallet_chain_not_supported",{wallet:t,chain:n.join(", ")});let c=n.filter((C)=>!h.includes(C));if(c.length>0)console.warn(`${t} wallet does not support the following chains: ${c.join(", ")}. These chains will be ignored.`);return o}export{it as wrapWithThrow,kh as wrapMethodWithNetworkSwitch,Hn as warnOnce,Ft as validateTNS,Tn as validateIdentifier,hn as updatedLastIndex,Oh as switchEVMWalletNetwork,nt as setRequestClientConfig,co as prepareNetworkSwitch,io as pickEvmApiKey,Sh as okxMobileEnabled,uh as listWeb3EVMWallets,xo as isWeb3Detected,nn as isGasAsset,ao as isDetected,wh as initializeRPCUrlsWithFallback,Yt as getWalletFormatFor,Ct as getTHORNameCost,mt as getSymmetricWithdraw,ah as getSymmetricPoolShare,K as getRPCUrl,_t as getMinAmountByChain,Hh as getMemoForWithdraw,ph as getMemoForUnbond,Ah as getMemoForSaverWithdraw,xh as getMemoForSaverDeposit,rt as getMemoForRunePoolWithdraw,lt as getMemoForRunePoolDeposit,Fh as getMemoForNameRegister,et as getMemoForNamePreferredAssetRegister,Th as getMemoForLoan,ih as getMemoForLeaveAndBond,Rh as getMemoForDeposit,no as getMemoFor,at as getMAYANameCost,Ut as getLiquiditySlippage,Gt as getGasAsset,Vt as getEstimatedPoolShare,Co as getETHDefaultWallet,po as getEIP6963Wallets,xt as getDynamicChainId,Zt as getDerivationPathFor,kn as getDecimal,gn as getCommonAssetInfo,pt as getChainIdentifier,Kt as getAsymmetricRuneWithdrawAmount,sh as getAsymmetricRuneShare,Wt as getAsymmetricAssetWithdrawAmount,Ch as getAsymmetricAssetShare,On as getAssetType,X as formatBigIntToSafeValue,ft as findAssetBy,To as filterSupportedChains,wt as filterAssets,zt as derivationPathToString,Vn as defaultRequestHeaders,bt as blockTimes,It as assetFromString,gh as addEVMWalletNetwork,so as addAccountsChangedCallback,Kn as WarningCodeEnum,xn as WalletOption,Ph as UTXOChains,Gh as TCSupportedChains,L as SwapKitNumber,u as SwapKitError,Lh as SubstrateChains,v as StagenetChain,Zh as SWAP_OUT,zh as SWAP_IN,b as RequestClient,Cn as RPC_URLS,zn as RPCUrl,bn as QuoteMode,Wn as ProviderName,W as NetworkDerivationPath,Rn as MemoType,Ih as MAYASupportedChains,Yn as LedgerErrorCode,mn as FeeTypeEnum,Mn as FeeOption,jn as FALLBACK_URLS,Zn as ExplorerUrl,Qn as ErrorCode,Gn as EXPLORER_URLS,Q as EVMChains,Jn as DerivationPath,jh as CosmosChains,Xn as ContractAddress,Nn as CommonAssetStrings,E as ChainToRPC,fh as ChainToHexChainId,bh as ChainToExplorerUrl,pn as ChainToChainId,_h as ChainIdToChain,J as ChainId,y as Chain,$h as BlockTimes,j as BigIntArithmetics,H as BaseDecimal,g as AssetValue,qn as ApproveMode,Jh as AGG_SWAP};
|
|
4
|
+
or by passing asyncTokenLookup: true to the from() function, which will make it async and return a promise.`);let{decimal:f,identifier:H,tax:r}=k||{decimal:M||p[x],identifier:e},b=t?D(BigInt(h),t):D(h,f);return o?Wn(H,t?b:h):O||m?Qn(H,b):new u({tax:r,decimal:f,identifier:H,value:b})}static async loadStaticAssets(){try{return await import("@swapkit/helpers/tokens").then(({tokenLists:n})=>{for(let{tokens:t}of Object.values(n))for(let{identifier:o,chain:s,...h}of t)E.set(s==="SOL"?o:o.toUpperCase(),{identifier:o,decimal:"decimals"in h?h.decimals:p[s]})}),!0}catch(n){return console.error(n),!1}}}function To(n){let t=u.from({chain:n});switch(n){case"BTC":case"LTC":case"BCH":case"DASH":return t.set(0.00010001);case"DOGE":return t.set(1.00000001);case"AVAX":case"ETH":case"ARB":case"BSC":return t.set(0.00000001);case"THOR":case"MAYA":return t.set(0);case"GAIA":case"KUJI":return t.set(0.000001);default:return t.set(0.00000001)}}async function Wn(n,t=0){pn(n);let s=n.includes("SOL.")?n:n.toUpperCase(),h=E.get(s),i=h?.decimal||await Fn(nn(n));if(!h)E.set(s,{identifier:n,decimal:i});return new u({decimal:i,value:D(t,i),identifier:n})}function Qn(n,t=0){let o=n.includes(".")?n.split(".")?.[0]?.toUpperCase():void 0,s=o?["MAYA","THOR"].includes(o):!1,h=n.slice(0,14).includes("~")?"~":"/",[i,c]=s?n.split(".").slice(1).join().split(h):n.split(h);if(!(i&&c))throw new F({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new u({decimal:8,value:D(t,8),identifier:`${o||"THOR"}.${i}${h}${c}`})}function D(n,t){return typeof n==="bigint"?I({value:n,bigIntDecimal:t,decimal:t}):n}function nn(n){let t=n.slice(0,14).includes("/"),o=n.slice(0,14).includes("~"),s=o?"~":"/",h=n.split(".")?.[0]?.toUpperCase()==="THOR",i=n.split(".")?.[0]?.toUpperCase()==="MAYA",[c,C=""]=h||i?n.split(".").slice(1).join().split(s):n.split(s);if((t||o)&&!(c&&C))throw new F({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});let e=n.includes(".")&&!t&&!o?n:`${i?"MAYA":"THOR"}.${C}`,[A,...x]=e.split("."),O=t||o?C:x.join("."),m=O.split("-"),k=m.length===1?m[0]:m.slice(0,-1).join("-"),M=m.length===1?void 0:m[m.length-1],f=A==="SOL"?M:M?.toLowerCase();return{address:f,chain:A,isGasAsset:tn({chain:A,symbol:O}),isSynthetic:t,isTradeAsset:o,ticker:k,symbol:(t||o?`${c}${s}`:"")+(f?`${k}-${f??""}`:O)}}var Vn="0x313ce567",Bn=[`${"MAYA"}.MAYA`,`${"ETH"}.THOR`,`${"ETH"}.vTHOR`,`${"KUJI"}.USK`,`${"ETH"}.FLIP`,`${"XRD"}.XRD`],un=async({chain:n,to:t})=>{try{let{result:o}=await L.post(S.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:t.toLowerCase(),data:Vn},"latest"]})});return Number.parseInt(BigInt(o||p[n]).toString())}catch(o){return console.error(o),p[n]}},zn=async({symbol:n})=>{try{let t=n.split("-")[1]?.toLowerCase(),{manager:o}=await L.post(`${S.get("rpcUrls").XRD}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:t})});return o.divisibility.value.divisibility}catch(t){return console.error(t),p["XRD"]}},Zn=(n)=>{if(n==="ETH")return p.ETH;let t=n.split("-"),o=t.length===1?void 0:t[t.length-1]?.toLowerCase();return o?.startsWith("0x")?un({chain:"ETH",to:o}):p.ETH},Yn=(n)=>{let t=n.split("-"),o=t.length===1?void 0:t[t.length-1];return o?.startsWith("0x")?un({chain:"AVAX",to:o.toLowerCase()}):p.AVAX},En=(n)=>{if(n==="BSC")return p.BSC;return p.BSC},Dn=(n)=>{if(n==="XRD")return p.XRD;return zn({symbol:n})},Fn=({chain:n,symbol:t})=>{switch(n){case"ETH":return Zn(t);case"AVAX":return Yn(t);case"BSC":return En(t);case"XRD":return Dn(t);default:return p[n]}},Po=({chain:n})=>{switch(n){case"ARB":case"BASE":case"OP":return u.from({asset:`${n}.ETH`});case"MAYA":return u.from({asset:`${n}.CACAO`});case"GAIA":return u.from({asset:`${n}.ATOM`});case"BSC":return u.from({asset:`${n}.BNB`});case"THOR":return u.from({asset:`${n}.RUNE`});default:return u.from({asset:`${n}.${n}`})}},tn=({chain:n,symbol:t})=>{switch(n){case"ARB":case"BASE":case"OP":return t==="ETH";case"MAYA":return t==="CACAO";case"GAIA":return t==="ATOM";case"BSC":return t==="BNB";case"THOR":return t==="RUNE";case"XRD":return`${n}.${t}`===q(n).identifier;default:return t===n}},q=(n)=>{switch(n){case"ARB":case"BASE":case"OP":return{identifier:`${n}.ETH`,decimal:p[n]};case`${"XRD"}.XRD`:case"XRD":return{identifier:"XRD.XRD-resource_rdx1tknxxxxxxxxxradxrdxxxxxxxxx009923554798xxxxxxxxxradxrd",decimal:p.XRD};case`${"ETH"}.FLIP`:return{identifier:"ETH.FLIP-0x826180541412D574cf1336d22c0C0a287822678A",decimal:p.ETH};case`${"ETH"}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:p.ETH};case`${"ETH"}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:p.ETH};case"GAIA":return{identifier:`${n}.ATOM`,decimal:p[n]};case"THOR":return{identifier:`${n}.RUNE`,decimal:p[n]};case"BSC":return{identifier:`${n}.BNB`,decimal:p[n]};case"MAYA":return{identifier:`${n}.CACAO`,decimal:10};case`${"MAYA"}.MAYA`:return{identifier:n,decimal:4};case`${"KUJI"}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:p[n]}}},On=({chain:n,symbol:t})=>{if(t.includes("/"))return"Synth";switch(n){case"XRD":return t==="XRD"||`${n}.${t}`===q(n).identifier?"Native":n;case"ARB":case"OP":case"BASE":return t==="ETH"?"Native":n;case"GAIA":return t==="ATOM"?"Native":n;case"BSC":return t==="BNB"?"Native":n;case"MAYA":return t==="CACAO"?"Native":n;case"THOR":return t==="RUNE"?"Native":n;default:return t===n?"Native":n}},Ho=(n)=>{let[t,...o]=n.split("."),s=n.includes("/"),h=o.join("."),i=h?.split("-"),c=i?.length?i.length===1?i[0]:i.slice(0,-1).join("-"):void 0;return{chain:t,symbol:h,ticker:c,synth:s}},qn=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Kn=(n)=>{let[t,o]=n.split(".");if(!W.includes(t))return!0;let s=o.split("-"),h=s.length===1?void 0:s[s.length-1];return tn({chain:t,symbol:o})||!!h},Bo=(n)=>n.filter(({chain:t,value:o,symbol:s})=>{let h=`${t}.${s}`;return!qn.test(h)&&Kn(h)&&o!=="0"});async function Fo(n){let{tokenLists:t}=await import("@swapkit/helpers/tokens");for(let o of Object.values(t))for(let{identifier:s,chain:h,...i}of o.tokens){if("identifier"in n&&s===n.identifier)return s;if("address"in i&&"chain"in n&&h===n.chain&&i.address.toLowerCase()===n.contract.toLowerCase())return s}return}var Oo={ARB:1,AVAX:3,BASE:1,BSC:3,BTC:600,BCH:600,FLIP:5,GAIA:1.5,DASH:150,DOGE:600,ETH:12.5,FIAT:60,KUJI:2.2,LTC:150,MAYA:6,OP:1,DOT:6,MATIC:2.1,XRD:5,SOL:1,THOR:6};var on=(n,t)=>{return[...n.slice(0,n.length-1),t]};function go([n,t,o,s,h]){return`m/${n}'/${t}'/${o}'/${s}${typeof h!=="number"?"":`/${h}`}`}function mo({chain:n,index:t,addressIndex:o=0,type:s}){if(W.includes(n)){if(s&&["legacy","account"].includes(s))return[44,60,0,t];if(s==="ledgerLive")return[44,60,t,0,o];return on(V[n],t)}if(n==="SOL"){if(s==="account")return[44,501,0,t];return on(V[n],t)}let h=n==="LTC"?2:0;switch(s){case"nativeSegwitMiddleAccount":return[84,h,t,0,o];case"segwit":return[49,h,0,0,t];case"legacy":return[44,h,0,0,t];default:return on(V[n],t)}}function No(n){let[t,o,s]=n.split("/").map((h)=>Number.parseInt(h,10));switch(o){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}function vn({liquidityUnits:n,poolUnits:t,runeDepth:o}){let s=_(n),h=_(t),i=_(o),c=s.mul(i),C=h.mul(h).mul(2),e=h.mul(s).mul(2),A=s.mul(s),x=h.mul(h).mul(h);return c.mul(C.sub(e).add(A)).div(x)}function ln({liquidityUnits:n,poolUnits:t,assetDepth:o}){let s=_(n),h=_(t),i=_(o),c=s.mul(i),C=h.mul(h).mul(2),e=h.mul(s).mul(2),A=s.mul(s),x=c.mul(C.sub(e).add(A)),O=h.mul(h).mul(h);return x.div(O)}function yo({percent:n,runeDepth:t,liquidityUnits:o,poolUnits:s}){return vn({runeDepth:t,liquidityUnits:o,poolUnits:s}).mul(n)}function ko({percent:n,assetDepth:t,liquidityUnits:o,poolUnits:s}){return ln({assetDepth:t,liquidityUnits:o,poolUnits:s}).mul(n)}function _(n){return $.fromBigInt(BigInt(n),p.THOR)}function nt({liquidityUnits:n,poolUnits:t,runeDepth:o,assetDepth:s}){return{assetAmount:_(s).mul(n).div(t),runeAmount:_(o).mul(n).div(t)}}function Mo({liquidityUnits:n,poolUnits:t,runeDepth:o,assetDepth:s,percent:h}){return Object.fromEntries(Object.entries(nt({liquidityUnits:n,poolUnits:t,runeDepth:o,assetDepth:s})).map(([i,c])=>[i,c.mul(h)]))}function bo({runeDepth:n,poolUnits:t,assetDepth:o,liquidityUnits:s,runeAmount:h,assetAmount:i}){let c=new $({value:n,decimal:8}),C=new $({value:o,decimal:8}),e=new $({value:t,decimal:8}),A=new $({value:h,decimal:8}),x=new $({value:i,decimal:8}),O=A.mul(C),m=x.mul(c),k=A.mul(x),M=c.mul(C),f=e.mul(O.add(m.add(k.mul(2)))),H=O.add(m.add(M.mul(2))),r=f.div(H),b=_(s).add(r);if(r.getBaseValue("number")===0)return b.div(e).getBaseValue("number");let B=e.add(b);return b.div(B).getBaseValue("number")}function Lo({runeAmount:n,assetAmount:t,runeDepth:o,assetDepth:s}){if(n==="0"||t==="0"||o==="0"||s==="0")return 0;let h=_(o),i=_(s),c=_(t),C=_(n),e=c.mul(h).sub(i.mul(C)),A=i.mul(C).add(h.mul(i));return Math.abs(e.div(A).getBaseValue("number"))}function Xo({type:n,address:t}){return`${n}:${t}`}function ro({address:n,unbondAmount:t}){return`${"UNBOND"}:${n}:${t}`}function wo(n){return X("POOL+",n)}function Uo({chain:n,symbol:t,...o}){return X(`${"+"}:${n}/${t}`,o)}function Jo({chain:n,symbol:t,address:o,...s}){let h=tt({chain:n,symbol:t}),i=o?`:${o}:`:":";return X(`${"+"}:${h}${i}`,s)}function Wo({chain:n,symbol:t,basisPoints:o}){return`${"-"}:${n}/${t}:${o}`}function Qo({chain:n,symbol:t,ticker:o,basisPoints:s,targetAsset:h}){let i=n==="ETH"&&o!=="ETH"?`${o}-${t.slice(-3)}`:t,c=h?`:${h}`:"";return`${"-"}:${n}.${i}:${s}${c}`}function Vo({basisPoints:n,...t}){return X(`${"POOL-"}:${n}`,t)}function zo({name:n,chain:t,address:o,owner:s}){let h=`${"~"}:${n}:${t}:${o}`,i=s?`:${s}`:"";return`${h}${i}`}function Zo({name:n,chain:t,asset:o,payout:s,owner:h}){return`${"~"}:${n}:${t}:${s}:${h}:${o}`}function Yo(n,{asset:t,address:o,minAmount:s,...h}){let i=`${n}:${t}:${o}`,c=s?`:${s}`:"";return X(`${i}${c}`,h)}function X(n,{affiliateAddress:t,affiliateBasisPoints:o}={}){let s=`${n}${t?`:${t}:${o||0}`:""}`;return s.endsWith(":")?s.slice(0,-1):s}function tt({chain:n,symbol:t}){switch(n){case"BTC":case"DOGE":case"LTC":return n.slice(0,1).toLowerCase();case"BCH":return"c";default:return`${n}.${t}`}}function Do({name:n,properties:t,methods:o}){function s(h){return{...o(h),...t}}return{[n]:s}}function ns(){return typeof window.ethereum!=="undefined"}function ts(n){return ot().includes(n)}function ot(){let n=window?.ethereum&&!window.ethereum?.isBraveWallet,t=window?.xfi||window?.ethereum?.__XDEFI,o=window?.ethereum?.isBraveWallet,s=window?.ethereum?.isTrust||window?.trustwallet,h=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,i=window?.bitkeep?.ethereum,c=[];if(n)c.push("METAMASK");if(t)c.push("CTRL");if(o)c.push("BRAVE");if(s)c.push("TRUSTWALLET_WEB");if(h)c.push("COINBASE_WEB");if(it())c.push("OKX_MOBILE");if(i)c.push("BITGET");return c}async function st(n,t,o){try{await _n({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:Cn[t]}]})}catch(s){if(!o)throw new Error("Failed to switch network, networkParams not provided");await ht(n,o)}}function os({chains:n,supportedChains:t,walletType:o}){let s=n.filter((i)=>t.includes(i));if(s.length===0)throw new F("wallet_chain_not_supported",{wallet:o,chain:n.join(", ")});let h=n.filter((i)=>!t.includes(i));return Z(h.length>0,`${o} wallet does not support the following chains: ${h.join(", ")}. These chains will be ignored.`),s}function at(n,t,o){}function ss({toolbox:n,chain:t,provider:o=window.ethereum,methodNames:s=[]}){let i=[...s,"approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"].reduce((c,C)=>{if(!n[C])return c;let e=n[C];if(typeof e!=="function")return c;return{...c,[C]:at(e,o,t)}},{});return{...n,...i}}function ht(n,t){return _n({provider:n,method:"wallet_addEthereumChain",params:[t]})}function as(n){window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())}function hs(){let{isTrust:n,isBraveWallet:t,__XDEFI:o,overrideIsMetaMask:s,selectedProvider:h}=window?.ethereum||{};if(n)return"TRUSTWALLET_WEB";if(t)return"BRAVE";if(s&&h?.isCoinbaseWallet)return"COINBASE_WEB";if(o)"CTRL";return"METAMASK"}function is(){let n=[];function t(s){if(n.map((h)=>h.info.uuid).includes(s.detail.info.uuid))return;n.push(s.detail)}window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider"));function o(){window.removeEventListener("eip6963:announceProvider",t)}return{providers:n,removeEIP6963EventListener:o}}function it(){let n=navigator.userAgent,t=/iphone|ipad|ipod|ios/i.test(n),o=/android|XiaoMi|MiuiBrowser/i.test(n),s=t||o,h=/OKApp/i.test(n);return s&&h}function cs({connect:n,name:t,supportedChains:o,walletType:s}){function h(i){return n({...i,walletType:s,supportedChains:o})}return{[t]:{supportedChains:o,connectWallet:h}}}function _n({provider:n,params:t,method:o}){if(!n?.send)throw new F("helpers_not_found_provider");let s=t?Array.isArray(t)?t:[t]:[];return n.send(o,s)}class $ extends y{eq(n){return this.eqValue(n)}static fromBigInt(n,t){return new $({decimal:t,value:I({value:n,bigIntDecimal:t,decimal:t})})}}export{Yt as wrapWithThrow,at as wrapMethodWithNetworkSwitch,Z as warnOnce,lt as validateTNS,pn as validateIdentifier,on as updatedLastIndex,st as switchEVMWalletNetwork,ss as prepareNetworkSwitch,it as okxMobileEnabled,ot as listWeb3EVMWallets,ns as isWeb3Detected,tn as isGasAsset,ts as isDetected,Pt as initializeRPCUrlsWithFallback,No as getWalletFormatFor,zt as getTHORNameCost,Mo as getSymmetricWithdraw,nt as getSymmetricPoolShare,To as getMinAmountByChain,Qo as getMemoForWithdraw,ro as getMemoForUnbond,Wo as getMemoForSaverWithdraw,Uo as getMemoForSaverDeposit,Vo as getMemoForRunePoolWithdraw,wo as getMemoForRunePoolDeposit,zo as getMemoForNameRegister,Zo as getMemoForNamePreferredAssetRegister,Yo as getMemoForLoan,Xo as getMemoForLeaveAndBond,Jo as getMemoForDeposit,Zt as getMAYANameCost,Lo as getLiquiditySlippage,Po as getGasAsset,bo as getEstimatedPoolShare,hs as getETHDefaultWallet,is as getEIP6963Wallets,Dt as getDynamicChainId,mo as getDerivationPathFor,Fn as getDecimal,q as getCommonAssetInfo,Et as getChainIdentifier,yo as getAsymmetricRuneWithdrawAmount,vn as getAsymmetricRuneShare,ko as getAsymmetricAssetWithdrawAmount,ln as getAsymmetricAssetShare,On as getAssetType,I as formatBigIntToSafeValue,Fo as findAssetBy,os as filterSupportedChains,Bo as filterAssets,go as derivationPathToString,wn as defaultRequestHeaders,cs as createWallet,Do as createPlugin,Oo as blockTimes,Ho as assetFromString,ht as addEVMWalletNetwork,as as addAccountsChangedCallback,bn as WarningCodeEnum,An as WalletOption,At as UTXOChains,pt as TCSupportedChains,$ as SwapKitNumber,F as SwapKitError,Tt as SubstrateChains,K as StagenetChain,ut as SWAP_OUT,Ot as SWAP_IN,S as SKConfig,L as RequestClient,Q as RPC_URLS,Sn as QuoteMode,dn as ProviderName,V as NetworkDerivationPath,w as NODE_URLS,Tn as MemoType,et as MAYASupportedChains,Gn as LedgerErrorCode,Ln as FeeTypeEnum,In as FeeOption,mn as FALLBACK_URLS,Mn as ErrorCode,v as EXPLORER_URLS,W as EVMChains,kn as DerivationPath,Rt as CosmosChains,xt as CosmosChainPrefixes,yn as ContractAddress,Bn as CommonAssetStrings,Cn as ChainToHexChainId,Ht as ChainToExplorerUrl,cn as ChainToChainId,ct as ChainIdToChain,U as ChainId,g as Chain,Ct as BlockTimes,y as BigIntArithmetics,p as BaseDecimal,u as AssetValue,jn as ApproveMode,Ft as AGG_SWAP};
|
|
5
5
|
|
|
6
|
-
//# debugId=
|
|
6
|
+
//# debugId=58EB5A8A43F1B6C464756E2164756E21
|