From 070077acb0c90631b74c5573dd202518b4f307b1 Mon Sep 17 00:00:00 2001 From: bun919tw Date: Wed, 20 Jan 2021 19:11:32 +0800 Subject: [PATCH] contracts/: fix cToken storage collision problem --- contracts/CErc20.sol | 2 +- contracts/CTokenInterfaces.sol | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/contracts/CErc20.sol b/contracts/CErc20.sol index 6aa9b8e3c..767b35066 100644 --- a/contracts/CErc20.sol +++ b/contracts/CErc20.sol @@ -7,7 +7,7 @@ import "./CToken.sol"; * @notice CTokens which wrap an EIP-20 underlying * @author Compound */ -contract CErc20 is CToken, CErc20Interface { +contract CErc20 is CToken, CErc20Interface, CErc20StorageExtension { /** * @notice Initialize the new money market * @param underlying_ The address of the underlying asset diff --git a/contracts/CTokenInterfaces.sol b/contracts/CTokenInterfaces.sol index 7f4184962..eee45b1e2 100644 --- a/contracts/CTokenInterfaces.sol +++ b/contracts/CTokenInterfaces.sol @@ -245,11 +245,6 @@ contract CErc20Storage { * @notice Underlying asset for this CToken */ address public underlying; - - /** - * @notice Internal cash counter for this CToken. Should equal underlying.balanceOf(address(this)) for CERC20. - */ - uint256 public internalCash; } contract CErc20Interface is CErc20Storage { @@ -270,14 +265,19 @@ contract CErc20Interface is CErc20Storage { function _addReserves(uint addAmount) external returns (uint); } -contract CDelegationStorage { +contract CErc20StorageExtension { /** * @notice Implementation address for this contract */ address public implementation; + + /** + * @notice Internal cash counter for this CToken. Should equal underlying.balanceOf(address(this)) for CERC20. + */ + uint256 public internalCash; } -contract CDelegatorInterface is CDelegationStorage { +contract CDelegatorInterface is CErc20StorageExtension { /** * @notice Emitted when implementation is changed */ @@ -292,7 +292,7 @@ contract CDelegatorInterface is CDelegationStorage { function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public; } -contract CDelegateInterface is CDelegationStorage { +contract CDelegateInterface is CErc20StorageExtension { /** * @notice Called by the delegator on a delegate to initialize it for duty * @dev Should revert if any issues arise which make it unfit for delegation