From 8fb79d5c547f8108b68e5e185148acfa219956a3 Mon Sep 17 00:00:00 2001 From: Anirudh Suresh Date: Fri, 1 Nov 2024 17:56:55 +0000 Subject: [PATCH] Fix/rounding bug limo sdk (#207) * fix rounding bug * unbump package version --- sdk/js/src/examples/simpleSearcherLimo.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sdk/js/src/examples/simpleSearcherLimo.ts b/sdk/js/src/examples/simpleSearcherLimo.ts index 5ce85c69..13b4a1e2 100644 --- a/sdk/js/src/examples/simpleSearcherLimo.ts +++ b/sdk/js/src/examples/simpleSearcherLimo.ts @@ -98,16 +98,18 @@ class SimpleSearcherLimo { const inputAmountDecimals = new Decimal( order.state.initialInputAmount.toNumber() ) - .div(new Decimal(10).pow(inputMintDecimals)) .mul(effectiveFillRate) - .div(100); + .div(100) + .floor() + .div(new Decimal(10).pow(inputMintDecimals)); const outputAmountDecimals = new Decimal( order.state.expectedOutputAmount.toNumber() ) - .div(new Decimal(10).pow(outputMintDecimals)) .mul(effectiveFillRate) - .div(100); + .div(100) + .ceil() + .div(new Decimal(10).pow(outputMintDecimals)); console.log("Order address", order.address.toBase58()); console.log("Fill rate", effectiveFillRate);