@1inch/fusion-sdk 2.4.8-rc.0 → 2.4.8
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.
- package/dist/cjs/api/quoter/quote/quote.js +3 -1
- package/dist/cjs/api/quoter/quoter.api.spec.js +38 -0
- package/dist/cjs/api/quoter/types.js +2 -0
- package/dist/cjs/fusion-order/fusion-extension.js +1 -2
- package/dist/esm/api/quoter/quote/quote.js +3 -1
- package/dist/esm/api/quoter/quoter.api.spec.js +38 -0
- package/dist/esm/api/quoter/types.js +2 -0
- package/dist/esm/fusion-order/fusion-extension.js +1 -2
- package/dist/esm/package.json +1 -1
- package/dist/types/src/api/quoter/quote/quote.d.ts +1 -0
- package/dist/types/src/api/quoter/types.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +6 -6
|
@@ -80,6 +80,7 @@ var Quote = /*#__PURE__*/ function() {
|
|
|
80
80
|
_define_property(this, "resolverFeePreset", void 0);
|
|
81
81
|
_define_property(this, "surplusFee", void 0);
|
|
82
82
|
_define_property(this, "integratorFeeParams", void 0);
|
|
83
|
+
_define_property(this, "source", void 0);
|
|
83
84
|
this.params = params;
|
|
84
85
|
this.fromTokenAmount = BigInt(response.fromTokenAmount);
|
|
85
86
|
var _obj;
|
|
@@ -102,6 +103,7 @@ var Quote = /*#__PURE__*/ function() {
|
|
|
102
103
|
bps: new _limitordersdk.Bps(BigInt(response.fee.bps))
|
|
103
104
|
};
|
|
104
105
|
this.surplusFee = response.surplusFee;
|
|
106
|
+
this.source = response.source;
|
|
105
107
|
this.integratorFeeParams = this.parseIntegratorFee(response);
|
|
106
108
|
}
|
|
107
109
|
_create_class(Quote, [
|
|
@@ -147,7 +149,7 @@ var Quote = /*#__PURE__*/ function() {
|
|
|
147
149
|
allowPartialFills: allowPartialFills,
|
|
148
150
|
allowMultipleFills: allowMultipleFills,
|
|
149
151
|
orderExpirationDelay: paramsData === null || paramsData === void 0 ? void 0 : paramsData.orderExpirationDelay,
|
|
150
|
-
source: this.params.source,
|
|
152
|
+
source: this.source || this.params.source,
|
|
151
153
|
enablePermit2: params.isPermit2,
|
|
152
154
|
fees: buildFees(this.resolverFeePreset, this.integratorFeeParams, this.surplusFee)
|
|
153
155
|
};
|
|
@@ -501,6 +501,44 @@ describe('Quoter API', function() {
|
|
|
501
501
|
}
|
|
502
502
|
});
|
|
503
503
|
}));
|
|
504
|
+
describe('source from response', function() {
|
|
505
|
+
it('should store source from response', function() {
|
|
506
|
+
var responseWithSource = _object_spread_props(_object_spread({}, ResponseMock), {
|
|
507
|
+
source: '0xabcdef01'
|
|
508
|
+
});
|
|
509
|
+
var quote = new _index.Quote(params, responseWithSource);
|
|
510
|
+
expect(quote.source).toBe('0xabcdef01');
|
|
511
|
+
});
|
|
512
|
+
it('should be undefined when response has no source', function() {
|
|
513
|
+
var quote = new _index.Quote(params, ResponseMock);
|
|
514
|
+
expect(quote.source).toBeUndefined();
|
|
515
|
+
});
|
|
516
|
+
it('should prefer response source over request source', function() {
|
|
517
|
+
var paramsWithSource = _quoterrequest.QuoterRequest.new({
|
|
518
|
+
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
519
|
+
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
520
|
+
amount: '1000000000000000000000',
|
|
521
|
+
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
522
|
+
source: 'user-provided-source'
|
|
523
|
+
});
|
|
524
|
+
var responseWithSource = _object_spread_props(_object_spread({}, ResponseMock), {
|
|
525
|
+
source: '0xabcdef01'
|
|
526
|
+
});
|
|
527
|
+
var quote = new _index.Quote(paramsWithSource, responseWithSource);
|
|
528
|
+
expect(quote.source).toBe('0xabcdef01');
|
|
529
|
+
});
|
|
530
|
+
it('should fall back to request source when response source is absent', function() {
|
|
531
|
+
var paramsWithSource = _quoterrequest.QuoterRequest.new({
|
|
532
|
+
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
533
|
+
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
534
|
+
amount: '1000000000000000000000',
|
|
535
|
+
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
536
|
+
source: 'user-provided-source'
|
|
537
|
+
});
|
|
538
|
+
var quote = new _index.Quote(paramsWithSource, ResponseMock);
|
|
539
|
+
expect(quote.source).toBeUndefined();
|
|
540
|
+
});
|
|
541
|
+
});
|
|
504
542
|
describe('parseIntegratorFee', function() {
|
|
505
543
|
it('should use response receiver when provided', function() {
|
|
506
544
|
var _quote_integratorFeeParams, _quote_integratorFeeParams1, _quote_integratorFeeParams2;
|
|
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "PresetEnum", {
|
|
|
17
17
|
* In bps
|
|
18
18
|
*/ /**
|
|
19
19
|
* Percentage of the integrator fee that will be shared with the integrator.
|
|
20
|
+
*/ /**
|
|
21
|
+
* Resolved source tracking code
|
|
20
22
|
*/ var PresetEnum = /*#__PURE__*/ function(PresetEnum) {
|
|
21
23
|
PresetEnum["fast"] = "fast";
|
|
22
24
|
PresetEnum["medium"] = "medium";
|
|
@@ -16,7 +16,6 @@ var _whitelist = require("./whitelist/whitelist.js");
|
|
|
16
16
|
var _surplusparams = require("./surplus-params.js");
|
|
17
17
|
var _index1 = require("./fees/index.js");
|
|
18
18
|
var _utils = require("../utils.js");
|
|
19
|
-
var _constants = require("../constants.js");
|
|
20
19
|
function _class_call_check(instance, Constructor) {
|
|
21
20
|
if (!(instance instanceof Constructor)) {
|
|
22
21
|
throw new TypeError("Cannot call a class as a function");
|
|
@@ -232,7 +231,7 @@ var FusionExtension = /*#__PURE__*/ function() {
|
|
|
232
231
|
}
|
|
233
232
|
//endregion Parse amount data
|
|
234
233
|
var makerPermit = extension.hasMakerPermit ? _limitordersdk.Interaction.decode(extension.makerPermit) : undefined;
|
|
235
|
-
var preInteraction = extension.
|
|
234
|
+
var preInteraction = extension.hasPreInteraction ? _limitordersdk.Interaction.decode(extension.preInteraction) : undefined;
|
|
236
235
|
(0, _assert.default)(amountData.fees.integratorFee.value === interactionData.fees.integratorFee.value, "invalid extension: integrator fee must be same in interaction data and in amount data");
|
|
237
236
|
(0, _assert.default)(amountData.fees.resolverFee.value === interactionData.fees.resolverFee.value, "invalid extension: resolver fee must be same in interaction data and in amount data");
|
|
238
237
|
(0, _assert.default)(amountData.fees.whitelistDiscount.equal(interactionData.fees.whitelistDiscount), "invalid extension: whitelistDiscount must be same in interaction data and in amount data");
|
|
@@ -65,6 +65,7 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
65
65
|
_define_property(this, "resolverFeePreset", void 0);
|
|
66
66
|
_define_property(this, "surplusFee", void 0);
|
|
67
67
|
_define_property(this, "integratorFeeParams", void 0);
|
|
68
|
+
_define_property(this, "source", void 0);
|
|
68
69
|
this.params = params;
|
|
69
70
|
this.fromTokenAmount = BigInt(response.fromTokenAmount);
|
|
70
71
|
var _obj;
|
|
@@ -87,6 +88,7 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
87
88
|
bps: new Bps(BigInt(response.fee.bps))
|
|
88
89
|
};
|
|
89
90
|
this.surplusFee = response.surplusFee;
|
|
91
|
+
this.source = response.source;
|
|
90
92
|
this.integratorFeeParams = this.parseIntegratorFee(response);
|
|
91
93
|
}
|
|
92
94
|
_create_class(Quote, [
|
|
@@ -132,7 +134,7 @@ export var Quote = /*#__PURE__*/ function() {
|
|
|
132
134
|
allowPartialFills: allowPartialFills,
|
|
133
135
|
allowMultipleFills: allowMultipleFills,
|
|
134
136
|
orderExpirationDelay: paramsData === null || paramsData === void 0 ? void 0 : paramsData.orderExpirationDelay,
|
|
135
|
-
source: this.params.source,
|
|
137
|
+
source: this.source || this.params.source,
|
|
136
138
|
enablePermit2: params.isPermit2,
|
|
137
139
|
fees: buildFees(this.resolverFeePreset, this.integratorFeeParams, this.surplusFee)
|
|
138
140
|
};
|
|
@@ -497,6 +497,44 @@ describe('Quoter API', function() {
|
|
|
497
497
|
}
|
|
498
498
|
});
|
|
499
499
|
}));
|
|
500
|
+
describe('source from response', function() {
|
|
501
|
+
it('should store source from response', function() {
|
|
502
|
+
var responseWithSource = _object_spread_props(_object_spread({}, ResponseMock), {
|
|
503
|
+
source: '0xabcdef01'
|
|
504
|
+
});
|
|
505
|
+
var quote = new Quote(params, responseWithSource);
|
|
506
|
+
expect(quote.source).toBe('0xabcdef01');
|
|
507
|
+
});
|
|
508
|
+
it('should be undefined when response has no source', function() {
|
|
509
|
+
var quote = new Quote(params, ResponseMock);
|
|
510
|
+
expect(quote.source).toBeUndefined();
|
|
511
|
+
});
|
|
512
|
+
it('should prefer response source over request source', function() {
|
|
513
|
+
var paramsWithSource = QuoterRequest.new({
|
|
514
|
+
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
515
|
+
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
516
|
+
amount: '1000000000000000000000',
|
|
517
|
+
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
518
|
+
source: 'user-provided-source'
|
|
519
|
+
});
|
|
520
|
+
var responseWithSource = _object_spread_props(_object_spread({}, ResponseMock), {
|
|
521
|
+
source: '0xabcdef01'
|
|
522
|
+
});
|
|
523
|
+
var quote = new Quote(paramsWithSource, responseWithSource);
|
|
524
|
+
expect(quote.source).toBe('0xabcdef01');
|
|
525
|
+
});
|
|
526
|
+
it('should fall back to request source when response source is absent', function() {
|
|
527
|
+
var paramsWithSource = QuoterRequest.new({
|
|
528
|
+
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
529
|
+
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
530
|
+
amount: '1000000000000000000000',
|
|
531
|
+
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
532
|
+
source: 'user-provided-source'
|
|
533
|
+
});
|
|
534
|
+
var quote = new Quote(paramsWithSource, ResponseMock);
|
|
535
|
+
expect(quote.source).toBeUndefined();
|
|
536
|
+
});
|
|
537
|
+
});
|
|
500
538
|
describe('parseIntegratorFee', function() {
|
|
501
539
|
it('should use response receiver when provided', function() {
|
|
502
540
|
var _quote_integratorFeeParams, _quote_integratorFeeParams1, _quote_integratorFeeParams2;
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* In bps
|
|
8
8
|
*/ /**
|
|
9
9
|
* Percentage of the integrator fee that will be shared with the integrator.
|
|
10
|
+
*/ /**
|
|
11
|
+
* Resolved source tracking code
|
|
10
12
|
*/ export var PresetEnum = /*#__PURE__*/ function(PresetEnum) {
|
|
11
13
|
PresetEnum["fast"] = "fast";
|
|
12
14
|
PresetEnum["medium"] = "medium";
|
|
@@ -38,7 +38,6 @@ import { Whitelist } from './whitelist/whitelist.js';
|
|
|
38
38
|
import { SurplusParams } from './surplus-params.js';
|
|
39
39
|
import { Fees, IntegratorFee, ResolverFee } from './fees/index.js';
|
|
40
40
|
import { add0x } from '../utils.js';
|
|
41
|
-
import { ZX } from '../constants.js';
|
|
42
41
|
export var FusionExtension = /*#__PURE__*/ function() {
|
|
43
42
|
"use strict";
|
|
44
43
|
function FusionExtension(address, auctionDetails, whitelist, surplus, extra) {
|
|
@@ -217,7 +216,7 @@ export var FusionExtension = /*#__PURE__*/ function() {
|
|
|
217
216
|
}
|
|
218
217
|
//endregion Parse amount data
|
|
219
218
|
var makerPermit = extension.hasMakerPermit ? Interaction.decode(extension.makerPermit) : undefined;
|
|
220
|
-
var preInteraction = extension.
|
|
219
|
+
var preInteraction = extension.hasPreInteraction ? Interaction.decode(extension.preInteraction) : undefined;
|
|
221
220
|
assert(amountData.fees.integratorFee.value === interactionData.fees.integratorFee.value, "invalid extension: integrator fee must be same in interaction data and in amount data");
|
|
222
221
|
assert(amountData.fees.resolverFee.value === interactionData.fees.resolverFee.value, "invalid extension: resolver fee must be same in interaction data and in amount data");
|
|
223
222
|
assert(amountData.fees.whitelistDiscount.equal(interactionData.fees.whitelistDiscount), "invalid extension: whitelistDiscount must be same in interaction data and in amount data");
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@1inch/fusion-sdk","version":"2.4.8
|
|
1
|
+
{"name":"@1inch/fusion-sdk","version":"2.4.8","type":"module"}
|
|
@@ -26,6 +26,7 @@ export declare class Quote {
|
|
|
26
26
|
readonly resolverFeePreset: ResolverFeePreset;
|
|
27
27
|
readonly surplusFee?: number;
|
|
28
28
|
readonly integratorFeeParams?: IntegratorFeeResponse;
|
|
29
|
+
readonly source?: string;
|
|
29
30
|
constructor(params: QuoterRequest, response: QuoterResponse);
|
|
30
31
|
createFusionOrder(paramsData: Omit<FusionOrderParamsData, 'permit' | 'isPermit2'>): FusionOrder;
|
|
31
32
|
getPreset(type?: PresetEnum): Preset;
|