Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add swap fee manager #224

Merged
merged 5 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { zeroAddress } from 'viem'
import { abbreviateAddress } from '@repo/lib/shared/utils/addresses'
import { fNum } from '@repo/lib/shared/utils/numbers'
import { isBoosted, isCowAmmPool, isStable } from '../../../pool.helpers'
import { isBoosted, isCowAmmPool, isStable, isV2Pool, isV3Pool } from '../../../pool.helpers'
import { useCurrency } from '@repo/lib/shared/hooks/useCurrency'
import { getPoolTypeLabel, shouldHideSwapFee } from '../../../pool.utils'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'
Expand All @@ -18,13 +18,15 @@
const { usdValueForBpt } = useTokens()

const { delegateOwner } = getProjectConfig()
const isV2 = isV2Pool(pool)
const isV3 = isV3Pool(pool)

const poolOwnerData = useMemo(() => {
if (!pool) return
const { owner } = pool
const { owner, swapFeeManager } = pool
if (!owner) return

if (owner === zeroAddress || isCowAmmPool(pool.type)) {
if ((owner === zeroAddress && isV2) || isCowAmmPool(pool.type)) {
return {
title: 'No owner',
link: '',
Expand All @@ -33,9 +35,9 @@
}
}

if (owner === delegateOwner) {
if (owner === delegateOwner || (owner === zeroAddress && isV3)) {
return {
title: 'Delegate owner',
title: `Delegate ${isV2 ? 'owner' : 'manager'}`,
link: '',
editableText: 'editable by governance',
attributeImmutabilityText: isStable(pool.type)
Expand All @@ -44,15 +46,17 @@
}
}

const editableBy = `editable by ${isV2 ? 'pool owner' : 'swap fee manager'}`

return {
title: abbreviateAddress(owner || ''),
title: abbreviateAddress((isV2 ? owner : swapFeeManager) || ''),
link: '',
editableText: 'editable by pool owner',
editableText: editableBy,
attributeImmutabilityText: isStable(pool.type)
? ' except for swap fees and AMP factor editable by the pool owner'
: ' except for swap fees editable by the pool owner',
? ` except for swap fees and AMP factor ${editableBy}`
: ` except for swap fees ${editableBy}`,
}
}, [pool])

Check warning on line 59 in packages/lib/modules/pool/PoolDetail/PoolInfo/PoolAttributes/useFormattedPoolAttributes.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useMemo has missing dependencies: 'delegateOwner', 'isV2', and 'isV3'. Either include them or remove the dependency array

const formattedPoolAttributes = useMemo(() => {
if (!pool) return []
Expand Down Expand Up @@ -87,7 +91,7 @@
: null,
poolOwnerData
? {
title: 'Pool Owner',
title: isV2 ? 'Pool owner' : 'Swap fee manager',
value: poolOwnerData.title,
}
: null,
Expand Down
2 changes: 1 addition & 1 deletion packages/lib/modules/pool/pool.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export function hasHooks(pool: Pool): boolean {
.filter(token => token.hasNestedPool)
.map(token => token.nestedPool?.hook)

return !![pool.hook, ...nestedHooks].length
return !![pool.hook, ...nestedHooks].filter(Boolean).length
}

/**
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/shared/services/api/pool.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ query GetPool($id: String!, $chain: GqlChain!, $userAddress: String) {
name
version
owner
swapFeeManager
pauseManager
poolCreator
decimals
factory
symbol
Expand Down
3 changes: 3 additions & 0 deletions packages/lib/shared/services/api/pools.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ query GetPools(
id
name
owner
swapFeeManager
pauseManager
poolCreator
symbol
type
userBalance {
Expand Down
Loading