Skip to content

Commit

Permalink
Update formulor calculate making amout before fee
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisngyn committed Dec 17, 2024
1 parent 0bf23e2 commit 2200649
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions pkg/source/limitorder/pool_simulator_calc_amount_in.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,18 +151,11 @@ func (p *PoolSimulator) calcMakerAssetAmountBeforeFee(order *order, makingAmount
}

// makingAmountBeforeFee = makingAmount * BasisPoint / (BasisPoint - feePct)

basicPointF := new(big.Float).SetInt(constant.BasisPoint)
makingAmountBeforeFeeF := new(big.Float).Mul(
new(big.Float).SetInt(makingAmount),
new(big.Float).Quo(
basicPointF,
new(big.Float).Sub(basicPointF, new(big.Float).SetInt64(int64(feePct))),
),
makingAmountBeforeFee = divCeil(
new(big.Int).Mul(makingAmount, constant.BasisPoint),
new(big.Int).Sub(constant.BasisPoint, big.NewInt(int64(feePct))),
)

makingAmountBeforeFee, _ = makingAmountBeforeFeeF.Int(nil)

// fee = makingAmount - makingAmountBeforeFee
fee = new(big.Int).Sub(makingAmount, makingAmountBeforeFee)

Expand Down

0 comments on commit 2200649

Please sign in to comment.