Skip to content

Commit

Permalink
Add quoteId to GpTrade class
Browse files Browse the repository at this point in the history
  • Loading branch information
alfetopito committed Jun 27, 2022
1 parent ba4dfac commit 4563ae4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/custom/state/swap/TradeGp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ interface TradeGpConstructor {
fee: FeeForTrade
executionPrice: Price<Currency, Currency>
tradeType: TradeType
quoteId?: number
}

/**
Expand Down Expand Up @@ -128,6 +129,13 @@ export default class TradeGp {
*/
readonly executionPrice: Price<Currency, Currency>

/**
* 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,
Expand All @@ -137,6 +145,7 @@ export default class TradeGp {
fee,
executionPrice,
tradeType,
quoteId,
}: TradeGpConstructor) {
this.tradeType = tradeType
this.inputAmount = inputAmount
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/custom/state/swap/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export function useTradeExactInWithFee({
fee,
executionPrice,
tradeType: TradeType.EXACT_INPUT,
quoteId: quote.price.quoteId,
})
}

Expand Down Expand Up @@ -129,5 +130,6 @@ export function useTradeExactOutWithFee({
fee,
executionPrice,
tradeType: TradeType.EXACT_OUTPUT,
quoteId: quote.price.quoteId,
})
}

0 comments on commit 4563ae4

Please sign in to comment.