@swapkit/helpers 1.0.0-rc.98 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2440
- package/dist/index.js.map +24 -23
- package/package.json +7 -14
- package/src/helpers/__tests__/asset.test.ts +40 -8
- package/src/helpers/__tests__/memo.test.ts +55 -74
- package/src/helpers/__tests__/others.test.ts +5 -3
- package/src/helpers/asset.ts +80 -26
- package/src/helpers/derivationPath.ts +5 -4
- package/src/helpers/memo.ts +157 -46
- package/src/helpers/others.ts +27 -2
- package/src/helpers/validators.ts +8 -3
- package/src/helpers/web3wallets.ts +34 -4
- package/src/modules/__tests__/assetValue.test.ts +183 -114
- package/src/modules/assetValue.ts +143 -101
- package/src/modules/bigIntArithmetics.ts +2 -6
- package/src/modules/requestClient.ts +22 -12
- package/src/modules/swapKitError.ts +78 -21
- package/src/types/chains.ts +12 -18
- package/src/types/commonTypes.ts +4 -0
- package/src/types/derivationPath.ts +4 -2
- package/src/types/errors/apiV1.ts +0 -0
- package/src/types/index.ts +2 -0
- package/src/types/network.ts +5 -3
- package/src/types/quotes.ts +391 -0
- package/src/types/radix.ts +14 -0
- package/src/types/sdk.ts +87 -5
- package/src/types/tokens.ts +18 -14
- package/src/types/wallet.ts +44 -19
package/dist/index.js
CHANGED
|
@@ -1,2441 +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 He=[{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 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 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"}],_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 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"}],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 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"}],Xe=[{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["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(s){s["Arbitrum"]="https://arbiscan.io";s["Avalanche"]="https://snowtrace.io";s["BinanceSmartChain"]="https://bscscan.com";s["Bitcoin"]="https://blockchair.com/bitcoin";s["BitcoinCash"]="https://www.blockchair.com/bitcoin-cash";s["Chainflip"]="https://explorer.polkascan.io/polkadot";s["Cosmos"]="https://www.mintscan.io/cosmos";s["Dash"]="https://blockchair.com/dash";s["Dogecoin"]="https://blockchair.com/dogecoin";s["Ethereum"]="https://etherscan.io";s["Kujira"]="https://finder.kujira.network/kaiyo-1";s["Litecoin"]="https://blockchair.com/litecoin";s["Maya"]="https://www.mayascan.org";s["Optimism"]="https://optimistic.etherscan.io";s["Polkadot"]="https://polkadot.subscan.io";s["Polygon"]="https://polygonscan.com";s["Radix"]="https://dashboard.radixdlt.com";s["THORChain"]="https://runescan.io";s["Solana"]="https://solscan.io"})(Q||(Q={}));var y;(function(s){s["Arbitrum"]="ARB";s["Avalanche"]="AVAX";s["BinanceSmartChain"]="BSC";s["Bitcoin"]="BTC";s["BitcoinCash"]="BCH";s["Cosmos"]="GAIA";s["Dash"]="DASH";s["Dogecoin"]="DOGE";s["Ethereum"]="ETH";s["Kujira"]="KUJI";s["Litecoin"]="LTC";s["Maya"]="MAYA";s["Optimism"]="OP";s["Polkadot"]="DOT";s["Chainflip"]="FLIP";s["Polygon"]="MATIC";s["Radix"]="XRD";s["THORChain"]="THOR";s["Solana"]="SOL"})(y||(y={}));var o;(function(T){T["Arbitrum"]="42161";T["ArbitrumHex"]="0xa4b1";T["Avalanche"]="43114";T["AvalancheHex"]="0xa86a";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"})(o||(o={}));var ke={[o.ArbitrumHex]:y.Arbitrum,[o.Arbitrum]:y.Arbitrum,[o.AvalancheHex]:y.Avalanche,[o.Avalanche]:y.Avalanche,[o.BinanceSmartChainHex]:y.BinanceSmartChain,[o.BinanceSmartChain]:y.BinanceSmartChain,[o.BitcoinCash]:y.BitcoinCash,[o.Bitcoin]:y.Bitcoin,[o.Chainflip]:y.Chainflip,[o.Cosmos]:y.Cosmos,[o.Dash]:y.Dash,[o.Dogecoin]:y.Dogecoin,[o.EthereumHex]:y.Ethereum,[o.Kujira]:y.Kujira,[o.Ethereum]:y.Ethereum,[o.Litecoin]:y.Litecoin,[o.MayaStagenet]:y.Maya,[o.Maya]:y.Maya,[o.OptimismHex]:y.Optimism,[o.Optimism]:y.Optimism,[o.Polkadot]:y.Polkadot,[o.PolygonHex]:y.Polygon,[o.Polygon]:y.Polygon,[o.Radix]:y.Radix,[o.THORChainStagenet]:y.THORChain,[o.THORChain]:y.THORChain,[o.Solana]:y.Solana},On=Object.keys(y),V=Object.values(y),j;(function(f){f[f["ARB"]=18]="ARB";f[f["AVAX"]=18]="AVAX";f[f["BCH"]=8]="BCH";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"})(j||(j={}));var Re=[y.Polkadot,y.Chainflip],W=[y.Ethereum,y.Avalanche,y.BinanceSmartChain,y.Arbitrum,y.Optimism,y.Polygon],Ye=[y.Bitcoin,y.BitcoinCash,y.Dash,y.Dogecoin,y.Litecoin],Le=[y.Cosmos,y.THORChain,y.Maya,y.Kujira],Oe=[y.Avalanche,y.BinanceSmartChain,y.Bitcoin,y.BitcoinCash,y.Cosmos,y.Dogecoin,y.Ethereum,y.Litecoin,y.THORChain],be=[y.Arbitrum,y.Dash,y.Ethereum,y.Kujira,y.Maya,y.THORChain],l=V.reduce((n,e)=>{const t=On.find((p)=>y[p]===e);if(t)n[e]=t;return n},{}),dn=V.reduce((n,e)=>{return n[e]=o[l[e]],n},{}),D=V.reduce((n,e)=>{return n[e]=M[l[e]],n},{}),ge=V.reduce((n,e)=>{const t=`${l[e]}Hex`;return n[e]=o[t],n},{}),qe=V.reduce((n,e)=>{return n[e]=Q[l[e]],n},{});var X;(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"})(X||(X={}));var Ve=[X.ETH_TO_ETH,X.AVAX_TO_AVAX,X.BSC_TO_BSC],Ne=[X.ETH_TO_TC_SUPPORTED,X.ETH_TO_AVAX,X.ETH_TO_BSC,X.AVAX_TO_TC_SUPPORTED,X.AVAX_TO_ETH,X.AVAX_TO_BSC,X.BSC_TO_TC_SUPPORTED,X.BSC_TO_ETH,X.BSC_TO_AVAX],Ae=[X.TC_SUPPORTED_TO_TC_SUPPORTED,X.TC_SUPPORTED_TO_ETH,X.TC_SUPPORTED_TO_AVAX,X.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(s){s["ARB"]="m/44'/60'/0'/0";s["AVAX"]="m/44'/60'/0'/0";s["BCH"]="m/44'/145'/0'/0";s["BSC"]="m/44'/60'/0'/0";s["BTC"]="m/84'/0'/0'/0";s["DASH"]="m/44'/5'/0'/0";s["DOGE"]="m/44'/3'/0'/0";s["DOT"]="////";s["ETH"]="m/44'/60'/0'/0";s["FLIP"]="////";s["GAIA"]="m/44'/118'/0'/0";s["KUJI"]="m/44'/118'/0'/0";s["LTC"]="m/84'/2'/0'/0";s["MATIC"]="m/44'/60'/0'/0";s["MAYA"]="m/44'/931'/0'/0";s["OP"]="m/44'/60'/0'/0";s["SOL"]="m/44'/501'/0'/0";s["THOR"]="m/44'/931'/0'/0";s["XRD"]="////"})(rn||(rn={}));var E={ARB:[44,60,0,0,0],AVAX:[44,60,0,0,0],BCH:[44,145,0,0,0],BSC:[44,60,0,0,0],BTC:[84,0,0,0,0],DASH:[44,5,0,0,0],DOGE:[44,3,0,0,0],ETH:[44,60,0,0,0],GAIA:[44,118,0,0,0],KUJI:[44,118,0,0,0],LTC:[84,2,0,0,0],MATIC:[44,60,0,0,0],MAYA:[44,931,0,0,0],OP:[44,60,0,0,0],SOL:[44,501,0,0,0],THOR:[44,931,0,0,0],XRD:[0,0,0,0,0],DOT:[0,0,0,0,0],FLIP:[0,0,0,0,0]};var k;(function(s){s["BRAVE"]="BRAVE";s["COINBASE_MOBILE"]="COINBASE_MOBILE";s["COINBASE_WEB"]="COINBASE_WEB";s["EIP6963"]="EIP6963";s["EXODUS"]="EXODUS";s["KEEPKEY"]="KEEPKEY";s["KEPLR"]="KEPLR";s["KEYSTORE"]="KEYSTORE";s["LEDGER"]="LEDGER";s["METAMASK"]="METAMASK";s["OKX"]="OKX";s["OKX_MOBILE"]="OKX_MOBILE";s["PHANTOM"]="PHANTOM";s["RADIX_WALLET"]="RADIX_WALLET";s["TREZOR"]="TREZOR";s["TALISMAN"]="TALISMAN";s["TRUSTWALLET_WEB"]="TRUSTWALLET_WEB";s["WALLETCONNECT"]="WALLETCONNECT";s["XDEFI"]="XDEFI"})(k||(k={}));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 J;(function(i){i["BOND"]="BOND";i["DEPOSIT"]="+";i["LEAVE"]="LEAVE";i["NAME_REGISTER"]="~";i["UNBOND"]="UNBOND";i["WITHDRAW"]="-";i["OPEN_LOAN"]="$+";i["CLOSE_LOAN"]="$-"})(J||(J={}));var We=$.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 a} from"zod";var h;(function(t){t["highSlippage"]="highSlippage";t["highPriceImpact"]="highPriceImpact"})(h||(h={}));var bn=a.array(a.union([a.string(),a.number(),a.array(a.string()),a.object({from:a.string(),value:a.string()}).describe("Parameters to pass to the contract method")])),fn=a.object({contractAddress:a.string({description:"Address of the contract to interact with"}),contractMethod:a.string({description:"Name of the method to call"}),contractParams:bn,contractParamNames:a.array(a.string({description:"Names of the parameters to pass to the contract method"})),approvalToken:a.optional(a.string({description:"Address of the token to approve spending of"})),approvalSpender:a.optional(a.string({description:"Address of the spender to approve"}))}),I=a.object({inbound:a.optional(a.number({description:"Time to receive inbound asset in seconds"})),swap:a.optional(a.number({description:"Time to swap assets in seconds"})),outbound:a.optional(a.number({description:"Time to receive outbound asset in seconds"})),total:a.number({description:"Total time in seconds"})}),O;(function(w){w["CHAINFLIP"]="CHAINFLIP";w["TRADERJOE_V1"]="TRADERJOE_V1";w["PANGOLIN_V1"]="PANGOLIN_V1";w["UNISWAP_V2"]="UNISWAP_V2";w["THORCHAIN"]="THORCHAIN";w["THORCHAIN_STREAMING"]="THORCHAIN_STREAMING";w["MAYACHAIN"]="MAYACHAIN";w["ONEINCH"]="ONEINCH";w["SUSHISWAP_V2"]="SUSHISWAP_V2";w["WOOFI_V2"]="WOOFI_V2";w["PANCAKESWAP"]="PANCAKESWAP"})(O||(O={}));var nn;(function(u){u["LIQUIDITY"]="liquidity";u["NETWORK"]="network";u["INBOUND"]="inbound";u["OUTBOUND"]="outbound";u["AFFILIATE"]="affiliate";u["TAX"]="tax"})(nn||(nn={}));var Hn=a.array(a.object({type:a.nativeEnum(nn),amount:a.string(),asset:a.string(),chain:a.string(),protocol:a.nativeEnum(O)})),gn=a.object({sellAsset:a.string({description:"Asset to sell"}),buyAsset:a.string({description:"Asset to buy"}),provider:a.nativeEnum(O),sourceAddress:a.string({description:"Source address"}),destinationAddress:a.string({description:"Destination address"}),estimatedTime:I.optional(),affiliate:a.string({description:"Affiliate address"}).optional(),affiliateFee:a.number({description:"Affiliate fee"}).optional(),slipPercentage:a.number({description:"Slippage as a percentage"})}),Ie=gn.omit({sourceAddress:!0,destinationAddress:!0,slipPercentage:!0}),qn=a.object({name:a.string({description:"Asset name"}),price:a.number({description:"Price in USD"}),image:a.string({description:"Asset image"})}),wn=a.object({priceImpact:a.number({description:"Price impact"}),assets:a.optional(a.array(qn))}),on=a.array(a.object({code:a.nativeEnum(h),display:a.string(),tooltip:a.string().optional()})),Kn=a.object({sellAsset:a.string({description:"Asset to sell"}),buyAsset:a.string({description:"Asset to buy"}),provider:a.nativeEnum(O),buyAmount:a.string({description:"Amount of asset to buy"}),buyAmountMaxSlippage:a.string({description:"Amount of asset to buy"}),sellAmount:a.string({description:"Amount of asset to sell"}),sourceAddress:a.string({description:"Source address"}),destinationAddress:a.string({description:"Destination address"}),slippageBps:a.number({description:"Slippage in bps"}),targetAddress:a.optional(a.string({description:"Target address for contract call or transfer address"})),inboundAddress:a.optional(a.string({description:"Inbound address"})),routerAddress:a.optional(a.string({description:"Inbound address"})),contractMethod:a.optional(a.string({description:"Contract method"})),fees:a.optional(Hn),estimatedTime:a.optional(I),memo:a.optional(a.string({description:"Memo"})),expiration:a.optional(a.string({description:"Expiration"}))}),Pe=a.object({providers:a.array(a.nativeEnum(O)),sellAsset:a.string({description:"Asset to sell"}),sellAmount:a.string({description:"sell amount"}),buyAsset:a.string({description:"Asset to buy"}),expectedBuyAmount:a.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:a.string({description:"Expected Buy amount max slippage"}),sourceAddress:a.string({description:"Source address"}),destinationAddress:a.string({description:"Destination address"}),targetAddress:a.optional(a.string({description:"Target address"})),routerAddress:a.optional(a.string({description:"Router address"})),inboundAddress:a.optional(a.string({description:"Inbound address"})),expiration:a.optional(a.string({description:"Expiration"})),memo:a.optional(a.string({description:"Memo"})),evmTransactionDetails:a.optional(fn),routePathArray:a.optional(a.array(a.string())),estimatedTime:a.optional(I),totalSlippageBps:a.number({description:"Total slippage in bps"}),legs:a.array(Kn),errorCode:a.optional(a.string()),warnings:on,meta:wn}),Vn=a.object({provider:a.nativeEnum(O),sellAsset:a.string({description:"Asset to sell"}),sellAmount:a.string({description:"Sell amount"}),buyAsset:a.string({description:"Asset to buy"}),buyAmount:a.string({description:"Buy amount"}),buyAmountMaxSlippage:a.string({description:"Buy amount max slippage"}),fees:a.optional(Hn)}),Nn=a.object({providers:a.array(a.nativeEnum(O)),sellAsset:a.string({description:"Asset to sell"}),sellAmount:a.string({description:"sell amount"}),buyAsset:a.string({description:"Asset to buy"}),expectedBuyAmount:a.string({description:"Expected Buy amount"}),expectedBuyAmountMaxSlippage:a.string({description:"Expected Buy amount max slippage"}),sourceAddress:a.string({description:"Source address"}),destinationAddress:a.string({description:"Destination address"}),targetAddress:a.optional(a.string({description:"Target address"})),expiration:a.optional(a.string({description:"Expiration"})),memo:a.optional(a.string({description:"Memo"})),evmTransactionDetails:a.optional(fn),estimatedTime:a.optional(I),totalSlippageBps:a.number({description:"Total slippage in bps"}),legs:a.array(Vn),warnings:on,meta:wn}),Se=a.object({quoteId:a.string({description:"Quote ID"}),routes:a.array(Nn),error:a.optional(a.string({description:"Error message"}))});var An={core_estimated_max_spendable_chain_not_supported:10002,core_extend_error:10003,core_inbound_data_not_found:10004,core_approve_asset_address_or_from_not_found:10005,core_plugin_not_found:10006,core_plugin_swap_not_found:10007,core_approve_asset_target_invalid:10008,core_explorer_unsupported_chain:10009,core_chain_halted:10099,core_wallet_connection_not_found:10100,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_missing_api_key:20001,wallet_chain_not_supported:20002,wallet_missing_params:20003,wallet_provider_not_found:20004,wallet_failed_to_add_or_switch_network:20005,wallet_ledger_connection_error:20101,wallet_ledger_connection_claimed:20102,wallet_ledger_get_address_error:20103,wallet_ledger_device_not_found:20104,wallet_ledger_device_locked:20105,wallet_phantom_not_found:20201,wallet_xdefi_not_found:20301,wallet_xdefi_send_transaction_no_address:20302,wallet_xdefi_contract_address_not_provided:20303,wallet_xdefi_asset_not_defined:20304,wallet_walletconnect_project_id_not_specified:20401,wallet_walletconnect_connection_not_established:20402,wallet_walletconnect_namespace_not_supported:20403,wallet_trezor_failed_to_sign_transaction:20501,wallet_trezor_derivation_path_not_supported:20502,wallet_trezor_failed_to_get_address:20503,wallet_talisman_not_enabled:20601,wallet_talisman_not_found:20602,chainflip_channel_error:30001,chainflip_unknown_asset:30002,chainflip_broker_invalid_params:30100,chainflip_broker_recipient_error:30101,chainflip_broker_register:30102,chainflip_broker_tx_error:30103,chainflip_broker_withdraw:30104,chainflip_broker_fund_only_flip_supported:30105,chainflip_broker_fund_invalid_address:30106,thorchain_chain_halted:40001,thorchain_trading_halted:40002,thorchain_swapin_router_required:40100,thorchain_swapin_vault_required:40101,thorchain_swapin_memo_required:40102,thorchain_swapin_token_required:40103,api_v2_invalid_response:50001,toolbox_cosmos_signer_not_defined:90101,toolbox_cosmos_no_accounts_found:90102,helpers_invalid_number_different_decimals:99000,helpers_invalid_number_of_years:99001,helpers_invalid_identifier:99002,helpers_invalid_asset_url:99003,helpers_invalid_asset_identifier:99004,helpers_invalid_memo_type:99005,helpers_failed_to_switch_network:99103,helpers_not_found_provider:99200};class z extends Error{static ErrorCode=An;constructor(n,e){const t=typeof n==="string",p=t?n:n.errorKey;if(e)console.error(e,{stack:e?.stack,message:e?.message});super(p,{cause:{code:z.ErrorCode[p],message:`${p}${t?"":`: ${JSON.stringify(n.info)}`}`}});Object.setPrototypeOf(this,z.prototype)}}function jn(n=""){const e=n.toUpperCase(),[t]=e.split(".");if(_n.includes(t))return!0;const[p]=e.split("/");if(_n.includes(p))return!0;throw new z({errorKey:"helpers_invalid_identifier",info:{message:`Invalid identifier: ${n}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`,identifier:n}})}function xt(n){if(n.length>30)return!1;const e=/^[a-zA-Z0-9+_-]+$/g;return!!n.match(e)}var _n=[...Object.values(y),"TERRA"];function q({value:n,bigIntDecimal:e=A,decimal:t=A}){if(t===0)return n.toString();const p=n<0n;let d=n.toString().substring(p?1:0);const r=t-(d.length-1);if(r>0)d="0".repeat(r)+d;const u=d.length-t;let x=d.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?"-":""}${d.slice(0,u)}.${x}`.replace(/\.?0*$/,"")}var P=function(n){const t=`${typeof n==="number"?Bn.format(n):en(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,A)},en=function(n){return typeof n==="object"?"getValue"in n?n.getValue("string"):n.value:n},A=8,g=(n)=>10n**BigInt(n),N=(n)=>Math.log10(Number.parseFloat(n.toString()));class b{decimalMultiplier=10n**8n;bigIntValue=0n;decimal;static fromBigInt(n,e){return new b({decimal:e,value:q({value:n,bigIntDecimal:e,decimal:e})})}static shiftDecimals({value:n,from:e,to:t}){return b.fromBigInt(n.getBaseValue("bigint")*g(t)/g(e),t)}constructor(n){const e=en(n),t=typeof n==="object";this.decimal=t?n.decimal:void 0,this.decimalMultiplier=t&&"decimalMultiplier"in n?n.decimalMultiplier:g(Math.max($n(P(e)),this.decimal||0)),this.#y(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||N(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/g(this.decimal||j.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=en(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||"",d=t||"";if((Number.parseInt(p)?p.length+d.length:d.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}.${d.slice(0,n-p.length)}`.padEnd(n-p.length,"0");const u=Number.parseInt(d),x=`${u}`.slice(0,n);return`0.${x.padStart(d.length-`${u}`.length+x.length,"0")}`}toFixed(n=6){const[e,t]=this.getValue("string").split("."),p=e||"",d=t||"";if(Number.parseInt(p))return`${p}.${d.slice(0,n)}`.padEnd(n,"0");const r=Number.parseInt(d),u=`${r}`.slice(0,n);return`0.${u.padStart(d.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),d=t[p];if(!d)return this.getValue("string");const r=10**(p*3);return`${(e/r).toFixed(n)}${d}`}toCurrency(n="$",{currencyPosition:e="start",decimal:t=2,decimalSeparator:p=".",thousandSeparator:d=","}={}){const r=this.getValue("number"),[u="",x=""]=r.toFixed(6).split("."),i=u.replace(/\B(?=(\d{3})+(?!\d))/g,d),_=u||x?u==="0"?`${Number.parseFloat(`0.${x}`)}`.replace(".",p):`${i}${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||A,p=Math.max(t,N(this.decimalMultiplier)),d=n<0n,r=n.toString().substring(d?1:0),u=p-(r.length-1),x=u>0?"0".repeat(u)+r:r,i=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`${d?"-":""}${x.slice(0,i)}.${_}`.replace(/\.?0*$/,"")}#e(n,...e){const t=this.#t(this,...e),p=Math.max(t,N(this.decimalMultiplier)),d=g(p),r=e.reduce((x,i)=>{const _=this.getBigIntValue(i,p);switch(n){case"add":return x+_;case"sub":return x-_;case"mul":return x*_/d;case"div":{if(_===0n)throw new RangeError("Division by zero");return x*d/_}default:return x}},this.bigIntValue*d/this.decimalMultiplier),u=q({bigIntDecimal:p,decimal:p,value:r});return new this.constructor({decimalMultiplier:g(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),d=this.getBigIntValue(this,t);switch(n){case"gt":return d>p;case"gte":return d>=p;case"lt":return d<p;case"lte":return d<=p;case"eqValue":return d===p}}#y(n){const e=P(n)||"0";this.bigIntValue=this.#p(e)}#t(...n){const e=n.map((t)=>{return typeof t==="object"?t.decimal||N(t.decimalMultiplier):$n(P(t))}).filter(Boolean);return Math.max(...e,A)}#p(n,e){const t=e?g(e):this.decimalMultiplier,p=N(t),[d="",r=""]=n.split(".");return BigInt(`${d}${r.padEnd(p,"0")}`)}}var Bn=Intl.NumberFormat("fullwide",{useGrouping:!1,maximumFractionDigits:20});function $t(n){const e=G.from({chain:n});switch(n){case y.Bitcoin:case y.Litecoin:case y.BitcoinCash:case y.Dash:return e.set(0.00010001);case y.Dogecoin:return e.set(1.00000001);case y.Avalanche:case y.Ethereum:case y.Arbitrum:case y.BinanceSmartChain:return e.set(0.00000001);case y.THORChain:case y.Maya:return e.set(0);case y.Cosmos:case y.Kujira:return e.set(0.000001);default:return e.set(0.00000001)}}async function Fn(n,e=0){jn(n);const t=S.get(n.toUpperCase()),p=t?.decimal||await Xn(tn(n));if(!t)S.set(n.toUpperCase(),{identifier:n,decimal:p});return new G({decimal:p,value:v(e,p),identifier:n})}var Mn=function(n,e=0){const[t,p]=n.split(".")?.[0]?.toUpperCase()===y.THORChain?n.split(".").slice(1).join().split("/"):n.split("/");if(!(t&&p))throw new z({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});return new G({decimal:8,value:v(e,8),identifier:`${y.THORChain}.${t}/${p}`})},v=function(n,e){return typeof n==="bigint"?q({value:n,bigIntDecimal:e,decimal:e}):n},tn=function(n){const e=n.slice(0,14).includes("/"),t=n.split(".")?.[0]?.toUpperCase()===y.THORChain,p=n.split(".")?.[0]?.toUpperCase()===y.Maya,[d,r=""]=t||p?n.split(".").slice(1).join().split("/"):n.split("/");if(e&&!(d&&r))throw new z({errorKey:"helpers_invalid_asset_identifier",info:{identifier:n}});const u=n.includes(".")&&!e?n:`${p?y.Maya:y.THORChain}.${r}`,[x,...i]=u.split("."),_=e?r:i.join("."),Z=_.split("-"),w=Z.length===1?Z[0]:Z.slice(0,-1).join("-"),L=Z.length===1?void 0:Z[Z.length-1];return{address:L?.toLowerCase(),chain:x,isGasAsset:pn({chain:x,symbol:_}),isSynthetic:e,ticker:w,symbol:(e?`${d}/`:"")+(L?`${w}-${L?.toLowerCase()??""}`:_)}},S=new Map;class G extends b{address;chain;isGasAsset=!1;isSynthetic=!1;symbol;tax;ticker;type;chainId;constructor({value:n,decimal:e,tax:t,chain:p,symbol:d,identifier:r}){super(typeof n==="object"?n:{decimal:e,value:n});const u=tn(r||`${p}.${d}`);this.type=Jn(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,d]=n.split(".");if(!(t&&p))throw new z({errorKey:"helpers_invalid_asset_url",info:{urlAsset:n}});const r=t===y.THORChain&&d?`${t}.${p}/${d}`:n;return G.from({asset:r,value:e})}static from({value:n=0,fromBaseDecimal:e,asyncTokenLookup:t,...p}){const d=n instanceof b?n.getValue("string"):n,r="chain"in p,u=r?p.chain:p.asset,x=r||Gn.includes(u),{identifier:i,decimal:_}=x?zn(u):{identifier:u,decimal:void 0},{chain:Z,isSynthetic:w}=tn(i),{tax:L,decimal:B,identifier:K}=S.get(i.toUpperCase())||{decimal:_||j[Z],identifier:i},F=e?v(BigInt(d),e):v(d,B);return t?Fn(K,e?F:d):w?Mn(K,d):new G({tax:L,decimal:B,identifier:K,value:F})}static loadStaticAssets(){return new Promise((n,e)=>{try{import("@swapkit/tokens").then((t)=>{for(let p of Object.values(t))for(let{identifier:d,chain:r,...u}of p.tokens)S.set(d.toUpperCase(),{identifier:d,decimal:"decimals"in u?u.decimals:j[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"})}})}static fromString(n,e=0){return G.from({asset:n,value:e,asyncTokenLookup:!0})}static fromIdentifier(n,e=0){return G.from({asset:n,value:e,asyncTokenLookup:!0})}static fromStringSync(n,e=0){return G.from({asset:n,value:e})}static fromStringWithBase(n,e=0n,t=j.THOR){return G.from({asyncTokenLookup:!0,asset:n,value:e,fromBaseDecimal:t})}static fromStringWithBaseSync(n,e=0n,t=j.THOR){return G.from({asset:n,value:e,fromBaseDecimal:t})}static fromIdentifierSync(n,e=0){return G.from({asset:n,value:e})}static fromChainOrSignature(n,e=0){if(n in y)return G.from({chain:n,value:e});return G.from({asset:n,value:e})}}import Qn from"ky";function zt({apiKey:n,...e}){Rn={...e,apiKey:n}}var Zn=function(){const{apiKey:n,...e}=Rn;return Qn.create({...e,headers:{...Wn,...e.headers,"x-api-key":n}})},Rn={},Wn=typeof window!=="undefined"?{}:{referrer:"https://sk.thorswap.net",referer:"https://sk.thorswap.net"},kn=(n)=>({get:async(e,t)=>(await n.get(e,t)).json(),post:async(e,t)=>(await n.post(e,t)).json()}),U={...kn(Zn()),extend:(n)=>{const e=Zn().extend(n);return{...kn(e),extend:U.extend}}};async function bt(n){const e=await import("@swapkit/tokens");for(let t of Object.values(e))for(let{identifier:p,chain:d,...r}of t.tokens){if("identifier"in n&&p===n.identifier)return p;if("address"in r&&"chain"in n&&d===n.chain&&r.address.toLowerCase()===n.contract.toLowerCase())return p}return}var ln="0x313ce567",Gn=[`${y.Maya}.MAYA`,`${y.Ethereum}.THOR`,`${y.Ethereum}.vTHOR`,`${y.Kujira}.USK`],Yn=async({chain:n,to:e})=>{try{const{result:t}=await U.post(D[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||j[n]).toString())}catch(t){return console.error(t),j[n]}},En=async({symbol:n})=>{try{const e=n.split("-")[1]?.toLowerCase(),{manager:t}=await U.post(`${D[y.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),j[y.Radix]}},In=(n)=>{if(n===y.Ethereum)return j.ETH;const e=n.split("-"),t=e.length===1?void 0:e[e.length-1]?.toLowerCase();return t?.startsWith("0x")?Yn({chain:y.Ethereum,to:t}):j.ETH},Pn=(n)=>{const e=n.split("-"),t=e.length===1?void 0:e[e.length-1];return t?.startsWith("0x")?Yn({chain:y.Avalanche,to:t.toLowerCase()}):j.AVAX},Sn=(n)=>{if(n===y.BinanceSmartChain)return j.BSC;return j.BSC},vn=(n)=>{if(n===y.Radix)return j.XRD;return En({symbol:n})},Xn=({chain:n,symbol:e})=>{switch(n){case y.Ethereum:return In(e);case y.Avalanche:return Pn(e);case y.BinanceSmartChain:return Sn(e);case y.Radix:return vn(e);default:return j[n]}},Yt=({chain:n})=>{switch(n){case y.Arbitrum:case y.Optimism:return G.from({asset:`${n}.ETH`});case y.Maya:return G.from({asset:`${n}.CACAO`});case y.Cosmos:return G.from({asset:`${n}.ATOM`});case y.BinanceSmartChain:return G.from({asset:`${n}.BNB`});case y.THORChain:return G.from({asset:`${n}.RUNE`});default:return G.from({asset:`${n}.${n}`})}},pn=({chain:n,symbol:e})=>{switch(n){case y.Arbitrum:case y.Optimism:return e==="ETH";case y.Maya:return e==="CACAO";case y.Cosmos:return e==="ATOM";case y.BinanceSmartChain:return e==="BNB";case y.THORChain:return e==="RUNE";default:return e===n}},zn=(n)=>{switch(n){case y.Arbitrum:case y.Optimism:return{identifier:`${n}.ETH`,decimal:j[n]};case`${y.Ethereum}.THOR`:return{identifier:"ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044",decimal:18};case`${y.Ethereum}.vTHOR`:return{identifier:"ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d",decimal:18};case y.Cosmos:return{identifier:`${n}.ATOM`,decimal:j[n]};case y.THORChain:return{identifier:`${n}.RUNE`,decimal:j[n]};case y.BinanceSmartChain:return{identifier:`${n}.BNB`,decimal:j[n]};case y.Maya:return{identifier:`${n}.CACAO`,decimal:j[n]};case y.Radix:return{identifier:`${y.Radix}.XRD`,decimal:j[n]};case`${y.Maya}.MAYA`:return{identifier:n,decimal:4};case`${y.Kujira}.USK`:return{identifier:n,decimal:6};default:return{identifier:`${n}.${n}`,decimal:j[n]}}},Jn=({chain:n,symbol:e})=>{if(e.includes("/"))return"Synth";switch(n){case y.Cosmos:return e==="ATOM"?"Native":y.Cosmos;case y.Kujira:return e===y.Kujira?"Native":y.Kujira;case y.BinanceSmartChain:return e==="BNB"?"Native":"BEP20";case y.Ethereum:return e===y.Ethereum?"Native":"ERC20";case y.Avalanche:return e===y.Avalanche?"Native":y.Avalanche;case y.Polygon:return e===y.Polygon?"Native":"POLYGON";case y.Arbitrum:return[y.Ethereum,y.Arbitrum].includes(e)?"Native":"ARBITRUM";case y.Optimism:return[y.Ethereum,y.Optimism].includes(e)?"Native":"OPTIMISM";case y.Radix:return e===y.Radix?"Native":"RADIX";default:return"Native"}},Lt=(n)=>{const[e,...t]=n.split("."),p=n.includes("/"),d=t.join("."),r=d?.split("-"),u=r?.length?r.length===1?r[0]:r.slice(0,-1).join("-"):void 0;return{chain:e,symbol:d,ticker:u,synth:p}},Un=new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/,"gmi"),cn=(n)=>{const[e,t]=n.split(".");if(!W.includes(e))return!0;const p=t.split("-"),d=p.length===1?void 0:p[p.length-1];return pn({chain:e,symbol:t})||!!d},Ot=(n)=>n.filter(({chain:e,value:t,symbol:p})=>{const d=`${e}.${p}`;return!Un.test(d)&&cn(d)&&t!=="0"});function Kt({chain:n,index:e,addressIndex:t=0,type:p}){if(W.includes(n)){if(p==="legacy")return[44,60,0,e];if(p==="ledgerLive")return[44,60,e,0,t];return yn(E[n],e)}if([y.Bitcoin,y.Litecoin].includes(n)){const d=n===y.Bitcoin?0:2;if(p==="nativeSegwitMiddleAccount")return[84,d,e,0,t];if(p==="segwit")return[49,d,0,0,e];if(p==="legacy")return[44,d,0,0,e];return yn(E[n],e)}return yn(E[n],e)}function Vt(n){const[e,t,p]=n.split("/").map((d)=>Number.parseInt(d,10));switch(t){case 44:return"legacy";case 49:return"p2sh";default:return"bech32"}}var yn=(n,e)=>[...n.slice(0,n.length-1),e];function Cn({liquidityUnits:n,poolUnits:e,runeDepth:t}){const p=R(n),d=R(e),r=R(t),u=p.mul(r),x=d.mul(d).mul(2),i=d.mul(p).mul(2),_=p.mul(p),Z=d.mul(d).mul(d);return u.mul(x.sub(i).add(_)).div(Z)}function Dn({liquidityUnits:n,poolUnits:e,assetDepth:t}){const p=R(n),d=R(e),r=R(t),u=p.mul(r),x=d.mul(d).mul(2),i=d.mul(p).mul(2),_=p.mul(p),Z=u.mul(x.sub(i).add(_)),w=d.mul(d).mul(d);return Z.div(w)}function Ft({percent:n,runeDepth:e,liquidityUnits:t,poolUnits:p}){return Cn({runeDepth:e,liquidityUnits:t,poolUnits:p}).mul(n)}function Mt({percent:n,assetDepth:e,liquidityUnits:t,poolUnits:p}){return Dn({assetDepth:e,liquidityUnits:t,poolUnits:p}).mul(n)}var R=function(n){return Y.fromBigInt(BigInt(n),j.THOR)};function hn({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p}){return{assetAmount:R(p).mul(n).div(e),runeAmount:R(t).mul(n).div(e)}}function Qt({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p,percent:d}){return Object.fromEntries(Object.entries(hn({liquidityUnits:n,poolUnits:e,runeDepth:t,assetDepth:p})).map(([r,u])=>[r,u.mul(d)]))}function Wt({runeDepth:n,poolUnits:e,assetDepth:t,liquidityUnits:p,runeAmount:d,assetAmount:r}){const u=new Y({value:n,decimal:8}),x=new Y({value:t,decimal:8}),i=new Y({value:e,decimal:8}),_=new Y({value:d,decimal:8}),Z=new Y({value:r,decimal:8}),w=_.mul(x),L=Z.mul(u),B=_.mul(Z),K=u.mul(x),F=i.mul(w.add(L.add(B.mul(2)))),H=w.add(L.add(K.mul(2))),sn=F.div(H),C=R(p).add(sn);if(sn.getBaseValue("number")===0)return C.div(i).getBaseValue("number");const s=i.add(C);return C.div(s).getBaseValue("number")}function lt({runeAmount:n,assetAmount:e,runeDepth:t,assetDepth:p}){if(n==="0"||e==="0"||t==="0"||p==="0")return 0;const d=R(t),r=R(p),u=R(e),x=R(n),i=u.mul(d).sub(r.mul(x)),_=r.mul(x).add(d.mul(r));return Math.abs(i.div(_).getBaseValue("number"))}var c=function(n,{affiliateAddress:e,affiliateBasisPoints:t}){const p=e?`:${e}:${t||0}`:"";return`${n}${p}`},ne=function({chain:n,symbol:e}){switch(n){case y.Bitcoin:case y.Dogecoin:case y.Litecoin:return n.slice(0,1).toLowerCase();case y.BitcoinCash:return"c";default:return`${n}.${e}`}};function ee({type:n,address:e}){return`${n}:${e}`}function te({address:n,unbondAmount:e}){return`${J.UNBOND}:${n}:${e}`}function pe({name:n,chain:e,address:t,owner:p}){const d=`${J.NAME_REGISTER}:${n}:${e}:${t}`,r=p?`:${p}`:"";return`${d}${r}`}function ye(n,{asset:e,address:t,minAmount:p,...d}){const r=`${n}:${e}:${t}`,u=p?`:${p}`:"";return c(`${r}${u}`,d)}function se({chain:n,symbol:e,...t}){return c(`${J.DEPOSIT}:${n}/${e}`,t)}function ae({chain:n,symbol:e,address:t}){const p=ne({chain:n,symbol:e}),d=t?`:${t}`:"";return`${J.DEPOSIT}:${p}${d}`}function de({chain:n,symbol:e,basisPoints:t,...p}){return c(`${J.WITHDRAW}:${n}/${e}:${t}`,p)}function ue({chain:n,symbol:e,ticker:t,basisPoints:p,targetAsset:d,...r}){const u=n==="ETH"&&t!=="ETH"?`${t}-${e.slice(-3)}`:e,x=d?`:${d}`:"";return c(`${J.WITHDRAW}:${n}.${u}:${p}${x}`,r)}var vt=(n,e)=>{switch(n){case J.LEAVE:case J.BOND:{const{address:t}=e;return ee({type:n,address:t})}case J.UNBOND:{const{address:t,unbondAmount:p}=e;return te({address:t,unbondAmount:p})}case J.NAME_REGISTER:return pe(e);case J.OPEN_LOAN:case J.CLOSE_LOAN:return ye(n,e);case J.DEPOSIT:{const{chain:t,symbol:p,address:d,singleSide:r}=e;if(r)return se({chain:t,symbol:p});return ae({chain:t,symbol:p,address:d})}case J.WITHDRAW:{const{chain:t,ticker:p,symbol:d,basisPoints:r,targetAssetString:u,singleSide:x}=e;if(x)return de({chain:t,symbol:d,basisPoints:r});return ue({chain:t,ticker:p,symbol:d,basisPoints:r,targetAsset:u})}default:throw new z({errorKey:"helpers_invalid_memo_type",info:{memoType:n}})}};function Dt(n){if(n<0)throw new z({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return 10+n}function ht(n){if(n<0)throw new z({errorKey:"helpers_invalid_number_of_years",info:{numberOfYears:n}});return Math.round((10+n*1.0512)*10000000000)/10000000000}function np([n,e,t,p,d]){return`m/${n}'/${e}'/${t}'/${p}${typeof d!=="number"?"":`/${d}`}`}function ep(n,e){try{return n()}catch(t){if(e)throw new z(e,t);return console.error(t)}}var tp=(n)=>{switch(n){case y.THORChain:return`${n}.RUNE`;case y.Cosmos:return`${n}.ATOM`;case y.BinanceSmartChain:return`${n}`;default:return`${n}.${n}`}};function xp(){const n=[];function e(p){if(n.map((d)=>d.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(d){throw new z({errorKey:"helpers_failed_to_switch_network",info:{error:d}})}return n(...p)},Ln=({provider:n,params:e,method:t})=>{if(!n?.send)throw new z("helpers_not_found_provider");const p=e?Array.isArray(e)?e:[e]:[];return n.send(t,p)},ap=({toolbox:n,chainId:e,provider:t=window.ethereum})=>{const p=re.reduce((d,r)=>{if(!n[r])return d;const u=n[r];if(typeof u!=="function")return d;return{...d,[r]:Te(u,t,e)}},{});return{...n,...p}},dp=(n,e)=>Ln({provider:n,method:"wallet_addEthereumChain",params:[e]}),xe=(n,e=o.EthereumHex)=>Ln({provider:n,method:"wallet_switchEthereumChain",params:[{chainId:e}]}),up=(n)=>{window.ethereum?.on("accountsChanged",()=>n()),window.xfi?.ethereum.on("accountsChanged",()=>n())},rp=()=>{const{isTrust:n,isBraveWallet:e,__XDEFI:t,overrideIsMetaMask:p,selectedProvider:d}=window?.ethereum||{};if(n)return k.TRUSTWALLET_WEB;if(e)return k.BRAVE;if(p&&d?.isCoinbaseWallet)return k.COINBASE_WEB;if(t)k.XDEFI;return k.METAMASK},Tp=(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,d=window?.ethereum?.overrideIsMetaMask&&window?.ethereum?.selectedProvider?.isCoinbaseWallet||window?.coinbaseWalletExtension,r=[];if(n)r.push(k.METAMASK);if(e)r.push(k.XDEFI);if(t)r.push(k.BRAVE);if(p)r.push(k.TRUSTWALLET_WEB);if(d)r.push(k.COINBASE_WEB);if(fe())r.push(k.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,d=/OKApp/i.test(n);return p&&d},mp=()=>typeof window.ethereum!=="undefined";class Y extends b{eq(n){return this.eqValue(n)}static fromBigInt(n,e){return new Y({decimal:e,value:q({value:n,bigIntDecimal:e,decimal:e})})}}export{ep as wrapWithThrow,Te as wrapMethodWithNetworkSwitch,xt as validateTNS,jn as validateIdentifier,xe as switchEVMWalletNetwork,zt as setRequestClientConfig,ap as prepareNetworkSwitch,fe as okxMobileEnabled,me as listWeb3EVMWallets,mp as isWeb3Detected,pn as isGasAsset,Tp as isDetected,Vt as getWalletFormatFor,Dt as getTHORNameCost,Qt as getSymmetricWithdraw,hn as getSymmetricPoolShare,$t as getMinAmountByChain,ue as getMemoForWithdraw,te as getMemoForUnbond,de as getMemoForSaverWithdraw,se as getMemoForSaverDeposit,pe as getMemoForNameRegister,ye as getMemoForLoan,ee as getMemoForLeaveAndBond,ae as getMemoForDeposit,vt as getMemoFor,ht as getMAYANameCost,lt as getLiquiditySlippage,Yt as getGasAsset,Wt as getEstimatedPoolShare,rp as getETHDefaultWallet,xp as getEIP6963Wallets,Kt as getDerivationPathFor,Xn as getDecimal,zn as getCommonAssetInfo,tp as getChainIdentifier,Ft as getAsymmetricRuneWithdrawAmount,Cn as getAsymmetricRuneShare,Mt as getAsymmetricAssetWithdrawAmount,Dn as getAsymmetricAssetShare,Jn as getAssetType,q as formatBigIntToSafeValue,bt as findAssetBy,Ot as filterAssets,He as erc20ABI,np as derivationPathToString,Wn as defaultRequestHeaders,Lt as assetFromString,dp as addEVMWalletNetwork,up as addAccountsChangedCallback,h as WarningCodeEnum,k as WalletOption,Ye as UTXOChains,Oe as TCSupportedChains,$e as TCEthereumVaultAbi,Xe as TCBscDepositABI,Ge as TCAvalancheDepositABI,Y as SwapKitNumber,z as SwapKitError,Re as SubstrateChains,Ae as SWAP_OUT,Ne as SWAP_IN,on as RouteQuoteWarningSchema,Pe as RouteQuoteSchema,wn as RouteQuoteMetadataSchema,qn as RouteQuoteMetadataAssetSchema,Kn as RouteQuoteLegSchema,Ie as RouteLegWithoutAddressesSchema,gn as RouteLegSchema,U as RequestClient,M as RPCUrl,Se as QuoteResponseSchema,We as QuoteRequestSchema,X as QuoteMode,O as ProviderName,E as NetworkDerivationPath,J as MemoType,oe as MayaEthereumVaultAbi,_e as MayaArbitrumVaultAbi,be as MAYASupportedChains,Tn as LedgerErrorCode,Hn as FeesSchema,nn as FeeTypeEnum,xn as FeeOption,Q as ExplorerUrl,I as EstimatedTimeSchema,fn as EVMTransactionDetailsSchema,bn as EVMTransactionDetailsParamsSchema,W as EVMChains,rn as DerivationPath,Le as CosmosChains,un as ContractAddress,Gn as CommonAssetStrings,D as ChainToRPC,ge as ChainToHexChainId,qe as ChainToExplorerUrl,dn as ChainToChainId,ke as ChainIdToChain,o as ChainId,y as Chain,b as BigIntArithmetics,j as BaseDecimal,G as AssetValue,mn as ApproveMode,Ve 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["THORChain"] = "https://rpc.thorswap.net";
|
|
957
|
-
RPCUrl2["THORChainStagenet"] = "https://stagenet-rpc.ninerealms.com";
|
|
958
|
-
})(RPCUrl || (RPCUrl = {}));
|
|
959
|
-
var ExplorerUrl;
|
|
960
|
-
(function(ExplorerUrl2) {
|
|
961
|
-
ExplorerUrl2["Arbitrum"] = "https://arbiscan.io";
|
|
962
|
-
ExplorerUrl2["Avalanche"] = "https://snowtrace.io";
|
|
963
|
-
ExplorerUrl2["Binance"] = "https://explorer.binance.org";
|
|
964
|
-
ExplorerUrl2["BinanceSmartChain"] = "https://bscscan.com";
|
|
965
|
-
ExplorerUrl2["Bitcoin"] = "https://blockchair.com/bitcoin";
|
|
966
|
-
ExplorerUrl2["BitcoinCash"] = "https://www.blockchair.com/bitcoin-cash";
|
|
967
|
-
ExplorerUrl2["Chainflip"] = "https://explorer.polkascan.io/polkadot";
|
|
968
|
-
ExplorerUrl2["Cosmos"] = "https://www.mintscan.io/cosmos";
|
|
969
|
-
ExplorerUrl2["Dash"] = "https://blockchair.com/dash";
|
|
970
|
-
ExplorerUrl2["Dogecoin"] = "https://blockchair.com/dogecoin";
|
|
971
|
-
ExplorerUrl2["Ethereum"] = "https://etherscan.io";
|
|
972
|
-
ExplorerUrl2["Kujira"] = "https://finder.kujira.network/kaiyo-1";
|
|
973
|
-
ExplorerUrl2["Litecoin"] = "https://blockchair.com/litecoin";
|
|
974
|
-
ExplorerUrl2["Maya"] = "https://www.mayascan.org";
|
|
975
|
-
ExplorerUrl2["Optimism"] = "https://optimistic.etherscan.io";
|
|
976
|
-
ExplorerUrl2["Polkadot"] = "https://polkadot.subscan.io/";
|
|
977
|
-
ExplorerUrl2["Polygon"] = "https://polygonscan.com";
|
|
978
|
-
ExplorerUrl2["THORChain"] = "https://runescan.io";
|
|
979
|
-
})(ExplorerUrl || (ExplorerUrl = {}));
|
|
980
|
-
|
|
981
|
-
// src/types/chains.ts
|
|
982
|
-
var Chain;
|
|
983
|
-
(function(Chain2) {
|
|
984
|
-
Chain2["Arbitrum"] = "ARB";
|
|
985
|
-
Chain2["Avalanche"] = "AVAX";
|
|
986
|
-
Chain2["Binance"] = "BNB";
|
|
987
|
-
Chain2["BinanceSmartChain"] = "BSC";
|
|
988
|
-
Chain2["Bitcoin"] = "BTC";
|
|
989
|
-
Chain2["BitcoinCash"] = "BCH";
|
|
990
|
-
Chain2["Cosmos"] = "GAIA";
|
|
991
|
-
Chain2["Dash"] = "DASH";
|
|
992
|
-
Chain2["Dogecoin"] = "DOGE";
|
|
993
|
-
Chain2["Ethereum"] = "ETH";
|
|
994
|
-
Chain2["Kujira"] = "KUJI";
|
|
995
|
-
Chain2["Litecoin"] = "LTC";
|
|
996
|
-
Chain2["Maya"] = "MAYA";
|
|
997
|
-
Chain2["Optimism"] = "OP";
|
|
998
|
-
Chain2["Polkadot"] = "DOT";
|
|
999
|
-
Chain2["Chainflip"] = "FLIP";
|
|
1000
|
-
Chain2["Polygon"] = "MATIC";
|
|
1001
|
-
Chain2["THORChain"] = "THOR";
|
|
1002
|
-
})(Chain || (Chain = {}));
|
|
1003
|
-
var ChainId;
|
|
1004
|
-
(function(ChainId2) {
|
|
1005
|
-
ChainId2["Arbitrum"] = "42161";
|
|
1006
|
-
ChainId2["ArbitrumHex"] = "0xa4b1";
|
|
1007
|
-
ChainId2["Avalanche"] = "43114";
|
|
1008
|
-
ChainId2["AvalancheHex"] = "0xa86a";
|
|
1009
|
-
ChainId2["Binance"] = "Binance-Chain-Tigris";
|
|
1010
|
-
ChainId2["BinanceSmartChain"] = "56";
|
|
1011
|
-
ChainId2["BinanceSmartChainHex"] = "0x38";
|
|
1012
|
-
ChainId2["Bitcoin"] = "bitcoin";
|
|
1013
|
-
ChainId2["BitcoinCash"] = "bitcoincash";
|
|
1014
|
-
ChainId2["Chainflip"] = "chainflip";
|
|
1015
|
-
ChainId2["Cosmos"] = "cosmoshub-4";
|
|
1016
|
-
ChainId2["Dash"] = "dash";
|
|
1017
|
-
ChainId2["Dogecoin"] = "dogecoin";
|
|
1018
|
-
ChainId2["Kujira"] = "kaiyo-1";
|
|
1019
|
-
ChainId2["Ethereum"] = "1";
|
|
1020
|
-
ChainId2["EthereumHex"] = "0x1";
|
|
1021
|
-
ChainId2["Litecoin"] = "litecoin";
|
|
1022
|
-
ChainId2["Maya"] = "mayachain-mainnet-v1";
|
|
1023
|
-
ChainId2["MayaStagenet"] = "mayachain-stagenet-v1";
|
|
1024
|
-
ChainId2["Optimism"] = "10";
|
|
1025
|
-
ChainId2["OptimismHex"] = "0xa";
|
|
1026
|
-
ChainId2["Polkadot"] = "polkadot";
|
|
1027
|
-
ChainId2["Polygon"] = "137";
|
|
1028
|
-
ChainId2["PolygonHex"] = "0x89";
|
|
1029
|
-
ChainId2["THORChain"] = "thorchain-mainnet-v1";
|
|
1030
|
-
ChainId2["THORChainStagenet"] = "thorchain-stagenet-v2";
|
|
1031
|
-
})(ChainId || (ChainId = {}));
|
|
1032
|
-
var ChainIdToChain = {
|
|
1033
|
-
[ChainId.ArbitrumHex]: Chain.Arbitrum,
|
|
1034
|
-
[ChainId.Arbitrum]: Chain.Arbitrum,
|
|
1035
|
-
[ChainId.AvalancheHex]: Chain.Avalanche,
|
|
1036
|
-
[ChainId.Avalanche]: Chain.Avalanche,
|
|
1037
|
-
[ChainId.BinanceSmartChainHex]: Chain.BinanceSmartChain,
|
|
1038
|
-
[ChainId.BinanceSmartChain]: Chain.BinanceSmartChain,
|
|
1039
|
-
[ChainId.Binance]: Chain.Binance,
|
|
1040
|
-
[ChainId.BitcoinCash]: Chain.BitcoinCash,
|
|
1041
|
-
[ChainId.Bitcoin]: Chain.Bitcoin,
|
|
1042
|
-
[ChainId.Chainflip]: Chain.Chainflip,
|
|
1043
|
-
[ChainId.Cosmos]: Chain.Cosmos,
|
|
1044
|
-
[ChainId.Dash]: Chain.Dash,
|
|
1045
|
-
[ChainId.Dogecoin]: Chain.Dogecoin,
|
|
1046
|
-
[ChainId.EthereumHex]: Chain.Ethereum,
|
|
1047
|
-
[ChainId.Kujira]: Chain.Kujira,
|
|
1048
|
-
[ChainId.Ethereum]: Chain.Ethereum,
|
|
1049
|
-
[ChainId.Litecoin]: Chain.Litecoin,
|
|
1050
|
-
[ChainId.MayaStagenet]: Chain.Maya,
|
|
1051
|
-
[ChainId.Maya]: Chain.Maya,
|
|
1052
|
-
[ChainId.OptimismHex]: Chain.Optimism,
|
|
1053
|
-
[ChainId.Optimism]: Chain.Optimism,
|
|
1054
|
-
[ChainId.Polkadot]: Chain.Polkadot,
|
|
1055
|
-
[ChainId.PolygonHex]: Chain.Polygon,
|
|
1056
|
-
[ChainId.Polygon]: Chain.Polygon,
|
|
1057
|
-
[ChainId.THORChainStagenet]: Chain.THORChain,
|
|
1058
|
-
[ChainId.THORChain]: Chain.THORChain
|
|
1059
|
-
};
|
|
1060
|
-
var chainNames = Object.keys(Chain);
|
|
1061
|
-
var chains = Object.values(Chain);
|
|
1062
|
-
var BaseDecimal;
|
|
1063
|
-
(function(BaseDecimal2) {
|
|
1064
|
-
BaseDecimal2[BaseDecimal2["ARB"] = 18] = "ARB";
|
|
1065
|
-
BaseDecimal2[BaseDecimal2["AVAX"] = 18] = "AVAX";
|
|
1066
|
-
BaseDecimal2[BaseDecimal2["BCH"] = 8] = "BCH";
|
|
1067
|
-
BaseDecimal2[BaseDecimal2["BNB"] = 8] = "BNB";
|
|
1068
|
-
BaseDecimal2[BaseDecimal2["BSC"] = 18] = "BSC";
|
|
1069
|
-
BaseDecimal2[BaseDecimal2["BTC"] = 8] = "BTC";
|
|
1070
|
-
BaseDecimal2[BaseDecimal2["DASH"] = 8] = "DASH";
|
|
1071
|
-
BaseDecimal2[BaseDecimal2["DOGE"] = 8] = "DOGE";
|
|
1072
|
-
BaseDecimal2[BaseDecimal2["DOT"] = 10] = "DOT";
|
|
1073
|
-
BaseDecimal2[BaseDecimal2["ETH"] = 18] = "ETH";
|
|
1074
|
-
BaseDecimal2[BaseDecimal2["FLIP"] = 18] = "FLIP";
|
|
1075
|
-
BaseDecimal2[BaseDecimal2["GAIA"] = 6] = "GAIA";
|
|
1076
|
-
BaseDecimal2[BaseDecimal2["KUJI"] = 6] = "KUJI";
|
|
1077
|
-
BaseDecimal2[BaseDecimal2["LTC"] = 8] = "LTC";
|
|
1078
|
-
BaseDecimal2[BaseDecimal2["MATIC"] = 18] = "MATIC";
|
|
1079
|
-
BaseDecimal2[BaseDecimal2["MAYA"] = 10] = "MAYA";
|
|
1080
|
-
BaseDecimal2[BaseDecimal2["OP"] = 18] = "OP";
|
|
1081
|
-
BaseDecimal2[BaseDecimal2["THOR"] = 8] = "THOR";
|
|
1082
|
-
BaseDecimal2[BaseDecimal2["ZEC"] = 8] = "ZEC";
|
|
1083
|
-
})(BaseDecimal || (BaseDecimal = {}));
|
|
1084
|
-
var SubstrateChains = [Chain.Polkadot, Chain.Chainflip];
|
|
1085
|
-
var EVMChains = [
|
|
1086
|
-
Chain.Ethereum,
|
|
1087
|
-
Chain.Avalanche,
|
|
1088
|
-
Chain.BinanceSmartChain,
|
|
1089
|
-
Chain.Arbitrum,
|
|
1090
|
-
Chain.Optimism,
|
|
1091
|
-
Chain.Polygon
|
|
1092
|
-
];
|
|
1093
|
-
var UTXOChains = [
|
|
1094
|
-
Chain.Bitcoin,
|
|
1095
|
-
Chain.BitcoinCash,
|
|
1096
|
-
Chain.Dash,
|
|
1097
|
-
Chain.Dogecoin,
|
|
1098
|
-
Chain.Litecoin
|
|
1099
|
-
];
|
|
1100
|
-
var CosmosChains = [
|
|
1101
|
-
Chain.Cosmos,
|
|
1102
|
-
Chain.THORChain,
|
|
1103
|
-
Chain.Binance,
|
|
1104
|
-
Chain.Maya,
|
|
1105
|
-
Chain.Kujira
|
|
1106
|
-
];
|
|
1107
|
-
var TCSupportedChains = [
|
|
1108
|
-
Chain.Avalanche,
|
|
1109
|
-
Chain.Binance,
|
|
1110
|
-
Chain.BinanceSmartChain,
|
|
1111
|
-
Chain.Bitcoin,
|
|
1112
|
-
Chain.BitcoinCash,
|
|
1113
|
-
Chain.Cosmos,
|
|
1114
|
-
Chain.Dogecoin,
|
|
1115
|
-
Chain.Ethereum,
|
|
1116
|
-
Chain.Litecoin,
|
|
1117
|
-
Chain.THORChain
|
|
1118
|
-
];
|
|
1119
|
-
var MAYASupportedChains = [
|
|
1120
|
-
Chain.Arbitrum,
|
|
1121
|
-
Chain.Dash,
|
|
1122
|
-
Chain.Ethereum,
|
|
1123
|
-
Chain.Kujira,
|
|
1124
|
-
Chain.Maya,
|
|
1125
|
-
Chain.THORChain
|
|
1126
|
-
];
|
|
1127
|
-
var ChainToChainName = chains.reduce((acc, chain) => {
|
|
1128
|
-
const chainName = chainNames.find((key) => Chain[key] === chain);
|
|
1129
|
-
if (chainName)
|
|
1130
|
-
acc[chain] = chainName;
|
|
1131
|
-
return acc;
|
|
1132
|
-
}, {});
|
|
1133
|
-
var ChainToChainId = chains.reduce((acc, chain) => {
|
|
1134
|
-
acc[chain] = ChainId[ChainToChainName[chain]];
|
|
1135
|
-
return acc;
|
|
1136
|
-
}, {});
|
|
1137
|
-
var ChainToRPC = chains.reduce((acc, chain) => {
|
|
1138
|
-
acc[chain] = RPCUrl[ChainToChainName[chain]];
|
|
1139
|
-
return acc;
|
|
1140
|
-
}, {});
|
|
1141
|
-
var ChainToHexChainId = chains.reduce((acc, chain) => {
|
|
1142
|
-
const chainString = `${ChainToChainName[chain]}Hex`;
|
|
1143
|
-
acc[chain] = ChainId[chainString];
|
|
1144
|
-
return acc;
|
|
1145
|
-
}, {});
|
|
1146
|
-
var ChainToExplorerUrl = chains.reduce((acc, chain) => {
|
|
1147
|
-
acc[chain] = ExplorerUrl[ChainToChainName[chain]];
|
|
1148
|
-
return acc;
|
|
1149
|
-
}, {});
|
|
1150
|
-
// src/types/commonTypes.ts
|
|
1151
|
-
var QuoteMode;
|
|
1152
|
-
(function(QuoteMode2) {
|
|
1153
|
-
QuoteMode2["TC_SUPPORTED_TO_TC_SUPPORTED"] = "TC-TC";
|
|
1154
|
-
QuoteMode2["TC_SUPPORTED_TO_ETH"] = "TC-ERC20";
|
|
1155
|
-
QuoteMode2["TC_SUPPORTED_TO_AVAX"] = "TC-ARC20";
|
|
1156
|
-
QuoteMode2["TC_SUPPORTED_TO_BSC"] = "TC-BEP20";
|
|
1157
|
-
QuoteMode2["ETH_TO_TC_SUPPORTED"] = "ERC20-TC";
|
|
1158
|
-
QuoteMode2["ETH_TO_ETH"] = "ERC20-ERC20";
|
|
1159
|
-
QuoteMode2["ETH_TO_AVAX"] = "ERC20-ARC20";
|
|
1160
|
-
QuoteMode2["ETH_TO_BSC"] = "ERC20-BEP20";
|
|
1161
|
-
QuoteMode2["AVAX_TO_TC_SUPPORTED"] = "ARC20-TC";
|
|
1162
|
-
QuoteMode2["AVAX_TO_ETH"] = "ARC20-ERC20";
|
|
1163
|
-
QuoteMode2["AVAX_TO_AVAX"] = "ARC20-ARC20";
|
|
1164
|
-
QuoteMode2["AVAX_TO_BSC"] = "ARC20-BEP20";
|
|
1165
|
-
QuoteMode2["BSC_TO_TC_SUPPORTED"] = "BEP20-TC";
|
|
1166
|
-
QuoteMode2["BSC_TO_ETH"] = "BEP20-ERC20";
|
|
1167
|
-
QuoteMode2["BSC_TO_AVAX"] = "BEP20-ARC20";
|
|
1168
|
-
QuoteMode2["BSC_TO_BSC"] = "BEP20-BEP20";
|
|
1169
|
-
})(QuoteMode || (QuoteMode = {}));
|
|
1170
|
-
var AGG_SWAP = [QuoteMode.ETH_TO_ETH, QuoteMode.AVAX_TO_AVAX, QuoteMode.BSC_TO_BSC];
|
|
1171
|
-
var SWAP_IN = [
|
|
1172
|
-
QuoteMode.ETH_TO_TC_SUPPORTED,
|
|
1173
|
-
QuoteMode.ETH_TO_AVAX,
|
|
1174
|
-
QuoteMode.ETH_TO_BSC,
|
|
1175
|
-
QuoteMode.AVAX_TO_TC_SUPPORTED,
|
|
1176
|
-
QuoteMode.AVAX_TO_ETH,
|
|
1177
|
-
QuoteMode.AVAX_TO_BSC,
|
|
1178
|
-
QuoteMode.BSC_TO_TC_SUPPORTED,
|
|
1179
|
-
QuoteMode.BSC_TO_ETH,
|
|
1180
|
-
QuoteMode.BSC_TO_AVAX
|
|
1181
|
-
];
|
|
1182
|
-
var SWAP_OUT = [
|
|
1183
|
-
QuoteMode.TC_SUPPORTED_TO_TC_SUPPORTED,
|
|
1184
|
-
QuoteMode.TC_SUPPORTED_TO_ETH,
|
|
1185
|
-
QuoteMode.TC_SUPPORTED_TO_AVAX,
|
|
1186
|
-
QuoteMode.TC_SUPPORTED_TO_BSC
|
|
1187
|
-
];
|
|
1188
|
-
// src/types/derivationPath.ts
|
|
1189
|
-
var ContractAddress;
|
|
1190
|
-
(function(ContractAddress2) {
|
|
1191
|
-
ContractAddress2["ARB"] = "0x0000000000000000000000000000000000000000";
|
|
1192
|
-
ContractAddress2["AVAX"] = "0x0000000000000000000000000000000000000000";
|
|
1193
|
-
ContractAddress2["ETH"] = "0x0000000000000000000000000000000000000000";
|
|
1194
|
-
ContractAddress2["BSC"] = "0x0000000000000000000000000000000000000000";
|
|
1195
|
-
ContractAddress2["MATIC"] = "0x0000000000000000000000000000000000001010";
|
|
1196
|
-
ContractAddress2["OP"] = "0x4200000000000000000000000000000000000042";
|
|
1197
|
-
})(ContractAddress || (ContractAddress = {}));
|
|
1198
|
-
var DerivationPath;
|
|
1199
|
-
(function(DerivationPath2) {
|
|
1200
|
-
DerivationPath2["ARB"] = "m/44'/60'/0'/0";
|
|
1201
|
-
DerivationPath2["AVAX"] = "m/44'/60'/0'/0";
|
|
1202
|
-
DerivationPath2["BCH"] = "m/44'/145'/0'/0";
|
|
1203
|
-
DerivationPath2["BNB"] = "m/44'/714'/0'/0";
|
|
1204
|
-
DerivationPath2["BSC"] = "m/44'/60'/0'/0";
|
|
1205
|
-
DerivationPath2["BTC"] = "m/84'/0'/0'/0";
|
|
1206
|
-
DerivationPath2["DASH"] = "m/44'/5'/0'/0";
|
|
1207
|
-
DerivationPath2["DOGE"] = "m/44'/3'/0'/0";
|
|
1208
|
-
DerivationPath2["DOT"] = "////";
|
|
1209
|
-
DerivationPath2["ETH"] = "m/44'/60'/0'/0";
|
|
1210
|
-
DerivationPath2["FLIP"] = "////";
|
|
1211
|
-
DerivationPath2["GAIA"] = "m/44'/118'/0'/0";
|
|
1212
|
-
DerivationPath2["KUJI"] = "m/44'/118'/0'/0";
|
|
1213
|
-
DerivationPath2["LTC"] = "m/84'/2'/0'/0";
|
|
1214
|
-
DerivationPath2["MATIC"] = "m/44'/60'/0'/0";
|
|
1215
|
-
DerivationPath2["MAYA"] = "m/44'/931'/0'/0";
|
|
1216
|
-
DerivationPath2["OP"] = "m/44'/60'/0'/0";
|
|
1217
|
-
DerivationPath2["THOR"] = "m/44'/931'/0'/0";
|
|
1218
|
-
})(DerivationPath || (DerivationPath = {}));
|
|
1219
|
-
var NetworkDerivationPath = {
|
|
1220
|
-
ARB: [44, 60, 0, 0, 0],
|
|
1221
|
-
AVAX: [44, 60, 0, 0, 0],
|
|
1222
|
-
BCH: [44, 145, 0, 0, 0],
|
|
1223
|
-
BNB: [44, 714, 0, 0, 0],
|
|
1224
|
-
BSC: [44, 60, 0, 0, 0],
|
|
1225
|
-
BTC: [84, 0, 0, 0, 0],
|
|
1226
|
-
DASH: [44, 5, 0, 0, 0],
|
|
1227
|
-
DOGE: [44, 3, 0, 0, 0],
|
|
1228
|
-
ETH: [44, 60, 0, 0, 0],
|
|
1229
|
-
GAIA: [44, 118, 0, 0, 0],
|
|
1230
|
-
KUJI: [44, 118, 0, 0, 0],
|
|
1231
|
-
LTC: [84, 2, 0, 0, 0],
|
|
1232
|
-
MATIC: [44, 60, 0, 0, 0],
|
|
1233
|
-
MAYA: [44, 931, 0, 0, 0],
|
|
1234
|
-
OP: [44, 60, 0, 0, 0],
|
|
1235
|
-
THOR: [44, 931, 0, 0, 0],
|
|
1236
|
-
DOT: [0, 0, 0, 0, 0],
|
|
1237
|
-
FLIP: [0, 0, 0, 0, 0]
|
|
1238
|
-
};
|
|
1239
|
-
// src/types/wallet.ts
|
|
1240
|
-
var WalletOption;
|
|
1241
|
-
(function(WalletOption2) {
|
|
1242
|
-
WalletOption2["KEYSTORE"] = "KEYSTORE";
|
|
1243
|
-
WalletOption2["KEEPKEY"] = "KEEPKEY";
|
|
1244
|
-
WalletOption2["XDEFI"] = "XDEFI";
|
|
1245
|
-
WalletOption2["METAMASK"] = "METAMASK";
|
|
1246
|
-
WalletOption2["COINBASE_WEB"] = "COINBASE_WEB";
|
|
1247
|
-
WalletOption2["COINBASE_MOBILE"] = "COINBASE_MOBILE";
|
|
1248
|
-
WalletOption2["TREZOR"] = "TREZOR";
|
|
1249
|
-
WalletOption2["TRUSTWALLET_WEB"] = "TRUSTWALLET_WEB";
|
|
1250
|
-
WalletOption2["LEDGER"] = "LEDGER";
|
|
1251
|
-
WalletOption2["KEPLR"] = "KEPLR";
|
|
1252
|
-
WalletOption2["OKX"] = "OKX";
|
|
1253
|
-
WalletOption2["OKX_MOBILE"] = "OKX_MOBILE";
|
|
1254
|
-
WalletOption2["BRAVE"] = "BRAVE";
|
|
1255
|
-
WalletOption2["WALLETCONNECT"] = "WALLETCONNECT";
|
|
1256
|
-
})(WalletOption || (WalletOption = {}));
|
|
1257
|
-
var LedgerErrorCode;
|
|
1258
|
-
(function(LedgerErrorCode2) {
|
|
1259
|
-
LedgerErrorCode2[LedgerErrorCode2["NoError"] = 36864] = "NoError";
|
|
1260
|
-
LedgerErrorCode2[LedgerErrorCode2["LockedDevice"] = 21781] = "LockedDevice";
|
|
1261
|
-
LedgerErrorCode2[LedgerErrorCode2["TC_NotFound"] = 65535] = "TC_NotFound";
|
|
1262
|
-
})(LedgerErrorCode || (LedgerErrorCode = {}));
|
|
1263
|
-
// src/types/sdk.ts
|
|
1264
|
-
var FeeOption;
|
|
1265
|
-
(function(FeeOption2) {
|
|
1266
|
-
FeeOption2["Average"] = "average";
|
|
1267
|
-
FeeOption2["Fast"] = "fast";
|
|
1268
|
-
FeeOption2["Fastest"] = "fastest";
|
|
1269
|
-
})(FeeOption || (FeeOption = {}));
|
|
1270
|
-
var ApproveMode;
|
|
1271
|
-
(function(ApproveMode2) {
|
|
1272
|
-
ApproveMode2["Approve"] = "approve";
|
|
1273
|
-
ApproveMode2["CheckOnly"] = "checkOnly";
|
|
1274
|
-
})(ApproveMode || (ApproveMode = {}));
|
|
1275
|
-
var MemoType;
|
|
1276
|
-
(function(MemoType2) {
|
|
1277
|
-
MemoType2["BOND"] = "BOND";
|
|
1278
|
-
MemoType2["DEPOSIT"] = "+";
|
|
1279
|
-
MemoType2["LEAVE"] = "LEAVE";
|
|
1280
|
-
MemoType2["THORNAME_REGISTER"] = "~";
|
|
1281
|
-
MemoType2["UNBOND"] = "UNBOND";
|
|
1282
|
-
MemoType2["WITHDRAW"] = "-";
|
|
1283
|
-
MemoType2["OPEN_LOAN"] = "$+";
|
|
1284
|
-
MemoType2["CLOSE_LOAN"] = "$-";
|
|
1285
|
-
})(MemoType || (MemoType = {}));
|
|
1286
|
-
// src/modules/requestClient.ts
|
|
1287
|
-
import ky from "ky";
|
|
1288
|
-
function setRequestClientConfig({ apiKey, ...config }) {
|
|
1289
|
-
kyClient = ky.create({
|
|
1290
|
-
...config,
|
|
1291
|
-
headers: { ...defaultRequestHeaders, ...config.headers, "x-api-key": apiKey }
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
var getKyClient = function() {
|
|
1295
|
-
if (kyClient)
|
|
1296
|
-
return kyClient;
|
|
1297
|
-
kyClient = ky.create({ headers: defaultRequestHeaders });
|
|
1298
|
-
return kyClient;
|
|
1299
|
-
};
|
|
1300
|
-
var kyClient;
|
|
1301
|
-
var defaultRequestHeaders = typeof window !== "undefined" ? {} : { referrer: "https://sk.thorswap.net", referer: "https://sk.thorswap.net" };
|
|
1302
|
-
var RequestClient = {
|
|
1303
|
-
get: (url, options) => getKyClient().get(url, options).json(),
|
|
1304
|
-
post: (url, options) => getKyClient().post(url, options).json()
|
|
1305
|
-
};
|
|
1306
|
-
|
|
1307
|
-
// src/helpers/asset.ts
|
|
1308
|
-
async function findAssetBy(params) {
|
|
1309
|
-
const tokenPackages = await import("@swapkit/tokens");
|
|
1310
|
-
for (const tokenList of Object.values(tokenPackages)) {
|
|
1311
|
-
for (const { identifier, chain: tokenChain, ...rest } of tokenList.tokens) {
|
|
1312
|
-
if ("identifier" in params && identifier === params.identifier) {
|
|
1313
|
-
return identifier;
|
|
1314
|
-
}
|
|
1315
|
-
if ("address" in rest && "chain" in params && tokenChain === params.chain && rest.address.toLowerCase() === params.contract.toLowerCase())
|
|
1316
|
-
return identifier;
|
|
1317
|
-
}
|
|
1318
|
-
}
|
|
1319
|
-
return;
|
|
1320
|
-
}
|
|
1321
|
-
var getDecimalMethodHex = "0x313ce567";
|
|
1322
|
-
var getContractDecimals = async ({ chain, to }) => {
|
|
1323
|
-
try {
|
|
1324
|
-
const { result } = await RequestClient.post(ChainToRPC[chain], {
|
|
1325
|
-
headers: {
|
|
1326
|
-
accept: "*/*",
|
|
1327
|
-
"content-type": "application/json",
|
|
1328
|
-
"cache-control": "no-cache"
|
|
1329
|
-
},
|
|
1330
|
-
body: JSON.stringify({
|
|
1331
|
-
id: 44,
|
|
1332
|
-
jsonrpc: "2.0",
|
|
1333
|
-
method: "eth_call",
|
|
1334
|
-
params: [{ to: to.toLowerCase(), data: getDecimalMethodHex }, "latest"]
|
|
1335
|
-
})
|
|
1336
|
-
});
|
|
1337
|
-
return Number.parseInt(BigInt(result || BaseDecimal[chain]).toString());
|
|
1338
|
-
} catch (error) {
|
|
1339
|
-
console.error(error);
|
|
1340
|
-
return BaseDecimal[chain];
|
|
1341
|
-
}
|
|
1342
|
-
};
|
|
1343
|
-
var getETHAssetDecimal = (symbol) => {
|
|
1344
|
-
if (symbol === Chain.Ethereum)
|
|
1345
|
-
return BaseDecimal.ETH;
|
|
1346
|
-
const splitSymbol = symbol.split("-");
|
|
1347
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
1348
|
-
return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Ethereum, to: address }) : BaseDecimal.ETH;
|
|
1349
|
-
};
|
|
1350
|
-
var getAVAXAssetDecimal = (symbol) => {
|
|
1351
|
-
const splitSymbol = symbol.split("-");
|
|
1352
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
1353
|
-
return address?.startsWith("0x") ? getContractDecimals({ chain: Chain.Avalanche, to: address.toLowerCase() }) : BaseDecimal.AVAX;
|
|
1354
|
-
};
|
|
1355
|
-
var getBSCAssetDecimal = (symbol) => {
|
|
1356
|
-
if (symbol === Chain.BinanceSmartChain)
|
|
1357
|
-
return BaseDecimal.BSC;
|
|
1358
|
-
return BaseDecimal.BSC;
|
|
1359
|
-
};
|
|
1360
|
-
var getDecimal = ({ chain, symbol }) => {
|
|
1361
|
-
switch (chain) {
|
|
1362
|
-
case Chain.Ethereum:
|
|
1363
|
-
return getETHAssetDecimal(symbol);
|
|
1364
|
-
case Chain.Avalanche:
|
|
1365
|
-
return getAVAXAssetDecimal(symbol);
|
|
1366
|
-
case Chain.BinanceSmartChain:
|
|
1367
|
-
return getBSCAssetDecimal(symbol);
|
|
1368
|
-
default:
|
|
1369
|
-
return BaseDecimal[chain];
|
|
1370
|
-
}
|
|
1371
|
-
};
|
|
1372
|
-
var isGasAsset = ({ chain, symbol }) => {
|
|
1373
|
-
switch (chain) {
|
|
1374
|
-
case Chain.Arbitrum:
|
|
1375
|
-
case Chain.Optimism:
|
|
1376
|
-
return symbol === "ETH";
|
|
1377
|
-
case Chain.Maya:
|
|
1378
|
-
return symbol === "CACAO";
|
|
1379
|
-
case Chain.Kujira:
|
|
1380
|
-
return symbol === "KUJI";
|
|
1381
|
-
case Chain.Cosmos:
|
|
1382
|
-
return symbol === "ATOM";
|
|
1383
|
-
case Chain.Polygon:
|
|
1384
|
-
return symbol === "MATIC";
|
|
1385
|
-
case Chain.BinanceSmartChain:
|
|
1386
|
-
return symbol === "BNB";
|
|
1387
|
-
case Chain.THORChain:
|
|
1388
|
-
return symbol === "RUNE";
|
|
1389
|
-
default:
|
|
1390
|
-
return symbol === chain;
|
|
1391
|
-
}
|
|
1392
|
-
};
|
|
1393
|
-
var getCommonAssetInfo = (assetString) => {
|
|
1394
|
-
switch (assetString) {
|
|
1395
|
-
case `${Chain.Ethereum}.THOR`:
|
|
1396
|
-
return { identifier: "ETH.THOR-0xa5f2211b9b8170f694421f2046281775e8468044", decimal: 18 };
|
|
1397
|
-
case `${Chain.Ethereum}.vTHOR`:
|
|
1398
|
-
return { identifier: "ETH.vTHOR-0x815c23eca83261b6ec689b60cc4a58b54bc24d8d", decimal: 18 };
|
|
1399
|
-
case Chain.Arbitrum:
|
|
1400
|
-
return { identifier: `${Chain.Arbitrum}.ETH`, decimal: BaseDecimal[assetString] };
|
|
1401
|
-
case Chain.Optimism:
|
|
1402
|
-
return { identifier: `${Chain.Optimism}.ETH`, decimal: BaseDecimal[assetString] };
|
|
1403
|
-
case Chain.Cosmos:
|
|
1404
|
-
return { identifier: "GAIA.ATOM", decimal: BaseDecimal[assetString] };
|
|
1405
|
-
case Chain.THORChain:
|
|
1406
|
-
return { identifier: "THOR.RUNE", decimal: BaseDecimal[assetString] };
|
|
1407
|
-
case Chain.BinanceSmartChain:
|
|
1408
|
-
return { identifier: "BSC.BNB", decimal: BaseDecimal[assetString] };
|
|
1409
|
-
case Chain.Maya:
|
|
1410
|
-
return { identifier: "MAYA.CACAO", decimal: BaseDecimal.MAYA };
|
|
1411
|
-
case `${Chain.Maya}.MAYA`:
|
|
1412
|
-
return { identifier: "MAYA.MAYA", decimal: 4 };
|
|
1413
|
-
case `${Chain.Kujira}.USK`:
|
|
1414
|
-
return { identifier: `${Chain.Kujira}.USK`, decimal: 6 };
|
|
1415
|
-
default:
|
|
1416
|
-
return { identifier: `${assetString}.${assetString}`, decimal: BaseDecimal[assetString] };
|
|
1417
|
-
}
|
|
1418
|
-
};
|
|
1419
|
-
var getAssetType = ({ chain, symbol }) => {
|
|
1420
|
-
if (symbol.includes("/"))
|
|
1421
|
-
return "Synth";
|
|
1422
|
-
switch (chain) {
|
|
1423
|
-
case Chain.Cosmos:
|
|
1424
|
-
return symbol === "ATOM" ? "Native" : Chain.Cosmos;
|
|
1425
|
-
case Chain.Kujira:
|
|
1426
|
-
return symbol === Chain.Kujira ? "Native" : Chain.Kujira;
|
|
1427
|
-
case Chain.Binance:
|
|
1428
|
-
return symbol === Chain.Binance ? "Native" : "BEP2";
|
|
1429
|
-
case Chain.BinanceSmartChain:
|
|
1430
|
-
return symbol === Chain.Binance ? "Native" : "BEP20";
|
|
1431
|
-
case Chain.Ethereum:
|
|
1432
|
-
return symbol === Chain.Ethereum ? "Native" : "ERC20";
|
|
1433
|
-
case Chain.Avalanche:
|
|
1434
|
-
return symbol === Chain.Avalanche ? "Native" : Chain.Avalanche;
|
|
1435
|
-
case Chain.Polygon:
|
|
1436
|
-
return symbol === Chain.Polygon ? "Native" : "POLYGON";
|
|
1437
|
-
case Chain.Arbitrum:
|
|
1438
|
-
return [Chain.Ethereum, Chain.Arbitrum].includes(symbol) ? "Native" : "ARBITRUM";
|
|
1439
|
-
case Chain.Optimism:
|
|
1440
|
-
return [Chain.Ethereum, Chain.Optimism].includes(symbol) ? "Native" : "OPTIMISM";
|
|
1441
|
-
default:
|
|
1442
|
-
return "Native";
|
|
1443
|
-
}
|
|
1444
|
-
};
|
|
1445
|
-
var assetFromString = (assetString) => {
|
|
1446
|
-
const [chain, ...symbolArray] = assetString.split(".");
|
|
1447
|
-
const synth = assetString.includes("/");
|
|
1448
|
-
const symbol = symbolArray.join(".");
|
|
1449
|
-
const splitSymbol = symbol?.split("-");
|
|
1450
|
-
const ticker = splitSymbol?.length ? splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-") : undefined;
|
|
1451
|
-
return { chain, symbol, ticker, synth };
|
|
1452
|
-
};
|
|
1453
|
-
var potentialScamRegex = new RegExp(/(.)\1{6}|\.ORG|\.NET|\.FINANCE|\.COM|WWW|HTTP|\\\\|\/\/|[\s$%:[\]]/, "gmi");
|
|
1454
|
-
var evmAssetHasAddress = (assetString) => {
|
|
1455
|
-
const [chain, symbol] = assetString.split(".");
|
|
1456
|
-
if (!EVMChains.includes(chain))
|
|
1457
|
-
return true;
|
|
1458
|
-
const splitSymbol = symbol.split("-");
|
|
1459
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
1460
|
-
return isGasAsset({ chain, symbol }) || !!address;
|
|
1461
|
-
};
|
|
1462
|
-
var filterAssets = (tokens2) => tokens2.filter(({ chain, value, symbol }) => {
|
|
1463
|
-
const assetString = `${chain}.${symbol}`;
|
|
1464
|
-
return !potentialScamRegex.test(assetString) && evmAssetHasAddress(assetString) && value !== "0";
|
|
1465
|
-
});
|
|
1466
|
-
// src/helpers/derivationPath.ts
|
|
1467
|
-
function getDerivationPathFor({ chain, index, type }) {
|
|
1468
|
-
if (EVMChains.includes(chain)) {
|
|
1469
|
-
if (type === "legacy")
|
|
1470
|
-
return [44, 60, 0, index];
|
|
1471
|
-
if (type === "ledgerLive")
|
|
1472
|
-
return [44, 60, index, 0, 0];
|
|
1473
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
1474
|
-
}
|
|
1475
|
-
if ([Chain.Bitcoin, Chain.Litecoin].includes(chain)) {
|
|
1476
|
-
const chainId = chain === Chain.Bitcoin ? 0 : 2;
|
|
1477
|
-
if (type === "nativeSegwitMiddleAccount")
|
|
1478
|
-
return [84, chainId, index, 0, 0];
|
|
1479
|
-
if (type === "segwit")
|
|
1480
|
-
return [49, chainId, 0, 0, index];
|
|
1481
|
-
if (type === "legacy")
|
|
1482
|
-
return [44, chainId, 0, 0, index];
|
|
1483
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
1484
|
-
}
|
|
1485
|
-
return updatedLastIndex(NetworkDerivationPath[chain], index);
|
|
1486
|
-
}
|
|
1487
|
-
function getWalletFormatFor(path) {
|
|
1488
|
-
const [_, purpose, chainId] = path.split("/").map((p) => Number.parseInt(p, 10));
|
|
1489
|
-
if (chainId === 145)
|
|
1490
|
-
;
|
|
1491
|
-
switch (purpose) {
|
|
1492
|
-
case 44:
|
|
1493
|
-
return "legacy";
|
|
1494
|
-
case 49:
|
|
1495
|
-
return "p2sh";
|
|
1496
|
-
default:
|
|
1497
|
-
return "bech32";
|
|
1498
|
-
}
|
|
1499
|
-
}
|
|
1500
|
-
var updatedLastIndex = (path, index) => [
|
|
1501
|
-
...path.slice(0, path.length - 1),
|
|
1502
|
-
index
|
|
1503
|
-
];
|
|
1504
|
-
// src/helpers/liquidity.ts
|
|
1505
|
-
function getAsymmetricRuneShare({
|
|
1506
|
-
liquidityUnits,
|
|
1507
|
-
poolUnits,
|
|
1508
|
-
runeDepth
|
|
1509
|
-
}) {
|
|
1510
|
-
const s = toTCSwapKitNumber(liquidityUnits);
|
|
1511
|
-
const T = toTCSwapKitNumber(poolUnits);
|
|
1512
|
-
const A = toTCSwapKitNumber(runeDepth);
|
|
1513
|
-
const part1 = s.mul(A);
|
|
1514
|
-
const part2 = T.mul(T).mul(2);
|
|
1515
|
-
const part3 = T.mul(s).mul(2);
|
|
1516
|
-
const part4 = s.mul(s);
|
|
1517
|
-
const part5 = T.mul(T).mul(T);
|
|
1518
|
-
const numerator = part1.mul(part2.sub(part3).add(part4));
|
|
1519
|
-
return numerator.div(part5);
|
|
1520
|
-
}
|
|
1521
|
-
function getAsymmetricAssetShare({
|
|
1522
|
-
liquidityUnits,
|
|
1523
|
-
poolUnits,
|
|
1524
|
-
assetDepth
|
|
1525
|
-
}) {
|
|
1526
|
-
const s = toTCSwapKitNumber(liquidityUnits);
|
|
1527
|
-
const T = toTCSwapKitNumber(poolUnits);
|
|
1528
|
-
const A = toTCSwapKitNumber(assetDepth);
|
|
1529
|
-
const part1 = s.mul(A);
|
|
1530
|
-
const part2 = T.mul(T).mul(2);
|
|
1531
|
-
const part3 = T.mul(s).mul(2);
|
|
1532
|
-
const part4 = s.mul(s);
|
|
1533
|
-
const numerator = part1.mul(part2.sub(part3).add(part4));
|
|
1534
|
-
const part5 = T.mul(T).mul(T);
|
|
1535
|
-
return numerator.div(part5);
|
|
1536
|
-
}
|
|
1537
|
-
function getAsymmetricRuneWithdrawAmount({
|
|
1538
|
-
percent,
|
|
1539
|
-
runeDepth,
|
|
1540
|
-
liquidityUnits,
|
|
1541
|
-
poolUnits
|
|
1542
|
-
}) {
|
|
1543
|
-
return getAsymmetricRuneShare({ runeDepth, liquidityUnits, poolUnits }).mul(percent);
|
|
1544
|
-
}
|
|
1545
|
-
function getAsymmetricAssetWithdrawAmount({
|
|
1546
|
-
percent,
|
|
1547
|
-
assetDepth,
|
|
1548
|
-
liquidityUnits,
|
|
1549
|
-
poolUnits
|
|
1550
|
-
}) {
|
|
1551
|
-
return getAsymmetricAssetShare({ assetDepth, liquidityUnits, poolUnits }).mul(percent);
|
|
1552
|
-
}
|
|
1553
|
-
var toTCSwapKitNumber = function(value) {
|
|
1554
|
-
return SwapKitNumber.fromBigInt(BigInt(value), BaseDecimal.THOR);
|
|
1555
|
-
};
|
|
1556
|
-
function getSymmetricPoolShare({
|
|
1557
|
-
liquidityUnits,
|
|
1558
|
-
poolUnits,
|
|
1559
|
-
runeDepth,
|
|
1560
|
-
assetDepth
|
|
1561
|
-
}) {
|
|
1562
|
-
return {
|
|
1563
|
-
assetAmount: toTCSwapKitNumber(assetDepth).mul(liquidityUnits).div(poolUnits),
|
|
1564
|
-
runeAmount: toTCSwapKitNumber(runeDepth).mul(liquidityUnits).div(poolUnits)
|
|
1565
|
-
};
|
|
1566
|
-
}
|
|
1567
|
-
function getSymmetricWithdraw({
|
|
1568
|
-
liquidityUnits,
|
|
1569
|
-
poolUnits,
|
|
1570
|
-
runeDepth,
|
|
1571
|
-
assetDepth,
|
|
1572
|
-
percent
|
|
1573
|
-
}) {
|
|
1574
|
-
return Object.fromEntries(Object.entries(getSymmetricPoolShare({ liquidityUnits, poolUnits, runeDepth, assetDepth })).map(([name, value]) => [name, value.mul(percent)]));
|
|
1575
|
-
}
|
|
1576
|
-
function getEstimatedPoolShare({
|
|
1577
|
-
runeDepth,
|
|
1578
|
-
poolUnits,
|
|
1579
|
-
assetDepth,
|
|
1580
|
-
liquidityUnits,
|
|
1581
|
-
runeAmount,
|
|
1582
|
-
assetAmount
|
|
1583
|
-
}) {
|
|
1584
|
-
const R = new SwapKitNumber({ value: runeDepth, decimal: 8 });
|
|
1585
|
-
const A = new SwapKitNumber({ value: assetDepth, decimal: 8 });
|
|
1586
|
-
const P = new SwapKitNumber({ value: poolUnits, decimal: 8 });
|
|
1587
|
-
const runeAddAmount = new SwapKitNumber({ value: runeAmount, decimal: 8 });
|
|
1588
|
-
const assetAddAmount = new SwapKitNumber({ value: assetAmount, decimal: 8 });
|
|
1589
|
-
const rA = runeAddAmount.mul(A);
|
|
1590
|
-
const aR = assetAddAmount.mul(R);
|
|
1591
|
-
const ra = runeAddAmount.mul(assetAddAmount);
|
|
1592
|
-
const RA = R.mul(A);
|
|
1593
|
-
const numerator = P.mul(rA.add(aR.add(ra.mul(2))));
|
|
1594
|
-
const denominator = rA.add(aR.add(RA.mul(2)));
|
|
1595
|
-
const liquidityUnitsAfterAdd = numerator.div(denominator);
|
|
1596
|
-
const estimatedLiquidityUnits = toTCSwapKitNumber(liquidityUnits).add(liquidityUnitsAfterAdd);
|
|
1597
|
-
if (liquidityUnitsAfterAdd.getBaseValue("number") === 0) {
|
|
1598
|
-
return estimatedLiquidityUnits.div(P).getBaseValue("number");
|
|
1599
|
-
}
|
|
1600
|
-
const newPoolUnits = P.add(estimatedLiquidityUnits);
|
|
1601
|
-
return estimatedLiquidityUnits.div(newPoolUnits).getBaseValue("number");
|
|
1602
|
-
}
|
|
1603
|
-
function getLiquiditySlippage({
|
|
1604
|
-
runeAmount,
|
|
1605
|
-
assetAmount,
|
|
1606
|
-
runeDepth,
|
|
1607
|
-
assetDepth
|
|
1608
|
-
}) {
|
|
1609
|
-
if (runeAmount === "0" || assetAmount === "0" || runeDepth === "0" || assetDepth === "0")
|
|
1610
|
-
return 0;
|
|
1611
|
-
const R = toTCSwapKitNumber(runeDepth);
|
|
1612
|
-
const T = toTCSwapKitNumber(assetDepth);
|
|
1613
|
-
const assetAddAmount = toTCSwapKitNumber(assetAmount);
|
|
1614
|
-
const runeAddAmount = toTCSwapKitNumber(runeAmount);
|
|
1615
|
-
const numerator = assetAddAmount.mul(R).sub(T.mul(runeAddAmount));
|
|
1616
|
-
const denominator = T.mul(runeAddAmount).add(R.mul(T));
|
|
1617
|
-
return Math.abs(numerator.div(denominator).getBaseValue("number"));
|
|
1618
|
-
}
|
|
1619
|
-
// src/helpers/memo.ts
|
|
1620
|
-
var getMemoFor = (memoType, options) => {
|
|
1621
|
-
switch (memoType) {
|
|
1622
|
-
case MemoType.LEAVE:
|
|
1623
|
-
case MemoType.BOND: {
|
|
1624
|
-
const { address } = options;
|
|
1625
|
-
return `${memoType}:${address}`;
|
|
1626
|
-
}
|
|
1627
|
-
case MemoType.UNBOND: {
|
|
1628
|
-
const { address, unbondAmount } = options;
|
|
1629
|
-
return `${memoType}:${address}:${unbondAmount}`;
|
|
1630
|
-
}
|
|
1631
|
-
case MemoType.THORNAME_REGISTER: {
|
|
1632
|
-
const { name, chain, address, owner } = options;
|
|
1633
|
-
return `${memoType}:${name}:${chain}:${address}${owner ? `:${owner}` : ""}`;
|
|
1634
|
-
}
|
|
1635
|
-
case MemoType.DEPOSIT: {
|
|
1636
|
-
const { chain, symbol, address, singleSide } = options;
|
|
1637
|
-
const getPoolIdentifier = (chain2, symbol2) => {
|
|
1638
|
-
switch (chain2) {
|
|
1639
|
-
case Chain.Litecoin:
|
|
1640
|
-
return "l";
|
|
1641
|
-
case Chain.Dogecoin:
|
|
1642
|
-
return "d";
|
|
1643
|
-
case Chain.BitcoinCash:
|
|
1644
|
-
return "c";
|
|
1645
|
-
default:
|
|
1646
|
-
return `${chain2}.${symbol2}`;
|
|
1647
|
-
}
|
|
1648
|
-
};
|
|
1649
|
-
return singleSide ? `${memoType}:${chain}/${symbol}` : `${memoType}:${getPoolIdentifier(chain, symbol)}:${address || ""}`;
|
|
1650
|
-
}
|
|
1651
|
-
case MemoType.WITHDRAW: {
|
|
1652
|
-
const { chain, ticker, symbol, basisPoints, targetAssetString, singleSide } = options;
|
|
1653
|
-
const shortenedSymbol = chain === "ETH" && ticker !== "ETH" ? `${ticker}-${symbol.slice(-3)}` : symbol;
|
|
1654
|
-
const target = !singleSide && targetAssetString ? `:${targetAssetString}` : "";
|
|
1655
|
-
const assetDivider = singleSide ? "/" : ".";
|
|
1656
|
-
return `${memoType}:${chain}${assetDivider}${shortenedSymbol}:${basisPoints}${target}`;
|
|
1657
|
-
}
|
|
1658
|
-
case MemoType.OPEN_LOAN:
|
|
1659
|
-
case MemoType.CLOSE_LOAN: {
|
|
1660
|
-
const { asset, address } = options;
|
|
1661
|
-
return `${memoType}:${asset}:${address}`;
|
|
1662
|
-
}
|
|
1663
|
-
default:
|
|
1664
|
-
return "";
|
|
1665
|
-
}
|
|
1666
|
-
};
|
|
1667
|
-
// src/modules/swapKitError.ts
|
|
1668
|
-
var errorMessages = {
|
|
1669
|
-
core_wallet_connection_not_found: 10001,
|
|
1670
|
-
core_estimated_max_spendable_chain_not_supported: 10002,
|
|
1671
|
-
core_extend_error: 10003,
|
|
1672
|
-
core_inbound_data_not_found: 10004,
|
|
1673
|
-
core_approve_asset_address_or_from_not_found: 10005,
|
|
1674
|
-
core_plugin_not_found: 10006,
|
|
1675
|
-
core_plugin_swap_not_found: 10007,
|
|
1676
|
-
core_chain_halted: 10099,
|
|
1677
|
-
core_wallet_xdefi_not_installed: 10101,
|
|
1678
|
-
core_wallet_evmwallet_not_installed: 10102,
|
|
1679
|
-
core_wallet_walletconnect_not_installed: 10103,
|
|
1680
|
-
core_wallet_keystore_not_installed: 10104,
|
|
1681
|
-
core_wallet_ledger_not_installed: 10105,
|
|
1682
|
-
core_wallet_trezor_not_installed: 10106,
|
|
1683
|
-
core_wallet_keplr_not_installed: 10107,
|
|
1684
|
-
core_wallet_okx_not_installed: 10108,
|
|
1685
|
-
core_wallet_keepkey_not_installed: 10109,
|
|
1686
|
-
core_swap_invalid_params: 10200,
|
|
1687
|
-
core_swap_route_not_complete: 10201,
|
|
1688
|
-
core_swap_asset_not_recognized: 10202,
|
|
1689
|
-
core_swap_contract_not_found: 10203,
|
|
1690
|
-
core_swap_route_transaction_not_found: 10204,
|
|
1691
|
-
core_swap_contract_not_supported: 10205,
|
|
1692
|
-
core_swap_transaction_error: 10206,
|
|
1693
|
-
core_swap_quote_mode_not_supported: 10207,
|
|
1694
|
-
core_transaction_deposit_error: 10301,
|
|
1695
|
-
core_transaction_create_liquidity_rune_error: 10302,
|
|
1696
|
-
core_transaction_create_liquidity_asset_error: 10303,
|
|
1697
|
-
core_transaction_create_liquidity_invalid_params: 10304,
|
|
1698
|
-
core_transaction_add_liquidity_invalid_params: 10305,
|
|
1699
|
-
core_transaction_add_liquidity_no_rune_address: 10306,
|
|
1700
|
-
core_transaction_add_liquidity_rune_error: 10307,
|
|
1701
|
-
core_transaction_add_liquidity_asset_error: 10308,
|
|
1702
|
-
core_transaction_withdraw_error: 10309,
|
|
1703
|
-
core_transaction_deposit_to_pool_error: 10310,
|
|
1704
|
-
core_transaction_deposit_insufficient_funds_error: 10311,
|
|
1705
|
-
core_transaction_deposit_gas_error: 10312,
|
|
1706
|
-
core_transaction_invalid_sender_address: 10313,
|
|
1707
|
-
core_transaction_deposit_server_error: 10314,
|
|
1708
|
-
core_transaction_user_rejected: 10315,
|
|
1709
|
-
wallet_ledger_connection_error: 20001,
|
|
1710
|
-
wallet_ledger_connection_claimed: 20002,
|
|
1711
|
-
wallet_ledger_get_address_error: 20003,
|
|
1712
|
-
wallet_ledger_device_not_found: 20004,
|
|
1713
|
-
wallet_ledger_device_locked: 20005,
|
|
1714
|
-
chainflip_channel_error: 30001,
|
|
1715
|
-
chainflip_broker_recipient_error: 30002,
|
|
1716
|
-
helpers_number_different_decimals: 99101
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
class SwapKitError extends Error {
|
|
1720
|
-
constructor(errorKey, sourceError) {
|
|
1721
|
-
if (sourceError) {
|
|
1722
|
-
console.error(sourceError, {
|
|
1723
|
-
stack: sourceError?.stack,
|
|
1724
|
-
message: sourceError?.message
|
|
1725
|
-
});
|
|
1726
|
-
}
|
|
1727
|
-
super(errorKey, {
|
|
1728
|
-
cause: { code: errorMessages[errorKey], message: errorKey }
|
|
1729
|
-
});
|
|
1730
|
-
Object.setPrototypeOf(this, SwapKitError.prototype);
|
|
1731
|
-
}
|
|
1732
|
-
}
|
|
1733
|
-
|
|
1734
|
-
// src/helpers/others.ts
|
|
1735
|
-
function getTHORNameCost(numberOfYears) {
|
|
1736
|
-
if (numberOfYears < 0)
|
|
1737
|
-
throw new Error("Invalid number of years");
|
|
1738
|
-
return 10 + numberOfYears;
|
|
1739
|
-
}
|
|
1740
|
-
function getMAYANameCost(numberOfYears) {
|
|
1741
|
-
if (numberOfYears < 0)
|
|
1742
|
-
throw new Error("Invalid number of year");
|
|
1743
|
-
return Math.round((10 + numberOfYears * 1.0512) * 10000000000) / 10000000000;
|
|
1744
|
-
}
|
|
1745
|
-
function derivationPathToString([network3, chainId, account, change, index]) {
|
|
1746
|
-
const shortPath = typeof index !== "number";
|
|
1747
|
-
return `m/${network3}'/${chainId}'/${account}'/${change}${shortPath ? "" : `/${index}`}`;
|
|
1748
|
-
}
|
|
1749
|
-
function wrapWithThrow(fn, errorKey) {
|
|
1750
|
-
try {
|
|
1751
|
-
return fn();
|
|
1752
|
-
} catch (error) {
|
|
1753
|
-
if (errorKey) {
|
|
1754
|
-
throw new SwapKitError(errorKey, error);
|
|
1755
|
-
}
|
|
1756
|
-
return console.error(error);
|
|
1757
|
-
}
|
|
1758
|
-
}
|
|
1759
|
-
// src/helpers/validators.ts
|
|
1760
|
-
function validateIdentifier(identifier = "") {
|
|
1761
|
-
const uppercasedIdentifier = identifier.toUpperCase();
|
|
1762
|
-
const [chain] = uppercasedIdentifier.split(".");
|
|
1763
|
-
if (supportedChains.includes(chain))
|
|
1764
|
-
return true;
|
|
1765
|
-
const [synthChain] = uppercasedIdentifier.split("/");
|
|
1766
|
-
if (supportedChains.includes(synthChain))
|
|
1767
|
-
return true;
|
|
1768
|
-
throw new Error(`Invalid identifier: ${identifier}. Expected format: <Chain>.<Ticker> or <Chain>.<Ticker>-<ContractAddress>`);
|
|
1769
|
-
}
|
|
1770
|
-
function validateTNS(name) {
|
|
1771
|
-
if (name.length > 30)
|
|
1772
|
-
return false;
|
|
1773
|
-
const regex = /^[a-zA-Z0-9+_-]+$/g;
|
|
1774
|
-
return !!name.match(regex);
|
|
1775
|
-
}
|
|
1776
|
-
var supportedChains = [...Object.values(Chain), "TERRA"];
|
|
1777
|
-
// src/helpers/web3wallets.ts
|
|
1778
|
-
var methodsToWrap = [
|
|
1779
|
-
"approve",
|
|
1780
|
-
"approvedAmount",
|
|
1781
|
-
"call",
|
|
1782
|
-
"sendTransaction",
|
|
1783
|
-
"transfer",
|
|
1784
|
-
"isApproved",
|
|
1785
|
-
"approvedAmount",
|
|
1786
|
-
"EIP1193SendTransaction",
|
|
1787
|
-
"getFeeData",
|
|
1788
|
-
"broadcastTransaction",
|
|
1789
|
-
"estimateCall",
|
|
1790
|
-
"estimateGasLimit",
|
|
1791
|
-
"estimateGasPrices",
|
|
1792
|
-
"createContractTxObject"
|
|
1793
|
-
];
|
|
1794
|
-
var wrapMethodWithNetworkSwitch = (func, provider, chainId) => async (...args) => {
|
|
1795
|
-
try {
|
|
1796
|
-
await switchEVMWalletNetwork(provider, chainId);
|
|
1797
|
-
} catch (error) {
|
|
1798
|
-
throw new Error(`Failed to switch network: ${error}`);
|
|
1799
|
-
}
|
|
1800
|
-
return func(...args);
|
|
1801
|
-
};
|
|
1802
|
-
var providerRequest = ({ provider, params, method }) => {
|
|
1803
|
-
if (!provider?.send)
|
|
1804
|
-
throw new Error("Provider not found");
|
|
1805
|
-
const providerParams = params ? Array.isArray(params) ? params : [params] : [];
|
|
1806
|
-
return provider.send(method, providerParams);
|
|
1807
|
-
};
|
|
1808
|
-
var prepareNetworkSwitch = ({
|
|
1809
|
-
toolbox,
|
|
1810
|
-
chainId,
|
|
1811
|
-
provider = window.ethereum
|
|
1812
|
-
}) => {
|
|
1813
|
-
const wrappedMethods = methodsToWrap.reduce((object, methodName) => {
|
|
1814
|
-
if (!toolbox[methodName])
|
|
1815
|
-
return object;
|
|
1816
|
-
const method = toolbox[methodName];
|
|
1817
|
-
if (typeof method !== "function")
|
|
1818
|
-
return object;
|
|
1819
|
-
return {
|
|
1820
|
-
...object,
|
|
1821
|
-
[methodName]: wrapMethodWithNetworkSwitch(method, provider, chainId)
|
|
1822
|
-
};
|
|
1823
|
-
}, {});
|
|
1824
|
-
return { ...toolbox, ...wrappedMethods };
|
|
1825
|
-
};
|
|
1826
|
-
var addEVMWalletNetwork = (provider, networkParams) => providerRequest({ provider, method: "wallet_addEthereumChain", params: [networkParams] });
|
|
1827
|
-
var switchEVMWalletNetwork = (provider, chainId = ChainId.EthereumHex) => providerRequest({ provider, method: "wallet_switchEthereumChain", params: [{ chainId }] });
|
|
1828
|
-
var addAccountsChangedCallback = (callback) => {
|
|
1829
|
-
window.ethereum?.on("accountsChanged", () => callback());
|
|
1830
|
-
window.xfi?.ethereum.on("accountsChanged", () => callback());
|
|
1831
|
-
};
|
|
1832
|
-
var getETHDefaultWallet = () => {
|
|
1833
|
-
const { isTrust, isBraveWallet, __XDEFI, overrideIsMetaMask, selectedProvider } = window?.ethereum || {};
|
|
1834
|
-
if (isTrust)
|
|
1835
|
-
return WalletOption.TRUSTWALLET_WEB;
|
|
1836
|
-
if (isBraveWallet)
|
|
1837
|
-
return WalletOption.BRAVE;
|
|
1838
|
-
if (overrideIsMetaMask && selectedProvider?.isCoinbaseWallet)
|
|
1839
|
-
return WalletOption.COINBASE_WEB;
|
|
1840
|
-
if (__XDEFI)
|
|
1841
|
-
WalletOption.XDEFI;
|
|
1842
|
-
return WalletOption.METAMASK;
|
|
1843
|
-
};
|
|
1844
|
-
var isDetected = (walletOption) => {
|
|
1845
|
-
return listWeb3EVMWallets().includes(walletOption);
|
|
1846
|
-
};
|
|
1847
|
-
var listWeb3EVMWallets = () => {
|
|
1848
|
-
const metamaskEnabled = window?.ethereum && !window.ethereum?.isBraveWallet;
|
|
1849
|
-
const xdefiEnabled = window?.xfi || window?.ethereum?.__XDEFI;
|
|
1850
|
-
const braveEnabled = window?.ethereum?.isBraveWallet;
|
|
1851
|
-
const trustEnabled = window?.ethereum?.isTrust || window?.trustwallet;
|
|
1852
|
-
const coinbaseEnabled = window?.ethereum?.overrideIsMetaMask && window?.ethereum?.selectedProvider?.isCoinbaseWallet || window?.coinbaseWalletExtension;
|
|
1853
|
-
const wallets = [];
|
|
1854
|
-
if (metamaskEnabled)
|
|
1855
|
-
wallets.push(WalletOption.METAMASK);
|
|
1856
|
-
if (xdefiEnabled)
|
|
1857
|
-
wallets.push(WalletOption.XDEFI);
|
|
1858
|
-
if (braveEnabled)
|
|
1859
|
-
wallets.push(WalletOption.BRAVE);
|
|
1860
|
-
if (trustEnabled)
|
|
1861
|
-
wallets.push(WalletOption.TRUSTWALLET_WEB);
|
|
1862
|
-
if (coinbaseEnabled)
|
|
1863
|
-
wallets.push(WalletOption.COINBASE_WEB);
|
|
1864
|
-
if (okxMobileEnabled())
|
|
1865
|
-
wallets.push(WalletOption.OKX_MOBILE);
|
|
1866
|
-
return wallets;
|
|
1867
|
-
};
|
|
1868
|
-
var okxMobileEnabled = () => {
|
|
1869
|
-
const ua = navigator.userAgent;
|
|
1870
|
-
const isIOS = /iphone|ipad|ipod|ios/i.test(ua);
|
|
1871
|
-
const isAndroid = /android|XiaoMi|MiuiBrowser/i.test(ua);
|
|
1872
|
-
const isMobile = isIOS || isAndroid;
|
|
1873
|
-
const isOKApp = /OKApp/i.test(ua);
|
|
1874
|
-
return isMobile && isOKApp;
|
|
1875
|
-
};
|
|
1876
|
-
var isWeb3Detected = () => typeof window.ethereum !== "undefined";
|
|
1877
|
-
// src/modules/bigIntArithmetics.ts
|
|
1878
|
-
function formatBigIntToSafeValue({
|
|
1879
|
-
value,
|
|
1880
|
-
bigIntDecimal = DEFAULT_DECIMAL,
|
|
1881
|
-
decimal = DEFAULT_DECIMAL
|
|
1882
|
-
}) {
|
|
1883
|
-
if (decimal === 0)
|
|
1884
|
-
return value.toString();
|
|
1885
|
-
const isNegative = value < 0n;
|
|
1886
|
-
let valueString = value.toString().substring(isNegative ? 1 : 0);
|
|
1887
|
-
const padLength = decimal - (valueString.length - 1);
|
|
1888
|
-
if (padLength > 0) {
|
|
1889
|
-
valueString = "0".repeat(padLength) + valueString;
|
|
1890
|
-
}
|
|
1891
|
-
const decimalIndex = valueString.length - decimal;
|
|
1892
|
-
let decimalString = valueString.slice(-decimal);
|
|
1893
|
-
if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
|
|
1894
|
-
decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
|
|
1895
|
-
} else {
|
|
1896
|
-
decimalString = decimalString.substring(0, bigIntDecimal);
|
|
1897
|
-
}
|
|
1898
|
-
return `${isNegative ? "-" : ""}${valueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
|
|
1899
|
-
}
|
|
1900
|
-
var toSafeValue = function(value) {
|
|
1901
|
-
const parsedValue = typeof value === "number" ? numberFormatter.format(value) : getStringValue(value);
|
|
1902
|
-
const splitValue = `${parsedValue}`.replaceAll(",", ".").split(".");
|
|
1903
|
-
return splitValue.length > 1 ? `${splitValue.slice(0, -1).join("")}.${splitValue.at(-1)}` : splitValue[0] || "0";
|
|
1904
|
-
};
|
|
1905
|
-
var getFloatDecimals = function(value) {
|
|
1906
|
-
const decimals = value.split(".")[1]?.length || 0;
|
|
1907
|
-
return Math.max(decimals, DEFAULT_DECIMAL);
|
|
1908
|
-
};
|
|
1909
|
-
var getStringValue = function(param) {
|
|
1910
|
-
return typeof param === "object" ? "getValue" in param ? param.getValue("string") : param.value : param;
|
|
1911
|
-
};
|
|
1912
|
-
var DEFAULT_DECIMAL = 8;
|
|
1913
|
-
var toMultiplier = (decimal) => 10n ** BigInt(decimal);
|
|
1914
|
-
var decimalFromMultiplier = (multiplier) => Math.log10(Number.parseFloat(multiplier.toString()));
|
|
1915
|
-
|
|
1916
|
-
class BigIntArithmetics {
|
|
1917
|
-
decimalMultiplier = 10n ** 8n;
|
|
1918
|
-
bigIntValue = 0n;
|
|
1919
|
-
decimal;
|
|
1920
|
-
static fromBigInt(value, decimal) {
|
|
1921
|
-
return new BigIntArithmetics({
|
|
1922
|
-
decimal,
|
|
1923
|
-
value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
|
|
1924
|
-
});
|
|
1925
|
-
}
|
|
1926
|
-
static shiftDecimals({
|
|
1927
|
-
value,
|
|
1928
|
-
from,
|
|
1929
|
-
to
|
|
1930
|
-
}) {
|
|
1931
|
-
return BigIntArithmetics.fromBigInt(value.getBaseValue("bigint") * toMultiplier(to) / toMultiplier(from), to);
|
|
1932
|
-
}
|
|
1933
|
-
constructor(params) {
|
|
1934
|
-
const value = getStringValue(params);
|
|
1935
|
-
const isComplex = typeof params === "object";
|
|
1936
|
-
this.decimal = isComplex ? params.decimal : undefined;
|
|
1937
|
-
this.decimalMultiplier = isComplex && "decimalMultiplier" in params ? params.decimalMultiplier : toMultiplier(Math.max(getFloatDecimals(toSafeValue(value)), this.decimal || 0));
|
|
1938
|
-
this.#setValue(value);
|
|
1939
|
-
}
|
|
1940
|
-
set(value) {
|
|
1941
|
-
return new this.constructor({ decimal: this.decimal, value, identifier: this.toString() });
|
|
1942
|
-
}
|
|
1943
|
-
add(...args) {
|
|
1944
|
-
return this.#arithmetics("add", ...args);
|
|
1945
|
-
}
|
|
1946
|
-
sub(...args) {
|
|
1947
|
-
return this.#arithmetics("sub", ...args);
|
|
1948
|
-
}
|
|
1949
|
-
mul(...args) {
|
|
1950
|
-
return this.#arithmetics("mul", ...args);
|
|
1951
|
-
}
|
|
1952
|
-
div(...args) {
|
|
1953
|
-
return this.#arithmetics("div", ...args);
|
|
1954
|
-
}
|
|
1955
|
-
gt(value) {
|
|
1956
|
-
return this.#comparison("gt", value);
|
|
1957
|
-
}
|
|
1958
|
-
gte(value) {
|
|
1959
|
-
return this.#comparison("gte", value);
|
|
1960
|
-
}
|
|
1961
|
-
lt(value) {
|
|
1962
|
-
return this.#comparison("lt", value);
|
|
1963
|
-
}
|
|
1964
|
-
lte(value) {
|
|
1965
|
-
return this.#comparison("lte", value);
|
|
1966
|
-
}
|
|
1967
|
-
eqValue(value) {
|
|
1968
|
-
return this.#comparison("eqValue", value);
|
|
1969
|
-
}
|
|
1970
|
-
getValue(type) {
|
|
1971
|
-
const value = this.formatBigIntToSafeValue(this.bigIntValue, this.decimal || decimalFromMultiplier(this.decimalMultiplier));
|
|
1972
|
-
switch (type) {
|
|
1973
|
-
case "number":
|
|
1974
|
-
return Number(value);
|
|
1975
|
-
case "string":
|
|
1976
|
-
return value;
|
|
1977
|
-
case "bigint":
|
|
1978
|
-
return this.bigIntValue * 10n ** BigInt(this.decimal || 8n) / this.decimalMultiplier;
|
|
1979
|
-
}
|
|
1980
|
-
}
|
|
1981
|
-
getBaseValue(type) {
|
|
1982
|
-
const divisor = this.decimalMultiplier / toMultiplier(this.decimal || BaseDecimal.THOR);
|
|
1983
|
-
const baseValue = this.bigIntValue / divisor;
|
|
1984
|
-
switch (type) {
|
|
1985
|
-
case "number":
|
|
1986
|
-
return Number(baseValue);
|
|
1987
|
-
case "string":
|
|
1988
|
-
return baseValue.toString();
|
|
1989
|
-
case "bigint":
|
|
1990
|
-
return baseValue;
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
getBigIntValue(value, decimal) {
|
|
1994
|
-
if (!decimal && typeof value === "object")
|
|
1995
|
-
return value.bigIntValue;
|
|
1996
|
-
const stringValue = getStringValue(value);
|
|
1997
|
-
const safeValue = toSafeValue(stringValue);
|
|
1998
|
-
if (safeValue === "0" || safeValue === "undefined")
|
|
1999
|
-
return 0n;
|
|
2000
|
-
return this.#toBigInt(safeValue, decimal);
|
|
2001
|
-
}
|
|
2002
|
-
toSignificant(significantDigits = 6) {
|
|
2003
|
-
const [int, dec] = this.getValue("string").split(".");
|
|
2004
|
-
const integer = int || "";
|
|
2005
|
-
const decimal = dec || "";
|
|
2006
|
-
const valueLength = Number.parseInt(integer) ? integer.length + decimal.length : decimal.length;
|
|
2007
|
-
if (valueLength <= significantDigits) {
|
|
2008
|
-
return this.getValue("string");
|
|
2009
|
-
}
|
|
2010
|
-
if (integer.length >= significantDigits) {
|
|
2011
|
-
return integer.slice(0, significantDigits).padEnd(integer.length, "0");
|
|
2012
|
-
}
|
|
2013
|
-
if (Number.parseInt(integer)) {
|
|
2014
|
-
return `${integer}.${decimal.slice(0, significantDigits - integer.length)}`.padEnd(significantDigits - integer.length, "0");
|
|
2015
|
-
}
|
|
2016
|
-
const trimmedDecimal = Number.parseInt(decimal);
|
|
2017
|
-
const slicedDecimal = `${trimmedDecimal}`.slice(0, significantDigits);
|
|
2018
|
-
return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
|
|
2019
|
-
}
|
|
2020
|
-
toFixed(fixedDigits = 6) {
|
|
2021
|
-
const [int, dec] = this.getValue("string").split(".");
|
|
2022
|
-
const integer = int || "";
|
|
2023
|
-
const decimal = dec || "";
|
|
2024
|
-
if (Number.parseInt(integer)) {
|
|
2025
|
-
return `${integer}.${decimal.slice(0, fixedDigits)}`.padEnd(fixedDigits, "0");
|
|
2026
|
-
}
|
|
2027
|
-
const trimmedDecimal = Number.parseInt(decimal);
|
|
2028
|
-
const slicedDecimal = `${trimmedDecimal}`.slice(0, fixedDigits);
|
|
2029
|
-
return `0.${slicedDecimal.padStart(decimal.length - `${trimmedDecimal}`.length + slicedDecimal.length, "0")}`;
|
|
2030
|
-
}
|
|
2031
|
-
toAbbreviation(digits = 2) {
|
|
2032
|
-
const value = this.getValue("number");
|
|
2033
|
-
const abbreviations = ["", "K", "M", "B", "T", "Q", "Qi", "S"];
|
|
2034
|
-
const tier = Math.floor(Math.log10(Math.abs(value)) / 3);
|
|
2035
|
-
const suffix = abbreviations[tier];
|
|
2036
|
-
if (!suffix)
|
|
2037
|
-
return this.getValue("string");
|
|
2038
|
-
const scale = 10 ** (tier * 3);
|
|
2039
|
-
const scaled = value / scale;
|
|
2040
|
-
return `${scaled.toFixed(digits)}${suffix}`;
|
|
2041
|
-
}
|
|
2042
|
-
toCurrency(currency = "$", {
|
|
2043
|
-
currencyPosition = "start",
|
|
2044
|
-
decimal = 2,
|
|
2045
|
-
decimalSeparator = ".",
|
|
2046
|
-
thousandSeparator = ","
|
|
2047
|
-
} = {}) {
|
|
2048
|
-
const value = this.getValue("number");
|
|
2049
|
-
const [int = "", dec = ""] = value.toFixed(6).split(".");
|
|
2050
|
-
const integer = int.replace(/\B(?=(\d{3})+(?!\d))/g, thousandSeparator);
|
|
2051
|
-
const parsedValue = int || dec ? int === "0" ? `${Number.parseFloat(`0.${dec}`)}`.replace(".", decimalSeparator) : `${integer}${Number.parseInt(dec) ? `${decimalSeparator}${dec.slice(0, decimal)}` : ""}` : "0.00";
|
|
2052
|
-
return `${currencyPosition === "start" ? currency : ""}${parsedValue}${currencyPosition === "end" ? currency : ""}`;
|
|
2053
|
-
}
|
|
2054
|
-
formatBigIntToSafeValue(value, decimal) {
|
|
2055
|
-
const bigIntDecimal = decimal || this.decimal || DEFAULT_DECIMAL;
|
|
2056
|
-
const decimalToUseForConversion = Math.max(bigIntDecimal, decimalFromMultiplier(this.decimalMultiplier));
|
|
2057
|
-
const isNegative = value < 0n;
|
|
2058
|
-
const valueString = value.toString().substring(isNegative ? 1 : 0);
|
|
2059
|
-
const padLength = decimalToUseForConversion - (valueString.length - 1);
|
|
2060
|
-
const parsedValueString = padLength > 0 ? "0".repeat(padLength) + valueString : valueString;
|
|
2061
|
-
const decimalIndex = parsedValueString.length - decimalToUseForConversion;
|
|
2062
|
-
let decimalString = parsedValueString.slice(-decimalToUseForConversion);
|
|
2063
|
-
if (Number.parseInt(decimalString[bigIntDecimal] || "0") >= 5) {
|
|
2064
|
-
decimalString = `${decimalString.substring(0, bigIntDecimal - 1)}${(Number.parseInt(decimalString[bigIntDecimal - 1] || "0") + 1).toString()}`;
|
|
2065
|
-
} else {
|
|
2066
|
-
decimalString = decimalString.substring(0, bigIntDecimal);
|
|
2067
|
-
}
|
|
2068
|
-
return `${isNegative ? "-" : ""}${parsedValueString.slice(0, decimalIndex)}.${decimalString}`.replace(/\.?0*$/, "");
|
|
2069
|
-
}
|
|
2070
|
-
#arithmetics(method, ...args) {
|
|
2071
|
-
const precisionDecimal = this.#retrievePrecisionDecimal(this, ...args);
|
|
2072
|
-
const decimal = Math.max(precisionDecimal, decimalFromMultiplier(this.decimalMultiplier));
|
|
2073
|
-
const precisionDecimalMultiplier = toMultiplier(decimal);
|
|
2074
|
-
const result = args.reduce((acc, arg) => {
|
|
2075
|
-
const value2 = this.getBigIntValue(arg, decimal);
|
|
2076
|
-
switch (method) {
|
|
2077
|
-
case "add":
|
|
2078
|
-
return acc + value2;
|
|
2079
|
-
case "sub":
|
|
2080
|
-
return acc - value2;
|
|
2081
|
-
case "mul":
|
|
2082
|
-
return acc * value2 / precisionDecimalMultiplier;
|
|
2083
|
-
case "div": {
|
|
2084
|
-
if (value2 === 0n)
|
|
2085
|
-
throw new RangeError("Division by zero");
|
|
2086
|
-
return acc * precisionDecimalMultiplier / value2;
|
|
2087
|
-
}
|
|
2088
|
-
default:
|
|
2089
|
-
return acc;
|
|
2090
|
-
}
|
|
2091
|
-
}, this.bigIntValue * precisionDecimalMultiplier / this.decimalMultiplier);
|
|
2092
|
-
const value = formatBigIntToSafeValue({
|
|
2093
|
-
bigIntDecimal: decimal,
|
|
2094
|
-
decimal,
|
|
2095
|
-
value: result
|
|
2096
|
-
});
|
|
2097
|
-
return new this.constructor({
|
|
2098
|
-
decimalMultiplier: toMultiplier(decimal),
|
|
2099
|
-
decimal: this.decimal,
|
|
2100
|
-
value,
|
|
2101
|
-
identifier: this.toString()
|
|
2102
|
-
});
|
|
2103
|
-
}
|
|
2104
|
-
#comparison(method, ...args) {
|
|
2105
|
-
const decimal = this.#retrievePrecisionDecimal(this, ...args);
|
|
2106
|
-
const value = this.getBigIntValue(args[0] || "0", decimal);
|
|
2107
|
-
const compareToValue = this.getBigIntValue(this, decimal);
|
|
2108
|
-
switch (method) {
|
|
2109
|
-
case "gt":
|
|
2110
|
-
return compareToValue > value;
|
|
2111
|
-
case "gte":
|
|
2112
|
-
return compareToValue >= value;
|
|
2113
|
-
case "lt":
|
|
2114
|
-
return compareToValue < value;
|
|
2115
|
-
case "lte":
|
|
2116
|
-
return compareToValue <= value;
|
|
2117
|
-
case "eqValue":
|
|
2118
|
-
return compareToValue === value;
|
|
2119
|
-
}
|
|
2120
|
-
}
|
|
2121
|
-
#setValue(value) {
|
|
2122
|
-
const safeValue = toSafeValue(value) || "0";
|
|
2123
|
-
this.bigIntValue = this.#toBigInt(safeValue);
|
|
2124
|
-
}
|
|
2125
|
-
#retrievePrecisionDecimal(...args) {
|
|
2126
|
-
const decimals = args.map((arg) => {
|
|
2127
|
-
const isObject = typeof arg === "object";
|
|
2128
|
-
const value = isObject ? arg.decimal || decimalFromMultiplier(arg.decimalMultiplier) : getFloatDecimals(toSafeValue(arg));
|
|
2129
|
-
return value;
|
|
2130
|
-
}).filter(Boolean);
|
|
2131
|
-
return Math.max(...decimals, DEFAULT_DECIMAL);
|
|
2132
|
-
}
|
|
2133
|
-
#toBigInt(value, decimal) {
|
|
2134
|
-
const multiplier = decimal ? toMultiplier(decimal) : this.decimalMultiplier;
|
|
2135
|
-
const padDecimal = decimalFromMultiplier(multiplier);
|
|
2136
|
-
const [integerPart = "", decimalPart = ""] = value.split(".");
|
|
2137
|
-
return BigInt(`${integerPart}${decimalPart.padEnd(padDecimal, "0")}`);
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
var numberFormatter = Intl.NumberFormat("fullwide", {
|
|
2141
|
-
useGrouping: false,
|
|
2142
|
-
maximumFractionDigits: 20
|
|
2143
|
-
});
|
|
2144
|
-
|
|
2145
|
-
// src/modules/swapKitNumber.ts
|
|
2146
|
-
class SwapKitNumber extends BigIntArithmetics {
|
|
2147
|
-
constructor() {
|
|
2148
|
-
super(...arguments);
|
|
2149
|
-
}
|
|
2150
|
-
eq(value) {
|
|
2151
|
-
return this.eqValue(value);
|
|
2152
|
-
}
|
|
2153
|
-
static fromBigInt(value, decimal) {
|
|
2154
|
-
return new SwapKitNumber({
|
|
2155
|
-
decimal,
|
|
2156
|
-
value: formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal })
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
|
|
2161
|
-
// src/modules/assetValue.ts
|
|
2162
|
-
function getMinAmountByChain(chain) {
|
|
2163
|
-
const asset2 = AssetValue.fromChainOrSignature(chain);
|
|
2164
|
-
switch (chain) {
|
|
2165
|
-
case Chain.Bitcoin:
|
|
2166
|
-
case Chain.Litecoin:
|
|
2167
|
-
case Chain.BitcoinCash:
|
|
2168
|
-
return asset2.set(0.00010001);
|
|
2169
|
-
case Chain.Dogecoin:
|
|
2170
|
-
return asset2.set(1.00000001);
|
|
2171
|
-
case Chain.Avalanche:
|
|
2172
|
-
case Chain.Ethereum:
|
|
2173
|
-
return asset2.set(0.00000001);
|
|
2174
|
-
case Chain.THORChain:
|
|
2175
|
-
case Chain.Maya:
|
|
2176
|
-
return asset2.set(0);
|
|
2177
|
-
case Chain.Cosmos:
|
|
2178
|
-
return asset2.set(0.000001);
|
|
2179
|
-
default:
|
|
2180
|
-
return asset2.set(0.00000001);
|
|
2181
|
-
}
|
|
2182
|
-
}
|
|
2183
|
-
async function createAssetValue(identifier, value = 0) {
|
|
2184
|
-
validateIdentifier(identifier);
|
|
2185
|
-
const staticToken = staticTokensMap.get(identifier.toUpperCase());
|
|
2186
|
-
const decimal = staticToken?.decimal || await getDecimal(getAssetInfo(identifier));
|
|
2187
|
-
if (!staticToken) {
|
|
2188
|
-
staticTokensMap.set(identifier.toUpperCase(), { identifier, decimal });
|
|
2189
|
-
}
|
|
2190
|
-
return new AssetValue({ decimal, value: safeValue(value, decimal), identifier });
|
|
2191
|
-
}
|
|
2192
|
-
var createSyntheticAssetValue = function(identifier, value = 0) {
|
|
2193
|
-
const [synthChain, symbol] = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
|
|
2194
|
-
if (!(synthChain && symbol))
|
|
2195
|
-
throw new Error("Invalid asset identifier");
|
|
2196
|
-
return new AssetValue({
|
|
2197
|
-
decimal: 8,
|
|
2198
|
-
value: safeValue(value, 8),
|
|
2199
|
-
identifier: `${Chain.THORChain}.${synthChain}/${symbol}`
|
|
2200
|
-
});
|
|
2201
|
-
};
|
|
2202
|
-
var safeValue = function(value, decimal) {
|
|
2203
|
-
return typeof value === "bigint" ? formatBigIntToSafeValue({ value, bigIntDecimal: decimal, decimal }) : value;
|
|
2204
|
-
};
|
|
2205
|
-
var getAssetInfo = function(identifier) {
|
|
2206
|
-
const isSynthetic = identifier.slice(0, 14).includes("/");
|
|
2207
|
-
const isThorchain = identifier.split(".")?.[0]?.toUpperCase() === Chain.THORChain;
|
|
2208
|
-
const isMaya = identifier.split(".")?.[0]?.toUpperCase() === Chain.Maya;
|
|
2209
|
-
const [synthChain, synthSymbol = ""] = isThorchain || isMaya ? identifier.split(".").slice(1).join().split("/") : identifier.split("/");
|
|
2210
|
-
if (isSynthetic && !(synthChain && synthSymbol))
|
|
2211
|
-
throw new Error("Invalid asset identifier");
|
|
2212
|
-
const adjustedIdentifier = identifier.includes(".") && !isSynthetic ? identifier : `${isMaya ? Chain.Maya : Chain.THORChain}.${synthSymbol}`;
|
|
2213
|
-
const [chain, ...rest] = adjustedIdentifier.split(".");
|
|
2214
|
-
const symbol = isSynthetic ? synthSymbol : rest.join(".");
|
|
2215
|
-
const splitSymbol = symbol.split("-");
|
|
2216
|
-
const ticker = splitSymbol.length === 1 ? splitSymbol[0] : splitSymbol.slice(0, -1).join("-");
|
|
2217
|
-
const address = splitSymbol.length === 1 ? undefined : splitSymbol[splitSymbol.length - 1];
|
|
2218
|
-
return {
|
|
2219
|
-
address: address?.toLowerCase(),
|
|
2220
|
-
chain,
|
|
2221
|
-
isGasAsset: isGasAsset({ chain, symbol }),
|
|
2222
|
-
isSynthetic,
|
|
2223
|
-
symbol: (isSynthetic ? `${synthChain}/` : "") + (address ? `${ticker}-${address?.toLowerCase() ?? ""}` : symbol),
|
|
2224
|
-
ticker
|
|
2225
|
-
};
|
|
2226
|
-
};
|
|
2227
|
-
var staticTokensMap = new Map;
|
|
2228
|
-
|
|
2229
|
-
class AssetValue extends BigIntArithmetics {
|
|
2230
|
-
address;
|
|
2231
|
-
chain;
|
|
2232
|
-
isGasAsset = false;
|
|
2233
|
-
isSynthetic = false;
|
|
2234
|
-
symbol;
|
|
2235
|
-
tax;
|
|
2236
|
-
ticker;
|
|
2237
|
-
type;
|
|
2238
|
-
chainId;
|
|
2239
|
-
constructor({
|
|
2240
|
-
value,
|
|
2241
|
-
decimal,
|
|
2242
|
-
tax,
|
|
2243
|
-
chain,
|
|
2244
|
-
symbol,
|
|
2245
|
-
identifier
|
|
2246
|
-
}) {
|
|
2247
|
-
super(typeof value === "object" ? value : { decimal, value });
|
|
2248
|
-
const assetInfo = getAssetInfo(identifier || `${chain}.${symbol}`);
|
|
2249
|
-
this.type = getAssetType(assetInfo);
|
|
2250
|
-
this.tax = tax;
|
|
2251
|
-
this.chain = assetInfo.chain;
|
|
2252
|
-
this.ticker = assetInfo.ticker;
|
|
2253
|
-
this.symbol = assetInfo.symbol;
|
|
2254
|
-
this.address = assetInfo.address;
|
|
2255
|
-
this.isSynthetic = assetInfo.isSynthetic;
|
|
2256
|
-
this.isGasAsset = assetInfo.isGasAsset;
|
|
2257
|
-
this.chainId = ChainToChainId[assetInfo.chain];
|
|
2258
|
-
}
|
|
2259
|
-
toString() {
|
|
2260
|
-
return this.isSynthetic ? this.symbol : `${this.chain}.${this.symbol}`;
|
|
2261
|
-
}
|
|
2262
|
-
toUrl() {
|
|
2263
|
-
return this.isSynthetic ? `${this.chain}.${this.symbol.replace("/", ".")}` : this.toString();
|
|
2264
|
-
}
|
|
2265
|
-
eq({ chain, symbol }) {
|
|
2266
|
-
return this.chain === chain && this.symbol === symbol;
|
|
2267
|
-
}
|
|
2268
|
-
static fromUrl(urlAsset, value = 0) {
|
|
2269
|
-
const [chain, ticker, symbol] = urlAsset.split(".");
|
|
2270
|
-
if (!(chain && ticker))
|
|
2271
|
-
throw new Error("Invalid asset url");
|
|
2272
|
-
const assetString = chain === Chain.THORChain && symbol ? `${chain}.${ticker}/${symbol}` : urlAsset;
|
|
2273
|
-
return createAssetValue(assetString, value);
|
|
2274
|
-
}
|
|
2275
|
-
static fromString(assetString, value = 0) {
|
|
2276
|
-
return createAssetValue(assetString, value);
|
|
2277
|
-
}
|
|
2278
|
-
static fromIdentifier(assetString, value = 0) {
|
|
2279
|
-
return createAssetValue(assetString, value);
|
|
2280
|
-
}
|
|
2281
|
-
static fromStringSync(assetString, value = 0) {
|
|
2282
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2283
|
-
const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
|
|
2284
|
-
if (isSynthetic)
|
|
2285
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2286
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2287
|
-
decimal: BaseDecimal[chain],
|
|
2288
|
-
identifier: assetString
|
|
2289
|
-
};
|
|
2290
|
-
return new AssetValue({
|
|
2291
|
-
tax,
|
|
2292
|
-
value: safeValue(value, decimal),
|
|
2293
|
-
identifier: isSynthetic ? assetString : identifier,
|
|
2294
|
-
decimal: isSynthetic ? 8 : decimal
|
|
2295
|
-
});
|
|
2296
|
-
}
|
|
2297
|
-
static async fromStringWithBase(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
|
|
2298
|
-
const shiftedAmount = BigIntArithmetics.shiftDecimals({
|
|
2299
|
-
value: SwapKitNumber.fromBigInt(BigInt(value)),
|
|
2300
|
-
from: 0,
|
|
2301
|
-
to: baseDecimal
|
|
2302
|
-
}).getBaseValue("string");
|
|
2303
|
-
const assetValue = await AssetValue.fromString(assetString, value);
|
|
2304
|
-
return assetValue.set(shiftedAmount);
|
|
2305
|
-
}
|
|
2306
|
-
static fromStringWithBaseSync(assetString, value = 0, baseDecimal = BaseDecimal.THOR) {
|
|
2307
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2308
|
-
const tokenInfo = staticTokensMap.get(assetString.toUpperCase());
|
|
2309
|
-
if (isSynthetic)
|
|
2310
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2311
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2312
|
-
decimal: BaseDecimal[chain],
|
|
2313
|
-
identifier: assetString
|
|
2314
|
-
};
|
|
2315
|
-
return new AssetValue({
|
|
2316
|
-
tax,
|
|
2317
|
-
value: safeValue(BigInt(value), baseDecimal),
|
|
2318
|
-
identifier,
|
|
2319
|
-
decimal
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
static fromIdentifierSync(assetString, value = 0) {
|
|
2323
|
-
const { chain, isSynthetic } = getAssetInfo(assetString);
|
|
2324
|
-
const tokenInfo = staticTokensMap.get(assetString);
|
|
2325
|
-
if (isSynthetic)
|
|
2326
|
-
return createSyntheticAssetValue(assetString, value);
|
|
2327
|
-
const { tax, decimal, identifier } = tokenInfo || {
|
|
2328
|
-
decimal: BaseDecimal[chain],
|
|
2329
|
-
identifier: assetString
|
|
2330
|
-
};
|
|
2331
|
-
return new AssetValue({ tax, decimal, identifier, value: safeValue(value, decimal) });
|
|
2332
|
-
}
|
|
2333
|
-
static fromChainOrSignature(assetString, value = 0) {
|
|
2334
|
-
const { decimal, identifier } = getCommonAssetInfo(assetString);
|
|
2335
|
-
return new AssetValue({ value: safeValue(value, decimal), decimal, identifier });
|
|
2336
|
-
}
|
|
2337
|
-
static loadStaticAssets() {
|
|
2338
|
-
return new Promise((resolve, reject) => {
|
|
2339
|
-
try {
|
|
2340
|
-
import("@swapkit/tokens").then((tokenPackages) => {
|
|
2341
|
-
for (const tokenList of Object.values(tokenPackages)) {
|
|
2342
|
-
for (const { identifier, chain, ...rest } of tokenList.tokens) {
|
|
2343
|
-
staticTokensMap.set(identifier.toUpperCase(), {
|
|
2344
|
-
identifier,
|
|
2345
|
-
decimal: "decimals" in rest ? rest.decimals : BaseDecimal[chain]
|
|
2346
|
-
});
|
|
2347
|
-
}
|
|
2348
|
-
}
|
|
2349
|
-
resolve({ ok: true });
|
|
2350
|
-
});
|
|
2351
|
-
} catch (error) {
|
|
2352
|
-
console.error(error);
|
|
2353
|
-
reject({
|
|
2354
|
-
ok: false,
|
|
2355
|
-
error,
|
|
2356
|
-
message: "Couldn't load static assets. Ensure you have installed @swapkit/tokens package"
|
|
2357
|
-
});
|
|
2358
|
-
}
|
|
2359
|
-
});
|
|
2360
|
-
}
|
|
2361
|
-
}
|
|
2362
|
-
export {
|
|
2363
|
-
wrapWithThrow,
|
|
2364
|
-
wrapMethodWithNetworkSwitch,
|
|
2365
|
-
validateTNS,
|
|
2366
|
-
validateIdentifier,
|
|
2367
|
-
switchEVMWalletNetwork,
|
|
2368
|
-
setRequestClientConfig,
|
|
2369
|
-
prepareNetworkSwitch,
|
|
2370
|
-
okxMobileEnabled,
|
|
2371
|
-
isWeb3Detected,
|
|
2372
|
-
isGasAsset,
|
|
2373
|
-
isDetected,
|
|
2374
|
-
getWalletFormatFor,
|
|
2375
|
-
getTHORNameCost,
|
|
2376
|
-
getSymmetricWithdraw,
|
|
2377
|
-
getSymmetricPoolShare,
|
|
2378
|
-
getMinAmountByChain,
|
|
2379
|
-
getMemoFor,
|
|
2380
|
-
getMAYANameCost,
|
|
2381
|
-
getLiquiditySlippage,
|
|
2382
|
-
getEstimatedPoolShare,
|
|
2383
|
-
getETHDefaultWallet,
|
|
2384
|
-
getDerivationPathFor,
|
|
2385
|
-
getDecimal,
|
|
2386
|
-
getCommonAssetInfo,
|
|
2387
|
-
getAsymmetricRuneWithdrawAmount,
|
|
2388
|
-
getAsymmetricRuneShare,
|
|
2389
|
-
getAsymmetricAssetWithdrawAmount,
|
|
2390
|
-
getAsymmetricAssetShare,
|
|
2391
|
-
getAssetType,
|
|
2392
|
-
formatBigIntToSafeValue,
|
|
2393
|
-
findAssetBy,
|
|
2394
|
-
filterAssets,
|
|
2395
|
-
erc20ABI,
|
|
2396
|
-
derivationPathToString,
|
|
2397
|
-
defaultRequestHeaders,
|
|
2398
|
-
assetFromString,
|
|
2399
|
-
addEVMWalletNetwork,
|
|
2400
|
-
addAccountsChangedCallback,
|
|
2401
|
-
WalletOption,
|
|
2402
|
-
UTXOChains,
|
|
2403
|
-
TCSupportedChains,
|
|
2404
|
-
TCEthereumVaultAbi,
|
|
2405
|
-
TCBscDepositABI,
|
|
2406
|
-
TCAvalancheDepositABI,
|
|
2407
|
-
SwapKitNumber,
|
|
2408
|
-
SwapKitError,
|
|
2409
|
-
SubstrateChains,
|
|
2410
|
-
SWAP_OUT,
|
|
2411
|
-
SWAP_IN,
|
|
2412
|
-
RequestClient,
|
|
2413
|
-
RPCUrl,
|
|
2414
|
-
QuoteMode,
|
|
2415
|
-
NetworkDerivationPath,
|
|
2416
|
-
MemoType,
|
|
2417
|
-
MayaEthereumVaultAbi,
|
|
2418
|
-
MayaArbitrumVaultAbi,
|
|
2419
|
-
MAYASupportedChains,
|
|
2420
|
-
LedgerErrorCode,
|
|
2421
|
-
FeeOption,
|
|
2422
|
-
ExplorerUrl,
|
|
2423
|
-
EVMChains,
|
|
2424
|
-
DerivationPath,
|
|
2425
|
-
CosmosChains,
|
|
2426
|
-
ContractAddress,
|
|
2427
|
-
ChainToRPC,
|
|
2428
|
-
ChainToHexChainId,
|
|
2429
|
-
ChainToExplorerUrl,
|
|
2430
|
-
ChainToChainId,
|
|
2431
|
-
ChainIdToChain,
|
|
2432
|
-
ChainId,
|
|
2433
|
-
Chain,
|
|
2434
|
-
BigIntArithmetics,
|
|
2435
|
-
BaseDecimal,
|
|
2436
|
-
AssetValue,
|
|
2437
|
-
ApproveMode,
|
|
2438
|
-
AGG_SWAP
|
|
2439
|
-
};
|
|
2440
|
-
|
|
2441
|
-
//# debugId=98BADB263971B32E64756e2164756e21
|
|
3
|
+
//# debugId=10B3754A9D3A879764756E2164756E21
|