Skip to content

Commit e605e84

Browse files
authored
Merge pull request #3143 from DFXswiss/develop
Release: develop -> main
2 parents 355eef4 + a7dec73 commit e605e84

5 files changed

Lines changed: 24 additions & 18 deletions

File tree

src/subdomains/core/custody/services/custody.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, NotFoundException } from '@nestjs/common';
1+
import { forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
22
import { Config } from 'src/config/config';
33
import { EvmUtil } from 'src/integration/blockchain/shared/evm/evm.util';
44
import { UserRole } from 'src/shared/auth/user-role.enum';
@@ -32,10 +32,10 @@ interface CustodyOrderSingle {
3232
export class CustodyService {
3333
constructor(
3434
private readonly userService: UserService,
35-
private readonly userDataService: UserDataService,
35+
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
3636
private readonly walletService: WalletService,
3737
private readonly refService: RefService,
38-
private readonly authService: AuthService,
38+
@Inject(forwardRef(() => AuthService)) private readonly authService: AuthService,
3939
private readonly custodyOrderRepo: CustodyOrderRepository,
4040
private readonly custodyBalanceRepo: CustodyBalanceRepository,
4141
private readonly assetPricesService: AssetPricesService,

src/subdomains/generic/kyc/services/kyc-admin.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Injectable, NotFoundException } from '@nestjs/common';
1+
import { forwardRef, Inject, Injectable, NotFoundException } from '@nestjs/common';
22
import { UpdateResult } from 'src/shared/models/entity';
33
import { DfxLogger } from 'src/shared/services/dfx-logger';
44
import { FindOptionsRelations } from 'typeorm';
@@ -27,7 +27,7 @@ export class KycAdminService {
2727
private readonly webhookService: WebhookService,
2828
private readonly kycService: KycService,
2929
private readonly kycNotificationService: KycNotificationService,
30-
private readonly userDataService: UserDataService,
30+
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
3131
) {}
3232

3333
async getKycSteps(userDataId: number, relations: FindOptionsRelations<KycStep> = {}): Promise<KycStep[]> {

src/subdomains/generic/user/models/auth/auth.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ export class AuthService {
8181
private readonly cryptoService: CryptoService,
8282
private readonly refService: RefService,
8383
private readonly feeService: FeeService,
84-
private readonly userDataService: UserDataService,
84+
@Inject(forwardRef(() => UserDataService)) private readonly userDataService: UserDataService,
8585
private readonly notificationService: NotificationService,
8686
private readonly ipLogService: IpLogService,
8787
private readonly siftService: SiftService,
8888
private readonly languageService: LanguageService,
8989
private readonly geoLocationService: GeoLocationService,
9090
private readonly settingService: SettingService,
9191
private readonly recommendationService: RecommendationService,
92-
private readonly kycAdminService: KycAdminService,
92+
@Inject(forwardRef(() => KycAdminService)) private readonly kycAdminService: KycAdminService,
9393
@Inject(forwardRef(() => KycService)) private readonly kycService: KycService,
9494
) {}
9595

src/subdomains/supporting/payment/services/transaction-request.service.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ import { GetSellPaymentInfoDto } from 'src/subdomains/core/sell-crypto/route/dto
2020
import { SellPaymentInfoDto } from 'src/subdomains/core/sell-crypto/route/dto/sell-payment-info.dto';
2121
import { SellService } from 'src/subdomains/core/sell-crypto/route/sell.service';
2222
import { Between, FindOptionsRelations, In, IsNull, LessThan, MoreThan } from 'typeorm';
23+
import { CustodyOrder } from '../../../core/custody/entities/custody-order.entity';
24+
import { CustodyOrderStatus } from '../../../core/custody/enums/custody';
2325
import { Deposit } from '../../address-pool/deposit/deposit.entity';
2426
import { DepositRoute } from '../../address-pool/route/deposit-route.entity';
2527
import { CryptoPaymentMethod, FiatPaymentMethod } from '../dto/payment-method.enum';
@@ -335,9 +337,13 @@ export class TransactionRequestService {
335337
.distinct()
336338
.innerJoin(DepositRoute, 'dr', 'tr.routeId = dr.id')
337339
.innerJoin(Deposit, 'd', 'dr.depositId = d.id')
340+
.leftJoin(CustodyOrder, 'co', 'co.transactionRequestId = tr.id')
338341
.where('tr.type IN (:...types)', { types: [TransactionRequestType.SELL, TransactionRequestType.SWAP] })
339-
.andWhere('tr.status = :status', { status: TransactionRequestStatus.CREATED })
340-
.andWhere('tr.created > :created', { created })
342+
.andWhere('tr.status = :trStatus', { trStatus: TransactionRequestStatus.CREATED })
343+
.andWhere('(tr.created > :created OR co.status = :coStatus)', {
344+
created,
345+
coStatus: CustodyOrderStatus.IN_PROGRESS,
346+
})
341347
.andWhere('d.blockchains LIKE :blockchain', { blockchain: `%${blockchain}%` })
342348
.getRawMany<{ address: string }>()
343349
.then((transactionRequests) => transactionRequests.map((deposit) => deposit.address));

src/subdomains/supporting/realunit/realunit.service.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,24 +214,24 @@ export class RealUnitService {
214214
throw new RegistrationRequiredException();
215215
}
216216

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

224-
const maxAmountForLevel20 = Config.tradingLimits.monthlyDefaultWoKyc;
225-
const requiresLevel50 = amountChf > maxAmountForLevel20;
226-
const requiredLevel = requiresLevel50 ? KycLevel.LEVEL_50 : KycLevel.LEVEL_20;
224+
const maxAmountForLevel30 = Config.tradingLimits.monthlyDefaultWoKyc;
225+
const requiresLevel50 = amountChf > maxAmountForLevel30;
226+
const requiredLevel = requiresLevel50 ? KycLevel.LEVEL_50 : KycLevel.LEVEL_30;
227227

228228
if (userData.kycLevel < requiredLevel) {
229229
throw new KycLevelRequiredException(
230230
requiredLevel,
231231
userData.kycLevel,
232232
requiresLevel50
233-
? `KYC Level 50 required for amounts above ${maxAmountForLevel20} CHF`
234-
: 'KYC Level 20 required for RealUnit',
233+
? `KYC Level 50 required for amounts above ${maxAmountForLevel30} CHF`
234+
: 'KYC Level 30 required for RealUnit',
235235
);
236236
}
237237

@@ -678,10 +678,10 @@ export class RealUnitService {
678678
throw new RegistrationRequiredException();
679679
}
680680

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

687687
// 3. Get REALU asset

0 commit comments

Comments
 (0)