Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
chore: rename permit2 helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
agualis committed Sep 19, 2024
1 parent 3321c77 commit a5b77e7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import { useMemo } from 'react'
import { usePool } from '../../PoolProvider'
import { LiquidityActionHelpers } from '../LiquidityActionHelpers'
import { AddLiquidityStepParams, useAddLiquidityStep } from './useAddLiquidityStep'
import { isV3Pool } from '../../pool.helpers'
import { requiresPermit2Approval } from '../../pool.helpers'
import { useSignRelayerStep } from '@/lib/modules/transactions/transaction-steps/useSignRelayerStep'
import { getTokenSpenderAddress } from '@/lib/modules/tokens/token.helpers'
import { getSpenderForAddLiquidity } from '@/lib/modules/tokens/token.helpers'

type AddLiquidityStepsParams = AddLiquidityStepParams & {
helpers: LiquidityActionHelpers
Expand All @@ -35,11 +35,11 @@ export function useAddLiquiditySteps({

const { isLoading: isLoadingTokenApprovalSteps, steps: tokenApprovalSteps } =
useTokenApprovalSteps({
spenderAddress: getTokenSpenderAddress(pool),
spenderAddress: getSpenderForAddLiquidity(pool),
chain: pool.chain,
approvalAmounts: inputAmounts,
actionType: 'AddLiquidity',
isPermit2: isV3Pool(pool),
isPermit2: requiresPermit2Approval(pool),
})

const addLiquidityStep = useAddLiquidityStep({
Expand Down
4 changes: 4 additions & 0 deletions lib/modules/pool/pool.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,10 @@ export function isV3Pool(pool: Pool): boolean {
return pool.protocolVersion === 3
}

export function requiresPermit2Approval(pool: Pool): boolean {
return isV3Pool(pool)
}

export function getRateProviderWarnings(warnings: string[]) {
return warnings.filter(warning => !isEmpty(warning))
}
2 changes: 1 addition & 1 deletion lib/modules/tokens/token.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export function getLeafTokens(poolTokens: PoolToken[]) {
return leafTokens
}

export function getTokenSpenderAddress(pool: Pool): Address {
export function getSpenderForAddLiquidity(pool: Pool): Address {
if (isCowAmmPool(pool.type)) return pool.address as Address
if (isV3Pool(pool)) {
const permit2Address = getNetworkConfig(pool.chain).contracts.permit2
Expand Down

0 comments on commit a5b77e7

Please sign in to comment.