Skip to content

Commit

Permalink
[APR] add rate provider block list (#549)
Browse files Browse the repository at this point in the history
* add rate provider block list

* fix format

* fix format
  • Loading branch information
luizakp authored Dec 23, 2023
1 parent 71a0119 commit ef2a966
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
38 changes: 38 additions & 0 deletions packages/balancer-apr/src/blockListRateProvider.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export const blockListRateProvider = [
{
network: "gnosis",
rateProviderAddress: "0xe7511f6e5c593007ea8a7f52af4b066333765e03",
tokenAddress: "0xcb444e90d8198415266c6a2724b7900fb12fc56e",
tokenSymbol: "EURe",
},
{
network: "polygon",
rateProviderAddress: "0x737b6ea575ad54e0c4f45c7a36ad8c0e730aad74",
tokenAddress: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
tokenSymbol: "USDC",
},
{
network: "polygon",
rateProviderAddress: "0x61e15f2a9607c8b29636ab39cb8839e50d5dea2a",
tokenAddress: "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
tokenSymbol: "USDC",
},
{
network: "polygon",
rateProviderAddress: "0x9ee91f9f426fa633d227f7a9b000e28b9dfd8599",
tokenAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
tokenSymbol: "WMATIC",
},
{
network: "polygon",
rateProviderAddress: "0x797c1369e578172112526dfcd0d5f9182067c928",
tokenAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
tokenSymbol: "WMATIC",
},
{
network: "polygon",
rateProviderAddress: "0x87393be8ac323f2e63520a6184e5a8a9cc9fc051",
tokenAddress: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
tokenSymbol: "WMATIC",
},
];
11 changes: 11 additions & 0 deletions packages/balancer-apr/src/dailySeed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
} from "drizzle-orm";
import { Address } from "viem";

import { blockListRateProvider } from "./blockListRateProvider";
import {
NETWORK_TO_BALANCER_ENDPOINT_MAP,
NETWORK_TO_REWARDS_ENDPOINT_MAP,
Expand Down Expand Up @@ -1415,6 +1416,11 @@ async function calculateApr() {
AND p1.timestamp >= '${sql.raw(
twoDaysAgo.toISOString(),
)}'::timestamp AT TIME ZONE 'UTC'
AND p1.rate_provider_address NOT IN (${sql.raw(
blockListRateProvider
.map((item) => `'${item.rateProviderAddress}'`)
.join(", "),
)})
) AS subquery ON subquery.timestamp = pool_snapshots.timestamp
AND subquery.token_address = pool_tokens.token_address
AND subquery.row_num = 1 -- Use the latest rate
Expand Down Expand Up @@ -1485,6 +1491,11 @@ async function calculateApr() {
AND p1.timestamp >= '${sql.raw(
twoDaysAgo.toISOString(),
)}'::timestamp AT TIME ZONE 'UTC'
AND p1.rate_provider_address NOT IN (${sql.raw(
blockListRateProvider
.map((item) => `'${item.rateProviderAddress}'`)
.join(", "),
)})
) AS subquery ON subquery.timestamp = pool_snapshots.timestamp
AND subquery.token_address = pool_tokens.token_address
AND subquery.row_num = 1 -- Use the latest rate
Expand Down
11 changes: 11 additions & 0 deletions packages/balancer-apr/src/lib/etl/load/loadAPRs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import "dotenv/config";

import { and, eq, isNotNull, sql } from "drizzle-orm";

import { blockListRateProvider } from "../../../blockListRateProvider";
import { db } from "../../../db/index";
import {
poolRewardsSnapshot,
Expand Down Expand Up @@ -100,6 +101,11 @@ export async function loadAPRs() {
AND p1.rate != 0
AND p2.rate != 0
AND p1.rate - p2.rate != 0
AND p1.rate_provider_address NOT IN (${sql.raw(
blockListRateProvider
.map((item) => `'${item.rateProviderAddress}'`)
.join(", "),
)})
) AS subquery ON subquery.timestamp = pool_snapshots.timestamp
AND subquery.token_address = pool_tokens.token_address
AND subquery.row_num = 1 -- Use the latest rate
Expand Down Expand Up @@ -158,6 +164,11 @@ export async function loadAPRs() {
AND p1.rate != 0
AND p2.rate != 0
AND p1.rate - p2.rate != 0
AND p1.rate_provider_address NOT IN (${sql.raw(
blockListRateProvider
.map((item) => `'${item.rateProviderAddress}'`)
.join(", "),
)})
) AS subquery ON subquery.timestamp = pool_snapshots.timestamp
AND subquery.token_address = pool_tokens.token_address
AND subquery.row_num = 1 -- Use the latest rate
Expand Down

0 comments on commit ef2a966

Please sign in to comment.