forked from sherlock-audit/2023-06-symmetrical
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AccountStorage.sol
58 lines (51 loc) · 1.99 KB
/
AccountStorage.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
// 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 "../libraries/LibLockedValues.sol";
enum LiquidationType {
NONE,
NORMAL,
LATE,
OVERDUE
}
struct LiquidationDetail {
LiquidationType liquidationType;
int256 upnl;
int256 totalUnrealizedLoss;
uint256 deficit;
uint256 liquidationFee;
}
struct Price {
uint256 price;
uint256 timestamp;
}
library AccountStorage {
bytes32 internal constant ACCOUNT_STORAGE_SLOT = keccak256("diamond.standard.storage.account");
struct Layout {
// Users deposited amounts
mapping(address => uint256) balances;
mapping(address => uint256) allocatedBalances;
// position value will become pending locked before openPosition and will be locked after that
mapping(address => LockedValues) pendingLockedBalances;
mapping(address => LockedValues) lockedBalances;
mapping(address => mapping(address => uint256)) partyBAllocatedBalances;
mapping(address => mapping(address => LockedValues)) partyBPendingLockedBalances;
mapping(address => mapping(address => LockedValues)) partyBLockedBalances;
mapping(address => uint256) withdrawCooldown;
mapping(address => uint256) partyANonces;
mapping(address => mapping(address => uint256)) partyBNonces;
mapping(address => bool) suspendedAddresses;
mapping(address => LiquidationDetail) liquidationDetails;
mapping(address => mapping(uint256 => Price)) symbolsPrices;
mapping(address => int256) totalUnplForLiquidation;
mapping(address => address[]) liquidators;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = ACCOUNT_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}