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

publish to prod #887

Closed
wants to merge 6 commits into from
Closed
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/dry-worms-explode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

add reward token to yb and nested apr
5 changes: 5 additions & 0 deletions .changeset/fresh-horses-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': minor
---

adding reward token data to apr item
5 changes: 5 additions & 0 deletions .changeset/grumpy-weeks-switch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

adding new pool query specific for aggregator needs
5 changes: 5 additions & 0 deletions .changeset/healthy-oranges-cheer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'backend': patch
---

refactoring VotingGaugesRepository to use viem
207 changes: 205 additions & 2 deletions graphql_schema_generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,178 @@ export const schema = gql`
valueUSD: Float!
}

type GqlPoolAggregator {
"""
The contract address of the pool.
"""
address: Bytes!

"""
Data specific to gyro/fx pools
"""
alpha: String

"""
Data specific to stable pools
"""
amp: BigInt

"""
Data specific to gyro/fx pools
"""
beta: String

"""
Data specific to gyro pools
"""
c: String

"""
The chain on which the pool is deployed
"""
chain: GqlChain!

"""
The timestamp the pool was created.
"""
createTime: Int!

"""
Data specific to gyro pools
"""
dSq: String

"""
The decimals of the BPT, usually 18
"""
decimals: Int!

"""
Data specific to fx pools
"""
delta: String

"""
Dynamic data such as token balances, swap fees or volume
"""
dynamicData: GqlPoolDynamicData!

"""
Data specific to fx pools
"""
epsilon: String

"""
The factory contract address from which the pool was created.
"""
factory: Bytes

"""
The pool id. This is equal to the address for protocolVersion 3 pools
"""
id: ID!

"""
Data specific to gyro/fx pools
"""
lambda: String

"""
The name of the pool as per contract
"""
name: String!

"""
The wallet address of the owner of the pool. Pool owners can set certain properties like swapFees or AMP.
"""
owner: Bytes

"""
Returns all pool tokens, including BPTs and nested pools if there are any. Only one nested level deep.
"""
poolTokens: [GqlPoolTokenDetail!]!

"""
The protocol version on which the pool is deployed, 1, 2 or 3
"""
protocolVersion: Int!

"""
Data specific to gyro pools
"""
root3Alpha: String

"""
Data specific to gyro pools
"""
s: String

"""
Data specific to gyro pools
"""
sqrtAlpha: String

"""
Data specific to gyro pools
"""
sqrtBeta: String

"""
The token symbol of the pool as per contract
"""
symbol: String!

"""
Data specific to gyro pools
"""
tauAlphaX: String

"""
Data specific to gyro pools
"""
tauAlphaY: String

"""
Data specific to gyro pools
"""
tauBetaX: String

"""
Data specific to gyro pools
"""
tauBetaY: String

"""
The pool type, such as weighted, stable, etc.
"""
type: GqlPoolType!

"""
Data specific to gyro pools
"""
u: String

"""
Data specific to gyro pools
"""
v: String

"""
The version of the pool type.
"""
version: Int!

"""
Data specific to gyro pools
"""
w: String

"""
Data specific to gyro pools
"""
z: String
}

type GqlPoolApr {
apr: GqlPoolAprValue!
hasRewardApr: Boolean!
Expand All @@ -303,10 +475,20 @@ export const schema = gql`
"""
id: ID!

"""
The reward token address, if the APR originates from token emissions
"""
rewardTokenAddress: String

"""
The reward token symbol, if the APR originates from token emissions
"""
rewardTokenSymbol: String

"""
The title of the APR item, a human readable form
"""
title: String!
title: String! @deprecated(reason: "No replacement, should be built client side")

"""
Specific type of this APR
Expand All @@ -333,6 +515,11 @@ export const schema = gql`
"""
LOCKING

"""
Reward APR in a pool from maBEETS emissions allocated by gauge votes. Emitted in BEETS.
"""
MABEETS_EMISSIONS

"""
Rewards distributed by merkl.xyz
"""
Expand All @@ -344,7 +531,7 @@ export const schema = gql`
NESTED

"""
Staking reward APR in a pool, i.e. BAL or BEETS.
Staking reward APR in a pool from a reward token.
"""
STAKING

Expand All @@ -363,6 +550,11 @@ export const schema = gql`
"""
SWAP_FEE

"""
Reward APR in a pool from veBAL emissions allocated by gauge votes. Emitted in BAL.
"""
VEBAL_EMISSIONS

"""
APR that can be earned thourgh voting, i.e. gauge votes
"""
Expand Down Expand Up @@ -2966,6 +3158,17 @@ export const schema = gql`
"""
poolEvents(first: Int, skip: Int, where: GqlPoolEventsFilter): [GqlPoolEvent!]!

"""
Returns all pools for a given filter, specific for aggregators
"""
poolGetAggregatorPools(
first: Int
orderBy: GqlPoolOrderBy
orderDirection: GqlPoolOrderDirection
skip: Int
where: GqlPoolFilter
): [GqlPoolAggregator!]!

"""
Will de deprecated in favor of poolEvents
"""
Expand Down
10 changes: 8 additions & 2 deletions modules/actions/pool/staking/sync-gauge-staking.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const syncGaugeStakingForPools = async (
}

const dbStakingGauge = allDbStakingGauges.find((stakingGauge) => stakingGauge?.id === gauge.id);
const workingSupply = onchainRates.find(({ id }) => `${gauge.id}-${balAddress}-balgauge` === id)?.workingSupply;
const workingSupply = onchainRates.find(({ id }) => id.includes(gauge.id))?.workingSupply;
const totalSupply = onchainRates.find(({ id }) => id.includes(gauge.id))?.totalSupply;
if (
!dbStakingGauge ||
Expand Down Expand Up @@ -193,7 +193,7 @@ export const syncGaugeStakingForPools = async (
const allStakingGaugeRewards = allDbStakingGauges.map((gauge) => gauge?.rewards).flat();

// DB operations for gauge reward tokens
for (const { id, rewardPerSecond } of onchainRates) {
for (const { id, rewardPerSecond, isVeBalemissions } of onchainRates) {
const [gaugeId, tokenAddress] = id.toLowerCase().split('-');
const token = prismaTokens.find((token) => token.address === tokenAddress);
if (!token) {
Expand All @@ -215,9 +215,11 @@ export const syncGaugeStakingForPools = async (
gaugeId,
tokenAddress,
rewardPerSecond,
isVeBalemissions,
},
update: {
rewardPerSecond,
isVeBalemissions,
},
where: { id_chain: { id, chain: networkContext.chain } },
}),
Expand All @@ -240,6 +242,7 @@ const getOnchainRewardTokensData = async (
rewardPerSecond: string;
workingSupply: string;
totalSupply: string;
isVeBalemissions: boolean;
}[]
> => {
// Get onchain data for BAL rewards
Expand Down Expand Up @@ -310,6 +313,7 @@ const getOnchainRewardTokensData = async (
rewardPerSecond,
workingSupply: workingSupply ? formatUnits(workingSupply) : '0',
totalSupply: totalSupply ? formatUnits(totalSupply) : '0',
isVeBalemissions: true,
};
}),
...Object.keys(rewardsData)
Expand All @@ -329,6 +333,7 @@ const getOnchainRewardTokensData = async (
rewardPerSecond,
workingSupply: '0',
totalSupply: totalSupply ? formatUnits(totalSupply) : '0',
isVeBalemissions: false,
};
}),
])
Expand All @@ -338,6 +343,7 @@ const getOnchainRewardTokensData = async (
rewardPerSecond: string;
workingSupply: string;
totalSupply: string;
isVeBalemissions: boolean;
}[];

return onchainRates;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export class MasterchefFarmAprService implements PoolAprService {
apr: beetsApr,
type: 'NATIVE_REWARD',
group: null,
rewardTokenAddress: this.beetsAddress,
rewardTokenSymbol: 'BEETS',
});
}

Expand Down Expand Up @@ -140,6 +142,8 @@ export class MasterchefFarmAprService implements PoolAprService {
apr: rewardApr,
type: 'THIRD_PARTY_REWARD',
group: null,
rewardTokenAddress: rewardToken.token,
rewardTokenSymbol: rewardToken.symbol,
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ export class ReliquaryFarmAprService implements PoolAprService {
},
type: PrismaPoolAprType.NATIVE_REWARD,
group: null,
rewardTokenAddress: this.beetsAddress,
rewardTokenSymbol: 'BEETS',
},
}),
);
Expand Down
9 changes: 8 additions & 1 deletion modules/pool/lib/apr-data-sources/nested-pool-apr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,15 @@ export class BoostedPoolAprService implements PoolAprService {
apr: userApr,
title: title,
group: aprItem.group,
rewardTokenAddress: aprItem.rewardTokenAddress,
rewardTokenSymbol: aprItem.rewardTokenSymbol,
},
update: {
apr: userApr,
title: title,
rewardTokenAddress: aprItem.rewardTokenAddress,
rewardTokenSymbol: aprItem.rewardTokenSymbol,
},
update: { apr: userApr, title: title },
});
}
}
Expand Down
Loading
Loading