@@ -135,8 +135,11 @@ abstract contract ReservoirPair is IAssetManagedPair, ReservoirERC20 {
135
135
_writeSlot0Timestamp (sSlot0, aBlockTimestampLast, false );
136
136
}
137
137
138
- // update reserves with new balances
139
- // on the first call per block, update price oracle using previous reserves
138
+ /// @notice update reserves with new balances
139
+ /// @notice on the first call per block, accumulate price oracle using previous instant prices and write the new instant prices
140
+ /// @dev we write an oracle sample even at the time of pair creation. Also we do not update instant prices for
141
+ /// subsequent mint/burn/swaps in the same block. the team has assessed that this is a small risk given the very
142
+ /// fast block times on L2s and has decided to make the tradeoff to minimize complexity
140
143
function _updateAndUnlock (
141
144
Slot0 storage sSlot0 ,
142
145
uint256 aBalance0 ,
@@ -156,13 +159,8 @@ abstract contract ReservoirPair is IAssetManagedPair, ReservoirERC20 {
156
159
lTimeElapsed = lBlockTimestamp - aBlockTimestampLast;
157
160
158
161
// both balance should never be zero, but necessary to check so we don't pass 0 values into arithmetic operations
159
- // on the first activity of every block, accumulate using previous instant prices and write the current instant prices
160
- // we create a new sample even at the time of pair creation
161
- // this implies that we do not update instant prices for subsequent mint/burn/swaps in the same block
162
- // but the team has assessed that this is a small risk given the very fast block times on L2s
163
- // and has decided to make the tradeoff to minimize complexity
164
- if (lTimeElapsed * aBalance0 * aBalance1 > 0 ) {
165
-
162
+ // shortcut to calculate lTimeElapsed > 0 && aBalance0 > 0 && aBalance1 > 0
163
+ if (lTimeElapsed * aBalance0 * aBalance1 > 0 ) {
166
164
Observation storage lPrevious = _observations[sSlot0.index];
167
165
(uint256 lInstantRawPrice , int256 lLogInstantRawPrice ) = _calcSpotAndLogPrice (aBalance0, aBalance1);
168
166
0 commit comments