@tokenlon/v6-sdk 1.0.6-canary.db97cd2 → 1.0.6-canary.df3ee2c

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 (88) hide show
  1. package/dist/cjs/constants/abis.js +40 -526
  2. package/dist/cjs/constants/abis.js.map +1 -1
  3. package/dist/cjs/constants/addresses.js +5 -58
  4. package/dist/cjs/constants/addresses.js.map +1 -1
  5. package/dist/cjs/constants/chains.js +2 -22
  6. package/dist/cjs/constants/chains.js.map +1 -1
  7. package/dist/cjs/constants/index.js +0 -1
  8. package/dist/cjs/constants/index.js.map +1 -1
  9. package/dist/cjs/constants/unit.js +1 -2
  10. package/dist/cjs/constants/unit.js.map +1 -1
  11. package/dist/cjs/price/index.js +2 -2
  12. package/dist/cjs/price/index.js.map +1 -1
  13. package/dist/cjs/sdk.js +5 -7
  14. package/dist/cjs/sdk.js.map +1 -1
  15. package/dist/cjs/service/contextHost.js +0 -19
  16. package/dist/cjs/service/contextHost.js.map +1 -1
  17. package/dist/cjs/serviceHost.js +1 -65
  18. package/dist/cjs/serviceHost.js.map +1 -1
  19. package/dist/cjs/swap/index.js +113 -725
  20. package/dist/cjs/swap/index.js.map +1 -1
  21. package/dist/cjs/swap/type.js +1 -6
  22. package/dist/cjs/swap/type.js.map +1 -1
  23. package/dist/cjs/version.js +1 -1
  24. package/dist/esm/constants/abis.js +39 -525
  25. package/dist/esm/constants/abis.js.map +1 -1
  26. package/dist/esm/constants/addresses.js +4 -57
  27. package/dist/esm/constants/addresses.js.map +1 -1
  28. package/dist/esm/constants/chains.js +3 -23
  29. package/dist/esm/constants/chains.js.map +1 -1
  30. package/dist/esm/constants/index.js +0 -1
  31. package/dist/esm/constants/index.js.map +1 -1
  32. package/dist/esm/constants/unit.js +0 -1
  33. package/dist/esm/constants/unit.js.map +1 -1
  34. package/dist/esm/price/index.js +3 -3
  35. package/dist/esm/price/index.js.map +1 -1
  36. package/dist/esm/sdk.js +5 -7
  37. package/dist/esm/sdk.js.map +1 -1
  38. package/dist/esm/service/contextHost.js +0 -19
  39. package/dist/esm/service/contextHost.js.map +1 -1
  40. package/dist/esm/serviceHost.js +1 -65
  41. package/dist/esm/serviceHost.js.map +1 -1
  42. package/dist/esm/swap/index.js +115 -726
  43. package/dist/esm/swap/index.js.map +1 -1
  44. package/dist/esm/swap/type.js +1 -5
  45. package/dist/esm/swap/type.js.map +1 -1
  46. package/dist/esm/version.js +1 -1
  47. package/dist/tsconfig.build.tsbuildinfo +1 -1
  48. package/dist/types/constants/abis.d.ts +14 -381
  49. package/dist/types/constants/abis.d.ts.map +1 -1
  50. package/dist/types/constants/addresses.d.ts +0 -2
  51. package/dist/types/constants/addresses.d.ts.map +1 -1
  52. package/dist/types/constants/chains.d.ts +1 -1
  53. package/dist/types/constants/chains.d.ts.map +1 -1
  54. package/dist/types/constants/index.d.ts +0 -1
  55. package/dist/types/constants/index.d.ts.map +1 -1
  56. package/dist/types/constants/unit.d.ts +0 -1
  57. package/dist/types/constants/unit.d.ts.map +1 -1
  58. package/dist/types/errors/base.d.ts +1 -1
  59. package/dist/types/sdk.d.ts +0 -1
  60. package/dist/types/sdk.d.ts.map +1 -1
  61. package/dist/types/service/contextHost.d.ts +1 -3
  62. package/dist/types/service/contextHost.d.ts.map +1 -1
  63. package/dist/types/serviceHost.d.ts +0 -3
  64. package/dist/types/serviceHost.d.ts.map +1 -1
  65. package/dist/types/swap/index.d.ts +28 -123
  66. package/dist/types/swap/index.d.ts.map +1 -1
  67. package/dist/types/swap/type.d.ts +23 -106
  68. package/dist/types/swap/type.d.ts.map +1 -1
  69. package/dist/types/version.d.ts +1 -1
  70. package/package.json +3 -3
  71. package/dist/cjs/constants/RFQAbi.js +0 -723
  72. package/dist/cjs/constants/RFQAbi.js.map +0 -1
  73. package/dist/cjs/constants/common.js +0 -5
  74. package/dist/cjs/constants/common.js.map +0 -1
  75. package/dist/cjs/types/token.js +0 -3
  76. package/dist/cjs/types/token.js.map +0 -1
  77. package/dist/esm/constants/RFQAbi.js +0 -721
  78. package/dist/esm/constants/RFQAbi.js.map +0 -1
  79. package/dist/esm/constants/common.js +0 -2
  80. package/dist/esm/constants/common.js.map +0 -1
  81. package/dist/esm/types/token.js +0 -2
  82. package/dist/esm/types/token.js.map +0 -1
  83. package/dist/types/constants/RFQAbi.d.ts +0 -82
  84. package/dist/types/constants/RFQAbi.d.ts.map +0 -1
  85. package/dist/types/constants/common.d.ts +0 -2
  86. package/dist/types/constants/common.d.ts.map +0 -1
  87. package/dist/types/types/token.d.ts +0 -11
  88. package/dist/types/types/token.d.ts.map +0 -1
@@ -1,13 +1,13 @@
1
- import { DEFAULT_GAS_LIMIT, GENERIC_SWAP_ABI, GS_EIP712_TYPES, MAX_UINT256, RFQ_ABI, apiVersion, bpBase, feeReceiptAddress, genericSwapAddress, nullAddress, rfqAddress, strategyAddress, usdtAddress, wrapperTokenAddress, } from '../constants/index.js';
1
+ import { DEFAULT_GAS_LIMIT, GENERIC_SWAP_ABI, GS_EIP712_TYPES, MAX_UINT256, bpBase, feeReceiptAddress, genericSwapAddress, nullAddress, strategyAddress, usdtAddress, wethAddress, } from '../constants/index.js';
2
2
  import { ContextHost } from '../service/contextHost.js';
3
3
  import { PermitSource } from '../types/permit2.js';
4
4
  import { http } from '../utils/request/index.js';
5
- import { defaultServiceHost, estimateGasServiceHost, httpServiceHost, } from './../serviceHost.js';
6
- import { OrderType, } from './type.js';
5
+ import { httpServiceHost } from './../serviceHost.js';
6
+ import {} from './type.js';
7
7
  import { JsonRpcProvider } from 'ethers';
8
8
  import { decodeAbiParameters, encodeAbiParameters, encodeFunctionData, encodePacked, isAddressEqual, parseAbiItem, parseAbiParameters, zeroAddress, } from 'viem';
9
- export const strategyOperationsABI = parseAbiParameters('(address dest, address inputToken, uint256 ratioNumerator, uint256 ratioDenominator, uint256 dataOffset, uint256 value, bytes data)[]');
10
- export const l2StrategyOperationsABI = parseAbiParameters('(address dest, address inputToken, uint128 inputRatio, uint128 dataOffset, uint256 value, bytes data)[]');
9
+ export const strategyOperationsABI = parseAbiParameters('(address dest, address inputToken, uint128 inputRatio, uint128 dataOffset, uint256 value, bytes data)[]');
10
+ export const ERC20_TRANSFER_GAS = 65000n;
11
11
  export class Swap extends ContextHost {
12
12
  constructor(config, injected) {
13
13
  super({ env: config.env, chainId: config.chain }, {
@@ -36,7 +36,6 @@ export class Swap extends ContextHost {
36
36
  configurable: true,
37
37
  writable: true,
38
38
  value: (fee, swapData, operations) => {
39
- const isMainnetOrSepoliaOrder = this.isMainnetOrSepolia();
40
39
  const newOperations = [...operations];
41
40
  if (fee > 0n) {
42
41
  const feeTransfer = encodeFunctionData({
@@ -44,75 +43,34 @@ export class Swap extends ContextHost {
44
43
  functionName: 'transfer',
45
44
  args: [feeReceiptAddress[this.chainId], fee],
46
45
  });
47
- if (!wrapperTokenAddress[this.chainId])
48
- throw new Error('wrapper token address not found');
49
- const feeToken = this.isNativeToken(swapData.makerToken)
50
- ? wrapperTokenAddress[this.chainId]
46
+ if (!wethAddress[this.chainId])
47
+ throw new Error('weth address not found');
48
+ const feeToken = this.isETH(swapData.makerToken)
49
+ ? wethAddress[this.chainId]
51
50
  : swapData.makerToken;
52
- const feeOperation = isMainnetOrSepoliaOrder
53
- ? {
54
- dest: feeToken,
55
- inputToken: feeToken,
56
- ratioNumerator: 0n,
57
- ratioDenominator: 0n,
58
- dataOffset: 0n,
59
- value: 0n,
60
- data: feeTransfer,
61
- }
62
- : {
63
- dest: feeToken,
64
- inputToken: feeToken,
65
- inputRatio: 0n,
66
- dataOffset: 0n,
67
- value: 0n,
68
- data: feeTransfer,
69
- };
51
+ const feeOperation = {
52
+ dest: feeToken,
53
+ inputToken: feeToken,
54
+ inputRatio: 0n,
55
+ dataOffset: 0n,
56
+ value: 0n,
57
+ data: feeTransfer,
58
+ };
70
59
  newOperations.push(feeOperation);
71
60
  }
72
- const targetStrategyOperationsABI = isMainnetOrSepoliaOrder
73
- ? strategyOperationsABI
74
- : l2StrategyOperationsABI;
75
- const newStrategyData = encodeAbiParameters(targetStrategyOperationsABI, [
61
+ const newStrategyData = encodeAbiParameters(strategyOperationsABI, [
76
62
  newOperations,
77
63
  ]);
78
64
  return newStrategyData;
79
65
  }
80
66
  });
81
- Object.defineProperty(this, "formatRFQOrderParams", {
82
- enumerable: true,
83
- configurable: true,
84
- writable: true,
85
- value: (order) => {
86
- const encodeResult = order.encodeResult;
87
- const rfqTx = encodeResult.rfqTx;
88
- const rfqOffer = rfqTx.rfqOffer ?? {};
89
- const { fromAddress } = order;
90
- const { makerTokenAmount } = rfqOffer;
91
- const value = BigInt(this.isNativeToken(fromAddress) ? rfqOffer.takerTokenAmount : '0x0');
92
- const fee = (BigInt(makerTokenAmount) * BigInt(rfqOffer.feeFactor)) / bpBase;
93
- const minMakerTokenAmount = BigInt(makerTokenAmount) - fee;
94
- return {
95
- rfqOffer,
96
- rfqTx,
97
- value,
98
- fee,
99
- minMakerTokenAmount: minMakerTokenAmount,
100
- makerTokenAmount: BigInt(rfqOffer.makerTokenAmount),
101
- takerTokenAmount: BigInt(rfqOffer.takerTokenAmount),
102
- takerRequestAmount: rfqTx.takerRequestAmount,
103
- };
104
- }
105
- });
106
67
  Object.defineProperty(this, "getProtocolFeeAmount", {
107
68
  enumerable: true,
108
69
  configurable: true,
109
70
  writable: true,
110
71
  value: (order) => {
111
- const { protocolFeeFactor: feeFactor } = order;
112
- const isSOROrder = order?.orderType === OrderType.SOR;
113
- const makerTokenAmount = isSOROrder
114
- ? order?.encodeResult?.swapData?.makerTokenAmount
115
- : order?.encodeResult?.rfqTx?.rfqOffer?.makerTokenAmount;
72
+ const { swapData, feeFactor } = order;
73
+ const { makerTokenAmount } = swapData;
116
74
  const protocolFeeAmount = (BigInt(makerTokenAmount) * BigInt(feeFactor)) / bpBase;
117
75
  return protocolFeeAmount;
118
76
  }
@@ -122,10 +80,8 @@ export class Swap extends ContextHost {
122
80
  configurable: true,
123
81
  writable: true,
124
82
  value: (order, slippage) => {
125
- const isSOROrder = order?.orderType === OrderType.SOR;
126
- const makerTokenAmount = isSOROrder
127
- ? order?.encodeResult?.swapData?.makerTokenAmount
128
- : order?.encodeResult?.rfqTx?.rfqOffer?.makerTokenAmount;
83
+ const { swapData } = order;
84
+ const { makerTokenAmount } = swapData;
129
85
  const slippageAmount = (BigInt(makerTokenAmount) * BigInt(slippage)) / bpBase;
130
86
  return slippageAmount;
131
87
  }
@@ -147,63 +103,8 @@ export class Swap extends ContextHost {
147
103
  enumerable: true,
148
104
  configurable: true,
149
105
  writable: true,
150
- value: async ({ protocolFeeAmount, gasFeeTokenAmount, }) => {
151
- return gasFeeTokenAmount + protocolFeeAmount;
152
- }
153
- });
154
- Object.defineProperty(this, "getL2RoutesApproveStrategy", {
155
- enumerable: true,
156
- configurable: true,
157
- writable: true,
158
- value: async (strategyAddress, takerToken, takerTokenAmount, routes = []) => {
159
- const isNativeToken = isAddressEqual(takerToken, zeroAddress) ||
160
- isAddressEqual(takerToken, nullAddress);
161
- const approvedToken = isNativeToken
162
- ? wrapperTokenAddress[this.chainId]
163
- : takerToken;
164
- if (!strategyAddress) {
165
- throw new Error(`cannot find strategyAddress on current chain ${this.chainId}`);
166
- }
167
- const namedSpenders = routes.flat(2).reduce((acc, route) => {
168
- route.spender && acc.add(route.spender);
169
- return acc;
170
- }, new Set());
171
- const spenders = [...namedSpenders];
172
- const allowances = await Promise.all([
173
- ...spenders.map((spender) => this.publicClient.readContract({
174
- abi: [
175
- parseAbiItem('function allowance(address owner, address spender) view returns (uint256)'),
176
- ],
177
- functionName: 'allowance',
178
- address: approvedToken,
179
- args: [strategyAddress, spender],
180
- })),
181
- ]);
182
- return allowances.reduce((acc, allowance, index) => {
183
- try {
184
- if (BigInt(allowance) < BigInt(takerTokenAmount)) {
185
- const data = encodeFunctionData({
186
- abi: [
187
- parseAbiItem('function approve(address spender, uint256 amount) returns (bool)'),
188
- ],
189
- functionName: 'approve',
190
- args: [spenders[index], MAX_UINT256],
191
- });
192
- acc.push({
193
- dest: approvedToken,
194
- inputToken: approvedToken,
195
- inputRatio: 0n,
196
- dataOffset: 0n,
197
- value: 0n,
198
- data,
199
- });
200
- }
201
- return acc;
202
- }
203
- catch {
204
- return acc;
205
- }
206
- }, []);
106
+ value: async ({ protocolFeeAmount, feeTokenAmount, }) => {
107
+ return feeTokenAmount + protocolFeeAmount;
207
108
  }
208
109
  });
209
110
  Object.defineProperty(this, "getRoutesApproveStrategy", {
@@ -211,10 +112,8 @@ export class Swap extends ContextHost {
211
112
  configurable: true,
212
113
  writable: true,
213
114
  value: async (takerTokenAmount, needApprovalDestinations) => {
214
- if (!Array.isArray(needApprovalDestinations) ||
215
- needApprovalDestinations.length === 0) {
115
+ if (needApprovalDestinations.length === 0)
216
116
  return [];
217
- }
218
117
  const allowances = await Promise.all([
219
118
  ...needApprovalDestinations.map(({ dest, inputToken }) => this.publicClient.readContract({
220
119
  abi: [
@@ -239,8 +138,7 @@ export class Swap extends ContextHost {
239
138
  const approveOperation = {
240
139
  dest: inputToken,
241
140
  inputToken: inputToken,
242
- ratioNumerator: 0n,
243
- ratioDenominator: 0n,
141
+ inputRatio: 0n,
244
142
  dataOffset: 0n,
245
143
  value: 0n,
246
144
  data: approve,
@@ -259,8 +157,7 @@ export class Swap extends ContextHost {
259
157
  const approveOperation = {
260
158
  dest: inputToken,
261
159
  inputToken: inputToken,
262
- ratioNumerator: 0n,
263
- ratioDenominator: 0n,
160
+ inputRatio: 0n,
264
161
  dataOffset: 0n,
265
162
  value: 0n,
266
163
  data: approve2Zero,
@@ -278,260 +175,63 @@ export class Swap extends ContextHost {
278
175
  return approveStrategies;
279
176
  }
280
177
  });
281
- Object.defineProperty(this, "preview", {
282
- enumerable: true,
283
- configurable: true,
284
- writable: true,
285
- value: async (params) => {
286
- let preview;
287
- let { order, gasFee = 0n, sendByRelayer } = params;
288
- if (order.orderType === OrderType.SOR) {
289
- order = order;
290
- const sorPrepare = await this.prepareOrder(params);
291
- const { swapData, fee, protocolFee, gasFeeTokenAmount } = sorPrepare;
292
- preview = {
293
- inputToken: swapData.takerToken,
294
- outputToken: swapData.makerToken,
295
- amountIn: swapData.takerTokenAmount,
296
- amountOut: swapData.makerTokenAmount,
297
- minAmountOut: swapData.minMakerTokenAmount,
298
- recipient: swapData.recipient,
299
- fee,
300
- protocolFee,
301
- gasFeeTokenAmount,
302
- feeFactor: order.protocolFeeFactor,
303
- };
304
- }
305
- else if (order.orderType === OrderType.RFQV6) {
306
- order = order;
307
- const { rfqTx } = order.encodeResult;
308
- const { rfqOffer } = rfqTx;
309
- const protocolFeeAmount = this.getProtocolFeeAmount(order);
310
- const { fee, minMakerTokenAmount } = this.formatRFQOrderParams(order);
311
- let gasFeeTokenAmount = gasFee;
312
- if (sendByRelayer) {
313
- gasFeeTokenAmount = await this.calcGasFeeTokenAmount({
314
- gasFeeAmount: gasFee,
315
- feeToken: rfqOffer.makerToken,
316
- });
317
- }
318
- preview = {
319
- inputToken: rfqOffer.takerToken,
320
- outputToken: rfqOffer.makerToken,
321
- amountIn: BigInt(rfqOffer.takerTokenAmount),
322
- amountOut: BigInt(rfqOffer.makerTokenAmount),
323
- minAmountOut: minMakerTokenAmount,
324
- recipient: rfqTx.recipient,
325
- fee,
326
- protocolFee: protocolFeeAmount,
327
- gasFeeTokenAmount,
328
- feeFactor: order.protocolFeeFactor,
329
- };
330
- }
331
- else {
332
- throw new Error('unsupported order type');
333
- }
334
- return preview;
335
- }
336
- });
337
- Object.defineProperty(this, "previewNewOrder", {
338
- enumerable: true,
339
- configurable: true,
340
- writable: true,
341
- value: async (params) => {
342
- let preview;
343
- let { order, slippage, sendByRelayer, gasFee = 0n } = params;
344
- if (order.orderType === OrderType.SOR) {
345
- order = order;
346
- const encodeResult = order.encodeResult ?? {};
347
- const { swapData } = encodeResult;
348
- const { makerToken } = swapData;
349
- const makerTokenAmount = BigInt(swapData.makerTokenAmount);
350
- const slippageAmount = this.getSlippageAmount(order, slippage);
351
- const protocolFeeAmount = this.getProtocolFeeAmount(order);
352
- let fee = protocolFeeAmount;
353
- let gasFeeTokenAmount = gasFee;
354
- if (sendByRelayer) {
355
- gasFeeTokenAmount = await this.calcGasFeeTokenAmount({
356
- gasFeeAmount: gasFee,
357
- feeToken: makerToken,
358
- });
359
- fee = await this.calcRelayerFee({
360
- protocolFeeAmount,
361
- gasFeeTokenAmount,
362
- });
363
- }
364
- const minMakerTokenAmount = makerTokenAmount - slippageAmount - fee;
365
- swapData.minMakerTokenAmount = minMakerTokenAmount.toString();
366
- preview = {
367
- inputToken: swapData.takerToken,
368
- outputToken: swapData.makerToken,
369
- amountIn: BigInt(swapData.takerTokenAmount),
370
- amountOut: BigInt(swapData.makerTokenAmount),
371
- minAmountOut: BigInt(swapData.minMakerTokenAmount),
372
- recipient: swapData.recipient,
373
- fee,
374
- protocolFee: protocolFeeAmount,
375
- gasFeeTokenAmount,
376
- feeFactor: order.protocolFeeFactor,
377
- };
378
- }
379
- else if (order.orderType === OrderType.RFQV6) {
380
- order = order;
381
- const { rfqTx } = order.encodeResult;
382
- const { rfqOffer } = rfqTx;
383
- const protocolFeeAmount = this.getProtocolFeeAmount(order);
384
- const { fee, minMakerTokenAmount } = this.formatRFQOrderParams(order);
385
- let gasFeeTokenAmount = gasFee;
386
- if (sendByRelayer) {
387
- gasFeeTokenAmount = await this.calcGasFeeTokenAmount({
388
- gasFeeAmount: gasFee,
389
- feeToken: rfqOffer.makerToken,
390
- });
391
- }
392
- preview = {
393
- inputToken: rfqOffer.takerToken,
394
- outputToken: rfqOffer.makerToken,
395
- amountIn: BigInt(rfqOffer.takerTokenAmount),
396
- amountOut: BigInt(rfqOffer.makerTokenAmount),
397
- minAmountOut: minMakerTokenAmount,
398
- recipient: rfqTx.recipient,
399
- fee,
400
- protocolFee: protocolFeeAmount,
401
- gasFeeTokenAmount,
402
- feeFactor: order.protocolFeeFactor,
403
- };
404
- }
405
- else {
406
- throw new Error('unsupported order type');
407
- }
408
- return preview;
409
- }
410
- });
411
178
  Object.defineProperty(this, "prepareOrder", {
412
179
  enumerable: true,
413
180
  configurable: true,
414
181
  writable: true,
415
182
  value: async ({ order, slippage, gasFee = 0n, sendByRelayer, }) => {
416
- let prepare;
417
- if (order.orderType === OrderType.SOR) {
418
- order = order;
419
- const isMainnetOrSepoliaOrder = this.isMainnetOrSepolia();
420
- const encodeResult = order.encodeResult ?? {};
421
- const { swapData, needApprovalDestinations } = encodeResult;
422
- const { recipient, strategyData, makerToken, takerToken } = swapData;
423
- const makerTokenAmount = BigInt(swapData.makerTokenAmount);
424
- const slippageAmount = this.getSlippageAmount(order, slippage);
425
- const protocolFeeAmount = this.getProtocolFeeAmount(order);
426
- const value = isAddressEqual(swapData.takerToken, nullAddress) ||
427
- isAddressEqual(swapData.takerToken, zeroAddress)
428
- ? BigInt(swapData.takerTokenAmount)
429
- : 0n;
430
- let fee = protocolFeeAmount;
431
- let gasFeeTokenAmount = gasFee;
432
- if (isMainnetOrSepoliaOrder) {
433
- if (sendByRelayer) {
434
- gasFeeTokenAmount = await this.calcGasFeeTokenAmount({
435
- gasFeeAmount: gasFee,
436
- feeToken: makerToken,
437
- });
438
- fee = await this.calcRelayerFee({
439
- protocolFeeAmount,
440
- gasFeeTokenAmount,
441
- });
442
- }
443
- const minMakerTokenAmount = makerTokenAmount - slippageAmount - fee;
444
- swapData.minMakerTokenAmount = minMakerTokenAmount.toString();
445
- const [operations] = decodeAbiParameters(strategyOperationsABI, strategyData);
446
- const approveOperations = await this.getRoutesApproveStrategy(BigInt(swapData.takerTokenAmount), needApprovalDestinations);
447
- const newStrategyData = this.rebuildStrategyData(fee, swapData, [
448
- ...approveOperations,
449
- ...operations,
450
- ]);
451
- const newSwapData = {
452
- ...swapData,
453
- strategyData: newStrategyData,
454
- takerTokenAmount: BigInt(swapData.takerTokenAmount),
455
- makerTokenAmount: BigInt(swapData.makerTokenAmount),
456
- minMakerTokenAmount: BigInt(swapData.minMakerTokenAmount),
457
- salt: BigInt(swapData.salt),
458
- expiry: BigInt(swapData.expiry),
459
- };
460
- prepare = {
461
- swapData: newSwapData,
462
- protocolFee: protocolFeeAmount,
463
- gasFeeTokenAmount,
464
- gasFee,
465
- fee,
466
- recipient,
467
- strategyData: newStrategyData,
468
- value,
469
- minMakerTokenAmount,
470
- makerTokenAmount: newSwapData.makerTokenAmount,
471
- takerTokenAmount: newSwapData.takerTokenAmount,
472
- };
473
- }
474
- else {
475
- const { address: strategyAddress } = order.strategies[0];
476
- const minMakerTokenAmount = makerTokenAmount - slippageAmount - fee;
477
- swapData.minMakerTokenAmount = minMakerTokenAmount.toString();
478
- const [operations] = decodeAbiParameters(l2StrategyOperationsABI, strategyData);
479
- const approveOperations = await this.getL2RoutesApproveStrategy(strategyAddress, takerToken, BigInt(swapData.takerTokenAmount), order.routes);
480
- const newStrategyData = this.rebuildStrategyData(fee, swapData, [
481
- ...approveOperations,
482
- ...operations,
483
- ]);
484
- const newSwapData = {
485
- ...swapData,
486
- strategyData: newStrategyData,
487
- takerTokenAmount: BigInt(swapData.takerTokenAmount),
488
- makerTokenAmount: BigInt(swapData.makerTokenAmount),
489
- minMakerTokenAmount: BigInt(swapData.minMakerTokenAmount),
490
- salt: BigInt(swapData.salt),
491
- expiry: BigInt(swapData.expiry),
492
- };
493
- prepare = {
494
- swapData: newSwapData,
495
- protocolFee: protocolFeeAmount,
496
- gasFeeTokenAmount,
497
- gasFee,
498
- fee,
499
- recipient,
500
- strategyData: newStrategyData,
501
- value,
502
- minMakerTokenAmount,
503
- makerTokenAmount: newSwapData.makerTokenAmount,
504
- takerTokenAmount: newSwapData.takerTokenAmount,
505
- };
506
- }
507
- }
508
- else if (order.orderType === OrderType.RFQV6) {
509
- order = order;
510
- const protocolFeeAmount = this.getProtocolFeeAmount(order);
511
- const rfqOrderParams = this.formatRFQOrderParams(order);
512
- prepare = {
513
- ...rfqOrderParams,
514
- protocolFee: protocolFeeAmount,
515
- };
516
- }
517
- else {
518
- throw new Error('unsupported order type');
183
+ const { swapData, needApprovalDestinations } = order;
184
+ const { recipient, strategyData, makerToken } = swapData;
185
+ const makerTokenAmount = BigInt(swapData.makerTokenAmount);
186
+ const slippageAmount = this.getSlippageAmount(order, slippage);
187
+ const protocolFeeAmount = this.getProtocolFeeAmount(order);
188
+ let fee = protocolFeeAmount;
189
+ let feeTokenAmount = gasFee;
190
+ if (sendByRelayer) {
191
+ feeTokenAmount = await this.calcGasFeeTokenAmount({
192
+ gasFeeAmount: gasFee,
193
+ feeToken: makerToken,
194
+ });
195
+ fee = await this.calcRelayerFee({
196
+ protocolFeeAmount,
197
+ feeTokenAmount,
198
+ });
519
199
  }
520
- return prepare;
521
- }
522
- });
523
- Object.defineProperty(this, "getTokenList", {
524
- enumerable: true,
525
- configurable: true,
526
- writable: true,
527
- value: async (chainId) => {
528
- if (!chainId)
529
- chainId = this.chainId;
530
- const tokenList = await http(`${this.specialHost(httpServiceHost)}/${apiVersion}/swap/tokenlist/${chainId}`);
531
- return tokenList;
200
+ const minMakerTokenAmount = makerTokenAmount - slippageAmount - fee;
201
+ swapData.minMakerTokenAmount = minMakerTokenAmount.toString();
202
+ const [operations] = decodeAbiParameters(strategyOperationsABI, strategyData);
203
+ const approveOperations = await this.getRoutesApproveStrategy(swapData.takerTokenAmount, needApprovalDestinations);
204
+ const newStrategyData = this.rebuildStrategyData(fee, swapData, [
205
+ ...approveOperations,
206
+ ...operations,
207
+ ]);
208
+ const value = isAddressEqual(swapData.takerToken, nullAddress) ||
209
+ isAddressEqual(swapData.takerToken, zeroAddress)
210
+ ? BigInt(swapData.takerTokenAmount)
211
+ : 0n;
212
+ const newSwapData = {
213
+ ...swapData,
214
+ strategyData: newStrategyData,
215
+ takerTokenAmount: BigInt(swapData.takerTokenAmount),
216
+ makerTokenAmount: BigInt(swapData.makerTokenAmount),
217
+ minMakerTokenAmount: BigInt(swapData.minMakerTokenAmount),
218
+ salt: BigInt(swapData.salt),
219
+ expiry: BigInt(swapData.expiry),
220
+ };
221
+ return {
222
+ swapData: newSwapData,
223
+ protocolFee: protocolFeeAmount,
224
+ gasFeeTokenAmount: feeTokenAmount,
225
+ gasFee,
226
+ fee,
227
+ recipient,
228
+ operations,
229
+ strategyData: newStrategyData,
230
+ value,
231
+ };
532
232
  }
533
233
  });
534
- Object.defineProperty(this, "quoteNewOrder", {
234
+ Object.defineProperty(this, "quote", {
535
235
  enumerable: true,
536
236
  configurable: true,
537
237
  writable: true,
@@ -544,16 +244,7 @@ export class Swap extends ContextHost {
544
244
  Object.entries(dto).forEach(([key, value]) => {
545
245
  p.append(key, value.toString());
546
246
  });
547
- const order = await http(`${this.specialHost(httpServiceHost)}/${apiVersion}/swap/quote/${chainId}?${p.toString()}`);
548
- return order;
549
- }
550
- });
551
- Object.defineProperty(this, "quoteLastOrder", {
552
- enumerable: true,
553
- configurable: true,
554
- writable: true,
555
- value: async (uniqueId) => {
556
- const order = await http(`${this.specialHost(httpServiceHost)}/${apiVersion}/swap/swap/${this.chainId}?uniqueId=${uniqueId}`);
247
+ const order = await http(`${this.host(httpServiceHost)}/v6/swap/quote/${chainId}?${p.toString()}`);
557
248
  return order;
558
249
  }
559
250
  });
@@ -564,13 +255,13 @@ export class Swap extends ContextHost {
564
255
  value: (token, permitType = PermitSource.Permit2AllowanceTransfer) => {
565
256
  const permitToAllowanceTarget = encodePacked(['uint8', 'bytes'], [permitType, '0x']);
566
257
  let takerTokenPermit = permitToAllowanceTarget;
567
- if (this.isNativeToken(token)) {
258
+ if (this.isETH(token)) {
568
259
  takerTokenPermit = '0x';
569
260
  }
570
261
  return takerTokenPermit;
571
262
  }
572
263
  });
573
- Object.defineProperty(this, "isNativeToken", {
264
+ Object.defineProperty(this, "isETH", {
574
265
  enumerable: true,
575
266
  configurable: true,
576
267
  writable: true,
@@ -579,95 +270,16 @@ export class Swap extends ContextHost {
579
270
  isAddressEqual(tokenAddress, zeroAddress));
580
271
  }
581
272
  });
582
- Object.defineProperty(this, "isMainnetOrSepolia", {
583
- enumerable: true,
584
- configurable: true,
585
- writable: true,
586
- value: () => {
587
- const chainId = this.chainId;
588
- return chainId === 1 || chainId === 11155111;
589
- }
590
- });
591
- Object.defineProperty(this, "estimateByApi", {
592
- enumerable: true,
593
- configurable: true,
594
- writable: true,
595
- value: async (order, sendByRelayer, useAll = true) => {
596
- if (!useAll) {
597
- const { gas_usage } = await http(`${this.host(estimateGasServiceHost)}/estimate/v6/gastable`, {
598
- fetchOptions: {
599
- method: 'POST',
600
- },
601
- body: {
602
- ...order,
603
- },
604
- });
605
- return BigInt(gas_usage || DEFAULT_GAS_LIMIT);
606
- }
607
- const { gas_table, simulation } = await http(`${this.host(estimateGasServiceHost)}/estimate/v6/all`, {
608
- fetchOptions: {
609
- method: 'POST',
610
- },
611
- body: {
612
- ...order,
613
- },
614
- });
615
- const simulationResult = simulation?.gas_usage + (sendByRelayer ? 31000 : 0);
616
- return BigInt(simulationResult || gas_table?.gas_usage || DEFAULT_GAS_LIMIT);
617
- }
618
- });
619
- Object.defineProperty(this, "estimateRFQOrder", {
620
- enumerable: true,
621
- configurable: true,
622
- writable: true,
623
- value: async ({ account, order, takerTokenPermit, }) => {
624
- const { encodeResult } = order;
625
- const { rfqTx } = encodeResult;
626
- const { rfqOffer } = rfqTx;
627
- const { value } = this.formatRFQOrderParams(order);
628
- const gasEstimate = await this.publicClient.estimateContractGas({
629
- address: rfqAddress[this.chainId],
630
- abi: RFQ_ABI,
631
- functionName: 'fillRFQ',
632
- args: [
633
- [
634
- [
635
- rfqOffer.taker,
636
- rfqOffer.maker,
637
- rfqOffer.takerToken,
638
- rfqOffer.takerTokenAmount,
639
- rfqOffer.makerToken,
640
- rfqOffer.makerTokenAmount,
641
- rfqOffer.feeFactor,
642
- rfqOffer.flags,
643
- rfqOffer.expiry,
644
- rfqOffer.salt,
645
- ],
646
- rfqTx.recipient,
647
- rfqTx.takerRequestAmount,
648
- ],
649
- encodeResult.makerSignature,
650
- encodeResult.makerTokenPermit,
651
- takerTokenPermit,
652
- ],
653
- value,
654
- account,
655
- });
656
- return gasEstimate;
657
- }
658
- });
659
- Object.defineProperty(this, "estimateSOROrder", {
273
+ Object.defineProperty(this, "estimate", {
660
274
  enumerable: true,
661
275
  configurable: true,
662
276
  writable: true,
663
- value: async ({ account, order, slippage, takerTokenPermit, }) => {
664
- const prepare = await this.prepareOrder({
277
+ value: async ({ account, order, slippage, permit, }) => {
278
+ const { swapData, value } = await this.prepareOrder({
665
279
  order,
666
280
  slippage,
667
281
  });
668
- const { swapData, value } = prepare;
669
- takerTokenPermit =
670
- takerTokenPermit ?? this.getTokenPermitData(swapData.takerToken);
282
+ const takerTokenPermit = permit ?? this.getTokenPermitData(swapData.takerToken);
671
283
  const gasEstimate = await this.publicClient.estimateContractGas({
672
284
  address: genericSwapAddress[this.chainId],
673
285
  abi: GENERIC_SWAP_ABI,
@@ -679,102 +291,50 @@ export class Swap extends ContextHost {
679
291
  return gasEstimate;
680
292
  }
681
293
  });
682
- Object.defineProperty(this, "estimate", {
294
+ Object.defineProperty(this, "estimateByApi", {
683
295
  enumerable: true,
684
296
  configurable: true,
685
297
  writable: true,
686
- value: async ({ account, order, slippage, takerTokenPermit, }) => {
687
- if (order.orderType === OrderType.SOR) {
688
- order = order;
689
- const { swapData } = order.encodeResult;
690
- takerTokenPermit =
691
- takerTokenPermit ?? this.getTokenPermitData(swapData.takerToken);
692
- return await this.estimateSOROrder({
693
- account,
694
- order: order,
695
- slippage,
696
- takerTokenPermit,
697
- });
698
- }
699
- else if (order.orderType === OrderType.RFQV6) {
700
- order = order;
701
- const rfqOffer = order?.encodeResult?.rfqTx?.rfqOffer ?? {};
702
- takerTokenPermit =
703
- takerTokenPermit ?? this.getTokenPermitData(rfqOffer.takerToken);
704
- return await this.estimateRFQOrder({
705
- account,
706
- order: order,
707
- takerTokenPermit,
298
+ value: async (order) => {
299
+ let gasEstimate = DEFAULT_GAS_LIMIT;
300
+ try {
301
+ const { gas_usage } = await http(`${this.host(httpServiceHost)}/v1/estimate/gastable`, {
302
+ fetchOptions: {
303
+ method: 'POST',
304
+ },
305
+ body: {
306
+ ...order,
307
+ },
708
308
  });
309
+ gasEstimate = BigInt(gas_usage);
709
310
  }
710
- else {
711
- throw new Error('unsupported order type');
311
+ catch (error) {
312
+ console.log('failed to estimate gas by api', error);
712
313
  }
314
+ return gasEstimate;
713
315
  }
714
316
  });
715
317
  Object.defineProperty(this, "estimateWithFallback", {
716
318
  enumerable: true,
717
319
  configurable: true,
718
320
  writable: true,
719
- value: async ({ account, order, slippage, sendByRelayer, takerTokenPermit, }) => {
720
- let gasEstimate;
321
+ value: async ({ account, order, slippage, permit, }) => {
322
+ let gasEstimate = DEFAULT_GAS_LIMIT;
721
323
  try {
722
324
  gasEstimate = await this.estimate({
723
325
  account,
724
326
  order,
725
327
  slippage,
726
- takerTokenPermit,
328
+ permit,
727
329
  });
728
330
  }
729
331
  catch (_error) {
730
- gasEstimate = await this.estimateByApi(order, sendByRelayer);
332
+ gasEstimate = await this.estimateByApi(order);
731
333
  }
732
334
  return gasEstimate;
733
335
  }
734
336
  });
735
- Object.defineProperty(this, "signRFQOrder", {
736
- enumerable: true,
737
- configurable: true,
738
- writable: true,
739
- value: async (params) => {
740
- const { account, value = 0n, txOverride, order, takerTokenPermit } = params;
741
- const { encodeResult } = order;
742
- const { rfqTx } = encodeResult;
743
- const { rfqOffer } = rfqTx;
744
- const txHash = await this.walletClient.writeContract({
745
- address: rfqAddress[this.chainId],
746
- abi: RFQ_ABI,
747
- account,
748
- functionName: 'fillRFQ',
749
- args: [
750
- [
751
- [
752
- rfqOffer.taker,
753
- rfqOffer.maker,
754
- rfqOffer.takerToken,
755
- rfqOffer.takerTokenAmount,
756
- rfqOffer.makerToken,
757
- rfqOffer.makerTokenAmount,
758
- rfqOffer.feeFactor,
759
- rfqOffer.flags,
760
- rfqOffer.expiry,
761
- rfqOffer.salt,
762
- ],
763
- rfqTx.recipient,
764
- rfqTx.takerRequestAmount,
765
- ],
766
- encodeResult.makerSignature,
767
- encodeResult.makerTokenPermit,
768
- takerTokenPermit,
769
- ],
770
- value,
771
- chain: this.walletClient.chain,
772
- ...txOverride,
773
- });
774
- return txHash;
775
- }
776
- });
777
- Object.defineProperty(this, "signSOROrder", {
337
+ Object.defineProperty(this, "sign", {
778
338
  enumerable: true,
779
339
  configurable: true,
780
340
  writable: true,
@@ -793,59 +353,6 @@ export class Swap extends ContextHost {
793
353
  return txHash;
794
354
  }
795
355
  });
796
- Object.defineProperty(this, "sign", {
797
- enumerable: true,
798
- configurable: true,
799
- writable: true,
800
- value: async (params) => {
801
- let { account, order, slippage, takerTokenPermit, txOverride, sendByRelayer, } = params;
802
- const gas = txOverride?.gas ??
803
- (await this.estimate({
804
- account,
805
- order,
806
- slippage,
807
- takerTokenPermit,
808
- }));
809
- const gasPrice = txOverride?.gasPrice ?? (await this.publicClient.getGasPrice());
810
- const gasFee = gas * gasPrice;
811
- txOverride = txOverride;
812
- if (order.orderType === OrderType.SOR) {
813
- const prepare = await this.prepareOrder({
814
- order,
815
- slippage,
816
- gasFee,
817
- sendByRelayer,
818
- });
819
- const { swapData, value } = prepare;
820
- takerTokenPermit =
821
- takerTokenPermit ?? this.getTokenPermitData(swapData.takerToken);
822
- return await this.signSOROrder({
823
- account,
824
- value,
825
- takerTokenPermit,
826
- swapData,
827
- txOverride,
828
- });
829
- }
830
- else if (order.orderType === OrderType.RFQV6) {
831
- order = order;
832
- const rfqOffer = order?.encodeResult?.rfqTx?.rfqOffer ?? {};
833
- takerTokenPermit =
834
- takerTokenPermit ?? this.getTokenPermitData(rfqOffer.takerToken);
835
- const { value } = this.formatRFQOrderParams(order);
836
- return await this.signRFQOrder({
837
- account,
838
- order,
839
- takerTokenPermit,
840
- value: value,
841
- txOverride,
842
- });
843
- }
844
- else {
845
- throw new Error('unsupported order type');
846
- }
847
- }
848
- });
849
356
  Object.defineProperty(this, "signWithReceipt", {
850
357
  enumerable: true,
851
358
  configurable: true,
@@ -858,7 +365,7 @@ export class Swap extends ContextHost {
858
365
  return receipt;
859
366
  }
860
367
  });
861
- Object.defineProperty(this, "sign712SOROrder", {
368
+ Object.defineProperty(this, "signTypedData", {
862
369
  enumerable: true,
863
370
  configurable: true,
864
371
  writable: true,
@@ -869,138 +376,28 @@ export class Swap extends ContextHost {
869
376
  chainId: this.chainId,
870
377
  verifyingContract: genericSwapAddress[this.chainId],
871
378
  };
872
- return this.walletClient.signTypedData({
873
- primaryType: 'GenericSwapData',
379
+ const EIP712_TYPED = {
874
380
  domain: EIP712_DOMAIN,
875
381
  types: GS_EIP712_TYPES,
876
- message: swapData,
877
- account,
878
- });
879
- }
880
- });
881
- Object.defineProperty(this, "sign712RFQOrder", {
882
- enumerable: true,
883
- configurable: true,
884
- writable: true,
885
- value: async (rfqTx, account) => {
886
- const EIP712_DOMAIN = {
887
- name: 'Tokenlon',
888
- version: 'v6',
889
- chainId: this.chainId,
890
- verifyingContract: rfqAddress[this.chainId],
891
- };
892
- const types = {
893
- RFQOffer: [
894
- { name: 'taker', type: 'address' },
895
- { name: 'maker', type: 'address' },
896
- { name: 'takerToken', type: 'address' },
897
- { name: 'takerTokenAmount', type: 'uint256' },
898
- { name: 'makerToken', type: 'address' },
899
- { name: 'makerTokenAmount', type: 'uint256' },
900
- { name: 'feeFactor', type: 'uint256' },
901
- { name: 'flags', type: 'uint256' },
902
- { name: 'expiry', type: 'uint256' },
903
- { name: 'salt', type: 'uint256' },
904
- ],
905
- RFQTx: [
906
- { name: 'rfqOffer', type: 'RFQOffer' },
907
- { name: 'recipient', type: 'address' },
908
- { name: 'takerRequestAmount', type: 'uint256' },
909
- ],
382
+ primaryType: 'GenericSwapData',
910
383
  };
911
384
  return this.walletClient.signTypedData({
912
- primaryType: 'RFQTx',
913
- domain: EIP712_DOMAIN,
914
- types: types,
915
- message: rfqTx,
385
+ ...EIP712_TYPED,
386
+ message: swapData,
916
387
  account,
917
388
  });
918
389
  }
919
390
  });
920
- Object.defineProperty(this, "signTypedData", {
921
- enumerable: true,
922
- configurable: true,
923
- writable: true,
924
- value: async (params) => {
925
- let { account, order, takerTokenPermit, prepare } = params;
926
- if (order.orderType === OrderType.SOR) {
927
- if (!prepare) {
928
- throw new Error('prepare is empty');
929
- }
930
- const { swapData } = prepare;
931
- takerTokenPermit =
932
- takerTokenPermit ?? this.getTokenPermitData(swapData.takerToken);
933
- return this.sign712SOROrder(swapData, account);
934
- }
935
- else if (order.orderType === OrderType.RFQV6) {
936
- const rfqOrder = order;
937
- const { encodeResult } = rfqOrder;
938
- const { rfqTx } = encodeResult;
939
- const rfqOffer = rfqTx.rfqOffer;
940
- takerTokenPermit =
941
- takerTokenPermit ?? this.getTokenPermitData(rfqOffer.takerToken);
942
- return this.sign712RFQOrder(rfqTx, account);
943
- }
944
- else {
945
- throw new Error('unsupported order type');
946
- }
947
- }
948
- });
949
391
  Object.defineProperty(this, "submit", {
950
392
  enumerable: true,
951
393
  configurable: true,
952
394
  writable: true,
953
- value: async (params) => {
954
- let { order, slippage, takerTokenPermit, txHash, rawTx, gasFee, sendByRelayer, orderSignature, } = params;
955
- const request = {
956
- uniqueId: order.uniqueId,
957
- slippage,
958
- permit: takerTokenPermit,
959
- fee: {
960
- protocolFee: 0n,
961
- gasFee: 0n,
962
- },
963
- };
964
- if (orderSignature)
965
- request.orderSignature = orderSignature;
966
- if (txHash)
967
- request.txHash = txHash;
968
- if (rawTx)
969
- request.rawTx = rawTx;
970
- if (order.orderType === OrderType.SOR) {
971
- const prepare = await this.prepareOrder({
972
- order,
973
- slippage,
974
- gasFee: gasFee,
975
- sendByRelayer,
976
- });
977
- const { swapData, protocolFee, gasFeeTokenAmount } = prepare;
978
- request.strategyData = swapData.strategyData;
979
- request.fee = {
980
- protocolFee: protocolFee,
981
- gasFee: gasFeeTokenAmount,
982
- };
983
- request.minAmountOut = swapData.minMakerTokenAmount;
984
- }
985
- else if (order.orderType === OrderType.RFQV6) {
986
- order = order;
987
- const rfqOrderParams = this.formatRFQOrderParams(order);
988
- const { fee, minMakerTokenAmount } = rfqOrderParams;
989
- request.slippage = 0;
990
- request.minAmountOut = minMakerTokenAmount;
991
- request.fee = {
992
- gasFee: 0n,
993
- protocolFee: fee,
994
- };
995
- }
996
- else {
997
- throw new Error('unsupported order type');
998
- }
999
- return http(`${this.specialHost(httpServiceHost)}/${apiVersion}/swap/submit/${this.chainId}`, {
395
+ value: async (dto) => {
396
+ return http(`${this.host(httpServiceHost)}/v6/swap/submit/${this.chainId}`, {
1000
397
  fetchOptions: {
1001
398
  method: 'POST',
1002
399
  },
1003
- body: request,
400
+ body: dto,
1004
401
  });
1005
402
  }
1006
403
  });
@@ -1012,7 +409,7 @@ export class Swap extends ContextHost {
1012
409
  const params = new URLSearchParams({
1013
410
  userAddress: dto.account,
1014
411
  });
1015
- return http(`${this.specialHost(httpServiceHost)}?${params}`);
412
+ return http(`${this.host(httpServiceHost)}?${params}`);
1016
413
  }
1017
414
  });
1018
415
  Object.defineProperty(this, "status", {
@@ -1023,7 +420,7 @@ export class Swap extends ContextHost {
1023
420
  const params = new URLSearchParams({
1024
421
  ...dto,
1025
422
  });
1026
- return http(`${this.specialHost(httpServiceHost)}/${apiVersion}/swap/status/${this.chainId}?${params}`);
423
+ return http(`${this.host(httpServiceHost)}/v6/swap/status/${this.chainId}?${params}`);
1027
424
  }
1028
425
  });
1029
426
  Object.defineProperty(this, "config", {
@@ -1031,7 +428,7 @@ export class Swap extends ContextHost {
1031
428
  configurable: true,
1032
429
  writable: true,
1033
430
  value: async (appVersion) => {
1034
- return http(`${this.host(defaultServiceHost)}/${apiVersion}/swap/config?appVersion=${appVersion}`);
431
+ return http(`${this.host(httpServiceHost)}/v6/swap/config?appVersion=${appVersion}`);
1035
432
  }
1036
433
  });
1037
434
  Object.defineProperty(this, "ordersHistory", {
@@ -1044,15 +441,7 @@ export class Swap extends ContextHost {
1044
441
  limit: limit.toString(),
1045
442
  offset: offset.toString(),
1046
443
  });
1047
- return http(`${this.host(defaultServiceHost)}/v6/swap/orders/${chainId}?${params}`);
1048
- }
1049
- });
1050
- Object.defineProperty(this, "trendingList", {
1051
- enumerable: true,
1052
- configurable: true,
1053
- writable: true,
1054
- value: async () => {
1055
- return http(`${this.host(defaultServiceHost)}/${apiVersion}/swap/trendinglist`);
444
+ return http(`${this.host(httpServiceHost)}/v6/swap/orders/${chainId}?${params}`);
1056
445
  }
1057
446
  });
1058
447
  this.walletClient = injected.walletClient;