hifi-finance / hifi

Monorepo implementing the Hifi fixed-rate, fixed-term lending protocol
https://app.hifi.finance
Other
106 stars 15 forks source link

[flash-swap] Bond dust left behind upon liquidation #55

Closed scorpion9979 closed 3 years ago

scorpion9979 commented 3 years ago

The accounts in the balance sheet are collecting bond and collateral dust, even after bond maturation and flash-swap liquidation. This is due to the way flash liquidation works. The liquidator bot flash borrows USDC in order to mint the htokens used to liquidate positions. When the 18-decimal repay amount is scaled down to 6 decimals, there will be some bond dust in most cases as 12 decimal places would be cut off. In order to liquidate the entire bond, we will need to:

  1. Offset the USDC amount to be borrowed by 1e-6 from the client side.
  2. Enable minting slightly more htokens than needed as a result of scaling up the borrowed USDC amount. The end result is that bonds would be fully liquidated, but the flash-swap contract would accumulate htoken dust. This is a compromise we're willing to make.
PaulRBerg commented 3 years ago

Hey Ahmed, thanks for opening this. Not a biggy but could you add labels to the issues you open in the future? That'll make it easier to sort and triage them.

scorpion9979 commented 3 years ago

Hey Ahmed, thanks for opening this. Not a biggy but could you add labels to the issues you'll open in the future? That'll make it easier to sort and triage the issues.

Thanks, Paul. I'll keep that in mind.

PaulRBerg commented 3 years ago

This issue may have been solved via https://github.com/hifi-finance/hifi/pull/59. Thus I will rename this issue to "bond dust" and tentatively close it for the time being.