From 10541b5a8faafb9b064c6fd14356dc0e462065b1 Mon Sep 17 00:00:00 2001 From: Chien Nguyen Date: Wed, 18 Dec 2024 09:53:17 +0700 Subject: [PATCH] Correct formular to calculate filledMakingAmountWei --- pkg/source/limitorder/pool_simulator.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/source/limitorder/pool_simulator.go b/pkg/source/limitorder/pool_simulator.go index a42f0c32a..cea2f7be0 100644 --- a/pkg/source/limitorder/pool_simulator.go +++ b/pkg/source/limitorder/pool_simulator.go @@ -249,9 +249,9 @@ func (p *PoolSimulator) calcAmountOutWithSwapInfo(swapSide SwapSide, tokenAmount if remainingTakingAmountWei.Cmp(totalAmountInAfterFee) >= 0 { filledTakingAmountWei := totalAmountInAfterFee filledMakingAmountWei := new(big.Int).Div( - new(big.Int).Mul(filledTakingAmountWei, remainingMakingAmountWei), - remainingTakingAmountWei, - ) // filledMakingAmountWei = filledTakingAmountWei * remainingMakingAmountWei / remainingTakingAmountWei + new(big.Int).Mul(filledTakingAmountWei, order.MakingAmount), + order.TakingAmount, + ) // filledMakingAmountWei = filledTakingAmountWei * order.MakingAmount / order.TakingAmount // order too small if filledMakingAmountWei.Sign() <= 0 {