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 {
this.slippage = getSlippage(route.midPrice, inputAmount, outputAmount)
}
// get the minimum amount that must be received from this trade for the given allowed slippage
public minimumAmountOut(additionalSlippageTolerance: Percent): TokenAmount {
invariant(!additionalSlippageTolerance.lessThan(ZERO), 'ADDITIONAL_SLIPPAGE_TOLERANCE')
// get the minimum amount that must be received from this trade for the given slippage tolerance
public minimumAmountOut(slippageTolerance: Percent): TokenAmount {
invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')
if (this.tradeType === TradeType.EXACT_OUTPUT) {
return this.outputAmount
} else {
return new TokenAmount(
this.outputAmount.token,
new Fraction(ONE)
.add(additionalSlippageTolerance)
.add(slippageTolerance)
.invert()
.multiply(this.outputAmount.raw).quotient
)
}
}
// get the maximum amount in that can be spent via this trade for the given allowed slippage
public maximumAmountIn(additionalSlippageTolerance: Percent): TokenAmount {
invariant(!additionalSlippageTolerance.lessThan(ZERO), 'ADDITIONAL_SLIPPAGE_TOLERANCE')
// get the maximum amount in that can be spent via this trade for the given slippage tolerance
public maximumAmountIn(slippageTolerance: Percent): TokenAmount {
invariant(!slippageTolerance.lessThan(ZERO), 'SLIPPAGE_TOLERANCE')
if (this.tradeType === TradeType.EXACT_INPUT) {
return this.inputAmount
} else {
return new TokenAmount(
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', () => {
)
it('throws if less than 0', () => {
expect(() => exactIn.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE'
'SLIPPAGE_TOLERANCE'
)
})
it('returns exact if 0', () => {
......@@ -121,7 +121,7 @@ describe('Trade', () => {
it('throws if less than 0', () => {
expect(() => exactOut.maximumAmountIn(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE'
'SLIPPAGE_TOLERANCE'
)
})
it('returns exact if 0', () => {
......@@ -150,7 +150,7 @@ describe('Trade', () => {
)
it('throws if less than 0', () => {
expect(() => exactIn.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE'
'SLIPPAGE_TOLERANCE'
)
})
it('returns exact if 0', () => {
......@@ -177,7 +177,7 @@ describe('Trade', () => {
it('throws if less than 0', () => {
expect(() => exactOut.minimumAmountOut(new Percent(JSBI.BigInt(-1), JSBI.BigInt(100)))).toThrow(
'ADDITIONAL_SLIPPAGE_TOLERANCE'
'SLIPPAGE_TOLERANCE'
)
})
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