omni / tokenbridge-contracts

Smart contracts for TokenBridge
http://docs.tokenbridge.net
GNU General Public License v3.0
229 stars 227 forks source link

Bridge imbalance if fixAssetsAboveLimits is used and Fee Manager enabled #210

Closed akolotov closed 5 years ago

akolotov commented 5 years ago

When the bridge owner calls fixAssetsAboveLimits to unlock funds (i.e. unlockOnForeign is true) and the Fee Manager is configured for erc20-to-erc20 and erc20-to-native modes as so the fee for the home-to-foreign direction is taken on the Home side, it will lead to the bridge imbalance: amount of coins/token on the Home side will be more than amount of tokens locked on the Foreign side. It will happen at the moment when the fee is collected after the final signature arrival: the amount that will be relayed, the fee calculated based on the amount that will be relayed is minted whereas full requested amount of tokens will be unlocked when confirmations are passed on the foreign side.

The proposed solution: Keeping in the mind that the validators needs to be rewarded for relaying the request to unlock tokens that was incorrectly transferred through the bridge due to the user misbehavior, it makes sense to introduce the logic in the OverdrawManagement contract to support the Fee Manager as so the amount of tokens which is requested to be unlocked is reduced by the fee amount.

It will lead to minting fees on the Home side and unlocking the tokens deducted by the fee on the foreign side.

akolotov commented 5 years ago

Included in TokenBridge contracts 2.3.3