diff --git a/src/config/config.ts b/src/config/config.ts index 189b2dec37..050cef6819 100644 --- a/src/config/config.ts +++ b/src/config/config.ts @@ -210,6 +210,15 @@ export class Configuration { USD: 1, }, }, + minTransactionVolume: { + // outputAsset: { minTransactionAsset: minTransactionVolume } + USD: { + USD: 1000, + }, + default: { + USD: 1, + }, + }, }, ethereum: { ethWalletAddress: process.env.ETH_WALLET_ADDRESS, diff --git a/src/payment/models/crypto-route/crypto-route.controller.ts b/src/payment/models/crypto-route/crypto-route.controller.ts index d61a8ddf10..3f9bca0996 100644 --- a/src/payment/models/crypto-route/crypto-route.controller.ts +++ b/src/payment/models/crypto-route/crypto-route.controller.ts @@ -138,7 +138,7 @@ export class CryptoRouteController { case Blockchain.BITCOIN: return Util.transformToMinDeposit(Config.blockchain.default.minDeposit.Bitcoin); case Blockchain.DEFICHAIN: - return Util.transformToMinDeposit(Config.blockchain.default.minDeposit.DeFiChain); + return Util.transformToMinDeposit(Config.blockchain.default.minDeposit.DeFiChain, 'USD'); } } diff --git a/src/payment/models/sell/sell.controller.ts b/src/payment/models/sell/sell.controller.ts index 98500d80ff..a03bc720b6 100644 --- a/src/payment/models/sell/sell.controller.ts +++ b/src/payment/models/sell/sell.controller.ts @@ -17,6 +17,7 @@ import { Config } from 'src/config/config'; import { Util } from 'src/shared/util'; import { GetSellPaymentInfoDto } from './dto/get-sell-payment-info.dto'; import { SellPaymentInfoDto } from './dto/sell-payment-info.dto'; +import { MinDeposit } from '../deposit/dto/min-deposit.dto'; @ApiTags('sell') @Controller('sell') @@ -84,7 +85,7 @@ export class SellController { ...sell, fee, isInUse: sellDepositsInUse.includes(sell.deposit.id), - minDeposits: Util.transformToMinDeposit(Config.blockchain.default.minDeposit.DeFiChain), + minDeposits: this.getMinDeposit(sell.fiat.name), }; } @@ -92,7 +93,7 @@ export class SellController { return { fee: await this.getFee(userId), depositAddress: sell.deposit.address, - minDeposits: Util.transformToMinDeposit(Config.blockchain.default.minDeposit.DeFiChain), + minDeposits: this.getMinDeposit(sell.fiat.name), }; } @@ -100,4 +101,12 @@ export class SellController { async getFee(userId: number): Promise { return this.userService.getUserSellFee(userId); } + + private getMinDeposit(outputAsset: string): MinDeposit[] { + const minVolume = Object.entries(Config.blockchain.default.minTransactionVolume) + .filter(([key, _]) => key === outputAsset) + .map(([_, value]) => value); + + return Util.transformToMinDeposit(minVolume[0] ?? Config.blockchain.default.minTransactionVolume.default); + } }