fix to APR calc to 90 days

This commit is contained in:
Finn 2024-04-09 17:09:43 +01:00
parent eb3d1a08c5
commit 73864ee27b
2 changed files with 6 additions and 6 deletions

View File

@ -154,7 +154,7 @@ export const fetchSwapChartPrices = async (
daysToShow: string,
) => {
if (!inputMint || !outputMint) return []
const interval = daysToShow === '1' ? '30m' : daysToShow === '7' ? '1H' : '4H'
const interval = daysToShow === '1' ? '30m' : daysToShow === '7' ? '1H' : '1D'
const queryEnd = Math.floor(Date.now() / 1000)
const queryStart = queryEnd - parseInt(daysToShow) * DAILY_SECONDS
const inputQuery = `defi/history_price?address=${inputMint}&address_type=token&type=${interval}&time_from=${queryStart}&time_to=${queryEnd}`

View File

@ -9,7 +9,7 @@ const fetchRates = async () => {
).map((t) => {
const isUsdcBorrow = t.name === 'JLP' || t.name === 'USDC'
const outputMint = isUsdcBorrow ? USDC_MINT : SOL_MINT
return fetchSwapChartPrices(t.mint_address, outputMint, '30')
return fetchSwapChartPrices(t.mint_address, outputMint, '90')
})
const [jlpPrices, msolPrices, jitoPrices, bsolPrices] =
await Promise.all(promises)
@ -27,22 +27,22 @@ const fetchRates = async () => {
const rateData: Record<string, number> = {}
if (jlpPrices && jlpPrices?.length > 1) {
rateData.jlp =
(12 * (jlpPrices[jlpPrices.length - 2].price - jlpPrices[0].price)) /
(4 * (jlpPrices[jlpPrices.length - 2].price - jlpPrices[0].price)) /
jlpPrices[0].price
}
if (msolPrices && msolPrices?.length > 1) {
rateData.msol =
(12 * (msolPrices[msolPrices.length - 2].price - msolPrices[0].price)) /
(4 * (msolPrices[msolPrices.length - 2].price - msolPrices[0].price)) /
msolPrices[0].price
}
if (jitoPrices && jitoPrices?.length > 1) {
rateData.jitosol =
(12 * (jitoPrices[jitoPrices.length - 2].price - jitoPrices[0].price)) /
(4 * (jitoPrices[jitoPrices.length - 2].price - jitoPrices[0].price)) /
jitoPrices[0].price
}
if (bsolPrices && bsolPrices?.length > 1) {
rateData.bsol =
(12 * (bsolPrices[bsolPrices.length - 2].price - bsolPrices[0].price)) /
(4 * (bsolPrices[bsolPrices.length - 2].price - bsolPrices[0].price)) /
bsolPrices[0].price
}