diff --git a/packages/cpp/src/ConstantProductPool.ts b/packages/cpp/src/ConstantProductPool.ts index a13f6b3..1f5b1d2 100644 --- a/packages/cpp/src/ConstantProductPool.ts +++ b/packages/cpp/src/ConstantProductPool.ts @@ -190,8 +190,8 @@ export const getSwapOutput = ( throw new Error("Input and reserves must be positive"); fee = Fraction.asFraction(fee); - if (fee.lt(Fraction.ZERO) || fee.gte(Fraction.ONE)) - throw new Error("fee must be [0,1)"); + if (fee.lt(Fraction.ZERO) || fee.gt(Fraction.ONE)) + throw new Error("fee must be between 0 and 1"); const feeDiff = fee.denominator - fee.numerator; const outputNumerator = outputReserve * input * feeDiff; diff --git a/packages/cpp/src/__tests__/ConstantProductPool.test.ts b/packages/cpp/src/__tests__/ConstantProductPool.test.ts index 20d5440..6800fdb 100644 --- a/packages/cpp/src/__tests__/ConstantProductPool.test.ts +++ b/packages/cpp/src/__tests__/ConstantProductPool.test.ts @@ -28,7 +28,9 @@ describe("getSwapOutput", () => { }); test("throws if fee is greater than or equal 1", () => { - expect(() => getSwapOutput(1n, 10n, 10n, Fraction.asFraction(1))).toThrow(); + expect(() => + getSwapOutput(1n, 10n, 10n, Fraction.asFraction(1)), + ).not.toThrow(); expect(() => getSwapOutput(1n, 10n, 10n, Fraction.asFraction(1.132)), ).toThrow();