From bdaffb2489d694dec2fa8dec760d65a880a0b618 Mon Sep 17 00:00:00 2001 From: suk-6 Date: Thu, 26 Sep 2024 20:39:08 +0900 Subject: [PATCH] fix: Update product price calculation in ProductService --- src/modules/product/product.service.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/modules/product/product.service.ts b/src/modules/product/product.service.ts index 62791ad..171270b 100644 --- a/src/modules/product/product.service.ts +++ b/src/modules/product/product.service.ts @@ -28,7 +28,11 @@ export class ProductService { S3_PUBLIC_URL: string; }>, ) { - this.updateProductPrice('324fefab-fdd3-4a64-8a90-e6cb94b19b41'); + this.getProducts('FUNDING').then((products) => { + products.forEach((product) => { + this.updateProductPrice(product.id); + }); + }); } async createProduct(userId: string, dto: CreateProductDTO) { @@ -670,6 +674,7 @@ export class ProductService { const D = product.fundingLog.filter((log) => log.type === FundingType.DEPOSIT).length; // 매수 요청 const S = product.fundingLog.filter((log) => log.type === FundingType.WITHDRAW).length; // 매도 요청 const L = 1000 - (await this.blockchain.getRemainingTokens(product.tokenAddress)); // 시장에 풀린 토큰 + if (L === 0) return; const newPrice = product.startAmount * (1 + 0.05 * ((D - S) / (S + L)));