Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fuse fixed accounting #10

Open
wants to merge 30 commits into
base: fuse-reactive-audit
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
78c15b2
reentrancy fix
sriyantra Apr 30, 2022
a35a047
Fix Etherscan warning from checkpointInterest
davidlucid Apr 30, 2022
d524f98
Code comments
davidlucid Apr 30, 2022
8c79124
Revert "Fix Etherscan warning from checkpointInterest"
davidlucid Apr 30, 2022
e84e42e
Create CEtherDelegateTempExploitAccounting.sol
davidlucid Apr 30, 2022
1194e20
Update CEtherDelegateTempExploitAccounting.sol
davidlucid Apr 30, 2022
5428a94
CEtherDelegateTempExploitAccounting: support multiple secondary accounts
davidlucid Apr 30, 2022
bdaee36
Hardhat tests
davidlucid Apr 30, 2022
79ca176
Fix quantities in tests to consider min borrow
davidlucid Apr 30, 2022
e5c2c23
Test with real-life exploit code
davidlucid May 1, 2022
79f93e7
Add fix script for testing
davidlucid May 1, 2022
b8b3187
Update hardhat.config.js
davidlucid May 1, 2022
da2497a
Update CEtherDelegateTempExploitAccounting.sol
davidlucid May 1, 2022
dc52214
Create hardhat/test/fix-accounting.js
davidlucid May 1, 2022
7aa950a
More assertions!
davidlucid May 1, 2022
36b83a2
add accrueInterest()
sriyantra May 4, 2022
4567caf
Revert "add accrueInterest()"
sriyantra May 4, 2022
1878d56
add accrueInterest()
sriyantra May 4, 2022
a3c0d58
inherit CEther
sriyantra May 4, 2022
21e9d21
doTransferIn() CEI
sriyantra May 4, 2022
91386dc
Revert "doTransferIn() CEI"
sriyantra May 4, 2022
e5c344b
remove unused
sriyantra May 5, 2022
34c4dd3
Merge branch 'fuse-fixed-accounting' of https://github.com/Rari-Capit…
sriyantra May 5, 2022
db1a653
format
sriyantra May 5, 2022
f39cfad
Update CEtherDelegateTempExploitAccounting.sol
sriyantra May 5, 2022
be592b8
fix comment
sriyantra May 5, 2022
cc29449
add borrowIndex update
sriyantra May 5, 2022
02dbeef
simplify statement
sriyantra May 5, 2022
852dd96
Remove unnecessary code
davidlucid May 7, 2022
5fea929
Simplify CEtherDelegateTempExploitAccounting
davidlucid May 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "Fix Etherscan warning from checkpointInterest"
This reverts commit a35a047.
davidlucid committed Apr 30, 2022
commit 8c791241d446d79273fd9578929d6e8de7462908
7 changes: 3 additions & 4 deletions contracts/CToken.sol
Original file line number Diff line number Diff line change
@@ -470,7 +470,7 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter {
emit AccrueInterest(cashPrior, interestAccumulated, borrowIndexNew, totalBorrowsNew);

// Attempt to add interest checkpoint
if (interestRateModelReactive) address(interestRateModel).call(abi.encodeWithSignature("checkpointInterest(uint256)", borrowRateMantissa));
address(interestRateModel).call(abi.encodeWithSignature("checkpointInterest(uint256)", borrowRateMantissa));

return uint(Error.NO_ERROR);
}
@@ -1501,11 +1501,10 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter {
emit NewMarketInterestRateModel(oldInterestRateModel, newInterestRateModel);

// Attempt to reset interest checkpoints on old IRM
if (interestRateModelReactive) address(oldInterestRateModel).call(abi.encodeWithSignature("resetInterestCheckpoints()"));
if (address(oldInterestRateModel) != address(0)) address(oldInterestRateModel).call(abi.encodeWithSignature("resetInterestCheckpoints()"));

// Attempt to add first interest checkpoint on new IRM
(bool success, ) = address(newInterestRateModel).call(abi.encodeWithSignature("checkpointInterest()"));
interestRateModelReactive = success;
address(newInterestRateModel).call(abi.encodeWithSignature("checkpointInterest()"));

return uint(Error.NO_ERROR);
}
23 changes: 11 additions & 12 deletions contracts/CTokenInterfaces.sol
Original file line number Diff line number Diff line change
@@ -157,16 +157,6 @@ contract CTokenStorage is CTokenAdminStorage {
* @notice Share of seized collateral that is added to reserves
*/
uint public constant protocolSeizeShareMantissa = 2.8e16; //2.8%

/**
* @notice Underlying asset for this CToken
*/
address public underlying;

/**
* @notice Whether or not the interestRateModel is reactive.
*/
bool public interestRateModelReactive;
}

contract CTokenInterface is CTokenStorage {
@@ -294,7 +284,15 @@ contract CTokenInterface is CTokenStorage {
function _setInterestRateModel(InterestRateModel newInterestRateModel) public returns (uint);
}

contract CErc20Interface {
contract CErc20Storage {
/**
* @notice Underlying asset for this CToken
*/
address public underlying;
}

contract CErc20Interface is CErc20Storage {

/*** User Interface ***/

function mint(uint mintAmount) external returns (uint);
@@ -304,9 +302,10 @@ contract CErc20Interface {
function repayBorrow(uint repayAmount) external returns (uint);
function repayBorrowBehalf(address borrower, uint repayAmount) external returns (uint);
function liquidateBorrow(address borrower, uint repayAmount, CTokenInterface cTokenCollateral) external returns (uint);

}

contract CEtherInterface {
contract CEtherInterface is CErc20Storage {
/**
* @notice Indicator that this is a CEther contract (for inspection)
*/