Why does "Network Fee" differ depending on swap direction?
Fees at Boltz are separated into two parts:
1. Boltz Fee: a percentage of the swap amount charged for using Boltz's services and liquidity
2. Network Fee: a fee charged to cover network fees for locking or claiming funds
Why does "Network Fee" differ depending on the swap direction?
Let's take Liquid <> Lightning swaps as an example:
For one Boltz charges a network fee of 19 sats, for the other 47 sats. Why?
Tl;dr: For Liquid -> Lightning, one part of the network fee is already paid for by the user's Liquid wallet, in the
other direction it's not. Hence the charged network fee differes.
A more detailed explanation:
Boltz's atomic swap protocol requires both sides, the user and Boltz, first to lock and then claim their part of the
swap. In above Liquid -> Lightning example, the user first locks 1020 sats in the Liquid swap address. And here it
comes: network fees for the transaction sending to the swap address is already paid for - by the user's Liquid wallet!
Hence Boltz should only charge for its own transaction claiming from the swap address. And that is estimated to cost 19
sats. Boltz doesn't charge any network fees on Lightning, so locking funds on Lightning is considered "free".
Vice versa, in above Lightning -> Liquid example, the user first locks 1050 sats on Lightning and Boltz locks 1000 sats
in the Liquid swap address. That is estimated to cost 28 sats. Then the user's web app needs to claim from that swap
address, which is estimated to cost 19 sats. Total 47 sats.
Another example using Liquid <> Bitcoin swaps:
For above Liquid -> Bitcoin swap, "Network Fee" includes 19 sats for Boltz to claim on Liquid and 530 sats to lock on
the Bitcoin mainchain. 549 sats total. The user's wallet paid for sending to the Liquid swap address. For above Bitcoin
-> Liquid swap, 349 sats is comprised of 302 sats for Boltz claiming on the Bitcoin mainchain, 28 sats for Boltz sending
to the Liquid swap address and 19 sats for the user's web app to claim from that swap address. 349 sats total. The
user's wallet paid for sending to the Bitcoin swap address.
As we can see, lock transaction costs differ slightly from claim transaction costs. Also, fees are dynamic based on a
specific layer's fee situation, e.g. mempool.space's current "High Priority" fee" is taken as source for fee
calculations of the Bitcoin mainchain.
For further details on fee calculations, refer to the relevant code here.