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
26 changes: 26 additions & 0 deletions migration/1773675740273-AddUserDataPhoneCallAccepted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* @typedef {import('typeorm').MigrationInterface} MigrationInterface
* @typedef {import('typeorm').QueryRunner} QueryRunner
*/

/**
* @class
* @implements {MigrationInterface}
*/
module.exports = class AddUserDataPhoneCallAccepted1773675740273 {
name = 'AddUserDataPhoneCallAccepted1773675740273'

/**
* @param {QueryRunner} queryRunner
*/
async up(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_data" ADD "phoneCallAccepted" bit`);
}

/**
* @param {QueryRunner} queryRunner
*/
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "user_data" DROP COLUMN "phoneCallAccepted"`);
}
}
16 changes: 16 additions & 0 deletions migration/1773700400000-AddEurBankPercentFee.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = class AddEurBankPercentFee1773700400000 {
name = 'AddEurBankPercentFee1773700400000';

async up(queryRunner) {
await queryRunner.query(`
INSERT INTO "dbo"."fee" ("label", "type", "rate", "fixed", "blockchainFactor", "payoutRefBonus", "active", "fiats")
VALUES ('Bank Fee EUR 0.5%', 'Bank', 0.005, 0, 1, 1, 1, '2')
`);
}

async down(queryRunner) {
await queryRunner.query(`
DELETE FROM "dbo"."fee" WHERE "label" = 'Bank Fee EUR 0.5%' AND "type" = 'Bank'
`);
}
};
2 changes: 1 addition & 1 deletion src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ export class Configuration {
}),
},
internetComputer: {
internetComputerHost: 'https://ic0.app',
internetComputerHost: 'https://icp-api.io',
internetComputerRosettaApiUrl: process.env.ICP_ROSETTA_API_URL ?? 'https://rosetta-api.internetcomputer.org',
internetComputerWalletSeed: process.env.ICP_WALLET_SEED,
internetComputerLedgerCanisterId: 'ryjl3-tyaaa-aaaaa-aaaba-cai',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export class BuyCryptoService {
}

async resetAmlCheck(id: number): Promise<void> {
const entity = await this.buyCryptoRepo.findOneBy({ id });
const entity = await this.buyCryptoRepo.findOne({ where: { id }, relations: { chargebackOutput: true } });
if (!entity) throw new NotFoundException('BuyCrypto not found');
if (entity.isComplete || entity.batch || entity.chargebackOutput?.isComplete)
throw new BadRequestException('BuyCrypto is already complete or payout initiated');
Expand Down
6 changes: 3 additions & 3 deletions src/subdomains/core/history/dto/transaction-refund.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export class CreditorDataDto {
}

export class TransactionRefundDto {
@ApiProperty({ description: 'Refund address or refund IBAN' })
@IsNotEmpty()
@ApiPropertyOptional({ description: 'Refund address or refund IBAN' })
@IsOptional()
@IsString()
@Transform(Util.trimAll)
@Transform(Util.sanitize)
refundTarget: string;
refundTarget?: string;

@ApiPropertyOptional({ description: 'Creditor data (required for bank refunds)' })
@IsOptional()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ export class TransactionDtoMapper {
entity.bankFeeAmount != null
? Util.roundReadable(entity.bankFeeAmount * referencePrice, feeAmountType(entity.inputAssetEntity))
: null,
bankFixed: null,
bankPercent: null,
fixed:
entity.absoluteFeeAmount != null
? Util.roundReadable(entity.absoluteFeeAmount * referencePrice, feeAmountType(entity.inputAssetEntity))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ export class UserData extends IEntity {
@Column({ length: 256, nullable: true })
phoneCallStatus: PhoneCallStatus;

@Column({ nullable: true })
phoneCallAccepted?: boolean;

@Column({ type: 'datetime2', nullable: true })
tradeApprovalDate?: Date;

Expand Down Expand Up @@ -507,11 +510,11 @@ export class UserData extends IEntity {
language: dto.language ?? this.language,
currency: dto.currency ?? this.currency,
phoneCallTimes: dto.preferredPhoneTimes ? dto.preferredPhoneTimes.join(';') : undefined,
phoneCallStatus: dto.acceptCall
? PhoneCallStatus.REPEAT
: dto.acceptCall === false
phoneCallStatus:
dto.acceptCall === false && (!this.phoneCallStatus || PhoneCallStatus.UNAVAILABLE === this.phoneCallStatus)
? PhoneCallStatus.USER_REJECTED
: undefined,
phoneCallAccepted: dto.acceptCall,
};

Object.assign(this, update);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export enum PhoneCallStatus {
FAILED = 'Failed',
COMPLETED = 'Completed',
SUSPICIOUS = 'Suspicious',
MANUAL_CHECK = 'ManualCheck',
}

export enum KycLevel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ import { Util } from 'src/shared/utils/util';
import { UserData } from '../../user-data/user-data.entity';
import { User } from '../user.entity';
import { UserProfileDto } from './user-profile.dto';
import { ReferralDto, UserAddressDto, UserV2Dto, VolumesDto } from './user-v2.dto';
import { PhoneCallStatusMapper } from './user.dto';
import { PhoneCallStatusMapper, ReferralDto, UserAddressDto, UserV2Dto, VolumesDto } from './user-v2.dto';

export class UserDtoMapper {
static mapUser(userData: UserData, activeUserId?: number): UserV2Dto {
Expand All @@ -29,6 +28,7 @@ export class UserDtoMapper {
hash: userData.kycHash,
level: userData.kycLevelDisplay,
dataComplete: userData.isDataComplete,
phoneCallAccepted: userData.phoneCallAccepted,
phoneCallStatus: userData.phoneCallStatus ? PhoneCallStatusMapper[userData.phoneCallStatus] : undefined,
preferredPhoneTimes: userData.phoneCallTimesObject,
},
Expand Down
27 changes: 24 additions & 3 deletions src/subdomains/generic/user/models/user/dto/user-v2.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,27 @@ import { FiatDto } from 'src/shared/models/fiat/dto/fiat.dto';
import { LanguageDto } from 'src/shared/models/language/dto/language.dto';
import { HistoryFilterKey } from 'src/subdomains/core/history/dto/history-filter.dto';
import { AccountType } from '../../user-data/account-type.enum';
import { KycLevel, PhoneCallPreferredTime } from '../../user-data/user-data.enum';
import { KycLevel, PhoneCallPreferredTime, PhoneCallStatus } from '../../user-data/user-data.enum';
import { RefPayoutFrequency } from '../user.enum';
import { TradingLimit, UserPhoneCallStatus, VolumeInformation } from './user.dto';
import { TradingLimit, VolumeInformation } from './user.dto';

export enum UserPhoneCallStatus {
UNAVAILABLE = 'Unavailable',
COMPLETED = 'Completed',
FAILED = 'Failed',
}

export const PhoneCallStatusMapper: {
[key in PhoneCallStatus]: UserPhoneCallStatus;
} = {
[PhoneCallStatus.REPEAT]: undefined,
[PhoneCallStatus.USER_REJECTED]: undefined,
[PhoneCallStatus.MANUAL_CHECK]: undefined,
[PhoneCallStatus.UNAVAILABLE]: UserPhoneCallStatus.UNAVAILABLE,
[PhoneCallStatus.FAILED]: UserPhoneCallStatus.FAILED,
[PhoneCallStatus.COMPLETED]: UserPhoneCallStatus.COMPLETED,
[PhoneCallStatus.SUSPICIOUS]: UserPhoneCallStatus.FAILED,
};

export class VolumesDto {
@ApiProperty({ type: VolumeInformation, description: 'Total buy volume in CHF' })
Expand Down Expand Up @@ -108,7 +126,10 @@ export class UserKycDto {
@ApiProperty({ enum: PhoneCallPreferredTime, isArray: true })
preferredPhoneTimes: PhoneCallPreferredTime[];

@ApiProperty({ enum: UserPhoneCallStatus })
@ApiPropertyOptional()
phoneCallAccepted: boolean;

@ApiPropertyOptional({ enum: UserPhoneCallStatus })
phoneCallStatus: UserPhoneCallStatus;
}

Expand Down
21 changes: 1 addition & 20 deletions src/subdomains/generic/user/models/user/dto/user.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,10 @@ import { Fiat } from 'src/shared/models/fiat/fiat.entity';
import { LanguageDto } from 'src/shared/models/language/dto/language.dto';
import { HistoryFilterKey } from 'src/subdomains/core/history/dto/history-filter.dto';
import { AccountType } from '../../user-data/account-type.enum';
import { KycLevel, KycState, KycStatus, LimitPeriod, PhoneCallStatus } from '../../user-data/user-data.enum';
import { KycLevel, KycState, KycStatus, LimitPeriod } from '../../user-data/user-data.enum';
import { UserStatus } from '../user.enum';
import { LinkedUserOutDto } from './linked-user.dto';

export enum UserPhoneCallStatus {
ACCEPTED = 'Accepted',
REJECTED = 'Rejected',
UNAVAILABLE = 'Unavailable',
COMPLETED = 'Completed',
FAILED = 'Failed',
}

export const PhoneCallStatusMapper: {
[key in PhoneCallStatus]: UserPhoneCallStatus;
} = {
[PhoneCallStatus.REPEAT]: UserPhoneCallStatus.ACCEPTED,
[PhoneCallStatus.USER_REJECTED]: UserPhoneCallStatus.REJECTED,
[PhoneCallStatus.UNAVAILABLE]: UserPhoneCallStatus.UNAVAILABLE,
[PhoneCallStatus.FAILED]: UserPhoneCallStatus.FAILED,
[PhoneCallStatus.COMPLETED]: UserPhoneCallStatus.COMPLETED,
[PhoneCallStatus.SUSPICIOUS]: UserPhoneCallStatus.FAILED,
};

export class VolumeInformation {
@ApiProperty()
total: number;
Expand Down
6 changes: 6 additions & 0 deletions src/subdomains/supporting/payment/dto/fee.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ export class FeeDto extends BaseFeeDto {
@ApiProperty({ description: 'Bank fee amount' })
bank: number; // final bank fee addition

@ApiPropertyOptional({ description: 'Bank fixed fee amount' })
bankFixed?: number;

@ApiPropertyOptional({ description: 'Bank percent fee amount' })
bankPercent?: number;

@ApiProperty({ description: 'Total fee amount (DFX + bank + network fee)' })
total: number;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ export class TransactionHelper implements OnModuleInit {

const sourceSpecs = await this.getSourceSpecs(fromReference, specs, PriceValidity.VALID_ONLY);

const { dfx, bank, total } = this.calculateTotalFee(
const { dfx, bank, bankFixed, bankPercent, total } = this.calculateTotalFee(
inputReferenceAmount,
fee.rate,
fee.bankRate,
Expand All @@ -246,6 +246,8 @@ export class TransactionHelper implements OnModuleInit {
total,
dfx,
bank,
bankFixed,
bankPercent,
};
}

Expand Down Expand Up @@ -823,6 +825,8 @@ export class TransactionHelper implements OnModuleInit {
dfx: this.convertFee(sourceFees.dfx, price, to),
total: this.convertFee(sourceFees.total, price, to),
bank: this.convertFee(sourceFees.bank, price, to),
bankFixed: this.convertFee(sourceFees.bankFixed, price, to),
bankPercent: this.convertFee(sourceFees.bankPercent, price, to),
};

return {
Expand Down Expand Up @@ -915,14 +919,17 @@ export class TransactionHelper implements OnModuleInit {
bankRate: number,
{ fee: { fixed, min, network, networkStart, bankFixed } }: TxSpec,
roundingActive: Active,
): { dfx: number; bank: number; total: number } {
const bank = amount * bankRate + bankFixed;
): { dfx: number; bank: number; bankFixed: number; bankPercent: number; total: number } {
const bankPercentAmount = amount * bankRate;
const bank = bankPercentAmount + bankFixed;
const dfx = Math.max(amount * rate + fixed, min);
const total = dfx + bank + network + (networkStart ?? 0);

return {
dfx: Util.roundReadable(dfx, feeAmountType(roundingActive)),
bank: Util.roundReadable(bank, feeAmountType(roundingActive)),
bankFixed: Util.roundReadable(bankFixed, feeAmountType(roundingActive)),
bankPercent: Util.roundReadable(bankPercentAmount, feeAmountType(roundingActive)),
total: Util.roundReadable(total, feeAmountType(roundingActive)),
};
}
Expand Down
Loading