Utils
validateAddress
Validate the given address.
Parameters
address
Address
Returns boolean true
or false
getTokenAddress
Get token address from asset.
Parameters
asset
Asset
Returns (Address | null) The token address.
validateSymbol
Check if the symbol is valid.
Parameters
Returns boolean true
or false
.
getFee
Calculate fees by multiplying .
Parameters
$0
Object$0.gasPrice
$0.gasLimit
$0.decimals
Returns Fees The default gas price.
getPrefix
Get address prefix based on the network.
Returns string The address prefix based on the network.*
filterSelfTxs
Filter self txs
Parameters
txs
Returns Array<T> *
getApprovalAmount
Returns approval amount
If given amount is not set or zero, MAX_APPROVAL
amount is used
Parameters
amount
estimateCall
Call a contract function.
Parameters
$0
Object$0.provider
$0.contractAddress
$0.abi
$0.funcName
$0.funcParams
(optional, default[]
)
provider
Provider Provider to interact with the contract.contractAddress
Address The contract address.abi
ContractInterface The contract ABI json.funcName
string The function to be called.funcParams
Array<unknown> The parameters of the function.
Returns BigNumber The result of the contract function call.
call
Calls a contract function.
Parameters
$0
Object$0.provider
$0.signer
$0.contractAddress
$0.abi
$0.funcName
$0.funcParams
(optional, default[]
)
provider
Provider Provider to interact with the contract.Signer
signer of the transaction (optional - needed for sending transactions only)contractAddress
Address The contract address.abi
ContractInterface The contract ABI json.funcName
string The function to be called.funcParams
Array<unknow> (optional) The parameters of the function.
Returns T The result of the contract function call.
getContract
Load a contract.
Parameters
$0
Object$0.provider
$0.contractAddress
$0.abi
provider
Provider Provider to interact with the contract.contractAddress
Address The contract address.abi
ContractInterface The contract ABI json.
estimateApprove
Estimate gas for calling approve
.
Parameters
$0
Object$0.provider
$0.contractAddress
$0.spenderAddress
$0.fromAddress
$0.abi
$0.amount
provider
Provider Provider to interact with the contract.contractAddress
Address The contract address.spenderAddress
Address The spender address.fromAddress
Address The address a transaction is sent from.amount
BaseAmount (optional) The amount of token. By default, it will be unlimited token allowance.
Returns BigNumber Estimated gas
isApproved
Check allowance.
Parameters
$0
Object$0.provider
$0.contractAddress
$0.spenderAddress
$0.fromAddress
$0.amount
provider
Provider Provider to interact with the contract.contractAddress
Address The contract (ERC20 token) address.spenderAddress
Address The spender address (router).fromAddress
Address The address a transaction is sent from.amount
BaseAmount The amount to check if it's allowed to spend or not (optional).walletIndex
number (optional) HD wallet index
Returns boolean true
or false
.
strip0x
Removes 0x
or 0X
from address
Parameters
addr