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
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'
`);
}
};
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
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