mirror of
https://github.com/Kevsl/crypto-exchange-api.git
synced 2025-07-09 06:00:12 +02:00
added token sell to bank
This commit is contained in:
parent
bbde4a2ec5
commit
61131388d5
@ -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({
|
||||
|
Loading…
x
Reference in New Issue
Block a user