Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Commit

Permalink
Add classicAmountInGasAndPortionAdjusted to RelayQuote
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongeric committed Jan 25, 2024
1 parent 4180d40 commit e61b3a8
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/entities/quote/RelayQuote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import { RelayOrder, RelayOrderBuilder, RelayOrderInfoJSON } from '@uniswap/unis
import { UNIVERSAL_ROUTER_ADDRESS} from '@uniswap/universal-router-sdk';
import { BigNumber, ethers } from 'ethers';

import { PermitTransferFromData } from '@uniswap/permit2-sdk';
import { PermitBatchTransferFromData } from '@uniswap/permit2-sdk';
import { v4 as uuidv4 } from 'uuid';
import { IQuote } from '.';
import { DEFAULT_START_TIME_BUFFER_SECS, NATIVE_ADDRESS, RELAY_BASE_GAS, RoutingType } from '../../constants';
import { DEFAULT_START_TIME_BUFFER_SECS, RELAY_BASE_GAS, RoutingType } from '../../constants';
import { generateRandomNonce } from '../../util/nonce';
import { currentTimestampInMs, timestampInMstoSeconds } from '../../util/time';
import { RelayRequest } from '../request/RelayRequest';
Expand All @@ -25,7 +25,7 @@ export type RelayQuoteDataJSON = {
startTimeBufferSecs: number;
auctionPeriodSecs: number;
deadlineBufferSecs: number;
permitData: PermitTransferFromData;
permitData: PermitBatchTransferFromData;
};

export type RelayQuoteJSON = {
Expand All @@ -39,6 +39,8 @@ export type RelayQuoteJSON = {
gasToken: string;
amountInGasToken: string;
swapper: string;
classicAmountInGasAndPortionAdjusted: string;
classicAmountOutGasAndPortionAdjusted: string;
};

type Amounts = {
Expand Down Expand Up @@ -80,7 +82,8 @@ export class RelayQuote implements IQuote {
startAmounts.amountInGasToken,
endAmounts.amountInGasToken,
request.config.swapper,
NATIVE_ADDRESS, // synthetic quote has no filler
quote.amountInGasAndPortionAdjusted,
quote.amountOutGasAndPortionAdjusted,
generateRandomNonce() // synthetic quote has no nonce
);
}
Expand All @@ -103,7 +106,9 @@ export class RelayQuote implements IQuote {
public readonly amountInGasTokenStart: BigNumber,
public readonly amountInGasTokenEnd: BigNumber,
public readonly swapper: string,
public readonly filler?: string,
// Used to compare X quotes vs Relay quotes
public readonly classicAmountInGasAndPortionAdjusted: BigNumber,
public readonly classicAmountOutGasAndPortionAdjusted: BigNumber,
public readonly nonce?: string,
derived?: RelayQuoteDerived
) {
Expand Down Expand Up @@ -172,15 +177,14 @@ export class RelayQuote implements IQuote {
amountInGasToken: this.amountInGasTokenStart.toString(),
endAmountInGasToken: this.amountInGasTokenEnd.toString(),
swapper: this.swapper,
filler: this.filler,
routing: RoutingType[this.routingType],
slippage: parseFloat(this.request.info.slippageTolerance),
createdAt: this.createdAt,
createdAtMs: this.createdAtMs,
};
}

getPermitData(): PermitTransferFromData {
getPermitData(): PermitBatchTransferFromData {
return this.toOrder().permitData();
}

Expand Down

0 comments on commit e61b3a8

Please sign in to comment.