fix to APR calc to 90 days
This commit is contained in:
parent
eb3d1a08c5
commit
73864ee27b
|
@ -154,7 +154,7 @@ export const fetchSwapChartPrices = async (
|
||||||
daysToShow: string,
|
daysToShow: string,
|
||||||
) => {
|
) => {
|
||||||
if (!inputMint || !outputMint) return []
|
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 queryEnd = Math.floor(Date.now() / 1000)
|
||||||
const queryStart = queryEnd - parseInt(daysToShow) * DAILY_SECONDS
|
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}`
|
const inputQuery = `defi/history_price?address=${inputMint}&address_type=token&type=${interval}&time_from=${queryStart}&time_to=${queryEnd}`
|
||||||
|
|
|
@ -9,7 +9,7 @@ const fetchRates = async () => {
|
||||||
).map((t) => {
|
).map((t) => {
|
||||||
const isUsdcBorrow = t.name === 'JLP' || t.name === 'USDC'
|
const isUsdcBorrow = t.name === 'JLP' || t.name === 'USDC'
|
||||||
const outputMint = isUsdcBorrow ? USDC_MINT : SOL_MINT
|
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] =
|
const [jlpPrices, msolPrices, jitoPrices, bsolPrices] =
|
||||||
await Promise.all(promises)
|
await Promise.all(promises)
|
||||||
|
@ -27,22 +27,22 @@ const fetchRates = async () => {
|
||||||
const rateData: Record<string, number> = {}
|
const rateData: Record<string, number> = {}
|
||||||
if (jlpPrices && jlpPrices?.length > 1) {
|
if (jlpPrices && jlpPrices?.length > 1) {
|
||||||
rateData.jlp =
|
rateData.jlp =
|
||||||
(12 * (jlpPrices[jlpPrices.length - 2].price - jlpPrices[0].price)) /
|
(4 * (jlpPrices[jlpPrices.length - 2].price - jlpPrices[0].price)) /
|
||||||
jlpPrices[0].price
|
jlpPrices[0].price
|
||||||
}
|
}
|
||||||
if (msolPrices && msolPrices?.length > 1) {
|
if (msolPrices && msolPrices?.length > 1) {
|
||||||
rateData.msol =
|
rateData.msol =
|
||||||
(12 * (msolPrices[msolPrices.length - 2].price - msolPrices[0].price)) /
|
(4 * (msolPrices[msolPrices.length - 2].price - msolPrices[0].price)) /
|
||||||
msolPrices[0].price
|
msolPrices[0].price
|
||||||
}
|
}
|
||||||
if (jitoPrices && jitoPrices?.length > 1) {
|
if (jitoPrices && jitoPrices?.length > 1) {
|
||||||
rateData.jitosol =
|
rateData.jitosol =
|
||||||
(12 * (jitoPrices[jitoPrices.length - 2].price - jitoPrices[0].price)) /
|
(4 * (jitoPrices[jitoPrices.length - 2].price - jitoPrices[0].price)) /
|
||||||
jitoPrices[0].price
|
jitoPrices[0].price
|
||||||
}
|
}
|
||||||
if (bsolPrices && bsolPrices?.length > 1) {
|
if (bsolPrices && bsolPrices?.length > 1) {
|
||||||
rateData.bsol =
|
rateData.bsol =
|
||||||
(12 * (bsolPrices[bsolPrices.length - 2].price - bsolPrices[0].price)) /
|
(4 * (bsolPrices[bsolPrices.length - 2].price - bsolPrices[0].price)) /
|
||||||
bsolPrices[0].price
|
bsolPrices[0].price
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue