Skip to content

Commit 05c10bf

Browse files
committed
Fix code style issues with Prettier
1 parent 412d9b2 commit 05c10bf

18 files changed

+239
-296
lines changed

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

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

383383
function test_mint(uint128 _amount) public {
384384
if (!inited) _init(_amount);
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);
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+
);
390397
storeUsedTicks(_tL, _tU);
391398

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

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

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -360,8 +360,11 @@ 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) =
364-
swapper.doSwap(true, _amountSpecified, sqrtPriceLimitX96);
363+
(UniswapSwapper.SwapperStats memory bfre, UniswapSwapper.SwapperStats memory aftr) = swapper.doSwap(
364+
true,
365+
_amountSpecified,
366+
sqrtPriceLimitX96
367+
);
365368

366369
check_swap_invariants(
367370
bfre.tick,
@@ -394,8 +397,11 @@ contract E2E_swap {
394397
uint160 sqrtPriceLimitX96 = get_random_oneForZero_priceLimit(_amount);
395398
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
396399

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

400406
check_swap_invariants(
401407
bfre.tick,
@@ -428,8 +434,11 @@ contract E2E_swap {
428434
uint160 sqrtPriceLimitX96 = get_random_zeroForOne_priceLimit(_amount);
429435
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
430436

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

434443
check_swap_invariants(
435444
bfre.tick,
@@ -462,8 +471,11 @@ contract E2E_swap {
462471
uint160 sqrtPriceLimitX96 = get_random_oneForZero_priceLimit(_amount);
463472
// console.log('sqrtPriceLimitX96 = %s', sqrtPriceLimitX96);
464473

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

468480
check_swap_invariants(
469481
bfre.tick,

contracts/UniswapV3Pool.sol

Lines changed: 82 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ 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) =
142-
token0.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
141+
(bool success, bytes memory data) = token0.staticcall(
142+
abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this))
143+
);
143144
require(success && data.length >= 32);
144145
return abi.decode(data, (uint256));
145146
}
@@ -148,8 +149,9 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
148149
/// @dev This function is gas optimized to avoid a redundant extcodesize check in addition to the returndatasize
149150
/// check
150151
function balance1() private view returns (uint256) {
151-
(bool success, bytes memory data) =
152-
token1.staticcall(abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this)));
152+
(bool success, bytes memory data) = token1.staticcall(
153+
abi.encodeWithSelector(IERC20Minimal.balanceOf.selector, address(this))
154+
);
153155
require(success && data.length >= 32);
154156
return abi.decode(data, (uint256));
155157
}
@@ -207,15 +209,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
207209
);
208210
} else if (_slot0.tick < tickUpper) {
209211
uint32 time = _blockTimestamp();
210-
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
211-
observations.observeSingle(
212-
time,
213-
0,
214-
_slot0.tick,
215-
_slot0.observationIndex,
216-
liquidity,
217-
_slot0.observationCardinality
218-
);
212+
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) = observations.observeSingle(
213+
time,
214+
0,
215+
_slot0.tick,
216+
_slot0.observationIndex,
217+
liquidity,
218+
_slot0.observationCardinality
219+
);
219220
return (
220221
tickCumulative - tickCumulativeLower - tickCumulativeUpper,
221222
secondsPerLiquidityCumulativeX128 -
@@ -259,8 +260,10 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
259260
noDelegateCall
260261
{
261262
uint16 observationCardinalityNextOld = slot0.observationCardinalityNext; // for the event
262-
uint16 observationCardinalityNextNew =
263-
observations.grow(observationCardinalityNextOld, observationCardinalityNext);
263+
uint16 observationCardinalityNextNew = observations.grow(
264+
observationCardinalityNextOld,
265+
observationCardinalityNext
266+
);
264267
slot0.observationCardinalityNext = observationCardinalityNextNew;
265268
if (observationCardinalityNextOld != observationCardinalityNextNew)
266269
emit IncreaseObservationCardinalityNext(observationCardinalityNextOld, observationCardinalityNextNew);
@@ -393,15 +396,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
393396
bool flippedUpper;
394397
if (liquidityDelta != 0) {
395398
uint32 time = _blockTimestamp();
396-
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) =
397-
observations.observeSingle(
398-
time,
399-
0,
400-
slot0.tick,
401-
slot0.observationIndex,
402-
liquidity,
403-
slot0.observationCardinality
404-
);
399+
(int56 tickCumulative, uint160 secondsPerLiquidityCumulativeX128) = observations.observeSingle(
400+
time,
401+
0,
402+
slot0.tick,
403+
slot0.observationIndex,
404+
liquidity,
405+
slot0.observationCardinality
406+
);
405407

406408
flippedLower = ticks.update(
407409
tickLower,
@@ -436,8 +438,13 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
436438
}
437439
}
438440

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

442449
position.update(liquidityDelta, feeGrowthInside0X128, feeGrowthInside1X128);
443450

@@ -462,15 +469,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
462469
bytes calldata data
463470
) external override lock returns (uint256 amount0, uint256 amount1) {
464471
require(amount > 0);
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-
);
472+
(, int256 amount0Int, int256 amount1Int) = _modifyPosition(
473+
ModifyPositionParams({
474+
owner: recipient,
475+
tickLower: tickLower,
476+
tickUpper: tickUpper,
477+
liquidityDelta: int256(amount).toInt128()
478+
})
479+
);
474480

475481
amount0 = uint256(amount0Int);
476482
amount1 = uint256(amount1Int);
@@ -519,15 +525,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
519525
int24 tickUpper,
520526
uint128 amount
521527
) external override lock returns (uint256 amount0, uint256 amount1) {
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-
);
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+
);
531536

532537
amount0 = uint256(-amount0Int);
533538
amount1 = uint256(-amount1Int);
@@ -614,28 +619,26 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
614619

615620
slot0.unlocked = false;
616621

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-
});
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+
});
626630

627631
bool exactInput = amountSpecified > 0;
628632

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-
});
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+
});
639642

640643
// continue swapping as long as we haven't used the entire input/output and haven't reached the price limit
641644
while (state.amountSpecifiedRemaining != 0 && state.sqrtPriceX96 != sqrtPriceLimitX96) {
@@ -706,15 +709,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
706709
);
707710
cache.computedLatestObservation = true;
708711
}
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-
);
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+
);
718720
// if we're moving leftward, we interpret liquidityNet as the opposite sign
719721
// safe because liquidityNet cannot be type(int128).min
720722
if (zeroForOne) liquidityNet = -liquidityNet;
@@ -731,15 +733,14 @@ contract UniswapV3Pool is IUniswapV3Pool, NoDelegateCall {
731733

732734
// update tick and write an oracle entry if the tick change
733735
if (state.tick != slot0Start.tick) {
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-
);
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+
);
743744
(slot0.sqrtPriceX96, slot0.tick, slot0.observationIndex, slot0.observationCardinality) = (
744745
state.sqrtPriceX96,
745746
state.tick,

contracts/libraries/Oracle.sol

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

260260
uint32 target = time - secondsAgo;
261261

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

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

contracts/libraries/Position.sol

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

6060
// calculate accumulated fees
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-
);
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+
);
7767

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

0 commit comments

Comments
 (0)