@1inch/fusion-sdk 2.4.5-rc.0 → 2.4.5
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 +7 -21
- package/dist/cjs/api/quoter/quoter.api.spec.js +5 -101
- package/dist/cjs/api/quoter/quoter.request.js +4 -1
- package/dist/cjs/api/quoter/quoter.request.spec.js +8 -2
- package/dist/cjs/fusion-order/fusion-order.js +3 -0
- package/dist/cjs/fusion-order/fusion-order.spec.js +33 -1
- package/dist/esm/api/quoter/quote/quote.js +7 -21
- package/dist/esm/api/quoter/quote/types.js +3 -15
- package/dist/esm/api/quoter/quoter.api.spec.js +5 -101
- package/dist/esm/api/quoter/quoter.request.js +4 -1
- package/dist/esm/api/quoter/quoter.request.spec.js +8 -2
- package/dist/esm/fusion-order/fusion-order.js +3 -0
- package/dist/esm/fusion-order/fusion-order.spec.js +33 -1
- package/dist/esm/package.json +1 -1
- package/dist/types/src/api/quoter/quote/quote.d.ts +2 -3
- package/dist/types/src/api/quoter/quote/types.d.ts +1 -6
- package/dist/types/src/api/quoter/quoter.request.d.ts +3 -3
- package/dist/types/src/api/quoter/types.d.ts +2 -2
- package/dist/types/src/sdk/types.d.ts +3 -3
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -128,6 +128,9 @@ export var FusionOrder = /*#__PURE__*/ function() {
|
|
|
128
128
|
if (orderInfo.makerAsset.isNative()) {
|
|
129
129
|
throw new Error('use FusionOrder.fromNative to create order from native asset');
|
|
130
130
|
}
|
|
131
|
+
if (!surplusParams.isZero()) {
|
|
132
|
+
assert(orderInfo.takingAmount <= surplusParams.estimatedTakerAmount, 'order.takingAmount must be less then surplusParams.estimatedTakerAmount');
|
|
133
|
+
}
|
|
131
134
|
var optimizeReceiverAddress = extra.optimizeReceiverAddress !== undefined ? extra.optimizeReceiverAddress : FusionOrder.defaultExtra.optimizeReceiverAddress;
|
|
132
135
|
this.inner = new LimitOrder(_object_spread_props(_object_spread({}, orderInfo), {
|
|
133
136
|
receiver: receiver,
|
|
@@ -292,6 +292,38 @@ describe('Fusion Order', function() {
|
|
|
292
292
|
expect(userAmount).toEqual(75000000n);
|
|
293
293
|
expect(surplus).toEqual(25000000n);
|
|
294
294
|
});
|
|
295
|
+
it('should fail to create fusion order with bad surplus params', function() {
|
|
296
|
+
var extensionContract = new Address('0x8273f37417da37c4a6c3995e82cf442f87a25d9c');
|
|
297
|
+
expect(function() {
|
|
298
|
+
return FusionOrder.new(extensionContract, {
|
|
299
|
+
makerAsset: new Address('0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2'),
|
|
300
|
+
takerAsset: new Address('0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48'),
|
|
301
|
+
makingAmount: 1000000000000000000n,
|
|
302
|
+
takingAmount: 1420000000n,
|
|
303
|
+
maker: new Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
|
|
304
|
+
salt: 10n
|
|
305
|
+
}, {
|
|
306
|
+
auction: new AuctionDetails({
|
|
307
|
+
duration: 180n,
|
|
308
|
+
startTime: 1673548149n,
|
|
309
|
+
initialRateBump: 50000,
|
|
310
|
+
points: [
|
|
311
|
+
{
|
|
312
|
+
coefficient: 20000,
|
|
313
|
+
delay: 12
|
|
314
|
+
}
|
|
315
|
+
]
|
|
316
|
+
}),
|
|
317
|
+
whitelist: Whitelist.new(1673548139n, [
|
|
318
|
+
{
|
|
319
|
+
address: new Address('0x00000000219ab540356cbb839cbe05303d7705fa'),
|
|
320
|
+
allowFrom: 0n
|
|
321
|
+
}
|
|
322
|
+
]),
|
|
323
|
+
surplus: new SurplusParams(1420000000n - 1n, Bps.fromFraction(0.1))
|
|
324
|
+
});
|
|
325
|
+
}).toThrow('order.takingAmount must be less then surplusParams.estimatedTakerAmount');
|
|
326
|
+
});
|
|
295
327
|
});
|
|
296
328
|
describe('FusionOrder Native', function() {
|
|
297
329
|
it('should correct detect that order is from native asset', function() {
|
|
@@ -425,7 +457,7 @@ describe('FusionOrder Native', function() {
|
|
|
425
457
|
allowFrom: 0n
|
|
426
458
|
}
|
|
427
459
|
]),
|
|
428
|
-
surplus: new SurplusParams(
|
|
460
|
+
surplus: new SurplusParams(1420000000n * 2n, new Bps(10000n))
|
|
429
461
|
});
|
|
430
462
|
expect(nativeOrder.build().receiver).toEqual(settlementExt.toString());
|
|
431
463
|
});
|
package/dist/esm/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@1inch/fusion-sdk","version":"2.4.5
|
|
1
|
+
{"name":"@1inch/fusion-sdk","version":"2.4.5","type":"module"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Address, ProxyFactory } from '@1inch/limit-order-sdk';
|
|
2
|
-
import { FusionOrderParamsData,
|
|
2
|
+
import { FusionOrderParamsData, IntegratorFeeParams, ResolverFeePreset } from './types.js';
|
|
3
3
|
import { Cost, PresetEnum, QuoterResponse } from '../types.js';
|
|
4
4
|
import { Preset } from '../preset.js';
|
|
5
5
|
import { FusionOrder } from '../../../fusion-order/index.js';
|
|
@@ -25,11 +25,10 @@ export declare class Quote {
|
|
|
25
25
|
readonly slippage: number;
|
|
26
26
|
readonly resolverFeePreset: ResolverFeePreset;
|
|
27
27
|
readonly surplusFee?: number;
|
|
28
|
-
readonly integratorFeeParams?:
|
|
28
|
+
readonly integratorFeeParams?: IntegratorFeeParams;
|
|
29
29
|
constructor(params: QuoterRequest, response: QuoterResponse);
|
|
30
30
|
createFusionOrder(paramsData: Omit<FusionOrderParamsData, 'permit' | 'isPermit2'>): FusionOrder;
|
|
31
31
|
getPreset(type?: PresetEnum): Preset;
|
|
32
32
|
private getWhitelist;
|
|
33
33
|
private _createOrder;
|
|
34
|
-
private parseIntegratorFee;
|
|
35
34
|
}
|
|
@@ -13,16 +13,11 @@ export type FusionOrderParamsData = {
|
|
|
13
13
|
delayAuctionStartTimeBy?: bigint;
|
|
14
14
|
orderExpirationDelay?: bigint;
|
|
15
15
|
};
|
|
16
|
-
export type
|
|
17
|
-
receiver: Address;
|
|
18
|
-
value: Bps;
|
|
19
|
-
};
|
|
20
|
-
export type IntegratorFeeResponse = {
|
|
16
|
+
export type IntegratorFeeParams = {
|
|
21
17
|
receiver: Address;
|
|
22
18
|
value: Bps;
|
|
23
19
|
share: Bps;
|
|
24
20
|
};
|
|
25
|
-
export type IntegratorFeeParams = IntegratorFeeResponse;
|
|
26
21
|
export type ResolverFeePreset = {
|
|
27
22
|
receiver: Address;
|
|
28
23
|
bps: Bps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Address } from '@1inch/limit-order-sdk';
|
|
2
2
|
import { QuoterRequestParams, QuoterRequestParamsRaw } from './types.js';
|
|
3
|
-
import {
|
|
3
|
+
import { IntegratorFeeParams } from './quote/index.js';
|
|
4
4
|
export declare class QuoterRequest {
|
|
5
5
|
readonly fromTokenAddress: Address;
|
|
6
6
|
readonly toTokenAddress: Address;
|
|
@@ -8,8 +8,8 @@ export declare class QuoterRequest {
|
|
|
8
8
|
readonly walletAddress: Address;
|
|
9
9
|
readonly enableEstimate: boolean;
|
|
10
10
|
readonly permit: string | undefined;
|
|
11
|
-
readonly integratorFee?:
|
|
12
|
-
readonly source
|
|
11
|
+
readonly integratorFee?: IntegratorFeeParams;
|
|
12
|
+
readonly source: string;
|
|
13
13
|
readonly isPermit2: boolean;
|
|
14
14
|
readonly slippage?: number;
|
|
15
15
|
constructor(params: QuoterRequestParams);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IntegratorFeeParams } from './quote/index.js';
|
|
2
2
|
import { NetworkEnum } from '../../constants.js';
|
|
3
3
|
export type QuoterRequestParams = {
|
|
4
4
|
fromTokenAddress: string;
|
|
@@ -7,7 +7,7 @@ export type QuoterRequestParams = {
|
|
|
7
7
|
walletAddress: string;
|
|
8
8
|
enableEstimate?: boolean;
|
|
9
9
|
permit?: string;
|
|
10
|
-
integratorFee?:
|
|
10
|
+
integratorFee?: IntegratorFeeParams;
|
|
11
11
|
source?: string;
|
|
12
12
|
isPermit2?: boolean;
|
|
13
13
|
slippage?: number;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Address, LimitOrderV4Struct } from '@1inch/limit-order-sdk';
|
|
2
2
|
import { BlockchainProviderConnector, HttpProviderConnector } from '../connector/index.js';
|
|
3
3
|
import { NetworkEnum } from '../constants.js';
|
|
4
|
-
import { CustomPreset,
|
|
4
|
+
import { CustomPreset, IntegratorFeeParams, PresetEnum } from '../api/index.js';
|
|
5
5
|
import { FusionOrder } from '../fusion-order/index.js';
|
|
6
6
|
export type FusionSDKConfigParams = {
|
|
7
7
|
url: string;
|
|
@@ -17,7 +17,7 @@ export type QuoteParams = {
|
|
|
17
17
|
walletAddress?: string;
|
|
18
18
|
enableEstimate?: boolean;
|
|
19
19
|
permit?: string;
|
|
20
|
-
integratorFee?:
|
|
20
|
+
integratorFee?: IntegratorFeeParams;
|
|
21
21
|
source?: string;
|
|
22
22
|
isPermit2?: boolean;
|
|
23
23
|
slippage?: number;
|
|
@@ -40,7 +40,7 @@ export type OrderParams = {
|
|
|
40
40
|
orderExpirationDelay?: bigint;
|
|
41
41
|
allowPartialFills?: boolean;
|
|
42
42
|
allowMultipleFills?: boolean;
|
|
43
|
-
integratorFee?:
|
|
43
|
+
integratorFee?: IntegratorFeeParams;
|
|
44
44
|
slippage?: number;
|
|
45
45
|
};
|
|
46
46
|
export type OrderInfo = {
|