@@ -179,7 +179,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
179
179
require (ls.ethPool > 0 , "Fund before minting " );
180
180
181
181
// 3. Refresh the oracle price (if available - see checkForFreshOraclePrice() below):
182
- (ls.ethUsdPrice,, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
182
+ (ls.ethUsdPrice, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
183
183
184
184
// 4. Calculate usmOut:
185
185
uint adjShrinkFactor;
@@ -201,7 +201,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
201
201
LoadedState memory ls = loadState ();
202
202
203
203
// 2. Refresh the oracle price:
204
- (ls.ethUsdPrice,, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
204
+ (ls.ethUsdPrice, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
205
205
206
206
// 3. Calculate ethOut:
207
207
uint adjGrowthFactor;
@@ -225,7 +225,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
225
225
ls.ethPool -= msg .value ; // Backing out the ETH just received, which our calculations should ignore
226
226
227
227
// 2. Refresh the oracle price:
228
- (ls.ethUsdPrice,, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
228
+ (ls.ethUsdPrice, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
229
229
230
230
// 3. Refresh timeSystemWentUnderwater, and replace ls.usmTotalSupply with the *effective* USM supply for FUM buys:
231
231
uint debtRatio_;
@@ -253,7 +253,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
253
253
LoadedState memory ls = loadState ();
254
254
255
255
// 2. Refresh the oracle price:
256
- (ls.ethUsdPrice,, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
256
+ (ls.ethUsdPrice, ls.bidAskAdjustment) = checkForFreshOraclePrice (ls);
257
257
258
258
// 3. Calculate ethOut:
259
259
uint fumSupply = fum.totalSupply ();
@@ -276,10 +276,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
276
276
}
277
277
278
278
/**
279
- * @notice Stores the current price, `bidAskAdjustment`, and `timeSystemWentUnderwater`. Note that whereas most calls to
280
- * this function store a fresh `bidAskAdjustmentTimestamp`, most calls do *not* store a fresh `ethUsdPriceTimestamp`: the
281
- * latter isn't updated every time this is called with a new price, but only when the *oracle's* price is refreshed. The
282
- * oracle price being "refreshed" is itself a subtle idea: see the comment in `Oracle.latestPrice()`.
279
+ * @notice Stores the current price (and oracle price), `bidAskAdjustment`, and `timeSystemWentUnderwater`.
283
280
*/
284
281
function _storeState (LoadedState memory ls ) internal {
285
282
require (ls.bidAskAdjustmentTimestamp <= type (uint32 ).max, "bidAskAdjustmentTimestamp overflow " );
@@ -322,8 +319,8 @@ contract USM is IUSM, ERC20Permit, OptOutable {
322
319
323
320
// ____________________ Public Oracle view functions ____________________
324
321
325
- function latestPrice () public virtual override view returns (uint price , uint updateTime ) {
326
- (price, updateTime, ) = checkForFreshOraclePrice (loadState ());
322
+ function latestPrice () public virtual override view returns (uint price ) {
323
+ (price,) = checkForFreshOraclePrice (loadState ());
327
324
}
328
325
329
326
// ____________________ Public informational view functions ____________________
@@ -332,16 +329,11 @@ contract USM is IUSM, ERC20Permit, OptOutable {
332
329
* @notice Checks the external oracle for a fresh ETH/USD price. If it has one, we take it as the new USM system price
333
330
* (and update `bidAskAdjustment` as described below); if no fresh oracle price is available, we stick with our existing
334
331
* system price, `ls.ethUsdPrice`, which may have been nudged around by mint/burn operations since the last oracle update.
335
- *
336
- * Note that our definition of whether an oracle price is "fresh" (`updateTime > ls.ethUsdPriceTimestamp`) isn't as simple
337
- * as "whether it's changed since our last call." Eg, we only consider a Uniswap TWAP price "fresh" when a new price
338
- * observation (trade) occurs, even though `price` may change without such an observation. See the comment in
339
- * `Oracle.latestPrice()`.
340
332
*/
341
333
function checkForFreshOraclePrice (LoadedState memory ls )
342
- public view returns (uint price , uint updateTime , uint adjustment )
334
+ public view returns (uint price , uint adjustment )
343
335
{
344
- ( price, updateTime) = oracle.latestPrice ();
336
+ price = oracle.latestPrice ();
345
337
uint oraclePriceRounded = price + HALF_TRILLION; // Round for comparison below (we only store millionths precision)
346
338
unchecked { oraclePriceRounded = oraclePriceRounded / TRILLION * TRILLION; } // Zeroing out the last 12 digits
347
339
@@ -358,7 +350,7 @@ contract USM is IUSM, ERC20Permit, OptOutable {
358
350
*
359
351
* 1. storedPrice = $1,000, and bidAskAdjustment = 1.02. So, our current ETH buy price is $1,020, and our current
360
352
* ETH sell price is $1,000 (mid).
361
- * 2. The oracle comes back with a fresh price (newer updateTime) of $990.
353
+ * 2. The oracle comes back with a fresh price of $990.
362
354
* 3. The currently adjusted price is buy price (ie, adj > 1). So, we want to:
363
355
* a) Update storedPrice (mid) to $990.
364
356
* b) Update bidAskAdj to ensure that buy price remains >= $1,020.
0 commit comments