mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
Explain code to overwrite fromAmount in comment
Fixes MixBytes Comment 1.
This commit is contained in:
parent
b13a01d8b8
commit
11d0367d3c
|
@ -66,9 +66,14 @@ abstract contract BaseParaSwapSellAdapter is BaseParaSwapAdapter {
|
||||||
IERC20(assetToSwapFrom).safeApprove(tokenTransferProxy, amountToSwap);
|
IERC20(assetToSwapFrom).safeApprove(tokenTransferProxy, amountToSwap);
|
||||||
|
|
||||||
if (fromAmountOffset != 0) {
|
if (fromAmountOffset != 0) {
|
||||||
|
// Ensure 256 bit (32 bytes) fromAmount value is within bounds of the
|
||||||
|
// calldata, not overlapping with the first 4 bytes (function selector).
|
||||||
require(fromAmountOffset >= 4 &&
|
require(fromAmountOffset >= 4 &&
|
||||||
fromAmountOffset <= swapCalldata.length.sub(32),
|
fromAmountOffset <= swapCalldata.length.sub(32),
|
||||||
'FROM_AMOUNT_OFFSET_OUT_OF_RANGE');
|
'FROM_AMOUNT_OFFSET_OUT_OF_RANGE');
|
||||||
|
// Overwrite the fromAmount with the correct amount for the swap.
|
||||||
|
// In memory, swapCalldata consists of a 256 bit length field, followed by
|
||||||
|
// the actual bytes data, that is why 32 is added to the byte offset.
|
||||||
assembly {
|
assembly {
|
||||||
mstore(add(swapCalldata, add(fromAmountOffset, 32)), amountToSwap)
|
mstore(add(swapCalldata, add(fromAmountOffset, 32)), amountToSwap)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user