@ubk-labs/ubk-oracle 0.1.4 → 0.1.6

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 (23) hide show
  1. package/contracts/constants/{Constants.sol → UBKOracleConstants.sol} +2 -2
  2. package/contracts/core/UBKOracle.sol +36 -36
  3. package/contracts/errors/{Errors.sol → UBKOracleErrors.sol} +1 -1
  4. package/contracts/imports/UBKImports.sol +14 -0
  5. package/package.json +4 -4
  6. package/artifacts/contracts/constants/Constants.sol/Constants.dbg.json +0 -4
  7. package/artifacts/contracts/constants/Constants.sol/Constants.json +0 -141
  8. package/artifacts/contracts/core/UBKOracle.sol/UBKOracle.dbg.json +0 -4
  9. package/artifacts/contracts/core/UBKOracle.sol/UBKOracle.json +0 -1028
  10. package/artifacts/contracts/mocks/MockAggregatorV3.sol/MockAggregatorV3.dbg.json +0 -4
  11. package/artifacts/contracts/mocks/MockAggregatorV3.sol/MockAggregatorV3.json +0 -177
  12. package/artifacts/contracts/mocks/MockERC20.sol/MockERC20.dbg.json +0 -4
  13. package/artifacts/contracts/mocks/MockERC20.sol/MockERC20.json +0 -381
  14. package/artifacts/contracts/mocks/MockERC4626.sol/Mock4626.dbg.json +0 -4
  15. package/artifacts/contracts/mocks/MockERC4626.sol/Mock4626.json +0 -500
  16. package/artifacts/contracts/mocks/MockIERC4626.sol/MockIERC4626.dbg.json +0 -4
  17. package/artifacts/contracts/mocks/MockIERC4626.sol/MockIERC4626.json +0 -99
  18. package/artifacts/interfaces/IUBKOracle.sol/IUBKOracle.dbg.json +0 -4
  19. package/artifacts/interfaces/IUBKOracle.sol/IUBKOracle.json +0 -312
  20. package/contracts/mocks/MockAggregatorV3.sol +0 -56
  21. package/contracts/mocks/MockERC20.sol +0 -28
  22. package/contracts/mocks/MockERC4626.sol +0 -74
  23. package/contracts/mocks/MockIERC4626.sol +0 -13
@@ -1,312 +0,0 @@
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
- "internalType": "uint256",
249
- "name": "usdAmount",
250
- "type": "uint256"
251
- }
252
- ],
253
- "name": "fromUSD",
254
- "outputs": [
255
- {
256
- "internalType": "uint256",
257
- "name": "tokenAmount",
258
- "type": "uint256"
259
- }
260
- ],
261
- "stateMutability": "view",
262
- "type": "function"
263
- },
264
- {
265
- "inputs": [
266
- {
267
- "internalType": "address",
268
- "name": "token",
269
- "type": "address"
270
- }
271
- ],
272
- "name": "getPrice",
273
- "outputs": [
274
- {
275
- "internalType": "uint256",
276
- "name": "",
277
- "type": "uint256"
278
- }
279
- ],
280
- "stateMutability": "view",
281
- "type": "function"
282
- },
283
- {
284
- "inputs": [
285
- {
286
- "internalType": "address",
287
- "name": "token",
288
- "type": "address"
289
- },
290
- {
291
- "internalType": "uint256",
292
- "name": "amount",
293
- "type": "uint256"
294
- }
295
- ],
296
- "name": "toUSD",
297
- "outputs": [
298
- {
299
- "internalType": "uint256",
300
- "name": "usdValue",
301
- "type": "uint256"
302
- }
303
- ],
304
- "stateMutability": "view",
305
- "type": "function"
306
- }
307
- ],
308
- "bytecode": "0x",
309
- "deployedBytecode": "0x",
310
- "linkReferences": {},
311
- "deployedLinkReferences": {}
312
- }
@@ -1,56 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";
5
-
6
- contract MockAggregatorV3 is AggregatorV3Interface {
7
- int256 private answer;
8
- uint8 private decimals_;
9
- uint256 private updatedAt_;
10
-
11
- constructor(int256 _initialAnswer, uint8 _decimals) {
12
- answer = _initialAnswer;
13
- decimals_ = _decimals;
14
- updatedAt_ = block.timestamp;
15
- }
16
-
17
- function decimals() external view override returns (uint8) {
18
- return decimals_;
19
- }
20
-
21
- function description() external pure override returns (string memory) {
22
- return "Mock Chainlink Aggregator";
23
- }
24
-
25
- function version() external pure override returns (uint256) {
26
- return 1;
27
- }
28
-
29
- function latestRoundData()
30
- external
31
- view
32
- override
33
- returns (uint80 roundId, int256 answer_, uint256 startedAt, uint256 updatedAt, uint80 answeredInRound)
34
- {
35
- return (0, answer, updatedAt_, updatedAt_, 0);
36
- }
37
-
38
- function getRoundData(uint80) external view override returns (uint80, int256, uint256, uint256, uint80) {
39
- return (0, answer, updatedAt_, updatedAt_, 0);
40
- }
41
-
42
- /// @notice manually update the price
43
- function updateAnswer(int256 _newAnswer) external {
44
- answer = _newAnswer;
45
- updatedAt_ = block.timestamp;
46
- }
47
-
48
- /// @notice manually set a custom updatedAt for staleness testing
49
- function setUpdatedAt(uint256 _timestamp) external {
50
- updatedAt_ = _timestamp;
51
- }
52
-
53
- function getUpdatedAt() external view returns (uint256) {
54
- return updatedAt_;
55
- }
56
- }
@@ -1,28 +0,0 @@
1
- // MockERC20 for testing
2
- // SPDX-License-Identifier: MIT
3
- pragma solidity ^0.8.20;
4
-
5
- import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
6
-
7
- contract MockERC20 is ERC20 {
8
- uint8 private immutable _decimals;
9
-
10
- constructor(string memory name_, string memory symbol_, uint8 decimals_, uint256 initialSupply)
11
- ERC20(name_, symbol_)
12
- {
13
- _decimals = decimals_;
14
- _mint(msg.sender, initialSupply);
15
- }
16
-
17
- function decimals() public view override returns (uint8) {
18
- return _decimals;
19
- }
20
-
21
- function mint(address to, uint256 amount) external {
22
- _mint(to, amount);
23
- }
24
-
25
- function burn(address from, uint256 amount) external {
26
- _burn(from, amount);
27
- }
28
- }
@@ -1,74 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- import "./MockERC20.sol";
5
- import "./MockIERC4626.sol";
6
-
7
- contract Mock4626 is MockERC20, MockIERC4626 {
8
- uint256 public exchangeRate = 1e18; // 1:1 default
9
- address private _asset; // underlying ERC20 asset
10
- uint8 private immutable _assetDecimals;
11
-
12
- constructor(
13
- string memory name_,
14
- string memory symbol_,
15
- uint8 decimals_, // vault decimals (e.g. 18)
16
- uint256 initialSupply,
17
- address asset_
18
- )
19
- MockERC20(name_, symbol_, decimals_, initialSupply)
20
- {
21
- _asset = asset_;
22
- _assetDecimals = MockERC20(asset_).decimals();
23
- }
24
-
25
- /// @notice sets a mock exchange rate for testing
26
- function setExchangeRate(uint256 newRate) external {
27
- exchangeRate = newRate;
28
- }
29
-
30
- /// @notice mock conversion (shares → assets)
31
- function convertToAssets(uint256 shares) external view override returns (uint256) {
32
- uint8 vaultDecimals = decimals();
33
-
34
- // Normalize shares → assets
35
- // assets = shares * 10^(assetDecimals) / 10^(vaultDecimals) * exchangeRate / 1e18
36
- uint256 assets = (shares * (10 ** _assetDecimals)) / (10 ** vaultDecimals);
37
- return (assets * exchangeRate) / 1e18;
38
- }
39
-
40
- /// @notice ERC-4626 required function
41
- function asset() external view override returns (address) {
42
- return _asset;
43
- }
44
-
45
- /// @notice Deposit assets and mint shares to `receiver`
46
- /// @notice Deposit assets and mint shares to `receiver`
47
- function deposit(uint256 assets, address receiver) external override returns (uint256 shares) {
48
- require(assets > 0, "Zero deposit");
49
-
50
- // Compute shares using convertToShares()
51
- shares = this.convertToShares(assets);
52
-
53
- // Pull underlying from sender
54
- IERC20(_asset).transferFrom(msg.sender, address(this), assets);
55
-
56
- // Mint vault shares (this ERC20) to receiver
57
- _mint(receiver, shares);
58
- }
59
-
60
- /// @notice mock conversion (assets → shares)
61
- function convertToShares(uint256 assets) external view returns (uint256) {
62
- uint8 vaultDecimals = decimals();
63
-
64
- // Normalize: assets → shares
65
- uint256 normalized = (assets * (10 ** vaultDecimals)) / (10 ** _assetDecimals);
66
-
67
- return (normalized * 1e18) / exchangeRate;
68
- }
69
-
70
- /// @notice get exchange rates
71
- function getExchangeRate() external view returns (uint256) {
72
- return exchangeRate;
73
- }
74
- }
@@ -1,13 +0,0 @@
1
- // SPDX-License-Identifier: MIT
2
- pragma solidity ^0.8.20;
3
-
4
- //Mocked interface for IERC-4626 behavior.
5
- //This is far more minimal and easy to work with for testing purposes.
6
- //Will be used to impart 4626 functionality to sDAI in tests.
7
- interface MockIERC4626 {
8
- function setExchangeRate(uint256 newRate) external;
9
- function convertToAssets(uint256 shares) external view returns (uint256);
10
- function convertToShares(uint256 assets) external view returns (uint256);
11
- function asset() external view returns (address);
12
- function deposit(uint256 assets, address receiver) external returns (uint256 shares);
13
- }