-
Notifications
You must be signed in to change notification settings - Fork 2
/
Accessibility.sol
72 lines (61 loc) · 2.38 KB
/
Accessibility.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: SYMM-Core-Business-Source-License-1.1
// This contract is licensed under the SYMM Core Business Source License 1.1
// Copyright (c) 2023 Symmetry Labs AG
// For more information, see https://docs.symm.io/legal-disclaimer/license
pragma solidity >=0.8.18;
import "../storages/MAStorage.sol";
import "../storages/AccountStorage.sol";
import "../storages/QuoteStorage.sol";
import "../libraries/LibAccessibility.sol";
abstract contract Accessibility {
modifier onlyPartyB() {
require(MAStorage.layout().partyBStatus[msg.sender], "Accessibility: Should be partyB");
_;
}
modifier notPartyB() {
require(!MAStorage.layout().partyBStatus[msg.sender], "Accessibility: Shouldn't be partyB");
_;
}
modifier userNotPartyB(address user) {
require(!MAStorage.layout().partyBStatus[user], "Accessibility: Shouldn't be partyB");
_;
}
modifier onlyRole(bytes32 role) {
require(LibAccessibility.hasRole(msg.sender, role), "Accessibility: Must has role");
_;
}
modifier notLiquidatedPartyA(address partyA) {
require(!MAStorage.layout().liquidationStatus[partyA], "Accessibility: PartyA isn't solvent");
_;
}
modifier notLiquidatedPartyB(address partyB, address partyA) {
require(!MAStorage.layout().partyBLiquidationStatus[partyB][partyA], "Accessibility: PartyB isn't solvent");
_;
}
modifier notLiquidated(uint256 quoteId) {
Quote storage quote = QuoteStorage.layout().quotes[quoteId];
require(!MAStorage.layout().liquidationStatus[quote.partyA], "Accessibility: PartyA isn't solvent");
require(!MAStorage.layout().partyBLiquidationStatus[quote.partyB][quote.partyA], "Accessibility: PartyB isn't solvent");
require(
quote.quoteStatus != QuoteStatus.LIQUIDATED &&
quote.quoteStatus != QuoteStatus.LIQUIDATED_PENDING &&
quote.quoteStatus != QuoteStatus.CLOSED,
"Accessibility: Invalid state"
);
_;
}
modifier onlyPartyAOfQuote(uint256 quoteId) {
Quote storage quote = QuoteStorage.layout().quotes[quoteId];
require(quote.partyA == msg.sender, "Accessibility: Should be partyA of quote");
_;
}
modifier onlyPartyBOfQuote(uint256 quoteId) {
Quote storage quote = QuoteStorage.layout().quotes[quoteId];
require(quote.partyB == msg.sender, "Accessibility: Should be partyB of quote");
_;
}
modifier notSuspended(address user) {
require(!AccountStorage.layout().suspendedAddresses[user], "Accessibility: Sender is Suspended");
_;
}
}