This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathQuoteStorage.sol
86 lines (78 loc) · 2.46 KB
/
QuoteStorage.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
84
85
86
// 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 PositionType {
LONG,
SHORT
}
enum OrderType {
LIMIT,
MARKET
}
enum QuoteStatus {
PENDING, //0
LOCKED, //1
CANCEL_PENDING, //2
CANCELED, //3
OPENED, //4
CLOSE_PENDING, //5
CANCEL_CLOSE_PENDING, //6
CLOSED, //7
LIQUIDATED, //8
EXPIRED //9
}
struct Quote {
uint256 id;
address[] partyBsWhiteList;
uint256 symbolId;
PositionType positionType;
OrderType orderType;
// Price of quote which PartyB opened in 18 decimals
uint256 openedPrice;
// Price of quote which PartyA requested in 18 decimals
uint256 requestedOpenPrice;
uint256 marketPrice;
// Quantity of quote which PartyA requested in 18 decimals
uint256 quantity;
// Quantity of quote which PartyB has closed until now in 18 decimals
uint256 closedAmount;
LockedValues initialLockedValues;
LockedValues lockedValues;
uint256 maxInterestRate;
address partyA;
address partyB;
QuoteStatus quoteStatus;
uint256 avgClosedPrice;
uint256 requestedClosePrice;
uint256 quantityToClose;
// handle partially open position
uint256 parentId;
uint256 createTimestamp;
uint256 modifyTimestamp;
uint256 deadline;
}
library QuoteStorage {
bytes32 internal constant QUOTE_STORAGE_SLOT = keccak256("diamond.standard.storage.quote");
struct Layout {
mapping(address => uint256[]) quoteIdsOf;
mapping(uint256 => Quote) quotes;
mapping(address => uint256) partyAPositionsCount;
mapping(address => mapping(address => uint256)) partyBPositionsCount;
mapping(address => uint256[]) partyAPendingQuotes;
mapping(address => mapping(address => uint256[])) partyBPendingQuotes;
mapping(address => uint256[]) partyAOpenPositions;
mapping(uint256 => uint256) partyAPositionsIndex;
mapping(address => mapping(address => uint256[])) partyBOpenPositions;
mapping(uint256 => uint256) partyBPositionsIndex;
uint256 lastId;
}
function layout() internal pure returns (Layout storage l) {
bytes32 slot = QUOTE_STORAGE_SLOT;
assembly {
l.slot := slot
}
}
}