Transaction Fees
Requesting and estimation
Last updated
Requesting and estimation
Last updated
Each transaction should include a fee. This is a payment to the relayer for maintaining a request, preparing, and sending a transaction to the pool contract. The fee is returned by the relayer and may vary for different reasons. Moreover different transactions require different fee amounts based on the calldata length. This is why the transaction fee must be calculated every time before sending a transaction in general.
The fee is always returned in the token denominated units (pool dimension). The relayer fee estimate follows the RelayerFee structure.
In general the transaction fee estimated on the client side follows this formula ( relayerFee
is the commission returned by relayer):
For withdrawal transactions with token swaps the equation is as follows:
It is not possible to define the absolute fee value when creating a transaction, but you may provide a relayer raw fee object. The final fee is calculated under the hood as described above. If the raw fee field is omitted, the raw fee will be automatically requested from the relayer.
Request the fee estimation from the relayer. If a previous request was performed recently (<30 secs) the cached value will be returned.
Promise
returns RelayerFee
: actual raw fee contents.
Calculate the typical fee amount for the desired transaction type. It may be helpful to display the approximate fee before entering the transaction config.
Keep in mind these are typical fee values. In several cases the transaction fee may be different depending on the account or transaction configuration (e.g. multi-transfer transactions). To estimate the actual transaction fee please use the feeEstimate full mode method.
txType
: transaction type (a member of TxType enum).
withdrawSwap
: An optional amount of tokens to swap in the withdrawal transaction. This may influence the typical withdraw transaction cost due to an additional fee component (ignored for other transaction types).
Promise
returns the absolute fee value for a typical transaction with the requested type (in tokens, pool dimension).
Direct deposit transaction should include extra cost for the relayer.
Promise
returns the direct deposit fee in the pool dimension.