1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ pragma solidity 0.6.10 ;
3
+ pragma experimental "ABIEncoderV2 " ;
4
+
5
+ import {IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol " ;
6
+
7
+ /**
8
+ * @title Optimistic Oracle V3 Interface that callers must use to assert truths about the world.
9
+ */
10
+ interface OptimisticOracleV3Interface {
11
+ // Struct grouping together the settings related to the escalation manager stored in the assertion.
12
+ struct EscalationManagerSettings {
13
+ bool arbitrateViaEscalationManager; // False if the DVM is used as an oracle (EscalationManager on True).
14
+ bool discardOracle; // False if Oracle result is used for resolving assertion after dispute.
15
+ bool validateDisputers; // True if the EM isDisputeAllowed should be checked on disputes.
16
+ address assertingCaller; // Stores msg.sender when assertion was made.
17
+ address escalationManager; // Address of the escalation manager (zero address if not configured).
18
+ }
19
+
20
+ // Struct for storing properties and lifecycle of an assertion.
21
+ struct Assertion {
22
+ EscalationManagerSettings escalationManagerSettings; // Settings related to the escalation manager.
23
+ address asserter; // Address of the asserter.
24
+ uint64 assertionTime; // Time of the assertion.
25
+ bool settled; // True if the request is settled.
26
+ IERC20 currency; // ERC20 token used to pay rewards and fees.
27
+ uint64 expirationTime; // Unix timestamp marking threshold when the assertion can no longer be disputed.
28
+ bool settlementResolution; // Resolution of the assertion (false till resolved).
29
+ bytes32 domainId; // Optional domain that can be used to relate the assertion to others in the escalationManager.
30
+ bytes32 identifier; // UMA DVM identifier to use for price requests in the event of a dispute.
31
+ uint256 bond; // Amount of currency that the asserter has bonded.
32
+ address callbackRecipient; // Address that receives the callback.
33
+ address disputer; // Address of the disputer.
34
+ }
35
+
36
+ // Struct for storing cached currency whitelist.
37
+ struct WhitelistedCurrency {
38
+ bool isWhitelisted; // True if the currency is whitelisted.
39
+ uint256 finalFee; // Final fee of the currency.
40
+ }
41
+
42
+ /**
43
+ * @notice Returns the default identifier used by the Optimistic Oracle V3.
44
+ * @return The default identifier.
45
+ */
46
+ function defaultIdentifier () external view returns (bytes32 );
47
+
48
+ /**
49
+ * @notice Fetches information about a specific assertion and returns it.
50
+ * @param assertionId unique identifier for the assertion to fetch information for.
51
+ * @return assertion information about the assertion.
52
+ */
53
+ function getAssertion (bytes32 assertionId ) external view returns (Assertion memory );
54
+
55
+ /**
56
+ * @notice Asserts a truth about the world, using the default currency and liveness. No callback recipient or
57
+ * escalation manager is enabled. The caller is expected to provide a bond of finalFee/burnedBondPercentage
58
+ * (with burnedBondPercentage set to 50%, the bond is 2x final fee) of the default currency.
59
+ * @dev The caller must approve this contract to spend at least the result of getMinimumBond(defaultCurrency).
60
+ * @param claim the truth claim being asserted. This is an assertion about the world, and is verified by disputers.
61
+ * @param asserter receives bonds back at settlement. This could be msg.sender or
62
+ * any other account that the caller wants to receive the bond at settlement time.
63
+ * @return assertionId unique identifier for this assertion.
64
+ */
65
+ function assertTruthWithDefaults (bytes memory claim , address asserter ) external returns (bytes32 );
66
+
67
+ /**
68
+ * @notice Asserts a truth about the world, using a fully custom configuration.
69
+ * @dev The caller must approve this contract to spend at least bond amount of currency.
70
+ * @param claim the truth claim being asserted. This is an assertion about the world, and is verified by disputers.
71
+ * @param asserter receives bonds back at settlement. This could be msg.sender or
72
+ * any other account that the caller wants to receive the bond at settlement time.
73
+ * @param callbackRecipient if configured, this address will receive a function call assertionResolvedCallback and
74
+ * assertionDisputedCallback at resolution or dispute respectively. Enables dynamic responses to these events. The
75
+ * recipient _must_ implement these callbacks and not revert or the assertion resolution will be blocked.
76
+ * @param escalationManager if configured, this address will control escalation properties of the assertion. This
77
+ * means a) choosing to arbitrate via the UMA DVM, b) choosing to discard assertions on dispute, or choosing to
78
+ * validate disputes. Combining these, the asserter can define their own security properties for the assertion.
79
+ * escalationManager also _must_ implement the same callbacks as callbackRecipient.
80
+ * @param liveness time to wait before the assertion can be resolved. Assertion can be disputed in this time.
81
+ * @param currency bond currency pulled from the caller and held in escrow until the assertion is resolved.
82
+ * @param bond amount of currency to pull from the caller and hold in escrow until the assertion is resolved. This
83
+ * must be >= getMinimumBond(address(currency)).
84
+ * @param identifier UMA DVM identifier to use for price requests in the event of a dispute. Must be pre-approved.
85
+ * @param domainId optional domain that can be used to relate this assertion to others in the escalationManager and
86
+ * can be used by the configured escalationManager to define custom behavior for groups of assertions. This is
87
+ * typically used for "escalation games" by changing bonds or other assertion properties based on the other
88
+ * assertions that have come before. If not needed this value should be 0 to save gas.
89
+ * @return assertionId unique identifier for this assertion.
90
+ */
91
+ function assertTruth (
92
+ bytes memory claim ,
93
+ address asserter ,
94
+ address callbackRecipient ,
95
+ address escalationManager ,
96
+ uint64 liveness ,
97
+ IERC20 currency ,
98
+ uint256 bond ,
99
+ bytes32 identifier ,
100
+ bytes32 domainId
101
+ ) external returns (bytes32 );
102
+
103
+ /**
104
+ * @notice Fetches information about a specific identifier & currency from the UMA contracts and stores a local copy
105
+ * of the information within this contract. This is used to save gas when making assertions as we can avoid an
106
+ * external call to the UMA contracts to fetch this.
107
+ * @param identifier identifier to fetch information for and store locally.
108
+ * @param currency currency to fetch information for and store locally.
109
+ */
110
+ function syncUmaParams (bytes32 identifier , address currency ) external ;
111
+
112
+ /**
113
+ * @notice Resolves an assertion. If the assertion has not been disputed, the assertion is resolved as true and the
114
+ * asserter receives the bond. If the assertion has been disputed, the assertion is resolved depending on the oracle
115
+ * result. Based on the result, the asserter or disputer receives the bond. If the assertion was disputed then an
116
+ * amount of the bond is sent to the UMA Store as an oracle fee based on the burnedBondPercentage. The remainder of
117
+ * the bond is returned to the asserter or disputer.
118
+ * @param assertionId unique identifier for the assertion to resolve.
119
+ */
120
+ function settleAssertion (bytes32 assertionId ) external ;
121
+
122
+ /**
123
+ * @notice Settles an assertion and returns the resolution.
124
+ * @param assertionId unique identifier for the assertion to resolve and return the resolution for.
125
+ * @return resolution of the assertion.
126
+ */
127
+ function settleAndGetAssertionResult (bytes32 assertionId ) external returns (bool );
128
+
129
+ /**
130
+ * @notice Fetches the resolution of a specific assertion and returns it. If the assertion has not been settled then
131
+ * this will revert. If the assertion was disputed and configured to discard the oracle resolution return false.
132
+ * @param assertionId unique identifier for the assertion to fetch the resolution for.
133
+ * @return resolution of the assertion.
134
+ */
135
+ function getAssertionResult (bytes32 assertionId ) external view returns (bool );
136
+
137
+ /**
138
+ * @notice Returns the minimum bond amount required to make an assertion. This is calculated as the final fee of the
139
+ * currency divided by the burnedBondPercentage. If burn percentage is 50% then the min bond is 2x the final fee.
140
+ * @param currency currency to calculate the minimum bond for.
141
+ * @return minimum bond amount.
142
+ */
143
+ function getMinimumBond (address currency ) external view returns (uint256 );
144
+
145
+ event AssertionMade (
146
+ bytes32 indexed assertionId ,
147
+ bytes32 domainId ,
148
+ bytes claim ,
149
+ address indexed asserter ,
150
+ address callbackRecipient ,
151
+ address escalationManager ,
152
+ address caller ,
153
+ uint64 expirationTime ,
154
+ IERC20 currency ,
155
+ uint256 bond ,
156
+ bytes32 indexed identifier
157
+ );
158
+
159
+ event AssertionDisputed (bytes32 indexed assertionId , address indexed caller , address indexed disputer );
160
+
161
+ event AssertionSettled (
162
+ bytes32 indexed assertionId ,
163
+ address indexed bondRecipient ,
164
+ bool disputed ,
165
+ bool settlementResolution ,
166
+ address settleCaller
167
+ );
168
+
169
+ event AdminPropertiesSet (IERC20 defaultCurrency , uint64 defaultLiveness , uint256 burnedBondPercentage );
170
+ }
0 commit comments