diff --git a/src/crypto/crypto.service.ts b/src/crypto/crypto.service.ts index ba5a4ad..ef9c67d 100644 --- a/src/crypto/crypto.service.ts +++ b/src/crypto/crypto.service.ts @@ -74,6 +74,7 @@ export class CryptoService { id_crypto: dto.id_crypto, }, }); + const newCryptoValue = crypto.value * 0.9; if (!userAsset || userAsset.amount < dto.amount) { throw new ForbiddenException(`Seller dont have enough asset`); } else { @@ -82,7 +83,7 @@ export class CryptoService { id: crypto.id, }, data: { - value: crypto.value * 0.9, + value: newCryptoValue, }, }); @@ -97,6 +98,12 @@ export class CryptoService { dollarAvailables: newBalanceSeller, }, }); + await this.prisma.cryptoHistory.create({ + data: { + id_crypto: crypto.id, + value: newCryptoValue, + }, + }); const newBalance = userAsset.amount - dto.amount; if (newBalance > 0) { return this.prisma.userHasCrypto.update({