@1inch/fusion-sdk 2.4.2-rc.0 → 2.4.4

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.
@@ -221,7 +221,7 @@ function _define_property(obj, key, value) {
221
221
  * @param makingAmount making amount to be filled
222
222
  * @param orderMakingAmount full order making amount
223
223
  */ function _getSurplusFee(userTakingAmount, makingAmount, orderMakingAmount) {
224
- var estimatedTakingAmount = (0, _limitordersdk.mulDiv)(this.surplus.estimatedTakerAmount, makingAmount, orderMakingAmount);
224
+ var estimatedTakingAmount = (0, _limitordersdk.mulDiv)(this.surplus.estimatedTakerAmount, makingAmount, orderMakingAmount, _limitordersdk.Rounding.Ceil);
225
225
  if (userTakingAmount > estimatedTakingAmount) {
226
226
  var surplusFee = (userTakingAmount - estimatedTakingAmount) * BigInt(this.surplus.protocolFee.toPercent()) / 100n;
227
227
  return surplusFee;
@@ -62,5 +62,47 @@ describe('AmountCalculator', function() {
62
62
  expect(userAmount).toBeGreaterThan(userAmountWithChargedSurplus);
63
63
  expect(userAmount - userAmountWithChargedSurplus).toEqual(surplus / 2n);
64
64
  });
65
- }) // fee is 50%
66
- ;
65
+ // fee is 50%
66
+ it('should apply surplus with correct rounding', function() {
67
+ var startTime = 1764548287n;
68
+ var execTime = startTime;
69
+ var auction = new _index.AuctionCalculator(startTime, 600n, 179149n, [
70
+ {
71
+ coefficient: 157277,
72
+ delay: 84
73
+ },
74
+ {
75
+ coefficient: 141862,
76
+ delay: 84
77
+ },
78
+ {
79
+ coefficient: 129415,
80
+ delay: 84
81
+ },
82
+ {
83
+ coefficient: 116876,
84
+ delay: 84
85
+ },
86
+ {
87
+ coefficient: 24,
88
+ delay: 264
89
+ }
90
+ ], {
91
+ gasBumpEstimate: 24n,
92
+ gasPriceEstimate: 221n
93
+ });
94
+ var taker = _limitordersdk.Address.fromBigInt(1n);
95
+ var feeCalculator = new _limitordersdk.FeeTakerExt.FeeCalculator(_index2.Fees.integratorFee(new _index2.IntegratorFee(new _limitordersdk.Address('0x0000000000000000000000000000000000000000'), new _limitordersdk.Address('0x0000000000000000000000000000000000000000'), new _limitordersdk.Bps(0n), new _limitordersdk.Bps(0n))), _index1.Whitelist.new(1764548263n, [
96
+ {
97
+ address: taker,
98
+ allowFrom: 0n
99
+ }
100
+ ]));
101
+ var makingAmountOrder = 1369521200000n;
102
+ var calculator = new _amountcalculator.AmountCalculator(auction, feeCalculator, new _index1.SurplusParams(107289453867377650931124n, _limitordersdk.Bps.fromPercent(90)));
103
+ var userAmount1 = calculator.getSurplusFee(taker, 982226837n, 76145644627284979970n, makingAmountOrder, execTime, 216836903n);
104
+ expect(userAmount1).toBe(505013885259508359n);
105
+ var userAmount2 = calculator.getSurplusFee(taker, 136853897316n, 10609390660421433527440n, makingAmountOrder, execTime + 4n, 242000680n);
106
+ expect(userAmount2).toBe(69365890784904718356n);
107
+ });
108
+ });
@@ -72,31 +72,16 @@ var FusionExtension = /*#__PURE__*/ function() {
72
72
  {
73
73
  key: "build",
74
74
  value: function build() {
75
- var _this_extra, _this_extra1, _this_extra2;
75
+ var _this_extra;
76
76
  var amountData = this.buildAmountGetterData(true);
77
- var builder = new _limitordersdk.ExtensionBuilder().withMakingAmountData(this.address, amountData).withTakingAmountData(this.address, amountData).withPostInteraction(new _limitordersdk.Interaction(this.address, this.buildInteractionData((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.postInteraction)));
78
- if ((_this_extra1 = this.extra) === null || _this_extra1 === void 0 ? void 0 : _this_extra1.preInteraction) {
79
- builder.withPreInteraction(this.extra.preInteraction);
80
- }
81
- if ((_this_extra2 = this.extra) === null || _this_extra2 === void 0 ? void 0 : _this_extra2.makerPermit) {
82
- var _this_extra3, _this_extra4;
83
- builder.withMakerPermit((_this_extra3 = this.extra) === null || _this_extra3 === void 0 ? void 0 : _this_extra3.makerPermit.target, (_this_extra4 = this.extra) === null || _this_extra4 === void 0 ? void 0 : _this_extra4.makerPermit.data);
77
+ var builder = new _limitordersdk.ExtensionBuilder().withMakingAmountData(this.address, amountData).withTakingAmountData(this.address, amountData).withPostInteraction(new _limitordersdk.Interaction(this.address, this.buildInteractionData()));
78
+ if ((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.makerPermit) {
79
+ var _this_extra1, _this_extra2;
80
+ builder.withMakerPermit((_this_extra1 = this.extra) === null || _this_extra1 === void 0 ? void 0 : _this_extra1.makerPermit.target, (_this_extra2 = this.extra) === null || _this_extra2 === void 0 ? void 0 : _this_extra2.makerPermit.data);
84
81
  }
85
82
  return builder.build();
86
83
  }
87
84
  },
88
- {
89
- key: "getTakingAmountWithFee",
90
- value: /**
91
- * Returns takingAmount with fee, but without auction bump
92
- * @param taker
93
- * @param orderTakingAmount
94
- * @private
95
- */ function getTakingAmountWithFee(taker, orderTakingAmount) {
96
- var fees = this.getFeesForTaker(taker);
97
- return (0, _limitordersdk.mulDiv)(orderTakingAmount, _index1.Fees.BASE_1E5 + fees.resolverFee + fees.integratorFee, _index1.Fees.BASE_1E5, _limitordersdk.Rounding.Ceil);
98
- }
99
- },
100
85
  {
101
86
  key: "buildInteractionData",
102
87
  value: /**
@@ -113,7 +98,7 @@ var FusionExtension = /*#__PURE__*/ function() {
113
98
  * `1 byte` - protocol surplus fee (in 1e2)
114
99
  * @see buildAmountGetterData
115
100
  * @see https://github.com/1inch/limit-order-protocol/blob/22a18f7f20acfec69d4f50ce1880e8e662477710/contracts/extensions/FeeTaker.sol#L114
116
- */ function buildInteractionData(customPostInteraction) {
101
+ */ function buildInteractionData() {
117
102
  var _this_extra, _this_extra_fees, _this_extra1, _this_extra_fees1, _this_extra2;
118
103
  var customReceiver = ((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.customReceiver) || _limitordersdk.Address.ZERO_ADDRESS;
119
104
  var flags = new _byteutils.BN(0n).setBit(FusionExtension.CUSTOM_RECEIVER_FLAG_BIT, Boolean(!customReceiver.isZero()));
@@ -127,9 +112,6 @@ var FusionExtension = /*#__PURE__*/ function() {
127
112
  // surplus params
128
113
  builder.addUint256(this.surplus.estimatedTakerAmount);
129
114
  builder.addUint8(BigInt(this.surplus.protocolFee.toPercent()));
130
- if (customPostInteraction) {
131
- builder.addBytes(customPostInteraction.encode());
132
- }
133
115
  return builder.asHex();
134
116
  }
135
117
  },
@@ -187,6 +169,18 @@ var FusionExtension = /*#__PURE__*/ function() {
187
169
  integratorFee: integratorFeeBN
188
170
  };
189
171
  }
172
+ },
173
+ {
174
+ key: "getTakingAmountWithFee",
175
+ value: /**
176
+ * Returns takingAmount with fee, but without auction bump
177
+ * @param taker
178
+ * @param orderTakingAmount
179
+ * @private
180
+ */ function getTakingAmountWithFee(taker, orderTakingAmount) {
181
+ var fees = this.getFeesForTaker(taker);
182
+ return (0, _limitordersdk.mulDiv)(orderTakingAmount, _index1.Fees.BASE_1E5 + fees.resolverFee + fees.integratorFee, _index1.Fees.BASE_1E5, _limitordersdk.Rounding.Ceil);
183
+ }
190
184
  }
191
185
  ], [
192
186
  {
@@ -243,23 +237,18 @@ var FusionExtension = /*#__PURE__*/ function() {
243
237
  return whitelistAddressesFromAmount[i] === addressHalf;
244
238
  }), 'whitelist addresses must be same in interaction data and in amount data');
245
239
  var hasFees = !integratorFeeRecipient.isZero() || !protocolFeeRecipient.isZero();
246
- var preInteraction = extension.preInteraction == _limitordersdk.ZX ? undefined : _limitordersdk.Interaction.decode(extension.preInteraction);
247
- var postInteraction = interactionBytes.isEmpty() ? undefined : _limitordersdk.Interaction.decode(interactionBytes.rest());
248
240
  if (!hasFees) {
249
241
  return new FusionExtension(settlementContract, auctionDetails, whitelist, surplusParams, {
250
242
  makerPermit: makerPermit,
251
243
  customReceiver: customReceiver,
252
- fees: undefined,
253
- preInteraction: preInteraction,
254
- postInteraction: postInteraction
244
+ fees: undefined
255
245
  });
256
246
  }
257
247
  var fees = new _index1.Fees(new _index1.ResolverFee(protocolFeeRecipient, interactionData.fees.resolverFee, interactionData.fees.whitelistDiscount), interactionData.fees.integratorFee.isZero() ? _index1.IntegratorFee.ZERO : new _index1.IntegratorFee(integratorFeeRecipient, protocolFeeRecipient, interactionData.fees.integratorFee, interactionData.fees.integratorShare));
258
248
  return new FusionExtension(settlementContract, auctionDetails, whitelist, surplusParams, {
259
249
  makerPermit: makerPermit,
260
250
  fees: fees,
261
- customReceiver: customReceiver,
262
- preInteraction: preInteraction
251
+ customReceiver: customReceiver
263
252
  });
264
253
  }
265
254
  }
@@ -75,40 +75,4 @@ describe('FusionExtension', function() {
75
75
  var fusionExtension = _fusionextension.FusionExtension.decode(order.extension.encode());
76
76
  expect(fusionExtension).toStrictEqual(order.fusionExtension);
77
77
  });
78
- it('should decode with pre/post interaction hooks', function() {
79
- var extensionContract = new _limitordersdk.Address('0x8273f37417da37c4a6c3995e82cf442f87a25d9c');
80
- var order = _fusionorder.FusionOrder.new(extensionContract, {
81
- makerAsset: new _limitordersdk.Address('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
82
- takerAsset: new _limitordersdk.Address('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'),
83
- makingAmount: 1000000000000000000n,
84
- takingAmount: 1420000000n,
85
- maker: new _limitordersdk.Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
86
- salt: 10n
87
- }, {
88
- auction: new _index.AuctionDetails({
89
- duration: 180n,
90
- startTime: 1673548149n,
91
- initialRateBump: 50000,
92
- points: [
93
- {
94
- coefficient: 20000,
95
- delay: 12
96
- }
97
- ]
98
- }),
99
- whitelist: _index1.Whitelist.new(1673548139n, [
100
- {
101
- address: new _limitordersdk.Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
102
- allowFrom: 0n
103
- }
104
- ]),
105
- surplus: _surplusparams.SurplusParams.NO_FEE
106
- }, {
107
- permit: '0xdeadbeef',
108
- preInteraction: new _limitordersdk.Interaction(_limitordersdk.Address.fromBigInt(1n), '0xbeef'),
109
- postInteraction: new _limitordersdk.Interaction(_limitordersdk.Address.fromBigInt(2n), '0xdead')
110
- });
111
- var fusionExtension = _fusionextension.FusionExtension.decode(order.extension.encode());
112
- expect(fusionExtension).toStrictEqual(order.fusionExtension);
113
- });
114
78
  });
@@ -103,9 +103,7 @@ var FusionOrder = /*#__PURE__*/ function() {
103
103
  var surplusParams = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : _surplusparams.SurplusParams.NO_FEE, extra = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : FusionOrder.defaultExtra, extension = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : new _fusionextension.FusionExtension(settlementExtensionContract, auctionDetails, whitelist, surplusParams, {
104
104
  makerPermit: extra.permit ? new _limitordersdk.Interaction(orderInfo.makerAsset, extra.permit) : undefined,
105
105
  customReceiver: orderInfo.receiver,
106
- fees: extra === null || extra === void 0 ? void 0 : extra.fees,
107
- preInteraction: extra.preInteraction,
108
- postInteraction: extra.postInteraction
106
+ fees: extra === null || extra === void 0 ? void 0 : extra.fees
109
107
  });
110
108
  _class_call_check(this, FusionOrder);
111
109
  _define_property(this, "settlementExtensionContract", void 0);
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- import { Bps, mulDiv, Rounding, FeeTakerExt } from '@1inch/limit-order-sdk';
33
+ import { Bps, FeeTakerExt, mulDiv, Rounding } from '@1inch/limit-order-sdk';
34
34
  import { AuctionCalculator } from './auction-calculator/index.js';
35
35
  import { SurplusParams } from '../fusion-order/index.js';
36
36
  import { Fees } from '../fusion-order/fees/index.js';
@@ -211,7 +211,7 @@ import { Fees } from '../fusion-order/fees/index.js';
211
211
  * @param makingAmount making amount to be filled
212
212
  * @param orderMakingAmount full order making amount
213
213
  */ function _getSurplusFee(userTakingAmount, makingAmount, orderMakingAmount) {
214
- var estimatedTakingAmount = mulDiv(this.surplus.estimatedTakerAmount, makingAmount, orderMakingAmount);
214
+ var estimatedTakingAmount = mulDiv(this.surplus.estimatedTakerAmount, makingAmount, orderMakingAmount, Rounding.Ceil);
215
215
  if (userTakingAmount > estimatedTakingAmount) {
216
216
  var surplusFee = (userTakingAmount - estimatedTakingAmount) * BigInt(this.surplus.protocolFee.toPercent()) / 100n;
217
217
  return surplusFee;
@@ -58,5 +58,47 @@ describe('AmountCalculator', function() {
58
58
  expect(userAmount).toBeGreaterThan(userAmountWithChargedSurplus);
59
59
  expect(userAmount - userAmountWithChargedSurplus).toEqual(surplus / 2n);
60
60
  });
61
- }) // fee is 50%
62
- ;
61
+ // fee is 50%
62
+ it('should apply surplus with correct rounding', function() {
63
+ var startTime = 1764548287n;
64
+ var execTime = startTime;
65
+ var auction = new AuctionCalculator(startTime, 600n, 179149n, [
66
+ {
67
+ coefficient: 157277,
68
+ delay: 84
69
+ },
70
+ {
71
+ coefficient: 141862,
72
+ delay: 84
73
+ },
74
+ {
75
+ coefficient: 129415,
76
+ delay: 84
77
+ },
78
+ {
79
+ coefficient: 116876,
80
+ delay: 84
81
+ },
82
+ {
83
+ coefficient: 24,
84
+ delay: 264
85
+ }
86
+ ], {
87
+ gasBumpEstimate: 24n,
88
+ gasPriceEstimate: 221n
89
+ });
90
+ var taker = Address.fromBigInt(1n);
91
+ var feeCalculator = new FeeTakerExt.FeeCalculator(Fees.integratorFee(new IntegratorFee(new Address('0x0000000000000000000000000000000000000000'), new Address('0x0000000000000000000000000000000000000000'), new Bps(0n), new Bps(0n))), Whitelist.new(1764548263n, [
92
+ {
93
+ address: taker,
94
+ allowFrom: 0n
95
+ }
96
+ ]));
97
+ var makingAmountOrder = 1369521200000n;
98
+ var calculator = new AmountCalculator(auction, feeCalculator, new SurplusParams(107289453867377650931124n, Bps.fromPercent(90)));
99
+ var userAmount1 = calculator.getSurplusFee(taker, 982226837n, 76145644627284979970n, makingAmountOrder, execTime, 216836903n);
100
+ expect(userAmount1).toBe(505013885259508359n);
101
+ var userAmount2 = calculator.getSurplusFee(taker, 136853897316n, 10609390660421433527440n, makingAmountOrder, execTime + 4n, 242000680n);
102
+ expect(userAmount2).toBe(69365890784904718356n);
103
+ });
104
+ });
@@ -30,7 +30,7 @@ function _define_property(obj, key, value) {
30
30
  }
31
31
  return obj;
32
32
  }
33
- import { Address, Extension, ExtensionBuilder, Interaction, Bps, mulDiv, Rounding, ZX } from '@1inch/limit-order-sdk';
33
+ import { Address, Extension, ExtensionBuilder, Interaction, Bps, mulDiv, Rounding } from '@1inch/limit-order-sdk';
34
34
  import { BN, BytesBuilder, BytesIter } from '@1inch/byte-utils';
35
35
  import assert from 'assert';
36
36
  import { AuctionDetails } from './auction-details/index.js';
@@ -57,31 +57,16 @@ export var FusionExtension = /*#__PURE__*/ function() {
57
57
  {
58
58
  key: "build",
59
59
  value: function build() {
60
- var _this_extra, _this_extra1, _this_extra2;
60
+ var _this_extra;
61
61
  var amountData = this.buildAmountGetterData(true);
62
- var builder = new ExtensionBuilder().withMakingAmountData(this.address, amountData).withTakingAmountData(this.address, amountData).withPostInteraction(new Interaction(this.address, this.buildInteractionData((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.postInteraction)));
63
- if ((_this_extra1 = this.extra) === null || _this_extra1 === void 0 ? void 0 : _this_extra1.preInteraction) {
64
- builder.withPreInteraction(this.extra.preInteraction);
65
- }
66
- if ((_this_extra2 = this.extra) === null || _this_extra2 === void 0 ? void 0 : _this_extra2.makerPermit) {
67
- var _this_extra3, _this_extra4;
68
- builder.withMakerPermit((_this_extra3 = this.extra) === null || _this_extra3 === void 0 ? void 0 : _this_extra3.makerPermit.target, (_this_extra4 = this.extra) === null || _this_extra4 === void 0 ? void 0 : _this_extra4.makerPermit.data);
62
+ var builder = new ExtensionBuilder().withMakingAmountData(this.address, amountData).withTakingAmountData(this.address, amountData).withPostInteraction(new Interaction(this.address, this.buildInteractionData()));
63
+ if ((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.makerPermit) {
64
+ var _this_extra1, _this_extra2;
65
+ builder.withMakerPermit((_this_extra1 = this.extra) === null || _this_extra1 === void 0 ? void 0 : _this_extra1.makerPermit.target, (_this_extra2 = this.extra) === null || _this_extra2 === void 0 ? void 0 : _this_extra2.makerPermit.data);
69
66
  }
70
67
  return builder.build();
71
68
  }
72
69
  },
73
- {
74
- key: "getTakingAmountWithFee",
75
- value: /**
76
- * Returns takingAmount with fee, but without auction bump
77
- * @param taker
78
- * @param orderTakingAmount
79
- * @private
80
- */ function getTakingAmountWithFee(taker, orderTakingAmount) {
81
- var fees = this.getFeesForTaker(taker);
82
- return mulDiv(orderTakingAmount, Fees.BASE_1E5 + fees.resolverFee + fees.integratorFee, Fees.BASE_1E5, Rounding.Ceil);
83
- }
84
- },
85
70
  {
86
71
  key: "buildInteractionData",
87
72
  value: /**
@@ -98,7 +83,7 @@ export var FusionExtension = /*#__PURE__*/ function() {
98
83
  * `1 byte` - protocol surplus fee (in 1e2)
99
84
  * @see buildAmountGetterData
100
85
  * @see https://github.com/1inch/limit-order-protocol/blob/22a18f7f20acfec69d4f50ce1880e8e662477710/contracts/extensions/FeeTaker.sol#L114
101
- */ function buildInteractionData(customPostInteraction) {
86
+ */ function buildInteractionData() {
102
87
  var _this_extra, _this_extra_fees, _this_extra1, _this_extra_fees1, _this_extra2;
103
88
  var customReceiver = ((_this_extra = this.extra) === null || _this_extra === void 0 ? void 0 : _this_extra.customReceiver) || Address.ZERO_ADDRESS;
104
89
  var flags = new BN(0n).setBit(FusionExtension.CUSTOM_RECEIVER_FLAG_BIT, Boolean(!customReceiver.isZero()));
@@ -112,9 +97,6 @@ export var FusionExtension = /*#__PURE__*/ function() {
112
97
  // surplus params
113
98
  builder.addUint256(this.surplus.estimatedTakerAmount);
114
99
  builder.addUint8(BigInt(this.surplus.protocolFee.toPercent()));
115
- if (customPostInteraction) {
116
- builder.addBytes(customPostInteraction.encode());
117
- }
118
100
  return builder.asHex();
119
101
  }
120
102
  },
@@ -172,6 +154,18 @@ export var FusionExtension = /*#__PURE__*/ function() {
172
154
  integratorFee: integratorFeeBN
173
155
  };
174
156
  }
157
+ },
158
+ {
159
+ key: "getTakingAmountWithFee",
160
+ value: /**
161
+ * Returns takingAmount with fee, but without auction bump
162
+ * @param taker
163
+ * @param orderTakingAmount
164
+ * @private
165
+ */ function getTakingAmountWithFee(taker, orderTakingAmount) {
166
+ var fees = this.getFeesForTaker(taker);
167
+ return mulDiv(orderTakingAmount, Fees.BASE_1E5 + fees.resolverFee + fees.integratorFee, Fees.BASE_1E5, Rounding.Ceil);
168
+ }
175
169
  }
176
170
  ], [
177
171
  {
@@ -228,23 +222,18 @@ export var FusionExtension = /*#__PURE__*/ function() {
228
222
  return whitelistAddressesFromAmount[i] === addressHalf;
229
223
  }), 'whitelist addresses must be same in interaction data and in amount data');
230
224
  var hasFees = !integratorFeeRecipient.isZero() || !protocolFeeRecipient.isZero();
231
- var preInteraction = extension.preInteraction == ZX ? undefined : Interaction.decode(extension.preInteraction);
232
- var postInteraction = interactionBytes.isEmpty() ? undefined : Interaction.decode(interactionBytes.rest());
233
225
  if (!hasFees) {
234
226
  return new FusionExtension(settlementContract, auctionDetails, whitelist, surplusParams, {
235
227
  makerPermit: makerPermit,
236
228
  customReceiver: customReceiver,
237
- fees: undefined,
238
- preInteraction: preInteraction,
239
- postInteraction: postInteraction
229
+ fees: undefined
240
230
  });
241
231
  }
242
232
  var fees = new Fees(new ResolverFee(protocolFeeRecipient, interactionData.fees.resolverFee, interactionData.fees.whitelistDiscount), interactionData.fees.integratorFee.isZero() ? IntegratorFee.ZERO : new IntegratorFee(integratorFeeRecipient, protocolFeeRecipient, interactionData.fees.integratorFee, interactionData.fees.integratorShare));
243
233
  return new FusionExtension(settlementContract, auctionDetails, whitelist, surplusParams, {
244
234
  makerPermit: makerPermit,
245
235
  fees: fees,
246
- customReceiver: customReceiver,
247
- preInteraction: preInteraction
236
+ customReceiver: customReceiver
248
237
  });
249
238
  }
250
239
  }
@@ -1,4 +1,4 @@
1
- import { Address, Interaction } from '@1inch/limit-order-sdk';
1
+ import { Address } from '@1inch/limit-order-sdk';
2
2
  import { FusionOrder } from './fusion-order.js';
3
3
  import { AuctionDetails } from './auction-details/index.js';
4
4
  import { FusionExtension } from './fusion-extension.js';
@@ -71,40 +71,4 @@ describe('FusionExtension', function() {
71
71
  var fusionExtension = FusionExtension.decode(order.extension.encode());
72
72
  expect(fusionExtension).toStrictEqual(order.fusionExtension);
73
73
  });
74
- it('should decode with pre/post interaction hooks', function() {
75
- var extensionContract = new Address('0x8273f37417da37c4a6c3995e82cf442f87a25d9c');
76
- var order = FusionOrder.new(extensionContract, {
77
- makerAsset: new Address('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
78
- takerAsset: new Address('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'),
79
- makingAmount: 1000000000000000000n,
80
- takingAmount: 1420000000n,
81
- maker: new Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
82
- salt: 10n
83
- }, {
84
- auction: new AuctionDetails({
85
- duration: 180n,
86
- startTime: 1673548149n,
87
- initialRateBump: 50000,
88
- points: [
89
- {
90
- coefficient: 20000,
91
- delay: 12
92
- }
93
- ]
94
- }),
95
- whitelist: Whitelist.new(1673548139n, [
96
- {
97
- address: new Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
98
- allowFrom: 0n
99
- }
100
- ]),
101
- surplus: SurplusParams.NO_FEE
102
- }, {
103
- permit: '0xdeadbeef',
104
- preInteraction: new Interaction(Address.fromBigInt(1n), '0xbeef'),
105
- postInteraction: new Interaction(Address.fromBigInt(2n), '0xdead')
106
- });
107
- var fusionExtension = FusionExtension.decode(order.extension.encode());
108
- expect(fusionExtension).toStrictEqual(order.fusionExtension);
109
- });
110
74
  });
@@ -88,9 +88,7 @@ export var FusionOrder = /*#__PURE__*/ function() {
88
88
  var surplusParams = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : SurplusParams.NO_FEE, extra = arguments.length > 5 && arguments[5] !== void 0 ? arguments[5] : FusionOrder.defaultExtra, extension = arguments.length > 6 && arguments[6] !== void 0 ? arguments[6] : new FusionExtension(settlementExtensionContract, auctionDetails, whitelist, surplusParams, {
89
89
  makerPermit: extra.permit ? new Interaction(orderInfo.makerAsset, extra.permit) : undefined,
90
90
  customReceiver: orderInfo.receiver,
91
- fees: extra === null || extra === void 0 ? void 0 : extra.fees,
92
- preInteraction: extra.preInteraction,
93
- postInteraction: extra.postInteraction
91
+ fees: extra === null || extra === void 0 ? void 0 : extra.fees
94
92
  });
95
93
  _class_call_check(this, FusionOrder);
96
94
  _define_property(this, "settlementExtensionContract", void 0);
@@ -12,10 +12,4 @@
12
12
  * When enabled, orders where maker == receiver will have ZERO_ADDRESS set
13
13
  * Used to save calldata costs
14
14
  * By default: enabled
15
- */ /**
16
- * Allows maker to execute custom code before order executed
17
- * @see https://github.com/1inch/limit-order-protocol/blob/master/docs/interfaces/IPreInteraction.md
18
- */ /**
19
- * Allows maker to execute custom code after order executed
20
- * @see https://github.com/1inch/limit-order-protocol/blob/master/docs/interfaces/IPostInteraction.md
21
15
  */ export { };
@@ -1 +1 @@
1
- {"name":"@1inch/fusion-sdk","version":"2.4.2-rc.0","type":"module"}
1
+ {"name":"@1inch/fusion-sdk","version":"2.4.4","type":"module"}
@@ -12,22 +12,18 @@ export declare class FusionExtension {
12
12
  makerPermit?: Interaction;
13
13
  customReceiver?: Address;
14
14
  fees?: Fees;
15
- preInteraction?: Interaction;
16
- postInteraction?: Interaction;
17
15
  } | undefined;
18
16
  private static CUSTOM_RECEIVER_FLAG_BIT;
19
17
  constructor(address: Address, auctionDetails: AuctionDetails, whitelist: Whitelist, surplus: SurplusParams, extra?: {
20
18
  makerPermit?: Interaction;
21
19
  customReceiver?: Address;
22
20
  fees?: Fees;
23
- preInteraction?: Interaction;
24
- postInteraction?: Interaction;
25
21
  } | undefined);
26
22
  static decode(bytes: string): FusionExtension;
27
23
  static fromExtension(extension: Extension): FusionExtension;
28
24
  build(): Extension;
29
- getTakingAmountWithFee(taker: Address, orderTakingAmount: bigint): bigint;
30
25
  private buildInteractionData;
31
26
  private buildAmountGetterData;
32
27
  private getFeesForTaker;
28
+ private getTakingAmountWithFee;
33
29
  }
@@ -1,4 +1,3 @@
1
- import { Interaction } from '@1inch/limit-order-sdk';
2
1
  import { AuctionDetails } from './auction-details/auction-details.js';
3
2
  import { Fees } from './fees/index.js';
4
3
  import { SurplusParams } from './surplus-params.js';
@@ -14,8 +13,6 @@ export type Extra = {
14
13
  source?: string;
15
14
  fees?: Fees;
16
15
  optimizeReceiverAddress?: boolean;
17
- preInteraction?: Interaction;
18
- postInteraction?: Interaction;
19
16
  };
20
17
  export type Details = {
21
18
  auction: AuctionDetails;