Skip to content

Commit 184406f

Browse files
committed
Include fee in toTokenAmount adjustment
1 parent c0b8941 commit 184406f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/api/utils/tradeQuoter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,8 @@ export class TradeQuoter {
253253
// BigNumber does not do fixed point math & FixedNumber underflows w/ numbers less than 1
254254
// Multiply the slippage by a factor and divide the end result by same...
255255
const percentMultiplier = 1000;
256-
const slippageToleranceBN = Math.floor(percentMultiplier * this.outputSlippageTolerance(slippagePercentage));
256+
const slippageAndFee = slippagePercentage + feePercentage;
257+
const slippageToleranceBN = Math.floor(percentMultiplier * this.outputSlippageTolerance(slippageAndFee));
257258
const toTokenAmountMinusSlippage = toTokenAmount.mul(slippageToleranceBN).div(percentMultiplier);
258259
const toUnits = toTokenAmountMinusSlippage.mul(SCALE).div(setTotalSupply);
259260

test/fixtures/tradeQuote.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export const tradeQuoteFixtures = {
181181
gasPrice: '61',
182182
slippagePercentage: '2.00%',
183183
fromTokenAmount: '1126868991563',
184-
toTokenAmount: '91245821628',
184+
toTokenAmount: '90314741816',
185185
display: {
186186
inputAmountRaw: '.5',
187187
inputAmount: '500000000000000000',

0 commit comments

Comments
 (0)