From 1513c560382423b0ef2d889db2029c4af9e3881c Mon Sep 17 00:00:00 2001 From: fmrsabino <3332770+fmrsabino@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:16:01 +0100 Subject: [PATCH 1/2] Rename surplusLabel to feeLabel - Renames the `surplusLabel` of a `FulfilledSwapOrderTransactionInfo` to a `feeLabel` (to better represent the value that the field holds). - Improves the description of the field. --- .../transactions/entities/swap-order-info.entity.ts | 8 ++++---- .../transactions/mappers/common/swap-order.mapper.ts | 11 ++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/routes/transactions/entities/swap-order-info.entity.ts b/src/routes/transactions/entities/swap-order-info.entity.ts index 805dad971e..f261757596 100644 --- a/src/routes/transactions/entities/swap-order-info.entity.ts +++ b/src/routes/transactions/entities/swap-order-info.entity.ts @@ -95,9 +95,9 @@ export class FulfilledSwapOrderTransactionInfo extends SwapOrderTransactionInfo type: String, nullable: true, description: - 'The surplus label is in the format of "$executedSurplusFee $tokenSymbol"', + 'The amount of fees paid for this order in the format of "$feeAmount $tokenSymbol"', }) - surplusLabel: string | null; + feeLabel: string | null; @ApiProperty({ description: @@ -111,14 +111,14 @@ export class FulfilledSwapOrderTransactionInfo extends SwapOrderTransactionInfo sellToken: TokenInfo; buyToken: TokenInfo; expiresTimestamp: number; - surplusFeeLabel: string | null; + feeLabel: string | null; executionPriceLabel: string; filledPercentage: string; explorerUrl: URL; }) { super({ ...args, status: 'fulfilled' }); this.status = 'fulfilled'; - this.surplusLabel = args.surplusFeeLabel; + this.feeLabel = args.feeLabel; this.executionPriceLabel = args.executionPriceLabel; } } diff --git a/src/routes/transactions/mappers/common/swap-order.mapper.ts b/src/routes/transactions/mappers/common/swap-order.mapper.ts index b59ce0f688..a4114a6a1f 100644 --- a/src/routes/transactions/mappers/common/swap-order.mapper.ts +++ b/src/routes/transactions/mappers/common/swap-order.mapper.ts @@ -182,11 +182,8 @@ export class SwapOrderMapper { if (args.order.kind === 'unknown') { throw new Error('Unknown order kind'); } - const surplusFeeLabel: string | null = args.order.executedSurplusFee - ? this._getExecutedSurplusFeeLabel( - args.order.executedSurplusFee, - args.buyToken.token, - ) + const feeLabel: string | null = args.order.executedSurplusFee + ? this._getFeeLabel(args.order.executedSurplusFee, args.buyToken.token) : null; return new FulfilledSwapOrderTransactionInfo({ @@ -195,7 +192,7 @@ export class SwapOrderMapper { sellToken: args.sellToken.toTokenInfo(), buyToken: args.buyToken.toTokenInfo(), expiresTimestamp: args.order.validTo, - surplusFeeLabel: surplusFeeLabel, + feeLabel: feeLabel, executionPriceLabel: this._getExecutionPriceLabel( args.sellToken, args.buyToken, @@ -205,7 +202,7 @@ export class SwapOrderMapper { }); } - private _getExecutedSurplusFeeLabel( + private _getFeeLabel( executedSurplusFee: bigint, token: Token & { decimals: number }, ): string { From 0736b132b0aba98baa372ac0be64f1837c2d1bf2 Mon Sep 17 00:00:00 2001 From: fmrsabino <3332770+fmrsabino@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:36:58 +0100 Subject: [PATCH 2/2] Fix test --- .../transactions/mappers/common/swap-order.mapper.spec.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/routes/transactions/mappers/common/swap-order.mapper.spec.ts b/src/routes/transactions/mappers/common/swap-order.mapper.spec.ts index 4fd2551544..915fe33fe4 100644 --- a/src/routes/transactions/mappers/common/swap-order.mapper.spec.ts +++ b/src/routes/transactions/mappers/common/swap-order.mapper.spec.ts @@ -81,8 +81,8 @@ describe('Swap Order Mapper tests', () => { data: transaction.data as `0x${string}`, }); - const surplus = asDecimal(order.executedSurplusFee!, buyToken.decimals!); - const expectedSurplus = `${surplus} ${buyToken.symbol}`; + const fee = asDecimal(order.executedSurplusFee!, buyToken.decimals!); + const expectedFeeLabel = `${fee} ${buyToken.symbol}`; const executionRatio = asDecimal(order.executedSellAmount, sellToken.decimals!) / asDecimal(order.executedBuyAmount, buyToken.decimals!); @@ -106,7 +106,7 @@ describe('Swap Order Mapper tests', () => { expiresTimestamp: order.validTo, filledPercentage: expect.any(String), explorerUrl: new URL(`${explorerBaseUrl}/orders/${order.uid}`), - surplusLabel: expectedSurplus, + feeLabel: expectedFeeLabel, executionPriceLabel: expectedExecutionPrice, humanDescription: null, richDecodedInfo: null,