diff --git a/main.ts b/main.ts index a53f02c..a450482 100644 --- a/main.ts +++ b/main.ts @@ -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) => { diff --git a/src/apy/constant/apy.ts b/src/apy/constant/apy.ts index 563714e..66dc479 100644 --- a/src/apy/constant/apy.ts +++ b/src/apy/constant/apy.ts @@ -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 => { diff --git a/src/apy/constant/constants.ts b/src/apy/constant/constants.ts index 88b86c0..c0e4fe7 100644 --- a/src/apy/constant/constants.ts +++ b/src/apy/constant/constants.ts @@ -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 > = { 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; diff --git a/src/apy/constants.ts b/src/apy/constants.ts new file mode 100644 index 0000000..40addb0 --- /dev/null +++ b/src/apy/constants.ts @@ -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 { + address: Address; + symbol: string; + + apys: Array; +} + +export type APYResult = Record; +export type APYHandler = (network: NetworkType) => Promise; diff --git a/src/apy/curve/apy.ts b/src/apy/curve/apy.ts index 9fee0aa..307debb 100644 --- a/src/apy/curve/apy.ts +++ b/src/apy/curve/apy.ts @@ -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 { diff --git a/src/apy/ethena/apy.ts b/src/apy/ethena/apy.ts index 7d6827c..06f0329 100644 --- a/src/apy/ethena/apy.ts +++ b/src/apy/ethena/apy.ts @@ -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 { diff --git a/src/apy/index.ts b/src/apy/index.ts index 7c2a778..f7b5a7f 100644 --- a/src/apy/index.ts +++ b/src/apy/index.ts @@ -1,4 +1,5 @@ export * from "./constant"; +export * from "./constants"; export * from "./curve"; export * from "./ethena"; export * from "./lido"; diff --git a/src/apy/lido/apy.ts b/src/apy/lido/apy.ts index 7dc02f5..59b5a05 100644 --- a/src/apy/lido/apy.ts +++ b/src/apy/lido/apy.ts @@ -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 { diff --git a/src/apy/llama/apy.ts b/src/apy/llama/apy.ts index c951971..a0ed499 100644 --- a/src/apy/llama/apy.ts +++ b/src/apy/llama/apy.ts @@ -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 { diff --git a/src/apy/sky/apy.ts b/src/apy/sky/apy.ts index 072440b..f17e3c7 100644 --- a/src/apy/sky/apy.ts +++ b/src/apy/sky/apy.ts @@ -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 = [ diff --git a/src/apy/yearn/apy.ts b/src/apy/yearn/apy.ts index 44362a6..871b26e 100644 --- a/src/apy/yearn/apy.ts +++ b/src/apy/yearn/apy.ts @@ -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 { diff --git a/src/endpoints.ts b/src/endpoints.ts index 7cad14a..49eb6ed 100644 --- a/src/endpoints.ts +++ b/src/endpoints.ts @@ -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 { diff --git a/src/fetcher.ts b/src/fetcher.ts index ed9d501..10311e0 100644 --- a/src/fetcher.ts +++ b/src/fetcher.ts @@ -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, @@ -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 }; diff --git a/src/points/constants.ts b/src/points/constants.ts index 7f961fc..0f869d1 100644 --- a/src/points/constants.ts +++ b/src/points/constants.ts @@ -2,6 +2,9 @@ import type { Address } from "viem"; import type { NetworkType } from "../utils"; +export type PointsResult = Record; +export type PointsHandler = (network: NetworkType) => Promise; + type PointsType = | "eigenlayer" | "renzo" diff --git a/src/points/index.ts b/src/points/index.ts index 1ce67fa..95f54f6 100644 --- a/src/points/index.ts +++ b/src/points/index.ts @@ -1 +1,2 @@ +export * from "./constants"; export * from "./points"; diff --git a/src/points/points.ts b/src/points/points.ts index bcf3a21..a9d8811 100644 --- a/src/points/points.ts +++ b/src/points/points.ts @@ -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 => { diff --git a/src/poolRewards/constants.ts b/src/poolRewards/constants.ts index 66281d1..9b5874f 100644 --- a/src/poolRewards/constants.ts +++ b/src/poolRewards/constants.ts @@ -2,6 +2,11 @@ import type { Address } from "viem"; import type { NetworkType } from "../utils"; +export type PoolPointsResult = Record>; +export type PoolPointsHandler = ( + network: NetworkType, +) => Promise; + export interface PoolPointsInfo { pool: Address; token: Address; diff --git a/src/poolRewards/index.ts b/src/poolRewards/index.ts index 1ce67fa..95f54f6 100644 --- a/src/poolRewards/index.ts +++ b/src/poolRewards/index.ts @@ -1 +1,2 @@ +export * from "./constants"; export * from "./points"; diff --git a/src/poolRewards/points.ts b/src/poolRewards/points.ts index c49c71b..56b0896 100644 --- a/src/poolRewards/points.ts +++ b/src/poolRewards/points.ts @@ -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 => { diff --git a/src/utils/index.ts b/src/utils/index.ts index cbc5378..6ab31bb 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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 { - address: Address; - symbol: string; - - apys: Array; -} - -export type APYResult = Record; -export type APYHandler = (network: NetworkType) => Promise; - -export type PointsResult = Record; -export type PointsHandler = (network: NetworkType) => Promise; - -export type PoolPointsResult = Record>; -export type PoolPointsHandler = ( - network: NetworkType, -) => Promise; - export const supportedChains = ["Mainnet", "Arbitrum", "Optimism"] as const; export type NetworkType = (typeof supportedChains)[number]; const CHAINS = {