Skip to content

Commit

Permalink
Merge pull request #11 from Gearbox-protocol/next
Browse files Browse the repository at this point in the history
fix: constant apy
  • Loading branch information
essserrr authored Jan 14, 2025
2 parents 6b6022e + 01001a5 commit 5e9b0c0
Show file tree
Hide file tree
Showing 20 changed files with 79 additions and 89 deletions.
2 changes: 1 addition & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ app.get("/api/rewards/gear-apy", (req, res) => {
app.get("/api/rewards/pools/all", (req, res) => {
void getPoolRewards(req, res, f);
});
app.get("/api/rewards/tokens/all/", (req, res) => {
app.get("/api/rewards/tokens/all", (req, res) => {
void getAll(req, res, f);
});
app.post("/api/rewards/tokens/list", (req, res) => {
Expand Down
2 changes: 1 addition & 1 deletion src/apy/constant/apy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address } from "viem";

import type { APYHandler, APYResult } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

const getAPY: APYHandler = async network => {
Expand Down
66 changes: 30 additions & 36 deletions src/apy/constant/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,45 @@ import type { Address } from "viem";

import type { NetworkType } from "../../utils";

const ezETH = {
symbol: "ezETH",
apy: 4.5,
};
const rsETH = {
symbol: "rsETH",
apy: 4.0,
};
const weETH = {
symbol: "weETH",
apy: 4.2,
};
const rswETH = {
symbol: "rswETH",
apy: 4.07,
};
const pufETH = {
symbol: "pufETH",
apy: 3.55,
};

export const TOKENS: Record<
NetworkType,
Record<Address, { symbol: string; apy: number }>
> = {
Mainnet: {
"0xbf5495Efe5DB9ce00f80364C8B423567e58d2110": {
symbol: "ezETH",
apy: 3.91,
},
"0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7": {
symbol: "rsETH",
apy: 4.6,
},
"0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee": {
symbol: "weETH",
apy: 4.23,
},
"0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0": {
symbol: "rswETH",
apy: 4.89,
},
"0xD9A442856C234a39a81a089C06451EBAa4306a72": {
symbol: "pufETH",
apy: 5.57,
},
"0xbf5495Efe5DB9ce00f80364C8B423567e58d2110": ezETH,
"0xA1290d69c65A6Fe4DF752f95823fae25cB99e5A7": rsETH,
"0xCd5fE23C85820F7B72D0926FC9b05b43E359b7ee": weETH,
"0xFAe103DC9cf190eD75350761e95403b7b8aFa6c0": rswETH,
"0xD9A442856C234a39a81a089C06451EBAa4306a72": pufETH,
},
Optimism: {
"0x2416092f143378750bb29b79eD961ab195CcEea5": {
symbol: "ezETH",
apy: 3.91,
},
"0x2416092f143378750bb29b79eD961ab195CcEea5": ezETH,
},
Arbitrum: {
"0x2416092f143378750bb29b79eD961ab195CcEea5": {
symbol: "ezETH",
apy: 3.91,
},
"0x4186BFC76E2E237523CBC30FD220FE055156b41F": {
symbol: "rsETH",
apy: 4.6,
},
"0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe": {
symbol: "weETH",
apy: 4.23,
},
"0x2416092f143378750bb29b79eD961ab195CcEea5": ezETH,
"0x4186BFC76E2E237523CBC30FD220FE055156b41F": rsETH,
"0x35751007a407ca6FEFfE80b3cB397736D2cf4dbe": weETH,
},
} as const;

Expand Down
21 changes: 21 additions & 0 deletions src/apy/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Address } from "viem";

import type { NetworkType } from "../utils";

export interface Apy {
reward: Address;
symbol: string;
protocol: string;

value: number;
}

export interface TokenAPY<A = Apy> {
address: Address;
symbol: string;

apys: Array<A>;
}

export type APYResult = Record<Address, TokenAPY>;
export type APYHandler = (network: NetworkType) => Promise<APYResult>;
3 changes: 2 additions & 1 deletion src/apy/curve/apy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import axios from "axios";
import type { Address } from "viem";

import type { APYHandler, APYResult, NetworkType } from "../../utils";
import type { NetworkType } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { GEAR_POOL, PROTOCOL, TOKENS } from "./constants";

interface VolumesResponse {
Expand Down
2 changes: 1 addition & 1 deletion src/apy/ethena/apy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

import type { APYHandler, APYResult, NetworkType } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

interface Response {
Expand Down
1 change: 1 addition & 0 deletions src/apy/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from "./constant";
export * from "./constants";
export * from "./curve";
export * from "./ethena";
export * from "./lido";
Expand Down
2 changes: 1 addition & 1 deletion src/apy/lido/apy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import type { Address } from "viem";

import type { APYHandler, APYResult } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

interface Apy {
Expand Down
2 changes: 1 addition & 1 deletion src/apy/llama/apy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios from "axios";
import type { Address } from "viem";

import type { APYHandler, APYResult } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

interface LamaItem {
Expand Down
2 changes: 1 addition & 1 deletion src/apy/sky/apy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from "axios";

import type { APYHandler, APYResult } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

type Response = [
Expand Down
2 changes: 1 addition & 1 deletion src/apy/yearn/apy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import axios from "axios";
import type { Address } from "viem";

import type { APYHandler, APYResult } from "../../utils";
import { getChainId } from "../../utils";
import type { APYHandler, APYResult } from "../constants";
import { PROTOCOL, TOKENS } from "./constants";

interface APYData {
Expand Down
4 changes: 2 additions & 2 deletions src/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { isAddress } from "viem";

import type { GearAPY } from "./apy";
import type { ApyDetails, Fetcher } from "./fetcher";
import type { PointsInfo } from "./points/constants";
import type { PoolPointsInfo } from "./poolRewards/constants";
import type { PointsInfo } from "./points";
import type { PoolPointsInfo } from "./poolRewards";
import { isSupportedNetwork, toJSONWithBigint } from "./utils";

interface TokenOutputDetails {
Expand Down
14 changes: 4 additions & 10 deletions src/fetcher.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import moment from "moment";
import type { Address } from "viem";

import type { GearAPY } from "./apy";
import type { Apy, APYResult, GearAPY, TokenAPY } from "./apy";
import {
getAPYConstant,
getAPYCurve,
Expand All @@ -12,17 +12,11 @@ import {
getAPYYearn,
getGearAPY,
} from "./apy";
import type { PointsResult } from "./points";
import { getPoints } from "./points";
import type { PointsInfo } from "./points/constants";
import type { PoolPointsResult } from "./poolRewards";
import { getPoolPoints } from "./poolRewards";
import type {
Apy,
APYResult,
NetworkType,
PointsResult,
PoolPointsResult,
TokenAPY,
} from "./utils";
import type { NetworkType } from "./utils";
import { getChainId, supportedChains } from "./utils";

export type ApyDetails = Apy & { lastUpdated: string };
Expand Down
3 changes: 3 additions & 0 deletions src/points/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import type { Address } from "viem";

import type { NetworkType } from "../utils";

export type PointsResult = Record<Address, PointsInfo>;
export type PointsHandler = (network: NetworkType) => Promise<PointsResult>;

type PointsType =
| "eigenlayer"
| "renzo"
Expand Down
1 change: 1 addition & 0 deletions src/points/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./constants";
export * from "./points";
2 changes: 1 addition & 1 deletion src/points/points.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address } from "viem";

import type { PointsHandler, PointsResult } from "../utils";
import type { PointsHandler, PointsResult } from "./constants";
import { POINTS_INFO_BY_NETWORK } from "./constants";

const getPoints: PointsHandler = async network => {
Expand Down
5 changes: 5 additions & 0 deletions src/poolRewards/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import type { Address } from "viem";

import type { NetworkType } from "../utils";

export type PoolPointsResult = Record<Address, Array<PoolPointsInfo>>;
export type PoolPointsHandler = (
network: NetworkType,
) => Promise<PoolPointsResult>;

export interface PoolPointsInfo {
pool: Address;
token: Address;
Expand Down
1 change: 1 addition & 0 deletions src/poolRewards/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./constants";
export * from "./points";
2 changes: 1 addition & 1 deletion src/poolRewards/points.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address } from "viem";

import type { PoolPointsHandler, PoolPointsResult } from "../utils";
import type { PoolPointsHandler, PoolPointsResult } from "./constants";
import { POOL_POINTS } from "./constants";

const getPoolPoints: PoolPointsHandler = async network => {
Expand Down
31 changes: 0 additions & 31 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,3 @@
import type { Address } from "viem";

import type { PointsInfo } from "../points/constants";
import type { PoolPointsInfo } from "../poolRewards/constants";

export interface Apy {
reward: Address;
symbol: string;
protocol: string;

value: number;
}

export interface TokenAPY<A = Apy> {
address: Address;
symbol: string;

apys: Array<A>;
}

export type APYResult = Record<Address, TokenAPY>;
export type APYHandler = (network: NetworkType) => Promise<APYResult>;

export type PointsResult = Record<Address, PointsInfo>;
export type PointsHandler = (network: NetworkType) => Promise<PointsResult>;

export type PoolPointsResult = Record<Address, Array<PoolPointsInfo>>;
export type PoolPointsHandler = (
network: NetworkType,
) => Promise<PoolPointsResult>;

export const supportedChains = ["Mainnet", "Arbitrum", "Optimism"] as const;
export type NetworkType = (typeof supportedChains)[number];
const CHAINS = {
Expand Down

0 comments on commit 5e9b0c0

Please sign in to comment.