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

V3 canary #547

Merged
merged 45 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1877f36
onchain data refactoring
gmbronco Nov 9, 2023
e98e5ab
updates
gmbronco Nov 9, 2023
81cfdad
fix pool version syncing
gmbronco Nov 10, 2023
cfc0f19
onchain syncing depends on network config
gmbronco Nov 10, 2023
e12c4cf
totalSupply depends on type
gmbronco Nov 10, 2023
42f0eac
Merge branch 'v3-canary' into onchain-data
gmbronco Nov 13, 2023
c157f3c
fetching metastable rates case
gmbronco Nov 13, 2023
96e8e81
type checking cleanup
gmbronco Nov 13, 2023
5c33a23
isolating networkContext.chain dependency
gmbronco Nov 15, 2023
3cf1cfc
fix status updates for filtered pools
gmbronco Nov 17, 2023
e9b230a
minor change plus prettier
franzns Nov 17, 2023
3028b15
Merge pull request #524 from beethovenxfi/onchain-data
franzns Nov 17, 2023
14d21da
fix: beetswars apr (#534)
gmbronco Nov 20, 2023
57a7c0d
Merge pull request #533 from beethovenxfi/chain
franzns Nov 20, 2023
1e2f7f5
excluding trumatic
franzns Nov 20, 2023
6813fbc
remove filter to remove bpt from tokens
franzns Nov 21, 2023
c802c46
Merge pull request #536 from beethovenxfi/feature/add-bpt-to-tokenlist
franzns Nov 21, 2023
a6342c9
only have one set of resolvers and schema, keep folders for dev
franzns Nov 21, 2023
b7e9ab0
protocol stats chain param
franzns Nov 21, 2023
6651086
cleanup
franzns Nov 21, 2023
0c57ba7
optional param
franzns Nov 21, 2023
e3fec90
fix worker
franzns Nov 21, 2023
ac463b7
Merge pull request #539 from beethovenxfi/feature/protocol-stats
franzns Nov 21, 2023
06c2a0f
start user balances for pools
franzns Nov 27, 2023
eebf7c5
unify rest routes
franzns Nov 27, 2023
be23e70
Merge pull request #538 from beethovenxfi/feature/remove-protocolspec…
franzns Nov 27, 2023
6ecaa5b
updating and testing stellate config
franzns Nov 27, 2023
4e4f049
filter on query
franzns Nov 29, 2023
e9c0cd0
not in use stellate config
franzns Nov 29, 2023
6ec9464
Merge branch 'v3-canary' into fix/filter-votinggauges-on-query
franzns Nov 29, 2023
f9b26cd
remove logging
franzns Nov 30, 2023
8bd6c6a
Merge pull request #541 from beethovenxfi/fix/filter-votinggauges-on-…
franzns Nov 30, 2023
6cb10a2
reduce coingecko address chunk size
franzns Nov 30, 2023
1e0aed2
filter gauges that don't have votes
franzns Nov 30, 2023
9ec1d36
filter missing info gauges
franzns Nov 30, 2023
97589a1
fix coingecko
franzns Dec 1, 2023
e6ed07d
Merge branch 'v3-canary' into feature/userbalances-on-pools
franzns Dec 1, 2023
fbb73de
return balances
franzns Dec 1, 2023
9b84298
Merge pull request #546 from beethovenxfi/feature/userbalances-on-pools
franzns Dec 1, 2023
41f45cb
adding missing fx#protocolPercentFee fn
gmbronco Dec 1, 2023
8f405b5
Merge pull request #550 from beethovenxfi/fix/fx-pool-onchain-sync
franzns Dec 1, 2023
2a93aa9
more logs for voting gauges
franzns Dec 4, 2023
9269002
we can have duplicate stakingGauges in the list, will be filtered
franzns Dec 4, 2023
1305660
change to one-to-many
franzns Dec 4, 2023
7311e8c
add migration
franzns Dec 4, 2023
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
19 changes: 6 additions & 13 deletions app.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { loadRestRoutesBeethoven } from './modules/beethoven/loadRestRoutes';
import { loadRestRoutesBalancer } from './modules/balancer/loadRestRoutes';
import { loadRestRoutes } from './modules/common/loadRestRoutes';
import { env } from './app/env';
import createExpressApp from 'express';
import { corsMiddleware } from './app/middleware/corsMiddleware';
Expand All @@ -12,10 +11,8 @@ import {
ApolloServerPluginLandingPageGraphQLPlayground,
ApolloServerPluginUsageReporting,
} from 'apollo-server-core';
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import { beethovenSchema } from './graphql_schema_generated_beethoven';
import { balancerSchema } from './graphql_schema_generated_balancer';
import { balancerResolvers, beethovenResolvers } from './app/gql/resolvers';
import { schema } from './graphql_schema_generated';
import { resolvers } from './app/gql/resolvers';
import helmet from 'helmet';
import GraphQLJSON from 'graphql-type-json';
import * as Sentry from '@sentry/node';
Expand Down Expand Up @@ -76,11 +73,7 @@ async function startServer() {
app.use(contextMiddleware);
app.use(sessionMiddleware);

if (env.PROTOCOL === 'beethoven') {
loadRestRoutesBeethoven(app);
} else if (env.PROTOCOL === 'balancer') {
loadRestRoutesBalancer(app);
}
loadRestRoutes(app);

const httpServer = http.createServer(app);

Expand All @@ -103,9 +96,9 @@ async function startServer() {
const server = new ApolloServer({
resolvers: {
JSON: GraphQLJSON,
...(env.PROTOCOL === 'beethoven' ? beethovenResolvers : balancerResolvers),
...resolvers,
},
typeDefs: env.PROTOCOL === 'beethoven' ? beethovenSchema : balancerSchema,
typeDefs: schema,
introspection: true,
plugins,
context: ({ req }) => req.context,
Expand Down
8 changes: 2 additions & 6 deletions app/gql/resolvers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ import { loadFilesSync } from '@graphql-tools/load-files';
import path from 'path';
import { mergeResolvers } from '@graphql-tools/merge';

const balancerResolversArray = loadFilesSync(path.join(__dirname, '../../modules/!(beethoven)/**/*.resolvers.*'));

const beethovenResolversArray = loadFilesSync(path.join(__dirname, '../../modules/!(balancer)/**/*.resolvers.*'));

export const balancerResolvers = mergeResolvers(balancerResolversArray);
export const beethovenResolvers = mergeResolvers(beethovenResolversArray);
const resolversArray = loadFilesSync(path.join(__dirname, '../../modules/**/*.resolvers.*'));
export const resolvers = mergeResolvers(resolversArray);
24 changes: 3 additions & 21 deletions codegen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,31 +137,13 @@ generates:
schema: ${USER_SNAPSHOT_SUBGRAPH}
plugins:
- schema-ast
graphql_schema_generated_balancer.ts:
schema:
- ./modules/**/*.gql
- '!./modules/beethoven/beets.gql'
- '!./modules/**/*.beets.gql'
plugins:
- add:
content: |
import { gql } from 'apollo-server-express';
export const balancerSchema = gql`
#\n# THIS FILE IS AUTOGENERATED — DO NOT EDIT IT\n#
- schema-ast
- add:
placement: 'append'
content: '`;'
graphql_schema_generated_beethoven.ts:
schema:
- ./modules/**/*.gql
- '!./modules/balancer/balancer.gql'
- '!./modules/**/*.balancer.gql'
graphql_schema_generated.ts:
schema: ./modules/**/*.gql
plugins:
- add:
content: |
import { gql } from 'apollo-server-express';
export const beethovenSchema = gql`
export const schema = gql`
#\n# THIS FILE IS AUTOGENERATED — DO NOT EDIT IT\n#
- schema-ast
- add:
Expand Down
5 changes: 0 additions & 5 deletions modules/balancer/loadRestRoutes.ts

This file was deleted.

12 changes: 7 additions & 5 deletions modules/coingecko/coingecko.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ interface CoinId {
that happen.

*/
const tokensPerInterval = env.COINGECKO_API_KEY ? ((env.DEPLOYMENT_ENV as DeploymentEnv) === 'main' ? 10 : 5) : 3;
const requestRateLimiter = new RateLimiter({ tokensPerInterval, interval: 'minute' });
const tokensPerMinute = env.COINGECKO_API_KEY ? 10 : 3;
const requestRateLimiter = new RateLimiter({ tokensPerInterval: tokensPerMinute, interval: 'minute' });
//max 10 addresses per request because of URI size limit, pro is max 180 because of URI limit
const addressChunkSize = env.COINGECKO_API_KEY ? 180 : 20;

export class CoingeckoService {
private readonly baseUrl: string;
Expand Down Expand Up @@ -104,10 +106,10 @@ export class CoingeckoService {
* Rate limit for the CoinGecko API is 10 calls each second per IP address.
*/
public async getTokenPrices(addresses: string[]): Promise<TokenPrices> {
//max 180 addresses per request because of URI size limit
const addressesPerRequest = 180;
const addressesPerRequest = addressChunkSize;
try {
if (addresses.length / addressesPerRequest > 10) throw new Error('Too many requests for rate limit.');
// if (addresses.length / addressesPerRequest > tokensPerMinute)
// throw new Error('Too many requests for rate limit.');

const tokenDefinitions = await tokenService.getTokenDefinitions([networkContext.chain]);
const mapped = addresses.map((address) => this.getMappedTokenDetails(address, tokenDefinitions));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import { Express } from 'express';
import { beetsGetCirculatingSupply } from '../beets/lib/beets';
import { tokenService } from '../token/token.service';

export function loadRestRoutesBeethoven(app: Express) {
export function loadRestRoutes(app: Express) {
app.use('/health', (req, res) => res.sendStatus(200));
app.use('/circulating_supply', (req, res) => {
beetsGetCirculatingSupply().then((result) => {
res.send(result);
});
});

app.use('/late-quartet', async (req, res) => {
const tokenPrices = await tokenService.getTokenPrices();
// app.use('/late-quartet', async (req, res) => {
// const tokenPrices = await tokenService.getTokenPrices();

res.send({
bptPrice: tokenService.getPriceForToken(tokenPrices, '0xf3a602d30dcb723a74a0198313a7551feaca7dac'),
});
});
// res.send({
// bptPrice: tokenService.getPriceForToken(tokenPrices, '0xf3a602d30dcb723a74a0198313a7551feaca7dac'),
// });
// });
}
7 changes: 2 additions & 5 deletions modules/network/mainnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const data: NetworkData = {
coingecko: {
nativeAssetId: 'ethereum',
platformId: 'ethereum',
excludedTokenAddresses: [],
excludedTokenAddresses: ['0xa43a7c62d56df036c187e1966c03e2799d8987ed'], // truMatic, has coingecko entry but no price
},
tokenPrices: {
maxHourlyPriceHistoryNumDays: 100,
Expand Down Expand Up @@ -378,10 +378,7 @@ export const mainnetNetworkConfig: NetworkConfig = {
data.balancer.yieldProtocolFeePercentage,
data.balancer.swapProtocolFeePercentage,
),
new PhantomStableAprService(
data.chain.prismaId,
data.balancer.yieldProtocolFeePercentage,
),
new PhantomStableAprService(data.chain.prismaId, data.balancer.yieldProtocolFeePercentage),
new BoostedPoolAprService(),
new SwapFeeAprService(data.balancer.swapProtocolFeePercentage),
new GaugeAprService(tokenService, [data.bal!.address]),
Expand Down
Loading