THORChain and Fees
Understanding how fees are calculated.

Understanding gas_rate

THORNode keeps track of current gas prices. Access these at the /inbound_addresses endpoint of the THORNode API. The response is an array of objects like this:
"chain": "ETH",
"pub_key": "thorpub1addwnpepqdlx0avvuax3x9skwcpvmvsvhdtnw6hr5a0398vkcvn9nk2ytpdx5cpp70n",
"address": "0x74ce1c3556a6d864de82575b36c3d1fb9c303a80",
"router": "0x3624525075b88B24ecc29CE226b0CEc1fFcB6976",
"halted": false,
"gas_rate": "210"
The gas_rate property can be used to estimate network fees for each chain the swap interacts with. For example, if the swap is BTC -> ETH the swap will incur fees on the bitcoin network and Ethereum network.
The gas_rate property works differently on each chain "type" (e.g. EVM, UTXO, BFT).

Fee Calcuation by Chain

THORChain (Native Rune)

The THORChain blockchain has a set 0.02 RUNE fee. This is set within the THORChain Constants by NativeTransactionFee. As THORChain is 1e8, 2000000 TOR = 0.02 RUNE

Binance Chain

THORChain uses the gas_rate as the flat Binance Chain transaction fee.
E.g. If the gas_rate = 11250 then fee is 0.0011250 BNB.

UTXO Chains like Bitcoin

For UXTO chains link Bitcoin, gas_rateis denoted in Satoshis. The gas_rate is calculated by looking at the average previous block fee seen by the THORNodes.
All THORChain transactions use BECH32 so a standard block size of 250 bytes can be used. The standard UTXO fee is then gas_rate* 250.

EVM Chains like Ethereum

For EVM chains like Ethereum, gas_rateis denoted in GWai. The gas_rate is calculated by looking at the average previous block fee seen by the THORNodes
An Ether Tx fee is: gasRate * 10^9 (GWEI) * 35000 (units).
An ERC20 Tx is larger: gasRate * 10^9 (GWEI) * 70000 (units)

Inbound Fees

Interfaces set the inbound fee. Fastest should be used where possible for a better UX.
Always use a "fast" or "fastest" fee, if the transaction is not confirmed in time, it could be abandoned by the network. You should allow your users to cancel or re-try with higher fees.

Outbound Fees

3 * the inbound fee is set for Outbouds. This should be added up and displayed to the user as the total fee. For any transaction:
Total Fee = Inbound Fee + Outbound Fee
See Outbound Fee for more information.

Affiliate Fees

In the swap transaction you build for your users you can include an affiliate fee for your exchange (accepted in $RUNE or a synthetic asset, so you will need a $RUNE address).
  • The affiliate fee is in basis points (0-10,000) and will be deducted from the inbound swap amount from the user.
  • If the inbound swap asset is a native THORChain asset ($RUNE or synth) the affiliate fee amount will be deducted directly from the transaction amount.
  • If the inbound swap asset is on any other chain the network will submit a swap to $RUNE with the destination address as your affiliate fee address.