Skip to content

Commit

Permalink
style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ConjunctiveNormalForm committed Nov 17, 2023
1 parent ca62ec2 commit c5b8c22
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 11 additions & 11 deletions contracts/lens/Quoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ contract Quoter is IQuoter {
using Hooks for IHooks;

// v4 Singleton contract
IPoolManager private immutable MANAGER;
IPoolManager public immutable manager;

constructor(address _poolManager) {
MANAGER = IPoolManager(_poolManager);
manager = IPoolManager(_poolManager);
}

function quoteExactInputSingle(ExactInputSingleParams memory params)
external
override
returns (int128[] memory deltaAmounts, uint160 sqrtPriceX96After, uint32 initializedTicksLoaded)
{
try MANAGER.lock(abi.encode(SwapInfo(SwapType.ExactInputSingle, abi.encode(params)))) {}
try manager.lock(abi.encode(SwapInfo(SwapType.ExactInputSingle, abi.encode(params)))) {}
catch (bytes memory reason) {
return _handleRevertExactInputSingle(reason, params.poolKey);
}
Expand All @@ -43,14 +43,14 @@ contract Quoter is IQuoter {
uint32[] memory initializedTicksLoadedList
)
{
try MANAGER.lock(abi.encode(SwapInfo(SwapType.ExactInput, abi.encode(params)))) {}
try manager.lock(abi.encode(SwapInfo(SwapType.ExactInput, abi.encode(params)))) {}
catch (bytes memory reason) {
return _handleRevertExactInput(reason);
}
}

function lockAcquired(bytes calldata encodedSwapIntention) external returns (bytes memory) {
if (msg.sender != address(MANAGER)) {
if (msg.sender != address(manager)) {
revert InvalidLockAcquiredSender();
}

Expand Down Expand Up @@ -103,13 +103,13 @@ contract Quoter is IQuoter {
int24 tickAfter;
BalanceDelta deltas;
deltaAmounts = new int128[](2);
(, tickBefore,,) = MANAGER.getSlot0(poolKey.toId());
(, tickBefore,,) = manager.getSlot0(poolKey.toId());
reason = validateRevertReason(reason);
(deltas, sqrtPriceX96After, tickAfter) = abi.decode(reason, (BalanceDelta, uint160, int24));
deltaAmounts[0] = deltas.amount0();
deltaAmounts[1] = deltas.amount1();

initializedTicksLoaded = PoolTicksCounter.countInitializedTicksLoaded(MANAGER, poolKey, tickBefore, tickAfter);
initializedTicksLoaded = PoolTicksCounter.countInitializedTicksLoaded(manager, poolKey, tickBefore, tickAfter);
}

function _handleRevertExactInput(bytes memory reason)
Expand Down Expand Up @@ -145,7 +145,7 @@ contract Quoter is IQuoter {
for (uint256 i = 0; i < pathLength; i++) {
(PoolKey memory poolKey, bool zeroForOne) =
SwapIntention.getPoolAndSwapDirection(params.path[i], i == 0 ? params.currencyIn : prevCurrencyOut);
(, int24 tickBefore,,) = MANAGER.getSlot0(poolKey.toId());
(, int24 tickBefore,,) = manager.getSlot0(poolKey.toId());

ExactInputSingleParams memory singleParams = ExactInputSingleParams({
poolKey: poolKey,
Expand All @@ -166,7 +166,7 @@ contract Quoter is IQuoter {
prevCurrencyOut = params.path[i].intermediateCurrency;
sqrtPriceX96AfterList[i] = sqrtPriceX96After;
initializedTicksLoadedList[i] =
PoolTicksCounter.countInitializedTicksLoaded(MANAGER, poolKey, tickBefore, tickAfter);
PoolTicksCounter.countInitializedTicksLoaded(manager, poolKey, tickBefore, tickAfter);
}
}

Expand All @@ -190,7 +190,7 @@ contract Quoter is IQuoter {
uint160 sqrtPriceLimitX96,
bytes memory hookData
) private returns (BalanceDelta deltas, uint160 sqrtPriceX96After, int24 tickAfter) {
deltas = MANAGER.swap(
deltas = manager.swap(
poolKey,
IPoolManager.SwapParams({
zeroForOne: zeroForOne,
Expand All @@ -199,7 +199,7 @@ contract Quoter is IQuoter {
}),
hookData
);
(sqrtPriceX96After, tickAfter,,) = MANAGER.getSlot0(poolKey.toId());
(sqrtPriceX96After, tickAfter,,) = manager.getSlot0(poolKey.toId());
}

function _sqrtPriceLimitOrDefault(uint160 sqrtPriceLimitX96, bool zeroForOne) private pure returns (uint160) {
Expand Down
4 changes: 3 additions & 1 deletion test/Quoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ contract QuoterTest is Test, Deployers {
// Max tick for full range with tick spacing of 60
int24 internal constant MAX_TICK = -MIN_TICK;

uint256 internal constant CONTROLLER_GAS_LIMIT = 500000;

Quoter quoter;

PoolManager manager;
Expand All @@ -45,7 +47,7 @@ contract QuoterTest is Test, Deployers {
MockERC20[] tokenPath;

function setUp() public {
manager = new PoolManager(500000);
manager = new PoolManager(CONTROLLER_GAS_LIMIT);
quoter = new Quoter(address(manager));
positionManager = new PoolModifyPositionTest(manager);

Expand Down

0 comments on commit c5b8c22

Please sign in to comment.