Utils
validateAddress
Validate the given address.
Parameters
addressAddress
Returns boolean true or false
getTokenAddress
Get token address from asset.
Parameters
assetAsset
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
$0Object$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
$0Object$0.provider$0.contractAddress$0.abi$0.funcName$0.funcParams(optional, default[])
providerProvider Provider to interact with the contract.contractAddressAddress The contract address.abiContractInterface The contract ABI json.funcNamestring The function to be called.funcParamsArray<unknown> The parameters of the function.
Returns BigNumber The result of the contract function call.
call
Calls a contract function.
Parameters
$0Object$0.provider$0.signer$0.contractAddress$0.abi$0.funcName$0.funcParams(optional, default[])
providerProvider Provider to interact with the contract.Signersigner of the transaction (optional - needed for sending transactions only)contractAddressAddress The contract address.abiContractInterface The contract ABI json.funcNamestring The function to be called.funcParamsArray<unknow> (optional) The parameters of the function.
Returns T The result of the contract function call.
getContract
Load a contract.
Parameters
$0Object$0.provider$0.contractAddress$0.abi
providerProvider Provider to interact with the contract.contractAddressAddress The contract address.abiContractInterface The contract ABI json.
estimateApprove
Estimate gas for calling approve.
Parameters
$0Object$0.provider$0.contractAddress$0.spenderAddress$0.fromAddress$0.abi$0.amount
providerProvider Provider to interact with the contract.contractAddressAddress The contract address.spenderAddressAddress The spender address.fromAddressAddress The address a transaction is sent from.amountBaseAmount (optional) The amount of token. By default, it will be unlimited token allowance.
Returns BigNumber Estimated gas
isApproved
Check allowance.
Parameters
$0Object$0.provider$0.contractAddress$0.spenderAddress$0.fromAddress$0.amount
providerProvider Provider to interact with the contract.contractAddressAddress The contract (ERC20 token) address.spenderAddressAddress The spender address (router).fromAddressAddress The address a transaction is sent from.amountBaseAmount The amount to check if it's allowed to spend or not (optional).walletIndexnumber (optional) HD wallet index
Returns boolean true or false.
strip0x
Removes 0x or 0X from address
Parameters
addr