Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Staging #257

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading