Skip to content

Commit

Permalink
Merge pull request #259 from metaDAOproject/staging
Browse files Browse the repository at this point in the history
Deploy Production
  • Loading branch information
LukasDeco authored Aug 23, 2024
2 parents 2d0d9b2 + b9d9d7e commit 139fcf7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/indexer/src/builders/swaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ export class SwapBuilder {
const userQuotePostBalance =
userQuoteAcctWithBalances?.postTokenBalance?.amount;

//TODO you need to populate post and prebalance here based on the txn balances perhaps...
const baseAmount = new BN(
(userBasePostBalance ?? BigInt(0)) - (userBasePreBalance ?? BigInt(0))
).abs();
Expand Down Expand Up @@ -244,9 +243,10 @@ export class SwapBuilder {
return Err({ type: AmmInstructionIndexerError.MissingMarket });
}

const ammPrice = quoteAmount
.mul(new BN(10).pow(new BN(12)))
.div(baseAmount);
const ammPrice =
quoteAmount && baseAmount
? quoteAmount.mul(new BN(10).pow(new BN(12))).div(baseAmount)
: 0;
const price = getHumanPrice(
ammPrice,
baseToken[0].decimals,
Expand Down

0 comments on commit 139fcf7

Please sign in to comment.