-
Notifications
You must be signed in to change notification settings - Fork 15
/
IMarket.sol
105 lines (97 loc) · 4.78 KB
/
IMarket.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.13;
import "@equilibria/root/attribute/interfaces/IInstance.sol";
import "@equilibria/root/number/types/UFixed6.sol";
import "@equilibria/root/token/types/Token18.sol";
import "./IOracleProvider.sol";
import "./IPayoffProvider.sol";
import "../types/OracleVersion.sol";
import "../types/MarketParameter.sol";
import "../types/RiskParameter.sol";
import "../types/Version.sol";
import "../types/Local.sol";
import "../types/Global.sol";
import "../types/Position.sol";
interface IMarket is IInstance {
struct MarketDefinition {
Token18 token;
IOracleProvider oracle;
IPayoffProvider payoff;
}
struct Context {
ProtocolParameter protocolParameter;
MarketParameter marketParameter;
RiskParameter riskParameter;
uint256 currentTimestamp;
OracleVersion latestVersion;
OracleVersion positionVersion;
Global global;
Local local;
PositionContext currentPosition;
PositionContext latestPosition;
}
struct PositionContext {
Position global;
Position local;
}
event Updated(address indexed account, uint256 version, UFixed6 newMaker, UFixed6 newLong, UFixed6 newShort, Fixed6 collateral, bool protect);
event PositionProcessed(uint256 indexed fromOracleVersion, uint256 indexed toOracleVersion, uint256 fromPosition, uint256 toPosition, VersionAccumulationResult accumulationResult);
event AccountPositionProcessed(address indexed account, uint256 indexed fromOracleVersion, uint256 indexed toOracleVersion, uint256 fromPosition, uint256 toPosition, LocalAccumulationResult accumulationResult);
event BeneficiaryUpdated(address newBeneficiary);
event CoordinatorUpdated(address newCoordinator);
event FeeClaimed(address indexed account, UFixed6 amount);
event RewardClaimed(address indexed account, UFixed6 amount);
event ParameterUpdated(MarketParameter newParameter);
event RiskParameterUpdated(RiskParameter newRiskParameter);
event RewardUpdated(Token18 newReward);
error MarketInsufficientLiquidityError();
error MarketInsufficientMarginError();
error MarketInsufficientMaintenanceError();
error MarketInsufficientCollateralError();
error MarketProtectedError();
error MarketMakerOverLimitError();
error MarketClosedError();
error MarketCollateralBelowLimitError();
error MarketOperatorNotAllowedError();
error MarketNotSingleSidedError();
error MarketExceedsPendingIdLimitError();
error MarketRewardAlreadySetError();
error MarketInvalidRewardError();
error MarketNotCoordinatorError();
error MarketNotBeneficiaryError();
error MarketInvalidProtectionError();
error MarketStalePriceError();
error MarketEfficiencyUnderLimitError();
error MarketInvalidMarketParameterError(uint256 code);
error MarketInvalidRiskParameterError(uint256 code);
error GlobalStorageInvalidError();
error LocalStorageInvalidError();
error MarketParameterStorageInvalidError();
error PositionStorageLocalInvalidError();
error RiskParameterStorageInvalidError();
error VersionStorageInvalidError();
function initialize(MarketDefinition calldata definition_) external;
function token() external view returns (Token18);
function reward() external view returns (Token18);
function oracle() external view returns (IOracleProvider);
function payoff() external view returns (IPayoffProvider);
function beneficiary() external view returns (address);
function coordinator() external view returns (address);
function positions(address account) external view returns (Position memory);
function pendingPositions(address account, uint256 id) external view returns (Position memory);
function locals(address account) external view returns (Local memory);
function versions(uint256 timestamp) external view returns (Version memory);
function pendingPosition(uint256 id) external view returns (Position memory);
function position() external view returns (Position memory);
function global() external view returns (Global memory);
function update(address account, UFixed6 newMaker, UFixed6 newLong, UFixed6 newShort, Fixed6 collateral, bool protect) external;
function updateBeneficiary(address newBeneficiary) external;
function updateCoordinator(address newCoordinator) external;
function updateReward(Token18 newReward) external;
function parameter() external view returns (MarketParameter memory);
function riskParameter() external view returns (RiskParameter memory);
function updateParameter(MarketParameter memory newParameter) external;
function updateRiskParameter(RiskParameter memory newRiskParameter) external;
function claimFee() external;
function claimReward() external;
}