@@ -49,15 +49,9 @@ func newGreedyBucketsBuilder(
49
49
}
50
50
51
51
// CutoffPriceFromOrder returns the cutoff price for a given order based on the cutoff percent.
52
- // For example, if the cutoff percent is 0.9, the cutoff price will be 90% of the order price, rounded down to the nearest integer.
53
- func CutoffPriceFromOrder (order * types.TxWithMinerFee , cutoffPercent * big.Float ) * big.Int {
54
- floorPrice := new (big.Float ).
55
- Mul (
56
- new (big.Float ).SetInt (order .Price ()),
57
- cutoffPercent ,
58
- )
59
- round , _ := floorPrice .Int64 ()
60
- return big .NewInt (round )
52
+ // For example, if the cutoff percent is 90, the cutoff price will be 90% of the order price, rounded down to the nearest integer.
53
+ func CutoffPriceFromOrder (order * types.TxWithMinerFee , cutoffPercent int ) * big.Int {
54
+ return common .PercentOf (order .Price (), cutoffPercent )
61
55
}
62
56
63
57
// IsOrderInPriceRange returns true if the order price is greater than or equal to the minPrice.
@@ -196,15 +190,12 @@ func (b *greedyBucketsBuilder) mergeOrdersIntoEnvDiff(
196
190
const retryLimit = 1
197
191
198
192
var (
199
- baseFee = envDiff .baseEnvironment .header .BaseFee
200
- retryMap = make (map [* types.TxWithMinerFee ]int )
201
- usedBundles []types.SimulatedBundle
202
- usedSbundles []types.UsedSBundle
203
- transactions []* types.TxWithMinerFee
204
- percent = new (big.Float ).Quo (
205
- new (big.Float ).SetInt (b .algoConf .ProfitThresholdPercent ),
206
- new (big.Float ).SetInt (common .Big100 ),
207
- )
193
+ baseFee = envDiff .baseEnvironment .header .BaseFee
194
+ retryMap = make (map [* types.TxWithMinerFee ]int )
195
+ usedBundles []types.SimulatedBundle
196
+ usedSbundles []types.UsedSBundle
197
+ transactions []* types.TxWithMinerFee
198
+ priceCutoffPercent = b .algoConf .PriceCutoffPercent
208
199
209
200
SortInPlaceByProfit = func (baseFee * big.Int , transactions []* types.TxWithMinerFee , gasUsedMap map [* types.TxWithMinerFee ]uint64 ) {
210
201
sort .SliceStable (transactions , func (i , j int ) bool {
@@ -213,7 +204,7 @@ func (b *greedyBucketsBuilder) mergeOrdersIntoEnvDiff(
213
204
}
214
205
)
215
206
216
- minPrice := CutoffPriceFromOrder (orders .Peek (), percent )
207
+ minPrice := CutoffPriceFromOrder (orders .Peek (), priceCutoffPercent )
217
208
for {
218
209
order := orders .Peek ()
219
210
if order == nil {
@@ -241,7 +232,7 @@ func (b *greedyBucketsBuilder) mergeOrdersIntoEnvDiff(
241
232
usedSbundles = append (usedSbundles , sbundles ... )
242
233
transactions = nil
243
234
}
244
- minPrice = CutoffPriceFromOrder (order , percent )
235
+ minPrice = CutoffPriceFromOrder (order , priceCutoffPercent )
245
236
}
246
237
}
247
238
0 commit comments