forked from sherlock-audit/2023-06-symmetrical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LiquidationFacet.sol
83 lines (76 loc) · 3.04 KB
/
LiquidationFacet.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
73
74
75
76
77
78
79
80
81
82
83
// 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 "../../utils/Pausable.sol";
import "../../utils/Accessibility.sol";
import "./ILiquidationEvents.sol";
import "./LiquidationFacetImpl.sol";
contract LiquidationFacet is Pausable, Accessibility, ILiquidationEvents {
function liquidatePartyA(
address partyA,
SingleUpnlSig memory upnlSig
)
external
whenNotLiquidationPaused
notLiquidatedPartyA(partyA)
onlyRole(LibAccessibility.LIQUIDATOR_ROLE)
{
LiquidationFacetImpl.liquidatePartyA(partyA, upnlSig);
emit LiquidatePartyA(msg.sender, partyA);
}
function setSymbolsPrice(
address partyA,
PriceSig memory priceSig
) external whenNotLiquidationPaused onlyRole(LibAccessibility.LIQUIDATOR_ROLE) {
LiquidationFacetImpl.setSymbolsPrice(partyA, priceSig);
emit SetSymbolsPrices(msg.sender, partyA, priceSig.symbolIds, priceSig.prices);
}
function liquidatePendingPositionsPartyA(
address partyA
) external whenNotLiquidationPaused onlyRole(LibAccessibility.LIQUIDATOR_ROLE) {
LiquidationFacetImpl.liquidatePendingPositionsPartyA(partyA);
emit LiquidatePendingPositionsPartyA(msg.sender, partyA);
}
function liquidatePositionsPartyA(
address partyA,
uint256[] memory quoteIds
) external whenNotLiquidationPaused onlyRole(LibAccessibility.LIQUIDATOR_ROLE) {
bool isSuccessful = LiquidationFacetImpl.liquidatePositionsPartyA(partyA, quoteIds);
emit LiquidatePositionsPartyA(msg.sender, partyA, quoteIds);
if (!isSuccessful) {
emit DisputeForLiquidation(msg.sender, partyA);
} else if (
QuoteStorage.layout().partyAPositionsCount[partyA] == 0 &&
QuoteStorage.layout().partyAPendingQuotes[partyA].length == 0
) {
emit FullyLiquidatedPartyA(partyA);
}
}
function liquidatePartyB(
address partyB,
address partyA,
SingleUpnlSig memory upnlSig
)
external
whenNotLiquidationPaused
notLiquidatedPartyB(partyB, partyA)
notLiquidatedPartyA(partyA)
onlyRole(LibAccessibility.LIQUIDATOR_ROLE)
{
LiquidationFacetImpl.liquidatePartyB(partyB, partyA, upnlSig);
emit LiquidatePartyB(msg.sender, partyB, partyA);
}
function liquidatePositionsPartyB(
address partyB,
address partyA,
QuotePriceSig memory priceSig
) external whenNotLiquidationPaused onlyRole(LibAccessibility.LIQUIDATOR_ROLE) {
LiquidationFacetImpl.liquidatePositionsPartyB(partyB, partyA, priceSig);
emit LiquidatePositionsPartyB(msg.sender, partyB, partyA, priceSig.quoteIds);
if (QuoteStorage.layout().partyBPositionsCount[partyB][partyA] == 0) {
emit FullyLiquidatedPartyB(partyB, partyA);
}
}
}