Skip to content

Commit

Permalink
Rename surplusLabel to feeLabel (#1390)
Browse files Browse the repository at this point in the history
- Renames the `surplusLabel` of a `FulfilledSwapOrderTransactionInfo` to a `feeLabel` (to better represent the value that the field holds).
- Improves the description of the field.
  • Loading branch information
fmrsabino committed Apr 10, 2024
1 parent 816f4ac commit 799289b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
8 changes: 4 additions & 4 deletions src/routes/transactions/entities/swap-order-info.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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!);
Expand All @@ -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,
Expand Down
11 changes: 4 additions & 7 deletions src/routes/transactions/mappers/common/swap-order.mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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,
Expand All @@ -205,7 +202,7 @@ export class SwapOrderMapper {
});
}

private _getExecutedSurplusFeeLabel(
private _getFeeLabel(
executedSurplusFee: bigint,
token: Token & { decimals: number },
): string {
Expand Down

0 comments on commit 799289b

Please sign in to comment.