Skip to content

Commit

Permalink
Merge pull request #66 from balancer/v3-canary
Browse files Browse the repository at this point in the history
V3 canary
  • Loading branch information
franzns authored Jan 25, 2024
2 parents a42e8a5 + 440d548 commit fd9e4e4
Show file tree
Hide file tree
Showing 46 changed files with 4,001 additions and 2,638 deletions.
4 changes: 0 additions & 4 deletions app/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ export const schema = {
optional: true,
type: String,
},
SUPPORTED_NETWORKS: {
optional: true,
type: String,
},
WORKER_QUEUE_URL: {
optional: true,
type: String,
Expand Down
53 changes: 0 additions & 53 deletions modules/beethoven/beets.gql
Original file line number Diff line number Diff line change
Expand Up @@ -4,58 +4,12 @@ extend type Query {
beetsPoolGetReliquaryFarmSnapshots(id: String!, range: GqlPoolSnapshotDataRange!): [GqlReliquaryFarmSnapshot!]!

userGetFbeetsBalance: GqlUserFbeetsBalance!

userGetPoolSnapshots(poolId: String!, chain: GqlChain!, range: GqlUserSnapshotDataRange!): [GqlUserPoolSnapshot!]!
userGetRelicSnapshots(farmId: String!, range: GqlUserSnapshotDataRange!): [GqlUserRelicSnapshot!]!

userGetPortfolioSnapshots(days: Int!): [GqlUserPortfolioSnapshot!]!
}

extend type Mutation {
beetsSyncFbeetsRatio: String!

beetsPoolLoadReliquarySnapshotsForAllFarms: String!

userLoadAllRelicSnapshots: String!
}

type GqlUserPortfolioSnapshot {
timestamp: Int!
walletBalance: AmountHumanReadable!
gaugeBalance: AmountHumanReadable!
farmBalance: AmountHumanReadable!
totalBalance: AmountHumanReadable!
totalValueUSD: AmountHumanReadable!
fees24h: AmountHumanReadable!
totalFees: AmountHumanReadable!
pools: [GqlUserPoolSnapshot!]!
}

enum GqlUserSnapshotDataRange {
THIRTY_DAYS
NINETY_DAYS
ONE_HUNDRED_EIGHTY_DAYS
ONE_YEAR
ALL_TIME
}

type GqlUserPoolSnapshot {
# id: ID!
timestamp: Int!
# poolId: String!
# poolAddress: String!
# poolName: String!
percentShare: Float!
walletBalance: AmountHumanReadable!
gaugeBalance: AmountHumanReadable!
farmBalance: AmountHumanReadable!
totalBalance: AmountHumanReadable!
totalValueUSD: AmountHumanReadable!
fees24h: AmountHumanReadable!
# totalFees: AmountHumanReadable!
# percentageOfPortfolio: Float!
# priceChange24h: AmountHumanReadable!
# priceChangePercent24h: Float!
}

type GqlUserFbeetsBalance {
Expand Down Expand Up @@ -135,13 +89,6 @@ type GqlPoolStakingFarmRewarder {
rewardPerSecond: String!
}

type GqlUserRelicSnapshot {
timestamp: Int!
totalBalance: String!
relicCount: Int!
relicSnapshots: [GqlRelicSnapshot!]!
}

type GqlRelicSnapshot {
relicId: Int!
farmId: String!
Expand Down
22 changes: 0 additions & 22 deletions modules/beethoven/beets.resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@ const beetsResolvers: Resolvers = {
...balance,
};
},
userGetPoolSnapshots: async (parent, { poolId, chain, range }, context) => {
const accountAddress = getRequiredAccountAddress(context);

return userService.getUserBalanceSnapshotsForPool(
accountAddress.toLowerCase(),
poolId.toLowerCase(),
chain,
range,
);
},
userGetRelicSnapshots: async (parent, { farmId, range }, context) => {
const accountAddress = getRequiredAccountAddress(context);

return userService.getUserRelicSnapshots(accountAddress.toLowerCase(), farmId, range);
},
},
Mutation: {
beetsSyncFbeetsRatio: async (parent, {}, context) => {
Expand All @@ -65,13 +50,6 @@ const beetsResolvers: Resolvers = {

await poolService.loadReliquarySnapshotsForAllFarms();

return 'success';
},
userLoadAllRelicSnapshots: async (parent, {}, context) => {
isAdminRoute(context);

await userService.loadAllUserRelicSnapshots();

return 'success';
},
},
Expand Down
1 change: 1 addition & 0 deletions modules/common/Base.gql
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ enum GqlChain {
OPTIMISM
POLYGON
ZKEVM
SEPOLIA
}
17 changes: 6 additions & 11 deletions modules/datastudio/datastudio.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class DatastudioService {
networkContext.data.datastudio![env.DEPLOYMENT_ENV as DeploymentEnv].compositionTabName;
const emissionDataTabName =
networkContext.data.datastudio![env.DEPLOYMENT_ENV as DeploymentEnv].emissionDataTabName;
const swapProtocolFeePercentage = networkContext.data.balancer.swapProtocolFeePercentage;
const chainSlug = networkContext.data.chain.slug;

const sheets = google.sheets({ version: 'v4' });
Expand Down Expand Up @@ -136,27 +135,23 @@ export class DatastudioService {
}

if (pool.dynamicData) {
const protocolYieldFeePercentage = pool.dynamicData.protocolYieldFee
? parseFloat(pool.dynamicData.protocolYieldFee)
: networkContext.data.balancer.yieldProtocolFeePercentage;
const protocolYieldFeePercentage = parseFloat(pool.dynamicData.protocolYieldFee || '');
const protocolSwapFeePercentage = parseFloat(pool.dynamicData.protocolSwapFee);
sharesChange = `${
parseFloat(pool.dynamicData.totalShares) - parseFloat(pool.dynamicData.totalShares24hAgo)
}`;
tvlChange = `${pool.dynamicData.totalLiquidity - pool.dynamicData.totalLiquidity24hAgo}`;
lpSwapFee = `${pool.dynamicData.fees24h * (1 - swapProtocolFeePercentage)}`;
protocolSwapFee = `${pool.dynamicData.fees24h * swapProtocolFeePercentage}`;
lpSwapFee = `${pool.dynamicData.fees24h * (1 - protocolSwapFeePercentage)}`;
protocolSwapFee = `${pool.dynamicData.fees24h * protocolSwapFeePercentage}`;

lpYieldCapture =
pool.type === 'META_STABLE'
? `${
pool.dynamicData.yieldCapture24h *
(1 - networkContext.data.balancer.swapProtocolFeePercentage)
}`
? `${pool.dynamicData.yieldCapture24h * (1 - protocolSwapFeePercentage)}`
: `${pool.dynamicData.yieldCapture24h * (1 - protocolYieldFeePercentage)}`;

protocolYieldCapture =
pool.type === 'META_STABLE'
? `${pool.dynamicData.yieldCapture24h * networkContext.data.balancer.swapProtocolFeePercentage}`
? `${pool.dynamicData.yieldCapture24h * protocolSwapFeePercentage}`
: `${pool.dynamicData.yieldCapture24h * protocolYieldFeePercentage}`;

if (pool.dynamicData.isInRecoveryMode || pool.type === 'LIQUIDITY_BOOTSTRAPPING') {
Expand Down
31 changes: 13 additions & 18 deletions modules/network/arbitrum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,16 @@ export const arbitrumNetworkData: NetworkData = {
delegationProxy: '0x81cfae226343b24ba12ec6521db2c79e7aeeb310',
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
swapProtocolFeePercentage: 0.5,
yieldProtocolFeePercentage: 0.5,
v2: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
v3: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
},
multicall: '0x80c7dd17b01855a6d2347444a0fcc36136a314de',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
Expand Down Expand Up @@ -199,10 +206,6 @@ export const arbitrumNetworkData: NetworkData = {
beefy: {
linearPools: [''],
},
lido: {
wstEthAprEndpoint: 'https://eth-api.lido.fi/v1/protocol/steth/apr/sma',
wstEthContract: '0x5979d7b546e38e414f7e9822514be443a4800529',
},
datastudio: {
main: {
user: '[email protected]',
Expand Down Expand Up @@ -234,18 +237,10 @@ export const arbitrumNetworkConfig: NetworkConfig = {
contentService: new GithubContentService(),
provider: new ethers.providers.JsonRpcProvider({ url: arbitrumNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new YbTokensAprService(
arbitrumNetworkData.ybAprConfig,
arbitrumNetworkData.chain.prismaId,
arbitrumNetworkData.balancer.yieldProtocolFeePercentage,
arbitrumNetworkData.balancer.swapProtocolFeePercentage,
),
new PhantomStableAprService(
arbitrumNetworkData.chain.prismaId,
arbitrumNetworkData.balancer.yieldProtocolFeePercentage,
),
new YbTokensAprService(arbitrumNetworkData.ybAprConfig, arbitrumNetworkData.chain.prismaId),
new PhantomStableAprService(arbitrumNetworkData.chain.prismaId),
new BoostedPoolAprService(),
new SwapFeeAprService(arbitrumNetworkData.balancer.swapProtocolFeePercentage),
new SwapFeeAprService(),
new GaugeAprService(tokenService, [arbitrumNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, arbitrumNetworkData.bal!.address)],
Expand Down
27 changes: 13 additions & 14 deletions modules/network/avalanche.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,16 @@ const avalancheNetworkData: NetworkData = {
delegationProxy: '0x0c6052254551eae3ecac77b01dfcf1025418828f',
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
swapProtocolFeePercentage: 0.5,
yieldProtocolFeePercentage: 0.5,
v2: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
v3: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
},
multicall: '0xca11bde05977b3631167028862be2a173976ca11',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
Expand Down Expand Up @@ -205,18 +212,10 @@ export const avalancheNetworkConfig: NetworkConfig = {
contentService: new GithubContentService(),
provider: new ethers.providers.JsonRpcProvider({ url: avalancheNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new YbTokensAprService(
avalancheNetworkData.ybAprConfig,
avalancheNetworkData.chain.prismaId,
avalancheNetworkData.balancer.yieldProtocolFeePercentage,
avalancheNetworkData.balancer.swapProtocolFeePercentage,
),
new PhantomStableAprService(
avalancheNetworkData.chain.prismaId,
avalancheNetworkData.balancer.yieldProtocolFeePercentage,
),
new YbTokensAprService(avalancheNetworkData.ybAprConfig, avalancheNetworkData.chain.prismaId),
new PhantomStableAprService(avalancheNetworkData.chain.prismaId),
new BoostedPoolAprService(),
new SwapFeeAprService(avalancheNetworkData.balancer.swapProtocolFeePercentage),
new SwapFeeAprService(),
new GaugeAprService(tokenService, [avalancheNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, avalancheNetworkData.bal!.address)],
Expand Down
22 changes: 12 additions & 10 deletions modules/network/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,16 @@ const baseNetworkData: NetworkData = {
delegationProxy: '0xd87f44df0159dc78029ab9ca7d7e57e7249f5acd',
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
swapProtocolFeePercentage: 0.5,
yieldProtocolFeePercentage: 0.5,
v2: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
v3: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
},
ybAprConfig: {
defaultHandlers: {
Expand Down Expand Up @@ -129,14 +136,9 @@ export const baseNetworkConfig: NetworkConfig = {
contentService: new GithubContentService(),
provider: new ethers.providers.JsonRpcProvider({ url: baseNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new YbTokensAprService(
baseNetworkData.ybAprConfig,
baseNetworkData.chain.prismaId,
baseNetworkData.balancer.yieldProtocolFeePercentage,
baseNetworkData.balancer.swapProtocolFeePercentage,
),
new YbTokensAprService(baseNetworkData.ybAprConfig, baseNetworkData.chain.prismaId),
new BoostedPoolAprService(),
new SwapFeeAprService(baseNetworkData.balancer.swapProtocolFeePercentage),
new SwapFeeAprService(),
new GaugeAprService(tokenService, [baseNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, baseNetworkData.bal!.address)],
Expand Down
27 changes: 13 additions & 14 deletions modules/network/fantom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,16 @@ const fantomNetworkData: NetworkData = {
poolAddress: '0xcde5a11a4acb4ee4c805352cec57e236bdbc3837',
},
balancer: {
vault: '0x20dd72ed959b6147912c2e529f0a0c651c33c9ce',
swapProtocolFeePercentage: 0.25,
yieldProtocolFeePercentage: 0.25,
v2: {
vaultAddress: '0x20dd72ed959b6147912c2e529f0a0c651c33c9ce',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
v3: {
vaultAddress: '0x20dd72ed959b6147912c2e529f0a0c651c33c9ce',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
},
multicall: '0x66335d7ad8011f6aa3f48aadcb523b62b38ed961',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
Expand Down Expand Up @@ -289,19 +296,11 @@ export const fantomNetworkConfig: NetworkConfig = {
contentService: new SanityContentService(fantomNetworkData.chain.prismaId),
provider: new ethers.providers.JsonRpcProvider({ url: fantomNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new YbTokensAprService(
fantomNetworkData.ybAprConfig,
fantomNetworkData.chain.prismaId,
fantomNetworkData.balancer.yieldProtocolFeePercentage,
fantomNetworkData.balancer.swapProtocolFeePercentage,
),
new YbTokensAprService(fantomNetworkData.ybAprConfig, fantomNetworkData.chain.prismaId),
// new SpookySwapAprService(tokenService, fantomNetworkData.spooky!.xBooContract),
new PhantomStableAprService(
fantomNetworkData.chain.prismaId,
fantomNetworkData.balancer.yieldProtocolFeePercentage,
),
new PhantomStableAprService(fantomNetworkData.chain.prismaId),
new BoostedPoolAprService(),
new SwapFeeAprService(fantomNetworkData.balancer.swapProtocolFeePercentage),
new SwapFeeAprService(),
new MasterchefFarmAprService(fantomNetworkData.beets!.address),
new ReliquaryFarmAprService(fantomNetworkData.beets!.address),
new BeetswarsGaugeVotingAprService(),
Expand Down
27 changes: 13 additions & 14 deletions modules/network/gnosis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,16 @@ const gnosisNetworkData: NetworkData = {
delegationProxy: '0x7a2535f5fb47b8e44c02ef5d9990588313fe8f05',
},
balancer: {
vault: '0xba12222222228d8ba445958a75a0704d566bf2c8',
swapProtocolFeePercentage: 0.5,
yieldProtocolFeePercentage: 0.5,
v2: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
v3: {
vaultAddress: '0xba12222222228d8ba445958a75a0704d566bf2c8',
defaultSwapFeePercentage: '0.5',
defaultYieldFeePercentage: '0.5',
},
},
multicall: '0xbb6fab6b627947dae0a75808250d8b2652952cb5',
multicall3: '0xca11bde05977b3631167028862be2a173976ca11',
Expand Down Expand Up @@ -133,18 +140,10 @@ export const gnosisNetworkConfig: NetworkConfig = {
contentService: new GithubContentService(),
provider: new ethers.providers.JsonRpcProvider({ url: gnosisNetworkData.rpcUrl, timeout: 60000 }),
poolAprServices: [
new YbTokensAprService(
gnosisNetworkData.ybAprConfig,
gnosisNetworkData.chain.prismaId,
gnosisNetworkData.balancer.yieldProtocolFeePercentage,
gnosisNetworkData.balancer.swapProtocolFeePercentage,
),
new PhantomStableAprService(
gnosisNetworkData.chain.prismaId,
gnosisNetworkData.balancer.yieldProtocolFeePercentage,
),
new YbTokensAprService(gnosisNetworkData.ybAprConfig, gnosisNetworkData.chain.prismaId),
new PhantomStableAprService(gnosisNetworkData.chain.prismaId),
new BoostedPoolAprService(),
new SwapFeeAprService(gnosisNetworkData.balancer.swapProtocolFeePercentage),
new SwapFeeAprService(),
new GaugeAprService(tokenService, [gnosisNetworkData.bal!.address]),
],
poolStakingServices: [new GaugeStakingService(gaugeSubgraphService, gnosisNetworkData.bal!.address)],
Expand Down
Loading

0 comments on commit fd9e4e4

Please sign in to comment.