From 4563ae4e6827f68afe9ac247790aa8e228d09dbf Mon Sep 17 00:00:00 2001 From: Alfetopito Date: Mon, 27 Jun 2022 16:42:56 +0100 Subject: [PATCH] Add quoteId to GpTrade class --- src/custom/state/swap/TradeGp.ts | 10 ++++++++++ src/custom/state/swap/extension.ts | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/custom/state/swap/TradeGp.ts b/src/custom/state/swap/TradeGp.ts index 8158f08ddb..1a94167149 100644 --- a/src/custom/state/swap/TradeGp.ts +++ b/src/custom/state/swap/TradeGp.ts @@ -97,6 +97,7 @@ interface TradeGpConstructor { fee: FeeForTrade executionPrice: Price tradeType: TradeType + quoteId?: number } /** @@ -128,6 +129,13 @@ export default class TradeGp { */ readonly executionPrice: Price + /** + * The id returned by CowSwap's quote backend, if any + * + * Note that it won't be set for fast quotes, nor for quotes from other sources (paraswap, 0x, etc) + */ + readonly quoteId?: number + public constructor({ inputAmount, inputAmountWithFee, @@ -137,6 +145,7 @@ export default class TradeGp { fee, executionPrice, tradeType, + quoteId, }: TradeGpConstructor) { this.tradeType = tradeType this.inputAmount = inputAmount @@ -146,6 +155,7 @@ export default class TradeGp { this.outputAmount = outputAmount this.fee = fee this.executionPrice = executionPrice + this.quoteId = quoteId } /** * Get the minimum amount that must be received from this trade for the given slippage tolerance diff --git a/src/custom/state/swap/extension.ts b/src/custom/state/swap/extension.ts index 661f7f8c38..5c36473d27 100644 --- a/src/custom/state/swap/extension.ts +++ b/src/custom/state/swap/extension.ts @@ -77,6 +77,7 @@ export function useTradeExactInWithFee({ fee, executionPrice, tradeType: TradeType.EXACT_INPUT, + quoteId: quote.price.quoteId, }) } @@ -129,5 +130,6 @@ export function useTradeExactOutWithFee({ fee, executionPrice, tradeType: TradeType.EXACT_OUTPUT, + quoteId: quote.price.quoteId, }) }