Skip to content

Commit

Permalink
Merge pull request #1440 from balancer/v3-canary
Browse files Browse the repository at this point in the history
publish to prod
  • Loading branch information
gmbronco authored Jan 9, 2025
2 parents 1ef72d6 + 0428854 commit 11efaa3
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# backend

## 1.27.3

### Patch Changes

- f6610d0: manage sentry config via env
- b27003d: handle additional morpho token reward apr
- f416bf9: adjust sentry sample rates

## 1.27.2

### Patch Changes
Expand Down
4 changes: 2 additions & 2 deletions apps/api/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ export const initApiSentry = () => {

// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 0.005,
tracesSampleRate: 0,

// Set sampling rate for profiling
// This is relative to tracesSampleRate
profilesSampleRate: 0.001,
profilesSampleRate: 0,

beforeSend(event, hint) {
const error = hint.originalException;
Expand Down
8 changes: 8 additions & 0 deletions apps/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ export const schema = {
SANITY_API_TOKEN: String,
SENTRY_DSN: String,
SENTRY_AUTH_TOKEN: String,
SENTRY_TRACES_SAMPLE_RATE: {
optional: true,
type: Number,
},
SENTRY_PROFILES_SAMPLE_RATE: {
optional: true,
type: Number,
},
AWS_REGION: String,
PROTOCOL: {
optional: true,
Expand Down
6 changes: 3 additions & 3 deletions apps/worker/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ export const initWorkerSentry = () => {
],

// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 0.005,
// Send 1% of transactions to Sentry
tracesSampleRate: env.SENTRY_TRACES_SAMPLE_RATE || 0.01,

// Set sampling rate for profiling
// This is relative to tracesSampleRate
profilesSampleRate: 0.001,
profilesSampleRate: env.SENTRY_PROFILES_SAMPLE_RATE || 0.01,

beforeSend: (event) => {
if (event.tags?.job && event.tags?.chain) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export * from './dforce-apr-handler';
export * from './defillama-apr-handler';
export * from './teth';
export * from './morpho-apr-handler';
export * from './morpho-token-apr-handler';
export * from './usdl-apr-handler';
// These need a refactor, because they depend on the network context
export * from './sftmx-apr-handler';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { gql, request } from 'graphql-request';
import { AprHandler } from '../types';

const url = 'https://blue-api.morpho.org/graphql';
const query = gql`
{
vault(id: "560b57bd-0e46-425f-9549-f3e38be0e1e6") {
state {
netApyWithoutRewards
netApy
}
}
}
`;

type Response = {
vault: {
state: {
netApyWithoutRewards: number;
netApy: number;
};
};
};

export class MorphoTokenAprHandler implements AprHandler {
constructor() {}

async getAprs() {
try {
const r = await request<Response>(url, query);
const apr = r?.vault?.state?.netApy - r?.vault?.state?.netApyWithoutRewards;

return {
'0x58d97b57bb95320f9a05dc918aef65434969c2b2': {
apr: apr,
isIbYield: false,
},
};
} catch (e) {
console.error(`Failed to fetch Morpho APRs`, e);
return {} as { [token: string]: { apr: number; isIbYield: boolean } };
}
}
}
6 changes: 4 additions & 2 deletions modules/pool/lib/apr-data-sources/yb-tokens-apr.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { prisma } from '../../../../prisma/prisma-client';
import { prismaBulkExecuteOperations } from '../../../../prisma/prisma-util';
import { Chain, PrismaPoolAprItemGroup, PrismaPoolAprType } from '@prisma/client';
import { YbAprHandlers, TokenApr } from './yb-apr-handlers';
import { MorphoTokenAprHandler } from './yb-apr-handlers/sources';
import { tokenService } from '../../../token/token.service';
import { collectsYieldFee, tokenCollectsYieldFee } from '../pool-utils';
import { YbAprConfig } from '../../../network/apr-config-types';

const MORPHO_TOKEN = '0x58d97b57bb95320f9a05dc918aef65434969c2b2';
const MORPHO_RATE = 0.07605350252138458;

export class YbTokensAprService implements PoolAprService {
private ybTokensAprHandlers: YbAprHandlers;
Expand Down Expand Up @@ -138,11 +138,13 @@ export class YbTokensAprService implements PoolAprService {
const morphoTokensShare = tokenAprs
.filter((t) => t.group === 'MORPHO')
.reduce((acc, t) => acc + t.share, 0);

const morphoRate = await new MorphoTokenAprHandler().getAprs();
const morphoId = `${pool.id}-morpho`;
const morphoData = {
...data,
id: morphoId,
apr: MORPHO_RATE * morphoTokensShare,
apr: morphoRate[MORPHO_TOKEN].apr * morphoTokensShare,
type: PrismaPoolAprType.IB_YIELD,
title: 'MORPHO APR',
rewardTokenAddress: MORPHO_TOKEN,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "backend",
"version": "1.27.2",
"version": "1.27.3",
"description": "Backend service for Beethoven X and Balancer",
"repository": "https://github.com/balancer/backend",
"author": "Beethoven X",
Expand Down

0 comments on commit 11efaa3

Please sign in to comment.