Skip to content
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# backend

## 2.1.4

### Patch Changes

- 071d4ce: set vebal apr to 0

## 2.1.3

### Patch Changes
Expand Down
53 changes: 27 additions & 26 deletions modules/aprs/handlers/vebal-apr/vebal-protocol-apr-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,35 +87,36 @@ export class VeBalProtocolAprHandler implements AprHandler {
}

async getApr(): Promise<number> {
const revenue = await fetchRevenue(Date.now(), config['MAINNET'].rpcUrl);

// Prices
const balPrice = await prisma.prismaTokenCurrentPrice.findFirst({
where: { tokenAddress: balAddress, chain: 'MAINNET' },
select: { price: true },
});

const usdcPrice = await prisma.prismaTokenCurrentPrice.findFirst({
where: { tokenAddress: usdcAddress, chain: 'MAINNET' },
select: { price: true },
});

const bptPrice = await prisma.prismaTokenCurrentPrice.findFirst({
where: { tokenAddress: vebalPoolAddress, chain: 'MAINNET' },
select: { price: true },
});

if (!balPrice || !usdcPrice || !bptPrice) {
return 0;
}
return 0;
// const revenue = await fetchRevenue(Date.now(), config['MAINNET'].rpcUrl);

// // Prices
// const balPrice = await prisma.prismaTokenCurrentPrice.findFirst({
// where: { tokenAddress: balAddress, chain: 'MAINNET' },
// select: { price: true },
// });

// const usdcPrice = await prisma.prismaTokenCurrentPrice.findFirst({
// where: { tokenAddress: usdcAddress, chain: 'MAINNET' },
// select: { price: true },
// });

// const bptPrice = await prisma.prismaTokenCurrentPrice.findFirst({
// where: { tokenAddress: vebalPoolAddress, chain: 'MAINNET' },
// select: { price: true },
// });

// if (!balPrice || !usdcPrice || !bptPrice) {
// return 0;
// }

const lastWeekBalRevenue = revenue.balAmount * balPrice.price;
const lastWeekUsdcRevenue = revenue.usdcAmount * usdcPrice.price;
// const lastWeekBalRevenue = revenue.balAmount * balPrice.price;
// const lastWeekUsdcRevenue = revenue.usdcAmount * usdcPrice.price;

const dailyRevenue = (lastWeekBalRevenue + lastWeekUsdcRevenue) / 7;
const apr = (365 * dailyRevenue) / (bptPrice.price * revenue.veBalSupply);
// const dailyRevenue = (lastWeekBalRevenue + lastWeekUsdcRevenue) / 7;
// const apr = (365 * dailyRevenue) / (bptPrice.price * revenue.veBalSupply);

return apr;
// return apr;
}

public async calculateAprForPools(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export class VeBalVotingAprHandler implements AprHandler {
}

async getApr(): Promise<number> {
return 0;
// Get APRs for last 3 weeks, if available
const round = await fetchLatestStakeDaoRound();

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": "2.1.3",
"version": "2.1.4",
"description": "Backend service for Beethoven X and Balancer",
"repository": "https://github.com/balancer/backend",
"author": "Beethoven X",
Expand Down
Loading