Skip to content

Commit

Permalink
Merge pull request #257 from metaDAOproject/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
LukasDeco authored Aug 21, 2024
2 parents 5047132 + 3727593 commit 2d0d9b2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions packages/indexer/src/indexers/jupiter/jupiter-quotes-indexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ const convertJupTokenPrice = (

const convertJupBaseOutTokenPrice = (
data: JupTokenQuoteRes,
inputTokenDecimals: number,
outputTokenDecimals: number
quoteTokenDecimals: number,
baseTokenDecimals: number
): number => {
const inPrice = Number(data.inAmount ?? "0") / 10 ** inputTokenDecimals;
const outPrice = Number(data.outAmount ?? "0") / 10 ** outputTokenDecimals;
const inPrice = Number(data.inAmount ?? "0") / 10 ** quoteTokenDecimals;
const outPrice = Number(data.outAmount ?? "0") / 10 ** baseTokenDecimals;
return inPrice / outPrice;
};

Expand Down Expand Up @@ -174,10 +174,17 @@ export const fetchQuoteFromJupe = async (

const bidPrice = convertJupBaseOutTokenPrice(
bidJson,
baseToken[0].decimals,
quoteToken[0].decimals
quoteToken[0].decimals,
baseToken[0].decimals
);

if (!askPrice) {
return [bidPrice, askJson.contextSlot];
}
if (!bidPrice) {
return [askPrice, askJson.contextSlot];
}

// Calculate the mid-price
const midPrice = (askPrice + bidPrice) / 2;

Expand Down

0 comments on commit 2d0d9b2

Please sign in to comment.