Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Commit

Permalink
Update minimumProtocolFee
Browse files Browse the repository at this point in the history
  • Loading branch information
dekz committed Jun 10, 2020
1 parent e88355f commit 80ffdfc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/handlers/meta_transaction_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as HttpStatus from 'http-status-codes';
import * as isValidUUID from 'uuid-validate';

import { CHAIN_ID } from '../config';
import { DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE, META_TRANSACTION_DOCS_URL } from '../constants';
import { DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE, META_TRANSACTION_DOCS_URL, ZERO } from '../constants';
import { TransactionEntity } from '../entities';
import {
GeneralErrorCodes,
Expand Down Expand Up @@ -158,6 +158,10 @@ export class MetaTransactionHandlers {
sellTokenAddress,
buyTokenAddress,
sources: metaTransactionPrice.sources,
estimatedGas: metaTransactionPrice.estimatedGas,
protocolFee: metaTransactionPrice.protocolFee,
estimatedGasTokenRefund: ZERO,
minimumProtocolFee: metaTransactionPrice.minimumProtocolFee,
};
res.status(HttpStatus.OK).send(metaTransactionPriceResponse);
} catch (e) {
Expand Down
9 changes: 7 additions & 2 deletions src/services/meta_transaction_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
SUBMITTED_TX_DB_POLLING_INTERVAL_MS,
TEN_MINUTES_MS,
TX_HASH_RESPONSE_WAIT_TIME_MS,
ZERO,
} from '../constants';
import { KeyValueEntity, TransactionEntity } from '../entities';
import { logger } from '../logger';
Expand Down Expand Up @@ -136,7 +137,7 @@ export class MetaTransactionService {
throw new Error('sellAmount or buyAmount required');
}
const { gasPrice } = swapQuote;
const { gas, protocolFee } = swapQuote.worstCaseQuoteInfo.worstCaseQuoteInfo;
const { gas, protocolFeeInWeiAmount: protocolFee } = swapQuote.worstCaseQuoteInfo;
const makerAssetAmount = swapQuote.bestCaseQuoteInfo.makerAssetAmount;
const totalTakerAssetAmount = swapQuote.bestCaseQuoteInfo.totalTakerAssetAmount;

Expand All @@ -162,9 +163,10 @@ export class MetaTransactionService {
price,
swapQuote,
sources: serviceUtils.convertSourceBreakdownToArray(swapQuote.sourceBreakdown),
estimatedGas: gas,
estimatedGas: new BigNumber(gas),
gasPrice,
protocolFee,
minimumProtocolFee: protocolFee,
};
return response;
}
Expand All @@ -179,6 +181,7 @@ export class MetaTransactionService {
price,
estimatedGas,
protocolFee,
minimumProtocolFee,
} = await this.calculateMetaTransactionPriceAsync(params, 'quote');

const floatGasPrice = swapQuote.gasPrice;
Expand Down Expand Up @@ -221,6 +224,8 @@ export class MetaTransactionService {
gasPrice,
estimatedGas,
protocolFee,
minimumProtocolFee,
estimatedGasTokenRefund: ZERO,
};
return apiMetaTransactionQuote;
}
Expand Down
10 changes: 9 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,9 +420,16 @@ export interface GetMetaTransactionQuoteResponse {
gasPrice: BigNumber;
protocolFee: BigNumber;
estimatedGas: BigNumber;
estimatedGasTokenRefund: BigNumber;
minimumProtocolFee: BigNumber;
}

export interface GetMetaTransactionPriceResponse extends BasePriceResponse {}
export interface GetMetaTransactionPriceResponse extends BasePriceResponse {
estimatedGas: BigNumber;
estimatedGasTokenRefund: BigNumber;
protocolFee: BigNumber;
minimumProtocolFee: BigNumber;
}

export interface GetMetaTransactionStatusResponse {
refHash: string;
Expand All @@ -445,6 +452,7 @@ export interface CalculateMetaTransactionPriceResponse {
sources: GetSwapQuoteResponseLiquiditySource[];
gasPrice: BigNumber;
protocolFee: BigNumber;
minimumProtocolFee: BigNumber;
estimatedGas: BigNumber;
}

Expand Down

0 comments on commit 80ffdfc

Please sign in to comment.