diff --git a/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.test.ts b/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.test.ts index 1c18f5bf..2ddc2168 100644 --- a/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.test.ts +++ b/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.test.ts @@ -125,25 +125,27 @@ describe("PriorityOrderTrade", () => { expect(ethOutputTrade.outputAmount.currency).toEqual(Ether.onChain(1)); }); - it("returns the correct amountIn and amountOut with classic quote data", () => { - const classicAmounts = { - classicAmountInGasAndPortionAdjusted: "1", - classicAmountOutGasAndPortionAdjusted: "1", + it("returns the correct amountIn and amountOut with expected quote data", () => { + const expectedAmounts = { + expectedAmountIn: "1", + expectedAmountOut: "1", }; - const classicAmountTrade = new PriorityOrderTrade( - { - currencyIn: USDC, - currenciesOut: [DAI], - orderInfo, - tradeType: TradeType.EXACT_INPUT, - classicAmounts, - } - ); - expect(classicAmountTrade.inputAmount.quotient.toString()).toEqual( - classicAmounts.classicAmountInGasAndPortionAdjusted + const expectedAmountTrade = new PriorityOrderTrade< + Currency, + Currency, + TradeType + >({ + currencyIn: USDC, + currenciesOut: [DAI], + orderInfo, + tradeType: TradeType.EXACT_INPUT, + expectedAmounts, + }); + expect(expectedAmountTrade.inputAmount.quotient.toString()).toEqual( + expectedAmounts.expectedAmountIn ); - expect(classicAmountTrade.outputAmount.quotient.toString()).toEqual( - classicAmounts.classicAmountOutGasAndPortionAdjusted + expect(expectedAmountTrade.outputAmount.quotient.toString()).toEqual( + expectedAmounts.expectedAmountOut ); }); }); diff --git a/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.ts b/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.ts index 82fc3146..975b13c4 100644 --- a/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.ts +++ b/sdks/uniswapx-sdk/src/trade/PriorityOrderTrade.ts @@ -11,9 +11,9 @@ export class PriorityOrderTrade< > { public readonly tradeType: TTradeType; public readonly order: UnsignedPriorityOrder; - public readonly classicAmounts: { - classicAmountInGasAndPortionAdjusted: string; - classicAmountOutGasAndPortionAdjusted: string; + public readonly expectedAmounts: { + expectedAmountIn: string; + expectedAmountOut: string; } | undefined; private _inputAmount: CurrencyAmount | undefined; @@ -27,21 +27,21 @@ export class PriorityOrderTrade< currenciesOut, orderInfo, tradeType, - classicAmounts, + expectedAmounts, }: { currencyIn: TInput; currenciesOut: TOutput[]; orderInfo: UnsignedPriorityOrderInfo; tradeType: TTradeType; - classicAmounts?: { - classicAmountInGasAndPortionAdjusted: string; - classicAmountOutGasAndPortionAdjusted: string; + expectedAmounts?: { + expectedAmountIn: string; + expectedAmountOut: string; }; }) { this._currencyIn = currencyIn; this._currenciesOut = currenciesOut; this.tradeType = tradeType; - this.classicAmounts = classicAmounts; + this.expectedAmounts = expectedAmounts; // assume single-chain for now this.order = new UnsignedPriorityOrder(orderInfo, currencyIn.chainId); @@ -50,9 +50,9 @@ export class PriorityOrderTrade< public get inputAmount(): CurrencyAmount { if (this._inputAmount) return this._inputAmount; - // If we have classic quote data use that, otherwise use the order input amount - const amount = this.classicAmounts?.classicAmountInGasAndPortionAdjusted - ? this.getClassicAmountIn() + // If we have expected quote data use that, otherwise use the order input amount + const amount = this.expectedAmounts?.expectedAmountIn + ? this.getExpectedAmountIn() : CurrencyAmount.fromRawAmount( this._currencyIn, this.order.info.input.amount.toString() @@ -120,8 +120,10 @@ export class PriorityOrderTrade< // TODO: revise when there are actually multiple output amounts. for now, assume only one non-fee output at a time public get outputAmount(): CurrencyAmount { - // If we have classic quote data use that, otherwise use the first non-fee output - return this.classicAmounts?.classicAmountOutGasAndPortionAdjusted ? this.getClassicAmountOut() : this.getFirstNonFeeOutputAmount(); + // If we have expected quote data use that, otherwise use the first non-fee output + return this.expectedAmounts?.expectedAmountOut + ? this.getExpectedAmountOut() + : this.getFirstNonFeeOutputAmount(); } public minimumAmountOut(): CurrencyAmount { @@ -165,25 +167,25 @@ export class PriorityOrderTrade< ); } - private getClassicAmountIn(): CurrencyAmount { - if (!this.classicAmounts?.classicAmountInGasAndPortionAdjusted) { - throw new Error("classicAmountInGasAndPortionAdjusted not set"); + private getExpectedAmountIn(): CurrencyAmount { + if (!this.expectedAmounts?.expectedAmountIn) { + throw new Error("expectedAmountIn not set"); } return CurrencyAmount.fromRawAmount( this._currencyIn, - this.classicAmounts.classicAmountInGasAndPortionAdjusted + this.expectedAmounts.expectedAmountIn ); } - private getClassicAmountOut(): CurrencyAmount { - if (!this.classicAmounts?.classicAmountOutGasAndPortionAdjusted) { - throw new Error("classicAmountOutGasAndPortionAdjusted not set"); + private getExpectedAmountOut(): CurrencyAmount { + if (!this.expectedAmounts?.expectedAmountOut) { + throw new Error("expectedAmountOut not set"); } return CurrencyAmount.fromRawAmount( this._currenciesOut[0], - this.classicAmounts.classicAmountOutGasAndPortionAdjusted + this.expectedAmounts.expectedAmountOut ); } }