How fees on Terra work

Fees structure

All transactions on Terra must include a fee to compensate the validator who spend computing resources to include it in a block. Terra commissions consist of 2 parts:

  • gas_fees (compute resource)
  • tax (aka. “stability fee”), on all stablecoins transfers
fees = gas_fees + tax

How gas fees are calculated

This formula is used to calculate the gas_fees :

gas_fees = gas_limit * gas_price
  • gas is a unit for measuring roughly the amount of compute resources required to put the transaction in a block. It is computed deterministically, two identical transactions will always require the same amount of gas.

TIP: If you have to execute a transaction of the same type multiple times you can use a constant as a gas limit, to calculate the correct value execute one of these transactions with an high limit, then look at how much gas is actually used and add a 10%.

  • gas_price is the price per unit gas. Nodes (both regular and validators) can set a min gas price. Transactions with a gas price below this threshold will not get processed or propagated by that node. You can get the updated gas prices from the FCD: https://fcd.terra.dev/v1/txs/gas_prices

Note:

  • setting higher gas prices gives no priority (yet)
  • fees paid for unused gas will not be refunded

How tax fees are calculated

In addition to the gas fee, if you move stablecoins with the transaction, you have to pay a stability fee that is a percentage of the moved coins.

Note: After approval of proposal 172, tax rate has been set to zero and it is therefore no longer necessary to calculate tax fees.

You can calculate the tax fees in this way:

tax_fees = min( moved_amount * tax_rate , tax_cap )  
  • moved_amount is the amount of stablecoins moved in the transaction.
  • tax_rate is the current tax_rate, you can get it from the LCD: https://lcd.terra.dev/treasury/tax_rate
  • tax_cap is the maximum amount of tax to be paid for a transaction. it is fixed to the equivalent of 1SDT (TerraSDR) in the moved stablecoin. You can get the current tax_rate for any currency here: https://lcd.terra.dev/treasury/tax_caps Note: The tax is only for the movement of Stablecoins (UST, EUT, SDT, KRT, …) not for the movement of LUNA or any CW20 token (MIR, ANC, MINE, mAAPL, …)

Conclusion

This is therefore the complete formula for calculating fees:

fees = (gas * gas_price) + min(moved_amount * tax_rate, tax_cap)
5 Likes

@Alessandro Can you put this on terrawiki.org? It’s very valuable info.

Ok, should I put it on ecosystem, tutorials or somewhere else?

Good question. You can create a new folder if you want, or leave it top level without a folder. It’s important and we can move it later if needed, once the wiki grows.