sherlock-audit / 2023-05-ironbank-judging

2 stars 2 forks source link

plainshift-2 - Users providing a low supply amount results in no tokens received #374

Closed sherlock-admin closed 1 year ago

sherlock-admin commented 1 year ago

plainshift-2

medium

Users providing a low supply amount results in no tokens received

Summary

The IronBank#supply function allows users to provide an underlying asset in exchange for ibTokens. Unfortunately, if the user supplies a low amount of underlying asset resulting in the user not receiving any ibTokens, the contract will still transfer the underlying asset over to the IronBank contract and the user will not receive any ibTokens.

Vulnerability Detail

The ibTokens given to the user is based on the following formula:

uint256 ibTokenAmount = (amount * 1e18) / _getExchangeRate(m);

If _getExchangeRate ever returns a value large enough to exceed the numerator, then the ibTokenAmount value will equal 0.

The relevant IronBank#supply() function can be found here.

Impact

Users who provide very little underlying asset will have their assets transferred over to IronBank without receiving any ibTokens.

Code Snippet

Found in IronBank#supply().

uint256 ibTokenAmount = (amount * 1e18) / _getExchangeRate(m);

Tool used

Line-by-line review

Manual Review

Recommendation

There should be a check that if the ibTokenAmount equals 0, the function should revert. This will allow for users to retain their tokens.