File tree Expand file tree Collapse file tree 3 files changed +10
-10
lines changed
asset-swapper/utils/market_operation_utils Expand file tree Collapse file tree 3 files changed +10
-10
lines changed Original file line number Diff line number Diff line change @@ -2197,17 +2197,18 @@ const DEFAULT_FEE_SCHEDULE: FeeSchedule = Object.keys(DEFAULT_GAS_SCHEDULE).redu
2197
2197
return acc ;
2198
2198
} , { } as FeeSchedule ) ;
2199
2199
2200
+ const numSamples = 40 ;
2200
2201
export const DEFAULT_GET_MARKET_ORDERS_OPTS : Omit < GetMarketOrdersOpts , 'gasPrice' > = {
2201
2202
excludedSources : [ ] ,
2202
2203
includedSources : [ ] ,
2203
2204
bridgeSlippage : 0.005 ,
2204
- numSamples : 13 ,
2205
+ numSamples : numSamples ,
2205
2206
sampleDistributionBase : 1 ,
2206
2207
feeSchedule : DEFAULT_FEE_SCHEDULE ,
2207
2208
exchangeProxyOverhead : ( ) => ZERO_AMOUNT ,
2208
2209
shouldGenerateQuoteReport : true ,
2209
2210
tokenAdjacencyGraph : TokenAdjacencyGraph . getEmptyGraph ( ) ,
2210
- neonRouterNumSamples : 14 ,
2211
+ neonRouterNumSamples : numSamples + 1 ,
2211
2212
fillAdjustor : new IdentityFillAdjustor ( ) ,
2212
2213
endpoint : 'price' ,
2213
2214
} ;
Original file line number Diff line number Diff line change @@ -262,23 +262,22 @@ export class PathOptimizer {
262
262
}
263
263
const fee = this . calculateOutputFee ( nativeOrder ) . integerValue ( ) . toNumber ( ) ;
264
264
265
- // HACK: due to an issue with the Rust router interpolation we need to create exactly 13 samples from the native order
265
+ // HACK: due to an issue with the Rust router interpolation we need to create exactly 40 samples from the native order
266
266
const ids = [ ] ;
267
267
const inputs = [ ] ;
268
268
const outputs = [ ] ;
269
269
const outputFees = [ ] ;
270
270
271
271
// NOTE: Limit orders can be both larger or smaller than the input amount
272
272
// If the order is larger than the input we can scale the order to the size of
273
- // the quote input (order pricing is constant) and then create 13 "samples" up to
273
+ // the quote input (order pricing is constant) and then create 40 "samples" up to
274
274
// and including the full quote input amount.
275
275
// If the order is smaller we don't need to scale anything, we will just end up
276
276
// with trailing duplicate samples for the order input as we cannot go higher
277
277
const scaleToInput = BigNumber . min ( this . inputAmount . dividedBy ( normalizedOrderInput ) , 1 ) ;
278
278
279
- // TODO: replace constant with a proper sample size.
280
- for ( let i = 1 ; i <= 13 ; i ++ ) {
281
- const fraction = i / 13 ;
279
+ for ( let i = 1 ; i < this . neonRouterNumSamples ; i ++ ) {
280
+ const fraction = i / ( this . neonRouterNumSamples - 1 ) ;
282
281
const currentInput = BigNumber . min (
283
282
normalizedOrderInput . times ( scaleToInput ) . times ( fraction ) ,
284
283
normalizedOrderInput ,
Original file line number Diff line number Diff line change @@ -77,14 +77,14 @@ const EXCHANGE_PROXY_OVERHEAD_FULLY_FEATURED = (sourceFlags: bigint) => {
77
77
}
78
78
} ;
79
79
80
- const NEON_ROUTER_NUM_SAMPLES = 14 ;
80
+ const NUM_SAMPLES = 40 ;
81
81
// TODO(kimpers): Due to an issue with the Rust router we want to use equidistant samples when using the Rust router
82
82
83
83
export const ASSET_SWAPPER_MARKET_ORDERS_OPTS : Partial < SwapQuoteRequestOpts > = {
84
84
bridgeSlippage : DEFAULT_QUOTE_SLIPPAGE_PERCENTAGE ,
85
- numSamples : 13 ,
85
+ numSamples : NUM_SAMPLES ,
86
86
sampleDistributionBase : SAMPLE_DISTRIBUTION_BASE ,
87
- neonRouterNumSamples : NEON_ROUTER_NUM_SAMPLES ,
87
+ neonRouterNumSamples : NUM_SAMPLES + 1 ,
88
88
exchangeProxyOverhead : EXCHANGE_PROXY_OVERHEAD_FULLY_FEATURED ,
89
89
shouldGenerateQuoteReport : true ,
90
90
} ;
You can’t perform that action at this time.
0 commit comments