@swapkit/helpers 1.0.0-rc.112 → 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 +2 -2897
- package/dist/index.js.map +11 -11
- package/package.json +6 -15
- package/src/helpers/__tests__/memo.test.ts +54 -73
- package/src/helpers/memo.ts +152 -45
- package/src/helpers/web3wallets.ts +1 -0
- package/src/modules/assetValue.ts +1 -0
- package/src/modules/bigIntArithmetics.ts +2 -6
- package/src/modules/swapKitError.ts +11 -13
- package/src/types/chains.ts +5 -1
- package/src/types/derivationPath.ts +3 -1
- package/src/types/network.ts +3 -1
- package/src/types/wallet.ts +16 -16
package/dist/index.js
CHANGED
|
@@ -1,2898 +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
|
-
|
|
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
|
-
})(WalletOption || (WalletOption = {}));
|
|
1268
|
-
var LedgerErrorCode;
|
|
1269
|
-
(function(LedgerErrorCode2) {
|
|
1270
|
-
LedgerErrorCode2[LedgerErrorCode2["NoError"] = 36864] = "NoError";
|
|
1271
|
-
LedgerErrorCode2[LedgerErrorCode2["LockedDevice"] = 21781] = "LockedDevice";
|
|
1272
|
-
LedgerErrorCode2[LedgerErrorCode2["TC_NotFound"] = 65535] = "TC_NotFound";
|
|
1273
|
-
})(LedgerErrorCode || (LedgerErrorCode = {}));
|
|
1274
|
-
// src/types/sdk.ts
|
|
1275
|
-
import {z} from "zod";
|
|
1276
|
-
var FeeOption;
|
|
1277
|
-
(function(FeeOption2) {
|
|
1278
|
-
FeeOption2["Average"] = "average";
|
|
1279
|
-
FeeOption2["Fast"] = "fast";
|
|
1280
|
-
FeeOption2["Fastest"] = "fastest";
|
|
1281
|
-
})(FeeOption || (FeeOption = {}));
|
|
1282
|
-
var ApproveMode;
|
|
1283
|
-
(function(ApproveMode2) {
|
|
1284
|
-
ApproveMode2["Approve"] = "approve";
|
|
1285
|
-
ApproveMode2["CheckOnly"] = "checkOnly";
|
|
1286
|
-
})(ApproveMode || (ApproveMode = {}));
|
|
1287
|
-
var MemoType;
|
|
1288
|
-
(function(MemoType2) {
|
|
1289
|
-
MemoType2["BOND"] = "BOND";
|
|
1290
|
-
MemoType2["DEPOSIT"] = "+";
|
|
1291
|
-
MemoType2["LEAVE"] = "LEAVE";
|
|
1292
|
-
MemoType2["NAME_REGISTER"] = "~";
|
|
1293
|
-
MemoType2["UNBOND"] = "UNBOND";
|
|
1294
|
-
MemoType2["WITHDRAW"] = "-";
|
|
1295
|
-
MemoType2["OPEN_LOAN"] = "$+";
|
|
1296
|
-
MemoType2["CLOSE_LOAN"] = "$-";
|
|
1297
|
-
})(MemoType || (MemoType = {}));
|
|
1298
|
-
var QuoteRequestSchema = z.object({
|
|
1299
|
-
sellAsset: z.string({
|
|
1300
|
-
description: "Asset to sell"
|
|
1301
|
-
}),
|
|
1302
|
-
buyAsset: z.string({
|
|
1303
|
-
description: "Asset to buy"
|
|
1304
|
-
}),
|
|
1305
|
-
sellAmount: z.number({
|
|
1306
|
-
description: "Amount of asset to sell"
|
|
1307
|
-
}).refine((amount) => amount > 0, {
|
|
1308
|
-
message: "sellAmount must be greater than 0",
|
|
1309
|
-
path: ["sellAmount"]
|
|
1310
|
-
}),
|
|
1311
|
-
providers: z.optional(z.array(z.string({
|
|
1312
|
-
description: "List of providers to use"
|
|
1313
|
-
}))),
|
|
1314
|
-
sourceAddress: z.optional(z.string({
|
|
1315
|
-
description: "Address to send asset from"
|
|
1316
|
-
})),
|
|
1317
|
-
destinationAddress: z.optional(z.string({
|
|
1318
|
-
description: "Address to send asset to"
|
|
1319
|
-
})),
|
|
1320
|
-
slippage: z.optional(z.number({
|
|
1321
|
-
description: "Slippage tolerance as a percentage. Default is 3%."
|
|
1322
|
-
})),
|
|
1323
|
-
affiliate: z.optional(z.string({
|
|
1324
|
-
description: "Affiliate thorname"
|
|
1325
|
-
})),
|
|
1326
|
-
affiliateFee: z.optional(z.number({
|
|
1327
|
-
description: "Affiliate fee in basis points"
|
|
1328
|
-
}).refine((fee) => {
|
|
1329
|
-
return fee === Math.floor(fee) && fee >= 0;
|
|
1330
|
-
}, { message: "affiliateFee must be a positive integer", path: ["affiliateFee"] })),
|
|
1331
|
-
allowSmartContractSender: z.optional(z.boolean({
|
|
1332
|
-
description: "Allow smart contract as sender"
|
|
1333
|
-
})),
|
|
1334
|
-
allowSmartContractReceiver: z.optional(z.boolean({
|
|
1335
|
-
description: "Allow smart contract as recipient"
|
|
1336
|
-
})),
|
|
1337
|
-
disableSecurityChecks: z.optional(z.boolean({
|
|
1338
|
-
description: "Disable security checks"
|
|
1339
|
-
}))
|
|
1340
|
-
}).refine((data) => data.sellAsset !== data.buyAsset, {
|
|
1341
|
-
message: "Must be different",
|
|
1342
|
-
path: ["sellAsset", "buyAsset"]
|
|
1343
|
-
});
|
|
1344
|
-
// src/types/quotes.ts
|
|
1345
|
-
import {z as z2} from "zod";
|
|
1346
|
-
var WarningCodeEnum;
|
|
1347
|
-
(function(WarningCodeEnum2) {
|
|
1348
|
-
WarningCodeEnum2["highSlippage"] = "highSlippage";
|
|
1349
|
-
WarningCodeEnum2["highPriceImpact"] = "highPriceImpact";
|
|
1350
|
-
})(WarningCodeEnum || (WarningCodeEnum = {}));
|
|
1351
|
-
var EVMTransactionDetailsParamsSchema = z2.array(z2.union([
|
|
1352
|
-
z2.string(),
|
|
1353
|
-
z2.number(),
|
|
1354
|
-
z2.array(z2.string()),
|
|
1355
|
-
z2.object({
|
|
1356
|
-
from: z2.string(),
|
|
1357
|
-
value: z2.string()
|
|
1358
|
-
}).describe("Parameters to pass to the contract method")
|
|
1359
|
-
]));
|
|
1360
|
-
var EVMTransactionDetailsSchema = z2.object({
|
|
1361
|
-
contractAddress: z2.string({
|
|
1362
|
-
description: "Address of the contract to interact with"
|
|
1363
|
-
}),
|
|
1364
|
-
contractMethod: z2.string({
|
|
1365
|
-
description: "Name of the method to call"
|
|
1366
|
-
}),
|
|
1367
|
-
contractParams: EVMTransactionDetailsParamsSchema,
|
|
1368
|
-
contractParamNames: z2.array(z2.string({
|
|
1369
|
-
description: "Names of the parameters to pass to the contract method"
|
|
1370
|
-
})),
|
|
1371
|
-
approvalToken: z2.optional(z2.string({
|
|
1372
|
-
description: "Address of the token to approve spending of"
|
|
1373
|
-
})),
|
|
1374
|
-
approvalSpender: z2.optional(z2.string({
|
|
1375
|
-
description: "Address of the spender to approve"
|
|
1376
|
-
}))
|
|
1377
|
-
});
|
|
1378
|
-
var EstimatedTimeSchema = z2.object({
|
|
1379
|
-
inbound: z2.optional(z2.number({
|
|
1380
|
-
description: "Time to receive inbound asset in seconds"
|
|
1381
|
-
})),
|
|
1382
|
-
swap: z2.optional(z2.number({
|
|
1383
|
-
description: "Time to swap assets in seconds"
|
|
1384
|
-
})),
|
|
1385
|
-
outbound: z2.optional(z2.number({
|
|
1386
|
-
description: "Time to receive outbound asset in seconds"
|
|
1387
|
-
})),
|
|
1388
|
-
total: z2.number({
|
|
1389
|
-
description: "Total time in seconds"
|
|
1390
|
-
})
|
|
1391
|
-
});
|
|
1392
|
-
var ProviderName;
|
|
1393
|
-
(function(ProviderName2) {
|
|
1394
|
-
ProviderName2["CHAINFLIP"] = "CHAINFLIP";
|
|
1395
|
-
ProviderName2["TRADERJOE_V1"] = "TRADERJOE_V1";
|
|
1396
|
-
ProviderName2["PANGOLIN_V1"] = "PANGOLIN_V1";
|
|
1397
|
-
ProviderName2["UNISWAP_V2"] = "UNISWAP_V2";
|
|
1398
|
-
ProviderName2["THORCHAIN"] = "THORCHAIN";
|
|
1399
|
-
ProviderName2["THORCHAIN_STREAMING"] = "THORCHAIN_STREAMING";
|
|
1400
|
-
ProviderName2["MAYACHAIN"] = "MAYACHAIN";
|
|
1401
|
-
ProviderName2["ONEINCH"] = "ONEINCH";
|
|
1402
|
-
ProviderName2["SUSHISWAP_V2"] = "SUSHISWAP_V2";
|
|
1403
|
-
ProviderName2["WOOFI_V2"] = "WOOFI_V2";
|
|
1404
|
-
ProviderName2["PANCAKESWAP"] = "PANCAKESWAP";
|
|
1405
|
-
})(ProviderName || (ProviderName = {}));
|
|
1406
|
-
var FeeTypeEnum;
|
|
1407
|
-
(function(FeeTypeEnum2) {
|
|
1408
|
-
FeeTypeEnum2["LIQUIDITY"] = "liquidity";
|
|
1409
|
-
FeeTypeEnum2["NETWORK"] = "network";
|
|
1410
|
-
FeeTypeEnum2["INBOUND"] = "inbound";
|
|
1411
|
-
FeeTypeEnum2["OUTBOUND"] = "outbound";
|
|
1412
|
-
FeeTypeEnum2["AFFILIATE"] = "affiliate";
|
|
1413
|
-
FeeTypeEnum2["TAX"] = "tax";
|
|
1414
|
-
})(FeeTypeEnum || (FeeTypeEnum = {}));
|
|
1415
|
-
var FeesSchema = z2.array(z2.object({
|
|
1416
|
-
type: z2.nativeEnum(FeeTypeEnum),
|
|
1417
|
-
amount: z2.string(),
|
|
1418
|
-
asset: z2.string(),
|
|
1419
|
-
chain: z2.string(),
|
|
1420
|
-
protocol: z2.nativeEnum(ProviderName)
|
|
1421
|
-
}));
|
|
1422
|
-
var RouteLegSchema = z2.object({
|
|
1423
|
-
sellAsset: z2.string({
|
|
1424
|
-
description: "Asset to sell"
|
|
1425
|
-
}),
|
|
1426
|
-
buyAsset: z2.string({
|
|
1427
|
-
description: "Asset to buy"
|
|
1428
|
-
}),
|
|
1429
|
-
provider: z2.nativeEnum(ProviderName),
|
|
1430
|
-
sourceAddress: z2.string({
|
|
1431
|
-
description: "Source address"
|
|
1432
|
-
}),
|
|
1433
|
-
destinationAddress: z2.string({
|
|
1434
|
-
description: "Destination address"
|
|
1435
|
-
}),
|
|
1436
|
-
estimatedTime: EstimatedTimeSchema.optional(),
|
|
1437
|
-
affiliate: z2.string({
|
|
1438
|
-
description: "Affiliate address"
|
|
1439
|
-
}).optional(),
|
|
1440
|
-
affiliateFee: z2.number({
|
|
1441
|
-
description: "Affiliate fee"
|
|
1442
|
-
}).optional(),
|
|
1443
|
-
slipPercentage: z2.number({
|
|
1444
|
-
description: "Slippage as a percentage"
|
|
1445
|
-
})
|
|
1446
|
-
});
|
|
1447
|
-
var RouteLegWithoutAddressesSchema = RouteLegSchema.omit({
|
|
1448
|
-
sourceAddress: true,
|
|
1449
|
-
destinationAddress: true,
|
|
1450
|
-
slipPercentage: true
|
|
1451
|
-
});
|
|
1452
|
-
var RouteQuoteMetadataAssetSchema = z2.object({
|
|
1453
|
-
name: z2.string({
|
|
1454
|
-
description: "Asset name"
|
|
1455
|
-
}),
|
|
1456
|
-
price: z2.number({
|
|
1457
|
-
description: "Price in USD"
|
|
1458
|
-
}),
|
|
1459
|
-
image: z2.string({
|
|
1460
|
-
description: "Asset image"
|
|
1461
|
-
})
|
|
1462
|
-
});
|
|
1463
|
-
var RouteQuoteMetadataSchema = z2.object({
|
|
1464
|
-
priceImpact: z2.number({
|
|
1465
|
-
description: "Price impact"
|
|
1466
|
-
}),
|
|
1467
|
-
assets: z2.optional(z2.array(RouteQuoteMetadataAssetSchema))
|
|
1468
|
-
});
|
|
1469
|
-
var RouteQuoteWarningSchema = z2.array(z2.object({
|
|
1470
|
-
code: z2.nativeEnum(WarningCodeEnum),
|
|
1471
|
-
display: z2.string(),
|
|
1472
|
-
tooltip: z2.string().optional()
|
|
1473
|
-
}));
|
|
1474
|
-
var RouteQuoteLegSchema = z2.object({
|
|
1475
|
-
sellAsset: z2.string({
|
|
1476
|
-
description: "Asset to sell"
|
|
1477
|
-
}),
|
|
1478
|
-
buyAsset: z2.string({
|
|
1479
|
-
description: "Asset to buy"
|
|
1480
|
-
}),
|
|
1481
|
-
provider: z2.nativeEnum(ProviderName),
|
|
1482
|
-
buyAmount: z2.string({
|
|
1483
|
-
description: "Amount of asset to buy"
|
|
1484
|
-
}),
|
|
1485
|
-
buyAmountMaxSlippage: z2.string({
|
|
1486
|
-
description: "Amount of asset to buy"
|
|
1487
|
-
}),
|
|
1488
|
-
sellAmount: z2.string({
|
|
1489
|
-
description: "Amount of asset to sell"
|
|
1490
|
-
}),
|
|
1491
|
-
sourceAddress: z2.string({
|
|
1492
|
-
description: "Source address"
|
|
1493
|
-
}),
|
|
1494
|
-
destinationAddress: z2.string({
|
|
1495
|
-
description: "Destination address"
|
|
1496
|
-
}),
|
|
1497
|
-
slippageBps: z2.number({
|
|
1498
|
-
description: "Slippage in bps"
|
|
1499
|
-
}),
|
|
1500
|
-
targetAddress: z2.optional(z2.string({
|
|
1501
|
-
description: "Target address for contract call or transfer address"
|
|
1502
|
-
})),
|
|
1503
|
-
inboundAddress: z2.optional(z2.string({
|
|
1504
|
-
description: "Inbound address"
|
|
1505
|
-
})),
|
|
1506
|
-
routerAddress: z2.optional(z2.string({
|
|
1507
|
-
description: "Inbound address"
|
|
1508
|
-
})),
|
|
1509
|
-
contractMethod: z2.optional(z2.string({
|
|
1510
|
-
description: "Contract method"
|
|
1511
|
-
})),
|
|
1512
|
-
fees: z2.optional(FeesSchema),
|
|
1513
|
-
estimatedTime: z2.optional(EstimatedTimeSchema),
|
|
1514
|
-
memo: z2.optional(z2.string({
|
|
1515
|
-
description: "Memo"
|
|
1516
|
-
})),
|
|
1517
|
-
expiration: z2.optional(z2.string({
|
|
1518
|
-
description: "Expiration"
|
|
1519
|
-
}))
|
|
1520
|
-
});
|
|
1521
|
-
var RouteQuoteSchema = z2.object({
|
|
1522
|
-
providers: z2.array(z2.nativeEnum(ProviderName)),
|
|
1523
|
-
sellAsset: z2.string({
|
|
1524
|
-
description: "Asset to sell"
|
|
1525
|
-
}),
|
|
1526
|
-
sellAmount: z2.string({
|
|
1527
|
-
description: "sell amount"
|
|
1528
|
-
}),
|
|
1529
|
-
buyAsset: z2.string({
|
|
1530
|
-
description: "Asset to buy"
|
|
1531
|
-
}),
|
|
1532
|
-
expectedBuyAmount: z2.string({
|
|
1533
|
-
description: "Expected Buy amount"
|
|
1534
|
-
}),
|
|
1535
|
-
expectedBuyAmountMaxSlippage: z2.string({
|
|
1536
|
-
description: "Expected Buy amount max slippage"
|
|
1537
|
-
}),
|
|
1538
|
-
sourceAddress: z2.string({
|
|
1539
|
-
description: "Source address"
|
|
1540
|
-
}),
|
|
1541
|
-
destinationAddress: z2.string({
|
|
1542
|
-
description: "Destination address"
|
|
1543
|
-
}),
|
|
1544
|
-
targetAddress: z2.optional(z2.string({
|
|
1545
|
-
description: "Target address"
|
|
1546
|
-
})),
|
|
1547
|
-
routerAddress: z2.optional(z2.string({
|
|
1548
|
-
description: "Router address"
|
|
1549
|
-
})),
|
|
1550
|
-
inboundAddress: z2.optional(z2.string({
|
|
1551
|
-
description: "Inbound address"
|
|
1552
|
-
})),
|
|
1553
|
-
expiration: z2.optional(z2.string({
|
|
1554
|
-
description: "Expiration"
|
|
1555
|
-
})),
|
|
1556
|
-
memo: z2.optional(z2.string({
|
|
1557
|
-
description: "Memo"
|
|
1558
|
-
})),
|
|
1559
|
-
evmTransactionDetails: z2.optional(EVMTransactionDetailsSchema),
|
|
1560
|
-
routePathArray: z2.optional(z2.array(z2.string())),
|
|
1561
|
-
estimatedTime: z2.optional(EstimatedTimeSchema),
|
|
1562
|
-
totalSlippageBps: z2.number({
|
|
1563
|
-
description: "Total slippage in bps"
|
|
1564
|
-
}),
|
|
1565
|
-
legs: z2.array(RouteQuoteLegSchema),
|
|
1566
|
-
errorCode: z2.optional(z2.string()),
|
|
1567
|
-
warnings: RouteQuoteWarningSchema,
|
|
1568
|
-
meta: RouteQuoteMetadataSchema
|
|
1569
|
-
});
|
|
1570
|
-
var QuoteResponseRouteLegItem = z2.object({
|
|
1571
|
-
provider: z2.nativeEnum(ProviderName),
|
|
1572
|
-
sellAsset: z2.string({
|
|
1573
|
-
description: "Asset to sell"
|
|
1574
|
-
}),
|
|
1575
|
-
sellAmount: z2.string({
|
|
1576
|
-
description: "Sell amount"
|
|
1577
|
-
}),
|
|
1578
|
-
buyAsset: z2.string({
|
|
1579
|
-
description: "Asset to buy"
|
|
1580
|
-
}),
|
|
1581
|
-
buyAmount: z2.string({
|
|
1582
|
-
description: "Buy amount"
|
|
1583
|
-
}),
|
|
1584
|
-
buyAmountMaxSlippage: z2.string({
|
|
1585
|
-
description: "Buy amount max slippage"
|
|
1586
|
-
}),
|
|
1587
|
-
fees: z2.optional(FeesSchema)
|
|
1588
|
-
});
|
|
1589
|
-
var QuoteResponseRouteItem = z2.object({
|
|
1590
|
-
providers: z2.array(z2.nativeEnum(ProviderName)),
|
|
1591
|
-
sellAsset: z2.string({
|
|
1592
|
-
description: "Asset to sell"
|
|
1593
|
-
}),
|
|
1594
|
-
sellAmount: z2.string({
|
|
1595
|
-
description: "sell amount"
|
|
1596
|
-
}),
|
|
1597
|
-
buyAsset: z2.string({
|
|
1598
|
-
description: "Asset to buy"
|
|
1599
|
-
}),
|
|
1600
|
-
expectedBuyAmount: z2.string({
|
|
1601
|
-
description: "Expected Buy amount"
|
|
1602
|
-
}),
|
|
1603
|
-
expectedBuyAmountMaxSlippage: z2.string({
|
|
1604
|
-
description: "Expected Buy amount max slippage"
|
|
1605
|
-
}),
|
|
1606
|
-
sourceAddress: z2.string({
|
|
1607
|
-
description: "Source address"
|
|
1608
|
-
}),
|
|
1609
|
-
destinationAddress: z2.string({
|
|
1610
|
-
description: "Destination address"
|
|
1611
|
-
}),
|
|
1612
|
-
targetAddress: z2.optional(z2.string({
|
|
1613
|
-
description: "Target address"
|
|
1614
|
-
})),
|
|
1615
|
-
expiration: z2.optional(z2.string({
|
|
1616
|
-
description: "Expiration"
|
|
1617
|
-
})),
|
|
1618
|
-
memo: z2.optional(z2.string({
|
|
1619
|
-
description: "Memo"
|
|
1620
|
-
})),
|
|
1621
|
-
evmTransactionDetails: z2.optional(EVMTransactionDetailsSchema),
|
|
1622
|
-
estimatedTime: z2.optional(EstimatedTimeSchema),
|
|
1623
|
-
totalSlippageBps: z2.number({
|
|
1624
|
-
description: "Total slippage in bps"
|
|
1625
|
-
}),
|
|
1626
|
-
legs: z2.array(QuoteResponseRouteLegItem),
|
|
1627
|
-
warnings: RouteQuoteWarningSchema,
|
|
1628
|
-
meta: RouteQuoteMetadataSchema
|
|
1629
|
-
});
|
|
1630
|
-
var QuoteResponseSchema = z2.object({
|
|
1631
|
-
quoteId: z2.string({
|
|
1632
|
-
description: "Quote ID"
|
|
1633
|
-
}),
|
|
1634
|
-
routes: z2.array(QuoteResponseRouteItem),
|
|
1635
|
-
error: z2.optional(z2.string({
|
|
1636
|
-
description: "Error message"
|
|
1637
|
-
}))
|
|
1638
|
-
});
|
|
1639
|
-
// src/helpers/validators.ts
|
|
1640
|
-
function validateIdentifier(identifier = "") {
|
|
1641
|
-
const uppercasedIdentifier = identifier.toUpperCase();
|
|
1642
|
-
const [chain] = uppercasedIdentifier.split(".");
|
|
1643
|
-
if (supportedChains.includes(chain))
|
|
1644
|
-
return true;
|
|
1645
|
-
const [synthChain] = uppercasedIdentifier.split("/");
|
|
1646
|
-
if (supportedChains.includes(synthChain))
|
|
1647
|
-
return true;
|
|
1648
|
-
throw new Error(`Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`);
|
|
1649
|
-
}
|
|
1650
|
-
function validateTNS(name) {
|
|
1651
|
-
if (name.length > 30)
|
|
1652
|
-
return false;
|
|
1653
|
-
const regex = /^[a-zA-Z0-9+_-]+$/g;
|
|
1654
|
-
return !!name.match(regex);
|
|
1655
|
-
}
|
|
1656
|
-
var supportedChains = [...Object.values(Chain), "TERRA"];
|
|
1657
|
-
|
|
1658
|
-
// src/modules/bigIntArithmetics.ts
|
|
1659
|
-
function formatBigIntToSafeValue({
|
|
1660
|
-
value,
|
|
1661
|
-
bigIntDecimal = DEFAULT_DECIMAL,
|
|
1662
|
-
decimal = DEFAULT_DECIMAL
|
|
1663
|
-
}) {
|
|
1664
|
-
if (decimal === 0)
|
|
1665
|
-
return value.toString();
|
|
1666
|
-
const isNegative = value < 0n;
|
|
1667
|
-
let valueString = value.toString().substring(isNegative ? 1 : 0);
|
|
1668
|
-
const padLength = decimal - (valueString.length - 1);
|
|
1669
|
-
if (padLength > 0) {
|
|
1670
|
-
valueString = "0".repeat(padLength) + valueString;
|
|
1671
|
-
}
|
|
1672
|
-
const decimalIndex = valueString.length - decimal;
|
|
1673
|
-
let decimalString = valueString.slice(-decimal);
|
|
1674
|
-
if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
|
|
1675
|
-
decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
|
|
1676
|
-
} else {
|
|
1677
|
-
decimalString = decimalString.substring(0, bigIntDecimal);
|
|
1678
|
-
}
|
|
1679
|
-
return `${isNegative ? "-" : ""}${valueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
|
|
1680
|
-
}
|
|
1681
|
-
var toSafeValue = function(value) {
|
|
1682
|
-
const parsedValue = typeof value === "number" ? numberFormatter.format(value) : getStringValue(value);
|
|
1683
|
-
const splitValue = `${parsedValue}`.replaceAll(",", ".").split(".");
|
|
1684
|
-
return splitValue.length > 1 ? `${splitValue.slice(0, -1).join("")}.${splitValue.at(-1)}` : splitValue[0] || "0";
|
|
1685
|
-
};
|
|
1686
|
-
var getFloatDecimals = function(value) {
|
|
1687
|
-
const decimals = value.split(".")[1]?.length || 0;
|
|
1688
|
-
return Math.max(decimals, DEFAULT_DECIMAL);
|
|
1689
|
-
};
|
|
1690
|
-
var getStringValue = function(param) {
|
|
1691
|
-
return typeof param === "object" ? "getValue" in param ? param.getValue("string") : param.value : param;
|
|
1692
|
-
};
|
|
1693
|
-
var DEFAULT_DECIMAL = 8;
|
|
1694
|
-
var toMultiplier = (decimal) => 10n ** BigInt(decimal);
|
|
1695
|
-
var decimalFromMultiplier = (multiplier) => Math.log10(Number.parseFloat(multiplier.toString()));
|
|
1696
|
-
|
|
1697
|
-
class BigIntArithmetics {
|
|
1698
|
-
decimalMultiplier = 10n ** 8n;
|
|
1699
|
-
bigIntValue = 0n;
|
|
1700
|
-
decimal;
|
|
1701
|
-
static fromBigInt(value, decimal) {
|
|
1702
|
-
return new BigIntArithmetics({
|
|
1703
|
-
decimal,
|
|
1704
|
-
value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
|
|
1705
|
-
});
|
|
1706
|
-
}
|
|
1707
|
-
static shiftDecimals({
|
|
1708
|
-
value,
|
|
1709
|
-
from,
|
|
1710
|
-
to
|
|
1711
|
-
}) {
|
|
1712
|
-
return BigIntArithmetics.fromBigInt(value.getBaseValue("bigint") * toMultiplier(to) / toMultiplier(from), to);
|
|
1713
|
-
}
|
|
1714
|
-
constructor(params) {
|
|
1715
|
-
const value = getStringValue(params);
|
|
1716
|
-
const isComplex = typeof params === "object";
|
|
1717
|
-
this.decimal = isComplex ? params.decimal : undefined;
|
|
1718
|
-
this.decimalMultiplier = isComplex && "decimalMultiplier" in params ? params.decimalMultiplier : toMultiplier(Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0));
|
|
1719
|
-
this.#setValue(value);
|
|
1720
|
-
}
|
|
1721
|
-
set(value) {
|
|
1722
|
-
return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });
|
|
1723
|
-
}
|
|
1724
|
-
add(...args) {
|
|
1725
|
-
return this.#arithmetics("add", ...args);
|
|
1726
|
-
}
|
|
1727
|
-
sub(...args) {
|
|
1728
|
-
return this.#arithmetics("sub", ...args);
|
|
1729
|
-
}
|
|
1730
|
-
mul(...args) {
|
|
1731
|
-
return this.#arithmetics("mul", ...args);
|
|
1732
|
-
}
|
|
1733
|
-
div(...args) {
|
|
1734
|
-
return this.#arithmetics("div", ...args);
|
|
1735
|
-
}
|
|
1736
|
-
gt(value) {
|
|
1737
|
-
return this.#comparison("gt", value);
|
|
1738
|
-
}
|
|
1739
|
-
gte(value) {
|
|
1740
|
-
return this.#comparison("gte", value);
|
|
1741
|
-
}
|
|
1742
|
-
lt(value) {
|
|
1743
|
-
return this.#comparison("lt", value);
|
|
1744
|
-
}
|
|
1745
|
-
lte(value) {
|
|
1746
|
-
return this.#comparison("lte", value);
|
|
1747
|
-
}
|
|
1748
|
-
eqValue(value) {
|
|
1749
|
-
return this.#comparison("eqValue", value);
|
|
1750
|
-
}
|
|
1751
|
-
getValue(type) {
|
|
1752
|
-
const value = this.formatBigIntToSafeValue(this.bigIntValue, this.decimal || decimalFromMultiplier(this.decimalMultiplier));
|
|
1753
|
-
switch (type) {
|
|
1754
|
-
case "number":
|
|
1755
|
-
return Number(value);
|
|
1756
|
-
case "string":
|
|
1757
|
-
return value;
|
|
1758
|
-
case "bigint":
|
|
1759
|
-
return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
getBaseValue(type) {
|
|
1763
|
-
const divisor = this.decimalMultiplier / toMultiplier(this.decimal || BaseDecimal.THOR);
|
|
1764
|
-
const baseValue = this.bigIntValue / divisor;
|
|
1765
|
-
switch (type) {
|
|
1766
|
-
case "number":
|
|
1767
|
-
return Number(baseValue);
|
|
1768
|
-
case "string":
|
|
1769
|
-
return baseValue.toString();
|
|
1770
|
-
case "bigint":
|
|
1771
|
-
return baseValue;
|
|
1772
|
-
}
|
|
1773
|
-
}
|
|
1774
|
-
getBigIntValue(value, decimal) {
|
|
1775
|
-
if (!decimal && typeof value === "object")
|
|
1776
|
-
return value.bigIntValue;
|
|
1777
|
-
const stringValue = getStringValue(value);
|
|
1778
|
-
const safeValue = toSafeValue(stringValue);
|
|
1779
|
-
if (safeValue === "0" || safeValue === "undefined")
|
|
1780
|
-
return 0n;
|
|
1781
|
-
return this.#toBigInt(safeValue, decimal);
|
|
1782
|
-
}
|
|
1783
|
-
toSignificant(significantDigits = 6) {
|
|
1784
|
-
const [int, dec] = this.getValue("string").split(".");
|
|
1785
|
-
const integer = int || "";
|
|
1786
|
-
const decimal = dec || "";
|
|
1787
|
-
const valueLength = Number.parseInt(integer) ? integer.length + decimal.length : decimal.length;
|
|
1788
|
-
if (valueLength <= significantDigits) {
|
|
1789
|
-
return this.getValue("string");
|
|
1790
|
-
}
|
|
1791
|
-
if (integer.length >= significantDigits) {
|
|
1792
|
-
return integer.slice(0, significantDigits).padEnd(integer.length, "0");
|
|
1793
|
-
}
|
|
1794
|
-
if (Number.parseInt(integer)) {
|
|
1795
|
-
return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(significantDigits - integer.length, "0");
|
|
1796
|
-
}
|
|
1797
|
-
const trimmedDecimal = Number.parseInt(decimal);
|
|
1798
|
-
const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);
|
|
1799
|
-
return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
|
|
1800
|
-
}
|
|
1801
|
-
toFixed(fixedDigits = 6) {
|
|
1802
|
-
const [int, dec] = this.getValue("string").split(".");
|
|
1803
|
-
const integer = int || "";
|
|
1804
|
-
const decimal = dec || "";
|
|
1805
|
-
if (Number.parseInt(integer)) {
|
|
1806
|
-
return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, "0");
|
|
1807
|
-
}
|
|
1808
|
-
const trimmedDecimal = Number.parseInt(decimal);
|
|
1809
|
-
const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);
|
|
1810
|
-
return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
|
|
1811
|
-
}
|
|
1812
|
-
toAbbreviation(digits = 2) {
|
|
1813
|
-
const value = this.getValue("number");
|
|
1814
|
-
const abbreviations = ["", "K", "M", "B", "T", "Q", "Qi", "S"];
|
|
1815
|
-
const tier = Math.floor(Math.log10(Math.abs(value)) / 3);
|
|
1816
|
-
const suffix = abbreviations[tier];
|
|
1817
|
-
if (!suffix)
|
|
1818
|
-
return this.getValue("string");
|
|
1819
|
-
const scale = 10 ** (tier * 3);
|
|
1820
|
-
const scaled = value / scale;
|
|
1821
|
-
return `${scaled.toFixed(digits)}${suffix}`;
|
|
1822
|
-
}
|
|
1823
|
-
toCurrency(currency = "$", {
|
|
1824
|
-
currencyPosition = "start",
|
|
1825
|
-
decimal = 2,
|
|
1826
|
-
decimalSeparator = ".",
|
|
1827
|
-
thousandSeparator = ","
|
|
1828
|
-
} = {}) {
|
|
1829
|
-
const value = this.getValue("number");
|
|
1830
|
-
const [int = "", dec = ""] = value.toFixed(6).split(".");
|
|
1831
|
-
const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
|
|
1832
|
-
const parsedValue = int || dec ? int === "0" ? `${Number.parseFloat(`0.${dec}`)}`.replace(".", decimalSeparator) : `${integer}${Number.parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ""}` : "0.00";
|
|
1833
|
-
return `${currencyPosition === "start" ? currency : ""}${parsedValue}${currencyPosition === "end" ? currency : ""}`;
|
|
1834
|
-
}
|
|
1835
|
-
formatBigIntToSafeValue(value, decimal) {
|
|
1836
|
-
const bigIntDecimal = decimal || this.decimal || DEFAULT_DECIMAL;
|
|
1837
|
-
const decimalToUseForConversion = Math.max(bigIntDecimal, decimalFromMultiplier(this.decimalMultiplier));
|
|
1838
|
-
const isNegative = value < 0n;
|
|
1839
|
-
const valueString = value.toString().substring(isNegative ? 1 : 0);
|
|
1840
|
-
const padLength = decimalToUseForConversion - (valueString.length - 1);
|
|
1841
|
-
const parsedValueString = padLength > 0 ? "0".repeat(padLength) + valueString : valueString;
|
|
1842
|
-
const decimalIndex = parsedValueString.length - decimalToUseForConversion;
|
|
1843
|
-
let decimalString = parsedValueString.slice(-decimalToUseForConversion);
|
|
1844
|
-
if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
|
|
1845
|
-
decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
|
|
1846
|
-
} else {
|
|
1847
|
-
decimalString = decimalString.substring(0, bigIntDecimal);
|
|
1848
|
-
}
|
|
1849
|
-
return `${isNegative ? "-" : ""}${parsedValueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
|
|
1850
|
-
}
|
|
1851
|
-
#arithmetics(method, ...args) {
|
|
1852
|
-
const precisionDecimal = this.#retrievePrecisionDecimal(this, ...args);
|
|
1853
|
-
const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
|
|
1854
|
-
const precisionDecimalMultiplier = toMultiplier(decimal);
|
|
1855
|
-
const result = args.reduce((acc, arg) => {
|
|
1856
|
-
const value2 = this.getBigIntValue(arg, decimal);
|
|
1857
|
-
switch (method) {
|
|
1858
|
-
case "add":
|
|
1859
|
-
return acc + value2;
|
|
1860
|
-
case "sub":
|
|
1861
|
-
return acc - value2;
|
|
1862
|
-
case "mul":
|
|
1863
|
-
return acc * value2 / precisionDecimalMultiplier;
|
|
1864
|
-
case "div": {
|
|
1865
|
-
if (value2 === 0n)
|
|
1866
|
-
throw new RangeError("Division by zero");
|
|
1867
|
-
return acc * precisionDecimalMultiplier / value2;
|
|
1868
|
-
}
|
|
1869
|
-
default:
|
|
1870
|
-
return acc;
|
|
1871
|
-
}
|
|
1872
|
-
}, this.bigIntValue * precisionDecimalMultiplier / this.decimalMultiplier);
|
|
1873
|
-
const value = formatBigIntToSafeValue({
|
|
1874
|
-
bigIntDecimal: decimal,
|
|
1875
|
-
decimal,
|
|
1876
|
-
value: result
|
|
1877
|
-
});
|
|
1878
|
-
return new this.constructor({
|
|
1879
|
-
decimalMultiplier: toMultiplier(decimal),
|
|
1880
|
-
decimal: this.decimal,
|
|
1881
|
-
value,
|
|
1882
|
-
identifier: this.toString()
|
|
1883
|
-
});
|
|
1884
|
-
}
|
|
1885
|
-
#comparison(method, ...args) {
|
|
1886
|
-
const decimal = this.#retrievePrecisionDecimal(this, ...args);
|
|
1887
|
-
const value = this.getBigIntValue(args[0] || "0", decimal);
|
|
1888
|
-
const compareToValue = this.getBigIntValue(this, decimal);
|
|
1889
|
-
switch (method) {
|
|
1890
|
-
case "gt":
|
|
1891
|
-
return compareToValue > value;
|
|
1892
|
-
case "gte":
|
|
1893
|
-
return compareToValue >= value;
|
|
1894
|
-
case "lt":
|
|
1895
|
-
return compareToValue < value;
|
|
1896
|
-
case "lte":
|
|
1897
|
-
return compareToValue <= value;
|
|
1898
|
-
case "eqValue":
|
|
1899
|
-
return compareToValue === value;
|
|
1900
|
-
}
|
|
1901
|
-
}
|
|
1902
|
-
#setValue(value) {
|
|
1903
|
-
const safeValue = toSafeValue(value) || "0";
|
|
1904
|
-
this.bigIntValue = this.#toBigInt(safeValue);
|
|
1905
|
-
}
|
|
1906
|
-
#retrievePrecisionDecimal(...args) {
|
|
1907
|
-
const decimals = args.map((arg) => {
|
|
1908
|
-
const isObject = typeof arg === "object";
|
|
1909
|
-
const value = isObject ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier) : getFloatDecimals(toSafeValue(arg));
|
|
1910
|
-
return value;
|
|
1911
|
-
}).filter(Boolean);
|
|
1912
|
-
return Math.max(...decimals, DEFAULT_DECIMAL);
|
|
1913
|
-
}
|
|
1914
|
-
#toBigInt(value, decimal) {
|
|
1915
|
-
const multiplier = decimal ? toMultiplier(decimal) : this.decimalMultiplier;
|
|
1916
|
-
const padDecimal = decimalFromMultiplier(multiplier);
|
|
1917
|
-
const [integerPart = "", decimalPart = ""] = value.split(".");
|
|
1918
|
-
return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, "0")}`);
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
var numberFormatter = Intl.NumberFormat("fullwide", {
|
|
1922
|
-
useGrouping: false,
|
|
1923
|
-
maximumFractionDigits: 20
|
|
1924
|
-
});
|
|
1925
|
-
|
|
1926
|
-
// src/modules/swapKitNumber.ts
|
|
1927
|
-
class SwapKitNumber extends BigIntArithmetics {
|
|
1928
|
-
eq(value) {
|
|
1929
|
-
return this.eqValue(value);
|
|
1930
|
-
}
|
|
1931
|
-
static fromBigInt(value, decimal) {
|
|
1932
|
-
return new SwapKitNumber({
|
|
1933
|
-
decimal,
|
|
1934
|
-
value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
|
|
1935
|
-
});
|
|
1936
|
-
}
|
|
1937
|
-
}
|
|
1938
|
-
|
|
1939
|
-
// src/modules/assetValue.ts
|
|
1940
|
-
function getMinAmountByChain(chain) {
|
|
1941
|
-
const asset2 = AssetValue.fromChainOrSignature(chain);
|
|
1942
|
-
switch (chain) {
|
|
1943
|
-
case Chain.Bitcoin:
|
|
1944
|
-
case Chain.Litecoin:
|
|
1945
|
-
case Chain.BitcoinCash:
|
|
1946
|
-
return asset2.set(0.00010001);
|
|
1947
|
-
case Chain.Dogecoin:
|
|
1948
|
-
return asset2.set(1.00000001);
|
|
1949
|
-
case Chain.Avalanche:
|
|
1950
|
-
case Chain.Ethereum:
|
|
1951
|
-
return asset2.set(0.00000001);
|
|
1952
|
-
case Chain.THORChain:
|
|
1953
|
-
case Chain.Maya:
|
|
1954
|
-
return asset2.set(0);
|
|
1955
|
-
case Chain.Cosmos:
|
|
1956
|
-
return asset2.set(0.000001);
|
|
1957
|
-
default:
|
|
1958
|
-
return asset2.set(0.00000001);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
async function createAssetValue(identifier, value = 0) {
|
|
1962
|
-
validateIdentifier(identifier);
|
|
1963
|
-
const staticToken = staticTokensMap.get(identifier.toUpperCase());
|
|
1964
|
-
const decimal = staticToken?.decimal || await getDecimal(getAssetInfo(identifier));
|
|
1965
|
-
if (!staticToken) {
|
|
1966
|
-
staticTokensMap.set(identifier.toUpperCase(), { identifier, decimal });
|
|
1967
|
-
}
|
|
1968
|
-
return new AssetValue({ decimal, value: safeValue(value, decimal), identifier });
|
|
1969
|
-
}
|
|
1970
|
-
var createSyntheticAssetValue = function(identifier, value = 0) {
|
|
1971
|
-
const [synthChain, symbol] = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
|
|
1972
|
-
if (!(synthChain && symbol))
|
|
1973
|
-
throw new Error("Invalid asset identifier");
|
|
1974
|
-
return new AssetValue({
|
|
1975
|
-
decimal: 8,
|
|
1976
|
-
value: safeValue(value, 8),
|
|
1977
|
-
identifier: `${Chain.THORChain}.${synthChain}/${symbol}`
|
|
1978
|
-
});
|
|
1979
|
-
};
|
|
1980
|
-
var safeValue = function(value, decimal) {
|
|
1981
|
-
return typeof value === "bigint" ? formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }) : value;
|
|
1982
|
-
};
|
|
1983
|
-
var getAssetInfo = function(identifier) {
|
|
1984
|
-
const isSynthetic = identifier.slice(0, 14).includes("/");
|
|
1985
|
-
const isThorchain = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain;
|
|
1986
|
-
const isMaya = identifier.split(".")?.[0]?.toUpperCase() === Chain.Maya;
|
|
1987
|
-
const [synthChain, synthSymbol = ""] = isThorchain || isMaya ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
|
|
1988
|
-
if (isSynthetic && !(synthChain && synthSymbol))
|
|
1989
|
-
throw new Error("Invalid asset identifier");
|
|
1990
|
-
const adjustedIdentifier = identifier.includes(".") && !isSynthetic ? identifier : `${isMaya ? Chain.Maya : Chain.THORChain}.${synthSymbol}`;
|
|
1991
|
-
const [chain, ...rest] = adjustedIdentifier.split(".");
|
|
1992
|
-
const symbol = isSynthetic ? synthSymbol : rest.join(".");
|
|
1993
|
-
const splitSymbol = symbol.split("-");
|
|
1994
|
-
const ticker = splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-");
|
|
1995
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
1996
|
-
return {
|
|
1997
|
-
address: address?.toLowerCase(),
|
|
1998
|
-
chain,
|
|
1999
|
-
isGasAsset: isGasAsset({ chain, symbol }),
|
|
2000
|
-
isSynthetic,
|
|
2001
|
-
symbol: (isSynthetic ? `${synthChain}/` : "") + (address ? `${ticker}-${address?.toLowerCase() ?? ""}` : symbol),
|
|
2002
|
-
ticker
|
|
2003
|
-
};
|
|
2004
|
-
};
|
|
2005
|
-
var staticTokensMap = new Map;
|
|
2006
|
-
|
|
2007
|
-
class AssetValue extends BigIntArithmetics {
|
|
2008
|
-
address;
|
|
2009
|
-
chain;
|
|
2010
|
-
isGasAsset = false;
|
|
2011
|
-
isSynthetic = false;
|
|
2012
|
-
symbol;
|
|
2013
|
-
tax;
|
|
2014
|
-
ticker;
|
|
2015
|
-
type;
|
|
2016
|
-
chainId;
|
|
2017
|
-
constructor({
|
|
2018
|
-
value,
|
|
2019
|
-
decimal,
|
|
2020
|
-
tax,
|
|
2021
|
-
chain,
|
|
2022
|
-
symbol,
|
|
2023
|
-
identifier
|
|
2024
|
-
}) {
|
|
2025
|
-
super(typeof value === "object" ? value : { decimal, value });
|
|
2026
|
-
const assetInfo = getAssetInfo(identifier || `${chain}.${symbol}`);
|
|
2027
|
-
this.type = getAssetType(assetInfo);
|
|
2028
|
-
this.tax = tax;
|
|
2029
|
-
this.chain = assetInfo.chain;
|
|
2030
|
-
this.ticker = assetInfo.ticker;
|
|
2031
|
-
this.symbol = assetInfo.symbol;
|
|
2032
|
-
this.address = assetInfo.address;
|
|
2033
|
-
this.isSynthetic = assetInfo.isSynthetic;
|
|
2034
|
-
this.isGasAsset = assetInfo.isGasAsset;
|
|
2035
|
-
this.chainId = ChainToChainId[assetInfo.chain];
|
|
2036
|
-
}
|
|
2037
|
-
toString() {
|
|
2038
|
-
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
2039
|
-
}
|
|
2040
|
-
toUrl() {
|
|
2041
|
-
return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
|
|
2042
|
-
}
|
|
2043
|
-
eqAsset({ chain, symbol }) {
|
|
2044
|
-
return this.chain === chain && this.symbol === symbol;
|
|
2045
|
-
}
|
|
2046
|
-
eq(assetValue) {
|
|
2047
|
-
return this.eqAsset(assetValue) && this.eqValue(assetValue);
|
|
2048
|
-
}
|
|
2049
|
-
static fromUrl(urlAsset, value = 0) {
|
|
2050
|
-
const [chain, ticker, symbol] = urlAsset.split(".");
|
|
2051
|
-
if (!(chain && ticker))
|
|
2052
|
-
throw new Error("Invalid asset url");
|
|
2053
|
-
const assetString = chain === Chain.THORChain && symbol ? `${chain}.${ticker}/${symbol}` : urlAsset;
|
|
2054
|
-
return createAssetValue(assetString, value);
|
|
2055
|
-
}
|
|
2056
|
-
static fromString(assetString, value = 0) {
|
|
2057
|
-
return createAssetValue(assetString, value);
|
|
2058
|
-
}
|
|
2059
|
-
static fromIdentifier(assetString, value = 0) {
|
|
2060
|
-
return createAssetValue(assetString, value);
|
|
2061
|
-
}
|
|
2062
|
-
static fromStringSync(assetString, value = 0) {
|
|
2063
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2064
|
-
const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
|
|
2065
|
-
if (isSynthetic)
|
|
2066
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2067
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2068
|
-
decimal: BaseDecimal[chain],
|
|
2069
|
-
identifier: assetString
|
|
2070
|
-
};
|
|
2071
|
-
return new AssetValue({
|
|
2072
|
-
tax,
|
|
2073
|
-
value: safeValue(value, decimal),
|
|
2074
|
-
identifier: isSynthetic ? assetString : identifier,
|
|
2075
|
-
decimal: isSynthetic ? 8 : decimal
|
|
2076
|
-
});
|
|
2077
|
-
}
|
|
2078
|
-
static async fromStringWithBase(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
|
|
2079
|
-
const shiftedAmount = BigIntArithmetics.shiftDecimals({
|
|
2080
|
-
value: SwapKitNumber.fromBigInt(BigInt(value)),
|
|
2081
|
-
from: 0,
|
|
2082
|
-
to: baseDecimal
|
|
2083
|
-
}).getBaseValue("string");
|
|
2084
|
-
const assetValue = await AssetValue.fromString(assetString, value);
|
|
2085
|
-
return assetValue.set(shiftedAmount);
|
|
2086
|
-
}
|
|
2087
|
-
static fromStringWithBaseSync(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
|
|
2088
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2089
|
-
const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
|
|
2090
|
-
if (isSynthetic)
|
|
2091
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2092
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2093
|
-
decimal: BaseDecimal[chain],
|
|
2094
|
-
identifier: assetString
|
|
2095
|
-
};
|
|
2096
|
-
return new AssetValue({
|
|
2097
|
-
tax,
|
|
2098
|
-
value: safeValue(BigInt(value), baseDecimal),
|
|
2099
|
-
identifier,
|
|
2100
|
-
decimal
|
|
2101
|
-
});
|
|
2102
|
-
}
|
|
2103
|
-
static fromIdentifierSync(assetString, value = 0) {
|
|
2104
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2105
|
-
const tokenInfo = staticTokensMap.get(assetString);
|
|
2106
|
-
if (isSynthetic)
|
|
2107
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2108
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2109
|
-
decimal: BaseDecimal[chain],
|
|
2110
|
-
identifier: assetString
|
|
2111
|
-
};
|
|
2112
|
-
return new AssetValue({ tax, decimal, identifier, value: safeValue(value, decimal) });
|
|
2113
|
-
}
|
|
2114
|
-
static fromChainOrSignature(assetString, value = 0) {
|
|
2115
|
-
const { decimal, identifier } = getCommonAssetInfo(assetString);
|
|
2116
|
-
return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });
|
|
2117
|
-
}
|
|
2118
|
-
static loadStaticAssets() {
|
|
2119
|
-
return new Promise((resolve, reject) => {
|
|
2120
|
-
try {
|
|
2121
|
-
import("@swapkit/tokens").then((tokenPackages) => {
|
|
2122
|
-
for (const tokenList of Object.values(tokenPackages)) {
|
|
2123
|
-
for (const { identifier, chain, ...rest } of tokenList.tokens) {
|
|
2124
|
-
staticTokensMap.set(identifier.toUpperCase(), {
|
|
2125
|
-
identifier,
|
|
2126
|
-
decimal: "decimals" in rest ? rest.decimals : BaseDecimal[chain]
|
|
2127
|
-
});
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
resolve({ ok: true });
|
|
2131
|
-
});
|
|
2132
|
-
} catch (error) {
|
|
2133
|
-
console.error(error);
|
|
2134
|
-
reject({
|
|
2135
|
-
ok: false,
|
|
2136
|
-
error,
|
|
2137
|
-
message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
|
|
2138
|
-
});
|
|
2139
|
-
}
|
|
2140
|
-
});
|
|
2141
|
-
}
|
|
2142
|
-
}
|
|
2143
|
-
|
|
2144
|
-
// src/modules/requestClient.ts
|
|
2145
|
-
import ky from "ky";
|
|
2146
|
-
function setRequestClientConfig({ apiKey, ...config }) {
|
|
2147
|
-
kyClientConfig = { ...config, apiKey };
|
|
2148
|
-
}
|
|
2149
|
-
var getKyClient = function() {
|
|
2150
|
-
const { apiKey, ...config } = kyClientConfig;
|
|
2151
|
-
return ky.create({
|
|
2152
|
-
...config,
|
|
2153
|
-
headers: { ...defaultRequestHeaders, ...config.headers, "x-api-key": apiKey }
|
|
2154
|
-
});
|
|
2155
|
-
};
|
|
2156
|
-
var kyClientConfig = {};
|
|
2157
|
-
var defaultRequestHeaders = typeof window !== "undefined" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" };
|
|
2158
|
-
var getTypedBaseRequestClient = (ky2) => ({
|
|
2159
|
-
get: async (url, options) => (await ky2.get(url, options)).json(),
|
|
2160
|
-
post: async (url, options) => (await ky2.post(url, options)).json()
|
|
2161
|
-
});
|
|
2162
|
-
var RequestClient = {
|
|
2163
|
-
...getTypedBaseRequestClient(getKyClient()),
|
|
2164
|
-
extend: (options) => {
|
|
2165
|
-
const extendedClient = getKyClient().extend(options);
|
|
2166
|
-
return {
|
|
2167
|
-
...getTypedBaseRequestClient(extendedClient),
|
|
2168
|
-
extend: RequestClient.extend
|
|
2169
|
-
};
|
|
2170
|
-
}
|
|
2171
|
-
};
|
|
2172
|
-
|
|
2173
|
-
// src/helpers/asset.ts
|
|
2174
|
-
async function findAssetBy(params) {
|
|
2175
|
-
const tokenPackages = await import("@swapkit/tokens");
|
|
2176
|
-
for (const tokenList of Object.values(tokenPackages)) {
|
|
2177
|
-
for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) {
|
|
2178
|
-
if ("identifier" in params && identifier === params.identifier) {
|
|
2179
|
-
return identifier;
|
|
2180
|
-
}
|
|
2181
|
-
if ("address" in rest && "chain" in params && tokenChain === params.chain && rest.address.toLowerCase() === params.contract.toLowerCase())
|
|
2182
|
-
return identifier;
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
return;
|
|
2186
|
-
}
|
|
2187
|
-
var getDecimalMethodHex = "0x313ce567";
|
|
2188
|
-
var getContractDecimals = async ({ chain, to }) => {
|
|
2189
|
-
try {
|
|
2190
|
-
const { result } = await RequestClient.post(ChainToRPC[chain], {
|
|
2191
|
-
headers: {
|
|
2192
|
-
accept: "*/*",
|
|
2193
|
-
"content-type": "application/json",
|
|
2194
|
-
"cache-control": "no-cache"
|
|
2195
|
-
},
|
|
2196
|
-
body: JSON.stringify({
|
|
2197
|
-
id: 44,
|
|
2198
|
-
jsonrpc: "2.0",
|
|
2199
|
-
method: "eth_call",
|
|
2200
|
-
params: [{ to: to.toLowerCase(), data: getDecimalMethodHex }, "latest"]
|
|
2201
|
-
})
|
|
2202
|
-
});
|
|
2203
|
-
return Number.parseInt(BigInt(result || BaseDecimal[chain]).toString());
|
|
2204
|
-
} catch (error) {
|
|
2205
|
-
console.error(error);
|
|
2206
|
-
return BaseDecimal[chain];
|
|
2207
|
-
}
|
|
2208
|
-
};
|
|
2209
|
-
var getRadixResourceDecimals = async ({ symbol }) => {
|
|
2210
|
-
try {
|
|
2211
|
-
const resourceAddress = symbol.split("-")[1]?.toLowerCase();
|
|
2212
|
-
const { manager } = await RequestClient.post(`${ChainToRPC[Chain.Radix]}/state/resource`, {
|
|
2213
|
-
headers: {
|
|
2214
|
-
Accept: "*/*",
|
|
2215
|
-
"Content-Type": "application/json"
|
|
2216
|
-
},
|
|
2217
|
-
body: JSON.stringify({
|
|
2218
|
-
network: "mainnet",
|
|
2219
|
-
resource_address: resourceAddress
|
|
2220
|
-
})
|
|
2221
|
-
});
|
|
2222
|
-
return manager.divisibility.value.divisibility;
|
|
2223
|
-
} catch (error) {
|
|
2224
|
-
console.error(error);
|
|
2225
|
-
return BaseDecimal[Chain.Radix];
|
|
2226
|
-
}
|
|
2227
|
-
};
|
|
2228
|
-
var getETHAssetDecimal = (symbol) => {
|
|
2229
|
-
if (symbol === Chain.Ethereum)
|
|
2230
|
-
return BaseDecimal.ETH;
|
|
2231
|
-
const splitSymbol = symbol.split("-");
|
|
2232
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1]?.toLowerCase();
|
|
2233
|
-
return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Ethereum, to: address }) : BaseDecimal.ETH;
|
|
2234
|
-
};
|
|
2235
|
-
var getAVAXAssetDecimal = (symbol) => {
|
|
2236
|
-
const splitSymbol = symbol.split("-");
|
|
2237
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
2238
|
-
return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Avalanche, to: address.toLowerCase() }) : BaseDecimal.AVAX;
|
|
2239
|
-
};
|
|
2240
|
-
var getBSCAssetDecimal = (symbol) => {
|
|
2241
|
-
if (symbol === Chain.BinanceSmartChain)
|
|
2242
|
-
return BaseDecimal.BSC;
|
|
2243
|
-
return BaseDecimal.BSC;
|
|
2244
|
-
};
|
|
2245
|
-
var getRadixAssetDecimal = (symbol) => {
|
|
2246
|
-
if (symbol === Chain.Radix)
|
|
2247
|
-
return BaseDecimal.XRD;
|
|
2248
|
-
return getRadixResourceDecimals({ symbol });
|
|
2249
|
-
};
|
|
2250
|
-
var getDecimal = ({ chain, symbol }) => {
|
|
2251
|
-
switch (chain) {
|
|
2252
|
-
case Chain.Ethereum:
|
|
2253
|
-
return getETHAssetDecimal(symbol);
|
|
2254
|
-
case Chain.Avalanche:
|
|
2255
|
-
return getAVAXAssetDecimal(symbol);
|
|
2256
|
-
case Chain.BinanceSmartChain:
|
|
2257
|
-
return getBSCAssetDecimal(symbol);
|
|
2258
|
-
case Chain.Radix:
|
|
2259
|
-
return getRadixAssetDecimal(symbol);
|
|
2260
|
-
default:
|
|
2261
|
-
return BaseDecimal[chain];
|
|
2262
|
-
}
|
|
2263
|
-
};
|
|
2264
|
-
var getGasAsset = ({ chain }) => {
|
|
2265
|
-
switch (chain) {
|
|
2266
|
-
case Chain.Arbitrum:
|
|
2267
|
-
case Chain.Optimism:
|
|
2268
|
-
return AssetValue.fromStringSync(`${chain}.ETH`);
|
|
2269
|
-
case Chain.Maya:
|
|
2270
|
-
return AssetValue.fromStringSync(`${chain}.CACAO`);
|
|
2271
|
-
case Chain.Cosmos:
|
|
2272
|
-
return AssetValue.fromStringSync(`${chain}.ATOM`);
|
|
2273
|
-
case Chain.BinanceSmartChain:
|
|
2274
|
-
return AssetValue.fromStringSync(`${chain}.BNB`);
|
|
2275
|
-
case Chain.THORChain:
|
|
2276
|
-
return AssetValue.fromStringSync(`${chain}.RUNE`);
|
|
2277
|
-
default:
|
|
2278
|
-
return AssetValue.fromStringSync(`${chain}.${chain}`);
|
|
2279
|
-
}
|
|
2280
|
-
};
|
|
2281
|
-
var isGasAsset = ({ chain, symbol }) => {
|
|
2282
|
-
switch (chain) {
|
|
2283
|
-
case Chain.Arbitrum:
|
|
2284
|
-
case Chain.Optimism:
|
|
2285
|
-
return symbol === "ETH";
|
|
2286
|
-
case Chain.Maya:
|
|
2287
|
-
return symbol === "CACAO";
|
|
2288
|
-
case Chain.Cosmos:
|
|
2289
|
-
return symbol === "ATOM";
|
|
2290
|
-
case Chain.BinanceSmartChain:
|
|
2291
|
-
return symbol === "BNB";
|
|
2292
|
-
case Chain.THORChain:
|
|
2293
|
-
return symbol === "RUNE";
|
|
2294
|
-
default:
|
|
2295
|
-
return symbol === chain;
|
|
2296
|
-
}
|
|
2297
|
-
};
|
|
2298
|
-
var getCommonAssetInfo = (assetString) => {
|
|
2299
|
-
switch (assetString) {
|
|
2300
|
-
case `${Chain.Ethereum}.THOR`:
|
|
2301
|
-
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
2302
|
-
case `${Chain.Ethereum}.vTHOR`:
|
|
2303
|
-
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
2304
|
-
case Chain.Arbitrum:
|
|
2305
|
-
return { identifier: `${Chain.Arbitrum}.ETH`, decimal: BaseDecimal[assetString] };
|
|
2306
|
-
case Chain.Optimism:
|
|
2307
|
-
return { identifier: `${Chain.Optimism}.ETH`, decimal: BaseDecimal[assetString] };
|
|
2308
|
-
case Chain.Cosmos:
|
|
2309
|
-
return { identifier: "GAIA.ATOM", decimal: BaseDecimal[assetString] };
|
|
2310
|
-
case Chain.THORChain:
|
|
2311
|
-
return { identifier: "THOR.RUNE", decimal: BaseDecimal[assetString] };
|
|
2312
|
-
case Chain.BinanceSmartChain:
|
|
2313
|
-
return { identifier: "BSC.BNB", decimal: BaseDecimal[assetString] };
|
|
2314
|
-
case Chain.Maya:
|
|
2315
|
-
return { identifier: "MAYA.CACAO", decimal: BaseDecimal.MAYA };
|
|
2316
|
-
case `${Chain.Maya}.MAYA`:
|
|
2317
|
-
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
2318
|
-
case `${Chain.Kujira}.USK`:
|
|
2319
|
-
return { identifier: `${Chain.Kujira}.USK`, decimal: 6 };
|
|
2320
|
-
case Chain.Radix:
|
|
2321
|
-
return { identifier: `${Chain.Radix}.XRD`, decimal: BaseDecimal.XRD };
|
|
2322
|
-
default:
|
|
2323
|
-
return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };
|
|
2324
|
-
}
|
|
2325
|
-
};
|
|
2326
|
-
var getAssetType = ({ chain, symbol }) => {
|
|
2327
|
-
if (symbol.includes("/"))
|
|
2328
|
-
return "Synth";
|
|
2329
|
-
switch (chain) {
|
|
2330
|
-
case Chain.Cosmos:
|
|
2331
|
-
return symbol === "ATOM" ? "Native" : Chain.Cosmos;
|
|
2332
|
-
case Chain.Kujira:
|
|
2333
|
-
return symbol === Chain.Kujira ? "Native" : Chain.Kujira;
|
|
2334
|
-
case Chain.Binance:
|
|
2335
|
-
return symbol === Chain.Binance ? "Native" : "BEP2";
|
|
2336
|
-
case Chain.BinanceSmartChain:
|
|
2337
|
-
return symbol === Chain.Binance ? "Native" : "BEP20";
|
|
2338
|
-
case Chain.Ethereum:
|
|
2339
|
-
return symbol === Chain.Ethereum ? "Native" : "ERC20";
|
|
2340
|
-
case Chain.Avalanche:
|
|
2341
|
-
return symbol === Chain.Avalanche ? "Native" : Chain.Avalanche;
|
|
2342
|
-
case Chain.Polygon:
|
|
2343
|
-
return symbol === Chain.Polygon ? "Native" : "POLYGON";
|
|
2344
|
-
case Chain.Arbitrum:
|
|
2345
|
-
return [Chain.Ethereum, Chain.Arbitrum].includes(symbol) ? "Native" : "ARBITRUM";
|
|
2346
|
-
case Chain.Optimism:
|
|
2347
|
-
return [Chain.Ethereum, Chain.Optimism].includes(symbol) ? "Native" : "OPTIMISM";
|
|
2348
|
-
case Chain.Radix:
|
|
2349
|
-
return symbol === Chain.Radix ? "Native" : "RADIX";
|
|
2350
|
-
default:
|
|
2351
|
-
return "Native";
|
|
2352
|
-
}
|
|
2353
|
-
};
|
|
2354
|
-
var assetFromString = (assetString) => {
|
|
2355
|
-
const [chain, ...symbolArray] = assetString.split(".");
|
|
2356
|
-
const synth = assetString.includes("/");
|
|
2357
|
-
const symbol = symbolArray.join(".");
|
|
2358
|
-
const splitSymbol = symbol?.split("-");
|
|
2359
|
-
const ticker = splitSymbol?.length ? splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-") : undefined;
|
|
2360
|
-
return { chain, symbol, ticker, synth };
|
|
2361
|
-
};
|
|
2362
|
-
var potentialScamRegex = new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, "gmi");
|
|
2363
|
-
var evmAssetHasAddress = (assetString) => {
|
|
2364
|
-
const [chain, symbol] = assetString.split(".");
|
|
2365
|
-
if (!EVMChains.includes(chain))
|
|
2366
|
-
return true;
|
|
2367
|
-
const splitSymbol = symbol.split("-");
|
|
2368
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
2369
|
-
return isGasAsset({ chain, symbol }) || !!address;
|
|
2370
|
-
};
|
|
2371
|
-
var filterAssets = (tokens2) => tokens2.filter(({ chain, value, symbol }) => {
|
|
2372
|
-
const assetString = `${chain}.${symbol}`;
|
|
2373
|
-
return !potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== "0";
|
|
2374
|
-
});
|
|
2375
|
-
// src/helpers/derivationPath.ts
|
|
2376
|
-
function getDerivationPathFor({ chain, index, addressIndex = 0, type }) {
|
|
2377
|
-
if (EVMChains.includes(chain)) {
|
|
2378
|
-
if (type === "legacy")
|
|
2379
|
-
return [44, 60, 0, index];
|
|
2380
|
-
if (type === "ledgerLive")
|
|
2381
|
-
return [44, 60, index, 0, addressIndex];
|
|
2382
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
2383
|
-
}
|
|
2384
|
-
if ([Chain.Bitcoin, Chain.Litecoin].includes(chain)) {
|
|
2385
|
-
const chainId = chain === Chain.Bitcoin ? 0 : 2;
|
|
2386
|
-
if (type === "nativeSegwitMiddleAccount")
|
|
2387
|
-
return [84, chainId, index, 0, addressIndex];
|
|
2388
|
-
if (type === "segwit")
|
|
2389
|
-
return [49, chainId, 0, 0, index];
|
|
2390
|
-
if (type === "legacy")
|
|
2391
|
-
return [44, chainId, 0, 0, index];
|
|
2392
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
2393
|
-
}
|
|
2394
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
2395
|
-
}
|
|
2396
|
-
function getWalletFormatFor(path) {
|
|
2397
|
-
const [_, purpose, chainId] = path.split("/").map((p) => Number.parseInt(p, 10));
|
|
2398
|
-
if (chainId === 145)
|
|
2399
|
-
;
|
|
2400
|
-
switch (purpose) {
|
|
2401
|
-
case 44:
|
|
2402
|
-
return "legacy";
|
|
2403
|
-
case 49:
|
|
2404
|
-
return "p2sh";
|
|
2405
|
-
default:
|
|
2406
|
-
return "bech32";
|
|
2407
|
-
}
|
|
2408
|
-
}
|
|
2409
|
-
var updatedLastIndex = (path, index) => [
|
|
2410
|
-
...path.slice(0, path.length - 1),
|
|
2411
|
-
index
|
|
2412
|
-
];
|
|
2413
|
-
// src/helpers/liquidity.ts
|
|
2414
|
-
function getAsymmetricRuneShare({
|
|
2415
|
-
liquidityUnits,
|
|
2416
|
-
poolUnits,
|
|
2417
|
-
runeDepth
|
|
2418
|
-
}) {
|
|
2419
|
-
const s = toTCSwapKitNumber(liquidityUnits);
|
|
2420
|
-
const T = toTCSwapKitNumber(poolUnits);
|
|
2421
|
-
const A = toTCSwapKitNumber(runeDepth);
|
|
2422
|
-
const part1 = s.mul(A);
|
|
2423
|
-
const part2 = T.mul(T).mul(2);
|
|
2424
|
-
const part3 = T.mul(s).mul(2);
|
|
2425
|
-
const part4 = s.mul(s);
|
|
2426
|
-
const part5 = T.mul(T).mul(T);
|
|
2427
|
-
const numerator = part1.mul(part2.sub(part3).add(part4));
|
|
2428
|
-
return numerator.div(part5);
|
|
2429
|
-
}
|
|
2430
|
-
function getAsymmetricAssetShare({
|
|
2431
|
-
liquidityUnits,
|
|
2432
|
-
poolUnits,
|
|
2433
|
-
assetDepth
|
|
2434
|
-
}) {
|
|
2435
|
-
const s = toTCSwapKitNumber(liquidityUnits);
|
|
2436
|
-
const T = toTCSwapKitNumber(poolUnits);
|
|
2437
|
-
const A = toTCSwapKitNumber(assetDepth);
|
|
2438
|
-
const part1 = s.mul(A);
|
|
2439
|
-
const part2 = T.mul(T).mul(2);
|
|
2440
|
-
const part3 = T.mul(s).mul(2);
|
|
2441
|
-
const part4 = s.mul(s);
|
|
2442
|
-
const numerator = part1.mul(part2.sub(part3).add(part4));
|
|
2443
|
-
const part5 = T.mul(T).mul(T);
|
|
2444
|
-
return numerator.div(part5);
|
|
2445
|
-
}
|
|
2446
|
-
function getAsymmetricRuneWithdrawAmount({
|
|
2447
|
-
percent,
|
|
2448
|
-
runeDepth,
|
|
2449
|
-
liquidityUnits,
|
|
2450
|
-
poolUnits
|
|
2451
|
-
}) {
|
|
2452
|
-
return getAsymmetricRuneShare({ runeDepth, liquidityUnits, poolUnits }).mul(percent);
|
|
2453
|
-
}
|
|
2454
|
-
function getAsymmetricAssetWithdrawAmount({
|
|
2455
|
-
percent,
|
|
2456
|
-
assetDepth,
|
|
2457
|
-
liquidityUnits,
|
|
2458
|
-
poolUnits
|
|
2459
|
-
}) {
|
|
2460
|
-
return getAsymmetricAssetShare({ assetDepth, liquidityUnits, poolUnits }).mul(percent);
|
|
2461
|
-
}
|
|
2462
|
-
var toTCSwapKitNumber = function(value) {
|
|
2463
|
-
return SwapKitNumber.fromBigInt(BigInt(value), BaseDecimal.THOR);
|
|
2464
|
-
};
|
|
2465
|
-
function getSymmetricPoolShare({
|
|
2466
|
-
liquidityUnits,
|
|
2467
|
-
poolUnits,
|
|
2468
|
-
runeDepth,
|
|
2469
|
-
assetDepth
|
|
2470
|
-
}) {
|
|
2471
|
-
return {
|
|
2472
|
-
assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),
|
|
2473
|
-
runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits)
|
|
2474
|
-
};
|
|
2475
|
-
}
|
|
2476
|
-
function getSymmetricWithdraw({
|
|
2477
|
-
liquidityUnits,
|
|
2478
|
-
poolUnits,
|
|
2479
|
-
runeDepth,
|
|
2480
|
-
assetDepth,
|
|
2481
|
-
percent
|
|
2482
|
-
}) {
|
|
2483
|
-
return Object.fromEntries(Object.entries(getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth })).map(([name, value]) => [name, value.mul(percent)]));
|
|
2484
|
-
}
|
|
2485
|
-
function getEstimatedPoolShare({
|
|
2486
|
-
runeDepth,
|
|
2487
|
-
poolUnits,
|
|
2488
|
-
assetDepth,
|
|
2489
|
-
liquidityUnits,
|
|
2490
|
-
runeAmount,
|
|
2491
|
-
assetAmount
|
|
2492
|
-
}) {
|
|
2493
|
-
const R = new SwapKitNumber({ value: runeDepth, decimal: 8 });
|
|
2494
|
-
const A = new SwapKitNumber({ value: assetDepth, decimal: 8 });
|
|
2495
|
-
const P = new SwapKitNumber({ value: poolUnits, decimal: 8 });
|
|
2496
|
-
const runeAddAmount = new SwapKitNumber({ value: runeAmount, decimal: 8 });
|
|
2497
|
-
const assetAddAmount = new SwapKitNumber({ value: assetAmount, decimal: 8 });
|
|
2498
|
-
const rA = runeAddAmount.mul(A);
|
|
2499
|
-
const aR = assetAddAmount.mul(R);
|
|
2500
|
-
const ra = runeAddAmount.mul(assetAddAmount);
|
|
2501
|
-
const RA = R.mul(A);
|
|
2502
|
-
const numerator = P.mul(rA.add(aR.add(ra.mul(2))));
|
|
2503
|
-
const denominator = rA.add(aR.add(RA.mul(2)));
|
|
2504
|
-
const liquidityUnitsAfterAdd = numerator.div(denominator);
|
|
2505
|
-
const estimatedLiquidityUnits = toTCSwapKitNumber(liquidityUnits).add(liquidityUnitsAfterAdd);
|
|
2506
|
-
if (liquidityUnitsAfterAdd.getBaseValue("number") === 0) {
|
|
2507
|
-
return estimatedLiquidityUnits.div(P).getBaseValue("number");
|
|
2508
|
-
}
|
|
2509
|
-
const newPoolUnits = P.add(estimatedLiquidityUnits);
|
|
2510
|
-
return estimatedLiquidityUnits.div(newPoolUnits).getBaseValue("number");
|
|
2511
|
-
}
|
|
2512
|
-
function getLiquiditySlippage({
|
|
2513
|
-
runeAmount,
|
|
2514
|
-
assetAmount,
|
|
2515
|
-
runeDepth,
|
|
2516
|
-
assetDepth
|
|
2517
|
-
}) {
|
|
2518
|
-
if (runeAmount === "0" || assetAmount === "0" || runeDepth === "0" || assetDepth === "0")
|
|
2519
|
-
return 0;
|
|
2520
|
-
const R = toTCSwapKitNumber(runeDepth);
|
|
2521
|
-
const T = toTCSwapKitNumber(assetDepth);
|
|
2522
|
-
const assetAddAmount = toTCSwapKitNumber(assetAmount);
|
|
2523
|
-
const runeAddAmount = toTCSwapKitNumber(runeAmount);
|
|
2524
|
-
const numerator = assetAddAmount.mul(R).sub(T.mul(runeAddAmount));
|
|
2525
|
-
const denominator = T.mul(runeAddAmount).add(R.mul(T));
|
|
2526
|
-
return Math.abs(numerator.div(denominator).getBaseValue("number"));
|
|
2527
|
-
}
|
|
2528
|
-
// src/helpers/memo.ts
|
|
2529
|
-
var getMemoFor = (memoType, options) => {
|
|
2530
|
-
switch (memoType) {
|
|
2531
|
-
case MemoType.LEAVE:
|
|
2532
|
-
case MemoType.BOND: {
|
|
2533
|
-
const { address } = options;
|
|
2534
|
-
return `${memoType}:${address}`;
|
|
2535
|
-
}
|
|
2536
|
-
case MemoType.UNBOND: {
|
|
2537
|
-
const { address, unbondAmount } = options;
|
|
2538
|
-
return `${memoType}:${address}:${unbondAmount}`;
|
|
2539
|
-
}
|
|
2540
|
-
case MemoType.NAME_REGISTER: {
|
|
2541
|
-
const { name, chain, address, owner } = options;
|
|
2542
|
-
return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
|
|
2543
|
-
}
|
|
2544
|
-
case MemoType.DEPOSIT: {
|
|
2545
|
-
const { chain, symbol, address, singleSide } = options;
|
|
2546
|
-
const getPoolIdentifier = (chain2, symbol2) => {
|
|
2547
|
-
switch (chain2) {
|
|
2548
|
-
case Chain.Litecoin:
|
|
2549
|
-
return "l";
|
|
2550
|
-
case Chain.Dogecoin:
|
|
2551
|
-
return "d";
|
|
2552
|
-
case Chain.BitcoinCash:
|
|
2553
|
-
return "c";
|
|
2554
|
-
default:
|
|
2555
|
-
return `${chain2}.${symbol2}`;
|
|
2556
|
-
}
|
|
2557
|
-
};
|
|
2558
|
-
return singleSide ? `${memoType}:${chain}/${symbol}` : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || ""}`;
|
|
2559
|
-
}
|
|
2560
|
-
case MemoType.WITHDRAW: {
|
|
2561
|
-
const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } = options;
|
|
2562
|
-
const shortenedSymbol = chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
|
|
2563
|
-
const target = !singleSide && targetAssetString ? `:${targetAssetString}` : "";
|
|
2564
|
-
const assetDivider = singleSide ? "/" : ".";
|
|
2565
|
-
return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
|
|
2566
|
-
}
|
|
2567
|
-
case MemoType.OPEN_LOAN:
|
|
2568
|
-
case MemoType.CLOSE_LOAN: {
|
|
2569
|
-
const { asset: asset2, address } = options;
|
|
2570
|
-
return `${memoType}:${asset2}:${address}`;
|
|
2571
|
-
}
|
|
2572
|
-
default:
|
|
2573
|
-
return "";
|
|
2574
|
-
}
|
|
2575
|
-
};
|
|
2576
|
-
// src/modules/swapKitError.ts
|
|
2577
|
-
var errorMessages = {
|
|
2578
|
-
core_wallet_connection_not_found: 10001,
|
|
2579
|
-
core_estimated_max_spendable_chain_not_supported: 10002,
|
|
2580
|
-
core_extend_error: 10003,
|
|
2581
|
-
core_inbound_data_not_found: 10004,
|
|
2582
|
-
core_approve_asset_address_or_from_not_found: 10005,
|
|
2583
|
-
core_plugin_not_found: 10006,
|
|
2584
|
-
core_plugin_swap_not_found: 10007,
|
|
2585
|
-
core_approve_asset_target_invalid: 10008,
|
|
2586
|
-
core_chain_halted: 10099,
|
|
2587
|
-
core_wallet_xdefi_not_installed: 10101,
|
|
2588
|
-
core_wallet_evmwallet_not_installed: 10102,
|
|
2589
|
-
core_wallet_walletconnect_not_installed: 10103,
|
|
2590
|
-
core_wallet_keystore_not_installed: 10104,
|
|
2591
|
-
core_wallet_ledger_not_installed: 10105,
|
|
2592
|
-
core_wallet_trezor_not_installed: 10106,
|
|
2593
|
-
core_wallet_keplr_not_installed: 10107,
|
|
2594
|
-
core_wallet_okx_not_installed: 10108,
|
|
2595
|
-
core_wallet_keepkey_not_installed: 10109,
|
|
2596
|
-
core_swap_invalid_params: 10200,
|
|
2597
|
-
core_swap_route_not_complete: 10201,
|
|
2598
|
-
core_swap_asset_not_recognized: 10202,
|
|
2599
|
-
core_swap_contract_not_found: 10203,
|
|
2600
|
-
core_swap_route_transaction_not_found: 10204,
|
|
2601
|
-
core_swap_contract_not_supported: 10205,
|
|
2602
|
-
core_swap_transaction_error: 10206,
|
|
2603
|
-
core_swap_quote_mode_not_supported: 10207,
|
|
2604
|
-
core_transaction_deposit_error: 10301,
|
|
2605
|
-
core_transaction_create_liquidity_rune_error: 10302,
|
|
2606
|
-
core_transaction_create_liquidity_asset_error: 10303,
|
|
2607
|
-
core_transaction_create_liquidity_invalid_params: 10304,
|
|
2608
|
-
core_transaction_add_liquidity_invalid_params: 10305,
|
|
2609
|
-
core_transaction_add_liquidity_no_rune_address: 10306,
|
|
2610
|
-
core_transaction_add_liquidity_rune_error: 10307,
|
|
2611
|
-
core_transaction_add_liquidity_asset_error: 10308,
|
|
2612
|
-
core_transaction_withdraw_error: 10309,
|
|
2613
|
-
core_transaction_deposit_to_pool_error: 10310,
|
|
2614
|
-
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
2615
|
-
core_transaction_deposit_gas_error: 10312,
|
|
2616
|
-
core_transaction_invalid_sender_address: 10313,
|
|
2617
|
-
core_transaction_deposit_server_error: 10314,
|
|
2618
|
-
core_transaction_user_rejected: 10315,
|
|
2619
|
-
core_transaction_create_liquidity_cacao_error: 10316,
|
|
2620
|
-
core_transaction_add_liquidity_no_cacao_address: 10306,
|
|
2621
|
-
core_transaction_add_liquidity_cacao_error: 10307,
|
|
2622
|
-
wallet_ledger_connection_error: 20001,
|
|
2623
|
-
wallet_ledger_connection_claimed: 20002,
|
|
2624
|
-
wallet_ledger_get_address_error: 20003,
|
|
2625
|
-
wallet_ledger_device_not_found: 20004,
|
|
2626
|
-
wallet_ledger_device_locked: 20005,
|
|
2627
|
-
chainflip_channel_error: 30001,
|
|
2628
|
-
chainflip_broker_recipient_error: 30002,
|
|
2629
|
-
api_v2_invalid_response: 40001,
|
|
2630
|
-
helpers_number_different_decimals: 99101
|
|
2631
|
-
};
|
|
2632
|
-
|
|
2633
|
-
class SwapKitError extends Error {
|
|
2634
|
-
constructor(errorKey, sourceError) {
|
|
2635
|
-
if (sourceError) {
|
|
2636
|
-
console.error(sourceError, {
|
|
2637
|
-
stack: sourceError?.stack,
|
|
2638
|
-
message: sourceError?.message
|
|
2639
|
-
});
|
|
2640
|
-
}
|
|
2641
|
-
super(errorKey, {
|
|
2642
|
-
cause: { code: errorMessages[errorKey], message: errorKey }
|
|
2643
|
-
});
|
|
2644
|
-
Object.setPrototypeOf(this, SwapKitError.prototype);
|
|
2645
|
-
}
|
|
2646
|
-
}
|
|
2647
|
-
|
|
2648
|
-
// src/helpers/others.ts
|
|
2649
|
-
function getTHORNameCost(numberOfYears) {
|
|
2650
|
-
if (numberOfYears < 0)
|
|
2651
|
-
throw new Error("Invalid number of years");
|
|
2652
|
-
return 10 + numberOfYears;
|
|
2653
|
-
}
|
|
2654
|
-
function getMAYANameCost(numberOfYears) {
|
|
2655
|
-
if (numberOfYears < 0)
|
|
2656
|
-
throw new Error("Invalid number of year");
|
|
2657
|
-
return Math.round((10 + numberOfYears * 1.0512) * 10000000000) / 10000000000;
|
|
2658
|
-
}
|
|
2659
|
-
function derivationPathToString([network3, chainId, account, change, index]) {
|
|
2660
|
-
const shortPath = typeof index !== "number";
|
|
2661
|
-
return `m/${network3}'/${chainId}'/${account}'/${change}${shortPath ? "" : `/${index}`}`;
|
|
2662
|
-
}
|
|
2663
|
-
function wrapWithThrow(fn, errorKey) {
|
|
2664
|
-
try {
|
|
2665
|
-
return fn();
|
|
2666
|
-
} catch (error) {
|
|
2667
|
-
if (errorKey) {
|
|
2668
|
-
throw new SwapKitError(errorKey, error);
|
|
2669
|
-
}
|
|
2670
|
-
return console.error(error);
|
|
2671
|
-
}
|
|
2672
|
-
}
|
|
2673
|
-
var getChainIdentifier = (chain) => {
|
|
2674
|
-
switch (chain) {
|
|
2675
|
-
case Chain.THORChain:
|
|
2676
|
-
return `${chain}.RUNE`;
|
|
2677
|
-
case Chain.Cosmos:
|
|
2678
|
-
return `${chain}.ATOM`;
|
|
2679
|
-
case Chain.BinanceSmartChain:
|
|
2680
|
-
return `${chain}`;
|
|
2681
|
-
default:
|
|
2682
|
-
return `${chain}.${chain}`;
|
|
2683
|
-
}
|
|
2684
|
-
};
|
|
2685
|
-
// src/helpers/web3wallets.ts
|
|
2686
|
-
function getEIP6963Wallets() {
|
|
2687
|
-
const providers = [];
|
|
2688
|
-
function onAnnouncement(event) {
|
|
2689
|
-
if (providers.map((p) => p.info.uuid).includes(event.detail.info.uuid))
|
|
2690
|
-
return;
|
|
2691
|
-
providers.push(event.detail);
|
|
2692
|
-
}
|
|
2693
|
-
window.addEventListener("eip6963:announceProvider", onAnnouncement);
|
|
2694
|
-
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
2695
|
-
function removeEIP6963EventListener() {
|
|
2696
|
-
window.removeEventListener("eip6963:announceProvider", onAnnouncement);
|
|
2697
|
-
}
|
|
2698
|
-
return { providers, removeEIP6963EventListener };
|
|
2699
|
-
}
|
|
2700
|
-
var methodsToWrap = [
|
|
2701
|
-
"approve",
|
|
2702
|
-
"approvedAmount",
|
|
2703
|
-
"call",
|
|
2704
|
-
"sendTransaction",
|
|
2705
|
-
"transfer",
|
|
2706
|
-
"isApproved",
|
|
2707
|
-
"approvedAmount",
|
|
2708
|
-
"EIP1193SendTransaction",
|
|
2709
|
-
"getFeeData",
|
|
2710
|
-
"broadcastTransaction",
|
|
2711
|
-
"estimateCall",
|
|
2712
|
-
"estimateGasLimit",
|
|
2713
|
-
"estimateGasPrices",
|
|
2714
|
-
"createContractTxObject"
|
|
2715
|
-
];
|
|
2716
|
-
var wrapMethodWithNetworkSwitch = (func, provider, chainId) => async (...args) => {
|
|
2717
|
-
try {
|
|
2718
|
-
await switchEVMWalletNetwork(provider, chainId);
|
|
2719
|
-
} catch (error) {
|
|
2720
|
-
throw new Error(`Failed to switch network: ${error}`);
|
|
2721
|
-
}
|
|
2722
|
-
return func(...args);
|
|
2723
|
-
};
|
|
2724
|
-
var providerRequest = ({ provider, params, method }) => {
|
|
2725
|
-
if (!provider?.send)
|
|
2726
|
-
throw new Error("Provider not found");
|
|
2727
|
-
const providerParams = params ? Array.isArray(params) ? params : [params] : [];
|
|
2728
|
-
return provider.send(method, providerParams);
|
|
2729
|
-
};
|
|
2730
|
-
var prepareNetworkSwitch = ({
|
|
2731
|
-
toolbox,
|
|
2732
|
-
chainId,
|
|
2733
|
-
provider = window.ethereum
|
|
2734
|
-
}) => {
|
|
2735
|
-
const wrappedMethods = methodsToWrap.reduce((object, methodName) => {
|
|
2736
|
-
if (!toolbox[methodName])
|
|
2737
|
-
return object;
|
|
2738
|
-
const method = toolbox[methodName];
|
|
2739
|
-
if (typeof method !== "function")
|
|
2740
|
-
return object;
|
|
2741
|
-
return {
|
|
2742
|
-
...object,
|
|
2743
|
-
[methodName]: wrapMethodWithNetworkSwitch(method, provider, chainId)
|
|
2744
|
-
};
|
|
2745
|
-
}, {});
|
|
2746
|
-
return { ...toolbox, ...wrappedMethods };
|
|
2747
|
-
};
|
|
2748
|
-
var addEVMWalletNetwork = (provider, networkParams) => providerRequest({ provider, method: "wallet_addEthereumChain", params: [networkParams] });
|
|
2749
|
-
var switchEVMWalletNetwork = (provider, chainId = ChainId.EthereumHex) => providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] });
|
|
2750
|
-
var addAccountsChangedCallback = (callback) => {
|
|
2751
|
-
window.ethereum?.on("accountsChanged", () => callback());
|
|
2752
|
-
window.xfi?.ethereum.on("accountsChanged", () => callback());
|
|
2753
|
-
};
|
|
2754
|
-
var getETHDefaultWallet = () => {
|
|
2755
|
-
const { isTrust, isBraveWallet, __XDEFI, overrideIsMetaMask, selectedProvider } = window?.ethereum || {};
|
|
2756
|
-
if (isTrust)
|
|
2757
|
-
return WalletOption.TRUSTWALLET_WEB;
|
|
2758
|
-
if (isBraveWallet)
|
|
2759
|
-
return WalletOption.BRAVE;
|
|
2760
|
-
if (overrideIsMetaMask && selectedProvider?.isCoinbaseWallet)
|
|
2761
|
-
return WalletOption.COINBASE_WEB;
|
|
2762
|
-
if (__XDEFI)
|
|
2763
|
-
WalletOption.XDEFI;
|
|
2764
|
-
return WalletOption.METAMASK;
|
|
2765
|
-
};
|
|
2766
|
-
var isDetected = (walletOption) => {
|
|
2767
|
-
return listWeb3EVMWallets().includes(walletOption);
|
|
2768
|
-
};
|
|
2769
|
-
var listWeb3EVMWallets = () => {
|
|
2770
|
-
const metamaskEnabled = window?.ethereum && !window.ethereum?.isBraveWallet;
|
|
2771
|
-
const xdefiEnabled = window?.xfi || window?.ethereum?.__XDEFI;
|
|
2772
|
-
const braveEnabled = window?.ethereum?.isBraveWallet;
|
|
2773
|
-
const trustEnabled = window?.ethereum?.isTrust || window?.trustwallet;
|
|
2774
|
-
const coinbaseEnabled = window?.ethereum?.overrideIsMetaMask && window?.ethereum?.selectedProvider?.isCoinbaseWallet || window?.coinbaseWalletExtension;
|
|
2775
|
-
const wallets = [];
|
|
2776
|
-
if (metamaskEnabled)
|
|
2777
|
-
wallets.push(WalletOption.METAMASK);
|
|
2778
|
-
if (xdefiEnabled)
|
|
2779
|
-
wallets.push(WalletOption.XDEFI);
|
|
2780
|
-
if (braveEnabled)
|
|
2781
|
-
wallets.push(WalletOption.BRAVE);
|
|
2782
|
-
if (trustEnabled)
|
|
2783
|
-
wallets.push(WalletOption.TRUSTWALLET_WEB);
|
|
2784
|
-
if (coinbaseEnabled)
|
|
2785
|
-
wallets.push(WalletOption.COINBASE_WEB);
|
|
2786
|
-
if (okxMobileEnabled())
|
|
2787
|
-
wallets.push(WalletOption.OKX_MOBILE);
|
|
2788
|
-
return wallets;
|
|
2789
|
-
};
|
|
2790
|
-
var okxMobileEnabled = () => {
|
|
2791
|
-
const ua = navigator.userAgent;
|
|
2792
|
-
const isIOS = /iphone|ipad|ipod|ios/i.test(ua);
|
|
2793
|
-
const isAndroid = /android|XiaoMi|MiuiBrowser/i.test(ua);
|
|
2794
|
-
const isMobile = isIOS || isAndroid;
|
|
2795
|
-
const isOKApp = /OKApp/i.test(ua);
|
|
2796
|
-
return isMobile && isOKApp;
|
|
2797
|
-
};
|
|
2798
|
-
var isWeb3Detected = () => typeof window.ethereum !== "undefined";
|
|
2799
|
-
export {
|
|
2800
|
-
wrapWithThrow,
|
|
2801
|
-
wrapMethodWithNetworkSwitch,
|
|
2802
|
-
validateTNS,
|
|
2803
|
-
validateIdentifier,
|
|
2804
|
-
switchEVMWalletNetwork,
|
|
2805
|
-
setRequestClientConfig,
|
|
2806
|
-
prepareNetworkSwitch,
|
|
2807
|
-
okxMobileEnabled,
|
|
2808
|
-
listWeb3EVMWallets,
|
|
2809
|
-
isWeb3Detected,
|
|
2810
|
-
isGasAsset,
|
|
2811
|
-
isDetected,
|
|
2812
|
-
getWalletFormatFor,
|
|
2813
|
-
getTHORNameCost,
|
|
2814
|
-
getSymmetricWithdraw,
|
|
2815
|
-
getSymmetricPoolShare,
|
|
2816
|
-
getMinAmountByChain,
|
|
2817
|
-
getMemoFor,
|
|
2818
|
-
getMAYANameCost,
|
|
2819
|
-
getLiquiditySlippage,
|
|
2820
|
-
getGasAsset,
|
|
2821
|
-
getEstimatedPoolShare,
|
|
2822
|
-
getETHDefaultWallet,
|
|
2823
|
-
getEIP6963Wallets,
|
|
2824
|
-
getDerivationPathFor,
|
|
2825
|
-
getDecimal,
|
|
2826
|
-
getCommonAssetInfo,
|
|
2827
|
-
getChainIdentifier,
|
|
2828
|
-
getAsymmetricRuneWithdrawAmount,
|
|
2829
|
-
getAsymmetricRuneShare,
|
|
2830
|
-
getAsymmetricAssetWithdrawAmount,
|
|
2831
|
-
getAsymmetricAssetShare,
|
|
2832
|
-
getAssetType,
|
|
2833
|
-
formatBigIntToSafeValue,
|
|
2834
|
-
findAssetBy,
|
|
2835
|
-
filterAssets,
|
|
2836
|
-
erc20ABI,
|
|
2837
|
-
derivationPathToString,
|
|
2838
|
-
defaultRequestHeaders,
|
|
2839
|
-
assetFromString,
|
|
2840
|
-
addEVMWalletNetwork,
|
|
2841
|
-
addAccountsChangedCallback,
|
|
2842
|
-
WarningCodeEnum,
|
|
2843
|
-
WalletOption,
|
|
2844
|
-
UTXOChains,
|
|
2845
|
-
TCSupportedChains,
|
|
2846
|
-
TCEthereumVaultAbi,
|
|
2847
|
-
TCBscDepositABI,
|
|
2848
|
-
TCAvalancheDepositABI,
|
|
2849
|
-
SwapKitNumber,
|
|
2850
|
-
SwapKitError,
|
|
2851
|
-
SubstrateChains,
|
|
2852
|
-
SWAP_OUT,
|
|
2853
|
-
SWAP_IN,
|
|
2854
|
-
RouteQuoteWarningSchema,
|
|
2855
|
-
RouteQuoteSchema,
|
|
2856
|
-
RouteQuoteMetadataSchema,
|
|
2857
|
-
RouteQuoteMetadataAssetSchema,
|
|
2858
|
-
RouteQuoteLegSchema,
|
|
2859
|
-
RouteLegWithoutAddressesSchema,
|
|
2860
|
-
RouteLegSchema,
|
|
2861
|
-
RequestClient,
|
|
2862
|
-
RPCUrl,
|
|
2863
|
-
QuoteResponseSchema,
|
|
2864
|
-
QuoteRequestSchema,
|
|
2865
|
-
QuoteMode,
|
|
2866
|
-
ProviderName,
|
|
2867
|
-
NetworkDerivationPath,
|
|
2868
|
-
MemoType,
|
|
2869
|
-
MayaEthereumVaultAbi,
|
|
2870
|
-
MayaArbitrumVaultAbi,
|
|
2871
|
-
MAYASupportedChains,
|
|
2872
|
-
LedgerErrorCode,
|
|
2873
|
-
FeesSchema,
|
|
2874
|
-
FeeTypeEnum,
|
|
2875
|
-
FeeOption,
|
|
2876
|
-
ExplorerUrl,
|
|
2877
|
-
EstimatedTimeSchema,
|
|
2878
|
-
EVMTransactionDetailsSchema,
|
|
2879
|
-
EVMTransactionDetailsParamsSchema,
|
|
2880
|
-
EVMChains,
|
|
2881
|
-
DerivationPath,
|
|
2882
|
-
CosmosChains,
|
|
2883
|
-
ContractAddress,
|
|
2884
|
-
ChainToRPC,
|
|
2885
|
-
ChainToHexChainId,
|
|
2886
|
-
ChainToExplorerUrl,
|
|
2887
|
-
ChainToChainId,
|
|
2888
|
-
ChainIdToChain,
|
|
2889
|
-
ChainId,
|
|
2890
|
-
Chain,
|
|
2891
|
-
BigIntArithmetics,
|
|
2892
|
-
BaseDecimal,
|
|
2893
|
-
AssetValue,
|
|
2894
|
-
ApproveMode,
|
|
2895
|
-
AGG_SWAP
|
|
2896
|
-
};
|
|
2897
|
-
|
|
2898
|
-
//# debugId=CB95B9DB311FB99D64756e2164756e21
|
|
3
|
+
//# debugId=46055CFCF1A3F05D64756E2164756E21
|