From edb5661261dab1ed64d19e999d4ff7829b8561d0 Mon Sep 17 00:00:00 2001 From: David Laprade Date: Fri, 23 Dec 2022 13:57:15 -0500 Subject: [PATCH] Add handleRepayment/2 to AToken mock for fork test compatibility --- test/MockATokenCheckpointed.sol | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/test/MockATokenCheckpointed.sol b/test/MockATokenCheckpointed.sol index 158e310..b4d324d 100644 --- a/test/MockATokenCheckpointed.sol +++ b/test/MockATokenCheckpointed.sol @@ -9,6 +9,33 @@ contract MockATokenCheckpointed is ATokenCheckpointed { ATokenCheckpointed(_pool, _governor, _castVoteWindow) {} + function handleRepayment( + address user, + uint256 amount + ) external virtual onlyPool { + // We need this because the Aave code we compile is ahead of the Aave code deployed on + // Optimism (where our tests fork from). + // + // Currently on Optimism, AToken.handleRepayment is a 2-argument function, as seen in the + // existing AToken implementation: + // + // https://optimistic.etherscan.io/address/0xa5ba6e5ec19a1bf23c857991c857db62b2aa187b#code + // + // But in the latest Aave v3 code, it is a 3-argument function: + // + // https://github.com/aave/aave-v3-core/blob/c38c627683c0db0449b7c9ea2fbd68bde3f8dc01/contracts/protocol/tokenization/AToken.sol#L166-L170 + // + // The change was made as a result of this issue: + // + // https://github.com/aave/aave-v3-core/issues/742 + // + // We expect that the on-chain AToken implementation will be upgraded to + // AToken.handleRepayment/3 at some point in the future. If/when that happens, we should remove + // this. But for now we need our aToken to have this function in our fork tests to maintain + // backwards compatibility. + } + + function exposed_RawBalanceOf(address _user) public view returns (uint256) { return _userState[_user].balance; }