use birdeye for prices
This commit is contained in:
parent
f477fd1d45
commit
44fc32c311
|
@ -66,6 +66,7 @@ export async function computePriceImpactOnJup(
|
|||
|
||||
try {
|
||||
const res = await response.json();
|
||||
|
||||
if (res['data'] && res.data.length > 0 && res.data[0].outAmount) {
|
||||
return {
|
||||
outAmount: parseFloat(res.data[0].outAmount),
|
||||
|
@ -91,12 +92,16 @@ export async function getOnChainPriceForMints(
|
|||
): Promise<number[]> {
|
||||
return await Promise.all(
|
||||
mints.map(async (mint) => {
|
||||
let data = await (
|
||||
const resp = await (
|
||||
await buildFetch()
|
||||
)(`https://price.jup.ag/v4/price?ids=${mint}`, { mode: 'no-cors' });
|
||||
data = await data.json();
|
||||
data = data['data'];
|
||||
return data[mint]['price'];
|
||||
)(`https://public-api.birdeye.so/public/price?address=${mint}`, {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
const data = await resp.json();
|
||||
return data?.data?.value;
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
@ -232,7 +237,8 @@ export async function getPriceImpactForLiqor(
|
|||
}, ZERO_I80F48());
|
||||
|
||||
const [pi1, pi2] = await Promise.all([
|
||||
!liabsInUsdc.eq(ZERO_I80F48())
|
||||
!liabsInUsdc.eq(ZERO_I80F48()) &&
|
||||
usdcMint.toBase58() !== bank.mint.toBase58()
|
||||
? computePriceImpactOnJup(
|
||||
liabsInUsdc.toString(),
|
||||
usdcMint.toBase58(),
|
||||
|
@ -240,7 +246,8 @@ export async function getPriceImpactForLiqor(
|
|||
)
|
||||
: Promise.resolve({ priceImpactPct: 0, outAmount: 0 }),
|
||||
|
||||
!assets.eq(ZERO_I80F48())
|
||||
!assets.eq(ZERO_I80F48()) &&
|
||||
usdcMint.toBase58() !== bank.mint.toBase58()
|
||||
? computePriceImpactOnJup(
|
||||
assets.floor().toString(),
|
||||
bank.mint.toBase58(),
|
||||
|
|
Loading…
Reference in New Issue