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

Adding V3 pool roles #1200

Merged
merged 1 commit into from
Nov 28, 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
5 changes: 5 additions & 0 deletions .changeset/lovely-radios-cry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

Adding V3 pool roles to the db model
17 changes: 16 additions & 1 deletion graphql_schema_generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
"""
Expand Down
3 changes: 3 additions & 0 deletions modules/pool/lib/pool-gql-loader.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}`,
Expand Down Expand Up @@ -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}`,
Expand Down
14 changes: 13 additions & 1 deletion modules/pool/pool.gql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure why this is bytes, lets make it string

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess Bytes naming comes from the contracts and it's meant to represent 0x strings. In TS it's just a String alias like BigDecimal is:
https://github.com/balancer/backend/blob/pool-roles/codegen.ts/#L15-L16
Maybe we should remove the mappings altogether to make it more understandable in the docs?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, lets get rid of bytes and just use strings

Copy link
Collaborator

@franzns franzns Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just change the owners to strings in the schema for now, leave the mapping as is

"""
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.
"""
Expand Down
2 changes: 1 addition & 1 deletion modules/pool/subgraph-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const subgraphMapper = (
decimals: 18,
type: type,
version: version,
owner: pool.owner || AddressZero,
swapFeeManager: pool.owner || AddressZero,
factory: pool.factory,
};

Expand Down
50 changes: 49 additions & 1 deletion modules/sources/subgraphs/balancer-v3-vault/generated/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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 */
Expand All @@ -783,6 +791,8 @@ export type Pool = {
snapshots: Array<PoolSnapshot>;
/** 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 */
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -1541,6 +1559,7 @@ export type Pool_Filter = {
pauseWindowEndTime_lte?: InputMaybe<Scalars['BigInt']>;
pauseWindowEndTime_not?: InputMaybe<Scalars['BigInt']>;
pauseWindowEndTime_not_in?: InputMaybe<Array<Scalars['BigInt']>>;
poolCreator?: InputMaybe<Scalars['Bytes']>;
poolCreatorSwapFee?: InputMaybe<Scalars['BigDecimal']>;
poolCreatorSwapFee_gt?: InputMaybe<Scalars['BigDecimal']>;
poolCreatorSwapFee_gte?: InputMaybe<Scalars['BigDecimal']>;
Expand All @@ -1557,6 +1576,15 @@ export type Pool_Filter = {
poolCreatorYieldFee_lte?: InputMaybe<Scalars['BigDecimal']>;
poolCreatorYieldFee_not?: InputMaybe<Scalars['BigDecimal']>;
poolCreatorYieldFee_not_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
poolCreator_contains?: InputMaybe<Scalars['Bytes']>;
poolCreator_gt?: InputMaybe<Scalars['Bytes']>;
poolCreator_gte?: InputMaybe<Scalars['Bytes']>;
poolCreator_in?: InputMaybe<Array<Scalars['Bytes']>>;
poolCreator_lt?: InputMaybe<Scalars['Bytes']>;
poolCreator_lte?: InputMaybe<Scalars['Bytes']>;
poolCreator_not?: InputMaybe<Scalars['Bytes']>;
poolCreator_not_contains?: InputMaybe<Scalars['Bytes']>;
poolCreator_not_in?: InputMaybe<Array<Scalars['Bytes']>>;
protocolSwapFee?: InputMaybe<Scalars['BigDecimal']>;
protocolSwapFee_gt?: InputMaybe<Scalars['BigDecimal']>;
protocolSwapFee_gte?: InputMaybe<Scalars['BigDecimal']>;
Expand All @@ -1576,6 +1604,16 @@ export type Pool_Filter = {
rateProviders_?: InputMaybe<RateProvider_Filter>;
snapshots_?: InputMaybe<PoolSnapshot_Filter>;
swapFee?: InputMaybe<Scalars['BigDecimal']>;
swapFeeManager?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_contains?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_gt?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_gte?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_in?: InputMaybe<Array<Scalars['Bytes']>>;
swapFeeManager_lt?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_lte?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_not?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_not_contains?: InputMaybe<Scalars['Bytes']>;
swapFeeManager_not_in?: InputMaybe<Array<Scalars['Bytes']>>;
swapFee_gt?: InputMaybe<Scalars['BigDecimal']>;
swapFee_gte?: InputMaybe<Scalars['BigDecimal']>;
swapFee_in?: InputMaybe<Array<Scalars['BigDecimal']>>;
Expand Down Expand Up @@ -1685,13 +1723,15 @@ export enum Pool_OrderBy {
Name = 'name',
PauseManager = 'pauseManager',
PauseWindowEndTime = 'pauseWindowEndTime',
PoolCreator = 'poolCreator',
PoolCreatorSwapFee = 'poolCreatorSwapFee',
PoolCreatorYieldFee = 'poolCreatorYieldFee',
ProtocolSwapFee = 'protocolSwapFee',
ProtocolYieldFee = 'protocolYieldFee',
RateProviders = 'rateProviders',
Snapshots = 'snapshots',
SwapFee = 'swapFee',
SwapFeeManager = 'swapFeeManager',
SwapsCount = 'swapsCount',
Symbol = 'symbol',
Tokens = 'tokens',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -3073,6 +3115,8 @@ export type VaultPoolFragment = {
totalShares: string;
pauseWindowEndTime: string;
pauseManager: string;
swapFeeManager: string;
poolCreator: string;
blockNumber: string;
blockTimestamp: string;
holdersCount: string;
Expand Down Expand Up @@ -3151,6 +3195,8 @@ export type PoolsQuery = {
totalShares: string;
pauseWindowEndTime: string;
pauseManager: string;
swapFeeManager: string;
poolCreator: string;
blockNumber: string;
blockTimestamp: string;
holdersCount: string;
Expand Down Expand Up @@ -3396,6 +3442,8 @@ export const VaultPoolFragmentDoc = gql`
totalShares
pauseWindowEndTime
pauseManager
swapFeeManager
poolCreator
blockNumber
blockTimestamp
holdersCount
Expand Down
2 changes: 2 additions & 0 deletions modules/sources/subgraphs/balancer-v3-vault/pools.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ fragment VaultPool on Pool {
totalShares
pauseWindowEndTime
pauseManager
swapFeeManager
poolCreator
blockNumber
blockTimestamp
holdersCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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: {},
Expand Down
4 changes: 3 additions & 1 deletion modules/sources/transformers/pool-upsert-transformer-v3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion modules/tests-helper/poolTestdataHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
19 changes: 19 additions & 0 deletions prisma/migrations/20241127185045_pool_roles/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
4 changes: 3 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion prisma/schema/pool.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading