Socket
Socket
Sign inDemoInstall

@uniswap/uniswapx-sdk

Package Overview
Dependencies
Maintainers
23
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@uniswap/uniswapx-sdk - npm Package Compare versions

Comparing version 2.0.1-alpha.9 to 2.0.1-alpha.10

38

dist/src/builder/V2DutchOrderBuilder.js

@@ -21,3 +21,3 @@ "use strict";

this.info = {
baseOutputs: [],
outputs: [],
cosignerData: {

@@ -38,3 +38,3 @@ decayStartTime: 0,

.nonce(order.info.nonce)
.input(order.info.baseInput)
.input(order.info.input)
.cosigner(order.info.cosigner)

@@ -45,3 +45,3 @@ .validation({

});
for (const output of order.info.baseOutputs) {
for (const output of order.info.outputs) {
builder.output(output);

@@ -79,3 +79,3 @@ }

input(input) {
this.info.baseInput = input;
this.info.input = input;
return this;

@@ -86,3 +86,3 @@ }

(0, tiny_invariant_1.default)(output.startAmount.gte(output.endAmount), `startAmount must be greater than endAmount: ${output.startAmount.toString()}`);
(_a = this.info.baseOutputs) === null || _a === void 0 ? void 0 : _a.push(output);
(_a = this.info.outputs) === null || _a === void 0 ? void 0 : _a.push(output);
return this;

@@ -115,6 +115,6 @@ }

(0, tiny_invariant_1.default)(newRecipient !== feeRecipient, `newRecipient must be different from feeRecipient: ${newRecipient}`);
if (!this.info.baseOutputs) {
if (!this.info.outputs) {
return this;
}
this.info.baseOutputs = this.info.baseOutputs.map((output) => {
this.info.outputs = this.info.outputs.map((output) => {
// if fee output then pass through

@@ -195,5 +195,5 @@ if (feeRecipient &&

(0, tiny_invariant_1.default)(this.info.cosigner !== undefined, "cosigner not set");
(0, tiny_invariant_1.default)(this.info.baseInput !== undefined, "input not set");
(0, tiny_invariant_1.default)(this.info.baseOutputs && this.info.baseOutputs.length > 0, "outputs not set");
(0, tiny_invariant_1.default)(this.info.baseInput !== undefined, "original input not set");
(0, tiny_invariant_1.default)(this.info.input !== undefined, "input not set");
(0, tiny_invariant_1.default)(this.info.outputs && this.info.outputs.length > 0, "outputs not set");
(0, tiny_invariant_1.default)(this.info.input !== undefined, "original input not set");
(0, tiny_invariant_1.default)(!this.orderInfo.deadline ||

@@ -206,4 +206,4 @@ (this.info.cosignerData &&

return new order_1.UnsignedV2DutchOrder(Object.assign(this.getOrderInfo(), {
baseInput: this.info.baseInput,
baseOutputs: this.info.baseOutputs,
input: this.info.input,
outputs: this.info.outputs,
cosigner: this.info.cosigner,

@@ -215,4 +215,4 @@ }), this.chainId, this.permit2Address);

(0, tiny_invariant_1.default)(this.info.cosignature !== undefined, "cosignature not set");
(0, tiny_invariant_1.default)(this.info.baseInput !== undefined, "input not set");
(0, tiny_invariant_1.default)(this.info.baseOutputs && this.info.baseOutputs.length > 0, "outputs not set");
(0, tiny_invariant_1.default)(this.info.input !== undefined, "input not set");
(0, tiny_invariant_1.default)(this.info.outputs && this.info.outputs.length > 0, "outputs not set");
(0, tiny_invariant_1.default)(this.info.cosignerData !== undefined, "cosignerData not set");

@@ -225,8 +225,8 @@ (0, tiny_invariant_1.default)(this.info.cosignerData.decayStartTime !== undefined, "decayStartTime not set");

(0, tiny_invariant_1.default)(this.info.cosignerData.inputOverride !== undefined &&
this.info.cosignerData.inputOverride.lte(this.info.baseInput.startAmount), "inputOverride not set or larger than original input");
this.info.cosignerData.inputOverride.lte(this.info.input.startAmount), "inputOverride not set or larger than original input");
(0, tiny_invariant_1.default)(this.info.cosignerData.outputOverrides.length > 0, "outputOverrides not set");
this.info.cosignerData.outputOverrides.forEach((override, idx) => {
(0, tiny_invariant_1.default)(override.gte(this.info.baseOutputs[idx].startAmount), "outputOverride must be larger than or equal to original output");
(0, tiny_invariant_1.default)(override.gte(this.info.outputs[idx].startAmount), "outputOverride must be larger than or equal to original output");
});
(0, tiny_invariant_1.default)(this.info.baseInput !== undefined, "original input not set");
(0, tiny_invariant_1.default)(this.info.input !== undefined, "original input not set");
(0, tiny_invariant_1.default)(!this.orderInfo.deadline ||

@@ -238,4 +238,4 @@ this.info.cosignerData.decayStartTime <= this.orderInfo.deadline, `decayStartTime must be before or same as deadline: ${this.info.cosignerData.decayStartTime}`);

cosignerData: this.info.cosignerData,
baseInput: this.info.baseInput,
baseOutputs: this.info.baseOutputs,
input: this.info.input,
outputs: this.info.outputs,
cosigner: this.info.cosigner,

@@ -242,0 +242,0 @@ cosignature: this.info.cosignature,

@@ -41,3 +41,3 @@ "use strict";

expect(order.info.cosignerData.decayStartTime).toEqual(deadline - 100);
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
});

@@ -74,3 +74,3 @@ it("Builds a valid order with validation", () => {

expect(order.info.cosignerData.decayStartTime).toEqual(deadline - 100);
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
expect(order.validation).toEqual({

@@ -182,3 +182,3 @@ type: validation_1.ValidationType.ExclusiveFiller,

expect(order.info.cosignerData.decayStartTime).toEqual(deadline - 100);
expect(order.info.baseOutputs.length).toEqual(2);
expect(order.info.outputs.length).toEqual(2);
});

@@ -354,3 +354,3 @@ it("cosigner not set", () => {

expect(order.info.cosignerData.decayEndTime).toEqual(deadline);
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
});

@@ -381,3 +381,3 @@ it("deadline defaults to decayEndTime", () => {

expect(order.info.deadline).toEqual(decayEndTime);
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
});

@@ -512,3 +512,3 @@ it("startAmount <= endAmount", () => {

.buildPartial();
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
});

@@ -536,3 +536,3 @@ it("builds an unsigned partial order with incomplete cosignerData values", () => {

.buildPartial();
expect(order.info.baseOutputs.length).toEqual(1);
expect(order.info.outputs.length).toEqual(1);
});

@@ -539,0 +539,0 @@ });

@@ -25,4 +25,4 @@ import { SignatureLike } from "@ethersproject/bytes";

cosigner: string;
baseInput: DutchInput;
baseOutputs: DutchOutput[];
input: DutchInput;
outputs: DutchOutput[];
};

@@ -33,6 +33,6 @@ export declare type CosignedV2DutchOrderInfo = UnsignedV2DutchOrderInfo & {

};
export declare type UnsignedV2DutchOrderInfoJSON = Omit<UnsignedV2DutchOrderInfo, "nonce" | "baseInput" | "baseOutputs" | "cosignerData"> & {
export declare type UnsignedV2DutchOrderInfoJSON = Omit<UnsignedV2DutchOrderInfo, "nonce" | "input" | "outputs" | "cosignerData"> & {
nonce: string;
baseInput: DutchInputJSON;
baseOutputs: DutchOutputJSON[];
input: DutchInputJSON;
outputs: DutchOutputJSON[];
};

@@ -39,0 +39,0 @@ export declare type CosignedV2DutchOrderInfoJSON = UnsignedV2DutchOrderInfoJSON & {

@@ -53,7 +53,7 @@ "use strict";

static fromJSON(json, chainId, _permit2Address) {
return new UnsignedV2DutchOrder(Object.assign(Object.assign({}, json), { nonce: ethers_1.BigNumber.from(json.nonce), baseInput: {
token: json.baseInput.token,
startAmount: ethers_1.BigNumber.from(json.baseInput.startAmount),
endAmount: ethers_1.BigNumber.from(json.baseInput.endAmount),
}, baseOutputs: json.baseOutputs.map((output) => ({
return new UnsignedV2DutchOrder(Object.assign(Object.assign({}, json), { nonce: ethers_1.BigNumber.from(json.nonce), input: {
token: json.input.token,
startAmount: ethers_1.BigNumber.from(json.input.startAmount),
endAmount: ethers_1.BigNumber.from(json.input.endAmount),
}, outputs: json.outputs.map((output) => ({
token: output.token,

@@ -81,8 +81,8 @@ startAmount: ethers_1.BigNumber.from(output.startAmount),

additionalValidationData: this.info.additionalValidationData,
baseInput: {
token: this.info.baseInput.token,
startAmount: this.info.baseInput.startAmount.toString(),
endAmount: this.info.baseInput.endAmount.toString(),
input: {
token: this.info.input.token,
startAmount: this.info.input.startAmount.toString(),
endAmount: this.info.input.endAmount.toString(),
},
baseOutputs: this.info.baseOutputs.map((output) => ({
outputs: this.info.outputs.map((output) => ({
token: output.token,

@@ -113,7 +113,7 @@ startAmount: output.startAmount.toString(),

[
this.info.baseInput.token,
this.info.baseInput.startAmount,
this.info.baseInput.endAmount,
this.info.input.token,
this.info.input.startAmount,
this.info.input.endAmount,
],
this.info.baseOutputs.map((output) => [
this.info.outputs.map((output) => [
output.token,

@@ -168,4 +168,4 @@ output.startAmount,

permitted: {
token: this.info.baseInput.token,
amount: this.info.baseInput.endAmount,
token: this.info.input.token,
amount: this.info.input.endAmount,
},

@@ -188,6 +188,6 @@ spender: this.info.reactor,

cosigner: this.info.cosigner,
baseInputToken: this.info.baseInput.token,
baseInputStartAmount: this.info.baseInput.startAmount,
baseInputEndAmount: this.info.baseInput.endAmount,
baseOutputs: this.info.baseOutputs,
baseInputToken: this.info.input.token,
baseInputStartAmount: this.info.input.startAmount,
baseInputEndAmount: this.info.input.endAmount,
baseOutputs: this.info.outputs,
};

@@ -236,7 +236,7 @@ }

static fromJSON(json, chainId, _permit2Address) {
return new CosignedV2DutchOrder(Object.assign(Object.assign({}, json), { nonce: ethers_1.BigNumber.from(json.nonce), baseInput: {
token: json.baseInput.token,
startAmount: ethers_1.BigNumber.from(json.baseInput.startAmount),
endAmount: ethers_1.BigNumber.from(json.baseInput.endAmount),
}, baseOutputs: json.baseOutputs.map((output) => ({
return new CosignedV2DutchOrder(Object.assign(Object.assign({}, json), { nonce: ethers_1.BigNumber.from(json.nonce), input: {
token: json.input.token,
startAmount: ethers_1.BigNumber.from(json.input.startAmount),
endAmount: ethers_1.BigNumber.from(json.input.endAmount),
}, outputs: json.outputs.map((output) => ({
token: output.token,

@@ -278,11 +278,11 @@ startAmount: ethers_1.BigNumber.from(output.startAmount),

input: {
token: this.info.baseInput.token,
token: this.info.input.token,
amount: (0, dutchDecay_1.getDecayedAmount)({
decayStartTime: this.info.cosignerData.decayStartTime,
decayEndTime: this.info.cosignerData.decayEndTime,
startAmount: originalIfZero(this.info.cosignerData.inputOverride, this.info.baseInput.startAmount),
endAmount: this.info.baseInput.endAmount,
startAmount: originalIfZero(this.info.cosignerData.inputOverride, this.info.input.startAmount),
endAmount: this.info.input.endAmount,
}, options.timestamp),
},
outputs: this.info.baseOutputs.map((output, idx) => {
outputs: this.info.outputs.map((output, idx) => {
return {

@@ -317,7 +317,7 @@ token: output.token,

[
this.info.baseInput.token,
this.info.baseInput.startAmount,
this.info.baseInput.endAmount,
this.info.input.token,
this.info.input.startAmount,
this.info.input.endAmount,
],
this.info.baseOutputs.map((output) => [
this.info.outputs.map((output) => [
output.token,

@@ -364,3 +364,3 @@ output.startAmount,

cosigner,
baseInput: {
input: {
token: inputToken,

@@ -370,3 +370,3 @@ startAmount: inputStartAmount,

},
baseOutputs: outputs.map(([token, startAmount, endAmount, recipient]) => {
outputs: outputs.map(([token, startAmount, endAmount, recipient]) => {
return {

@@ -373,0 +373,0 @@ token,

@@ -29,3 +29,3 @@ "use strict";

cosignerData: COSIGNER_DATA,
baseInput: {
input: {
token: INPUT_TOKEN,

@@ -35,3 +35,3 @@ startAmount: RAW_AMOUNT,

},
baseOutputs: [
outputs: [
{

@@ -57,3 +57,3 @@ token: OUTPUT_TOKEN,

cosignerData: undefined,
baseInput: {
input: {
token: INPUT_TOKEN,

@@ -63,3 +63,3 @@ startAmount: RAW_AMOUNT,

},
baseOutputs: [
outputs: [
{

@@ -83,7 +83,7 @@ token: OUTPUT_TOKEN,

it("parses the inner v2 order with no cosignerOverrides", () => {
const orderInfoJSON = Object.assign(Object.assign({}, getOrderInfo({})), { nonce: "10", baseInput: {
const orderInfoJSON = Object.assign(Object.assign({}, getOrderInfo({})), { nonce: "10", input: {
token: INPUT_TOKEN,
startAmount: "1000000",
endAmount: "1000000",
}, baseOutputs: [
}, outputs: [
{

@@ -97,4 +97,4 @@ token: OUTPUT_TOKEN,

const order = V2DutchOrder_1.UnsignedV2DutchOrder.fromJSON(orderInfoJSON, 1);
expect(order.info.baseInput.startAmount).toEqual(ethers_1.BigNumber.from("1000000"));
expect(order.info.baseOutputs[0].startAmount).toEqual(ethers_1.BigNumber.from("1000000"));
expect(order.info.input.startAmount).toEqual(ethers_1.BigNumber.from("1000000"));
expect(order.info.outputs[0].startAmount).toEqual(ethers_1.BigNumber.from("1000000"));
});

@@ -128,5 +128,5 @@ it("valid signature over inner order", () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.cosignerData.outputOverrides[0]);

@@ -148,6 +148,6 @@ });

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.amount).toEqual(order.info.baseInput.startAmount);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.baseOutputs[0].startAmount);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.input.startAmount);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.outputs[0].startAmount);
});

@@ -159,6 +159,6 @@ it("resolves at decayStartTime", () => {

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.cosignerData.outputOverrides[0]);

@@ -171,7 +171,7 @@ });

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.baseOutputs[0].endAmount);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.outputs[0].endAmount);
});

@@ -183,7 +183,7 @@ it("resolves after decayEndTime", () => {

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.baseOutputs[0].endAmount);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.outputs[0].endAmount);
});

@@ -206,6 +206,6 @@ it("resolves when filler has exclusivity", () => {

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.cosignerData.outputOverrides[0]);

@@ -230,6 +230,6 @@ });

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.cosignerData.outputOverrides[0]);

@@ -254,7 +254,7 @@ });

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.baseOutputs[0].endAmount);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.outputs[0].endAmount);
});

@@ -276,6 +276,6 @@ it("resolves when filler is not set but there is exclusivity", () => {

});
expect(resolved.input.token).toEqual(order.info.baseInput.token);
expect(resolved.input.token).toEqual(order.info.input.token);
expect(resolved.input.amount).toEqual(order.info.cosignerData.inputOverride);
expect(resolved.outputs.length).toEqual(1);
expect(resolved.outputs[0].token).toEqual(order.info.baseOutputs[0].token);
expect(resolved.outputs[0].token).toEqual(order.info.outputs[0].token);
expect(resolved.outputs[0].amount).toEqual(order.info.cosignerData.outputOverrides[0]);

@@ -282,0 +282,0 @@ });

@@ -18,3 +18,3 @@ "use strict";

return this._inputAmount;
const amount = sdk_core_1.CurrencyAmount.fromRawAmount(this._currencyIn, this.order.info.baseInput.startAmount.toString());
const amount = sdk_core_1.CurrencyAmount.fromRawAmount(this._currencyIn, this.order.info.input.startAmount.toString());
this._inputAmount = amount;

@@ -26,3 +26,3 @@ return amount;

return this._outputAmounts;
const amounts = this.order.info.baseOutputs.map((output) => {
const amounts = this.order.info.outputs.map((output) => {
// assume single chain ids across all outputs for now

@@ -41,6 +41,6 @@ const currencyOut = this._currenciesOut.find((currency) => (0, utils_1.areCurrenciesEqual)(currency, output.token, currency.chainId));

return this._firstNonFeeOutputStartEndAmounts;
if (this.order.info.baseOutputs.length === 0) {
if (this.order.info.outputs.length === 0) {
throw new Error("there must be at least one output token");
}
const output = this.order.info.baseOutputs[0];
const output = this.order.info.outputs[0];
// assume single chain ids across all outputs for now

@@ -66,3 +66,3 @@ const currencyOut = this._currenciesOut.find((currency) => (0, utils_1.areCurrenciesEqual)(currency, output.token, currency.chainId));

maximumAmountIn() {
return sdk_core_1.CurrencyAmount.fromRawAmount(this._currencyIn, this.order.info.baseInput.endAmount.toString());
return sdk_core_1.CurrencyAmount.fromRawAmount(this._currencyIn, this.order.info.input.endAmount.toString());
}

@@ -69,0 +69,0 @@ /**

@@ -20,3 +20,3 @@ "use strict";

additionalValidationData: "0x",
baseInput: {
input: {
token: USDC.address,

@@ -26,3 +26,3 @@ startAmount: ethers_1.BigNumber.from(1000),

},
baseOutputs: [
outputs: [
{

@@ -49,3 +49,3 @@ token: DAI.address,

it("returns the right input amount for an exact-in trade", () => {
expect(trade.inputAmount.quotient.toString()).toEqual(orderInfo.baseInput.startAmount.toString());
expect(trade.inputAmount.quotient.toString()).toEqual(orderInfo.input.startAmount.toString());
});

@@ -59,3 +59,3 @@ it("returns the correct non-fee output amount", () => {

it("works for native output trades", () => {
const ethOutputOrderInfo = Object.assign(Object.assign({}, orderInfo), { baseOutputs: [
const ethOutputOrderInfo = Object.assign(Object.assign({}, orderInfo), { outputs: [
{

@@ -77,3 +77,3 @@ token: utils_1.NativeAssets.ETH,

it("works for native output trades where order info has 0 address", () => {
const ethOutputOrderInfo = Object.assign(Object.assign({}, orderInfo), { baseOutputs: [
const ethOutputOrderInfo = Object.assign(Object.assign({}, orderInfo), { outputs: [
{

@@ -80,0 +80,0 @@ token: ethers_1.constants.AddressZero,

{
"name": "@uniswap/uniswapx-sdk",
"author": "Uniswap",
"version": "2.0.1-alpha.9",
"version": "2.0.1-alpha.10",
"license": "MIT",

@@ -6,0 +6,0 @@ "main": "dist/src/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc