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

Add _setCollateralPaused function to Comptroller #19

Open
nourharidy opened this issue Jan 23, 2022 · 3 comments
Open

Add _setCollateralPaused function to Comptroller #19

nourharidy opened this issue Jan 23, 2022 · 3 comments

Comments

@nourharidy
Copy link
Member

nourharidy commented Jan 23, 2022

Add a _setCollateralPaused(CToken cToken, bool state) public returns (bool) function the Comptroller that disables future borrows for all users using a cToken as collateral

Similar to the other guardian roles, the function can be called by either the pauseGuardian or the admin (governance). However, only admin can pass state as false. Both can pass it as true.

If state is passed as true, the Comptroller should prevent future borrows across all Anchor markets for any user that uses the cToken as a collateral by checking checkMembership(address account, CToken cToken) function. If passed as false, the effect should be reversed.

The function should allow multiple cTokens to be paused as collateral at the same time.

Changes should be made to https://github.com/InverseFinance/anchor/blob/master/contracts/Comptroller.sol and its dependencies only.

The modified Comptroller will replace the existing Anchor Comptroller on Ethereum by executing a a proxy pattern upgrade on the Unitroller https://etherscan.io/address/0x4dcf7407ae5c07f8681e1659f626e114a7667339

Changes to the Comptroller must follow proxy pattern best practices in order to avoid an upgrade flaw

@beepidibop
Copy link

beepidibop commented Jan 30, 2022

Saw your tweet, here's the PR

I have no idea if it'll work tbh. Just thought I'd give it a shot.

#21

@georgeroman
Copy link

Isn't this already covered by the below method and check?

function _setBorrowPaused(CToken cToken, bool state) public returns (bool) {
require(markets[address(cToken)].isListed, "cannot pause a market that is not listed");
require(msg.sender == pauseGuardian || msg.sender == admin, "only pause guardian and admin can pause");
require(msg.sender == admin || state == true, "only admin can unpause");
borrowGuardianPaused[address(cToken)] = state;
emit ActionPaused(cToken, "Borrow", state);
return state;
}
// Pausing is a very serious situation - we revert to sound the alarms
require(!borrowGuardianPaused[cToken], "borrow is paused");

@beepidibop
Copy link

Isn't this already covered by the below method and check?

Different scenarios. The above case is enough if you want to pause borrowing a token completely. The issue requested a way to stop said token from being a collateral for new loans.

E.g.
Pausing ETH borrowing would prevent people from borrowing more ETH, but doesn't stop them from borrowing WBTC with ETH deposits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants