[feature] dynamic gas fees

Closed Son of Odin requested to merge efficient-gas into develop

We charge 3x the gas fee for outbound transactions. This makes swapping on THORChain more expensive, especially on chains like ETH. We do this because we don't want to have the network subsidize swaps costs, and since we don't know what the gas cost will be for some chains, we have to be liberal in fees. So we charge 3x, but will likely only use 1x or 1.5x (3x in extreme conditions)

The solution here has everyone subsidizing everyone, rather than the network. The network will track how much value it's withheld in outbound transactions (in rune), and track how much the reserve has paid in rune to gas pools. Between these two numbers, the network can know if it's operating at a surplus or deficit in gas fees.

So rather than blinding charging every 3x in gas fees for outbound transactions, it will charge 1x, 2x, or 3x depending on if the network is in a surplus or deficit.

If the surplus is 3x the fee or less, the network will charge 3x the gas fees. If the surplus is 12x the fee or less, the network will charge 2x the gas fees. If the surplus is higher, the network will charge 1x the gas fees.

I suspect for cheap gas chains the network will pretty consistently choose 1x. For expensive chains like ETH, it will most likely select 2x or 1x the vast majority of the time.

Edited by Son of Odin