added token sell to bank

This commit is contained in:
Kevsl 2024-06-14 12:09:07 +02:00
parent bbde4a2ec5
commit 61131388d5

View File

@ -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({