Commit 9938cc18 authored by Moody Salem's avatar Moody Salem

Fix naming of error and parameter

parent 3f22d17e
...@@ -115,31 +115,31 @@ export class Trade { ...@@ -115,31 +115,31 @@ export class Trade {
this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount) this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount)
} }
// get the minimum amount that must be received from this trade for the given allowed slippage // get the minimum amount that must be received from this trade for the given slippage tolerance
public minimumAmountOut(additionalSlippageTolerance: Percent): TokenAmount { public minimumAmountOut(slippageTolerance: Percent): TokenAmount {
invariant(!additionalSlippageTolerance.lessThan(ZERO), 'ADDITIONAL_SLIPPAGE_TOLERANCE') invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')
if (this.tradeType === TradeType.EXACT_OUTPUT) { if (this.tradeType === TradeType.EXACT_OUTPUT) {
return this.outputAmount return this.outputAmount
} else { } else {
return new TokenAmount( return new TokenAmount(
this.outputAmount.token, this.outputAmount.token,
new Fraction(ONE) new Fraction(ONE)
.add(additionalSlippageTolerance) .add(slippageTolerance)
.invert() .invert()
.multiply(this.outputAmount.raw).quotient .multiply(this.outputAmount.raw).quotient
) )
} }
} }
// get the maximum amount in that can be spent via this trade for the given allowed slippage // get the maximum amount in that can be spent via this trade for the given slippage tolerance
public maximumAmountIn(additionalSlippageTolerance: Percent): TokenAmount { public maximumAmountIn(slippageTolerance: Percent): TokenAmount {
invariant(!additionalSlippageTolerance.lessThan(ZERO), 'ADDITIONAL_SLIPPAGE_TOLERANCE') invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')
if (this.tradeType === TradeType.EXACT_INPUT) { if (this.tradeType === TradeType.EXACT_INPUT) {
return this.inputAmount return this.inputAmount
} else { } else {
return new TokenAmount( return new TokenAmount(
this.inputAmount.token, this.inputAmount.token,
new Fraction(ONE).add(additionalSlippageTolerance).multiply(this.inputAmount.raw).quotient new Fraction(ONE).add(slippageTolerance).multiply(this.inputAmount.raw).quotient
) )
} }
} }
......
...@@ -94,7 +94,7 @@ describe('Trade', () => { ...@@ -94,7 +94,7 @@ describe('Trade', () => {
) )
it('throws if less than 0', () => { it('throws if less than 0', () => {
expect(() => exactIn.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( expect(() => exactIn.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE' 'SLIPPAGE_TOLERANCE'
) )
}) })
it('returns exact if 0', () => { it('returns exact if 0', () => {
...@@ -121,7 +121,7 @@ describe('Trade', () => { ...@@ -121,7 +121,7 @@ describe('Trade', () => {
it('throws if less than 0', () => { it('throws if less than 0', () => {
expect(() => exactOut.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( expect(() => exactOut.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE' 'SLIPPAGE_TOLERANCE'
) )
}) })
it('returns exact if 0', () => { it('returns exact if 0', () => {
...@@ -150,7 +150,7 @@ describe('Trade', () => { ...@@ -150,7 +150,7 @@ describe('Trade', () => {
) )
it('throws if less than 0', () => { it('throws if less than 0', () => {
expect(() => exactIn.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( expect(() => exactIn.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE' 'SLIPPAGE_TOLERANCE'
) )
}) })
it('returns exact if 0', () => { it('returns exact if 0', () => {
...@@ -177,7 +177,7 @@ describe('Trade', () => { ...@@ -177,7 +177,7 @@ describe('Trade', () => {
it('throws if less than 0', () => { it('throws if less than 0', () => {
expect(() => exactOut.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow( expect(() => exactOut.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE' 'SLIPPAGE_TOLERANCE'
) )
}) })
it('returns exact if 0', () => { it('returns exact if 0', () => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment