Skip to content

Commit

Permalink
Merge pull request #7 from beefyfinance/chore/harvest-price-processing
Browse files Browse the repository at this point in the history
Present pre processed harvest price values
  • Loading branch information
seguido authored May 22, 2024
2 parents a384d1b + 90e256a commit a9adbc3
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/routes/v1/vault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { sdk } from '../../utils/sdk';
import { getPeriodSeconds, Period, periodSchema } from '../../schema/period';
import { chainSchema } from '../../schema/chain';
import { bigintSchema } from '../../schema/bigint';
import { interpretAsDecimal } from '../../utils/decimal';

export default async function (
instance: FastifyInstance,
Expand Down Expand Up @@ -211,7 +212,20 @@ const getVaultHarvests = async (chain: ChainId, vault_address: string) => {
return undefined;
}

return res.beefyCLVaultHarvestEvents;
return res.beefyCLVaultHarvestEvents.map(harvest => {
const token0ToNativePrice = interpretAsDecimal(harvest.token0ToNativePrice, 18);
const token1ToNativePrice = interpretAsDecimal(harvest.token1ToNativePrice, 18);
const nativeToUsd = interpretAsDecimal(harvest.nativeToUSDPrice, 18);

return {
timestamp: harvest.timestamp,
compoundedAmount0: harvest.compoundedAmount0,
compoundedAmount1: harvest.compoundedAmount1,
token0ToUsd: token0ToNativePrice.mul(nativeToUsd).toString(),
token1ToUsd: token1ToNativePrice.mul(nativeToUsd).toString(),
totalSupply: harvest.totalSupply,
};
});
};

const getVaultHistoricPrices = async (
Expand Down

0 comments on commit a9adbc3

Please sign in to comment.