@ubk-labs/ubk-oracle 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +34 -0
  3. package/artifacts/contracts/constants/Constants.sol/Constants.dbg.json +4 -0
  4. package/artifacts/contracts/constants/Constants.sol/Constants.json +141 -0
  5. package/artifacts/contracts/core/UBKOracle.sol/UBKOracle.dbg.json +4 -0
  6. package/artifacts/contracts/core/UBKOracle.sol/UBKOracle.json +1028 -0
  7. package/artifacts/contracts/mocks/MockAggregatorV3.sol/MockAggregatorV3.dbg.json +4 -0
  8. package/artifacts/contracts/mocks/MockAggregatorV3.sol/MockAggregatorV3.json +177 -0
  9. package/artifacts/contracts/mocks/MockERC20.sol/MockERC20.dbg.json +4 -0
  10. package/artifacts/contracts/mocks/MockERC20.sol/MockERC20.json +381 -0
  11. package/artifacts/contracts/mocks/MockERC4626.sol/Mock4626.dbg.json +4 -0
  12. package/artifacts/contracts/mocks/MockERC4626.sol/Mock4626.json +500 -0
  13. package/artifacts/contracts/mocks/MockIERC4626.sol/MockIERC4626.dbg.json +4 -0
  14. package/artifacts/contracts/mocks/MockIERC4626.sol/MockIERC4626.json +99 -0
  15. package/artifacts/interfaces/IUBKOracle.sol/IUBKOracle.dbg.json +4 -0
  16. package/artifacts/interfaces/IUBKOracle.sol/IUBKOracle.json +264 -0
  17. package/contracts/constants/Constants.sol +34 -0
  18. package/contracts/core/UBKOracle.sol +560 -0
  19. package/contracts/errors/Errors.sol +17 -0
  20. package/contracts/mocks/MockAggregatorV3.sol +56 -0
  21. package/contracts/mocks/MockERC20.sol +28 -0
  22. package/contracts/mocks/MockERC4626.sol +74 -0
  23. package/contracts/mocks/MockIERC4626.sol +13 -0
  24. package/interfaces/IUBKOracle.sol +54 -0
  25. package/package.json +41 -0
@@ -0,0 +1,264 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "IUBKOracle",
4
+ "sourceName": "interfaces/IUBKOracle.sol",
5
+ "abi": [
6
+ {
7
+ "anonymous": false,
8
+ "inputs": [
9
+ {
10
+ "indexed": true,
11
+ "internalType": "address",
12
+ "name": "token",
13
+ "type": "address"
14
+ },
15
+ {
16
+ "indexed": true,
17
+ "internalType": "address",
18
+ "name": "feed",
19
+ "type": "address"
20
+ }
21
+ ],
22
+ "name": "ChainlinkFeedSet",
23
+ "type": "event"
24
+ },
25
+ {
26
+ "anonymous": false,
27
+ "inputs": [
28
+ {
29
+ "indexed": true,
30
+ "internalType": "address",
31
+ "name": "vault",
32
+ "type": "address"
33
+ },
34
+ {
35
+ "indexed": true,
36
+ "internalType": "address",
37
+ "name": "underlying",
38
+ "type": "address"
39
+ }
40
+ ],
41
+ "name": "ERC4626Registered",
42
+ "type": "event"
43
+ },
44
+ {
45
+ "anonymous": false,
46
+ "inputs": [
47
+ {
48
+ "indexed": false,
49
+ "internalType": "uint256",
50
+ "name": "newPeriod",
51
+ "type": "uint256"
52
+ }
53
+ ],
54
+ "name": "FallbackStalePeriodUpdated",
55
+ "type": "event"
56
+ },
57
+ {
58
+ "anonymous": false,
59
+ "inputs": [
60
+ {
61
+ "indexed": true,
62
+ "internalType": "address",
63
+ "name": "token",
64
+ "type": "address"
65
+ },
66
+ {
67
+ "indexed": false,
68
+ "internalType": "uint256",
69
+ "name": "price",
70
+ "type": "uint256"
71
+ },
72
+ {
73
+ "indexed": false,
74
+ "internalType": "uint256",
75
+ "name": "timestamp",
76
+ "type": "uint256"
77
+ }
78
+ ],
79
+ "name": "LastValidPriceUpdated",
80
+ "type": "event"
81
+ },
82
+ {
83
+ "anonymous": false,
84
+ "inputs": [
85
+ {
86
+ "indexed": true,
87
+ "internalType": "address",
88
+ "name": "token",
89
+ "type": "address"
90
+ },
91
+ {
92
+ "indexed": false,
93
+ "internalType": "bool",
94
+ "name": "enabled",
95
+ "type": "bool"
96
+ }
97
+ ],
98
+ "name": "ManualModeEnabled",
99
+ "type": "event"
100
+ },
101
+ {
102
+ "anonymous": false,
103
+ "inputs": [
104
+ {
105
+ "indexed": true,
106
+ "internalType": "address",
107
+ "name": "token",
108
+ "type": "address"
109
+ },
110
+ {
111
+ "indexed": false,
112
+ "internalType": "uint256",
113
+ "name": "price",
114
+ "type": "uint256"
115
+ }
116
+ ],
117
+ "name": "ManualPriceSet",
118
+ "type": "event"
119
+ },
120
+ {
121
+ "anonymous": false,
122
+ "inputs": [
123
+ {
124
+ "indexed": true,
125
+ "internalType": "address",
126
+ "name": "token",
127
+ "type": "address"
128
+ },
129
+ {
130
+ "indexed": false,
131
+ "internalType": "uint256",
132
+ "name": "lastValid",
133
+ "type": "uint256"
134
+ },
135
+ {
136
+ "indexed": false,
137
+ "internalType": "uint256",
138
+ "name": "at",
139
+ "type": "uint256"
140
+ },
141
+ {
142
+ "indexed": false,
143
+ "internalType": "string",
144
+ "name": "reason",
145
+ "type": "string"
146
+ }
147
+ ],
148
+ "name": "OracleFallbackUsed",
149
+ "type": "event"
150
+ },
151
+ {
152
+ "anonymous": false,
153
+ "inputs": [
154
+ {
155
+ "indexed": false,
156
+ "internalType": "enum IUBKOracle.OracleMode",
157
+ "name": "oldMode",
158
+ "type": "uint8"
159
+ },
160
+ {
161
+ "indexed": false,
162
+ "internalType": "enum IUBKOracle.OracleMode",
163
+ "name": "newMode",
164
+ "type": "uint8"
165
+ }
166
+ ],
167
+ "name": "OracleModeChanged",
168
+ "type": "event"
169
+ },
170
+ {
171
+ "anonymous": false,
172
+ "inputs": [
173
+ {
174
+ "indexed": false,
175
+ "internalType": "uint256",
176
+ "name": "newPeriod",
177
+ "type": "uint256"
178
+ }
179
+ ],
180
+ "name": "StalePeriodUpdated",
181
+ "type": "event"
182
+ },
183
+ {
184
+ "anonymous": false,
185
+ "inputs": [
186
+ {
187
+ "indexed": true,
188
+ "internalType": "address",
189
+ "name": "token",
190
+ "type": "address"
191
+ }
192
+ ],
193
+ "name": "TokenSupportAdded",
194
+ "type": "event"
195
+ },
196
+ {
197
+ "anonymous": false,
198
+ "inputs": [
199
+ {
200
+ "indexed": true,
201
+ "internalType": "address",
202
+ "name": "vault",
203
+ "type": "address"
204
+ },
205
+ {
206
+ "indexed": false,
207
+ "internalType": "uint256",
208
+ "name": "minRate",
209
+ "type": "uint256"
210
+ },
211
+ {
212
+ "indexed": false,
213
+ "internalType": "uint256",
214
+ "name": "maxRate",
215
+ "type": "uint256"
216
+ }
217
+ ],
218
+ "name": "VaultRateBoundsSet",
219
+ "type": "event"
220
+ },
221
+ {
222
+ "inputs": [
223
+ {
224
+ "internalType": "address",
225
+ "name": "token",
226
+ "type": "address"
227
+ }
228
+ ],
229
+ "name": "fetchAndUpdatePrice",
230
+ "outputs": [
231
+ {
232
+ "internalType": "uint256",
233
+ "name": "",
234
+ "type": "uint256"
235
+ }
236
+ ],
237
+ "stateMutability": "nonpayable",
238
+ "type": "function"
239
+ },
240
+ {
241
+ "inputs": [
242
+ {
243
+ "internalType": "address",
244
+ "name": "token",
245
+ "type": "address"
246
+ }
247
+ ],
248
+ "name": "getPrice",
249
+ "outputs": [
250
+ {
251
+ "internalType": "uint256",
252
+ "name": "",
253
+ "type": "uint256"
254
+ }
255
+ ],
256
+ "stateMutability": "view",
257
+ "type": "function"
258
+ }
259
+ ],
260
+ "bytecode": "0x",
261
+ "deployedBytecode": "0x",
262
+ "linkReferences": {},
263
+ "deployedLinkReferences": {}
264
+ }
@@ -0,0 +1,34 @@
1
+ // SPDX-License-Identifier: MIT
2
+ pragma solidity ^0.8.20;
3
+
4
+ library Constants {
5
+ // -----------------------------------------------------------------------
6
+ // Fixed-point Math
7
+ // -----------------------------------------------------------------------
8
+ uint256 public constant WAD = 1e18; // Fixed-point math base
9
+
10
+ // -----------------------------------------------------------------------
11
+ // Oracle Price Bounds
12
+ // -----------------------------------------------------------------------
13
+ uint256 public constant ORACLE_MANUAL_PRICE_MAX_DELTA_WAD = 0.1e18; // 10%
14
+ uint256 public constant ORACLE_MIN_ABSOLUTE_PRICE_WAD = 1e10; // 0.00000001
15
+ uint256 public constant ORACLE_MAX_ABSOLUTE_PRICE_WAD = 1e24; // 1,000,000
16
+
17
+ // -----------------------------------------------------------------------
18
+ // Oracle Vault Rate Bounds
19
+ // -----------------------------------------------------------------------
20
+ uint256 public constant ORACLE_MIN_VAULT_RATE_WAD = 0.2e18; // 0.2x (20%)
21
+ uint256 public constant ORACLE_MAX_VAULT_RATE_WAD = 3e18; // 3x (300%)
22
+
23
+ // -----------------------------------------------------------------------
24
+ // Oracle Staleness Periods
25
+ // -----------------------------------------------------------------------
26
+ uint256 public constant ORACLE_DEFAULT_STALE_PERIOD = 1 hours;
27
+ uint256 public constant ORACLE_MIN_STALE_PERIOD = 1 hours;
28
+ uint256 public constant ORACLE_MAX_STALE_PERIOD = 3 hours;
29
+
30
+ // -----------------------------------------------------------------------
31
+ // Oracle Recursion
32
+ // -----------------------------------------------------------------------
33
+ uint256 public constant MAX_RECURSION_DEPTH = 5;
34
+ }