change to affiliate fees
This commit is contained in:
@@ -158,7 +158,7 @@ export interface SwapQuote {
|
||||
|
||||
/**
|
||||
* assetEthAmount: The amount of eth required to pay for the requested asset.
|
||||
* feeEthAmount: The amount of eth required to pay the affiliate fee.
|
||||
* feeEthAmount: The amount of eth required to pay any fee concerned with an extension contract.
|
||||
* totalEthAmount: The total amount of eth required to complete the buy (filling orders, feeOrders, and paying affiliate fee).
|
||||
*/
|
||||
export interface SwapQuoteInfo {
|
||||
|
@@ -12,13 +12,18 @@ export const affiliateFeeUtils = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds a fee based on feePercentage of the takerTokenAmount and adds it to the feeTakerTokenAmount and totalTakerTokenAmount
|
||||
* @param quoteInfo quote information to add fee to
|
||||
* @param feePercentage the percentage of takerTokenAmount charged additionally as a fee
|
||||
*/
|
||||
const getSwapQuoteInfoWithAffiliateFee = (quoteInfo: SwapQuoteInfo, feePercentage: number): SwapQuoteInfo => {
|
||||
const newQuoteInfo = _.clone(quoteInfo);
|
||||
const affiliateFeeAmount = newQuoteInfo.takerTokenAmount
|
||||
const affiliateFeeAmount = quoteInfo.takerTokenAmount
|
||||
.multipliedBy(feePercentage)
|
||||
.integerValue(BigNumber.ROUND_CEIL);
|
||||
const newFeeAmount = newQuoteInfo.feeTakerTokenAmount.plus(affiliateFeeAmount);
|
||||
const newFeeAmount = quoteInfo.feeTakerTokenAmount.plus(affiliateFeeAmount);
|
||||
newQuoteInfo.feeTakerTokenAmount = newFeeAmount;
|
||||
newQuoteInfo.totalTakerTokenAmount = newFeeAmount.plus(newQuoteInfo.takerTokenAmount);
|
||||
newQuoteInfo.totalTakerTokenAmount = newFeeAmount.plus(quoteInfo.takerTokenAmount);
|
||||
return newQuoteInfo;
|
||||
};
|
||||
|
Reference in New Issue
Block a user