@pioneer-platform/uniswap-client 0.0.28 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/lib/constants/chainInfo.d.ts +2 -2
  3. package/lib/constants/chainInfo.js +40 -43
  4. package/lib/constants/chains.d.ts +20 -20
  5. package/lib/constants/chains.js +25 -26
  6. package/lib/constants/governance.js +13 -14
  7. package/lib/constants/lists.js +20 -28
  8. package/lib/constants/misc.d.ts +4 -5
  9. package/lib/constants/misc.js +2 -2
  10. package/lib/constants/networks.js +45 -46
  11. package/lib/constants/proposals/uniswap_grants_proposal_description.js +106 -1
  12. package/lib/constants/providers.d.ts +16 -15
  13. package/lib/constants/providers.js +23 -24
  14. package/lib/constants/routing.js +44 -61
  15. package/lib/constants/tokens.d.ts +49 -49
  16. package/lib/constants/tokens.js +133 -170
  17. package/lib/index.js +556 -877
  18. package/lib/routing/clientSideSmartOrderRouter.js +72 -121
  19. package/lib/routing/gas.js +63 -150
  20. package/lib/routing/types.d.ts +7 -7
  21. package/lib/routing/types.js +160 -264
  22. package/lib/routing/utils.js +141 -196
  23. package/lib/rpc/AppJsonRpcProvider.js +40 -131
  24. package/lib/rpc/ConfiguredJsonRpcProvider.d.ts +1 -1
  25. package/lib/rpc/ConfiguredJsonRpcProvider.js +8 -27
  26. package/lib/utils/contracts/getContract.js +6 -7
  27. package/lib/utils/transformSwapRouteToGetQuoteResult.js +24 -27
  28. package/lib/utils/uniswapData.d.ts +6 -6
  29. package/lib/utils/uniswapData.js +64 -142
  30. package/package.json +19 -19
  31. package/tsconfig.json +27 -8
  32. package/lib/constants/chains.test.d.ts +0 -1
  33. package/lib/constants/chains.test.js +0 -26
  34. package/lib/constants/localCurrencies.d.ts +0 -6
  35. package/lib/constants/localCurrencies.js +0 -94
  36. package/lib/constants/localCurrencyIcons.d.ts +0 -18
  37. package/lib/constants/localCurrencyIcons.js +0 -298
  38. package/lib/constants/routing.test.d.ts +0 -1
  39. package/lib/constants/routing.test.js +0 -32
  40. package/lib/constants/tokenLists/broken.tokenlist.json +0 -22
  41. package/lib/constants/tokenLogoLookup.d.ts +0 -8
  42. package/lib/constants/tokenLogoLookup.js +0 -48
  43. package/lib/constants/tokenSafety.js +0 -129
  44. package/lib/constants/tokenSafetyLookup.d.ts +0 -18
  45. package/lib/constants/tokenSafetyLookup.js +0 -66
  46. package/lib/constants/tokenSaftey.test.d.ts +0 -1
  47. package/lib/constants/tokenSaftey.test.js +0 -31
@@ -1,39 +1,13 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __rest = (this && this.__rest) || function (s, e) {
18
- var t = {};
19
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20
- t[p] = s[p];
21
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
22
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
23
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24
- t[p[i]] = s[p[i]];
25
- }
26
- return t;
27
- };
28
- var _a;
29
2
  Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.URAQuoteType = exports.SwapRouterNativeAssets = exports.PoolType = exports.QuoteState = exports.LimitOrderTrade = exports.PreviewTrade = exports.DutchOrderTrade = exports.OFFCHAIN_ORDER_TYPE_TO_SIGNATURE_TYPE = exports.OffchainOrderType = exports.ClassicTrade = exports.TradeFillType = exports.isClassicQuoteResponse = exports.QuoteIntent = exports.RouterPreference = exports.INTERNAL_ROUTER_PREFERENCE_PRICE = exports.QuoteMethod = exports.TradeState = void 0;
31
- var constants_1 = require("@ethersproject/constants");
32
- var router_sdk_1 = require("@uniswap/router-sdk");
33
- var sdk_core_1 = require("@uniswap/sdk-core");
34
- var uniswapx_sdk_1 = require("@uniswap/uniswapx-sdk");
35
- var misc_1 = require("../constants/misc");
36
- var ethers_1 = require("ethers/lib/ethers");
3
+ exports.URAQuoteType = exports.SwapRouterNativeAssets = exports.PoolType = exports.QuoteState = exports.LimitOrderTrade = exports.PreviewTrade = exports.DutchOrderTrade = exports.OFFCHAIN_ORDER_TYPE_TO_SIGNATURE_TYPE = exports.OffchainOrderType = exports.ClassicTrade = exports.TradeFillType = exports.QuoteIntent = exports.RouterPreference = exports.INTERNAL_ROUTER_PREFERENCE_PRICE = exports.QuoteMethod = exports.TradeState = void 0;
4
+ exports.isClassicQuoteResponse = isClassicQuoteResponse;
5
+ const constants_1 = require("@ethersproject/constants");
6
+ const router_sdk_1 = require("@uniswap/router-sdk");
7
+ const sdk_core_1 = require("@uniswap/sdk-core");
8
+ const uniswapx_sdk_1 = require("@uniswap/uniswapx-sdk");
9
+ const misc_1 = require("../constants/misc");
10
+ const ethers_1 = require("ethers/lib/ethers");
37
11
  var SignatureType;
38
12
  (function (SignatureType) {
39
13
  SignatureType["SIGN_UNISWAPX_ORDER"] = "signUniswapXOrder";
@@ -71,65 +45,46 @@ var QuoteIntent;
71
45
  function isClassicQuoteResponse(data) {
72
46
  return data.routing === URAQuoteType.CLASSIC;
73
47
  }
74
- exports.isClassicQuoteResponse = isClassicQuoteResponse;
75
48
  var TradeFillType;
76
49
  (function (TradeFillType) {
77
50
  TradeFillType["Classic"] = "classic";
78
51
  TradeFillType["UniswapX"] = "uniswap_x";
79
52
  TradeFillType["None"] = "none";
80
53
  })(TradeFillType || (exports.TradeFillType = TradeFillType = {}));
81
- var ClassicTrade = /** @class */ (function (_super) {
82
- __extends(ClassicTrade, _super);
83
- function ClassicTrade(_a) {
84
- var _this = this;
85
- var gasUseEstimate = _a.gasUseEstimate, gasUseEstimateUSD = _a.gasUseEstimateUSD, blockNumber = _a.blockNumber, requestId = _a.requestId, quoteMethod = _a.quoteMethod, approveInfo = _a.approveInfo, swapFee = _a.swapFee, routes = __rest(_a, ["gasUseEstimate", "gasUseEstimateUSD", "blockNumber", "requestId", "quoteMethod", "approveInfo", "swapFee"]);
86
- _this = _super.call(this, routes) || this;
87
- _this.fillType = TradeFillType.Classic;
88
- _this.blockNumber = blockNumber;
89
- _this.gasUseEstimateUSD = gasUseEstimateUSD;
90
- _this.requestId = requestId;
91
- _this.quoteMethod = quoteMethod;
92
- _this.approveInfo = approveInfo;
93
- _this.swapFee = swapFee;
94
- _this.gasUseEstimate = gasUseEstimate;
95
- return _this;
54
+ class ClassicTrade extends router_sdk_1.Trade {
55
+ constructor({ gasUseEstimate, gasUseEstimateUSD, blockNumber, requestId, quoteMethod, approveInfo, swapFee, ...routes }) {
56
+ super(routes);
57
+ this.fillType = TradeFillType.Classic;
58
+ this.blockNumber = blockNumber;
59
+ this.gasUseEstimateUSD = gasUseEstimateUSD;
60
+ this.requestId = requestId;
61
+ this.quoteMethod = quoteMethod;
62
+ this.approveInfo = approveInfo;
63
+ this.swapFee = swapFee;
64
+ this.gasUseEstimate = gasUseEstimate;
65
+ }
66
+ get executionPrice() {
67
+ if (this.tradeType === sdk_core_1.TradeType.EXACT_INPUT || !this.swapFee) { // @ts-ignore
68
+ return super.executionPrice;
69
+ }
70
+ // Fix inaccurate price calculation for exact output trades
71
+ return new sdk_core_1.Price({ baseAmount: this.inputAmount, quoteAmount: this.postSwapFeeOutputAmount });
72
+ }
73
+ get postSwapFeeOutputAmount() {
74
+ // Routing api already applies the swap fee to the output amount for exact-in
75
+ if (this.tradeType === sdk_core_1.TradeType.EXACT_INPUT)
76
+ return this.outputAmount;
77
+ const swapFeeAmount = sdk_core_1.CurrencyAmount.fromRawAmount(this.outputAmount.currency, this.swapFee?.amount ?? 0);
78
+ return this.outputAmount.subtract(swapFeeAmount);
79
+ }
80
+ // gas estimate for maybe approve + swap
81
+ get totalGasUseEstimateUSD() {
82
+ if (this.approveInfo.needsApprove && this.gasUseEstimateUSD) {
83
+ return this.approveInfo.approveGasEstimateUSD + this.gasUseEstimateUSD;
84
+ }
85
+ return this.gasUseEstimateUSD;
96
86
  }
97
- Object.defineProperty(ClassicTrade.prototype, "executionPrice", {
98
- get: function () {
99
- if (this.tradeType === sdk_core_1.TradeType.EXACT_INPUT || !this.swapFee) { // @ts-ignore
100
- return _super.prototype.executionPrice;
101
- }
102
- // Fix inaccurate price calculation for exact output trades
103
- return new sdk_core_1.Price({ baseAmount: this.inputAmount, quoteAmount: this.postSwapFeeOutputAmount });
104
- },
105
- enumerable: false,
106
- configurable: true
107
- });
108
- Object.defineProperty(ClassicTrade.prototype, "postSwapFeeOutputAmount", {
109
- get: function () {
110
- var _a, _b;
111
- // Routing api already applies the swap fee to the output amount for exact-in
112
- if (this.tradeType === sdk_core_1.TradeType.EXACT_INPUT)
113
- return this.outputAmount;
114
- var swapFeeAmount = sdk_core_1.CurrencyAmount.fromRawAmount(this.outputAmount.currency, (_b = (_a = this.swapFee) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : 0);
115
- return this.outputAmount.subtract(swapFeeAmount);
116
- },
117
- enumerable: false,
118
- configurable: true
119
- });
120
- Object.defineProperty(ClassicTrade.prototype, "totalGasUseEstimateUSD", {
121
- // gas estimate for maybe approve + swap
122
- get: function () {
123
- if (this.approveInfo.needsApprove && this.gasUseEstimateUSD) {
124
- return this.approveInfo.approveGasEstimateUSD + this.gasUseEstimateUSD;
125
- }
126
- return this.gasUseEstimateUSD;
127
- },
128
- enumerable: false,
129
- configurable: true
130
- });
131
- return ClassicTrade;
132
- }(router_sdk_1.Trade));
87
+ }
133
88
  exports.ClassicTrade = ClassicTrade;
134
89
  var OffchainOrderType;
135
90
  (function (OffchainOrderType) {
@@ -137,55 +92,46 @@ var OffchainOrderType;
137
92
  OffchainOrderType["DUTCH_V2_AUCTION"] = "Dutch_V2";
138
93
  OffchainOrderType["LIMIT_ORDER"] = "Limit";
139
94
  })(OffchainOrderType || (exports.OffchainOrderType = OffchainOrderType = {}));
140
- exports.OFFCHAIN_ORDER_TYPE_TO_SIGNATURE_TYPE = (_a = {},
141
- _a[OffchainOrderType.DUTCH_AUCTION] = SignatureType.SIGN_UNISWAPX_ORDER,
142
- _a[OffchainOrderType.DUTCH_V2_AUCTION] = SignatureType.SIGN_UNISWAPX_V2_ORDER,
143
- _a[OffchainOrderType.LIMIT_ORDER] = SignatureType.SIGN_LIMIT,
144
- _a);
145
- var DutchOrderTrade = /** @class */ (function (_super) {
146
- __extends(DutchOrderTrade, _super);
147
- function DutchOrderTrade(_a) {
148
- var currencyIn = _a.currencyIn, currenciesOut = _a.currenciesOut, orderInfo = _a.orderInfo, tradeType = _a.tradeType, quoteId = _a.quoteId, requestId = _a.requestId, wrapInfo = _a.wrapInfo, approveInfo = _a.approveInfo, classicGasUseEstimateUSD = _a.classicGasUseEstimateUSD, auctionPeriodSecs = _a.auctionPeriodSecs, startTimeBufferSecs = _a.startTimeBufferSecs, deadlineBufferSecs = _a.deadlineBufferSecs, slippageTolerance = _a.slippageTolerance, swapFee = _a.swapFee;
149
- var _this = _super.call(this, { currencyIn: currencyIn, currenciesOut: currenciesOut, orderInfo: orderInfo, tradeType: tradeType }) || this;
150
- _this.fillType = TradeFillType.UniswapX;
151
- _this.offchainOrderType = OffchainOrderType.DUTCH_AUCTION;
152
- _this.inputTax = misc_1.ZERO_PERCENT;
153
- _this.outputTax = misc_1.ZERO_PERCENT;
154
- _this.quoteId = quoteId;
155
- _this.requestId = requestId;
156
- _this.approveInfo = approveInfo;
157
- _this.wrapInfo = wrapInfo;
158
- _this.classicGasUseEstimateUSD = classicGasUseEstimateUSD;
159
- _this.auctionPeriodSecs = auctionPeriodSecs;
160
- _this.deadlineBufferSecs = deadlineBufferSecs;
161
- _this.slippageTolerance = slippageTolerance;
162
- _this.startTimeBufferSecs = startTimeBufferSecs;
163
- _this.swapFee = swapFee;
164
- return _this;
95
+ exports.OFFCHAIN_ORDER_TYPE_TO_SIGNATURE_TYPE = {
96
+ [OffchainOrderType.DUTCH_AUCTION]: SignatureType.SIGN_UNISWAPX_ORDER,
97
+ [OffchainOrderType.DUTCH_V2_AUCTION]: SignatureType.SIGN_UNISWAPX_V2_ORDER,
98
+ [OffchainOrderType.LIMIT_ORDER]: SignatureType.SIGN_LIMIT,
99
+ };
100
+ class DutchOrderTrade extends uniswapx_sdk_1.DutchOrderTrade {
101
+ constructor({ currencyIn, currenciesOut, orderInfo, tradeType, quoteId, requestId, wrapInfo, approveInfo, classicGasUseEstimateUSD, auctionPeriodSecs, startTimeBufferSecs, deadlineBufferSecs, slippageTolerance, swapFee, }) {
102
+ super({ currencyIn, currenciesOut, orderInfo, tradeType });
103
+ this.fillType = TradeFillType.UniswapX;
104
+ this.offchainOrderType = OffchainOrderType.DUTCH_AUCTION;
105
+ this.inputTax = misc_1.ZERO_PERCENT;
106
+ this.outputTax = misc_1.ZERO_PERCENT;
107
+ this.quoteId = quoteId;
108
+ this.requestId = requestId;
109
+ this.approveInfo = approveInfo;
110
+ this.wrapInfo = wrapInfo;
111
+ this.classicGasUseEstimateUSD = classicGasUseEstimateUSD;
112
+ this.auctionPeriodSecs = auctionPeriodSecs;
113
+ this.deadlineBufferSecs = deadlineBufferSecs;
114
+ this.slippageTolerance = slippageTolerance;
115
+ this.startTimeBufferSecs = startTimeBufferSecs;
116
+ this.swapFee = swapFee;
165
117
  }
166
- Object.defineProperty(DutchOrderTrade.prototype, "totalGasUseEstimateUSD", {
167
- get: function () {
168
- if (this.wrapInfo.needsWrap && this.approveInfo.needsApprove) {
169
- return this.wrapInfo.wrapGasEstimateUSD + this.approveInfo.approveGasEstimateUSD;
170
- }
171
- if (this.wrapInfo.needsWrap)
172
- return this.wrapInfo.wrapGasEstimateUSD;
173
- if (this.approveInfo.needsApprove)
174
- return this.approveInfo.approveGasEstimateUSD;
175
- return 0;
176
- },
177
- enumerable: false,
178
- configurable: true
179
- });
180
- DutchOrderTrade.prototype.asDutchOrderTrade = function () {
118
+ get totalGasUseEstimateUSD() {
119
+ if (this.wrapInfo.needsWrap && this.approveInfo.needsApprove) {
120
+ return this.wrapInfo.wrapGasEstimateUSD + this.approveInfo.approveGasEstimateUSD;
121
+ }
122
+ if (this.wrapInfo.needsWrap)
123
+ return this.wrapInfo.wrapGasEstimateUSD;
124
+ if (this.approveInfo.needsApprove)
125
+ return this.approveInfo.approveGasEstimateUSD;
126
+ return 0;
127
+ }
128
+ asDutchOrderTrade() {
181
129
  return this;
182
- };
183
- return DutchOrderTrade;
184
- }(uniswapx_sdk_1.DutchOrderTrade));
130
+ }
131
+ }
185
132
  exports.DutchOrderTrade = DutchOrderTrade;
186
- var PreviewTrade = /** @class */ (function () {
187
- function PreviewTrade(_a) {
188
- var inputAmount = _a.inputAmount, outputAmount = _a.outputAmount, tradeType = _a.tradeType;
133
+ class PreviewTrade {
134
+ constructor({ inputAmount, outputAmount, tradeType, }) {
189
135
  this.fillType = TradeFillType.None;
190
136
  this.quoteMethod = QuoteMethod.QUICK_ROUTE;
191
137
  this.inputAmount = inputAmount;
@@ -194,77 +140,61 @@ var PreviewTrade = /** @class */ (function () {
194
140
  }
195
141
  // below methods are copied from router-sdk
196
142
  // Trade https://github.com/Uniswap/router-sdk/blob/main/src/entities/trade.ts#L10
197
- PreviewTrade.prototype.minimumAmountOut = function (slippageTolerance, amountOut) {
198
- if (amountOut === void 0) { amountOut = this.outputAmount; }
143
+ minimumAmountOut(slippageTolerance, amountOut = this.outputAmount) {
199
144
  if (this.tradeType === sdk_core_1.TradeType.EXACT_OUTPUT) {
200
145
  return amountOut;
201
146
  }
202
147
  else {
203
- var slippageAdjustedAmountOut = new sdk_core_1.Fraction(router_sdk_1.ONE)
148
+ const slippageAdjustedAmountOut = new sdk_core_1.Fraction(router_sdk_1.ONE)
204
149
  .add(slippageTolerance)
205
150
  .invert()
206
151
  .multiply(amountOut.quotient).quotient;
207
152
  return sdk_core_1.CurrencyAmount.fromRawAmount(amountOut.currency, slippageAdjustedAmountOut);
208
153
  }
209
- };
210
- PreviewTrade.prototype.maximumAmountIn = function (slippageTolerance, amountIn) {
211
- if (amountIn === void 0) { amountIn = this.inputAmount; }
154
+ }
155
+ maximumAmountIn(slippageTolerance, amountIn = this.inputAmount) {
212
156
  if (this.tradeType === sdk_core_1.TradeType.EXACT_INPUT) {
213
157
  return amountIn;
214
158
  }
215
159
  else {
216
- var slippageAdjustedAmountIn = new sdk_core_1.Fraction(router_sdk_1.ONE).add(slippageTolerance).multiply(amountIn.quotient).quotient;
160
+ const slippageAdjustedAmountIn = new sdk_core_1.Fraction(router_sdk_1.ONE).add(slippageTolerance).multiply(amountIn.quotient).quotient;
217
161
  return sdk_core_1.CurrencyAmount.fromRawAmount(amountIn.currency, slippageAdjustedAmountIn);
218
162
  }
219
- };
220
- Object.defineProperty(PreviewTrade.prototype, "inputTax", {
221
- /**
222
- * Returns the sell tax of the input token
223
- */
224
- get: function () {
225
- var inputCurrency = this.inputAmount.currency;
226
- if (inputCurrency.isNative || !inputCurrency.wrapped.sellFeeBps)
227
- return misc_1.ZERO_PERCENT;
228
- return new sdk_core_1.Percent(inputCurrency.wrapped.sellFeeBps.toNumber(), 10000);
229
- },
230
- enumerable: false,
231
- configurable: true
232
- });
233
- Object.defineProperty(PreviewTrade.prototype, "outputTax", {
234
- /**
235
- * Returns the buy tax of the output token
236
- */
237
- get: function () {
238
- var outputCurrency = this.outputAmount.currency;
239
- if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps)
240
- return misc_1.ZERO_PERCENT;
241
- return new sdk_core_1.Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
242
- },
243
- enumerable: false,
244
- configurable: true
245
- });
246
- Object.defineProperty(PreviewTrade.prototype, "executionPrice", {
247
- /**
248
- * The price expressed in terms of output amount/input amount.
249
- */
250
- get: function () {
251
- var _a;
252
- return ((_a = this._executionPrice) !== null && _a !== void 0 ? _a : (this._executionPrice = new sdk_core_1.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient)));
253
- },
254
- enumerable: false,
255
- configurable: true
256
- });
257
- PreviewTrade.prototype.worstExecutionPrice = function (slippageTolerance) {
163
+ }
164
+ /**
165
+ * Returns the sell tax of the input token
166
+ */
167
+ get inputTax() {
168
+ const inputCurrency = this.inputAmount.currency;
169
+ if (inputCurrency.isNative || !inputCurrency.wrapped.sellFeeBps)
170
+ return misc_1.ZERO_PERCENT;
171
+ return new sdk_core_1.Percent(inputCurrency.wrapped.sellFeeBps.toNumber(), 10000);
172
+ }
173
+ /**
174
+ * Returns the buy tax of the output token
175
+ */
176
+ get outputTax() {
177
+ const outputCurrency = this.outputAmount.currency;
178
+ if (outputCurrency.isNative || !outputCurrency.wrapped.buyFeeBps)
179
+ return misc_1.ZERO_PERCENT;
180
+ return new sdk_core_1.Percent(outputCurrency.wrapped.buyFeeBps.toNumber(), 10000);
181
+ }
182
+ /**
183
+ * The price expressed in terms of output amount/input amount.
184
+ */
185
+ get executionPrice() {
186
+ return (this._executionPrice ??
187
+ (this._executionPrice = new sdk_core_1.Price(this.inputAmount.currency, this.outputAmount.currency, this.inputAmount.quotient, this.outputAmount.quotient)));
188
+ }
189
+ worstExecutionPrice(slippageTolerance) {
258
190
  return new sdk_core_1.Price(this.inputAmount.currency, this.outputAmount.currency, this.maximumAmountIn(slippageTolerance).quotient, this.minimumAmountOut(slippageTolerance).quotient);
259
- };
260
- return PreviewTrade;
261
- }());
191
+ }
192
+ }
262
193
  exports.PreviewTrade = PreviewTrade;
263
194
  // TODO(limits): get this from uniswapx-sdk
264
- var UNISWAPX_REACTOR = '0x6000da47483062a0d734ba3dc7576ce6a0b645c4';
265
- var LimitOrderTrade = /** @class */ (function () {
266
- function LimitOrderTrade(_a) {
267
- var tradeType = _a.tradeType, amountIn = _a.amountIn, amountOut = _a.amountOut, deadlineBufferSecs = _a.deadlineBufferSecs, swapFee = _a.swapFee, wrapInfo = _a.wrapInfo, approveInfo = _a.approveInfo, swapper = _a.swapper;
195
+ const UNISWAPX_REACTOR = '0x6000da47483062a0d734ba3dc7576ce6a0b645c4';
196
+ class LimitOrderTrade {
197
+ constructor({ tradeType, amountIn, amountOut, deadlineBufferSecs, swapFee, wrapInfo, approveInfo, swapper, }) {
268
198
  this.fillType = TradeFillType.UniswapX;
269
199
  this.offchainOrderType = OffchainOrderType.LIMIT_ORDER;
270
200
  // Placeholder values that aren't used in a limit trade
@@ -282,35 +212,34 @@ var LimitOrderTrade = /** @class */ (function () {
282
212
  this.tradeType = tradeType;
283
213
  this.swapper = swapper;
284
214
  // deadline is shown in the review modal, but updated on submission
285
- var nowSecs = Math.floor(Date.now() / 1000);
215
+ const nowSecs = Math.floor(Date.now() / 1000);
286
216
  this.deadline = (nowSecs + deadlineBufferSecs) * 1000;
287
217
  }
288
- LimitOrderTrade.prototype.asDutchOrderTrade = function (options) {
289
- var _a, _b, _c;
290
- var swapperOutput = {
218
+ asDutchOrderTrade(options) {
219
+ const swapperOutput = {
291
220
  token: this.amountOut.currency.isNative ? constants_1.AddressZero : this.amountOut.currency.address,
292
- recipient: (_a = options === null || options === void 0 ? void 0 : options.swapper) !== null && _a !== void 0 ? _a : this.swapper,
221
+ recipient: options?.swapper ?? this.swapper,
293
222
  startAmount: ethers_1.BigNumber.from(this.amountOut.quotient.toString()),
294
223
  endAmount: ethers_1.BigNumber.from(this.amountOut.quotient.toString()),
295
224
  };
296
- var swapFee = this.swapFee && {
225
+ const swapFee = this.swapFee && {
297
226
  token: this.amountOut.currency.isNative ? constants_1.AddressZero : this.amountOut.currency.address,
298
227
  recipient: this.swapFee.recipient,
299
228
  startAmount: ethers_1.BigNumber.from(this.amountOut.multiply(this.swapFee.percent).quotient.toString()),
300
229
  endAmount: ethers_1.BigNumber.from(this.amountOut.multiply(this.swapFee.percent).quotient.toString()),
301
230
  };
302
- var outputs = swapFee ? [swapperOutput, swapFee] : [swapperOutput];
303
- var nowSecs = Math.floor(Date.now() / 1000);
231
+ const outputs = swapFee ? [swapperOutput, swapFee] : [swapperOutput];
232
+ const nowSecs = Math.floor(Date.now() / 1000);
304
233
  return new uniswapx_sdk_1.DutchOrderTrade({
305
234
  currencyIn: this.amountIn.currency,
306
235
  currenciesOut: [this.amountOut.currency],
307
236
  orderInfo: {
308
237
  reactor: UNISWAPX_REACTOR,
309
- swapper: (_b = options === null || options === void 0 ? void 0 : options.swapper) !== null && _b !== void 0 ? _b : this.swapper,
238
+ swapper: options?.swapper ?? this.swapper,
310
239
  deadline: (nowSecs + this.deadlineBufferSecs) * 1000,
311
240
  additionalValidationContract: constants_1.AddressZero,
312
241
  additionalValidationData: '0x',
313
- nonce: (_c = options === null || options === void 0 ? void 0 : options.nonce) !== null && _c !== void 0 ? _c : ethers_1.BigNumber.from(0),
242
+ nonce: options?.nonce ?? ethers_1.BigNumber.from(0),
314
243
  // decay timings dont matter at all
315
244
  decayStartTime: nowSecs,
316
245
  decayEndTime: nowSecs,
@@ -321,81 +250,48 @@ var LimitOrderTrade = /** @class */ (function () {
321
250
  startAmount: ethers_1.BigNumber.from(this.amountIn.quotient.toString()),
322
251
  endAmount: ethers_1.BigNumber.from(this.amountIn.quotient.toString()),
323
252
  },
324
- outputs: outputs,
253
+ outputs,
325
254
  },
326
255
  tradeType: this.tradeType,
327
256
  });
328
- };
329
- Object.defineProperty(LimitOrderTrade.prototype, "inputAmount", {
330
- get: function () {
331
- return this.amountIn;
332
- },
333
- enumerable: false,
334
- configurable: true
335
- });
336
- Object.defineProperty(LimitOrderTrade.prototype, "outputAmount", {
337
- get: function () {
338
- return this.amountOut;
339
- },
340
- enumerable: false,
341
- configurable: true
342
- });
343
- Object.defineProperty(LimitOrderTrade.prototype, "postTaxOutputAmount", {
344
- /** For UniswapX, handling token taxes in the output amount is outsourced to quoters */
345
- get: function () {
346
- return this.outputAmount;
347
- },
348
- enumerable: false,
349
- configurable: true
350
- });
351
- Object.defineProperty(LimitOrderTrade.prototype, "totalGasUseEstimateUSD", {
352
- get: function () {
353
- return this.wrapInfo.needsWrap ? this.wrapInfo.wrapGasEstimateUSD : 0;
354
- },
355
- enumerable: false,
356
- configurable: true
357
- });
358
- Object.defineProperty(LimitOrderTrade.prototype, "classicGasUseEstimateUSD", {
359
- get: function () {
360
- return 0;
361
- },
362
- enumerable: false,
363
- configurable: true
364
- });
365
- Object.defineProperty(LimitOrderTrade.prototype, "startTimeBufferSecs", {
366
- // no decay for limit orders
367
- get: function () {
368
- return 0;
369
- },
370
- enumerable: false,
371
- configurable: true
372
- });
373
- Object.defineProperty(LimitOrderTrade.prototype, "auctionPeriodSecs", {
374
- // no decay auction for limit orders
375
- get: function () {
376
- return 0;
377
- },
378
- enumerable: false,
379
- configurable: true
380
- });
381
- Object.defineProperty(LimitOrderTrade.prototype, "executionPrice", {
382
- get: function () {
383
- return new sdk_core_1.Price(this.amountIn.currency, this.amountOut.currency, this.amountIn.quotient, this.amountOut.quotient);
384
- },
385
- enumerable: false,
386
- configurable: true
387
- });
388
- LimitOrderTrade.prototype.worstExecutionPrice = function () {
257
+ }
258
+ get inputAmount() {
259
+ return this.amountIn;
260
+ }
261
+ get outputAmount() {
262
+ return this.amountOut;
263
+ }
264
+ /** For UniswapX, handling token taxes in the output amount is outsourced to quoters */
265
+ get postTaxOutputAmount() {
266
+ return this.outputAmount;
267
+ }
268
+ get totalGasUseEstimateUSD() {
269
+ return this.wrapInfo.needsWrap ? this.wrapInfo.wrapGasEstimateUSD : 0;
270
+ }
271
+ get classicGasUseEstimateUSD() {
272
+ return 0;
273
+ }
274
+ // no decay for limit orders
275
+ get startTimeBufferSecs() {
276
+ return 0;
277
+ }
278
+ // no decay auction for limit orders
279
+ get auctionPeriodSecs() {
280
+ return 0;
281
+ }
282
+ get executionPrice() {
283
+ return new sdk_core_1.Price(this.amountIn.currency, this.amountOut.currency, this.amountIn.quotient, this.amountOut.quotient);
284
+ }
285
+ worstExecutionPrice() {
389
286
  return this.executionPrice;
390
- };
391
- LimitOrderTrade.prototype.maximumAmountIn = function () {
287
+ }
288
+ maximumAmountIn() {
392
289
  return this.inputAmount;
393
- };
394
- LimitOrderTrade.prototype.minimumAmountOut = function () {
290
+ }
291
+ minimumAmountOut() {
395
292
  return this.outputAmount;
396
- };
397
- return LimitOrderTrade;
398
- }());
293
+ }
294
+ }
399
295
  exports.LimitOrderTrade = LimitOrderTrade;
400
296
  var QuoteState;
401
297
  (function (QuoteState) {