You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jul 15, 2024. It is now read-only.
deposit function allows a user to call it with a certain amount of assets, end up transferring more than that amount, and get 1 less share in return.
An example can be seen here (report)
Summary:
Suppose the user calls the deposit function with an asset amount equivalent to anywhere in the range [x.5, x+1) AToken. In that case, the deposit function will round up the amount of Atokens that needs to be transferred from the sender but will round down the number of staticAToken shares the receiver gets in return, i.e. the user send x+1 Atokens, but receive only x staticAtokens.
Detailed Scenario:
User calls deposit function with an asset amount of 9 underlying tokens. The fromUnderlying flag is false so the AToken.transferFrom function is called.
AToken.transferFrom function eventually calls AToken._transfer function. This function converts the user specified underlying asset amount to the number of ATokens by calling the rayDiv function with the current rate and asset amount.
Due to round-up, rayDiv returns 1 AToken, which is equivalent to 18 underlying tokens.
1 AToken is transferred from the user to the staticAToken contract.
Deposit function proceeds to calculate the shares to be minted to the user. rayDivRoundDown is called with the rate and the asset amount (9). Due to round-down, rayDivRoundDown returns 0.
User gets 0 shares in return for the 1 AToken deposited in the vault.
The text was updated successfully, but these errors were encountered:
deposit
function allows a user to call it with a certain amount of assets, end up transferring more than that amount, and get 1 less share in return.An example can be seen here (report)
Summary:
Suppose the user calls the deposit function with an asset amount equivalent to anywhere in the range [x.5, x+1) AToken. In that case, the deposit function will round up the amount of Atokens that needs to be transferred from the sender but will round down the number of staticAToken shares the receiver gets in return, i.e. the user send x+1 Atokens, but receive only x staticAtokens.
Detailed Scenario:
User calls
deposit
function with an asset amount of 9 underlying tokens. ThefromUnderlying
flag is false so theAToken.transferFrom
function is called.AToken.transferFrom
function eventually callsAToken._transfer
function. This function converts the user specified underlying asset amount to the number of ATokens by calling therayDiv
function with the currentrate
and asset amount.Due to round-up,
rayDiv
returns 1 AToken, which is equivalent to 18 underlying tokens.1 AToken is transferred from the user to the staticAToken contract.
Deposit
function proceeds to calculate the shares to be minted to the user.rayDivRoundDown
is called with the rate and the asset amount (9). Due to round-down,rayDivRoundDown
returns 0.User gets 0
shares
in return for the 1 AToken deposited in the vault.The text was updated successfully, but these errors were encountered: