Skip to content

Commit

Permalink
Merge pull request #290 from alchemix-finance/staging
Browse files Browse the repository at this point in the history
CHORE: Staging
  • Loading branch information
t0rbik authored Dec 2, 2024
2 parents f08f4b9 + 56a785e commit 48914b5
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 12 deletions.
3 changes: 2 additions & 1 deletion src/components/vaults/row/VaultInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
variants,
} from "./motion";
import { AprHistoricalChart } from "./AprHistoricalChart";
import { ALCHEMIST_FEE_MULTIPLIER } from "@/lib/middleware/common";

interface VaultInfoProps {
vault: Vault;
Expand Down Expand Up @@ -191,7 +192,7 @@ export const VaultInfo = ({ vault }: VaultInfoProps) => {
name: values[1],
timestamp: parseInt(values[0]),
formattedDate: dayjs.unix(parseInt(values[0])).format("MMM D"),
apr: +values[2] * 100,
apr: +values[2] * 100 * ALCHEMIST_FEE_MULTIPLIER,
};
});
return parsedData;
Expand Down
10 changes: 6 additions & 4 deletions src/lib/middleware/aave.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { AprFn } from "@/lib/config/metadataTypes";

import { SupportedChainId } from "@/lib/wagmi/wagmiConfig";
import { arbitrum, fantom, mainnet, optimism } from "viem/chains";
import { gql, request } from "graphql-request";

import { AprFn } from "@/lib/config/metadataTypes";
import { SupportedChainId } from "@/lib/wagmi/wagmiConfig";

import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

const aaveApiParams = {
[mainnet.id]: {
url: `https://gateway-arbitrum.network.thegraph.com/api/${import.meta.env.VITE_SUBGRAPH_API_KEY}/subgraphs/id/8wR23o1zkS4gpLqLNU4kG3JHYVucqGyopL5utGxP2q1N`,
Expand Down Expand Up @@ -145,7 +147,7 @@ export const processApr = async ({

const ray = 10 ** 27;
let a = parseFloat(reserve?.liquidityRate || "1") / ray;
a = a * 0.9;
a = a * ALCHEMIST_FEE_MULTIPLIER;
const b = a * 100;
return b;
};
Expand Down
2 changes: 2 additions & 0 deletions src/lib/middleware/common.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/** Alchemist contract takes a 10% fee at harvest transactions. */
export const ALCHEMIST_FEE_MULTIPLIER = 0.9;
3 changes: 2 additions & 1 deletion src/lib/middleware/frax.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

const apiUrl = "https://api.frax.finance/v2/frxeth/summary/latest";

export const getFraxApy: AprFn = async () => {
const query = await fetch(apiUrl);
const data = (await query.json()) as { sfrxethApr: number };
return data.sfrxethApr * 0.9;
return data.sfrxethApr * ALCHEMIST_FEE_MULTIPLIER;
};
3 changes: 2 additions & 1 deletion src/lib/middleware/gearbox.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { toNumber } from "dnum";

import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

export const getGearboxApy: AprFn = async ({ vaultAddress, publicClient }) => {
const poolContract = {
Expand Down Expand Up @@ -37,5 +38,5 @@ export const getGearboxApy: AprFn = async ({ vaultAddress, publicClient }) => {
functionName: "supplyRate",
});

return toNumber([rateBigInt, 25]);
return toNumber([rateBigInt, 25]) * ALCHEMIST_FEE_MULTIPLIER;
};
3 changes: 2 additions & 1 deletion src/lib/middleware/jones.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

export const getJonesApy: AprFn = async () => {
const response = await fetch("https://app.jonesdao.io/api/jusdc-apy");
Expand All @@ -7,5 +8,5 @@ export const getJonesApy: AprFn = async () => {
if (data.jusdcApy === undefined || typeof data.jusdcApy !== "number")
throw new Error("Invalid APY data");

return data.jusdcApy;
return data.jusdcApy * ALCHEMIST_FEE_MULTIPLIER;
};
3 changes: 2 additions & 1 deletion src/lib/middleware/lido.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// see documentation at https://docs.lido.fi/integrations/api

import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

export const getLidoApy: AprFn = async () => {
const api = await fetch("https://eth-api.lido.fi/v1/protocol/steth/apr/last");
const data = await api.json();
return (data.data.apr * 0.9) as number;
return (data.data.apr as number) * ALCHEMIST_FEE_MULTIPLIER;
};
3 changes: 2 additions & 1 deletion src/lib/middleware/rocketPool.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

const apiUrl = "https://api.rocketpool.net/api/mainnet/apr";

Expand All @@ -9,6 +10,6 @@ type RocketResponse = {
export const getRocketApr: AprFn = async () => {
const api = await fetch(apiUrl);
const response = (await api.json()) as RocketResponse;
const totalStake = parseFloat(response.yearlyAPR) * 0.9;
const totalStake = parseFloat(response.yearlyAPR) * ALCHEMIST_FEE_MULTIPLIER;
return totalStake;
};
3 changes: 2 additions & 1 deletion src/lib/middleware/vesper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AprFn } from "@/lib/config/metadataTypes";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

interface VesperReserve {
address: string;
Expand Down Expand Up @@ -29,7 +30,7 @@ export const processApr = async ({

let yieldValue = reserve?.actualRates["30"] ?? 0;
if (yieldValue < 0) yieldValue = 0;
return yieldValue;
return yieldValue * ALCHEMIST_FEE_MULTIPLIER;
};

export const getVesperApr: AprFn = async ({ vaultAddress }) => {
Expand Down
3 changes: 2 additions & 1 deletion src/lib/middleware/yearn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import { AprFn } from "@/lib/config/metadataTypes";
import { optimism } from "viem/chains";
import { ALCHEMIST_FEE_MULTIPLIER } from "./common";

export const getYearnApy: AprFn = async ({
yieldTokenOverride,
Expand All @@ -24,5 +25,5 @@ export const getYearnApy: AprFn = async ({
? vaultData.apr.netAPR + vaultData.apr.extra.stakingRewardsAPR
: vaultData.apr.netAPR;

return value * 100 * 0.9;
return value * 100 * ALCHEMIST_FEE_MULTIPLIER;
};

0 comments on commit 48914b5

Please sign in to comment.