Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/subdomains/core/custody/services/custody.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
import { Config } from 'src/config/config';
import { EvmUtil } from 'src/integration/blockchain/shared/evm/evm.util';
import { UserRole } from 'src/shared/auth/user-role.enum';
Expand Down Expand Up @@ -32,10 +32,10 @@ interface CustodyOrderSingle {
export class CustodyService {
constructor(
private readonly userService: UserService,
private readonly userDataService: UserDataService,
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
private readonly walletService: WalletService,
private readonly refService: RefService,
private readonly authService: AuthService,
@Inject(forwardRef(() => AuthService)) private readonly authService: AuthService,
private readonly custodyOrderRepo: CustodyOrderRepository,
private readonly custodyBalanceRepo: CustodyBalanceRepository,
private readonly assetPricesService: AssetPricesService,
Expand Down
4 changes: 2 additions & 2 deletions src/subdomains/generic/kyc/services/kyc-admin.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, NotFoundException } from '@nestjs/common';
import { forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
import { UpdateResult } from 'src/shared/models/entity';
import { DfxLogger } from 'src/shared/services/dfx-logger';
import { FindOptionsRelations } from 'typeorm';
Expand Down Expand Up @@ -27,7 +27,7 @@ export class KycAdminService {
private readonly webhookService: WebhookService,
private readonly kycService: KycService,
private readonly kycNotificationService: KycNotificationService,
private readonly userDataService: UserDataService,
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
) {}

async getKycSteps(userDataId: number, relations: FindOptionsRelations<KycStep> = {}): Promise<KycStep[]> {
Expand Down
4 changes: 2 additions & 2 deletions src/subdomains/generic/user/models/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export class AuthService {
private readonly cryptoService: CryptoService,
private readonly refService: RefService,
private readonly feeService: FeeService,
private readonly userDataService: UserDataService,
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
private readonly notificationService: NotificationService,
private readonly ipLogService: IpLogService,
private readonly siftService: SiftService,
private readonly languageService: LanguageService,
private readonly geoLocationService: GeoLocationService,
private readonly settingService: SettingService,
private readonly recommendationService: RecommendationService,
private readonly kycAdminService: KycAdminService,
@Inject(forwardRef(() => KycAdminService)) private readonly kycAdminService: KycAdminService,
@Inject(forwardRef(() => KycService)) private readonly kycService: KycService,
) {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import { GetSellPaymentInfoDto } from 'src/subdomains/core/sell-crypto/route/dto
import { SellPaymentInfoDto } from 'src/subdomains/core/sell-crypto/route/dto/sell-payment-info.dto';
import { SellService } from 'src/subdomains/core/sell-crypto/route/sell.service';
import { Between, FindOptionsRelations, In, IsNull, LessThan, MoreThan } from 'typeorm';
import { CustodyOrder } from '../../../core/custody/entities/custody-order.entity';
import { CustodyOrderStatus } from '../../../core/custody/enums/custody';
import { Deposit } from '../../address-pool/deposit/deposit.entity';
import { DepositRoute } from '../../address-pool/route/deposit-route.entity';
import { CryptoPaymentMethod, FiatPaymentMethod } from '../dto/payment-method.enum';
Expand Down Expand Up @@ -335,9 +337,13 @@ export class TransactionRequestService {
.distinct()
.innerJoin(DepositRoute, 'dr', 'tr.routeId = dr.id')
.innerJoin(Deposit, 'd', 'dr.depositId = d.id')
.leftJoin(CustodyOrder, 'co', 'co.transactionRequestId = tr.id')
.where('tr.type IN (:...types)', { types: [TransactionRequestType.SELL, TransactionRequestType.SWAP] })
.andWhere('tr.status = :status', { status: TransactionRequestStatus.CREATED })
.andWhere('tr.created > :created', { created })
.andWhere('tr.status = :trStatus', { trStatus: TransactionRequestStatus.CREATED })
.andWhere('(tr.created > :created OR co.status = :coStatus)', {
created,
coStatus: CustodyOrderStatus.IN_PROGRESS,
})
.andWhere('d.blockchains LIKE :blockchain', { blockchain: `%${blockchain}%` })
.getRawMany<{ address: string }>()
.then((transactionRequests) => transactionRequests.map((deposit) => deposit.address));
Expand Down
18 changes: 9 additions & 9 deletions src/subdomains/supporting/realunit/realunit.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,24 @@ export class RealUnitService {
throw new RegistrationRequiredException();
}

// 2. KYC Level check - Level 20 for amounts <= 1000 CHF, Level 50 for higher amounts
// 2. KYC Level check - Level 30 for amounts <= 1000 CHF, Level 50 for higher amounts
const currency = await this.fiatService.getFiatByName(currencyName);
const amountChf =
currencyName === 'CHF'
? dto.amount
: (await this.pricingService.getPrice(currency, PriceCurrency.CHF, PriceValidity.ANY)).convert(dto.amount);

const maxAmountForLevel20 = Config.tradingLimits.monthlyDefaultWoKyc;
const requiresLevel50 = amountChf > maxAmountForLevel20;
const requiredLevel = requiresLevel50 ? KycLevel.LEVEL_50 : KycLevel.LEVEL_20;
const maxAmountForLevel30 = Config.tradingLimits.monthlyDefaultWoKyc;
const requiresLevel50 = amountChf > maxAmountForLevel30;
const requiredLevel = requiresLevel50 ? KycLevel.LEVEL_50 : KycLevel.LEVEL_30;

if (userData.kycLevel < requiredLevel) {
throw new KycLevelRequiredException(
requiredLevel,
userData.kycLevel,
requiresLevel50
? `KYC Level 50 required for amounts above ${maxAmountForLevel20} CHF`
: 'KYC Level 20 required for RealUnit',
? `KYC Level 50 required for amounts above ${maxAmountForLevel30} CHF`
: 'KYC Level 30 required for RealUnit',
);
}

Expand Down Expand Up @@ -678,10 +678,10 @@ export class RealUnitService {
throw new RegistrationRequiredException();
}

// 2. KYC Level check - Level 20 minimum
const requiredLevel = KycLevel.LEVEL_20;
// 2. KYC Level check - Level 30 minimum
const requiredLevel = KycLevel.LEVEL_30;
if (userData.kycLevel < requiredLevel) {
throw new KycLevelRequiredException(requiredLevel, userData.kycLevel, 'KYC Level 20 required for RealUnit sell');
throw new KycLevelRequiredException(requiredLevel, userData.kycLevel, 'KYC Level 30 required for RealUnit sell');
}

// 3. Get REALU asset
Expand Down
Loading