From 61131388d5ad21d608df068ac7a08d1a60537af5 Mon Sep 17 00:00:00 2001 From: Kevsl Date: Fri, 14 Jun 2024 12:09:07 +0200 Subject: [PATCH] added token sell to bank --- src/crypto/crypto.service.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/crypto/crypto.service.ts b/src/crypto/crypto.service.ts index 62ae643..e772b4f 100644 --- a/src/crypto/crypto.service.ts +++ b/src/crypto/crypto.service.ts @@ -73,6 +73,15 @@ export class CryptoService { if (!userAsset || userAsset.amount < dto.amount) { throw new ForbiddenException(`Seller dont have enough asset`); } else { + await this.prisma.crypto.update({ + where: { + id: crypto.id, + }, + data: { + value: crypto.value * 0.9, + }, + }); + const newBalance = userAsset.amount - dto.amount; if (newBalance > 0) { await this.prisma.userHasCrypto.update({