-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: one ProdConfig file to factorize dealAave
- Loading branch information
Showing
3 changed files
with
31 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity ^0.8.0; | ||
|
||
import {SafeTransferLib, ERC20} from "@rari-capital/solmate/src/utils/SafeTransferLib.sol"; | ||
|
||
import {PercentageMath} from "@morpho-dao/morpho-utils/math/PercentageMath.sol"; | ||
import {Math} from "@morpho-dao/morpho-utils/math/Math.sol"; | ||
import {WadRayMath} from "@morpho-dao/morpho-utils/math/WadRayMath.sol"; | ||
|
||
import {BaseConfig} from "config/BaseConfig.sol"; | ||
import "@forge-std/console.sol"; | ||
import "@forge-std/Test.sol"; | ||
|
||
contract ProdTest is Test, BaseConfig { | ||
// Needed because AAVE packs the balance struct. | ||
function dealAave(address who, uint104 amount) public { | ||
// The slot of the balance struct "_balances" is 0. | ||
bytes32 slot = keccak256(abi.encode(who, uint256(0))); | ||
bytes32 initialValue = vm.load(aave, slot); | ||
// The balance is stored in the first 104 bits. | ||
bytes32 finalValue = ((initialValue >> 104) << 104) | bytes32(uint256(amount)); | ||
vm.store(aave, slot, finalValue); | ||
require(ERC20(aave).balanceOf(who) == uint256(amount)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters