Skip to content

Commit

Permalink
fix: ask service error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungGwan123 authored and SeongHyeon0409 committed Dec 5, 2024
1 parent 600babd commit 6a93b55
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions packages/server/src/trade/trade-ask.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class AskService extends TradeAskBidService implements OnModuleInit {

for (const order of orderbook) {
if (order.bid_price < askDto.receivedPrice) break;
await this.executeTransaction(async (queryRunner) => {
const tradeResult = await this.executeTransaction(async (queryRunner) => {
const remainingQuantity = await this.executeAskTrade(
askDto,
order,
Expand All @@ -183,6 +183,7 @@ export class AskService extends TradeAskBidService implements OnModuleInit {

return !isMinimumQuantity(remainingQuantity);
});
if (!tradeResult) break;
}
} catch (error) {
if (error instanceof TradeNotFoundException) {
Expand Down Expand Up @@ -244,15 +245,13 @@ export class AskService extends TradeAskBidService implements OnModuleInit {
buyData.assetName = buyData.tradeCurrency;
buyData.tradeCurrency = assetName;

await Promise.all([
this.tradeHistoryRepository.createTradeHistory(
user,
buyData,
queryRunner,
),
this.processAssetUpdate(asset, buyData, queryRunner),
this.updateAccountBalances(askDto, buyData, queryRunner),
]);
await this.tradeHistoryRepository.createTradeHistory(
user,
buyData,
queryRunner,
)
await this.processAssetUpdate(asset, buyData, queryRunner)
await this.updateAccountBalances(askDto, buyData, queryRunner)

return await this.updateTradeData(tradeData, buyData, queryRunner);
}
Expand Down

0 comments on commit 6a93b55

Please sign in to comment.