Skip to content

Commit c5ccf4d

Browse files
ewilzlint-action
andauthored
Fix code style issues with Prettier (#629)
Co-authored-by: Lint Action <[email protected]>
1 parent 05c10bf commit c5ccf4d

18 files changed

+296
-239
lines changed

audits/tob/contracts/crytic/echidna/E2E_mint_burn.sol

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,11 @@ contract E2E_mint_burn {
382382

383383
function test_mint(uint128 _amount) public {
384384
if (!inited) _init(_amount);
385-
(int24 _tL, int24 _tU) = forgePosition(
386-
_amount,
387-
poolParams.tickSpacing,
388-
poolParams.tickCount,
389-
poolParams.maxTick
390-
);
391-
392-
(UniswapMinter.MinterStats memory bfre, UniswapMinter.MinterStats memory aftr) = minter.doMint(
393-
_tL,
394-
_tU,
395-
_amount
396-
);
385+
(int24 _tL, int24 _tU) =
386+
forgePosition(_amount, poolParams.tickSpacing, poolParams.tickCount, poolParams.maxTick);
387+
388+
(UniswapMinter.MinterStats memory bfre, UniswapMinter.MinterStats memory aftr) =
389+
minter.doMint(_tL, _tU, _amount);
397390
storeUsedTicks(_tL, _tU);
398391

399392
check_mint_invariants(_tL, _tU, bfre, aftr);

audits/tob/contracts/crytic/echidna/E2E_swap.sol

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -360,11 +360,8 @@ contract E2E_swap {
360360
uint160 sqrtPriceLimitX96 = get_random_zeroForOne_priceLimit(_amount);
361361
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
362362

363-
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) = swapper.doSwap(
364-
true,
365-
_amountSpecified,
366-
sqrtPriceLimitX96
367-
);
363+
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) =
364+
swapper.doSwap(true, _amountSpecified, sqrtPriceLimitX96);
368365

369366
check_swap_invariants(
370367
bfre.tick,
@@ -397,11 +394,8 @@ contract E2E_swap {
397394
uint160 sqrtPriceLimitX96 = get_random_oneForZero_priceLimit(_amount);
398395
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
399396

400-
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) = swapper.doSwap(
401-
false,
402-
_amountSpecified,
403-
sqrtPriceLimitX96
404-
);
397+
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) =
398+
swapper.doSwap(false, _amountSpecified, sqrtPriceLimitX96);
405399

406400
check_swap_invariants(
407401
bfre.tick,
@@ -434,11 +428,8 @@ contract E2E_swap {
434428
uint160 sqrtPriceLimitX96 = get_random_zeroForOne_priceLimit(_amount);
435429
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
436430

437-
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) = swapper.doSwap(
438-
true,
439-
_amountSpecified,
440-
sqrtPriceLimitX96
441-
);
431+
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) =
432+
swapper.doSwap(true, _amountSpecified, sqrtPriceLimitX96);
442433

443434
check_swap_invariants(
444435
bfre.tick,
@@ -471,11 +462,8 @@ contract E2E_swap {
471462
uint160 sqrtPriceLimitX96 = get_random_oneForZero_priceLimit(_amount);
472463
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
473464

474-
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) = swapper.doSwap(
475-
false,
476-
_amountSpecified,
477-
sqrtPriceLimitX96
478-
);
465+
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) =
466+
swapper.doSwap(false, _amountSpecified, sqrtPriceLimitX96);
479467

480468
check_swap_invariants(
481469
bfre.tick,

contracts/UniswapV3Pool.sol

Lines changed: 81 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
138138
/// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
139139
/// check
140140
function balance0() private view returns (uint256) {
141-
(bool success, bytes memory data) = token0.staticcall(
142-
abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this))
143-
);
141+
(bool success, bytes memory data) =
142+
token0.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
144143
require(success && data.length >= 32);
145144
return abi.decode(data, (uint256));
146145
}
@@ -149,9 +148,8 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
149148
/// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
150149
/// check
151150
function balance1() private view returns (uint256) {
152-
(bool success, bytes memory data) = token1.staticcall(
153-
abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this))
154-
);
151+
(bool success, bytes memory data) =
152+
token1.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
155153
require(success && data.length >= 32);
156154
return abi.decode(data, (uint256));
157155
}
@@ -209,14 +207,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
209207
);
210208
} else if (_slot0.tick < tickUpper) {
211209
uint32 time = _blockTimestamp();
212-
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) = observations.observeSingle(
213-
time,
214-
0,
215-
_slot0.tick,
216-
_slot0.observationIndex,
217-
liquidity,
218-
_slot0.observationCardinality
219-
);
210+
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
211+
observations.observeSingle(
212+
time,
213+
0,
214+
_slot0.tick,
215+
_slot0.observationIndex,
216+
liquidity,
217+
_slot0.observationCardinality
218+
);
220219
return (
221220
tickCumulative - tickCumulativeLower - tickCumulativeUpper,
222221
secondsPerLiquidityCumulativeX128 -
@@ -260,10 +259,8 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
260259
noDelegateCall
261260
{
262261
uint16 observationCardinalityNextOld = slot0.observationCardinalityNext; // for the event
263-
uint16 observationCardinalityNextNew = observations.grow(
264-
observationCardinalityNextOld,
265-
observationCardinalityNext
266-
);
262+
uint16 observationCardinalityNextNew =
263+
observations.grow(observationCardinalityNextOld, observationCardinalityNext);
267264
slot0.observationCardinalityNext = observationCardinalityNextNew;
268265
if (observationCardinalityNextOld != observationCardinalityNextNew)
269266
emit IncreaseObservationCardinalityNext(observationCardinalityNextOld, observationCardinalityNextNew);
@@ -396,14 +393,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
396393
bool flippedUpper;
397394
if (liquidityDelta != 0) {
398395
uint32 time = _blockTimestamp();
399-
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) = observations.observeSingle(
400-
time,
401-
0,
402-
slot0.tick,
403-
slot0.observationIndex,
404-
liquidity,
405-
slot0.observationCardinality
406-
);
396+
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
397+
observations.observeSingle(
398+
time,
399+
0,
400+
slot0.tick,
401+
slot0.observationIndex,
402+
liquidity,
403+
slot0.observationCardinality
404+
);
407405

408406
flippedLower = ticks.update(
409407
tickLower,
@@ -438,13 +436,8 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
438436
}
439437
}
440438

441-
(uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) = ticks.getFeeGrowthInside(
442-
tickLower,
443-
tickUpper,
444-
tick,
445-
_feeGrowthGlobal0X128,
446-
_feeGrowthGlobal1X128
447-
);
439+
(uint256 feeGrowthInside0X128, uint256 feeGrowthInside1X128) =
440+
ticks.getFeeGrowthInside(tickLower, tickUpper, tick, _feeGrowthGlobal0X128, _feeGrowthGlobal1X128);
448441

449442
position.update(liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128);
450443

@@ -469,14 +462,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
469462
bytes calldata data
470463
) external override lock returns (uint256 amount0, uint256 amount1) {
471464
require(amount > 0);
472-
(, int256 amount0Int, int256 amount1Int) = _modifyPosition(
473-
ModifyPositionParams({
474-
owner: recipient,
475-
tickLower: tickLower,
476-
tickUpper: tickUpper,
477-
liquidityDelta: int256(amount).toInt128()
478-
})
479-
);
465+
(, int256 amount0Int, int256 amount1Int) =
466+
_modifyPosition(
467+
ModifyPositionParams({
468+
owner: recipient,
469+
tickLower: tickLower,
470+
tickUpper: tickUpper,
471+
liquidityDelta: int256(amount).toInt128()
472+
})
473+
);
480474

481475
amount0 = uint256(amount0Int);
482476
amount1 = uint256(amount1Int);
@@ -525,14 +519,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
525519
int24 tickUpper,
526520
uint128 amount
527521
) external override lock returns (uint256 amount0, uint256 amount1) {
528-
(Position.Info storage position, int256 amount0Int, int256 amount1Int) = _modifyPosition(
529-
ModifyPositionParams({
530-
owner: msg.sender,
531-
tickLower: tickLower,
532-
tickUpper: tickUpper,
533-
liquidityDelta: -int256(amount).toInt128()
534-
})
535-
);
522+
(Position.Info storage position, int256 amount0Int, int256 amount1Int) =
523+
_modifyPosition(
524+
ModifyPositionParams({
525+
owner: msg.sender,
526+
tickLower: tickLower,
527+
tickUpper: tickUpper,
528+
liquidityDelta: -int256(amount).toInt128()
529+
})
530+
);
536531

537532
amount0 = uint256(-amount0Int);
538533
amount1 = uint256(-amount1Int);
@@ -619,26 +614,28 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
619614

620615
slot0.unlocked = false;
621616

622-
SwapCache memory cache = SwapCache({
623-
liquidityStart: liquidity,
624-
blockTimestamp: _blockTimestamp(),
625-
feeProtocol: zeroForOne ? (slot0Start.feeProtocol % 16) : (slot0Start.feeProtocol >> 4),
626-
secondsPerLiquidityCumulativeX128: 0,
627-
tickCumulative: 0,
628-
computedLatestObservation: false
629-
});
617+
SwapCache memory cache =
618+
SwapCache({
619+
liquidityStart: liquidity,
620+
blockTimestamp: _blockTimestamp(),
621+
feeProtocol: zeroForOne ? (slot0Start.feeProtocol % 16) : (slot0Start.feeProtocol >> 4),
622+
secondsPerLiquidityCumulativeX128: 0,
623+
tickCumulative: 0,
624+
computedLatestObservation: false
625+
});
630626

631627
bool exactInput = amountSpecified > 0;
632628

633-
SwapState memory state = SwapState({
634-
amountSpecifiedRemaining: amountSpecified,
635-
amountCalculated: 0,
636-
sqrtPriceX96: slot0Start.sqrtPriceX96,
637-
tick: slot0Start.tick,
638-
feeGrowthGlobalX128: zeroForOne ? feeGrowthGlobal0X128 : feeGrowthGlobal1X128,
639-
protocolFee: 0,
640-
liquidity: cache.liquidityStart
641-
});
629+
SwapState memory state =
630+
SwapState({
631+
amountSpecifiedRemaining: amountSpecified,
632+
amountCalculated: 0,
633+
sqrtPriceX96: slot0Start.sqrtPriceX96,
634+
tick: slot0Start.tick,
635+
feeGrowthGlobalX128: zeroForOne ? feeGrowthGlobal0X128 : feeGrowthGlobal1X128,
636+
protocolFee: 0,
637+
liquidity: cache.liquidityStart
638+
});
642639

643640
// continue swapping as long as we haven't used the entire input/output and haven't reached the price limit
644641
while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {
@@ -709,14 +706,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
709706
);
710707
cache.computedLatestObservation = true;
711708
}
712-
int128 liquidityNet = ticks.cross(
713-
step.tickNext,
714-
(zeroForOne ? state.feeGrowthGlobalX128 : feeGrowthGlobal0X128),
715-
(zeroForOne ? feeGrowthGlobal1X128 : state.feeGrowthGlobalX128),
716-
cache.secondsPerLiquidityCumulativeX128,
717-
cache.tickCumulative,
718-
cache.blockTimestamp
719-
);
709+
int128 liquidityNet =
710+
ticks.cross(
711+
step.tickNext,
712+
(zeroForOne ? state.feeGrowthGlobalX128 : feeGrowthGlobal0X128),
713+
(zeroForOne ? feeGrowthGlobal1X128 : state.feeGrowthGlobalX128),
714+
cache.secondsPerLiquidityCumulativeX128,
715+
cache.tickCumulative,
716+
cache.blockTimestamp
717+
);
720718
// if we're moving leftward, we interpret liquidityNet as the opposite sign
721719
// safe because liquidityNet cannot be type(int128).min
722720
if (zeroForOne) liquidityNet = -liquidityNet;
@@ -733,14 +731,15 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
733731

734732
// update tick and write an oracle entry if the tick change
735733
if (state.tick != slot0Start.tick) {
736-
(uint16 observationIndex, uint16 observationCardinality) = observations.write(
737-
slot0Start.observationIndex,
738-
cache.blockTimestamp,
739-
slot0Start.tick,
740-
cache.liquidityStart,
741-
slot0Start.observationCardinality,
742-
slot0Start.observationCardinalityNext
743-
);
734+
(uint16 observationIndex, uint16 observationCardinality) =
735+
observations.write(
736+
slot0Start.observationIndex,
737+
cache.blockTimestamp,
738+
slot0Start.tick,
739+
cache.liquidityStart,
740+
slot0Start.observationCardinality,
741+
slot0Start.observationCardinalityNext
742+
);
744743
(slot0.sqrtPriceX96, slot0.tick, slot0.observationIndex, slot0.observationCardinality) = (
745744
state.sqrtPriceX96,
746745
state.tick,

contracts/libraries/Oracle.sol

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,8 @@ library Oracle {
259259

260260
uint32 target = time - secondsAgo;
261261

262-
(Observation memory beforeOrAt, Observation memory atOrAfter) = getSurroundingObservations(
263-
self,
264-
time,
265-
target,
266-
tick,
267-
index,
268-
liquidity,
269-
cardinality
270-
);
262+
(Observation memory beforeOrAt, Observation memory atOrAfter) =
263+
getSurroundingObservations(self, time, target, tick, index, liquidity, cardinality);
271264

272265
if (target == beforeOrAt.blockTimestamp) {
273266
// we're at the left boundary

contracts/libraries/Position.sol

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,22 @@ library Position {
5858
}
5959

6060
// calculate accumulated fees
61-
uint128 tokensOwed0 = uint128(
62-
FullMath.mulDiv(feeGrowthInside0X128 - _self.feeGrowthInside0LastX128, _self.liquidity, FixedPoint128.Q128)
63-
);
64-
uint128 tokensOwed1 = uint128(
65-
FullMath.mulDiv(feeGrowthInside1X128 - _self.feeGrowthInside1LastX128, _self.liquidity, FixedPoint128.Q128)
66-
);
61+
uint128 tokensOwed0 =
62+
uint128(
63+
FullMath.mulDiv(
64+
feeGrowthInside0X128 - _self.feeGrowthInside0LastX128,
65+
_self.liquidity,
66+
FixedPoint128.Q128
67+
)
68+
);
69+
uint128 tokensOwed1 =
70+
uint128(
71+
FullMath.mulDiv(
72+
feeGrowthInside1X128 - _self.feeGrowthInside1LastX128,
73+
_self.liquidity,
74+
FixedPoint128.Q128
75+
)
76+
);
6777

6878
// update the position
6979
if (liquidityDelta != 0) self.liquidity = liquidityNext;

0 commit comments

Comments
 (0)