Skip to content

Commit

Permalink
continuing the function
Browse files Browse the repository at this point in the history
  • Loading branch information
TheRanomial committed Feb 17, 2025
1 parent 6319507 commit 26669f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions apps/nestjs-indexer/src/services/buy-token/buy-token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class BuyTokenService {
const liquidityInQuoteToken = Number(newLiquidityRaised); // ETH liquidity that increases on buy, decreases on sell
const tokensInPool = Number(initPoolSupply); // Fixed token supply
// Memecoin per ETH
let priceBuy =
const priceBuy =
tokensInPool > 0 ? liquidityInQuoteToken / tokensInPool : 0;
// ETH per Memecoin
// let priceBuy = liquidityInQuoteToken > 0 && tokensInPool > 0 ? liquidityInQuoteToken / tokensInPool : 0;
Expand Down Expand Up @@ -90,15 +90,15 @@ export class BuyTokenService {
},
});

const newAmountOwned = sharesTokenUser
let newAmountOwned = sharesTokenUser
? Number(sharesTokenUser.amount_owned) + Number(data.amount)
: Number(data.amount);

if (newAmountOwned > newTotalTokenHolded) {
this.logger.error(
`Amount owned (${newAmountOwned}) exceeds total token held (${newTotalTokenHolded})`,
this.logger.warn(
`Amount owned (${newAmountOwned}) exceeds total token held (${newTotalTokenHolded}). Adjusting amount owned to total token held.`,
);
throw new Error('Amount owned exceeds total token held');
newAmountOwned = newTotalTokenHolded;
}

await prisma.shares_token_user.upsert({
Expand Down

0 comments on commit 26669f2

Please sign in to comment.