Swap for both On-Chain and Cross-Chain trade are pretty similar and very easy to use. You just have to call swap method in trade object (instantTrade or crossChain).
After swap execution you will get the transaction receipt or hash in case of cross-chain swap.
Well done!
Swap options
Swap method takes optional params with options:
interfaceSwapOptions { /** * Callback to be called, when user confirm swap transaction. * @param hash Transaction hash. */onConfirm?: (hash:string) =>void;/** * Callback to be called, when user confirm approve transaction. * @param hash Transaction hash. */onApprove?: (hash:string|null) =>void;/** * Tokens receiver address. */ receiverAddress?:string;/** * Transaction gas price options. */ gasPriceOptions?:EIP1559Gas|SingleGasPrice;/** * Approve transaction gas limit. * Will be used for approve transaction, if it is called before swap. */ approveGasLimit?:string;/** * Approve tron-transaction fee limit. * Will be used for approve transaction, if it is called before swap. */ approveFeeLimit?:number;}
With these parameters, you can specify your gas data or actions which will be executed right after transaction signing.