Skip to content

Commit

Permalink
utilize hook utility functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ewilz committed Nov 11, 2024
1 parent be3ab17 commit 36602ca
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sdks/v4-sdk/src/entities/pool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
} from '@uniswap/v3-sdk'
import { defaultAbiCoder, isAddress } from 'ethers/lib/utils'
import { sortsBefore } from '../utils/sortsBefore'
import { HookOptions, Hook } from '../utils/hook'
import { Hook } from '../utils/hook'
import { ADDRESS_ZERO, NEGATIVE_ONE, Q192 } from '../internalConstants'
import JSBI from 'jsbi'

Expand Down Expand Up @@ -300,7 +300,7 @@ export class Pool {
amountSpecified: JSBI,
sqrtPriceLimitX96?: JSBI
): Promise<{ amountCalculated: JSBI; sqrtRatioX96: JSBI; liquidity: JSBI; tickCurrent: number }> {
if (!this.hookHasSwapPermissions()) {
if (!this.hookImpactsSwap()) {
return v3Swap(
JSBI.BigInt(this.fee),
this.sqrtRatioX96,
Expand All @@ -317,9 +317,9 @@ export class Pool {
}
}

private hookHasSwapPermissions(): boolean {
return (
Hook.hasPermission(this.hooks, HookOptions.BeforeSwap) || Hook.hasPermission(this.hooks, HookOptions.AfterSwap)
)
private hookImpactsSwap(): boolean {
// could use this function to clear certain hooks that may have swap Permissions, but we know they don't interfere
// in the swap outcome
return Hook.hasSwapPermissions(this.hooks)
}
}

0 comments on commit 36602ca

Please sign in to comment.