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

Prevent partyA to become liquidator #48

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions contracts/facets/PartyA/PartyAFacetImpl.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../libraries/LibAccount.sol";
import "../../libraries/LibSolvency.sol";
import "../../libraries/LibQuote.sol";
import "../../libraries/LibLiquidation.sol";
import "../../libraries/LibAccessibility.sol";
import "../../libraries/SharedEvents.sol";
import "../../storages/MAStorage.sol";
import "../../storages/QuoteStorage.sol";
Expand Down Expand Up @@ -41,6 +42,7 @@ library PartyAFacetImpl {
MAStorage.Layout storage maLayout = MAStorage.layout();
SymbolStorage.Layout storage symbolLayout = SymbolStorage.layout();

require(!LibAccessibility.hasRole(msg.sender, LibAccessibility.LIQUIDATOR_ROLE), "PartyAFacet: Liquidator can't be partyA");
require(
quoteLayout.partyAPendingQuotes[msg.sender].length < maLayout.pendingQuotesValidLength,
"PartyAFacet: Number of pending quotes out of range"
Expand Down
6 changes: 6 additions & 0 deletions contracts/facets/control/ControlFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ contract ControlFacet is Accessibility, Ownable, IControlFacet {
/// @param role The role to be granted
function grantRole(address user, bytes32 role) external onlyRole(LibAccessibility.DEFAULT_ADMIN_ROLE) {
require(user != address(0), "ControlFacet: Zero address");
if (role == LibAccessibility.LIQUIDATOR_ROLE) {
require(
QuoteStorage.layout().partyAPendingQuotes[user].length == 0 && QuoteStorage.layout().partyAOpenPositions[user].length == 0,
"ControlFacet: PartyA can't become liquidator"
);
}
GlobalAppStorage.layout().hasRole[user][role] = true;
emit RoleGranted(role, user);
}
Expand Down