Skip to content

Commit

Permalink
refactor(uniswapx-sdk): DutchV3 witness uses string instead of bigint…
Browse files Browse the repository at this point in the history
… for serialization (#191)
  • Loading branch information
alanhwu authored Nov 7, 2024
1 parent a3b7102 commit 92b2ff0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
8 changes: 6 additions & 2 deletions sdks/uniswapx-sdk/src/order/V3DutchOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ export class UnsignedV3DutchOrder implements OffChainOrder {
startAmount: this.info.input.startAmount,
curve: {
relativeBlocks: encodeRelativeBlocks(this.info.input.curve.relativeBlocks),
relativeAmounts: this.info.input.curve.relativeAmounts,
relativeAmounts: this.info.input.curve.relativeAmounts.map((amount) =>
amount.toString()
),
},
maxAmount: this.info.input.maxAmount,
adjustmentPerGweiBaseFee: this.info.input.adjustmentPerGweiBaseFee,
Expand All @@ -327,7 +329,9 @@ export class UnsignedV3DutchOrder implements OffChainOrder {
startAmount: output.startAmount,
curve: {
relativeBlocks: encodeRelativeBlocks(output.curve.relativeBlocks),
relativeAmounts: output.curve.relativeAmounts,
relativeAmounts: output.curve.relativeAmounts.map((amount) =>
amount.toString()
),
},
recipient: output.recipient,
minAmount: output.minAmount,
Expand Down
18 changes: 12 additions & 6 deletions sdks/uniswapx-sdk/src/order/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface OffChainOrder {
* Returns any block overrides to be applied when quoting the order on chain
* @return The block overrides
*/
get blockOverrides(): BlockOverrides
get blockOverrides(): BlockOverrides;
}

export type TokenAmount = {
Expand Down Expand Up @@ -73,7 +73,7 @@ export type PriorityOrderResolutionOptions = {
export type V3OrderResolutionOptions = {
currentBlock: number;
filler?: string;
}
};

export type DutchOutput = {
readonly token: string;
Expand Down Expand Up @@ -146,7 +146,10 @@ export type V3DutchInput = {
readonly adjustmentPerGweiBaseFee: BigNumber;
};

export type V3DutchInputJSON = Omit<V3DutchInput, "startAmount" | "curve" | "maxAmount" | "adjustmentPerGweiBaseFee"> & {
export type V3DutchInputJSON = Omit<
V3DutchInput,
"startAmount" | "curve" | "maxAmount" | "adjustmentPerGweiBaseFee"
> & {
startAmount: string;
curve: NonlinearDutchDecayJSON;
maxAmount: string;
Expand All @@ -160,7 +163,7 @@ export type NonlinearDutchDecay = {

export type EncodedNonlinearDutchDecay = {
relativeBlocks: BigNumber;
relativeAmounts: bigint[];
relativeAmounts: string[];
};

export type EncodedV3DutchInput = Omit<V3DutchInput, "curve"> & {
Expand All @@ -185,9 +188,12 @@ export type V3DutchOutput = {
readonly adjustmentPerGweiBaseFee: BigNumber;
};

export type V3DutchOutputJSON = Omit<V3DutchOutput, "startAmount" | "curve" | "minAmount" | "adjustmentPerGweiBaseFee"> & {
export type V3DutchOutputJSON = Omit<
V3DutchOutput,
"startAmount" | "curve" | "minAmount" | "adjustmentPerGweiBaseFee"
> & {
startAmount: string;
curve: NonlinearDutchDecayJSON;
minAmount: string;
adjustmentPerGweiBaseFee: string;
};
};

0 comments on commit 92b2ff0

Please sign in to comment.