hifi-finance / hifi

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

fix: remove extra transfer of underlyingAmount which result in dust #88

Closed surbhiaudichya closed 2 years ago

surbhiaudichya commented 2 years ago

Hey @paulrberg, in recent testing @defi-david discovered that all calls to depositUnderlyingAndBorrowHTokenAndAddLiquidityWithSignature failed, but calls to depositUnderlyingAndBorrowHTokenAndAddLiquidity worked.

After debugging, I found out that the depositUnderlyingAndBorrowHTokenAndAddLiquidity function is trying to transfer underlying twice, once totalUnderlyingAmount and later call to depositUnderlyingInternal transfer extra depositAmount which results in dust in DSProxy. Since in non-signature functions we approve transfer of large amount of tokens in advance this issue didn’t come to surface, but in the withSignature functions we permit transfer of totalUnderlyingAmount only, the later call to transfer depositAmount in depositUnderlyingInternal resulted in failure of transaction.

PaulRBerg commented 2 years ago

Great catch!