@swapkit/helpers 1.0.0-rc.113 → 1.0.0-rc.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2901 +1,3 @@
1
- var __require = ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
- }) : x)(function(x) {
4
- if (typeof require !== "undefined")
5
- return require.apply(this, arguments);
6
- throw Error('Dynamic require of "' + x + '" is not supported');
7
- });
1
+ var an=((n)=>typeof require!=="undefined"?require:typeof Proxy!=="undefined"?new Proxy(n,{get:(e,t)=>(typeof require!=="undefined"?require:e)[t]}):n)(function(n){if(typeof require!=="undefined")return require.apply(this,arguments);throw Error('Dynamic require of "'+n+'" is not supported')});var oe=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"spender",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"value",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"",type:"address"},{internalType:"address",name:"",type:"address"}],name:"allowance",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"spender",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"approve",outputs:[{internalType:"bool",name:"success",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transfer",outputs:[{internalType:"bool",name:"success",type:"bool"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"value",type:"uint256"}],name:"transferFrom",outputs:[{internalType:"bool",name:"success",type:"bool"}],stateMutability:"nonpayable",type:"function"}];var we=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferAllowance",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOut",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!1,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"address",name:"finalAsset",type:"address"},{indexed:!1,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amountOutMin",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOutAndCall",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],indexed:!1,internalType:"struct MAYAChain_Router.Coin[]",name:"coins",type:"tuple[]"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"VaultTransfer",type:"event"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"},{internalType:"uint256",name:"expiration",type:"uint256"}],name:"depositWithExpiry",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address payable",name:"asgard",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct MAYAChain_Router.Coin[]",name:"coins",type:"tuple[]"},{internalType:"string",name:"memo",type:"string"}],name:"returnVaultAssets",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address",name:"newVault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferAllowance",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"to",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOut",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"target",type:"address"},{internalType:"address",name:"finalToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountOutMin",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOutAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"vault",type:"address"},{internalType:"address",name:"token",type:"address"}],name:"vaultAllowance",outputs:[{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"}],Oe=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferAllowance",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOut",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!1,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"address",name:"finalAsset",type:"address"},{indexed:!1,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amountOutMin",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOutAndCall",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],indexed:!1,internalType:"struct ArbRouter.Coin[]",name:"coins",type:"tuple[]"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"VaultTransfer",type:"event"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"},{internalType:"uint256",name:"expiration",type:"uint256"}],name:"depositWithExpiry",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address payable",name:"asgard",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct ArbRouter.Coin[]",name:"coins",type:"tuple[]"},{internalType:"string",name:"memo",type:"string"}],name:"returnVaultAssets",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address",name:"newVault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferAllowance",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"to",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOut",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"target",type:"address"},{internalType:"address",name:"finalToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountOutMin",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOutAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"vault",type:"address"},{internalType:"address",name:"token",type:"address"}],name:"vaultAllowance",outputs:[{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"}];var _e=[{inputs:[{internalType:"address",name:"rune",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferAllowance",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOut",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!1,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"address",name:"finalAsset",type:"address"},{indexed:!1,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amountOutMin",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOutAndCall",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],indexed:!1,internalType:"struct THORChain_Router.Coin[]",name:"coins",type:"tuple[]"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"VaultTransfer",type:"event"},{inputs:[],name:"RUNE",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"},{internalType:"uint256",name:"expiration",type:"uint256"}],name:"depositWithExpiry",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address payable",name:"asgard",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct THORChain_Router.Coin[]",name:"coins",type:"tuple[]"},{internalType:"string",name:"memo",type:"string"}],name:"returnVaultAssets",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address",name:"newVault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferAllowance",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"to",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOut",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"aggregator",type:"address"},{internalType:"address",name:"finalToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountOutMin",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOutAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"vault",type:"address"},{internalType:"address",name:"token",type:"address"}],name:"vaultAllowance",outputs:[{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"}],$e=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferAllowance",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOut",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!1,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"address",name:"finalAsset",type:"address"},{indexed:!1,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amountOutMin",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOutAndCall",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],indexed:!1,internalType:"struct AvaxRouter.Coin[]",name:"coins",type:"tuple[]"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"VaultTransfer",type:"event"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"deposit",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"},{internalType:"uint256",name:"expiration",type:"uint256"}],name:"depositWithExpiry",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address payable",name:"asgard",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct AvaxRouter.Coin[]",name:"coins",type:"tuple[]"},{internalType:"string",name:"memo",type:"string"}],name:"returnVaultAssets",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address",name:"newVault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferAllowance",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"to",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOut",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"target",type:"address"},{internalType:"address",name:"finalToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountOutMin",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOutAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"vault",type:"address"},{internalType:"address",name:"token",type:"address"}],name:"vaultAllowance",outputs:[{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"}],Ge=[{inputs:[],stateMutability:"nonpayable",type:"constructor"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"Deposit",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferAllowance",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"address",name:"asset",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOut",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"vault",type:"address"},{indexed:!1,internalType:"address",name:"target",type:"address"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"},{indexed:!1,internalType:"address",name:"finalAsset",type:"address"},{indexed:!1,internalType:"address",name:"to",type:"address"},{indexed:!1,internalType:"uint256",name:"amountOutMin",type:"uint256"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"TransferOutAndCall",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"oldVault",type:"address"},{indexed:!0,internalType:"address",name:"newVault",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],indexed:!1,internalType:"struct THORChain_Router.Coin[]",name:"coins",type:"tuple[]"},{indexed:!1,internalType:"string",name:"memo",type:"string"}],name:"VaultTransfer",type:"event"},{inputs:[{internalType:"address payable",name:"vault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"},{internalType:"uint256",name:"expiration",type:"uint256"}],name:"depositWithExpiry",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address payable",name:"asgard",type:"address"},{components:[{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"}],internalType:"struct THORChain_Router.Coin[]",name:"coins",type:"tuple[]"},{internalType:"string",name:"memo",type:"string"}],name:"returnVaultAssets",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"router",type:"address"},{internalType:"address",name:"newVault",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferAllowance",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address payable",name:"to",type:"address"},{internalType:"address",name:"asset",type:"address"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOut",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address payable",name:"target",type:"address"},{internalType:"address",name:"finalToken",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"amountOutMin",type:"uint256"},{internalType:"string",name:"memo",type:"string"}],name:"transferOutAndCall",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"vault",type:"address"},{internalType:"address",name:"token",type:"address"}],name:"vaultAllowance",outputs:[{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"}];var M;(function(m){m["Arbitrum"]="https://arb1.arbitrum.io/rpc";m["Avalanche"]="https://node-router.thorswap.net/avalanche-c";m["Binance"]="";m["BinanceSmartChain"]="https://bsc-dataseed.binance.org";m["Bitcoin"]="https://node-router.thorswap.net/bitcoin";m["BitcoinCash"]="https://node-router.thorswap.net/bitcoin-cash";m["Chainflip"]="wss://mainnet-archive.chainflip.io";m["Cosmos"]="https://node-router.thorswap.net/cosmos/rpc";m["Dash"]="https://node-router.thorswap.net/dash";m["Dogecoin"]="https://node-router.thorswap.net/dogecoin";m["Ethereum"]="https://node-router.thorswap.net/ethereum";m["Kujira"]="https://rpc-kujira.synergynodes.com/";m["Litecoin"]="https://node-router.thorswap.net/litecoin";m["Maya"]="https://tendermint.mayachain.info";m["MayaStagenet"]="https://stagenet.tendermint.mayachain.info";m["Optimism"]="https://mainnet.optimism.io";m["Polkadot"]="wss://rpc.polkadot.io";m["Polygon"]="https://polygon-rpc.com";m["Radix"]="https://radix-mainnet.rpc.grove.city/v1/326002fc/core";m["THORChain"]="https://rpc.thorswap.net";m["THORChainStagenet"]="https://stagenet-rpc.ninerealms.com";m["Solana"]="https://mainnet.helius-rpc.com/?api-key=2cbe3ae6-cfc5-4141-a093-0055d0fa3d80"})(M||(M={}));var Q;(function(d){d["Arbitrum"]="https://arbiscan.io";d["Avalanche"]="https://snowtrace.io";d["Binance"]="https://explorer.binance.org";d["BinanceSmartChain"]="https://bscscan.com";d["Bitcoin"]="https://blockchair.com/bitcoin";d["BitcoinCash"]="https://www.blockchair.com/bitcoin-cash";d["Chainflip"]="https://explorer.polkascan.io/polkadot";d["Cosmos"]="https://www.mintscan.io/cosmos";d["Dash"]="https://blockchair.com/dash";d["Dogecoin"]="https://blockchair.com/dogecoin";d["Ethereum"]="https://etherscan.io";d["Kujira"]="https://finder.kujira.network/kaiyo-1";d["Litecoin"]="https://blockchair.com/litecoin";d["Maya"]="https://www.mayascan.org";d["Optimism"]="https://optimistic.etherscan.io";d["Polkadot"]="https://polkadot.subscan.io";d["Polygon"]="https://polygonscan.com";d["Radix"]="https://dashboard.radixdlt.com";d["THORChain"]="https://runescan.io";d["Solana"]="https://solscan.io"})(Q||(Q={}));var s;(function(d){d["Arbitrum"]="ARB";d["Avalanche"]="AVAX";d["Binance"]="BNB";d["BinanceSmartChain"]="BSC";d["Bitcoin"]="BTC";d["BitcoinCash"]="BCH";d["Cosmos"]="GAIA";d["Dash"]="DASH";d["Dogecoin"]="DOGE";d["Ethereum"]="ETH";d["Kujira"]="KUJI";d["Litecoin"]="LTC";d["Maya"]="MAYA";d["Optimism"]="OP";d["Polkadot"]="DOT";d["Chainflip"]="FLIP";d["Polygon"]="MATIC";d["Radix"]="XRD";d["THORChain"]="THOR";d["Solana"]="SOL"})(s||(s={}));var w;(function(T){T["Arbitrum"]="42161";T["ArbitrumHex"]="0xa4b1";T["Avalanche"]="43114";T["AvalancheHex"]="0xa86a";T["Binance"]="Binance-Chain-Tigris";T["BinanceSmartChain"]="56";T["BinanceSmartChainHex"]="0x38";T["Bitcoin"]="bitcoin";T["BitcoinCash"]="bitcoincash";T["Chainflip"]="chainflip";T["Cosmos"]="cosmoshub-4";T["Dash"]="dash";T["Dogecoin"]="dogecoin";T["Kujira"]="kaiyo-1";T["Ethereum"]="1";T["EthereumHex"]="0x1";T["Litecoin"]="litecoin";T["Maya"]="mayachain-mainnet-v1";T["MayaStagenet"]="mayachain-stagenet-v1";T["Optimism"]="10";T["OptimismHex"]="0xa";T["Polkadot"]="polkadot";T["Polygon"]="137";T["PolygonHex"]="0x89";T["Radix"]="radix-mainnet";T["THORChain"]="thorchain-mainnet-v1";T["THORChainStagenet"]="thorchain-stagenet-v2";T["Solana"]="solana"})(w||(w={}));var Ze={[w.ArbitrumHex]:s.Arbitrum,[w.Arbitrum]:s.Arbitrum,[w.AvalancheHex]:s.Avalanche,[w.Avalanche]:s.Avalanche,[w.BinanceSmartChainHex]:s.BinanceSmartChain,[w.BinanceSmartChain]:s.BinanceSmartChain,[w.Binance]:s.Binance,[w.BitcoinCash]:s.BitcoinCash,[w.Bitcoin]:s.Bitcoin,[w.Chainflip]:s.Chainflip,[w.Cosmos]:s.Cosmos,[w.Dash]:s.Dash,[w.Dogecoin]:s.Dogecoin,[w.EthereumHex]:s.Ethereum,[w.Kujira]:s.Kujira,[w.Ethereum]:s.Ethereum,[w.Litecoin]:s.Litecoin,[w.MayaStagenet]:s.Maya,[w.Maya]:s.Maya,[w.OptimismHex]:s.Optimism,[w.Optimism]:s.Optimism,[w.Polkadot]:s.Polkadot,[w.PolygonHex]:s.Polygon,[w.Polygon]:s.Polygon,[w.Radix]:s.Radix,[w.THORChainStagenet]:s.THORChain,[w.THORChain]:s.THORChain,[w.Solana]:s.Solana},bn=Object.keys(s),V=Object.values(s),O;(function(f){f[f["ARB"]=18]="ARB";f[f["AVAX"]=18]="AVAX";f[f["BCH"]=8]="BCH";f[f["BNB"]=8]="BNB";f[f["BSC"]=18]="BSC";f[f["BTC"]=8]="BTC";f[f["DASH"]=8]="DASH";f[f["DOGE"]=8]="DOGE";f[f["DOT"]=10]="DOT";f[f["ETH"]=18]="ETH";f[f["FLIP"]=18]="FLIP";f[f["GAIA"]=6]="GAIA";f[f["KUJI"]=6]="KUJI";f[f["LTC"]=8]="LTC";f[f["MATIC"]=18]="MATIC";f[f["MAYA"]=10]="MAYA";f[f["OP"]=18]="OP";f[f["SOL"]=9]="SOL";f[f["THOR"]=8]="THOR";f[f["XRD"]=18]="XRD";f[f["ZEC"]=8]="ZEC"})(O||(O={}));var ke=[s.Polkadot,s.Chainflip],l=[s.Ethereum,s.Avalanche,s.BinanceSmartChain,s.Arbitrum,s.Optimism,s.Polygon],Re=[s.Bitcoin,s.BitcoinCash,s.Dash,s.Dogecoin,s.Litecoin],Ye=[s.Cosmos,s.THORChain,s.Binance,s.Maya,s.Kujira],Le=[s.Avalanche,s.Binance,s.BinanceSmartChain,s.Bitcoin,s.BitcoinCash,s.Cosmos,s.Dogecoin,s.Ethereum,s.Litecoin,s.THORChain],qe=[s.Arbitrum,s.Dash,s.Ethereum,s.Kujira,s.Maya,s.THORChain],W=V.reduce((n,e)=>{const t=bn.find((p)=>s[p]===e);if(t)n[e]=t;return n},{}),dn=V.reduce((n,e)=>{return n[e]=w[W[e]],n},{}),c=V.reduce((n,e)=>{return n[e]=M[W[e]],n},{}),be=V.reduce((n,e)=>{const t=`${W[e]}Hex`;return n[e]=w[t],n},{}),Ke=V.reduce((n,e)=>{return n[e]=Q[W[e]],n},{});var G;(function(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"})(G||(G={}));var Ae=[G.ETH_TO_ETH,G.AVAX_TO_AVAX,G.BSC_TO_BSC],Ve=[G.ETH_TO_TC_SUPPORTED,G.ETH_TO_AVAX,G.ETH_TO_BSC,G.AVAX_TO_TC_SUPPORTED,G.AVAX_TO_ETH,G.AVAX_TO_BSC,G.BSC_TO_TC_SUPPORTED,G.BSC_TO_ETH,G.BSC_TO_AVAX],ge=[G.TC_SUPPORTED_TO_TC_SUPPORTED,G.TC_SUPPORTED_TO_ETH,G.TC_SUPPORTED_TO_AVAX,G.TC_SUPPORTED_TO_BSC];var un;(function(u){u["ARB"]="0x0000000000000000000000000000000000000000";u["AVAX"]="0x0000000000000000000000000000000000000000";u["ETH"]="0x0000000000000000000000000000000000000000";u["BSC"]="0x0000000000000000000000000000000000000000";u["MATIC"]="0x0000000000000000000000000000000000001010";u["OP"]="0x4200000000000000000000000000000000000042"})(un||(un={}));var rn;(function(d){d["ARB"]="m/44'/60'/0'/0";d["AVAX"]="m/44'/60'/0'/0";d["BCH"]="m/44'/145'/0'/0";d["BNB"]="m/44'/714'/0'/0";d["BSC"]="m/44'/60'/0'/0";d["BTC"]="m/84'/0'/0'/0";d["DASH"]="m/44'/5'/0'/0";d["DOGE"]="m/44'/3'/0'/0";d["DOT"]="////";d["ETH"]="m/44'/60'/0'/0";d["FLIP"]="////";d["GAIA"]="m/44'/118'/0'/0";d["KUJI"]="m/44'/118'/0'/0";d["LTC"]="m/84'/2'/0'/0";d["MATIC"]="m/44'/60'/0'/0";d["MAYA"]="m/44'/931'/0'/0";d["OP"]="m/44'/60'/0'/0";d["SOL"]="m/44'/501'/0'/0";d["THOR"]="m/44'/931'/0'/0";d["XRD"]="////"})(rn||(rn={}));var E={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BCH:[44,145,0,0,0],BNB:[44,714,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],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var J;(function(i){i["BRAVE"]="BRAVE";i["COINBASE_MOBILE"]="COINBASE_MOBILE";i["COINBASE_WEB"]="COINBASE_WEB";i["EIP6963"]="EIP6963";i["EXODUS"]="EXODUS";i["KEEPKEY"]="KEEPKEY";i["KEPLR"]="KEPLR";i["KEYSTORE"]="KEYSTORE";i["LEDGER"]="LEDGER";i["METAMASK"]="METAMASK";i["OKX"]="OKX";i["OKX_MOBILE"]="OKX_MOBILE";i["PHANTOM"]="PHANTOM";i["RADIX_WALLET"]="RADIX_WALLET";i["TREZOR"]="TREZOR";i["TALISMAN"]="TALISMAN";i["TRUSTWALLET_WEB"]="TRUSTWALLET_WEB";i["WALLETCONNECT"]="WALLETCONNECT";i["XDEFI"]="XDEFI"})(J||(J={}));var Tn;(function(p){p[p["NoError"]=36864]="NoError";p[p["LockedDevice"]=21781]="LockedDevice";p[p["TC_NotFound"]=65535]="TC_NotFound"})(Tn||(Tn={}));import{z as $} from"zod";var xn;(function(p){p["Average"]="average";p["Fast"]="fast";p["Fastest"]="fastest"})(xn||(xn={}));var mn;(function(t){t["Approve"]="approve";t["CheckOnly"]="checkOnly"})(mn||(mn={}));var X;(function(o){o["BOND"]="BOND";o["DEPOSIT"]="+";o["LEAVE"]="LEAVE";o["NAME_REGISTER"]="~";o["UNBOND"]="UNBOND";o["WITHDRAW"]="-";o["OPEN_LOAN"]="$+";o["CLOSE_LOAN"]="$-"})(X||(X={}));var le=$.object({sellAsset:$.string({description:"Asset to sell"}),buyAsset:$.string({description:"Asset to buy"}),sellAmount:$.number({description:"Amount of asset to sell"}).refine((n)=>n>0,{message:"sellAmount must be greater than 0",path:["sellAmount"]}),providers:$.optional($.array($.string({description:"List of providers to use"}))),sourceAddress:$.optional($.string({description:"Address to send asset from"})),destinationAddress:$.optional($.string({description:"Address to send asset to"})),slippage:$.optional($.number({description:"Slippage tolerance as a percentage. Default is 3%."})),affiliate:$.optional($.string({description:"Affiliate thorname"})),affiliateFee:$.optional($.number({description:"Affiliate fee in basis points"}).refine((n)=>{return n===Math.floor(n)&&n>=0},{message:"affiliateFee must be a positive integer",path:["affiliateFee"]})),allowSmartContractSender:$.optional($.boolean({description:"Allow smart contract as sender"})),allowSmartContractReceiver:$.optional($.boolean({description:"Allow smart contract as recipient"})),disableSecurityChecks:$.optional($.boolean({description:"Disable security checks"}))}).refine((n)=>n.sellAsset!==n.buyAsset,{message:"Must be different",path:["sellAsset","buyAsset"]});import{z as y} from"zod";var D;(function(t){t["highSlippage"]="highSlippage";t["highPriceImpact"]="highPriceImpact"})(D||(D={}));var Kn=y.array(y.union([y.string(),y.number(),y.array(y.string()),y.object({from:y.string(),value:y.string()}).describe("Parameters to pass to the contract method")])),fn=y.object({contractAddress:y.string({description:"Address of the contract to interact with"}),contractMethod:y.string({description:"Name of the method to call"}),contractParams:Kn,contractParamNames:y.array(y.string({description:"Names of the parameters to pass to the contract method"})),approvalToken:y.optional(y.string({description:"Address of the token to approve spending of"})),approvalSpender:y.optional(y.string({description:"Address of the spender to approve"}))}),I=y.object({inbound:y.optional(y.number({description:"Time to receive inbound asset in seconds"})),swap:y.optional(y.number({description:"Time to swap assets in seconds"})),outbound:y.optional(y.number({description:"Time to receive outbound asset in seconds"})),total:y.number({description:"Total time in seconds"})}),Y;(function(j){j["CHAINFLIP"]="CHAINFLIP";j["TRADERJOE_V1"]="TRADERJOE_V1";j["PANGOLIN_V1"]="PANGOLIN_V1";j["UNISWAP_V2"]="UNISWAP_V2";j["THORCHAIN"]="THORCHAIN";j["THORCHAIN_STREAMING"]="THORCHAIN_STREAMING";j["MAYACHAIN"]="MAYACHAIN";j["ONEINCH"]="ONEINCH";j["SUSHISWAP_V2"]="SUSHISWAP_V2";j["WOOFI_V2"]="WOOFI_V2";j["PANCAKESWAP"]="PANCAKESWAP"})(Y||(Y={}));var h;(function(u){u["LIQUIDITY"]="liquidity";u["NETWORK"]="network";u["INBOUND"]="inbound";u["OUTBOUND"]="outbound";u["AFFILIATE"]="affiliate";u["TAX"]="tax"})(h||(h={}));var on=y.array(y.object({type:y.nativeEnum(h),amount:y.string(),asset:y.string(),chain:y.string(),protocol:y.nativeEnum(Y)})),Bn=y.object({sellAsset:y.string({description:"Asset to sell"}),buyAsset:y.string({description:"Asset to buy"}),provider:y.nativeEnum(Y),sourceAddress:y.string({description:"Source address"}),destinationAddress:y.string({description:"Destination address"}),estimatedTime:I.optional(),affiliate:y.string({description:"Affiliate address"}).optional(),affiliateFee:y.number({description:"Affiliate fee"}).optional(),slipPercentage:y.number({description:"Slippage as a percentage"})}),Ie=Bn.omit({sourceAddress:!0,destinationAddress:!0,slipPercentage:!0}),An=y.object({name:y.string({description:"Asset name"}),price:y.number({description:"Price in USD"}),image:y.string({description:"Asset image"})}),Hn=y.object({priceImpact:y.number({description:"Price impact"}),assets:y.optional(y.array(An))}),wn=y.array(y.object({code:y.nativeEnum(D),display:y.string(),tooltip:y.string().optional()})),Vn=y.object({sellAsset:y.string({description:"Asset to sell"}),buyAsset:y.string({description:"Asset to buy"}),provider:y.nativeEnum(Y),buyAmount:y.string({description:"Amount of asset to buy"}),buyAmountMaxSlippage:y.string({description:"Amount of asset to buy"}),sellAmount:y.string({description:"Amount of asset to sell"}),sourceAddress:y.string({description:"Source address"}),destinationAddress:y.string({description:"Destination address"}),slippageBps:y.number({description:"Slippage in bps"}),targetAddress:y.optional(y.string({description:"Target address for contract call or transfer address"})),inboundAddress:y.optional(y.string({description:"Inbound address"})),routerAddress:y.optional(y.string({description:"Inbound address"})),contractMethod:y.optional(y.string({description:"Contract method"})),fees:y.optional(on),estimatedTime:y.optional(I),memo:y.optional(y.string({description:"Memo"})),expiration:y.optional(y.string({description:"Expiration"}))}),Pe=y.object({providers:y.array(y.nativeEnum(Y)),sellAsset:y.string({description:"Asset to sell"}),sellAmount:y.string({description:"sell amount"}),buyAsset:y.string({description:"Asset to buy"}),expectedBuyAmount:y.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:y.string({description:"Expected Buy amount max slippage"}),sourceAddress:y.string({description:"Source address"}),destinationAddress:y.string({description:"Destination address"}),targetAddress:y.optional(y.string({description:"Target address"})),routerAddress:y.optional(y.string({description:"Router address"})),inboundAddress:y.optional(y.string({description:"Inbound address"})),expiration:y.optional(y.string({description:"Expiration"})),memo:y.optional(y.string({description:"Memo"})),evmTransactionDetails:y.optional(fn),routePathArray:y.optional(y.array(y.string())),estimatedTime:y.optional(I),totalSlippageBps:y.number({description:"Total slippage in bps"}),legs:y.array(Vn),errorCode:y.optional(y.string()),warnings:wn,meta:Hn}),gn=y.object({provider:y.nativeEnum(Y),sellAsset:y.string({description:"Asset to sell"}),sellAmount:y.string({description:"Sell amount"}),buyAsset:y.string({description:"Asset to buy"}),buyAmount:y.string({description:"Buy amount"}),buyAmountMaxSlippage:y.string({description:"Buy amount max slippage"}),fees:y.optional(on)}),Nn=y.object({providers:y.array(y.nativeEnum(Y)),sellAsset:y.string({description:"Asset to sell"}),sellAmount:y.string({description:"sell amount"}),buyAsset:y.string({description:"Asset to buy"}),expectedBuyAmount:y.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:y.string({description:"Expected Buy amount max slippage"}),sourceAddress:y.string({description:"Source address"}),destinationAddress:y.string({description:"Destination address"}),targetAddress:y.optional(y.string({description:"Target address"})),expiration:y.optional(y.string({description:"Expiration"})),memo:y.optional(y.string({description:"Memo"})),evmTransactionDetails:y.optional(fn),estimatedTime:y.optional(I),totalSlippageBps:y.number({description:"Total slippage in bps"}),legs:y.array(gn),warnings:wn,meta:Hn}),ve=y.object({quoteId:y.string({description:"Quote ID"}),routes:y.array(Nn),error:y.optional(y.string({description:"Error message"}))});function jn(n=""){const e=n.toUpperCase(),[t]=e.split(".");if(On.includes(t))return!0;const[p]=e.split("/");if(On.includes(p))return!0;throw new Error(`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`)}function rt(n){if(n.length>30)return!1;const e=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(e)}var On=[...Object.values(s),"TERRA"];function K({value:n,bigIntDecimal:e=N,decimal:t=N}){if(t===0)return n.toString();const p=n<0n;let a=n.toString().substring(p?1:0);const r=t-(a.length-1);if(r>0)a="0".repeat(r)+a;const u=a.length-t;let x=a.slice(-t);if(Number.parseInt(x[e]||"0")>=5)x=`${x.substring(0,e-1)}${(Number.parseInt(x[e-1]||"0")+1).toString()}`;else x=x.substring(0,e);return`${p?"-":""}${a.slice(0,u)}.${x}`.replace(/\.?0*$/,"")}var P=function(n){const t=`${typeof n==="number"?Fn.format(n):nn(n)}`.replaceAll(",",".").split(".");return t.length>1?`${t.slice(0,-1).join("")}.${t.at(-1)}`:t[0]||"0"},_n=function(n){const e=n.split(".")[1]?.length||0;return Math.max(e,N)},nn=function(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n},N=8,q=(n)=>10n**BigInt(n),g=(n)=>Math.log10(Number.parseFloat(n.toString()));class L{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,e){return new L({decimal:e,value:K({value:n,bigIntDecimal:e,decimal:e})})}static shiftDecimals({value:n,from:e,to:t}){return L.fromBigInt(n.getBaseValue("bigint")*q(t)/q(e),t)}constructor(n){const e=nn(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:q(Math.max(_n(P(e)),this.decimal||0)),this.#s(e)}set(n){return new this.constructor({decimal:this.decimal,value:n,identifier:this.toString()})}add(...n){return this.#e("add",...n)}sub(...n){return this.#e("sub",...n)}mul(...n){return this.#e("mul",...n)}div(...n){return this.#e("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){const e=this.formatBigIntToSafeValue(this.bigIntValue,this.decimal||g(this.decimalMultiplier));switch(n){case"number":return Number(e);case"string":return e;case"bigint":return this.bigIntValue*10n**BigInt(this.decimal||8n)/this.decimalMultiplier}}getBaseValue(n){const e=this.decimalMultiplier/q(this.decimal||O.THOR),t=this.bigIntValue/e;switch(n){case"number":return Number(t);case"string":return t.toString();case"bigint":return t}}getBigIntValue(n,e){if(!e&&typeof n==="object")return n.bigIntValue;const t=nn(n),p=P(t);if(p==="0"||p==="undefined")return 0n;return this.#p(p,e)}toSignificant(n=6){const[e,t]=this.getValue("string").split("."),p=e||"",a=t||"";if((Number.parseInt(p)?p.length+a.length:a.length)<=n)return this.getValue("string");if(p.length>=n)return p.slice(0,n).padEnd(p.length,"0");if(Number.parseInt(p))return`${p}.${a.slice(0,n-p.length)}`.padEnd(n-p.length,"0");const u=Number.parseInt(a),x=`${u}`.slice(0,n);return`0.${x.padStart(a.length-`${u}`.length+x.length,"0")}`}toFixed(n=6){const[e,t]=this.getValue("string").split("."),p=e||"",a=t||"";if(Number.parseInt(p))return`${p}.${a.slice(0,n)}`.padEnd(n,"0");const r=Number.parseInt(a),u=`${r}`.slice(0,n);return`0.${u.padStart(a.length-`${r}`.length+u.length,"0")}`}toAbbreviation(n=2){const e=this.getValue("number"),t=["","K","M","B","T","Q","Qi","S"],p=Math.floor(Math.log10(Math.abs(e))/3),a=t[p];if(!a)return this.getValue("string");const r=10**(p*3);return`${(e/r).toFixed(n)}${a}`}toCurrency(n="$",{currencyPosition:e="start",decimal:t=2,decimalSeparator:p=".",thousandSeparator:a=","}={}){const r=this.getValue("number"),[u="",x=""]=r.toFixed(6).split("."),o=u.replace(/\B(?=(\d{3})+(?!\d))/g,a),_=u||x?u==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",p):`${o}${Number.parseInt(x)?`${p}${x.slice(0,t)}`:""}`:"0.00";return`${e==="start"?n:""}${_}${e==="end"?n:""}`}formatBigIntToSafeValue(n,e){const t=e||this.decimal||N,p=Math.max(t,g(this.decimalMultiplier)),a=n<0n,r=n.toString().substring(a?1:0),u=p-(r.length-1),x=u>0?"0".repeat(u)+r:r,o=x.length-p;let _=x.slice(-p);if(Number.parseInt(_[t]||"0")>=5)_=`${_.substring(0,t-1)}${(Number.parseInt(_[t-1]||"0")+1).toString()}`;else _=_.substring(0,t);return`${a?"-":""}${x.slice(0,o)}.${_}`.replace(/\.?0*$/,"")}#e(n,...e){const t=this.#t(this,...e),p=Math.max(t,g(this.decimalMultiplier)),a=q(p),r=e.reduce((x,o)=>{const _=this.getBigIntValue(o,p);switch(n){case"add":return x+_;case"sub":return x-_;case"mul":return x*_/a;case"div":{if(_===0n)throw new RangeError("Division by zero");return x*a/_}default:return x}},this.bigIntValue*a/this.decimalMultiplier),u=K({bigIntDecimal:p,decimal:p,value:r});return new this.constructor({decimalMultiplier:q(p),decimal:this.decimal,value:u,identifier:this.toString()})}#n(n,...e){const t=this.#t(this,...e),p=this.getBigIntValue(e[0]||"0",t),a=this.getBigIntValue(this,t);switch(n){case"gt":return a>p;case"gte":return a>=p;case"lt":return a<p;case"lte":return a<=p;case"eqValue":return a===p}}#s(n){const e=P(n)||"0";this.bigIntValue=this.#p(e)}#t(...n){const e=n.map((t)=>{return typeof t==="object"?t.decimal||g(t.decimalMultiplier):_n(P(t))}).filter(Boolean);return Math.max(...e,N)}#p(n,e){const t=e?q(e):this.decimalMultiplier,p=g(t),[a="",r=""]=n.split(".");return BigInt(`${a}${r.padEnd(p,"0")}`)}}var Fn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});class R extends L{eq(n){return this.eqValue(n)}static fromBigInt(n,e){return new R({decimal:e,value:K({value:n,bigIntDecimal:e,decimal:e})})}}function _t(n){const e=z.fromChainOrSignature(n);switch(n){case s.Bitcoin:case s.Litecoin:case s.BitcoinCash:return e.set(0.00010001);case s.Dogecoin:return e.set(1.00000001);case s.Avalanche:case s.Ethereum:return e.set(0.00000001);case s.THORChain:case s.Maya:return e.set(0);case s.Cosmos:return e.set(0.000001);default:return e.set(0.00000001)}}async function en(n,e=0){jn(n);const t=B.get(n.toUpperCase()),p=t?.decimal||await $n(F(n));if(!t)B.set(n.toUpperCase(),{identifier:n,decimal:p});return new z({decimal:p,value:A(e,p),identifier:n})}var tn=function(n,e=0){const[t,p]=n.split(".")?.[0]?.toUpperCase()===s.THORChain?n.split(".").slice(1).join().split("/"):n.split("/");if(!(t&&p))throw new Error("Invalid asset identifier");return new z({decimal:8,value:A(e,8),identifier:`${s.THORChain}.${t}/${p}`})},A=function(n,e){return typeof n==="bigint"?K({value:n,bigIntDecimal:e,decimal:e}):n},F=function(n){const e=n.slice(0,14).includes("/"),t=n.split(".")?.[0]?.toUpperCase()===s.THORChain,p=n.split(".")?.[0]?.toUpperCase()===s.Maya,[a,r=""]=t||p?n.split(".").slice(1).join().split("/"):n.split("/");if(e&&!(a&&r))throw new Error("Invalid asset identifier");const u=n.includes(".")&&!e?n:`${p?s.Maya:s.THORChain}.${r}`,[x,...o]=u.split("."),_=e?r:o.join("."),Z=_.split("-"),j=Z.length===1?Z[0]:Z.slice(0,-1).join("-"),b=Z.length===1?void 0:Z[Z.length-1];return{address:b?.toLowerCase(),chain:x,isGasAsset:pn({chain:x,symbol:_}),isSynthetic:e,symbol:(e?`${a}/`:"")+(b?`${j}-${b?.toLowerCase()??""}`:_),ticker:j}},B=new Map;class z extends L{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:e,tax:t,chain:p,symbol:a,identifier:r}){super(typeof n==="object"?n:{decimal:e,value:n});const u=F(r||`${p}.${a}`);this.type=Xn(u),this.tax=t,this.chain=u.chain,this.ticker=u.ticker,this.symbol=u.symbol,this.address=u.address,this.isSynthetic=u.isSynthetic,this.isGasAsset=u.isGasAsset,this.chainId=dn[u.chain]}toString(){return this.isSynthetic?this.symbol:`${this.chain}.${this.symbol}`}toUrl(){return this.isSynthetic?`${this.chain}.${this.symbol.replace("/",".")}`:this.toString()}eqAsset({chain:n,symbol:e}){return this.chain===n&&this.symbol===e}eq(n){return this.eqAsset(n)&&this.eqValue(n)}static fromUrl(n,e=0){const[t,p,a]=n.split(".");if(!(t&&p))throw new Error("Invalid asset url");const r=t===s.THORChain&&a?`${t}.${p}/${a}`:n;return en(r,e)}static fromString(n,e=0){return en(n,e)}static fromIdentifier(n,e=0){return en(n,e)}static fromStringSync(n,e=0){const{chain:t,isSynthetic:p}=F(n),a=B.get(n.toUpperCase());if(p)return tn(n,e);const{tax:r,decimal:u,identifier:x}=a||{decimal:O[t],identifier:n};return new z({tax:r,value:A(e,u),identifier:p?n:x,decimal:p?8:u})}static async fromStringWithBase(n,e=0,t=O.THOR){const p=L.shiftDecimals({value:R.fromBigInt(BigInt(e)),from:0,to:t}).getBaseValue("string");return(await z.fromString(n,e)).set(p)}static fromStringWithBaseSync(n,e=0,t=O.THOR){const{chain:p,isSynthetic:a}=F(n),r=B.get(n.toUpperCase());if(a)return tn(n,e);const{tax:u,decimal:x,identifier:o}=r||{decimal:O[p],identifier:n};return new z({tax:u,value:A(BigInt(e),t),identifier:o,decimal:x})}static fromIdentifierSync(n,e=0){const{chain:t,isSynthetic:p}=F(n),a=B.get(n);if(p)return tn(n,e);const{tax:r,decimal:u,identifier:x}=a||{decimal:O[t],identifier:n};return new z({tax:r,decimal:u,identifier:x,value:A(e,u)})}static fromChainOrSignature(n,e=0){const{decimal:t,identifier:p}=Gn(n);return new z({value:A(e,t),decimal:t,identifier:p})}static loadStaticAssets(){return new Promise((n,e)=>{try{import("@swapkit/tokens").then((t)=>{for(let p of Object.values(t))for(let{identifier:a,chain:r,...u}of p.tokens)B.set(a.toUpperCase(),{identifier:a,decimal:"decimals"in u?u.decimals:O[r]});n({ok:!0})})}catch(t){console.error(t),e({ok:!1,error:t,message:"Couldn't load static assets. Ensure you have installed @swapkit/tokens package"})}})}}import Mn from"ky";function Xt({apiKey:n,...e}){Zn={...e,apiKey:n}}var zn=function(){const{apiKey:n,...e}=Zn;return Mn.create({...e,headers:{...Qn,...e.headers,"x-api-key":n}})},Zn={},Qn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},Jn=(n)=>({get:async(e,t)=>(await n.get(e,t)).json(),post:async(e,t)=>(await n.post(e,t)).json()}),v={...Jn(zn()),extend:(n)=>{const e=zn().extend(n);return{...Jn(e),extend:v.extend}}};async function qt(n){const e=await import("@swapkit/tokens");for(let t of Object.values(e))for(let{identifier:p,chain:a,...r}of t.tokens){if("identifier"in n&&p===n.identifier)return p;if("address"in r&&"chain"in n&&a===n.chain&&r.address.toLowerCase()===n.contract.toLowerCase())return p}return}var ln="0x313ce567",kn=async({chain:n,to:e})=>{try{const{result:t}=await v.post(c[n],{headers:{accept:"*/*","content-type":"application/json","cache-control":"no-cache"},body:JSON.stringify({id:44,jsonrpc:"2.0",method:"eth_call",params:[{to:e.toLowerCase(),data:ln},"latest"]})});return Number.parseInt(BigInt(t||O[n]).toString())}catch(t){return console.error(t),O[n]}},Wn=async({symbol:n})=>{try{const e=n.split("-")[1]?.toLowerCase(),{manager:t}=await v.post(`${c[s.Radix]}/state/resource`,{headers:{Accept:"*/*","Content-Type":"application/json"},body:JSON.stringify({network:"mainnet",resource_address:e})});return t.divisibility.value.divisibility}catch(e){return console.error(e),O[s.Radix]}},En=(n)=>{if(n===s.Ethereum)return O.ETH;const e=n.split("-"),t=e.length===1?void 0:e[e.length-1]?.toLowerCase();return t?.startsWith("0x")?kn({chain:s.Ethereum,to:t}):O.ETH},In=(n)=>{const e=n.split("-"),t=e.length===1?void 0:e[e.length-1];return t?.startsWith("0x")?kn({chain:s.Avalanche,to:t.toLowerCase()}):O.AVAX},Pn=(n)=>{if(n===s.BinanceSmartChain)return O.BSC;return O.BSC},vn=(n)=>{if(n===s.Radix)return O.XRD;return Wn({symbol:n})},$n=({chain:n,symbol:e})=>{switch(n){case s.Ethereum:return En(e);case s.Avalanche:return In(e);case s.BinanceSmartChain:return Pn(e);case s.Radix:return vn(e);default:return O[n]}},Rt=({chain:n})=>{switch(n){case s.Arbitrum:case s.Optimism:return z.fromStringSync(`${n}.ETH`);case s.Maya:return z.fromStringSync(`${n}.CACAO`);case s.Cosmos:return z.fromStringSync(`${n}.ATOM`);case s.BinanceSmartChain:return z.fromStringSync(`${n}.BNB`);case s.THORChain:return z.fromStringSync(`${n}.RUNE`);default:return z.fromStringSync(`${n}.${n}`)}},pn=({chain:n,symbol:e})=>{switch(n){case s.Arbitrum:case s.Optimism:return e==="ETH";case s.Maya:return e==="CACAO";case s.Cosmos:return e==="ATOM";case s.BinanceSmartChain:return e==="BNB";case s.THORChain:return e==="RUNE";default:return e===n}},Gn=(n)=>{switch(n){case`${s.Ethereum}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${s.Ethereum}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case s.Arbitrum:return{identifier:`${s.Arbitrum}.ETH`,decimal:O[n]};case s.Optimism:return{identifier:`${s.Optimism}.ETH`,decimal:O[n]};case s.Cosmos:return{identifier:"GAIA.ATOM",decimal:O[n]};case s.THORChain:return{identifier:"THOR.RUNE",decimal:O[n]};case s.BinanceSmartChain:return{identifier:"BSC.BNB",decimal:O[n]};case s.Maya:return{identifier:"MAYA.CACAO",decimal:O.MAYA};case`${s.Maya}.MAYA`:return{identifier:"MAYA.MAYA",decimal:4};case`${s.Kujira}.USK`:return{identifier:`${s.Kujira}.USK`,decimal:6};case s.Radix:return{identifier:`${s.Radix}.XRD`,decimal:O.XRD};default:return{identifier:`${n}.${n}`,decimal:O[n]}}},Xn=({chain:n,symbol:e})=>{if(e.includes("/"))return"Synth";switch(n){case s.Cosmos:return e==="ATOM"?"Native":s.Cosmos;case s.Kujira:return e===s.Kujira?"Native":s.Kujira;case s.Binance:return e===s.Binance?"Native":"BEP2";case s.BinanceSmartChain:return e===s.Binance?"Native":"BEP20";case s.Ethereum:return e===s.Ethereum?"Native":"ERC20";case s.Avalanche:return e===s.Avalanche?"Native":s.Avalanche;case s.Polygon:return e===s.Polygon?"Native":"POLYGON";case s.Arbitrum:return[s.Ethereum,s.Arbitrum].includes(e)?"Native":"ARBITRUM";case s.Optimism:return[s.Ethereum,s.Optimism].includes(e)?"Native":"OPTIMISM";case s.Radix:return e===s.Radix?"Native":"RADIX";default:return"Native"}},Yt=(n)=>{const[e,...t]=n.split("."),p=n.includes("/"),a=t.join("."),r=a?.split("-"),u=r?.length?r.length===1?r[0]:r.slice(0,-1).join("-"):void 0;return{chain:e,symbol:a,ticker:u,synth:p}},Cn=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),Un=(n)=>{const[e,t]=n.split(".");if(!l.includes(e))return!0;const p=t.split("-"),a=p.length===1?void 0:p[p.length-1];return pn({chain:e,symbol:t})||!!a},Lt=(n)=>n.filter(({chain:e,value:t,symbol:p})=>{const a=`${e}.${p}`;return!Cn.test(a)&&Un(a)&&t!=="0"});function Bt({chain:n,index:e,addressIndex:t=0,type:p}){if(l.includes(n)){if(p==="legacy")return[44,60,0,e];if(p==="ledgerLive")return[44,60,e,0,t];return sn(E[n],e)}if([s.Bitcoin,s.Litecoin].includes(n)){const a=n===s.Bitcoin?0:2;if(p==="nativeSegwitMiddleAccount")return[84,a,e,0,t];if(p==="segwit")return[49,a,0,0,e];if(p==="legacy")return[44,a,0,0,e];return sn(E[n],e)}return sn(E[n],e)}function At(n){const[e,t,p]=n.split("/").map((a)=>Number.parseInt(a,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var sn=(n,e)=>[...n.slice(0,n.length-1),e];function Sn({liquidityUnits:n,poolUnits:e,runeDepth:t}){const p=k(n),a=k(e),r=k(t),u=p.mul(r),x=a.mul(a).mul(2),o=a.mul(p).mul(2),_=p.mul(p),Z=a.mul(a).mul(a);return u.mul(x.sub(o).add(_)).div(Z)}function cn({liquidityUnits:n,poolUnits:e,assetDepth:t}){const p=k(n),a=k(e),r=k(t),u=p.mul(r),x=a.mul(a).mul(2),o=a.mul(p).mul(2),_=p.mul(p),Z=u.mul(x.sub(o).add(_)),j=a.mul(a).mul(a);return Z.div(j)}function Ft({percent:n,runeDepth:e,liquidityUnits:t,poolUnits:p}){return Sn({runeDepth:e,liquidityUnits:t,poolUnits:p}).mul(n)}function Mt({percent:n,assetDepth:e,liquidityUnits:t,poolUnits:p}){return cn({assetDepth:e,liquidityUnits:t,poolUnits:p}).mul(n)}var k=function(n){return R.fromBigInt(BigInt(n),O.THOR)};function Dn({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p}){return{assetAmount:k(p).mul(n).div(e),runeAmount:k(t).mul(n).div(e)}}function Qt({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p,percent:a}){return Object.fromEntries(Object.entries(Dn({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p})).map(([r,u])=>[r,u.mul(a)]))}function lt({runeDepth:n,poolUnits:e,assetDepth:t,liquidityUnits:p,runeAmount:a,assetAmount:r}){const u=new R({value:n,decimal:8}),x=new R({value:t,decimal:8}),o=new R({value:e,decimal:8}),_=new R({value:a,decimal:8}),Z=new R({value:r,decimal:8}),j=_.mul(x),b=Z.mul(u),Yn=_.mul(Z),Ln=u.mul(x),qn=o.mul(j.add(b.add(Yn.mul(2)))),H=j.add(b.add(Ln.mul(2))),yn=qn.div(H),S=k(p).add(yn);if(yn.getBaseValue("number")===0)return S.div(o).getBaseValue("number");const i=o.add(S);return S.div(i).getBaseValue("number")}function Wt({runeAmount:n,assetAmount:e,runeDepth:t,assetDepth:p}){if(n==="0"||e==="0"||t==="0"||p==="0")return 0;const a=k(t),r=k(p),u=k(e),x=k(n),o=u.mul(a).sub(r.mul(x)),_=r.mul(x).add(a.mul(r));return Math.abs(o.div(_).getBaseValue("number"))}var C=function(n,{affiliateAddress:e,affiliateBasisPoints:t}){const p=e?`:${e}:${t||0}`:"";return`${n}${p}`},hn=function({chain:n,symbol:e}){switch(n){case s.Bitcoin:case s.Dogecoin:case s.Litecoin:return n.slice(0,1).toLowerCase();case s.BitcoinCash:return"c";default:return`${n}.${e}`}};function ne({type:n,address:e}){return`${n}:${e}`}function ee({address:n,unbondAmount:e}){return`${X.UNBOND}:${n}:${e}`}function te({name:n,chain:e,address:t,owner:p}){const a=`${X.NAME_REGISTER}:${n}:${e}:${t}`,r=p?`:${p}`:"";return`${a}${r}`}function pe(n,{asset:e,address:t,minAmount:p,...a}){const r=`${n}:${e}:${t}`,u=p?`:${p}`:"";return C(`${r}${u}`,a)}function se({chain:n,symbol:e,...t}){return C(`${X.DEPOSIT}:${n}/${e}`,t)}function ye({chain:n,symbol:e,address:t}){const p=hn({chain:n,symbol:e}),a=t?`:${t}`:"";return`${X.DEPOSIT}:${p}${a}`}function ae({chain:n,symbol:e,basisPoints:t,...p}){return C(`${X.WITHDRAW}:${n}/${e}:${t}`,p)}function de({chain:n,symbol:e,ticker:t,basisPoints:p,targetAsset:a,...r}){const u=n==="ETH"&&t!=="ETH"?`${t}-${e.slice(-3)}`:e,x=a?`:${a}`:"";return C(`${X.WITHDRAW}:${n}.${u}:${p}${x}`,r)}var vt=(n,e)=>{switch(n){case X.LEAVE:case X.BOND:{const{address:t}=e;return ne({type:n,address:t})}case X.UNBOND:{const{address:t,unbondAmount:p}=e;return ee({address:t,unbondAmount:p})}case X.NAME_REGISTER:return te(e);case X.OPEN_LOAN:case X.CLOSE_LOAN:return pe(n,e);case X.DEPOSIT:{const{chain:t,symbol:p,address:a,singleSide:r}=e;if(r)return se({chain:t,symbol:p});return ye({chain:t,symbol:p,address:a})}case X.WITHDRAW:{const{chain:t,ticker:p,symbol:a,basisPoints:r,targetAssetString:u,singleSide:x}=e;if(x)return ae({chain:t,symbol:a,basisPoints:r});return de({chain:t,ticker:p,symbol:a,basisPoints:r,targetAsset:u})}default:throw new Error(`Unsupported memo type: ${n}`)}};var ue={core_wallet_connection_not_found:10001,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_chain_halted:10099,core_wallet_xdefi_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_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,wallet_connection_rejected_by_user:20000,wallet_ledger_connection_error:20001,wallet_ledger_connection_claimed:20002,wallet_ledger_get_address_error:20003,wallet_ledger_device_not_found:20004,wallet_ledger_device_locked:20005,wallet_phantom_not_found:20101,wallet_xdefi_not_found:20201,wallet_xdefi_failed_to_add_or_switch_network:20202,chainflip_channel_error:30001,chainflip_broker_recipient_error:30002,thorchain_chain_halted:40001,thorchain_trading_halted:40002,api_v2_invalid_response:50001,helpers_number_different_decimals:99001};class U extends Error{constructor(n,e){if(e)console.error(e,{stack:e?.stack,message:e?.message});super(n,{cause:{code:ue[n],message:n}});Object.setPrototypeOf(this,U.prototype)}}function Dt(n){if(n<0)throw new Error("Invalid number of years");return 10+n}function ht(n){if(n<0)throw new Error("Invalid number of year");return Math.round((10+n*1.0512)*10000000000)/10000000000}function np([n,e,t,p,a]){return`m/${n}'/${e}'/${t}'/${p}${typeof a!=="number"?"":`/${a}`}`}function ep(n,e){try{return n()}catch(t){if(e)throw new U(e,t);return console.error(t)}}var tp=(n)=>{switch(n){case s.THORChain:return`${n}.RUNE`;case s.Cosmos:return`${n}.ATOM`;case s.BinanceSmartChain:return`${n}`;default:return`${n}.${n}`}};function Tp(){const n=[];function e(p){if(n.map((a)=>a.info.uuid).includes(p.detail.info.uuid))return;n.push(p.detail)}window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider"));function t(){window.removeEventListener("eip6963:announceProvider",e)}return{providers:n,removeEIP6963EventListener:t}}var re=["approve","approvedAmount","call","sendTransaction","transfer","isApproved","approvedAmount","EIP1193SendTransaction","getFeeData","broadcastTransaction","estimateCall","estimateGasLimit","estimateGasPrices","createContractTxObject"],Te=(n,e,t)=>async(...p)=>{try{await xe(e,t)}catch(a){throw new Error(`Failed to switch network: ${a}`)}return n(...p)},Rn=({provider:n,params:e,method:t})=>{if(!n?.send)throw new Error("Provider not found");const p=e?Array.isArray(e)?e:[e]:[];return n.send(t,p)},yp=({toolbox:n,chainId:e,provider:t=window.ethereum})=>{const p=re.reduce((a,r)=>{if(!n[r])return a;const u=n[r];if(typeof u!=="function")return a;return{...a,[r]:Te(u,t,e)}},{});return{...n,...p}},ap=(n,e)=>Rn({provider:n,method:"wallet_addEthereumChain",params:[e]}),xe=(n,e=w.EthereumHex)=>Rn({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:e}]}),dp=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},up=()=>{const{isTrust:n,isBraveWallet:e,__XDEFI:t,overrideIsMetaMask:p,selectedProvider:a}=window?.ethereum||{};if(n)return J.TRUSTWALLET_WEB;if(e)return J.BRAVE;if(p&&a?.isCoinbaseWallet)return J.COINBASE_WEB;if(t)J.XDEFI;return J.METAMASK},rp=(n)=>{return me().includes(n)},me=()=>{const n=window?.ethereum&&!window.ethereum?.isBraveWallet,e=window?.xfi||window?.ethereum?.__XDEFI,t=window?.ethereum?.isBraveWallet,p=window?.ethereum?.isTrust||window?.trustwallet,a=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,r=[];if(n)r.push(J.METAMASK);if(e)r.push(J.XDEFI);if(t)r.push(J.BRAVE);if(p)r.push(J.TRUSTWALLET_WEB);if(a)r.push(J.COINBASE_WEB);if(fe())r.push(J.OKX_MOBILE);return r},fe=()=>{const n=navigator.userAgent,e=/iphone|ipad|ipod|ios/i.test(n),t=/android|XiaoMi|MiuiBrowser/i.test(n),p=e||t,a=/OKApp/i.test(n);return p&&a},xp=()=>typeof window.ethereum!=="undefined";export{ep as wrapWithThrow,Te as wrapMethodWithNetworkSwitch,rt as validateTNS,jn as validateIdentifier,xe as switchEVMWalletNetwork,Xt as setRequestClientConfig,yp as prepareNetworkSwitch,fe as okxMobileEnabled,me as listWeb3EVMWallets,xp as isWeb3Detected,pn as isGasAsset,rp as isDetected,At as getWalletFormatFor,Dt as getTHORNameCost,Qt as getSymmetricWithdraw,Dn as getSymmetricPoolShare,_t as getMinAmountByChain,de as getMemoForWithdraw,ee as getMemoForUnbond,ae as getMemoForSaverWithdraw,se as getMemoForSaverDeposit,te as getMemoForNameRegister,pe as getMemoForLoan,ne as getMemoForLeaveAndBond,ye as getMemoForDeposit,vt as getMemoFor,ht as getMAYANameCost,Wt as getLiquiditySlippage,Rt as getGasAsset,lt as getEstimatedPoolShare,up as getETHDefaultWallet,Tp as getEIP6963Wallets,Bt as getDerivationPathFor,$n as getDecimal,Gn as getCommonAssetInfo,tp as getChainIdentifier,Ft as getAsymmetricRuneWithdrawAmount,Sn as getAsymmetricRuneShare,Mt as getAsymmetricAssetWithdrawAmount,cn as getAsymmetricAssetShare,Xn as getAssetType,K as formatBigIntToSafeValue,qt as findAssetBy,Lt as filterAssets,oe as erc20ABI,np as derivationPathToString,Qn as defaultRequestHeaders,Yt as assetFromString,ap as addEVMWalletNetwork,dp as addAccountsChangedCallback,D as WarningCodeEnum,J as WalletOption,Re as UTXOChains,Le as TCSupportedChains,_e as TCEthereumVaultAbi,Ge as TCBscDepositABI,$e as TCAvalancheDepositABI,R as SwapKitNumber,U as SwapKitError,ke as SubstrateChains,ge as SWAP_OUT,Ve as SWAP_IN,wn as RouteQuoteWarningSchema,Pe as RouteQuoteSchema,Hn as RouteQuoteMetadataSchema,An as RouteQuoteMetadataAssetSchema,Vn as RouteQuoteLegSchema,Ie as RouteLegWithoutAddressesSchema,Bn as RouteLegSchema,v as RequestClient,M as RPCUrl,ve as QuoteResponseSchema,le as QuoteRequestSchema,G as QuoteMode,Y as ProviderName,E as NetworkDerivationPath,X as MemoType,we as MayaEthereumVaultAbi,Oe as MayaArbitrumVaultAbi,qe as MAYASupportedChains,Tn as LedgerErrorCode,on as FeesSchema,h as FeeTypeEnum,xn as FeeOption,Q as ExplorerUrl,I as EstimatedTimeSchema,fn as EVMTransactionDetailsSchema,Kn as EVMTransactionDetailsParamsSchema,l as EVMChains,rn as DerivationPath,Ye as CosmosChains,un as ContractAddress,c as ChainToRPC,be as ChainToHexChainId,Ke as ChainToExplorerUrl,dn as ChainToChainId,Ze as ChainIdToChain,w as ChainId,s as Chain,L as BigIntArithmetics,O as BaseDecimal,z as AssetValue,mn as ApproveMode,Ae as AGG_SWAP};
8
2
 
9
- // src/types/abis/erc20.ts
10
- var erc20ABI = [
11
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
12
- {
13
- anonymous: false,
14
- inputs: [
15
- { indexed: true, internalType: "address", name: "owner", type: "address" },
16
- { indexed: true, internalType: "address", name: "spender", type: "address" },
17
- { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
18
- ],
19
- name: "Approval",
20
- type: "event"
21
- },
22
- {
23
- anonymous: false,
24
- inputs: [
25
- { indexed: true, internalType: "address", name: "from", type: "address" },
26
- { indexed: true, internalType: "address", name: "to", type: "address" },
27
- { indexed: false, internalType: "uint256", name: "value", type: "uint256" }
28
- ],
29
- name: "Transfer",
30
- type: "event"
31
- },
32
- {
33
- inputs: [
34
- { internalType: "address", name: "", type: "address" },
35
- { internalType: "address", name: "", type: "address" }
36
- ],
37
- name: "allowance",
38
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
39
- stateMutability: "view",
40
- type: "function"
41
- },
42
- {
43
- inputs: [
44
- { internalType: "address", name: "spender", type: "address" },
45
- { internalType: "uint256", name: "value", type: "uint256" }
46
- ],
47
- name: "approve",
48
- outputs: [{ internalType: "bool", name: "success", type: "bool" }],
49
- stateMutability: "nonpayable",
50
- type: "function"
51
- },
52
- {
53
- inputs: [{ internalType: "address", name: "", type: "address" }],
54
- name: "balanceOf",
55
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
56
- stateMutability: "view",
57
- type: "function"
58
- },
59
- {
60
- inputs: [],
61
- name: "decimals",
62
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
63
- stateMutability: "view",
64
- type: "function"
65
- },
66
- {
67
- inputs: [],
68
- name: "name",
69
- outputs: [{ internalType: "string", name: "", type: "string" }],
70
- stateMutability: "view",
71
- type: "function"
72
- },
73
- {
74
- inputs: [],
75
- name: "symbol",
76
- outputs: [{ internalType: "string", name: "", type: "string" }],
77
- stateMutability: "view",
78
- type: "function"
79
- },
80
- {
81
- inputs: [],
82
- name: "totalSupply",
83
- outputs: [{ internalType: "uint256", name: "", type: "uint256" }],
84
- stateMutability: "view",
85
- type: "function"
86
- },
87
- {
88
- inputs: [
89
- { internalType: "address", name: "to", type: "address" },
90
- { internalType: "uint256", name: "value", type: "uint256" }
91
- ],
92
- name: "transfer",
93
- outputs: [{ internalType: "bool", name: "success", type: "bool" }],
94
- stateMutability: "nonpayable",
95
- type: "function"
96
- },
97
- {
98
- inputs: [
99
- { internalType: "address", name: "from", type: "address" },
100
- { internalType: "address", name: "to", type: "address" },
101
- { internalType: "uint256", name: "value", type: "uint256" }
102
- ],
103
- name: "transferFrom",
104
- outputs: [{ internalType: "bool", name: "success", type: "bool" }],
105
- stateMutability: "nonpayable",
106
- type: "function"
107
- }
108
- ];
109
- // src/types/abis/mayaEvmVaults.ts
110
- var MayaEthereumVaultAbi = [
111
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
112
- {
113
- anonymous: false,
114
- inputs: [
115
- { indexed: true, internalType: "address", name: "to", type: "address" },
116
- { indexed: true, internalType: "address", name: "asset", type: "address" },
117
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
118
- { indexed: false, internalType: "string", name: "memo", type: "string" }
119
- ],
120
- name: "Deposit",
121
- type: "event"
122
- },
123
- {
124
- anonymous: false,
125
- inputs: [
126
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
127
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
128
- { indexed: false, internalType: "address", name: "asset", type: "address" },
129
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
130
- { indexed: false, internalType: "string", name: "memo", type: "string" }
131
- ],
132
- name: "TransferAllowance",
133
- type: "event"
134
- },
135
- {
136
- anonymous: false,
137
- inputs: [
138
- { indexed: true, internalType: "address", name: "vault", type: "address" },
139
- { indexed: true, internalType: "address", name: "to", type: "address" },
140
- { indexed: false, internalType: "address", name: "asset", type: "address" },
141
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
142
- { indexed: false, internalType: "string", name: "memo", type: "string" }
143
- ],
144
- name: "TransferOut",
145
- type: "event"
146
- },
147
- {
148
- anonymous: false,
149
- inputs: [
150
- { indexed: true, internalType: "address", name: "vault", type: "address" },
151
- { indexed: false, internalType: "address", name: "target", type: "address" },
152
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
153
- { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
154
- { indexed: false, internalType: "address", name: "to", type: "address" },
155
- { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
156
- { indexed: false, internalType: "string", name: "memo", type: "string" }
157
- ],
158
- name: "TransferOutAndCall",
159
- type: "event"
160
- },
161
- {
162
- anonymous: false,
163
- inputs: [
164
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
165
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
166
- {
167
- components: [
168
- { internalType: "address", name: "asset", type: "address" },
169
- { internalType: "uint256", name: "amount", type: "uint256" }
170
- ],
171
- indexed: false,
172
- internalType: "struct MAYAChain_Router.Coin[]",
173
- name: "coins",
174
- type: "tuple[]"
175
- },
176
- { indexed: false, internalType: "string", name: "memo", type: "string" }
177
- ],
178
- name: "VaultTransfer",
179
- type: "event"
180
- },
181
- {
182
- inputs: [
183
- { internalType: "address payable", name: "vault", type: "address" },
184
- { internalType: "address", name: "asset", type: "address" },
185
- { internalType: "uint256", name: "amount", type: "uint256" },
186
- { internalType: "string", name: "memo", type: "string" }
187
- ],
188
- name: "deposit",
189
- outputs: [],
190
- stateMutability: "payable",
191
- type: "function"
192
- },
193
- {
194
- inputs: [
195
- { internalType: "address payable", name: "vault", type: "address" },
196
- { internalType: "address", name: "asset", type: "address" },
197
- { internalType: "uint256", name: "amount", type: "uint256" },
198
- { internalType: "string", name: "memo", type: "string" },
199
- { internalType: "uint256", name: "expiration", type: "uint256" }
200
- ],
201
- name: "depositWithExpiry",
202
- outputs: [],
203
- stateMutability: "payable",
204
- type: "function"
205
- },
206
- {
207
- inputs: [
208
- { internalType: "address", name: "router", type: "address" },
209
- { internalType: "address payable", name: "asgard", type: "address" },
210
- {
211
- components: [
212
- { internalType: "address", name: "asset", type: "address" },
213
- { internalType: "uint256", name: "amount", type: "uint256" }
214
- ],
215
- internalType: "struct MAYAChain_Router.Coin[]",
216
- name: "coins",
217
- type: "tuple[]"
218
- },
219
- { internalType: "string", name: "memo", type: "string" }
220
- ],
221
- name: "returnVaultAssets",
222
- outputs: [],
223
- stateMutability: "payable",
224
- type: "function"
225
- },
226
- {
227
- inputs: [
228
- { internalType: "address", name: "router", type: "address" },
229
- { internalType: "address", name: "newVault", type: "address" },
230
- { internalType: "address", name: "asset", type: "address" },
231
- { internalType: "uint256", name: "amount", type: "uint256" },
232
- { internalType: "string", name: "memo", type: "string" }
233
- ],
234
- name: "transferAllowance",
235
- outputs: [],
236
- stateMutability: "nonpayable",
237
- type: "function"
238
- },
239
- {
240
- inputs: [
241
- { internalType: "address payable", name: "to", type: "address" },
242
- { internalType: "address", name: "asset", type: "address" },
243
- { internalType: "uint256", name: "amount", type: "uint256" },
244
- { internalType: "string", name: "memo", type: "string" }
245
- ],
246
- name: "transferOut",
247
- outputs: [],
248
- stateMutability: "payable",
249
- type: "function"
250
- },
251
- {
252
- inputs: [
253
- { internalType: "address payable", name: "target", type: "address" },
254
- { internalType: "address", name: "finalToken", type: "address" },
255
- { internalType: "address", name: "to", type: "address" },
256
- { internalType: "uint256", name: "amountOutMin", type: "uint256" },
257
- { internalType: "string", name: "memo", type: "string" }
258
- ],
259
- name: "transferOutAndCall",
260
- outputs: [],
261
- stateMutability: "payable",
262
- type: "function"
263
- },
264
- {
265
- inputs: [
266
- { internalType: "address", name: "vault", type: "address" },
267
- { internalType: "address", name: "token", type: "address" }
268
- ],
269
- name: "vaultAllowance",
270
- outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
271
- stateMutability: "view",
272
- type: "function"
273
- }
274
- ];
275
- var MayaArbitrumVaultAbi = [
276
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
277
- {
278
- anonymous: false,
279
- inputs: [
280
- { indexed: true, internalType: "address", name: "to", type: "address" },
281
- { indexed: true, internalType: "address", name: "asset", type: "address" },
282
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
283
- { indexed: false, internalType: "string", name: "memo", type: "string" }
284
- ],
285
- name: "Deposit",
286
- type: "event"
287
- },
288
- {
289
- anonymous: false,
290
- inputs: [
291
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
292
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
293
- { indexed: false, internalType: "address", name: "asset", type: "address" },
294
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
295
- { indexed: false, internalType: "string", name: "memo", type: "string" }
296
- ],
297
- name: "TransferAllowance",
298
- type: "event"
299
- },
300
- {
301
- anonymous: false,
302
- inputs: [
303
- { indexed: true, internalType: "address", name: "vault", type: "address" },
304
- { indexed: true, internalType: "address", name: "to", type: "address" },
305
- { indexed: false, internalType: "address", name: "asset", type: "address" },
306
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
307
- { indexed: false, internalType: "string", name: "memo", type: "string" }
308
- ],
309
- name: "TransferOut",
310
- type: "event"
311
- },
312
- {
313
- anonymous: false,
314
- inputs: [
315
- { indexed: true, internalType: "address", name: "vault", type: "address" },
316
- { indexed: false, internalType: "address", name: "target", type: "address" },
317
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
318
- { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
319
- { indexed: false, internalType: "address", name: "to", type: "address" },
320
- { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
321
- { indexed: false, internalType: "string", name: "memo", type: "string" }
322
- ],
323
- name: "TransferOutAndCall",
324
- type: "event"
325
- },
326
- {
327
- anonymous: false,
328
- inputs: [
329
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
330
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
331
- {
332
- components: [
333
- { internalType: "address", name: "asset", type: "address" },
334
- { internalType: "uint256", name: "amount", type: "uint256" }
335
- ],
336
- indexed: false,
337
- internalType: "struct ArbRouter.Coin[]",
338
- name: "coins",
339
- type: "tuple[]"
340
- },
341
- { indexed: false, internalType: "string", name: "memo", type: "string" }
342
- ],
343
- name: "VaultTransfer",
344
- type: "event"
345
- },
346
- {
347
- inputs: [
348
- { internalType: "address payable", name: "vault", type: "address" },
349
- { internalType: "address", name: "asset", type: "address" },
350
- { internalType: "uint256", name: "amount", type: "uint256" },
351
- { internalType: "string", name: "memo", type: "string" }
352
- ],
353
- name: "deposit",
354
- outputs: [],
355
- stateMutability: "payable",
356
- type: "function"
357
- },
358
- {
359
- inputs: [
360
- { internalType: "address payable", name: "vault", type: "address" },
361
- { internalType: "address", name: "asset", type: "address" },
362
- { internalType: "uint256", name: "amount", type: "uint256" },
363
- { internalType: "string", name: "memo", type: "string" },
364
- { internalType: "uint256", name: "expiration", type: "uint256" }
365
- ],
366
- name: "depositWithExpiry",
367
- outputs: [],
368
- stateMutability: "payable",
369
- type: "function"
370
- },
371
- {
372
- inputs: [
373
- { internalType: "address", name: "router", type: "address" },
374
- { internalType: "address payable", name: "asgard", type: "address" },
375
- {
376
- components: [
377
- { internalType: "address", name: "asset", type: "address" },
378
- { internalType: "uint256", name: "amount", type: "uint256" }
379
- ],
380
- internalType: "struct ArbRouter.Coin[]",
381
- name: "coins",
382
- type: "tuple[]"
383
- },
384
- { internalType: "string", name: "memo", type: "string" }
385
- ],
386
- name: "returnVaultAssets",
387
- outputs: [],
388
- stateMutability: "payable",
389
- type: "function"
390
- },
391
- {
392
- inputs: [
393
- { internalType: "address", name: "router", type: "address" },
394
- { internalType: "address", name: "newVault", type: "address" },
395
- { internalType: "address", name: "asset", type: "address" },
396
- { internalType: "uint256", name: "amount", type: "uint256" },
397
- { internalType: "string", name: "memo", type: "string" }
398
- ],
399
- name: "transferAllowance",
400
- outputs: [],
401
- stateMutability: "nonpayable",
402
- type: "function"
403
- },
404
- {
405
- inputs: [
406
- { internalType: "address payable", name: "to", type: "address" },
407
- { internalType: "address", name: "asset", type: "address" },
408
- { internalType: "uint256", name: "amount", type: "uint256" },
409
- { internalType: "string", name: "memo", type: "string" }
410
- ],
411
- name: "transferOut",
412
- outputs: [],
413
- stateMutability: "payable",
414
- type: "function"
415
- },
416
- {
417
- inputs: [
418
- { internalType: "address payable", name: "target", type: "address" },
419
- { internalType: "address", name: "finalToken", type: "address" },
420
- { internalType: "address", name: "to", type: "address" },
421
- { internalType: "uint256", name: "amountOutMin", type: "uint256" },
422
- { internalType: "string", name: "memo", type: "string" }
423
- ],
424
- name: "transferOutAndCall",
425
- outputs: [],
426
- stateMutability: "payable",
427
- type: "function"
428
- },
429
- {
430
- inputs: [
431
- { internalType: "address", name: "vault", type: "address" },
432
- { internalType: "address", name: "token", type: "address" }
433
- ],
434
- name: "vaultAllowance",
435
- outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
436
- stateMutability: "view",
437
- type: "function"
438
- }
439
- ];
440
- // src/types/abis/tcEthVault.ts
441
- var TCEthereumVaultAbi = [
442
- {
443
- inputs: [{ internalType: "address", name: "rune", type: "address" }],
444
- stateMutability: "nonpayable",
445
- type: "constructor"
446
- },
447
- {
448
- anonymous: false,
449
- inputs: [
450
- { indexed: true, internalType: "address", name: "to", type: "address" },
451
- { indexed: true, internalType: "address", name: "asset", type: "address" },
452
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
453
- { indexed: false, internalType: "string", name: "memo", type: "string" }
454
- ],
455
- name: "Deposit",
456
- type: "event"
457
- },
458
- {
459
- anonymous: false,
460
- inputs: [
461
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
462
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
463
- { indexed: false, internalType: "address", name: "asset", type: "address" },
464
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
465
- { indexed: false, internalType: "string", name: "memo", type: "string" }
466
- ],
467
- name: "TransferAllowance",
468
- type: "event"
469
- },
470
- {
471
- anonymous: false,
472
- inputs: [
473
- { indexed: true, internalType: "address", name: "vault", type: "address" },
474
- { indexed: true, internalType: "address", name: "to", type: "address" },
475
- { indexed: false, internalType: "address", name: "asset", type: "address" },
476
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
477
- { indexed: false, internalType: "string", name: "memo", type: "string" }
478
- ],
479
- name: "TransferOut",
480
- type: "event"
481
- },
482
- {
483
- anonymous: false,
484
- inputs: [
485
- { indexed: true, internalType: "address", name: "vault", type: "address" },
486
- { indexed: false, internalType: "address", name: "target", type: "address" },
487
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
488
- { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
489
- { indexed: false, internalType: "address", name: "to", type: "address" },
490
- { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
491
- { indexed: false, internalType: "string", name: "memo", type: "string" }
492
- ],
493
- name: "TransferOutAndCall",
494
- type: "event"
495
- },
496
- {
497
- anonymous: false,
498
- inputs: [
499
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
500
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
501
- {
502
- components: [
503
- { internalType: "address", name: "asset", type: "address" },
504
- { internalType: "uint256", name: "amount", type: "uint256" }
505
- ],
506
- indexed: false,
507
- internalType: "struct THORChain_Router.Coin[]",
508
- name: "coins",
509
- type: "tuple[]"
510
- },
511
- { indexed: false, internalType: "string", name: "memo", type: "string" }
512
- ],
513
- name: "VaultTransfer",
514
- type: "event"
515
- },
516
- {
517
- inputs: [],
518
- name: "RUNE",
519
- outputs: [{ internalType: "address", name: "", type: "address" }],
520
- stateMutability: "view",
521
- type: "function"
522
- },
523
- {
524
- inputs: [
525
- { internalType: "address payable", name: "vault", type: "address" },
526
- { internalType: "address", name: "asset", type: "address" },
527
- { internalType: "uint256", name: "amount", type: "uint256" },
528
- { internalType: "string", name: "memo", type: "string" }
529
- ],
530
- name: "deposit",
531
- outputs: [],
532
- stateMutability: "payable",
533
- type: "function"
534
- },
535
- {
536
- inputs: [
537
- { internalType: "address payable", name: "vault", type: "address" },
538
- { internalType: "address", name: "asset", type: "address" },
539
- { internalType: "uint256", name: "amount", type: "uint256" },
540
- { internalType: "string", name: "memo", type: "string" },
541
- { internalType: "uint256", name: "expiration", type: "uint256" }
542
- ],
543
- name: "depositWithExpiry",
544
- outputs: [],
545
- stateMutability: "payable",
546
- type: "function"
547
- },
548
- {
549
- inputs: [
550
- { internalType: "address", name: "router", type: "address" },
551
- { internalType: "address payable", name: "asgard", type: "address" },
552
- {
553
- components: [
554
- { internalType: "address", name: "asset", type: "address" },
555
- { internalType: "uint256", name: "amount", type: "uint256" }
556
- ],
557
- internalType: "struct THORChain_Router.Coin[]",
558
- name: "coins",
559
- type: "tuple[]"
560
- },
561
- { internalType: "string", name: "memo", type: "string" }
562
- ],
563
- name: "returnVaultAssets",
564
- outputs: [],
565
- stateMutability: "payable",
566
- type: "function"
567
- },
568
- {
569
- inputs: [
570
- { internalType: "address", name: "router", type: "address" },
571
- { internalType: "address", name: "newVault", type: "address" },
572
- { internalType: "address", name: "asset", type: "address" },
573
- { internalType: "uint256", name: "amount", type: "uint256" },
574
- { internalType: "string", name: "memo", type: "string" }
575
- ],
576
- name: "transferAllowance",
577
- outputs: [],
578
- stateMutability: "nonpayable",
579
- type: "function"
580
- },
581
- {
582
- inputs: [
583
- { internalType: "address payable", name: "to", type: "address" },
584
- { internalType: "address", name: "asset", type: "address" },
585
- { internalType: "uint256", name: "amount", type: "uint256" },
586
- { internalType: "string", name: "memo", type: "string" }
587
- ],
588
- name: "transferOut",
589
- outputs: [],
590
- stateMutability: "payable",
591
- type: "function"
592
- },
593
- {
594
- inputs: [
595
- { internalType: "address payable", name: "aggregator", type: "address" },
596
- { internalType: "address", name: "finalToken", type: "address" },
597
- { internalType: "address", name: "to", type: "address" },
598
- { internalType: "uint256", name: "amountOutMin", type: "uint256" },
599
- { internalType: "string", name: "memo", type: "string" }
600
- ],
601
- name: "transferOutAndCall",
602
- outputs: [],
603
- stateMutability: "payable",
604
- type: "function"
605
- },
606
- {
607
- inputs: [
608
- { internalType: "address", name: "vault", type: "address" },
609
- { internalType: "address", name: "token", type: "address" }
610
- ],
611
- name: "vaultAllowance",
612
- outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
613
- stateMutability: "view",
614
- type: "function"
615
- }
616
- ];
617
- var TCAvalancheDepositABI = [
618
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
619
- {
620
- anonymous: false,
621
- inputs: [
622
- { indexed: true, internalType: "address", name: "to", type: "address" },
623
- { indexed: true, internalType: "address", name: "asset", type: "address" },
624
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
625
- { indexed: false, internalType: "string", name: "memo", type: "string" }
626
- ],
627
- name: "Deposit",
628
- type: "event"
629
- },
630
- {
631
- anonymous: false,
632
- inputs: [
633
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
634
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
635
- { indexed: false, internalType: "address", name: "asset", type: "address" },
636
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
637
- { indexed: false, internalType: "string", name: "memo", type: "string" }
638
- ],
639
- name: "TransferAllowance",
640
- type: "event"
641
- },
642
- {
643
- anonymous: false,
644
- inputs: [
645
- { indexed: true, internalType: "address", name: "vault", type: "address" },
646
- { indexed: true, internalType: "address", name: "to", type: "address" },
647
- { indexed: false, internalType: "address", name: "asset", type: "address" },
648
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
649
- { indexed: false, internalType: "string", name: "memo", type: "string" }
650
- ],
651
- name: "TransferOut",
652
- type: "event"
653
- },
654
- {
655
- anonymous: false,
656
- inputs: [
657
- { indexed: true, internalType: "address", name: "vault", type: "address" },
658
- { indexed: false, internalType: "address", name: "target", type: "address" },
659
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
660
- { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
661
- { indexed: false, internalType: "address", name: "to", type: "address" },
662
- { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
663
- { indexed: false, internalType: "string", name: "memo", type: "string" }
664
- ],
665
- name: "TransferOutAndCall",
666
- type: "event"
667
- },
668
- {
669
- anonymous: false,
670
- inputs: [
671
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
672
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
673
- {
674
- components: [
675
- { internalType: "address", name: "asset", type: "address" },
676
- { internalType: "uint256", name: "amount", type: "uint256" }
677
- ],
678
- indexed: false,
679
- internalType: "struct AvaxRouter.Coin[]",
680
- name: "coins",
681
- type: "tuple[]"
682
- },
683
- { indexed: false, internalType: "string", name: "memo", type: "string" }
684
- ],
685
- name: "VaultTransfer",
686
- type: "event"
687
- },
688
- {
689
- inputs: [
690
- { internalType: "address payable", name: "vault", type: "address" },
691
- { internalType: "address", name: "asset", type: "address" },
692
- { internalType: "uint256", name: "amount", type: "uint256" },
693
- { internalType: "string", name: "memo", type: "string" }
694
- ],
695
- name: "deposit",
696
- outputs: [],
697
- stateMutability: "payable",
698
- type: "function"
699
- },
700
- {
701
- inputs: [
702
- { internalType: "address payable", name: "vault", type: "address" },
703
- { internalType: "address", name: "asset", type: "address" },
704
- { internalType: "uint256", name: "amount", type: "uint256" },
705
- { internalType: "string", name: "memo", type: "string" },
706
- { internalType: "uint256", name: "expiration", type: "uint256" }
707
- ],
708
- name: "depositWithExpiry",
709
- outputs: [],
710
- stateMutability: "payable",
711
- type: "function"
712
- },
713
- {
714
- inputs: [
715
- { internalType: "address", name: "router", type: "address" },
716
- { internalType: "address payable", name: "asgard", type: "address" },
717
- {
718
- components: [
719
- { internalType: "address", name: "asset", type: "address" },
720
- { internalType: "uint256", name: "amount", type: "uint256" }
721
- ],
722
- internalType: "struct AvaxRouter.Coin[]",
723
- name: "coins",
724
- type: "tuple[]"
725
- },
726
- { internalType: "string", name: "memo", type: "string" }
727
- ],
728
- name: "returnVaultAssets",
729
- outputs: [],
730
- stateMutability: "payable",
731
- type: "function"
732
- },
733
- {
734
- inputs: [
735
- { internalType: "address", name: "router", type: "address" },
736
- { internalType: "address", name: "newVault", type: "address" },
737
- { internalType: "address", name: "asset", type: "address" },
738
- { internalType: "uint256", name: "amount", type: "uint256" },
739
- { internalType: "string", name: "memo", type: "string" }
740
- ],
741
- name: "transferAllowance",
742
- outputs: [],
743
- stateMutability: "nonpayable",
744
- type: "function"
745
- },
746
- {
747
- inputs: [
748
- { internalType: "address payable", name: "to", type: "address" },
749
- { internalType: "address", name: "asset", type: "address" },
750
- { internalType: "uint256", name: "amount", type: "uint256" },
751
- { internalType: "string", name: "memo", type: "string" }
752
- ],
753
- name: "transferOut",
754
- outputs: [],
755
- stateMutability: "payable",
756
- type: "function"
757
- },
758
- {
759
- inputs: [
760
- { internalType: "address payable", name: "target", type: "address" },
761
- { internalType: "address", name: "finalToken", type: "address" },
762
- { internalType: "address", name: "to", type: "address" },
763
- { internalType: "uint256", name: "amountOutMin", type: "uint256" },
764
- { internalType: "string", name: "memo", type: "string" }
765
- ],
766
- name: "transferOutAndCall",
767
- outputs: [],
768
- stateMutability: "payable",
769
- type: "function"
770
- },
771
- {
772
- inputs: [
773
- { internalType: "address", name: "vault", type: "address" },
774
- { internalType: "address", name: "token", type: "address" }
775
- ],
776
- name: "vaultAllowance",
777
- outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
778
- stateMutability: "view",
779
- type: "function"
780
- }
781
- ];
782
- var TCBscDepositABI = [
783
- { inputs: [], stateMutability: "nonpayable", type: "constructor" },
784
- {
785
- anonymous: false,
786
- inputs: [
787
- { indexed: true, internalType: "address", name: "to", type: "address" },
788
- { indexed: true, internalType: "address", name: "asset", type: "address" },
789
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
790
- { indexed: false, internalType: "string", name: "memo", type: "string" }
791
- ],
792
- name: "Deposit",
793
- type: "event"
794
- },
795
- {
796
- anonymous: false,
797
- inputs: [
798
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
799
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
800
- { indexed: false, internalType: "address", name: "asset", type: "address" },
801
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
802
- { indexed: false, internalType: "string", name: "memo", type: "string" }
803
- ],
804
- name: "TransferAllowance",
805
- type: "event"
806
- },
807
- {
808
- anonymous: false,
809
- inputs: [
810
- { indexed: true, internalType: "address", name: "vault", type: "address" },
811
- { indexed: true, internalType: "address", name: "to", type: "address" },
812
- { indexed: false, internalType: "address", name: "asset", type: "address" },
813
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
814
- { indexed: false, internalType: "string", name: "memo", type: "string" }
815
- ],
816
- name: "TransferOut",
817
- type: "event"
818
- },
819
- {
820
- anonymous: false,
821
- inputs: [
822
- { indexed: true, internalType: "address", name: "vault", type: "address" },
823
- { indexed: false, internalType: "address", name: "target", type: "address" },
824
- { indexed: false, internalType: "uint256", name: "amount", type: "uint256" },
825
- { indexed: false, internalType: "address", name: "finalAsset", type: "address" },
826
- { indexed: false, internalType: "address", name: "to", type: "address" },
827
- { indexed: false, internalType: "uint256", name: "amountOutMin", type: "uint256" },
828
- { indexed: false, internalType: "string", name: "memo", type: "string" }
829
- ],
830
- name: "TransferOutAndCall",
831
- type: "event"
832
- },
833
- {
834
- anonymous: false,
835
- inputs: [
836
- { indexed: true, internalType: "address", name: "oldVault", type: "address" },
837
- { indexed: true, internalType: "address", name: "newVault", type: "address" },
838
- {
839
- components: [
840
- { internalType: "address", name: "asset", type: "address" },
841
- { internalType: "uint256", name: "amount", type: "uint256" }
842
- ],
843
- indexed: false,
844
- internalType: "struct THORChain_Router.Coin[]",
845
- name: "coins",
846
- type: "tuple[]"
847
- },
848
- { indexed: false, internalType: "string", name: "memo", type: "string" }
849
- ],
850
- name: "VaultTransfer",
851
- type: "event"
852
- },
853
- {
854
- inputs: [
855
- { internalType: "address payable", name: "vault", type: "address" },
856
- { internalType: "address", name: "asset", type: "address" },
857
- { internalType: "uint256", name: "amount", type: "uint256" },
858
- { internalType: "string", name: "memo", type: "string" },
859
- { internalType: "uint256", name: "expiration", type: "uint256" }
860
- ],
861
- name: "depositWithExpiry",
862
- outputs: [],
863
- stateMutability: "payable",
864
- type: "function"
865
- },
866
- {
867
- inputs: [
868
- { internalType: "address", name: "router", type: "address" },
869
- { internalType: "address payable", name: "asgard", type: "address" },
870
- {
871
- components: [
872
- { internalType: "address", name: "asset", type: "address" },
873
- { internalType: "uint256", name: "amount", type: "uint256" }
874
- ],
875
- internalType: "struct THORChain_Router.Coin[]",
876
- name: "coins",
877
- type: "tuple[]"
878
- },
879
- { internalType: "string", name: "memo", type: "string" }
880
- ],
881
- name: "returnVaultAssets",
882
- outputs: [],
883
- stateMutability: "payable",
884
- type: "function"
885
- },
886
- {
887
- inputs: [
888
- { internalType: "address", name: "router", type: "address" },
889
- { internalType: "address", name: "newVault", type: "address" },
890
- { internalType: "address", name: "asset", type: "address" },
891
- { internalType: "uint256", name: "amount", type: "uint256" },
892
- { internalType: "string", name: "memo", type: "string" }
893
- ],
894
- name: "transferAllowance",
895
- outputs: [],
896
- stateMutability: "nonpayable",
897
- type: "function"
898
- },
899
- {
900
- inputs: [
901
- { internalType: "address payable", name: "to", type: "address" },
902
- { internalType: "address", name: "asset", type: "address" },
903
- { internalType: "uint256", name: "amount", type: "uint256" },
904
- { internalType: "string", name: "memo", type: "string" }
905
- ],
906
- name: "transferOut",
907
- outputs: [],
908
- stateMutability: "payable",
909
- type: "function"
910
- },
911
- {
912
- inputs: [
913
- { internalType: "address payable", name: "target", type: "address" },
914
- { internalType: "address", name: "finalToken", type: "address" },
915
- { internalType: "address", name: "to", type: "address" },
916
- { internalType: "uint256", name: "amountOutMin", type: "uint256" },
917
- { internalType: "string", name: "memo", type: "string" }
918
- ],
919
- name: "transferOutAndCall",
920
- outputs: [],
921
- stateMutability: "payable",
922
- type: "function"
923
- },
924
- {
925
- inputs: [
926
- { internalType: "address", name: "vault", type: "address" },
927
- { internalType: "address", name: "token", type: "address" }
928
- ],
929
- name: "vaultAllowance",
930
- outputs: [{ internalType: "uint256", name: "amount", type: "uint256" }],
931
- stateMutability: "view",
932
- type: "function"
933
- }
934
- ];
935
- // src/types/network.ts
936
- var RPCUrl;
937
- (function(RPCUrl2) {
938
- RPCUrl2["Arbitrum"] = "https://arb1.arbitrum.io/rpc";
939
- RPCUrl2["Avalanche"] = "https://node-router.thorswap.net/avalanche-c";
940
- RPCUrl2["Binance"] = "";
941
- RPCUrl2["BinanceSmartChain"] = "https://bsc-dataseed.binance.org";
942
- RPCUrl2["Bitcoin"] = "https://node-router.thorswap.net/bitcoin";
943
- RPCUrl2["BitcoinCash"] = "https://node-router.thorswap.net/bitcoin-cash";
944
- RPCUrl2["Chainflip"] = "wss://mainnet-archive.chainflip.io";
945
- RPCUrl2["Cosmos"] = "https://node-router.thorswap.net/cosmos/rpc";
946
- RPCUrl2["Dash"] = "https://node-router.thorswap.net/dash";
947
- RPCUrl2["Dogecoin"] = "https://node-router.thorswap.net/dogecoin";
948
- RPCUrl2["Ethereum"] = "https://node-router.thorswap.net/ethereum";
949
- RPCUrl2["Kujira"] = "https://rpc-kujira.synergynodes.com/";
950
- RPCUrl2["Litecoin"] = "https://node-router.thorswap.net/litecoin";
951
- RPCUrl2["Maya"] = "https://tendermint.mayachain.info";
952
- RPCUrl2["MayaStagenet"] = "https://stagenet.tendermint.mayachain.info";
953
- RPCUrl2["Optimism"] = "https://mainnet.optimism.io";
954
- RPCUrl2["Polkadot"] = "wss://rpc.polkadot.io";
955
- RPCUrl2["Polygon"] = "https://polygon-rpc.com";
956
- RPCUrl2["Radix"] = "https://radix-mainnet.rpc.grove.city/v1/326002fc/core";
957
- RPCUrl2["THORChain"] = "https://rpc.thorswap.net";
958
- RPCUrl2["THORChainStagenet"] = "https://stagenet-rpc.ninerealms.com";
959
- })(RPCUrl || (RPCUrl = {}));
960
- var ExplorerUrl;
961
- (function(ExplorerUrl2) {
962
- ExplorerUrl2["Arbitrum"] = "https://arbiscan.io";
963
- ExplorerUrl2["Avalanche"] = "https://snowtrace.io";
964
- ExplorerUrl2["Binance"] = "https://explorer.binance.org";
965
- ExplorerUrl2["BinanceSmartChain"] = "https://bscscan.com";
966
- ExplorerUrl2["Bitcoin"] = "https://blockchair.com/bitcoin";
967
- ExplorerUrl2["BitcoinCash"] = "https://www.blockchair.com/bitcoin-cash";
968
- ExplorerUrl2["Chainflip"] = "https://explorer.polkascan.io/polkadot";
969
- ExplorerUrl2["Cosmos"] = "https://www.mintscan.io/cosmos";
970
- ExplorerUrl2["Dash"] = "https://blockchair.com/dash";
971
- ExplorerUrl2["Dogecoin"] = "https://blockchair.com/dogecoin";
972
- ExplorerUrl2["Ethereum"] = "https://etherscan.io";
973
- ExplorerUrl2["Kujira"] = "https://finder.kujira.network/kaiyo-1";
974
- ExplorerUrl2["Litecoin"] = "https://blockchair.com/litecoin";
975
- ExplorerUrl2["Maya"] = "https://www.mayascan.org";
976
- ExplorerUrl2["Optimism"] = "https://optimistic.etherscan.io";
977
- ExplorerUrl2["Polkadot"] = "https://polkadot.subscan.io/";
978
- ExplorerUrl2["Polygon"] = "https://polygonscan.com";
979
- ExplorerUrl2["Radix"] = "https://dashboard.radixdlt.com";
980
- ExplorerUrl2["THORChain"] = "https://runescan.io";
981
- })(ExplorerUrl || (ExplorerUrl = {}));
982
-
983
- // src/types/chains.ts
984
- var Chain;
985
- (function(Chain2) {
986
- Chain2["Arbitrum"] = "ARB";
987
- Chain2["Avalanche"] = "AVAX";
988
- Chain2["Binance"] = "BNB";
989
- Chain2["BinanceSmartChain"] = "BSC";
990
- Chain2["Bitcoin"] = "BTC";
991
- Chain2["BitcoinCash"] = "BCH";
992
- Chain2["Cosmos"] = "GAIA";
993
- Chain2["Dash"] = "DASH";
994
- Chain2["Dogecoin"] = "DOGE";
995
- Chain2["Ethereum"] = "ETH";
996
- Chain2["Kujira"] = "KUJI";
997
- Chain2["Litecoin"] = "LTC";
998
- Chain2["Maya"] = "MAYA";
999
- Chain2["Optimism"] = "OP";
1000
- Chain2["Polkadot"] = "DOT";
1001
- Chain2["Chainflip"] = "FLIP";
1002
- Chain2["Polygon"] = "MATIC";
1003
- Chain2["Radix"] = "XRD";
1004
- Chain2["THORChain"] = "THOR";
1005
- })(Chain || (Chain = {}));
1006
- var ChainId;
1007
- (function(ChainId2) {
1008
- ChainId2["Arbitrum"] = "42161";
1009
- ChainId2["ArbitrumHex"] = "0xa4b1";
1010
- ChainId2["Avalanche"] = "43114";
1011
- ChainId2["AvalancheHex"] = "0xa86a";
1012
- ChainId2["Binance"] = "Binance-Chain-Tigris";
1013
- ChainId2["BinanceSmartChain"] = "56";
1014
- ChainId2["BinanceSmartChainHex"] = "0x38";
1015
- ChainId2["Bitcoin"] = "bitcoin";
1016
- ChainId2["BitcoinCash"] = "bitcoincash";
1017
- ChainId2["Chainflip"] = "chainflip";
1018
- ChainId2["Cosmos"] = "cosmoshub-4";
1019
- ChainId2["Dash"] = "dash";
1020
- ChainId2["Dogecoin"] = "dogecoin";
1021
- ChainId2["Kujira"] = "kaiyo-1";
1022
- ChainId2["Ethereum"] = "1";
1023
- ChainId2["EthereumHex"] = "0x1";
1024
- ChainId2["Litecoin"] = "litecoin";
1025
- ChainId2["Maya"] = "mayachain-mainnet-v1";
1026
- ChainId2["MayaStagenet"] = "mayachain-stagenet-v1";
1027
- ChainId2["Optimism"] = "10";
1028
- ChainId2["OptimismHex"] = "0xa";
1029
- ChainId2["Polkadot"] = "polkadot";
1030
- ChainId2["Polygon"] = "137";
1031
- ChainId2["PolygonHex"] = "0x89";
1032
- ChainId2["Radix"] = "radix-mainnet";
1033
- ChainId2["THORChain"] = "thorchain-mainnet-v1";
1034
- ChainId2["THORChainStagenet"] = "thorchain-stagenet-v2";
1035
- })(ChainId || (ChainId = {}));
1036
- var ChainIdToChain = {
1037
- [ChainId.ArbitrumHex]: Chain.Arbitrum,
1038
- [ChainId.Arbitrum]: Chain.Arbitrum,
1039
- [ChainId.AvalancheHex]: Chain.Avalanche,
1040
- [ChainId.Avalanche]: Chain.Avalanche,
1041
- [ChainId.BinanceSmartChainHex]: Chain.BinanceSmartChain,
1042
- [ChainId.BinanceSmartChain]: Chain.BinanceSmartChain,
1043
- [ChainId.Binance]: Chain.Binance,
1044
- [ChainId.BitcoinCash]: Chain.BitcoinCash,
1045
- [ChainId.Bitcoin]: Chain.Bitcoin,
1046
- [ChainId.Chainflip]: Chain.Chainflip,
1047
- [ChainId.Cosmos]: Chain.Cosmos,
1048
- [ChainId.Dash]: Chain.Dash,
1049
- [ChainId.Dogecoin]: Chain.Dogecoin,
1050
- [ChainId.EthereumHex]: Chain.Ethereum,
1051
- [ChainId.Kujira]: Chain.Kujira,
1052
- [ChainId.Ethereum]: Chain.Ethereum,
1053
- [ChainId.Litecoin]: Chain.Litecoin,
1054
- [ChainId.MayaStagenet]: Chain.Maya,
1055
- [ChainId.Maya]: Chain.Maya,
1056
- [ChainId.OptimismHex]: Chain.Optimism,
1057
- [ChainId.Optimism]: Chain.Optimism,
1058
- [ChainId.Polkadot]: Chain.Polkadot,
1059
- [ChainId.PolygonHex]: Chain.Polygon,
1060
- [ChainId.Polygon]: Chain.Polygon,
1061
- [ChainId.Radix]: Chain.Radix,
1062
- [ChainId.THORChainStagenet]: Chain.THORChain,
1063
- [ChainId.THORChain]: Chain.THORChain
1064
- };
1065
- var chainNames = Object.keys(Chain);
1066
- var chains = Object.values(Chain);
1067
- var BaseDecimal;
1068
- (function(BaseDecimal2) {
1069
- BaseDecimal2[BaseDecimal2["ARB"] = 18] = "ARB";
1070
- BaseDecimal2[BaseDecimal2["AVAX"] = 18] = "AVAX";
1071
- BaseDecimal2[BaseDecimal2["BCH"] = 8] = "BCH";
1072
- BaseDecimal2[BaseDecimal2["BNB"] = 8] = "BNB";
1073
- BaseDecimal2[BaseDecimal2["BSC"] = 18] = "BSC";
1074
- BaseDecimal2[BaseDecimal2["BTC"] = 8] = "BTC";
1075
- BaseDecimal2[BaseDecimal2["DASH"] = 8] = "DASH";
1076
- BaseDecimal2[BaseDecimal2["DOGE"] = 8] = "DOGE";
1077
- BaseDecimal2[BaseDecimal2["DOT"] = 10] = "DOT";
1078
- BaseDecimal2[BaseDecimal2["ETH"] = 18] = "ETH";
1079
- BaseDecimal2[BaseDecimal2["FLIP"] = 18] = "FLIP";
1080
- BaseDecimal2[BaseDecimal2["GAIA"] = 6] = "GAIA";
1081
- BaseDecimal2[BaseDecimal2["KUJI"] = 6] = "KUJI";
1082
- BaseDecimal2[BaseDecimal2["LTC"] = 8] = "LTC";
1083
- BaseDecimal2[BaseDecimal2["MATIC"] = 18] = "MATIC";
1084
- BaseDecimal2[BaseDecimal2["MAYA"] = 10] = "MAYA";
1085
- BaseDecimal2[BaseDecimal2["OP"] = 18] = "OP";
1086
- BaseDecimal2[BaseDecimal2["THOR"] = 8] = "THOR";
1087
- BaseDecimal2[BaseDecimal2["ZEC"] = 8] = "ZEC";
1088
- BaseDecimal2[BaseDecimal2["XRD"] = 18] = "XRD";
1089
- })(BaseDecimal || (BaseDecimal = {}));
1090
- var SubstrateChains = [Chain.Polkadot, Chain.Chainflip];
1091
- var EVMChains = [
1092
- Chain.Ethereum,
1093
- Chain.Avalanche,
1094
- Chain.BinanceSmartChain,
1095
- Chain.Arbitrum,
1096
- Chain.Optimism,
1097
- Chain.Polygon
1098
- ];
1099
- var UTXOChains = [
1100
- Chain.Bitcoin,
1101
- Chain.BitcoinCash,
1102
- Chain.Dash,
1103
- Chain.Dogecoin,
1104
- Chain.Litecoin
1105
- ];
1106
- var CosmosChains = [
1107
- Chain.Cosmos,
1108
- Chain.THORChain,
1109
- Chain.Binance,
1110
- Chain.Maya,
1111
- Chain.Kujira
1112
- ];
1113
- var TCSupportedChains = [
1114
- Chain.Avalanche,
1115
- Chain.Binance,
1116
- Chain.BinanceSmartChain,
1117
- Chain.Bitcoin,
1118
- Chain.BitcoinCash,
1119
- Chain.Cosmos,
1120
- Chain.Dogecoin,
1121
- Chain.Ethereum,
1122
- Chain.Litecoin,
1123
- Chain.THORChain
1124
- ];
1125
- var MAYASupportedChains = [
1126
- Chain.Arbitrum,
1127
- Chain.Dash,
1128
- Chain.Ethereum,
1129
- Chain.Kujira,
1130
- Chain.Maya,
1131
- Chain.THORChain
1132
- ];
1133
- var ChainToChainName = chains.reduce((acc, chain) => {
1134
- const chainName = chainNames.find((key) => Chain[key] === chain);
1135
- if (chainName)
1136
- acc[chain] = chainName;
1137
- return acc;
1138
- }, {});
1139
- var ChainToChainId = chains.reduce((acc, chain) => {
1140
- acc[chain] = ChainId[ChainToChainName[chain]];
1141
- return acc;
1142
- }, {});
1143
- var ChainToRPC = chains.reduce((acc, chain) => {
1144
- acc[chain] = RPCUrl[ChainToChainName[chain]];
1145
- return acc;
1146
- }, {});
1147
- var ChainToHexChainId = chains.reduce((acc, chain) => {
1148
- const chainString = `${ChainToChainName[chain]}Hex`;
1149
- acc[chain] = ChainId[chainString];
1150
- return acc;
1151
- }, {});
1152
- var ChainToExplorerUrl = chains.reduce((acc, chain) => {
1153
- acc[chain] = ExplorerUrl[ChainToChainName[chain]];
1154
- return acc;
1155
- }, {});
1156
- // src/types/commonTypes.ts
1157
- var QuoteMode;
1158
- (function(QuoteMode2) {
1159
- QuoteMode2["TC_SUPPORTED_TO_TC_SUPPORTED"] = "TC-TC";
1160
- QuoteMode2["TC_SUPPORTED_TO_ETH"] = "TC-ERC20";
1161
- QuoteMode2["TC_SUPPORTED_TO_AVAX"] = "TC-ARC20";
1162
- QuoteMode2["TC_SUPPORTED_TO_BSC"] = "TC-BEP20";
1163
- QuoteMode2["ETH_TO_TC_SUPPORTED"] = "ERC20-TC";
1164
- QuoteMode2["ETH_TO_ETH"] = "ERC20-ERC20";
1165
- QuoteMode2["ETH_TO_AVAX"] = "ERC20-ARC20";
1166
- QuoteMode2["ETH_TO_BSC"] = "ERC20-BEP20";
1167
- QuoteMode2["AVAX_TO_TC_SUPPORTED"] = "ARC20-TC";
1168
- QuoteMode2["AVAX_TO_ETH"] = "ARC20-ERC20";
1169
- QuoteMode2["AVAX_TO_AVAX"] = "ARC20-ARC20";
1170
- QuoteMode2["AVAX_TO_BSC"] = "ARC20-BEP20";
1171
- QuoteMode2["BSC_TO_TC_SUPPORTED"] = "BEP20-TC";
1172
- QuoteMode2["BSC_TO_ETH"] = "BEP20-ERC20";
1173
- QuoteMode2["BSC_TO_AVAX"] = "BEP20-ARC20";
1174
- QuoteMode2["BSC_TO_BSC"] = "BEP20-BEP20";
1175
- })(QuoteMode || (QuoteMode = {}));
1176
- var AGG_SWAP = [QuoteMode.ETH_TO_ETH, QuoteMode.AVAX_TO_AVAX, QuoteMode.BSC_TO_BSC];
1177
- var SWAP_IN = [
1178
- QuoteMode.ETH_TO_TC_SUPPORTED,
1179
- QuoteMode.ETH_TO_AVAX,
1180
- QuoteMode.ETH_TO_BSC,
1181
- QuoteMode.AVAX_TO_TC_SUPPORTED,
1182
- QuoteMode.AVAX_TO_ETH,
1183
- QuoteMode.AVAX_TO_BSC,
1184
- QuoteMode.BSC_TO_TC_SUPPORTED,
1185
- QuoteMode.BSC_TO_ETH,
1186
- QuoteMode.BSC_TO_AVAX
1187
- ];
1188
- var SWAP_OUT = [
1189
- QuoteMode.TC_SUPPORTED_TO_TC_SUPPORTED,
1190
- QuoteMode.TC_SUPPORTED_TO_ETH,
1191
- QuoteMode.TC_SUPPORTED_TO_AVAX,
1192
- QuoteMode.TC_SUPPORTED_TO_BSC
1193
- ];
1194
- // src/types/derivationPath.ts
1195
- var ContractAddress;
1196
- (function(ContractAddress2) {
1197
- ContractAddress2["ARB"] = "0x0000000000000000000000000000000000000000";
1198
- ContractAddress2["AVAX"] = "0x0000000000000000000000000000000000000000";
1199
- ContractAddress2["ETH"] = "0x0000000000000000000000000000000000000000";
1200
- ContractAddress2["BSC"] = "0x0000000000000000000000000000000000000000";
1201
- ContractAddress2["MATIC"] = "0x0000000000000000000000000000000000001010";
1202
- ContractAddress2["OP"] = "0x4200000000000000000000000000000000000042";
1203
- })(ContractAddress || (ContractAddress = {}));
1204
- var DerivationPath;
1205
- (function(DerivationPath2) {
1206
- DerivationPath2["ARB"] = "m/44'/60'/0'/0";
1207
- DerivationPath2["AVAX"] = "m/44'/60'/0'/0";
1208
- DerivationPath2["BCH"] = "m/44'/145'/0'/0";
1209
- DerivationPath2["BNB"] = "m/44'/714'/0'/0";
1210
- DerivationPath2["BSC"] = "m/44'/60'/0'/0";
1211
- DerivationPath2["BTC"] = "m/84'/0'/0'/0";
1212
- DerivationPath2["DASH"] = "m/44'/5'/0'/0";
1213
- DerivationPath2["DOGE"] = "m/44'/3'/0'/0";
1214
- DerivationPath2["DOT"] = "////";
1215
- DerivationPath2["ETH"] = "m/44'/60'/0'/0";
1216
- DerivationPath2["FLIP"] = "////";
1217
- DerivationPath2["GAIA"] = "m/44'/118'/0'/0";
1218
- DerivationPath2["KUJI"] = "m/44'/118'/0'/0";
1219
- DerivationPath2["LTC"] = "m/84'/2'/0'/0";
1220
- DerivationPath2["MATIC"] = "m/44'/60'/0'/0";
1221
- DerivationPath2["MAYA"] = "m/44'/931'/0'/0";
1222
- DerivationPath2["OP"] = "m/44'/60'/0'/0";
1223
- DerivationPath2["XRD"] = "////";
1224
- DerivationPath2["THOR"] = "m/44'/931'/0'/0";
1225
- })(DerivationPath || (DerivationPath = {}));
1226
- var NetworkDerivationPath = {
1227
- ARB: [44, 60, 0, 0, 0],
1228
- AVAX: [44, 60, 0, 0, 0],
1229
- BCH: [44, 145, 0, 0, 0],
1230
- BNB: [44, 714, 0, 0, 0],
1231
- BSC: [44, 60, 0, 0, 0],
1232
- BTC: [84, 0, 0, 0, 0],
1233
- DASH: [44, 5, 0, 0, 0],
1234
- DOGE: [44, 3, 0, 0, 0],
1235
- ETH: [44, 60, 0, 0, 0],
1236
- GAIA: [44, 118, 0, 0, 0],
1237
- KUJI: [44, 118, 0, 0, 0],
1238
- LTC: [84, 2, 0, 0, 0],
1239
- MATIC: [44, 60, 0, 0, 0],
1240
- MAYA: [44, 931, 0, 0, 0],
1241
- OP: [44, 60, 0, 0, 0],
1242
- THOR: [44, 931, 0, 0, 0],
1243
- XRD: [0, 0, 0, 0, 0],
1244
- DOT: [0, 0, 0, 0, 0],
1245
- FLIP: [0, 0, 0, 0, 0]
1246
- };
1247
- // src/types/wallet.ts
1248
- var WalletOption;
1249
- (function(WalletOption2) {
1250
- WalletOption2["KEYSTORE"] = "KEYSTORE";
1251
- WalletOption2["KEEPKEY"] = "KEEPKEY";
1252
- WalletOption2["XDEFI"] = "XDEFI";
1253
- WalletOption2["METAMASK"] = "METAMASK";
1254
- WalletOption2["COINBASE_WEB"] = "COINBASE_WEB";
1255
- WalletOption2["COINBASE_MOBILE"] = "COINBASE_MOBILE";
1256
- WalletOption2["TREZOR"] = "TREZOR";
1257
- WalletOption2["TRUSTWALLET_WEB"] = "TRUSTWALLET_WEB";
1258
- WalletOption2["LEDGER"] = "LEDGER";
1259
- WalletOption2["KEPLR"] = "KEPLR";
1260
- WalletOption2["OKX"] = "OKX";
1261
- WalletOption2["OKX_MOBILE"] = "OKX_MOBILE";
1262
- WalletOption2["BRAVE"] = "BRAVE";
1263
- WalletOption2["WALLETCONNECT"] = "WALLETCONNECT";
1264
- WalletOption2["EIP6963"] = "EIP6963";
1265
- WalletOption2["EXODUS"] = "EXODUS";
1266
- WalletOption2["RADIX_WALLET"] = "RADIX_WALLET";
1267
- WalletOption2["TALISMAN"] = "TALISMAN";
1268
- })(WalletOption || (WalletOption = {}));
1269
- var LedgerErrorCode;
1270
- (function(LedgerErrorCode2) {
1271
- LedgerErrorCode2[LedgerErrorCode2["NoError"] = 36864] = "NoError";
1272
- LedgerErrorCode2[LedgerErrorCode2["LockedDevice"] = 21781] = "LockedDevice";
1273
- LedgerErrorCode2[LedgerErrorCode2["TC_NotFound"] = 65535] = "TC_NotFound";
1274
- })(LedgerErrorCode || (LedgerErrorCode = {}));
1275
- // src/types/sdk.ts
1276
- import {z} from "zod";
1277
- var FeeOption;
1278
- (function(FeeOption2) {
1279
- FeeOption2["Average"] = "average";
1280
- FeeOption2["Fast"] = "fast";
1281
- FeeOption2["Fastest"] = "fastest";
1282
- })(FeeOption || (FeeOption = {}));
1283
- var ApproveMode;
1284
- (function(ApproveMode2) {
1285
- ApproveMode2["Approve"] = "approve";
1286
- ApproveMode2["CheckOnly"] = "checkOnly";
1287
- })(ApproveMode || (ApproveMode = {}));
1288
- var MemoType;
1289
- (function(MemoType2) {
1290
- MemoType2["BOND"] = "BOND";
1291
- MemoType2["DEPOSIT"] = "+";
1292
- MemoType2["LEAVE"] = "LEAVE";
1293
- MemoType2["NAME_REGISTER"] = "~";
1294
- MemoType2["UNBOND"] = "UNBOND";
1295
- MemoType2["WITHDRAW"] = "-";
1296
- MemoType2["OPEN_LOAN"] = "$+";
1297
- MemoType2["CLOSE_LOAN"] = "$-";
1298
- })(MemoType || (MemoType = {}));
1299
- var QuoteRequestSchema = z.object({
1300
- sellAsset: z.string({
1301
- description: "Asset to sell"
1302
- }),
1303
- buyAsset: z.string({
1304
- description: "Asset to buy"
1305
- }),
1306
- sellAmount: z.number({
1307
- description: "Amount of asset to sell"
1308
- }).refine((amount) => amount > 0, {
1309
- message: "sellAmount must be greater than 0",
1310
- path: ["sellAmount"]
1311
- }),
1312
- providers: z.optional(z.array(z.string({
1313
- description: "List of providers to use"
1314
- }))),
1315
- sourceAddress: z.optional(z.string({
1316
- description: "Address to send asset from"
1317
- })),
1318
- destinationAddress: z.optional(z.string({
1319
- description: "Address to send asset to"
1320
- })),
1321
- slippage: z.optional(z.number({
1322
- description: "Slippage tolerance as a percentage. Default is 3%."
1323
- })),
1324
- affiliate: z.optional(z.string({
1325
- description: "Affiliate thorname"
1326
- })),
1327
- affiliateFee: z.optional(z.number({
1328
- description: "Affiliate fee in basis points"
1329
- }).refine((fee) => {
1330
- return fee === Math.floor(fee) && fee >= 0;
1331
- }, { message: "affiliateFee must be a positive integer", path: ["affiliateFee"] })),
1332
- allowSmartContractSender: z.optional(z.boolean({
1333
- description: "Allow smart contract as sender"
1334
- })),
1335
- allowSmartContractReceiver: z.optional(z.boolean({
1336
- description: "Allow smart contract as recipient"
1337
- })),
1338
- disableSecurityChecks: z.optional(z.boolean({
1339
- description: "Disable security checks"
1340
- }))
1341
- }).refine((data) => data.sellAsset !== data.buyAsset, {
1342
- message: "Must be different",
1343
- path: ["sellAsset", "buyAsset"]
1344
- });
1345
- // src/types/quotes.ts
1346
- import {z as z2} from "zod";
1347
- var WarningCodeEnum;
1348
- (function(WarningCodeEnum2) {
1349
- WarningCodeEnum2["highSlippage"] = "highSlippage";
1350
- WarningCodeEnum2["highPriceImpact"] = "highPriceImpact";
1351
- })(WarningCodeEnum || (WarningCodeEnum = {}));
1352
- var EVMTransactionDetailsParamsSchema = z2.array(z2.union([
1353
- z2.string(),
1354
- z2.number(),
1355
- z2.array(z2.string()),
1356
- z2.object({
1357
- from: z2.string(),
1358
- value: z2.string()
1359
- }).describe("Parameters to pass to the contract method")
1360
- ]));
1361
- var EVMTransactionDetailsSchema = z2.object({
1362
- contractAddress: z2.string({
1363
- description: "Address of the contract to interact with"
1364
- }),
1365
- contractMethod: z2.string({
1366
- description: "Name of the method to call"
1367
- }),
1368
- contractParams: EVMTransactionDetailsParamsSchema,
1369
- contractParamNames: z2.array(z2.string({
1370
- description: "Names of the parameters to pass to the contract method"
1371
- })),
1372
- approvalToken: z2.optional(z2.string({
1373
- description: "Address of the token to approve spending of"
1374
- })),
1375
- approvalSpender: z2.optional(z2.string({
1376
- description: "Address of the spender to approve"
1377
- }))
1378
- });
1379
- var EstimatedTimeSchema = z2.object({
1380
- inbound: z2.optional(z2.number({
1381
- description: "Time to receive inbound asset in seconds"
1382
- })),
1383
- swap: z2.optional(z2.number({
1384
- description: "Time to swap assets in seconds"
1385
- })),
1386
- outbound: z2.optional(z2.number({
1387
- description: "Time to receive outbound asset in seconds"
1388
- })),
1389
- total: z2.number({
1390
- description: "Total time in seconds"
1391
- })
1392
- });
1393
- var ProviderName;
1394
- (function(ProviderName2) {
1395
- ProviderName2["CHAINFLIP"] = "CHAINFLIP";
1396
- ProviderName2["TRADERJOE_V1"] = "TRADERJOE_V1";
1397
- ProviderName2["PANGOLIN_V1"] = "PANGOLIN_V1";
1398
- ProviderName2["UNISWAP_V2"] = "UNISWAP_V2";
1399
- ProviderName2["THORCHAIN"] = "THORCHAIN";
1400
- ProviderName2["THORCHAIN_STREAMING"] = "THORCHAIN_STREAMING";
1401
- ProviderName2["MAYACHAIN"] = "MAYACHAIN";
1402
- ProviderName2["ONEINCH"] = "ONEINCH";
1403
- ProviderName2["SUSHISWAP_V2"] = "SUSHISWAP_V2";
1404
- ProviderName2["WOOFI_V2"] = "WOOFI_V2";
1405
- ProviderName2["PANCAKESWAP"] = "PANCAKESWAP";
1406
- })(ProviderName || (ProviderName = {}));
1407
- var FeeTypeEnum;
1408
- (function(FeeTypeEnum2) {
1409
- FeeTypeEnum2["LIQUIDITY"] = "liquidity";
1410
- FeeTypeEnum2["NETWORK"] = "network";
1411
- FeeTypeEnum2["INBOUND"] = "inbound";
1412
- FeeTypeEnum2["OUTBOUND"] = "outbound";
1413
- FeeTypeEnum2["AFFILIATE"] = "affiliate";
1414
- FeeTypeEnum2["TAX"] = "tax";
1415
- })(FeeTypeEnum || (FeeTypeEnum = {}));
1416
- var FeesSchema = z2.array(z2.object({
1417
- type: z2.nativeEnum(FeeTypeEnum),
1418
- amount: z2.string(),
1419
- asset: z2.string(),
1420
- chain: z2.string(),
1421
- protocol: z2.nativeEnum(ProviderName)
1422
- }));
1423
- var RouteLegSchema = z2.object({
1424
- sellAsset: z2.string({
1425
- description: "Asset to sell"
1426
- }),
1427
- buyAsset: z2.string({
1428
- description: "Asset to buy"
1429
- }),
1430
- provider: z2.nativeEnum(ProviderName),
1431
- sourceAddress: z2.string({
1432
- description: "Source address"
1433
- }),
1434
- destinationAddress: z2.string({
1435
- description: "Destination address"
1436
- }),
1437
- estimatedTime: EstimatedTimeSchema.optional(),
1438
- affiliate: z2.string({
1439
- description: "Affiliate address"
1440
- }).optional(),
1441
- affiliateFee: z2.number({
1442
- description: "Affiliate fee"
1443
- }).optional(),
1444
- slipPercentage: z2.number({
1445
- description: "Slippage as a percentage"
1446
- })
1447
- });
1448
- var RouteLegWithoutAddressesSchema = RouteLegSchema.omit({
1449
- sourceAddress: true,
1450
- destinationAddress: true,
1451
- slipPercentage: true
1452
- });
1453
- var RouteQuoteMetadataAssetSchema = z2.object({
1454
- name: z2.string({
1455
- description: "Asset name"
1456
- }),
1457
- price: z2.number({
1458
- description: "Price in USD"
1459
- }),
1460
- image: z2.string({
1461
- description: "Asset image"
1462
- })
1463
- });
1464
- var RouteQuoteMetadataSchema = z2.object({
1465
- priceImpact: z2.number({
1466
- description: "Price impact"
1467
- }),
1468
- assets: z2.optional(z2.array(RouteQuoteMetadataAssetSchema))
1469
- });
1470
- var RouteQuoteWarningSchema = z2.array(z2.object({
1471
- code: z2.nativeEnum(WarningCodeEnum),
1472
- display: z2.string(),
1473
- tooltip: z2.string().optional()
1474
- }));
1475
- var RouteQuoteLegSchema = z2.object({
1476
- sellAsset: z2.string({
1477
- description: "Asset to sell"
1478
- }),
1479
- buyAsset: z2.string({
1480
- description: "Asset to buy"
1481
- }),
1482
- provider: z2.nativeEnum(ProviderName),
1483
- buyAmount: z2.string({
1484
- description: "Amount of asset to buy"
1485
- }),
1486
- buyAmountMaxSlippage: z2.string({
1487
- description: "Amount of asset to buy"
1488
- }),
1489
- sellAmount: z2.string({
1490
- description: "Amount of asset to sell"
1491
- }),
1492
- sourceAddress: z2.string({
1493
- description: "Source address"
1494
- }),
1495
- destinationAddress: z2.string({
1496
- description: "Destination address"
1497
- }),
1498
- slippageBps: z2.number({
1499
- description: "Slippage in bps"
1500
- }),
1501
- targetAddress: z2.optional(z2.string({
1502
- description: "Target address for contract call or transfer address"
1503
- })),
1504
- inboundAddress: z2.optional(z2.string({
1505
- description: "Inbound address"
1506
- })),
1507
- routerAddress: z2.optional(z2.string({
1508
- description: "Inbound address"
1509
- })),
1510
- contractMethod: z2.optional(z2.string({
1511
- description: "Contract method"
1512
- })),
1513
- fees: z2.optional(FeesSchema),
1514
- estimatedTime: z2.optional(EstimatedTimeSchema),
1515
- memo: z2.optional(z2.string({
1516
- description: "Memo"
1517
- })),
1518
- expiration: z2.optional(z2.string({
1519
- description: "Expiration"
1520
- }))
1521
- });
1522
- var RouteQuoteSchema = z2.object({
1523
- providers: z2.array(z2.nativeEnum(ProviderName)),
1524
- sellAsset: z2.string({
1525
- description: "Asset to sell"
1526
- }),
1527
- sellAmount: z2.string({
1528
- description: "sell amount"
1529
- }),
1530
- buyAsset: z2.string({
1531
- description: "Asset to buy"
1532
- }),
1533
- expectedBuyAmount: z2.string({
1534
- description: "Expected Buy amount"
1535
- }),
1536
- expectedBuyAmountMaxSlippage: z2.string({
1537
- description: "Expected Buy amount max slippage"
1538
- }),
1539
- sourceAddress: z2.string({
1540
- description: "Source address"
1541
- }),
1542
- destinationAddress: z2.string({
1543
- description: "Destination address"
1544
- }),
1545
- targetAddress: z2.optional(z2.string({
1546
- description: "Target address"
1547
- })),
1548
- routerAddress: z2.optional(z2.string({
1549
- description: "Router address"
1550
- })),
1551
- inboundAddress: z2.optional(z2.string({
1552
- description: "Inbound address"
1553
- })),
1554
- expiration: z2.optional(z2.string({
1555
- description: "Expiration"
1556
- })),
1557
- memo: z2.optional(z2.string({
1558
- description: "Memo"
1559
- })),
1560
- evmTransactionDetails: z2.optional(EVMTransactionDetailsSchema),
1561
- routePathArray: z2.optional(z2.array(z2.string())),
1562
- estimatedTime: z2.optional(EstimatedTimeSchema),
1563
- totalSlippageBps: z2.number({
1564
- description: "Total slippage in bps"
1565
- }),
1566
- legs: z2.array(RouteQuoteLegSchema),
1567
- errorCode: z2.optional(z2.string()),
1568
- warnings: RouteQuoteWarningSchema,
1569
- meta: RouteQuoteMetadataSchema
1570
- });
1571
- var QuoteResponseRouteLegItem = z2.object({
1572
- provider: z2.nativeEnum(ProviderName),
1573
- sellAsset: z2.string({
1574
- description: "Asset to sell"
1575
- }),
1576
- sellAmount: z2.string({
1577
- description: "Sell amount"
1578
- }),
1579
- buyAsset: z2.string({
1580
- description: "Asset to buy"
1581
- }),
1582
- buyAmount: z2.string({
1583
- description: "Buy amount"
1584
- }),
1585
- buyAmountMaxSlippage: z2.string({
1586
- description: "Buy amount max slippage"
1587
- }),
1588
- fees: z2.optional(FeesSchema)
1589
- });
1590
- var QuoteResponseRouteItem = z2.object({
1591
- providers: z2.array(z2.nativeEnum(ProviderName)),
1592
- sellAsset: z2.string({
1593
- description: "Asset to sell"
1594
- }),
1595
- sellAmount: z2.string({
1596
- description: "sell amount"
1597
- }),
1598
- buyAsset: z2.string({
1599
- description: "Asset to buy"
1600
- }),
1601
- expectedBuyAmount: z2.string({
1602
- description: "Expected Buy amount"
1603
- }),
1604
- expectedBuyAmountMaxSlippage: z2.string({
1605
- description: "Expected Buy amount max slippage"
1606
- }),
1607
- sourceAddress: z2.string({
1608
- description: "Source address"
1609
- }),
1610
- destinationAddress: z2.string({
1611
- description: "Destination address"
1612
- }),
1613
- targetAddress: z2.optional(z2.string({
1614
- description: "Target address"
1615
- })),
1616
- expiration: z2.optional(z2.string({
1617
- description: "Expiration"
1618
- })),
1619
- memo: z2.optional(z2.string({
1620
- description: "Memo"
1621
- })),
1622
- evmTransactionDetails: z2.optional(EVMTransactionDetailsSchema),
1623
- estimatedTime: z2.optional(EstimatedTimeSchema),
1624
- totalSlippageBps: z2.number({
1625
- description: "Total slippage in bps"
1626
- }),
1627
- legs: z2.array(QuoteResponseRouteLegItem),
1628
- warnings: RouteQuoteWarningSchema,
1629
- meta: RouteQuoteMetadataSchema
1630
- });
1631
- var QuoteResponseSchema = z2.object({
1632
- quoteId: z2.string({
1633
- description: "Quote ID"
1634
- }),
1635
- routes: z2.array(QuoteResponseRouteItem),
1636
- error: z2.optional(z2.string({
1637
- description: "Error message"
1638
- }))
1639
- });
1640
- // src/helpers/validators.ts
1641
- function validateIdentifier(identifier = "") {
1642
- const uppercasedIdentifier = identifier.toUpperCase();
1643
- const [chain] = uppercasedIdentifier.split(".");
1644
- if (supportedChains.includes(chain))
1645
- return true;
1646
- const [synthChain] = uppercasedIdentifier.split("/");
1647
- if (supportedChains.includes(synthChain))
1648
- return true;
1649
- throw new Error(`Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`);
1650
- }
1651
- function validateTNS(name) {
1652
- if (name.length > 30)
1653
- return false;
1654
- const regex = /^[a-zA-Z0-9+_-]+$/g;
1655
- return !!name.match(regex);
1656
- }
1657
- var supportedChains = [...Object.values(Chain), "TERRA"];
1658
-
1659
- // src/modules/bigIntArithmetics.ts
1660
- function formatBigIntToSafeValue({
1661
- value,
1662
- bigIntDecimal = DEFAULT_DECIMAL,
1663
- decimal = DEFAULT_DECIMAL
1664
- }) {
1665
- if (decimal === 0)
1666
- return value.toString();
1667
- const isNegative = value < 0n;
1668
- let valueString = value.toString().substring(isNegative ? 1 : 0);
1669
- const padLength = decimal - (valueString.length - 1);
1670
- if (padLength > 0) {
1671
- valueString = "0".repeat(padLength) + valueString;
1672
- }
1673
- const decimalIndex = valueString.length - decimal;
1674
- let decimalString = valueString.slice(-decimal);
1675
- if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
1676
- decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
1677
- } else {
1678
- decimalString = decimalString.substring(0, bigIntDecimal);
1679
- }
1680
- return `${isNegative ? "-" : ""}${valueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
1681
- }
1682
- var toSafeValue = function(value) {
1683
- const parsedValue = typeof value === "number" ? numberFormatter.format(value) : getStringValue(value);
1684
- const splitValue = `${parsedValue}`.replaceAll(",", ".").split(".");
1685
- return splitValue.length > 1 ? `${splitValue.slice(0, -1).join("")}.${splitValue.at(-1)}` : splitValue[0] || "0";
1686
- };
1687
- var getFloatDecimals = function(value) {
1688
- const decimals = value.split(".")[1]?.length || 0;
1689
- return Math.max(decimals, DEFAULT_DECIMAL);
1690
- };
1691
- var getStringValue = function(param) {
1692
- return typeof param === "object" ? "getValue" in param ? param.getValue("string") : param.value : param;
1693
- };
1694
- var DEFAULT_DECIMAL = 8;
1695
- var toMultiplier = (decimal) => 10n ** BigInt(decimal);
1696
- var decimalFromMultiplier = (multiplier) => Math.log10(Number.parseFloat(multiplier.toString()));
1697
-
1698
- class BigIntArithmetics {
1699
- decimalMultiplier = 10n ** 8n;
1700
- bigIntValue = 0n;
1701
- decimal;
1702
- static fromBigInt(value, decimal) {
1703
- return new BigIntArithmetics({
1704
- decimal,
1705
- value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
1706
- });
1707
- }
1708
- static shiftDecimals({
1709
- value,
1710
- from,
1711
- to
1712
- }) {
1713
- return BigIntArithmetics.fromBigInt(value.getBaseValue("bigint") * toMultiplier(to) / toMultiplier(from), to);
1714
- }
1715
- constructor(params) {
1716
- const value = getStringValue(params);
1717
- const isComplex = typeof params === "object";
1718
- this.decimal = isComplex ? params.decimal : undefined;
1719
- this.decimalMultiplier = isComplex && "decimalMultiplier" in params ? params.decimalMultiplier : toMultiplier(Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0));
1720
- this.#setValue(value);
1721
- }
1722
- set(value) {
1723
- return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });
1724
- }
1725
- add(...args) {
1726
- return this.#arithmetics("add", ...args);
1727
- }
1728
- sub(...args) {
1729
- return this.#arithmetics("sub", ...args);
1730
- }
1731
- mul(...args) {
1732
- return this.#arithmetics("mul", ...args);
1733
- }
1734
- div(...args) {
1735
- return this.#arithmetics("div", ...args);
1736
- }
1737
- gt(value) {
1738
- return this.#comparison("gt", value);
1739
- }
1740
- gte(value) {
1741
- return this.#comparison("gte", value);
1742
- }
1743
- lt(value) {
1744
- return this.#comparison("lt", value);
1745
- }
1746
- lte(value) {
1747
- return this.#comparison("lte", value);
1748
- }
1749
- eqValue(value) {
1750
- return this.#comparison("eqValue", value);
1751
- }
1752
- getValue(type) {
1753
- const value = this.formatBigIntToSafeValue(this.bigIntValue, this.decimal || decimalFromMultiplier(this.decimalMultiplier));
1754
- switch (type) {
1755
- case "number":
1756
- return Number(value);
1757
- case "string":
1758
- return value;
1759
- case "bigint":
1760
- return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
1761
- }
1762
- }
1763
- getBaseValue(type) {
1764
- const divisor = this.decimalMultiplier / toMultiplier(this.decimal || BaseDecimal.THOR);
1765
- const baseValue = this.bigIntValue / divisor;
1766
- switch (type) {
1767
- case "number":
1768
- return Number(baseValue);
1769
- case "string":
1770
- return baseValue.toString();
1771
- case "bigint":
1772
- return baseValue;
1773
- }
1774
- }
1775
- getBigIntValue(value, decimal) {
1776
- if (!decimal && typeof value === "object")
1777
- return value.bigIntValue;
1778
- const stringValue = getStringValue(value);
1779
- const safeValue = toSafeValue(stringValue);
1780
- if (safeValue === "0" || safeValue === "undefined")
1781
- return 0n;
1782
- return this.#toBigInt(safeValue, decimal);
1783
- }
1784
- toSignificant(significantDigits = 6) {
1785
- const [int, dec] = this.getValue("string").split(".");
1786
- const integer = int || "";
1787
- const decimal = dec || "";
1788
- const valueLength = Number.parseInt(integer) ? integer.length + decimal.length : decimal.length;
1789
- if (valueLength <= significantDigits) {
1790
- return this.getValue("string");
1791
- }
1792
- if (integer.length >= significantDigits) {
1793
- return integer.slice(0, significantDigits).padEnd(integer.length, "0");
1794
- }
1795
- if (Number.parseInt(integer)) {
1796
- return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(significantDigits - integer.length, "0");
1797
- }
1798
- const trimmedDecimal = Number.parseInt(decimal);
1799
- const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);
1800
- return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
1801
- }
1802
- toFixed(fixedDigits = 6) {
1803
- const [int, dec] = this.getValue("string").split(".");
1804
- const integer = int || "";
1805
- const decimal = dec || "";
1806
- if (Number.parseInt(integer)) {
1807
- return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, "0");
1808
- }
1809
- const trimmedDecimal = Number.parseInt(decimal);
1810
- const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);
1811
- return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
1812
- }
1813
- toAbbreviation(digits = 2) {
1814
- const value = this.getValue("number");
1815
- const abbreviations = ["", "K", "M", "B", "T", "Q", "Qi", "S"];
1816
- const tier = Math.floor(Math.log10(Math.abs(value)) / 3);
1817
- const suffix = abbreviations[tier];
1818
- if (!suffix)
1819
- return this.getValue("string");
1820
- const scale = 10 ** (tier * 3);
1821
- const scaled = value / scale;
1822
- return `${scaled.toFixed(digits)}${suffix}`;
1823
- }
1824
- toCurrency(currency = "$", {
1825
- currencyPosition = "start",
1826
- decimal = 2,
1827
- decimalSeparator = ".",
1828
- thousandSeparator = ","
1829
- } = {}) {
1830
- const value = this.getValue("number");
1831
- const [int = "", dec = ""] = value.toFixed(6).split(".");
1832
- const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
1833
- const parsedValue = int || dec ? int === "0" ? `${Number.parseFloat(`0.${dec}`)}`.replace(".", decimalSeparator) : `${integer}${Number.parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ""}` : "0.00";
1834
- return `${currencyPosition === "start" ? currency : ""}${parsedValue}${currencyPosition === "end" ? currency : ""}`;
1835
- }
1836
- formatBigIntToSafeValue(value, decimal) {
1837
- const bigIntDecimal = decimal || this.decimal || DEFAULT_DECIMAL;
1838
- const decimalToUseForConversion = Math.max(bigIntDecimal, decimalFromMultiplier(this.decimalMultiplier));
1839
- const isNegative = value < 0n;
1840
- const valueString = value.toString().substring(isNegative ? 1 : 0);
1841
- const padLength = decimalToUseForConversion - (valueString.length - 1);
1842
- const parsedValueString = padLength > 0 ? "0".repeat(padLength) + valueString : valueString;
1843
- const decimalIndex = parsedValueString.length - decimalToUseForConversion;
1844
- let decimalString = parsedValueString.slice(-decimalToUseForConversion);
1845
- if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
1846
- decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
1847
- } else {
1848
- decimalString = decimalString.substring(0, bigIntDecimal);
1849
- }
1850
- return `${isNegative ? "-" : ""}${parsedValueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
1851
- }
1852
- #arithmetics(method, ...args) {
1853
- const precisionDecimal = this.#retrievePrecisionDecimal(this, ...args);
1854
- const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
1855
- const precisionDecimalMultiplier = toMultiplier(decimal);
1856
- const result = args.reduce((acc, arg) => {
1857
- const value2 = this.getBigIntValue(arg, decimal);
1858
- switch (method) {
1859
- case "add":
1860
- return acc + value2;
1861
- case "sub":
1862
- return acc - value2;
1863
- case "mul":
1864
- return acc * value2 / precisionDecimalMultiplier;
1865
- case "div": {
1866
- if (value2 === 0n)
1867
- throw new RangeError("Division by zero");
1868
- return acc * precisionDecimalMultiplier / value2;
1869
- }
1870
- default:
1871
- return acc;
1872
- }
1873
- }, this.bigIntValue * precisionDecimalMultiplier / this.decimalMultiplier);
1874
- const value = formatBigIntToSafeValue({
1875
- bigIntDecimal: decimal,
1876
- decimal,
1877
- value: result
1878
- });
1879
- return new this.constructor({
1880
- decimalMultiplier: toMultiplier(decimal),
1881
- decimal: this.decimal,
1882
- value,
1883
- identifier: this.toString()
1884
- });
1885
- }
1886
- #comparison(method, ...args) {
1887
- const decimal = this.#retrievePrecisionDecimal(this, ...args);
1888
- const value = this.getBigIntValue(args[0] || "0", decimal);
1889
- const compareToValue = this.getBigIntValue(this, decimal);
1890
- switch (method) {
1891
- case "gt":
1892
- return compareToValue > value;
1893
- case "gte":
1894
- return compareToValue >= value;
1895
- case "lt":
1896
- return compareToValue < value;
1897
- case "lte":
1898
- return compareToValue <= value;
1899
- case "eqValue":
1900
- return compareToValue === value;
1901
- }
1902
- }
1903
- #setValue(value) {
1904
- const safeValue = toSafeValue(value) || "0";
1905
- this.bigIntValue = this.#toBigInt(safeValue);
1906
- }
1907
- #retrievePrecisionDecimal(...args) {
1908
- const decimals = args.map((arg) => {
1909
- const isObject = typeof arg === "object";
1910
- const value = isObject ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier) : getFloatDecimals(toSafeValue(arg));
1911
- return value;
1912
- }).filter(Boolean);
1913
- return Math.max(...decimals, DEFAULT_DECIMAL);
1914
- }
1915
- #toBigInt(value, decimal) {
1916
- const multiplier = decimal ? toMultiplier(decimal) : this.decimalMultiplier;
1917
- const padDecimal = decimalFromMultiplier(multiplier);
1918
- const [integerPart = "", decimalPart = ""] = value.split(".");
1919
- return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, "0")}`);
1920
- }
1921
- }
1922
- var numberFormatter = Intl.NumberFormat("fullwide", {
1923
- useGrouping: false,
1924
- maximumFractionDigits: 20
1925
- });
1926
-
1927
- // src/modules/swapKitNumber.ts
1928
- class SwapKitNumber extends BigIntArithmetics {
1929
- eq(value) {
1930
- return this.eqValue(value);
1931
- }
1932
- static fromBigInt(value, decimal) {
1933
- return new SwapKitNumber({
1934
- decimal,
1935
- value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
1936
- });
1937
- }
1938
- }
1939
-
1940
- // src/modules/assetValue.ts
1941
- function getMinAmountByChain(chain) {
1942
- const asset2 = AssetValue.fromChainOrSignature(chain);
1943
- switch (chain) {
1944
- case Chain.Bitcoin:
1945
- case Chain.Litecoin:
1946
- case Chain.BitcoinCash:
1947
- return asset2.set(0.00010001);
1948
- case Chain.Dogecoin:
1949
- return asset2.set(1.00000001);
1950
- case Chain.Avalanche:
1951
- case Chain.Ethereum:
1952
- return asset2.set(0.00000001);
1953
- case Chain.THORChain:
1954
- case Chain.Maya:
1955
- return asset2.set(0);
1956
- case Chain.Cosmos:
1957
- return asset2.set(0.000001);
1958
- default:
1959
- return asset2.set(0.00000001);
1960
- }
1961
- }
1962
- async function createAssetValue(identifier, value = 0) {
1963
- validateIdentifier(identifier);
1964
- const staticToken = staticTokensMap.get(identifier.toUpperCase());
1965
- const decimal = staticToken?.decimal || await getDecimal(getAssetInfo(identifier));
1966
- if (!staticToken) {
1967
- staticTokensMap.set(identifier.toUpperCase(), { identifier, decimal });
1968
- }
1969
- return new AssetValue({ decimal, value: safeValue(value, decimal), identifier });
1970
- }
1971
- var createSyntheticAssetValue = function(identifier, value = 0) {
1972
- const [synthChain, symbol] = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
1973
- if (!(synthChain && symbol))
1974
- throw new Error("Invalid asset identifier");
1975
- return new AssetValue({
1976
- decimal: 8,
1977
- value: safeValue(value, 8),
1978
- identifier: `${Chain.THORChain}.${synthChain}/${symbol}`
1979
- });
1980
- };
1981
- var safeValue = function(value, decimal) {
1982
- return typeof value === "bigint" ? formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }) : value;
1983
- };
1984
- var getAssetInfo = function(identifier) {
1985
- const isSynthetic = identifier.slice(0, 14).includes("/");
1986
- const isThorchain = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain;
1987
- const isMaya = identifier.split(".")?.[0]?.toUpperCase() === Chain.Maya;
1988
- const [synthChain, synthSymbol = ""] = isThorchain || isMaya ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
1989
- if (isSynthetic && !(synthChain && synthSymbol))
1990
- throw new Error("Invalid asset identifier");
1991
- const adjustedIdentifier = identifier.includes(".") && !isSynthetic ? identifier : `${isMaya ? Chain.Maya : Chain.THORChain}.${synthSymbol}`;
1992
- const [chain, ...rest] = adjustedIdentifier.split(".");
1993
- const symbol = isSynthetic ? synthSymbol : rest.join(".");
1994
- const splitSymbol = symbol.split("-");
1995
- const ticker = splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-");
1996
- const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
1997
- return {
1998
- address: address?.toLowerCase(),
1999
- chain,
2000
- isGasAsset: isGasAsset({ chain, symbol }),
2001
- isSynthetic,
2002
- symbol: (isSynthetic ? `${synthChain}/` : "") + (address ? `${ticker}-${address?.toLowerCase() ?? ""}` : symbol),
2003
- ticker
2004
- };
2005
- };
2006
- var staticTokensMap = new Map;
2007
-
2008
- class AssetValue extends BigIntArithmetics {
2009
- address;
2010
- chain;
2011
- isGasAsset = false;
2012
- isSynthetic = false;
2013
- symbol;
2014
- tax;
2015
- ticker;
2016
- type;
2017
- chainId;
2018
- constructor({
2019
- value,
2020
- decimal,
2021
- tax,
2022
- chain,
2023
- symbol,
2024
- identifier
2025
- }) {
2026
- super(typeof value === "object" ? value : { decimal, value });
2027
- const assetInfo = getAssetInfo(identifier || `${chain}.${symbol}`);
2028
- this.type = getAssetType(assetInfo);
2029
- this.tax = tax;
2030
- this.chain = assetInfo.chain;
2031
- this.ticker = assetInfo.ticker;
2032
- this.symbol = assetInfo.symbol;
2033
- this.address = assetInfo.address;
2034
- this.isSynthetic = assetInfo.isSynthetic;
2035
- this.isGasAsset = assetInfo.isGasAsset;
2036
- this.chainId = ChainToChainId[assetInfo.chain];
2037
- }
2038
- toString() {
2039
- return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
2040
- }
2041
- toUrl() {
2042
- return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
2043
- }
2044
- eqAsset({ chain, symbol }) {
2045
- return this.chain === chain && this.symbol === symbol;
2046
- }
2047
- eq(assetValue) {
2048
- return this.eqAsset(assetValue) && this.eqValue(assetValue);
2049
- }
2050
- static fromUrl(urlAsset, value = 0) {
2051
- const [chain, ticker, symbol] = urlAsset.split(".");
2052
- if (!(chain && ticker))
2053
- throw new Error("Invalid asset url");
2054
- const assetString = chain === Chain.THORChain && symbol ? `${chain}.${ticker}/${symbol}` : urlAsset;
2055
- return createAssetValue(assetString, value);
2056
- }
2057
- static fromString(assetString, value = 0) {
2058
- return createAssetValue(assetString, value);
2059
- }
2060
- static fromIdentifier(assetString, value = 0) {
2061
- return createAssetValue(assetString, value);
2062
- }
2063
- static fromStringSync(assetString, value = 0) {
2064
- const { chain, isSynthetic } = getAssetInfo(assetString);
2065
- const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
2066
- if (isSynthetic)
2067
- return createSyntheticAssetValue(assetString, value);
2068
- const { tax, decimal, identifier } = tokenInfo || {
2069
- decimal: BaseDecimal[chain],
2070
- identifier: assetString
2071
- };
2072
- return new AssetValue({
2073
- tax,
2074
- value: safeValue(value, decimal),
2075
- identifier: isSynthetic ? assetString : identifier,
2076
- decimal: isSynthetic ? 8 : decimal
2077
- });
2078
- }
2079
- static async fromStringWithBase(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
2080
- const shiftedAmount = BigIntArithmetics.shiftDecimals({
2081
- value: SwapKitNumber.fromBigInt(BigInt(value)),
2082
- from: 0,
2083
- to: baseDecimal
2084
- }).getBaseValue("string");
2085
- const assetValue = await AssetValue.fromString(assetString, value);
2086
- return assetValue.set(shiftedAmount);
2087
- }
2088
- static fromStringWithBaseSync(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
2089
- const { chain, isSynthetic } = getAssetInfo(assetString);
2090
- const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
2091
- if (isSynthetic)
2092
- return createSyntheticAssetValue(assetString, value);
2093
- const { tax, decimal, identifier } = tokenInfo || {
2094
- decimal: BaseDecimal[chain],
2095
- identifier: assetString
2096
- };
2097
- return new AssetValue({
2098
- tax,
2099
- value: safeValue(BigInt(value), baseDecimal),
2100
- identifier,
2101
- decimal
2102
- });
2103
- }
2104
- static fromIdentifierSync(assetString, value = 0) {
2105
- const { chain, isSynthetic } = getAssetInfo(assetString);
2106
- const tokenInfo = staticTokensMap.get(assetString);
2107
- if (isSynthetic)
2108
- return createSyntheticAssetValue(assetString, value);
2109
- const { tax, decimal, identifier } = tokenInfo || {
2110
- decimal: BaseDecimal[chain],
2111
- identifier: assetString
2112
- };
2113
- return new AssetValue({ tax, decimal, identifier, value: safeValue(value, decimal) });
2114
- }
2115
- static fromChainOrSignature(assetString, value = 0) {
2116
- const { decimal, identifier } = getCommonAssetInfo(assetString);
2117
- return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });
2118
- }
2119
- static loadStaticAssets() {
2120
- return new Promise((resolve, reject) => {
2121
- try {
2122
- import("@swapkit/tokens").then((tokenPackages) => {
2123
- for (const tokenList of Object.values(tokenPackages)) {
2124
- for (const { identifier, chain, ...rest } of tokenList.tokens) {
2125
- staticTokensMap.set(identifier.toUpperCase(), {
2126
- identifier,
2127
- decimal: "decimals" in rest ? rest.decimals : BaseDecimal[chain]
2128
- });
2129
- }
2130
- }
2131
- resolve({ ok: true });
2132
- });
2133
- } catch (error) {
2134
- console.error(error);
2135
- reject({
2136
- ok: false,
2137
- error,
2138
- message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
2139
- });
2140
- }
2141
- });
2142
- }
2143
- }
2144
-
2145
- // src/modules/requestClient.ts
2146
- import ky from "ky";
2147
- function setRequestClientConfig({ apiKey, ...config }) {
2148
- kyClientConfig = { ...config, apiKey };
2149
- }
2150
- var getKyClient = function() {
2151
- const { apiKey, ...config } = kyClientConfig;
2152
- return ky.create({
2153
- ...config,
2154
- headers: { ...defaultRequestHeaders, ...config.headers, "x-api-key": apiKey }
2155
- });
2156
- };
2157
- var kyClientConfig = {};
2158
- var defaultRequestHeaders = typeof window !== "undefined" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" };
2159
- var getTypedBaseRequestClient = (ky2) => ({
2160
- get: async (url, options) => (await ky2.get(url, options)).json(),
2161
- post: async (url, options) => (await ky2.post(url, options)).json()
2162
- });
2163
- var RequestClient = {
2164
- ...getTypedBaseRequestClient(getKyClient()),
2165
- extend: (options) => {
2166
- const extendedClient = getKyClient().extend(options);
2167
- return {
2168
- ...getTypedBaseRequestClient(extendedClient),
2169
- extend: RequestClient.extend
2170
- };
2171
- }
2172
- };
2173
-
2174
- // src/helpers/asset.ts
2175
- async function findAssetBy(params) {
2176
- const tokenPackages = await import("@swapkit/tokens");
2177
- for (const tokenList of Object.values(tokenPackages)) {
2178
- for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) {
2179
- if ("identifier" in params && identifier === params.identifier) {
2180
- return identifier;
2181
- }
2182
- if ("address" in rest && "chain" in params && tokenChain === params.chain && rest.address.toLowerCase() === params.contract.toLowerCase())
2183
- return identifier;
2184
- }
2185
- }
2186
- return;
2187
- }
2188
- var getDecimalMethodHex = "0x313ce567";
2189
- var getContractDecimals = async ({ chain, to }) => {
2190
- try {
2191
- const { result } = await RequestClient.post(ChainToRPC[chain], {
2192
- headers: {
2193
- accept: "*/*",
2194
- "content-type": "application/json",
2195
- "cache-control": "no-cache"
2196
- },
2197
- body: JSON.stringify({
2198
- id: 44,
2199
- jsonrpc: "2.0",
2200
- method: "eth_call",
2201
- params: [{ to: to.toLowerCase(), data: getDecimalMethodHex }, "latest"]
2202
- })
2203
- });
2204
- return Number.parseInt(BigInt(result || BaseDecimal[chain]).toString());
2205
- } catch (error) {
2206
- console.error(error);
2207
- return BaseDecimal[chain];
2208
- }
2209
- };
2210
- var getRadixResourceDecimals = async ({ symbol }) => {
2211
- try {
2212
- const resourceAddress = symbol.split("-")[1]?.toLowerCase();
2213
- const { manager } = await RequestClient.post(`${ChainToRPC[Chain.Radix]}/state/resource`, {
2214
- headers: {
2215
- Accept: "*/*",
2216
- "Content-Type": "application/json"
2217
- },
2218
- body: JSON.stringify({
2219
- network: "mainnet",
2220
- resource_address: resourceAddress
2221
- })
2222
- });
2223
- return manager.divisibility.value.divisibility;
2224
- } catch (error) {
2225
- console.error(error);
2226
- return BaseDecimal[Chain.Radix];
2227
- }
2228
- };
2229
- var getETHAssetDecimal = (symbol) => {
2230
- if (symbol === Chain.Ethereum)
2231
- return BaseDecimal.ETH;
2232
- const splitSymbol = symbol.split("-");
2233
- const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1]?.toLowerCase();
2234
- return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Ethereum, to: address }) : BaseDecimal.ETH;
2235
- };
2236
- var getAVAXAssetDecimal = (symbol) => {
2237
- const splitSymbol = symbol.split("-");
2238
- const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
2239
- return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Avalanche, to: address.toLowerCase() }) : BaseDecimal.AVAX;
2240
- };
2241
- var getBSCAssetDecimal = (symbol) => {
2242
- if (symbol === Chain.BinanceSmartChain)
2243
- return BaseDecimal.BSC;
2244
- return BaseDecimal.BSC;
2245
- };
2246
- var getRadixAssetDecimal = (symbol) => {
2247
- if (symbol === Chain.Radix)
2248
- return BaseDecimal.XRD;
2249
- return getRadixResourceDecimals({ symbol });
2250
- };
2251
- var getDecimal = ({ chain, symbol }) => {
2252
- switch (chain) {
2253
- case Chain.Ethereum:
2254
- return getETHAssetDecimal(symbol);
2255
- case Chain.Avalanche:
2256
- return getAVAXAssetDecimal(symbol);
2257
- case Chain.BinanceSmartChain:
2258
- return getBSCAssetDecimal(symbol);
2259
- case Chain.Radix:
2260
- return getRadixAssetDecimal(symbol);
2261
- default:
2262
- return BaseDecimal[chain];
2263
- }
2264
- };
2265
- var getGasAsset = ({ chain }) => {
2266
- switch (chain) {
2267
- case Chain.Arbitrum:
2268
- case Chain.Optimism:
2269
- return AssetValue.fromStringSync(`${chain}.ETH`);
2270
- case Chain.Maya:
2271
- return AssetValue.fromStringSync(`${chain}.CACAO`);
2272
- case Chain.Cosmos:
2273
- return AssetValue.fromStringSync(`${chain}.ATOM`);
2274
- case Chain.BinanceSmartChain:
2275
- return AssetValue.fromStringSync(`${chain}.BNB`);
2276
- case Chain.THORChain:
2277
- return AssetValue.fromStringSync(`${chain}.RUNE`);
2278
- default:
2279
- return AssetValue.fromStringSync(`${chain}.${chain}`);
2280
- }
2281
- };
2282
- var isGasAsset = ({ chain, symbol }) => {
2283
- switch (chain) {
2284
- case Chain.Arbitrum:
2285
- case Chain.Optimism:
2286
- return symbol === "ETH";
2287
- case Chain.Maya:
2288
- return symbol === "CACAO";
2289
- case Chain.Cosmos:
2290
- return symbol === "ATOM";
2291
- case Chain.BinanceSmartChain:
2292
- return symbol === "BNB";
2293
- case Chain.THORChain:
2294
- return symbol === "RUNE";
2295
- default:
2296
- return symbol === chain;
2297
- }
2298
- };
2299
- var getCommonAssetInfo = (assetString) => {
2300
- switch (assetString) {
2301
- case `${Chain.Ethereum}.THOR`:
2302
- return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
2303
- case `${Chain.Ethereum}.vTHOR`:
2304
- return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
2305
- case Chain.Arbitrum:
2306
- return { identifier: `${Chain.Arbitrum}.ETH`, decimal: BaseDecimal[assetString] };
2307
- case Chain.Optimism:
2308
- return { identifier: `${Chain.Optimism}.ETH`, decimal: BaseDecimal[assetString] };
2309
- case Chain.Cosmos:
2310
- return { identifier: "GAIA.ATOM", decimal: BaseDecimal[assetString] };
2311
- case Chain.THORChain:
2312
- return { identifier: "THOR.RUNE", decimal: BaseDecimal[assetString] };
2313
- case Chain.BinanceSmartChain:
2314
- return { identifier: "BSC.BNB", decimal: BaseDecimal[assetString] };
2315
- case Chain.Maya:
2316
- return { identifier: "MAYA.CACAO", decimal: BaseDecimal.MAYA };
2317
- case `${Chain.Maya}.MAYA`:
2318
- return { identifier: "MAYA.MAYA", decimal: 4 };
2319
- case `${Chain.Kujira}.USK`:
2320
- return { identifier: `${Chain.Kujira}.USK`, decimal: 6 };
2321
- case Chain.Radix:
2322
- return { identifier: `${Chain.Radix}.XRD`, decimal: BaseDecimal.XRD };
2323
- default:
2324
- return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };
2325
- }
2326
- };
2327
- var getAssetType = ({ chain, symbol }) => {
2328
- if (symbol.includes("/"))
2329
- return "Synth";
2330
- switch (chain) {
2331
- case Chain.Cosmos:
2332
- return symbol === "ATOM" ? "Native" : Chain.Cosmos;
2333
- case Chain.Kujira:
2334
- return symbol === Chain.Kujira ? "Native" : Chain.Kujira;
2335
- case Chain.Binance:
2336
- return symbol === Chain.Binance ? "Native" : "BEP2";
2337
- case Chain.BinanceSmartChain:
2338
- return symbol === Chain.Binance ? "Native" : "BEP20";
2339
- case Chain.Ethereum:
2340
- return symbol === Chain.Ethereum ? "Native" : "ERC20";
2341
- case Chain.Avalanche:
2342
- return symbol === Chain.Avalanche ? "Native" : Chain.Avalanche;
2343
- case Chain.Polygon:
2344
- return symbol === Chain.Polygon ? "Native" : "POLYGON";
2345
- case Chain.Arbitrum:
2346
- return [Chain.Ethereum, Chain.Arbitrum].includes(symbol) ? "Native" : "ARBITRUM";
2347
- case Chain.Optimism:
2348
- return [Chain.Ethereum, Chain.Optimism].includes(symbol) ? "Native" : "OPTIMISM";
2349
- case Chain.Radix:
2350
- return symbol === Chain.Radix ? "Native" : "RADIX";
2351
- default:
2352
- return "Native";
2353
- }
2354
- };
2355
- var assetFromString = (assetString) => {
2356
- const [chain, ...symbolArray] = assetString.split(".");
2357
- const synth = assetString.includes("/");
2358
- const symbol = symbolArray.join(".");
2359
- const splitSymbol = symbol?.split("-");
2360
- const ticker = splitSymbol?.length ? splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-") : undefined;
2361
- return { chain, symbol, ticker, synth };
2362
- };
2363
- var potentialScamRegex = new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, "gmi");
2364
- var evmAssetHasAddress = (assetString) => {
2365
- const [chain, symbol] = assetString.split(".");
2366
- if (!EVMChains.includes(chain))
2367
- return true;
2368
- const splitSymbol = symbol.split("-");
2369
- const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
2370
- return isGasAsset({ chain, symbol }) || !!address;
2371
- };
2372
- var filterAssets = (tokens2) => tokens2.filter(({ chain, value, symbol }) => {
2373
- const assetString = `${chain}.${symbol}`;
2374
- return !potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== "0";
2375
- });
2376
- // src/helpers/derivationPath.ts
2377
- function getDerivationPathFor({ chain, index, addressIndex = 0, type }) {
2378
- if (EVMChains.includes(chain)) {
2379
- if (type === "legacy")
2380
- return [44, 60, 0, index];
2381
- if (type === "ledgerLive")
2382
- return [44, 60, index, 0, addressIndex];
2383
- return updatedLastIndex(NetworkDerivationPath[chain], index);
2384
- }
2385
- if ([Chain.Bitcoin, Chain.Litecoin].includes(chain)) {
2386
- const chainId = chain === Chain.Bitcoin ? 0 : 2;
2387
- if (type === "nativeSegwitMiddleAccount")
2388
- return [84, chainId, index, 0, addressIndex];
2389
- if (type === "segwit")
2390
- return [49, chainId, 0, 0, index];
2391
- if (type === "legacy")
2392
- return [44, chainId, 0, 0, index];
2393
- return updatedLastIndex(NetworkDerivationPath[chain], index);
2394
- }
2395
- return updatedLastIndex(NetworkDerivationPath[chain], index);
2396
- }
2397
- function getWalletFormatFor(path) {
2398
- const [_, purpose, chainId] = path.split("/").map((p) => Number.parseInt(p, 10));
2399
- if (chainId === 145)
2400
- ;
2401
- switch (purpose) {
2402
- case 44:
2403
- return "legacy";
2404
- case 49:
2405
- return "p2sh";
2406
- default:
2407
- return "bech32";
2408
- }
2409
- }
2410
- var updatedLastIndex = (path, index) => [
2411
- ...path.slice(0, path.length - 1),
2412
- index
2413
- ];
2414
- // src/helpers/liquidity.ts
2415
- function getAsymmetricRuneShare({
2416
- liquidityUnits,
2417
- poolUnits,
2418
- runeDepth
2419
- }) {
2420
- const s = toTCSwapKitNumber(liquidityUnits);
2421
- const T = toTCSwapKitNumber(poolUnits);
2422
- const A = toTCSwapKitNumber(runeDepth);
2423
- const part1 = s.mul(A);
2424
- const part2 = T.mul(T).mul(2);
2425
- const part3 = T.mul(s).mul(2);
2426
- const part4 = s.mul(s);
2427
- const part5 = T.mul(T).mul(T);
2428
- const numerator = part1.mul(part2.sub(part3).add(part4));
2429
- return numerator.div(part5);
2430
- }
2431
- function getAsymmetricAssetShare({
2432
- liquidityUnits,
2433
- poolUnits,
2434
- assetDepth
2435
- }) {
2436
- const s = toTCSwapKitNumber(liquidityUnits);
2437
- const T = toTCSwapKitNumber(poolUnits);
2438
- const A = toTCSwapKitNumber(assetDepth);
2439
- const part1 = s.mul(A);
2440
- const part2 = T.mul(T).mul(2);
2441
- const part3 = T.mul(s).mul(2);
2442
- const part4 = s.mul(s);
2443
- const numerator = part1.mul(part2.sub(part3).add(part4));
2444
- const part5 = T.mul(T).mul(T);
2445
- return numerator.div(part5);
2446
- }
2447
- function getAsymmetricRuneWithdrawAmount({
2448
- percent,
2449
- runeDepth,
2450
- liquidityUnits,
2451
- poolUnits
2452
- }) {
2453
- return getAsymmetricRuneShare({ runeDepth, liquidityUnits, poolUnits }).mul(percent);
2454
- }
2455
- function getAsymmetricAssetWithdrawAmount({
2456
- percent,
2457
- assetDepth,
2458
- liquidityUnits,
2459
- poolUnits
2460
- }) {
2461
- return getAsymmetricAssetShare({ assetDepth, liquidityUnits, poolUnits }).mul(percent);
2462
- }
2463
- var toTCSwapKitNumber = function(value) {
2464
- return SwapKitNumber.fromBigInt(BigInt(value), BaseDecimal.THOR);
2465
- };
2466
- function getSymmetricPoolShare({
2467
- liquidityUnits,
2468
- poolUnits,
2469
- runeDepth,
2470
- assetDepth
2471
- }) {
2472
- return {
2473
- assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),
2474
- runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits)
2475
- };
2476
- }
2477
- function getSymmetricWithdraw({
2478
- liquidityUnits,
2479
- poolUnits,
2480
- runeDepth,
2481
- assetDepth,
2482
- percent
2483
- }) {
2484
- return Object.fromEntries(Object.entries(getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth })).map(([name, value]) => [name, value.mul(percent)]));
2485
- }
2486
- function getEstimatedPoolShare({
2487
- runeDepth,
2488
- poolUnits,
2489
- assetDepth,
2490
- liquidityUnits,
2491
- runeAmount,
2492
- assetAmount
2493
- }) {
2494
- const R = new SwapKitNumber({ value: runeDepth, decimal: 8 });
2495
- const A = new SwapKitNumber({ value: assetDepth, decimal: 8 });
2496
- const P = new SwapKitNumber({ value: poolUnits, decimal: 8 });
2497
- const runeAddAmount = new SwapKitNumber({ value: runeAmount, decimal: 8 });
2498
- const assetAddAmount = new SwapKitNumber({ value: assetAmount, decimal: 8 });
2499
- const rA = runeAddAmount.mul(A);
2500
- const aR = assetAddAmount.mul(R);
2501
- const ra = runeAddAmount.mul(assetAddAmount);
2502
- const RA = R.mul(A);
2503
- const numerator = P.mul(rA.add(aR.add(ra.mul(2))));
2504
- const denominator = rA.add(aR.add(RA.mul(2)));
2505
- const liquidityUnitsAfterAdd = numerator.div(denominator);
2506
- const estimatedLiquidityUnits = toTCSwapKitNumber(liquidityUnits).add(liquidityUnitsAfterAdd);
2507
- if (liquidityUnitsAfterAdd.getBaseValue("number") === 0) {
2508
- return estimatedLiquidityUnits.div(P).getBaseValue("number");
2509
- }
2510
- const newPoolUnits = P.add(estimatedLiquidityUnits);
2511
- return estimatedLiquidityUnits.div(newPoolUnits).getBaseValue("number");
2512
- }
2513
- function getLiquiditySlippage({
2514
- runeAmount,
2515
- assetAmount,
2516
- runeDepth,
2517
- assetDepth
2518
- }) {
2519
- if (runeAmount === "0" || assetAmount === "0" || runeDepth === "0" || assetDepth === "0")
2520
- return 0;
2521
- const R = toTCSwapKitNumber(runeDepth);
2522
- const T = toTCSwapKitNumber(assetDepth);
2523
- const assetAddAmount = toTCSwapKitNumber(assetAmount);
2524
- const runeAddAmount = toTCSwapKitNumber(runeAmount);
2525
- const numerator = assetAddAmount.mul(R).sub(T.mul(runeAddAmount));
2526
- const denominator = T.mul(runeAddAmount).add(R.mul(T));
2527
- return Math.abs(numerator.div(denominator).getBaseValue("number"));
2528
- }
2529
- // src/helpers/memo.ts
2530
- var getMemoFor = (memoType, options) => {
2531
- switch (memoType) {
2532
- case MemoType.LEAVE:
2533
- case MemoType.BOND: {
2534
- const { address } = options;
2535
- return `${memoType}:${address}`;
2536
- }
2537
- case MemoType.UNBOND: {
2538
- const { address, unbondAmount } = options;
2539
- return `${memoType}:${address}:${unbondAmount}`;
2540
- }
2541
- case MemoType.NAME_REGISTER: {
2542
- const { name, chain, address, owner } = options;
2543
- return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
2544
- }
2545
- case MemoType.DEPOSIT: {
2546
- const { chain, symbol, address, singleSide } = options;
2547
- const getPoolIdentifier = (chain2, symbol2) => {
2548
- switch (chain2) {
2549
- case Chain.Litecoin:
2550
- return "l";
2551
- case Chain.Dogecoin:
2552
- return "d";
2553
- case Chain.BitcoinCash:
2554
- return "c";
2555
- default:
2556
- return `${chain2}.${symbol2}`;
2557
- }
2558
- };
2559
- return singleSide ? `${memoType}:${chain}/${symbol}` : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || ""}`;
2560
- }
2561
- case MemoType.WITHDRAW: {
2562
- const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } = options;
2563
- const shortenedSymbol = chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
2564
- const target = !singleSide && targetAssetString ? `:${targetAssetString}` : "";
2565
- const assetDivider = singleSide ? "/" : ".";
2566
- return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
2567
- }
2568
- case MemoType.OPEN_LOAN:
2569
- case MemoType.CLOSE_LOAN: {
2570
- const { asset: asset2, address } = options;
2571
- return `${memoType}:${asset2}:${address}`;
2572
- }
2573
- default:
2574
- return "";
2575
- }
2576
- };
2577
- // src/modules/swapKitError.ts
2578
- var errorMessages = {
2579
- core_wallet_connection_not_found: 10001,
2580
- core_estimated_max_spendable_chain_not_supported: 10002,
2581
- core_extend_error: 10003,
2582
- core_inbound_data_not_found: 10004,
2583
- core_approve_asset_address_or_from_not_found: 10005,
2584
- core_plugin_not_found: 10006,
2585
- core_plugin_swap_not_found: 10007,
2586
- core_approve_asset_target_invalid: 10008,
2587
- core_chain_halted: 10099,
2588
- core_wallet_xdefi_not_installed: 10101,
2589
- core_wallet_evmwallet_not_installed: 10102,
2590
- core_wallet_walletconnect_not_installed: 10103,
2591
- core_wallet_keystore_not_installed: 10104,
2592
- core_wallet_ledger_not_installed: 10105,
2593
- core_wallet_trezor_not_installed: 10106,
2594
- core_wallet_keplr_not_installed: 10107,
2595
- core_wallet_okx_not_installed: 10108,
2596
- core_wallet_keepkey_not_installed: 10109,
2597
- core_wallet_talisman_not_installed: 10110,
2598
- core_wallet_not_keypair_wallet: 10111,
2599
- core_swap_invalid_params: 10200,
2600
- core_swap_route_not_complete: 10201,
2601
- core_swap_asset_not_recognized: 10202,
2602
- core_swap_contract_not_found: 10203,
2603
- core_swap_route_transaction_not_found: 10204,
2604
- core_swap_contract_not_supported: 10205,
2605
- core_swap_transaction_error: 10206,
2606
- core_swap_quote_mode_not_supported: 10207,
2607
- core_transaction_deposit_error: 10301,
2608
- core_transaction_create_liquidity_rune_error: 10302,
2609
- core_transaction_create_liquidity_asset_error: 10303,
2610
- core_transaction_create_liquidity_invalid_params: 10304,
2611
- core_transaction_add_liquidity_invalid_params: 10305,
2612
- core_transaction_add_liquidity_no_rune_address: 10306,
2613
- core_transaction_add_liquidity_rune_error: 10307,
2614
- core_transaction_add_liquidity_asset_error: 10308,
2615
- core_transaction_withdraw_error: 10309,
2616
- core_transaction_deposit_to_pool_error: 10310,
2617
- core_transaction_deposit_insufficient_funds_error: 10311,
2618
- core_transaction_deposit_gas_error: 10312,
2619
- core_transaction_invalid_sender_address: 10313,
2620
- core_transaction_deposit_server_error: 10314,
2621
- core_transaction_user_rejected: 10315,
2622
- core_transaction_create_liquidity_cacao_error: 10316,
2623
- core_transaction_add_liquidity_no_cacao_address: 10306,
2624
- core_transaction_add_liquidity_cacao_error: 10307,
2625
- wallet_ledger_connection_error: 20001,
2626
- wallet_ledger_connection_claimed: 20002,
2627
- wallet_ledger_get_address_error: 20003,
2628
- wallet_ledger_device_not_found: 20004,
2629
- wallet_ledger_device_locked: 20005,
2630
- chainflip_channel_error: 30001,
2631
- chainflip_broker_recipient_error: 30002,
2632
- api_v2_invalid_response: 40001,
2633
- helpers_number_different_decimals: 99101
2634
- };
2635
-
2636
- class SwapKitError extends Error {
2637
- constructor(errorKey, sourceError) {
2638
- if (sourceError) {
2639
- console.error(sourceError, {
2640
- stack: sourceError?.stack,
2641
- message: sourceError?.message
2642
- });
2643
- }
2644
- super(errorKey, {
2645
- cause: { code: errorMessages[errorKey], message: errorKey }
2646
- });
2647
- Object.setPrototypeOf(this, SwapKitError.prototype);
2648
- }
2649
- }
2650
-
2651
- // src/helpers/others.ts
2652
- function getTHORNameCost(numberOfYears) {
2653
- if (numberOfYears < 0)
2654
- throw new Error("Invalid number of years");
2655
- return 10 + numberOfYears;
2656
- }
2657
- function getMAYANameCost(numberOfYears) {
2658
- if (numberOfYears < 0)
2659
- throw new Error("Invalid number of year");
2660
- return Math.round((10 + numberOfYears * 1.0512) * 10000000000) / 10000000000;
2661
- }
2662
- function derivationPathToString([network3, chainId, account, change, index]) {
2663
- const shortPath = typeof index !== "number";
2664
- return `m/${network3}'/${chainId}'/${account}'/${change}${shortPath ? "" : `/${index}`}`;
2665
- }
2666
- function wrapWithThrow(fn, errorKey) {
2667
- try {
2668
- return fn();
2669
- } catch (error) {
2670
- if (errorKey) {
2671
- throw new SwapKitError(errorKey, error);
2672
- }
2673
- return console.error(error);
2674
- }
2675
- }
2676
- var getChainIdentifier = (chain) => {
2677
- switch (chain) {
2678
- case Chain.THORChain:
2679
- return `${chain}.RUNE`;
2680
- case Chain.Cosmos:
2681
- return `${chain}.ATOM`;
2682
- case Chain.BinanceSmartChain:
2683
- return `${chain}`;
2684
- default:
2685
- return `${chain}.${chain}`;
2686
- }
2687
- };
2688
- // src/helpers/web3wallets.ts
2689
- function getEIP6963Wallets() {
2690
- const providers = [];
2691
- function onAnnouncement(event) {
2692
- if (providers.map((p) => p.info.uuid).includes(event.detail.info.uuid))
2693
- return;
2694
- providers.push(event.detail);
2695
- }
2696
- window.addEventListener("eip6963:announceProvider", onAnnouncement);
2697
- window.dispatchEvent(new Event("eip6963:requestProvider"));
2698
- function removeEIP6963EventListener() {
2699
- window.removeEventListener("eip6963:announceProvider", onAnnouncement);
2700
- }
2701
- return { providers, removeEIP6963EventListener };
2702
- }
2703
- var methodsToWrap = [
2704
- "approve",
2705
- "approvedAmount",
2706
- "call",
2707
- "sendTransaction",
2708
- "transfer",
2709
- "isApproved",
2710
- "approvedAmount",
2711
- "EIP1193SendTransaction",
2712
- "getFeeData",
2713
- "broadcastTransaction",
2714
- "estimateCall",
2715
- "estimateGasLimit",
2716
- "estimateGasPrices",
2717
- "createContractTxObject"
2718
- ];
2719
- var wrapMethodWithNetworkSwitch = (func, provider, chainId) => async (...args) => {
2720
- try {
2721
- await switchEVMWalletNetwork(provider, chainId);
2722
- } catch (error) {
2723
- throw new Error(`Failed to switch network: ${error}`);
2724
- }
2725
- return func(...args);
2726
- };
2727
- var providerRequest = ({ provider, params, method }) => {
2728
- if (!provider?.send)
2729
- throw new Error("Provider not found");
2730
- const providerParams = params ? Array.isArray(params) ? params : [params] : [];
2731
- return provider.send(method, providerParams);
2732
- };
2733
- var prepareNetworkSwitch = ({
2734
- toolbox,
2735
- chainId,
2736
- provider = window.ethereum
2737
- }) => {
2738
- const wrappedMethods = methodsToWrap.reduce((object, methodName) => {
2739
- if (!toolbox[methodName])
2740
- return object;
2741
- const method = toolbox[methodName];
2742
- if (typeof method !== "function")
2743
- return object;
2744
- return {
2745
- ...object,
2746
- [methodName]: wrapMethodWithNetworkSwitch(method, provider, chainId)
2747
- };
2748
- }, {});
2749
- return { ...toolbox, ...wrappedMethods };
2750
- };
2751
- var addEVMWalletNetwork = (provider, networkParams) => providerRequest({ provider, method: "wallet_addEthereumChain", params: [networkParams] });
2752
- var switchEVMWalletNetwork = (provider, chainId = ChainId.EthereumHex) => providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] });
2753
- var addAccountsChangedCallback = (callback) => {
2754
- window.ethereum?.on("accountsChanged", () => callback());
2755
- window.xfi?.ethereum.on("accountsChanged", () => callback());
2756
- };
2757
- var getETHDefaultWallet = () => {
2758
- const { isTrust, isBraveWallet, __XDEFI, overrideIsMetaMask, selectedProvider } = window?.ethereum || {};
2759
- if (isTrust)
2760
- return WalletOption.TRUSTWALLET_WEB;
2761
- if (isBraveWallet)
2762
- return WalletOption.BRAVE;
2763
- if (overrideIsMetaMask && selectedProvider?.isCoinbaseWallet)
2764
- return WalletOption.COINBASE_WEB;
2765
- if (__XDEFI)
2766
- WalletOption.XDEFI;
2767
- return WalletOption.METAMASK;
2768
- };
2769
- var isDetected = (walletOption) => {
2770
- return listWeb3EVMWallets().includes(walletOption);
2771
- };
2772
- var listWeb3EVMWallets = () => {
2773
- const metamaskEnabled = window?.ethereum && !window.ethereum?.isBraveWallet;
2774
- const xdefiEnabled = window?.xfi || window?.ethereum?.__XDEFI;
2775
- const braveEnabled = window?.ethereum?.isBraveWallet;
2776
- const trustEnabled = window?.ethereum?.isTrust || window?.trustwallet;
2777
- const coinbaseEnabled = window?.ethereum?.overrideIsMetaMask && window?.ethereum?.selectedProvider?.isCoinbaseWallet || window?.coinbaseWalletExtension;
2778
- const wallets = [];
2779
- if (metamaskEnabled)
2780
- wallets.push(WalletOption.METAMASK);
2781
- if (xdefiEnabled)
2782
- wallets.push(WalletOption.XDEFI);
2783
- if (braveEnabled)
2784
- wallets.push(WalletOption.BRAVE);
2785
- if (trustEnabled)
2786
- wallets.push(WalletOption.TRUSTWALLET_WEB);
2787
- if (coinbaseEnabled)
2788
- wallets.push(WalletOption.COINBASE_WEB);
2789
- if (okxMobileEnabled())
2790
- wallets.push(WalletOption.OKX_MOBILE);
2791
- return wallets;
2792
- };
2793
- var okxMobileEnabled = () => {
2794
- const ua = navigator.userAgent;
2795
- const isIOS = /iphone|ipad|ipod|ios/i.test(ua);
2796
- const isAndroid = /android|XiaoMi|MiuiBrowser/i.test(ua);
2797
- const isMobile = isIOS || isAndroid;
2798
- const isOKApp = /OKApp/i.test(ua);
2799
- return isMobile && isOKApp;
2800
- };
2801
- var isWeb3Detected = () => typeof window.ethereum !== "undefined";
2802
- export {
2803
- wrapWithThrow,
2804
- wrapMethodWithNetworkSwitch,
2805
- validateTNS,
2806
- validateIdentifier,
2807
- switchEVMWalletNetwork,
2808
- setRequestClientConfig,
2809
- prepareNetworkSwitch,
2810
- okxMobileEnabled,
2811
- listWeb3EVMWallets,
2812
- isWeb3Detected,
2813
- isGasAsset,
2814
- isDetected,
2815
- getWalletFormatFor,
2816
- getTHORNameCost,
2817
- getSymmetricWithdraw,
2818
- getSymmetricPoolShare,
2819
- getMinAmountByChain,
2820
- getMemoFor,
2821
- getMAYANameCost,
2822
- getLiquiditySlippage,
2823
- getGasAsset,
2824
- getEstimatedPoolShare,
2825
- getETHDefaultWallet,
2826
- getEIP6963Wallets,
2827
- getDerivationPathFor,
2828
- getDecimal,
2829
- getCommonAssetInfo,
2830
- getChainIdentifier,
2831
- getAsymmetricRuneWithdrawAmount,
2832
- getAsymmetricRuneShare,
2833
- getAsymmetricAssetWithdrawAmount,
2834
- getAsymmetricAssetShare,
2835
- getAssetType,
2836
- formatBigIntToSafeValue,
2837
- findAssetBy,
2838
- filterAssets,
2839
- erc20ABI,
2840
- derivationPathToString,
2841
- defaultRequestHeaders,
2842
- assetFromString,
2843
- addEVMWalletNetwork,
2844
- addAccountsChangedCallback,
2845
- WarningCodeEnum,
2846
- WalletOption,
2847
- UTXOChains,
2848
- TCSupportedChains,
2849
- TCEthereumVaultAbi,
2850
- TCBscDepositABI,
2851
- TCAvalancheDepositABI,
2852
- SwapKitNumber,
2853
- SwapKitError,
2854
- SubstrateChains,
2855
- SWAP_OUT,
2856
- SWAP_IN,
2857
- RouteQuoteWarningSchema,
2858
- RouteQuoteSchema,
2859
- RouteQuoteMetadataSchema,
2860
- RouteQuoteMetadataAssetSchema,
2861
- RouteQuoteLegSchema,
2862
- RouteLegWithoutAddressesSchema,
2863
- RouteLegSchema,
2864
- RequestClient,
2865
- RPCUrl,
2866
- QuoteResponseSchema,
2867
- QuoteRequestSchema,
2868
- QuoteMode,
2869
- ProviderName,
2870
- NetworkDerivationPath,
2871
- MemoType,
2872
- MayaEthereumVaultAbi,
2873
- MayaArbitrumVaultAbi,
2874
- MAYASupportedChains,
2875
- LedgerErrorCode,
2876
- FeesSchema,
2877
- FeeTypeEnum,
2878
- FeeOption,
2879
- ExplorerUrl,
2880
- EstimatedTimeSchema,
2881
- EVMTransactionDetailsSchema,
2882
- EVMTransactionDetailsParamsSchema,
2883
- EVMChains,
2884
- DerivationPath,
2885
- CosmosChains,
2886
- ContractAddress,
2887
- ChainToRPC,
2888
- ChainToHexChainId,
2889
- ChainToExplorerUrl,
2890
- ChainToChainId,
2891
- ChainIdToChain,
2892
- ChainId,
2893
- Chain,
2894
- BigIntArithmetics,
2895
- BaseDecimal,
2896
- AssetValue,
2897
- ApproveMode,
2898
- AGG_SWAP
2899
- };
2900
-
2901
- //# debugId=4CE59F15680AEBD264756E2164756E21
3
+ //# debugId=46055CFCF1A3F05D64756E2164756E21