diff --git a/.changeset/lovely-radios-cry.md b/.changeset/lovely-radios-cry.md new file mode 100644 index 000000000..b4c3185b6 --- /dev/null +++ b/.changeset/lovely-radios-cry.md @@ -0,0 +1,5 @@ +--- +'backend': patch +--- + +Adding V3 pool roles to the db model diff --git a/graphql_schema_generated.ts b/graphql_schema_generated.ts index 65c082e6f..dfe1c5460 100644 --- a/graphql_schema_generated.ts +++ b/graphql_schema_generated.ts @@ -1488,7 +1488,17 @@ export const schema = gql` """ The wallet address of the owner of the pool. Pool owners can set certain properties like swapFees or AMP. """ - owner: Bytes + owner: Bytes @deprecated(reason: "Use swapFeeManager instead") + + """ + Account empowered to pause/unpause the pool (or 0 to delegate to governance) + """ + pauseManager: Bytes + + """ + Account empowered to set the pool creator fee percentage + """ + poolCreator: Bytes """ Returns all pool tokens, including BPTs and nested pools if there are any. Only one nested level deep. @@ -1505,6 +1515,11 @@ export const schema = gql` """ staking: GqlPoolStaking + """ + Account empowered to set static swap fees for a pool (when 0 on V2 swap fees are immutable, on V3 delegate to governance) + """ + swapFeeManager: Bytes + """ The token symbol of the pool as per contract """ diff --git a/modules/pool/lib/pool-gql-loader.service.ts b/modules/pool/lib/pool-gql-loader.service.ts index 09da49383..5451a4cf8 100644 --- a/modules/pool/lib/pool-gql-loader.service.ts +++ b/modules/pool/lib/pool-gql-loader.service.ts @@ -697,6 +697,7 @@ export class PoolGqlLoaderService { const mappedData = { decimals: 18, + owner: pool.swapFeeManager, // Keep for backwards compatibility staking: this.getStakingData(pool), dynamicData: this.getPoolDynamicData(pool), investConfig: this.getPoolInvestConfig(pool), // TODO DEPRECATE @@ -868,6 +869,7 @@ export class PoolGqlLoaderService { return { ...nestedPool, + owner: nestedPool.swapFeeManager, // Keep for backwards compatibility liquidityManagement: (nestedPool.liquidityManagement as LiquidityManagement) || undefined, totalLiquidity: `${totalLiquidity}`, totalShares: `${totalShares}`, @@ -1454,6 +1456,7 @@ export class PoolGqlLoaderService { __typename: 'GqlPoolComposableStableNested', ...pool, ...(pool.typeData as StableData)!, + owner: pool.swapFeeManager, // Keep for backwards compatibility nestingType: this.getPoolNestingType(pool), tokens: pool.tokens.map((token) => this.mapPoolTokenToGql(token)), totalLiquidity: `${pool.dynamicData?.totalLiquidity || 0}`, diff --git a/modules/pool/pool.gql b/modules/pool/pool.gql index 1db24bd28..9e99b9b80 100644 --- a/modules/pool/pool.gql +++ b/modules/pool/pool.gql @@ -165,7 +165,19 @@ type GqlPoolMinimal { """ The wallet address of the owner of the pool. Pool owners can set certain properties like swapFees or AMP. """ - owner: Bytes + owner: Bytes @deprecated(reason: "Use swapFeeManager instead") + """ + Account empowered to set static swap fees for a pool (when 0 on V2 swap fees are immutable, on V3 delegate to governance) + """ + swapFeeManager: Bytes + """ + Account empowered to pause/unpause the pool (or 0 to delegate to governance) + """ + pauseManager: Bytes + """ + Account empowered to set the pool creator fee percentage + """ + poolCreator: Bytes """ The factory contract address from which the pool was created. """ diff --git a/modules/pool/subgraph-mapper.ts b/modules/pool/subgraph-mapper.ts index b63a7e9e5..c8e0f7e08 100644 --- a/modules/pool/subgraph-mapper.ts +++ b/modules/pool/subgraph-mapper.ts @@ -81,7 +81,7 @@ const subgraphMapper = ( decimals: 18, type: type, version: version, - owner: pool.owner || AddressZero, + swapFeeManager: pool.owner || AddressZero, factory: pool.factory, }; diff --git a/modules/sources/subgraphs/balancer-v3-vault/generated/types.ts b/modules/sources/subgraphs/balancer-v3-vault/generated/types.ts index 0e24e3c99..703c461fa 100644 --- a/modules/sources/subgraphs/balancer-v3-vault/generated/types.ts +++ b/modules/sources/subgraphs/balancer-v3-vault/generated/types.ts @@ -174,11 +174,13 @@ export enum AddRemove_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -578,11 +580,13 @@ export enum HookConfig_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -724,11 +728,13 @@ export enum LiquidityManagement_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -765,10 +771,12 @@ export type Pool = { liquidityManagement: LiquidityManagement; /** Name of the Pool */ name: Scalars['String']; - /** Address of the pause manager for this Pool */ + /** Account empowered to pause/unpause the pool */ pauseManager: Scalars['Bytes']; /** Timestamp when the pause window ends */ pauseWindowEndTime: Scalars['BigInt']; + /** Account empowered to set the pool creator fee percentage */ + poolCreator: Scalars['Bytes']; /** Pool creator swap fee percentage */ poolCreatorSwapFee: Scalars['BigDecimal']; /** Pool creator yield fee percentage */ @@ -783,6 +791,8 @@ export type Pool = { snapshots: Array; /** Swap fee percentage for this Pool */ swapFee: Scalars['BigDecimal']; + /** Account empowered to set static swap fees for a pool */ + swapFeeManager: Scalars['Bytes']; /** Total number of swaps performed in this Pool */ swapsCount: Scalars['BigInt']; /** Symbol of the Pool */ @@ -912,11 +922,13 @@ export enum PoolShare_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -1064,11 +1076,13 @@ export enum PoolSnapshot_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -1339,11 +1353,13 @@ export enum PoolToken_OrderBy { NestedPoolName = 'nestedPool__name', NestedPoolPauseManager = 'nestedPool__pauseManager', NestedPoolPauseWindowEndTime = 'nestedPool__pauseWindowEndTime', + NestedPoolPoolCreator = 'nestedPool__poolCreator', NestedPoolPoolCreatorSwapFee = 'nestedPool__poolCreatorSwapFee', NestedPoolPoolCreatorYieldFee = 'nestedPool__poolCreatorYieldFee', NestedPoolProtocolSwapFee = 'nestedPool__protocolSwapFee', NestedPoolProtocolYieldFee = 'nestedPool__protocolYieldFee', NestedPoolSwapFee = 'nestedPool__swapFee', + NestedPoolSwapFeeManager = 'nestedPool__swapFeeManager', NestedPoolSwapsCount = 'nestedPool__swapsCount', NestedPoolSymbol = 'nestedPool__symbol', NestedPoolTotalShares = 'nestedPool__totalShares', @@ -1360,11 +1376,13 @@ export enum PoolToken_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -1541,6 +1559,7 @@ export type Pool_Filter = { pauseWindowEndTime_lte?: InputMaybe; pauseWindowEndTime_not?: InputMaybe; pauseWindowEndTime_not_in?: InputMaybe>; + poolCreator?: InputMaybe; poolCreatorSwapFee?: InputMaybe; poolCreatorSwapFee_gt?: InputMaybe; poolCreatorSwapFee_gte?: InputMaybe; @@ -1557,6 +1576,15 @@ export type Pool_Filter = { poolCreatorYieldFee_lte?: InputMaybe; poolCreatorYieldFee_not?: InputMaybe; poolCreatorYieldFee_not_in?: InputMaybe>; + poolCreator_contains?: InputMaybe; + poolCreator_gt?: InputMaybe; + poolCreator_gte?: InputMaybe; + poolCreator_in?: InputMaybe>; + poolCreator_lt?: InputMaybe; + poolCreator_lte?: InputMaybe; + poolCreator_not?: InputMaybe; + poolCreator_not_contains?: InputMaybe; + poolCreator_not_in?: InputMaybe>; protocolSwapFee?: InputMaybe; protocolSwapFee_gt?: InputMaybe; protocolSwapFee_gte?: InputMaybe; @@ -1576,6 +1604,16 @@ export type Pool_Filter = { rateProviders_?: InputMaybe; snapshots_?: InputMaybe; swapFee?: InputMaybe; + swapFeeManager?: InputMaybe; + swapFeeManager_contains?: InputMaybe; + swapFeeManager_gt?: InputMaybe; + swapFeeManager_gte?: InputMaybe; + swapFeeManager_in?: InputMaybe>; + swapFeeManager_lt?: InputMaybe; + swapFeeManager_lte?: InputMaybe; + swapFeeManager_not?: InputMaybe; + swapFeeManager_not_contains?: InputMaybe; + swapFeeManager_not_in?: InputMaybe>; swapFee_gt?: InputMaybe; swapFee_gte?: InputMaybe; swapFee_in?: InputMaybe>; @@ -1685,6 +1723,7 @@ export enum Pool_OrderBy { Name = 'name', PauseManager = 'pauseManager', PauseWindowEndTime = 'pauseWindowEndTime', + PoolCreator = 'poolCreator', PoolCreatorSwapFee = 'poolCreatorSwapFee', PoolCreatorYieldFee = 'poolCreatorYieldFee', ProtocolSwapFee = 'protocolSwapFee', @@ -1692,6 +1731,7 @@ export enum Pool_OrderBy { RateProviders = 'rateProviders', Snapshots = 'snapshots', SwapFee = 'swapFee', + SwapFeeManager = 'swapFeeManager', SwapsCount = 'swapsCount', Symbol = 'symbol', Tokens = 'tokens', @@ -2081,11 +2121,13 @@ export enum RateProvider_OrderBy { PoolName = 'pool__name', PoolPauseManager = 'pool__pauseManager', PoolPauseWindowEndTime = 'pool__pauseWindowEndTime', + PoolPoolCreator = 'pool__poolCreator', PoolPoolCreatorSwapFee = 'pool__poolCreatorSwapFee', PoolPoolCreatorYieldFee = 'pool__poolCreatorYieldFee', PoolProtocolSwapFee = 'pool__protocolSwapFee', PoolProtocolYieldFee = 'pool__protocolYieldFee', PoolSwapFee = 'pool__swapFee', + PoolSwapFeeManager = 'pool__swapFeeManager', PoolSwapsCount = 'pool__swapsCount', PoolSymbol = 'pool__symbol', PoolTotalShares = 'pool__totalShares', @@ -3073,6 +3115,8 @@ export type VaultPoolFragment = { totalShares: string; pauseWindowEndTime: string; pauseManager: string; + swapFeeManager: string; + poolCreator: string; blockNumber: string; blockTimestamp: string; holdersCount: string; @@ -3151,6 +3195,8 @@ export type PoolsQuery = { totalShares: string; pauseWindowEndTime: string; pauseManager: string; + swapFeeManager: string; + poolCreator: string; blockNumber: string; blockTimestamp: string; holdersCount: string; @@ -3396,6 +3442,8 @@ export const VaultPoolFragmentDoc = gql` totalShares pauseWindowEndTime pauseManager + swapFeeManager + poolCreator blockNumber blockTimestamp holdersCount diff --git a/modules/sources/subgraphs/balancer-v3-vault/pools.graphql b/modules/sources/subgraphs/balancer-v3-vault/pools.graphql index 60a114aad..46bf7b6f4 100644 --- a/modules/sources/subgraphs/balancer-v3-vault/pools.graphql +++ b/modules/sources/subgraphs/balancer-v3-vault/pools.graphql @@ -6,6 +6,8 @@ fragment VaultPool on Pool { totalShares pauseWindowEndTime pauseManager + swapFeeManager + poolCreator blockNumber blockTimestamp holdersCount diff --git a/modules/sources/transformers/pool-upsert-transformer-cow-amm.ts b/modules/sources/transformers/pool-upsert-transformer-cow-amm.ts index aa43a2e13..516e88f6f 100644 --- a/modules/sources/transformers/pool-upsert-transformer-cow-amm.ts +++ b/modules/sources/transformers/pool-upsert-transformer-cow-amm.ts @@ -17,7 +17,7 @@ export const poolUpsertTransformerCowAmm = ( decimals: 18, symbol: poolFragment.symbol, name: poolFragment.name, - owner: zeroAddress, //TODO + swapFeeManager: zeroAddress, // TODO factory: poolFragment.factory.id.toLowerCase(), type: 'COW_AMM', typeData: {}, diff --git a/modules/sources/transformers/pool-upsert-transformer-v3.ts b/modules/sources/transformers/pool-upsert-transformer-v3.ts index 9dad47eac..91dcaf416 100644 --- a/modules/sources/transformers/pool-upsert-transformer-v3.ts +++ b/modules/sources/transformers/pool-upsert-transformer-v3.ts @@ -50,7 +50,9 @@ export const poolUpsertTransformerV3 = ( decimals: 18, symbol: poolData.symbol, name: poolData.name, - owner: zeroAddress, //TODO + swapFeeManager: poolData.swapFeeManager, + pauseManager: poolData.pauseManager, + poolCreator: poolData.poolCreator, factory: poolData.factory.id.toLowerCase(), type: type, typeData: typeData, diff --git a/modules/tests-helper/poolTestdataHelpers.ts b/modules/tests-helper/poolTestdataHelpers.ts index 2f029fa28..3817dfef9 100644 --- a/modules/tests-helper/poolTestdataHelpers.ts +++ b/modules/tests-helper/poolTestdataHelpers.ts @@ -90,7 +90,7 @@ const defaultWeightedPool: Prisma.PrismaPoolCreateInput = { name: 'A Late Quartet', decimals: 18, type: PrismaPoolType.WEIGHTED, - owner: '0x0000000000000000000000000000000000000000', + swapFeeManager: '0x0000000000000000000000000000000000000000', factory: '0x92b377187bccc6556fced2f1e6dad65850c20630', tokens: {}, dynamicData: { diff --git a/prisma/migrations/20241127185045_pool_roles/migration.sql b/prisma/migrations/20241127185045_pool_roles/migration.sql new file mode 100644 index 000000000..5e262b128 --- /dev/null +++ b/prisma/migrations/20241127185045_pool_roles/migration.sql @@ -0,0 +1,19 @@ +/* + Warnings: + + - You are about to drop the column `owner` on the `PrismaPool` table. All the data in the column will be lost. + - Added the required column `pauseManager` to the `PrismaPool` table without a default value. This is not possible if the table is not empty. + - Added the required column `poolCreator` to the `PrismaPool` table without a default value. This is not possible if the table is not empty. + - Added the required column `swapFeeManager` to the `PrismaPool` table without a default value. This is not possible if the table is not empty. + + */ +-- AlterTable +ALTER TABLE + "PrismaPool" RENAME COLUMN "owner" TO "swapFeeManager"; + +ALTER TABLE + "PrismaPool" +ADD + COLUMN "pauseManager" TEXT, +ADD + COLUMN "poolCreator" TEXT; \ No newline at end of file diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 92a681ae0..35b616d52 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -68,7 +68,9 @@ model PrismaPool { type PrismaPoolType version Int @default(1) decimals Int @default(18) - owner String + pauseManager String? + swapFeeManager String + poolCreator String? factory String? protocolVersion Int @default(2) diff --git a/prisma/schema/pool.prisma b/prisma/schema/pool.prisma index dcf9a46a8..86bb5d89a 100644 --- a/prisma/schema/pool.prisma +++ b/prisma/schema/pool.prisma @@ -12,7 +12,9 @@ model PrismaPool { type PrismaPoolType version Int @default(1) decimals Int @default(18) - owner String + pauseManager String? + swapFeeManager String + poolCreator String? factory String? protocolVersion Int @default(2) diff --git a/schema.ts b/schema.ts index b86ab1683..a11e8bf67 100644 --- a/schema.ts +++ b/schema.ts @@ -1067,14 +1067,23 @@ export interface GqlPoolMinimal { liquidityManagement?: Maybe; /** The name of the pool as per contract */ name: Scalars['String']; - /** The wallet address of the owner of the pool. Pool owners can set certain properties like swapFees or AMP. */ + /** + * The wallet address of the owner of the pool. Pool owners can set certain properties like swapFees or AMP. + * @deprecated Use swapFeeManager instead + */ owner?: Maybe; + /** Account empowered to pause/unpause the pool (or 0 to delegate to governance) */ + pauseManager?: Maybe; + /** Account empowered to set the pool creator fee percentage */ + poolCreator?: Maybe; /** Returns all pool tokens, including BPTs and nested pools if there are any. Only one nested level deep. */ poolTokens: Array; /** The protocol version on which the pool is deployed, 1, 2 or 3 */ protocolVersion: Scalars['Int']; /** Staking options of this pool which emit additional rewards */ staking?: Maybe; + /** Account empowered to set static swap fees for a pool (when 0 on V2 swap fees are immutable, on V3 delegate to governance) */ + swapFeeManager?: Maybe; /** The token symbol of the pool as per contract */ symbol: Scalars['String']; /** List of tags assigned by the team based on external factors */ @@ -3960,9 +3969,12 @@ export type GqlPoolMinimalResolvers< liquidityManagement?: Resolver, ParentType, ContextType>; name?: Resolver; owner?: Resolver, ParentType, ContextType>; + pauseManager?: Resolver, ParentType, ContextType>; + poolCreator?: Resolver, ParentType, ContextType>; poolTokens?: Resolver, ParentType, ContextType>; protocolVersion?: Resolver; staking?: Resolver, ParentType, ContextType>; + swapFeeManager?: Resolver, ParentType, ContextType>; symbol?: Resolver; tags?: Resolver>>, ParentType, ContextType>; type?: Resolver; diff --git a/test/factories/prismaPool.factory.ts b/test/factories/prismaPool.factory.ts index 09dff7fd1..8d020357c 100644 --- a/test/factories/prismaPool.factory.ts +++ b/test/factories/prismaPool.factory.ts @@ -21,7 +21,9 @@ export const prismaPoolFactory = PrismaPoolFactory.define(({ params }) => { name: 'test pool', type: PrismaPoolType.WEIGHTED, decimals: 18, - owner: createRandomAddress(), + swapFeeManager: createRandomAddress(), + pauseManager: createRandomAddress(), + poolCreator: createRandomAddress(), factory: createRandomAddress(), chain: Chain.SEPOLIA, version: 1,