Skip to content

Commit

Permalink
Correct formular to calculate filledMakingAmountWei
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisngyn committed Dec 18, 2024
1 parent adf23e3 commit 10541b5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pkg/source/limitorder/pool_simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 10541b5

Please sign in to comment.