blocknetdx / blocknet

Official Blocknet cryptocurrency wallet
https://www.blocknet.org
MIT License
214 stars 95 forks source link

[feature] rework xbridge transaction fees #595

Open rikublock opened 2 years ago

rikublock commented 2 years ago

Currently, when an order is triggered both parties send their amount to a timelocked address, including two types of transaction fees

Example: If one were to send 1 LTC (trade_amount), the wallet would actually send

total = trade_amount + fee1 + fee2.

The redeeming side would then be able to claim

total = trade_amount + fee2,

while using fee2 to cover the tx costs, ending up with trade_amount in their wallet.

All of these calculations happen without any user interaction. This works fairly well as long as fee calculations are static and both parties use very similar fee settings.

When moving towards a more dynamic (estimated) fees system, certain problems arise. This ticket makes attempt to highlight some of the shortcomings of the current implementation as well as present possible solutions.

Problem: Transaction fees are currently somewhat of a black box system. Fees are automatically calculated and added to the trading amounts without any user interaction. Consequently, the user never sees nor confirms the actual fee amounts. This works well with static tx fees as costs are fairly predictable, however it poses a problem with dynamic fees, where this is no longer the case. Dynamic fee estimations might add quite high, even ridiculous fees, aren't very reliable and shouldn't blindly be trusted.

Problem: Currently, fee1 and fee2 are calculated once during the order creation process and then never changed. Now, orders aren't necessary taken right away. In fact, a significant amount of time might pass between placing and taking an order. During that time estimated fees might drastically change leading to stuck/failed orders or to overpaid fees. In order to address this problem the client has to become more flexible when dealing with tx fees.

Additionally:

The above list is not complete, but has the intention to start a discussion on the topic.

Related: