Skip to content

Commit

Permalink
chore: resolve issues per comments
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Oct 14, 2024
1 parent 8ca2365 commit 6b6a2e8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/interfaces/IQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ pragma solidity ^0.8.24;
import {Currency} from "pancake-v4-core/src/types/Currency.sol";
import {PathKey} from "../libraries/PathKey.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";

/// @title IQuoter Interface
/// @notice Supports quoting the delta amounts from exact input or exact output swaps.
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface IQuoter {
error NotEnoughLiquidity(PoolId poolId);
error NotSelf();
error UnexpectedCallSuccess();

Expand Down
13 changes: 7 additions & 6 deletions src/pool-bin/lens/BinQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,12 @@ contract BinQuoter is BaseV4Quoter, IBinQuoter {
{
deltas = poolManager.swap(poolKey, zeroForOne, amountSpecified, hookData);

// TODO: confirm we don't need this check in the bin quoter since BinPool will revert if there is not enough liquidity
// Check that the pool was not illiquid.
// int128 amountSpecifiedActual = (zeroForOne == (amountSpecified < 0)) ? deltas.amount0() : deltas.amount1();
// if (amountSpecifiedActual != amountSpecified) {
// revert NotEnoughLiquidity(poolKey.toId());
// }
/// @dev Check that the pool was not illiquid
/// even BinPool will emit BinPool__OutOfLiquidity when the pool is illiquid
/// We still need to apply the check in case hook contract manipulates the delta
int128 amountSpecifiedActual = (zeroForOne == (amountSpecified < 0)) ? deltas.amount0() : deltas.amount1();
if (amountSpecifiedActual != amountSpecified) {
revert NotEnoughLiquidity(poolKey.toId());
}
}
}
3 changes: 0 additions & 3 deletions src/pool-cl/interfaces/ICLQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@
pragma solidity ^0.8.24;

import {IQuoter} from "../../interfaces/IQuoter.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";

/// @title ICLQuoter Interface
/// @notice Supports quoting the delta amounts for exact input or exact output swaps.
/// @notice For each pool also tells you the estimation of gas cost for the swap.
/// @dev These functions are not marked view because they rely on calling non-view functions and reverting
/// to compute the result. They are also not gas efficient and should not be called on-chain.
interface ICLQuoter is IQuoter {
error NotEnoughLiquidity(PoolId poolId);

/// @notice Returns the delta amounts for a given exact input swap of a single pool
/// @param params The params for the quote, encoded as `QuoteExactSingleParams`
/// poolKey The key for identifying a V4 pool
Expand Down
2 changes: 1 addition & 1 deletion test/pool-cl/CLQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ contract CLQuoterTest is Test, Deployers {
vm.expectRevert(
abi.encodeWithSelector(
QuoterRevert.UnexpectedRevertBytes.selector,
abi.encodeWithSelector(ICLQuoter.NotEnoughLiquidity.selector, key01.toId())
abi.encodeWithSelector(IQuoter.NotEnoughLiquidity.selector, key01.toId())
)
);
quoter.quoteExactOutputSingle(
Expand Down

0 comments on commit 6b6a2e8

Please sign in to comment.