chore: Optional quote report generation (#2687)
This commit is contained in:
parent
a2f0d5eedf
commit
514db24ceb
@ -77,6 +77,10 @@
|
|||||||
{
|
{
|
||||||
"note": "Re-worked `Kyber` quotes supporting multiple reserves",
|
"note": "Re-worked `Kyber` quotes supporting multiple reserves",
|
||||||
"pr": 2683
|
"pr": 2683
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"note": "Enable Quote Report to be generated with an option `shouldGenerateQuoteReport`. Default is `false`",
|
||||||
|
"pr": 2687
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -46,6 +46,7 @@ export const DEFAULT_GET_MARKET_ORDERS_OPTS: GetMarketOrdersOpts = {
|
|||||||
gasSchedule: {},
|
gasSchedule: {},
|
||||||
allowFallback: true,
|
allowFallback: true,
|
||||||
shouldBatchBridgeOrders: true,
|
shouldBatchBridgeOrders: true,
|
||||||
|
shouldGenerateQuoteReport: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -342,6 +342,7 @@ export class MarketOperationUtils {
|
|||||||
allowFallback: _opts.allowFallback,
|
allowFallback: _opts.allowFallback,
|
||||||
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
||||||
quoteRequestor: _opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
|
quoteRequestor: _opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
|
||||||
|
shouldGenerateQuoteReport: _opts.shouldGenerateQuoteReport,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,6 +369,7 @@ export class MarketOperationUtils {
|
|||||||
allowFallback: _opts.allowFallback,
|
allowFallback: _opts.allowFallback,
|
||||||
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
||||||
quoteRequestor: _opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
|
quoteRequestor: _opts.rfqt ? _opts.rfqt.quoteRequestor : undefined,
|
||||||
|
shouldGenerateQuoteReport: _opts.shouldGenerateQuoteReport,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,6 +457,7 @@ export class MarketOperationUtils {
|
|||||||
feeSchedule: _opts.feeSchedule,
|
feeSchedule: _opts.feeSchedule,
|
||||||
allowFallback: _opts.allowFallback,
|
allowFallback: _opts.allowFallback,
|
||||||
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
shouldBatchBridgeOrders: _opts.shouldBatchBridgeOrders,
|
||||||
|
shouldGenerateQuoteReport: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
return optimizedOrders;
|
return optimizedOrders;
|
||||||
@ -478,6 +481,7 @@ export class MarketOperationUtils {
|
|||||||
allowFallback?: boolean;
|
allowFallback?: boolean;
|
||||||
shouldBatchBridgeOrders?: boolean;
|
shouldBatchBridgeOrders?: boolean;
|
||||||
quoteRequestor?: QuoteRequestor;
|
quoteRequestor?: QuoteRequestor;
|
||||||
|
shouldGenerateQuoteReport?: boolean;
|
||||||
},
|
},
|
||||||
): Promise<OptimizerResult> {
|
): Promise<OptimizerResult> {
|
||||||
const {
|
const {
|
||||||
@ -534,15 +538,17 @@ export class MarketOperationUtils {
|
|||||||
);
|
);
|
||||||
if (bestTwoHopQuote && bestTwoHopRate.isGreaterThan(optimalPathRate)) {
|
if (bestTwoHopQuote && bestTwoHopRate.isGreaterThan(optimalPathRate)) {
|
||||||
const twoHopOrders = createOrdersFromTwoHopSample(bestTwoHopQuote, orderOpts);
|
const twoHopOrders = createOrdersFromTwoHopSample(bestTwoHopQuote, orderOpts);
|
||||||
const twoHopQuoteReport = generateQuoteReport(
|
const twoHopQuoteReport = opts.shouldGenerateQuoteReport
|
||||||
side,
|
? generateQuoteReport(
|
||||||
_.flatten(dexQuotes),
|
side,
|
||||||
twoHopQuotes,
|
_.flatten(dexQuotes),
|
||||||
nativeOrders,
|
twoHopQuotes,
|
||||||
orderFillableAmounts,
|
nativeOrders,
|
||||||
bestTwoHopQuote,
|
orderFillableAmounts,
|
||||||
opts.quoteRequestor,
|
bestTwoHopQuote,
|
||||||
);
|
opts.quoteRequestor,
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
return { optimizedOrders: twoHopOrders, quoteReport: twoHopQuoteReport, isTwoHop: true };
|
return { optimizedOrders: twoHopOrders, quoteReport: twoHopQuoteReport, isTwoHop: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -574,15 +580,17 @@ export class MarketOperationUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const optimizedOrders = createOrdersFromPath(optimalPath, orderOpts);
|
const optimizedOrders = createOrdersFromPath(optimalPath, orderOpts);
|
||||||
const quoteReport = generateQuoteReport(
|
const quoteReport = opts.shouldGenerateQuoteReport
|
||||||
side,
|
? generateQuoteReport(
|
||||||
_.flatten(dexQuotes),
|
side,
|
||||||
twoHopQuotes,
|
_.flatten(dexQuotes),
|
||||||
nativeOrders,
|
twoHopQuotes,
|
||||||
orderFillableAmounts,
|
nativeOrders,
|
||||||
_.flatten(optimizedOrders.map(order => order.fills)),
|
orderFillableAmounts,
|
||||||
opts.quoteRequestor,
|
_.flatten(optimizedOrders.map(order => order.fills)),
|
||||||
);
|
opts.quoteRequestor,
|
||||||
|
)
|
||||||
|
: undefined;
|
||||||
return { optimizedOrders, quoteReport, isTwoHop: false };
|
return { optimizedOrders, quoteReport, isTwoHop: false };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,6 +275,10 @@ export interface GetMarketOrdersOpts {
|
|||||||
* order. Defaults to `true`.
|
* order. Defaults to `true`.
|
||||||
*/
|
*/
|
||||||
shouldBatchBridgeOrders: boolean;
|
shouldBatchBridgeOrders: boolean;
|
||||||
|
/**
|
||||||
|
* Whether to generate a quote report
|
||||||
|
*/
|
||||||
|
shouldGenerateQuoteReport: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -294,7 +298,7 @@ export interface SourceQuoteOperation<TFillData extends FillData = FillData>
|
|||||||
export interface OptimizerResult {
|
export interface OptimizerResult {
|
||||||
optimizedOrders: OptimizedMarketOrder[];
|
optimizedOrders: OptimizedMarketOrder[];
|
||||||
isTwoHop: boolean;
|
isTwoHop: boolean;
|
||||||
quoteReport: QuoteReport;
|
quoteReport?: QuoteReport;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type MarketDepthSide = Array<Array<DexSample<FillData>>>;
|
export type MarketDepthSide = Array<Array<DexSample<FillData>>>;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user