@1inch/fusion-sdk 0.0.6 → 0.0.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/README.md +4 -0
- package/api/fusion-api.d.ts +16 -25
- package/api/fusion-api.js +26 -36
- package/api/index.d.ts +4 -4
- package/api/index.js +8 -8
- package/api/orders/index.d.ts +3 -3
- package/api/orders/index.js +7 -7
- package/api/orders/order-api.spec.d.ts +1 -1
- package/api/orders/order-api.spec.js +397 -479
- package/api/orders/orders.api.d.ts +10 -24
- package/api/orders/orders.api.js +28 -30
- package/api/orders/orders.request.d.ts +18 -22
- package/api/orders/orders.request.js +31 -40
- package/api/orders/types.d.ts +58 -59
- package/api/orders/types.js +16 -17
- package/api/pagination.d.ts +7 -7
- package/api/pagination.js +10 -10
- package/api/pagination.spec.d.ts +1 -1
- package/api/pagination.spec.js +21 -28
- package/api/params.d.ts +1 -3
- package/api/params.js +19 -25
- package/api/quoter/index.d.ts +5 -5
- package/api/quoter/index.js +9 -9
- package/api/quoter/preset.d.ts +13 -13
- package/api/quoter/preset.js +17 -19
- package/api/quoter/quote/index.d.ts +3 -3
- package/api/quoter/quote/index.js +7 -7
- package/api/quoter/quote/order-params.d.ts +7 -6
- package/api/quoter/quote/order-params.js +13 -12
- package/api/quoter/quote/order-params.js.map +1 -1
- package/api/quoter/quote/quote.d.ts +22 -26
- package/api/quoter/quote/quote.js +59 -84
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quote/types.d.ts +5 -4
- package/api/quoter/quote/types.js +3 -3
- package/api/quoter/quoter.api.d.ts +9 -12
- package/api/quoter/quoter.api.js +19 -19
- package/api/quoter/quoter.api.spec.d.ts +1 -1
- package/api/quoter/quoter.api.spec.js +24 -30
- package/api/quoter/quoter.api.spec.js.map +1 -1
- package/api/quoter/quoter.request.d.ts +11 -11
- package/api/quoter/quoter.request.js +26 -28
- package/api/quoter/types.d.ts +45 -45
- package/api/quoter/types.js +10 -10
- package/api/relayer/index.d.ts +3 -3
- package/api/relayer/index.js +7 -7
- package/api/relayer/relayer.api.d.ts +9 -12
- package/api/relayer/relayer.api.js +13 -13
- package/api/relayer/relayer.api.spec.d.ts +1 -1
- package/api/relayer/relayer.api.spec.js +79 -96
- package/api/relayer/relayer.request.d.ts +8 -8
- package/api/relayer/relayer.request.js +10 -10
- package/api/relayer/types.d.ts +9 -9
- package/api/relayer/types.js +3 -3
- package/api/types.d.ts +15 -17
- package/api/types.js +3 -3
- package/auction-calculator/auction-calculator.d.ts +13 -22
- package/auction-calculator/auction-calculator.js +45 -70
- package/auction-calculator/auction-calculator.spec.d.ts +1 -1
- package/auction-calculator/auction-calculator.spec.js +32 -45
- package/auction-calculator/calc.d.ts +2 -8
- package/auction-calculator/calc.js +12 -12
- package/auction-calculator/constants.d.ts +1 -1
- package/auction-calculator/constants.js +5 -5
- package/auction-calculator/index.d.ts +3 -3
- package/auction-calculator/index.js +7 -7
- package/auction-salt/auction-salt.d.ts +9 -9
- package/auction-salt/auction-salt.js +23 -34
- package/auction-salt/auction.salt.spec.d.ts +1 -1
- package/auction-salt/auction.salt.spec.js +27 -38
- package/auction-salt/index.d.ts +3 -3
- package/auction-salt/index.js +7 -7
- package/auction-salt/parser/constants.d.ts +9 -9
- package/auction-salt/parser/constants.js +14 -33
- package/auction-salt/parser/index.d.ts +2 -2
- package/auction-salt/parser/index.js +6 -6
- package/auction-salt/parser/parser.d.ts +6 -6
- package/auction-salt/parser/parser.js +22 -33
- package/auction-salt/types.d.ts +6 -6
- package/auction-salt/types.js +3 -3
- package/auction-suffix/auction-suffix.d.ts +9 -9
- package/auction-suffix/auction-suffix.js +23 -36
- package/auction-suffix/auction-suffix.spec.d.ts +1 -1
- package/auction-suffix/auction-suffix.spec.js +15 -20
- package/auction-suffix/constants.d.ts +1 -1
- package/auction-suffix/constants.js +5 -5
- package/auction-suffix/encoder.d.ts +6 -15
- package/auction-suffix/encoder.js +28 -45
- package/auction-suffix/index.d.ts +5 -5
- package/auction-suffix/index.js +9 -9
- package/auction-suffix/parser/constants.d.ts +13 -13
- package/auction-suffix/parser/constants.js +17 -30
- package/auction-suffix/parser/errors.d.ts +2 -1
- package/auction-suffix/parser/errors.js +7 -6
- package/auction-suffix/parser/index.d.ts +4 -4
- package/auction-suffix/parser/index.js +8 -8
- package/auction-suffix/parser/parser.d.ts +8 -28
- package/auction-suffix/parser/parser.js +81 -162
- package/auction-suffix/parser/types.d.ts +22 -22
- package/auction-suffix/parser/types.js +3 -3
- package/auction-suffix/types.d.ts +12 -12
- package/auction-suffix/types.js +3 -3
- package/connector/blockchain/blockchain-provider.connector.d.ts +3 -6
- package/connector/blockchain/blockchain-provider.connector.js +3 -3
- package/connector/blockchain/index.d.ts +3 -3
- package/connector/blockchain/index.js +7 -7
- package/connector/blockchain/private-key-provider.connector.d.ts +10 -15
- package/connector/blockchain/private-key-provider.connector.js +12 -12
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/private-key-provider.connector.spec.js +23 -36
- package/connector/blockchain/web3-provider-connector.d.ts +8 -13
- package/connector/blockchain/web3-provider-connector.js +9 -12
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/web3-provider.connector.spec.js +26 -37
- package/connector/http/axios-provider.connector.d.ts +3 -3
- package/connector/http/axios-provider.connector.js +13 -13
- package/connector/http/axios-provider.connector.spec.d.ts +1 -1
- package/connector/http/axios-provider.connector.spec.js +31 -37
- package/connector/http/http-provider.connector.d.ts +2 -2
- package/connector/http/http-provider.connector.js +3 -3
- package/connector/http/index.d.ts +2 -2
- package/connector/http/index.js +6 -6
- package/connector/index.d.ts +2 -2
- package/connector/index.js +6 -6
- package/constants.d.ts +6 -10
- package/constants.js +16 -23
- package/fusion-order/fusion-order.d.ts +7 -17
- package/fusion-order/fusion-order.js +12 -14
- package/fusion-order/fusion-order.spec.d.ts +1 -1
- package/fusion-order/fusion-order.spec.js +22 -27
- package/fusion-order/index.d.ts +1 -1
- package/fusion-order/index.js +5 -5
- package/index.d.ts +11 -11
- package/index.js +15 -15
- package/limit-order/eip712/domain.d.ts +9 -10
- package/limit-order/eip712/domain.js +23 -28
- package/limit-order/eip712/eip712.types.d.ts +15 -19
- package/limit-order/eip712/eip712.types.js +3 -3
- package/limit-order/eip712/index.d.ts +3 -3
- package/limit-order/eip712/index.js +7 -7
- package/limit-order/eip712/order-typed-data-builder.d.ts +6 -17
- package/limit-order/eip712/order-typed-data-builder.js +19 -34
- package/limit-order/index.d.ts +4 -4
- package/limit-order/index.js +8 -8
- package/limit-order/interactions-factory.d.ts +1 -1
- package/limit-order/interactions-factory.js +6 -6
- package/limit-order/limit-order.d.ts +25 -31
- package/limit-order/limit-order.js +50 -103
- package/limit-order/limit-order.spec.d.ts +1 -1
- package/limit-order/limit-order.spec.js +51 -75
- package/limit-order/parser/constants.d.ts +9 -9
- package/limit-order/parser/constants.js +5 -5
- package/limit-order/parser/index.d.ts +3 -3
- package/limit-order/parser/index.js +7 -7
- package/limit-order/parser/parser.d.ts +2 -5
- package/limit-order/parser/parser.js +18 -23
- package/limit-order/parser/types.d.ts +3 -3
- package/limit-order/parser/types.js +3 -3
- package/limit-order/predicate-factory.d.ts +5 -9
- package/limit-order/predicate-factory.js +24 -40
- package/limit-order/predicate-factory.spec.d.ts +1 -1
- package/limit-order/predicate-factory.spec.js +29 -44
- package/limit-order/types.d.ts +29 -29
- package/limit-order/types.js +3 -3
- package/limit-order/utils.d.ts +1 -1
- package/limit-order/utils.js +6 -6
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +6 -6
- package/sdk/sdk.d.ts +11 -29
- package/sdk/sdk.js +40 -49
- package/sdk/sdk.js.map +1 -1
- package/sdk/types.d.ts +27 -27
- package/sdk/types.js +3 -3
- package/settlement/encoders/constants.d.ts +1 -1
- package/settlement/encoders/constants.js +5 -5
- package/settlement/encoders/fill-order.encoder.d.ts +2 -2
- package/settlement/encoders/fill-order.encoder.js +12 -26
- package/settlement/encoders/index.d.ts +3 -3
- package/settlement/encoders/index.js +7 -7
- package/settlement/encoders/settlement.encoder.d.ts +5 -13
- package/settlement/encoders/settlement.encoder.js +38 -42
- package/settlement/encoders/settlement.encoder.js.map +1 -1
- package/settlement/index.d.ts +4 -4
- package/settlement/index.js +8 -8
- package/settlement/settlement.d.ts +6 -8
- package/settlement/settlement.js +20 -28
- package/settlement/settlement.js.map +1 -1
- package/settlement/settlement.spec.d.ts +1 -1
- package/settlement/settlement.spec.js +41 -45
- package/settlement/settlement.spec.js.map +1 -1
- package/settlement/signature-patcher.d.ts +1 -1
- package/settlement/signature-patcher.js +16 -19
- package/settlement/types.d.ts +13 -13
- package/settlement/types.js +3 -3
- package/utils.d.ts +6 -6
- package/utils.js +23 -29
- package/validations.d.ts +2 -2
- package/validations.js +15 -14
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const limit_order_1 = require(
|
|
4
|
-
const predicate_factory_1 = require(
|
|
5
|
-
const interactions_factory_1 = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const limit_order_1 = require("./limit-order");
|
|
4
|
+
const predicate_factory_1 = require("./predicate-factory");
|
|
5
|
+
const interactions_factory_1 = require("./interactions-factory");
|
|
6
6
|
describe('Limit Order', () => {
|
|
7
|
-
jest.spyOn(Math, 'random').mockReturnValue(1)
|
|
8
|
-
jest.spyOn(Date, 'now').mockReturnValue(1673549418040)
|
|
7
|
+
jest.spyOn(Math, 'random').mockReturnValue(1);
|
|
8
|
+
jest.spyOn(Date, 'now').mockReturnValue(1673549418040);
|
|
9
9
|
it('should create limit order', () => {
|
|
10
10
|
const order = new limit_order_1.LimitOrder({
|
|
11
11
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -13,7 +13,7 @@ describe('Limit Order', () => {
|
|
|
13
13
|
makingAmount: '1000000000000000000',
|
|
14
14
|
takingAmount: '1420000000',
|
|
15
15
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
16
|
-
})
|
|
16
|
+
});
|
|
17
17
|
expect(order.build()).toStrictEqual({
|
|
18
18
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
19
19
|
interactions: '0x',
|
|
@@ -25,93 +25,71 @@ describe('Limit Order', () => {
|
|
|
25
25
|
salt: '1673549418040',
|
|
26
26
|
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
27
27
|
takingAmount: '1420000000'
|
|
28
|
-
})
|
|
29
|
-
})
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
30
|
it('should create limit order with timestampBelow predicate', () => {
|
|
31
|
-
const order = new limit_order_1.LimitOrder(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
predicate:
|
|
41
|
-
predicate_factory_1.PredicateFactory.timestampBelow(
|
|
42
|
-
1673549418
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
)
|
|
31
|
+
const order = new limit_order_1.LimitOrder({
|
|
32
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
33
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
34
|
+
makingAmount: '1000000000000000000',
|
|
35
|
+
takingAmount: '1420000000',
|
|
36
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
37
|
+
}, {
|
|
38
|
+
predicate: predicate_factory_1.PredicateFactory.timestampBelow(1673549418)
|
|
39
|
+
});
|
|
46
40
|
expect(order.build()).toStrictEqual({
|
|
47
41
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
48
|
-
interactions:
|
|
49
|
-
'0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a',
|
|
42
|
+
interactions: '0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a',
|
|
50
43
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
51
44
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
52
45
|
makingAmount: '1000000000000000000',
|
|
53
|
-
offsets:
|
|
54
|
-
'970558080243398695134547109586957793750899628853613079895592438595584',
|
|
46
|
+
offsets: '970558080243398695134547109586957793750899628853613079895592438595584',
|
|
55
47
|
receiver: '0x0000000000000000000000000000000000000000',
|
|
56
48
|
salt: '1673549418040',
|
|
57
49
|
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
58
50
|
takingAmount: '1420000000'
|
|
59
|
-
})
|
|
60
|
-
})
|
|
51
|
+
});
|
|
52
|
+
});
|
|
61
53
|
it('should create limit order with timestampBelow predicate that will unwrap maker weth to eth', () => {
|
|
62
|
-
const order = new limit_order_1.LimitOrder(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
predicate_factory_1.PredicateFactory.timestampBelow(
|
|
73
|
-
1673549418
|
|
74
|
-
),
|
|
75
|
-
postInteraction:
|
|
76
|
-
interactions_factory_1.InteractionsFactory.unwrap(
|
|
77
|
-
'0x08b067ad41e45babe5bbb52fc2fe7f692f628b06',
|
|
78
|
-
'0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
79
|
-
)
|
|
80
|
-
}
|
|
81
|
-
)
|
|
54
|
+
const order = new limit_order_1.LimitOrder({
|
|
55
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
56
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
57
|
+
makingAmount: '1000000000000000000',
|
|
58
|
+
takingAmount: '1420000000',
|
|
59
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
60
|
+
}, {
|
|
61
|
+
predicate: predicate_factory_1.PredicateFactory.timestampBelow(1673549418),
|
|
62
|
+
postInteraction: interactions_factory_1.InteractionsFactory.unwrap('0x08b067ad41e45babe5bbb52fc2fe7f692f628b06', '0x00000000219ab540356cbb839cbe05303d7705fa')
|
|
63
|
+
});
|
|
82
64
|
expect(order.build()).toStrictEqual({
|
|
83
65
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
84
|
-
interactions:
|
|
85
|
-
'0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a08b067ad41e45babe5bbb52fc2fe7f692f628b0600000000219ab540356cbb839cbe05303d7705fa',
|
|
66
|
+
interactions: '0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a08b067ad41e45babe5bbb52fc2fe7f692f628b0600000000219ab540356cbb839cbe05303d7705fa',
|
|
86
67
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
87
68
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
88
69
|
makingAmount: '1000000000000000000',
|
|
89
|
-
offsets:
|
|
90
|
-
'2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
70
|
+
offsets: '2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
91
71
|
receiver: '0x0000000000000000000000000000000000000000',
|
|
92
72
|
salt: '1673549418040',
|
|
93
73
|
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
94
74
|
takingAmount: '1420000000'
|
|
95
|
-
})
|
|
96
|
-
})
|
|
75
|
+
});
|
|
76
|
+
});
|
|
97
77
|
it('should decode limit order struct', () => {
|
|
98
78
|
const orderStruct = {
|
|
99
79
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
100
|
-
interactions:
|
|
101
|
-
'0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a08b067ad41e45babe5bbb52fc2fe7f692f628b0600000000219ab540356cbb839cbe05303d7705fa',
|
|
80
|
+
interactions: '0x63592c2b0000000000000000000000000000000000000000000000000000000063c0566a08b067ad41e45babe5bbb52fc2fe7f692f628b0600000000219ab540356cbb839cbe05303d7705fa',
|
|
102
81
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
103
82
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
104
83
|
makingAmount: '1000000000000000000',
|
|
105
|
-
offsets:
|
|
106
|
-
'2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
84
|
+
offsets: '2048955946929424286921227713067743020696385405755235979139736848564224',
|
|
107
85
|
receiver: '0x0000000000000000000000000000000000000000',
|
|
108
86
|
salt: '1673549418040',
|
|
109
87
|
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
110
88
|
takingAmount: '1420000000'
|
|
111
|
-
}
|
|
112
|
-
const order = limit_order_1.LimitOrder.decode(orderStruct)
|
|
113
|
-
expect(order.build()).toStrictEqual(orderStruct)
|
|
114
|
-
})
|
|
89
|
+
};
|
|
90
|
+
const order = limit_order_1.LimitOrder.decode(orderStruct);
|
|
91
|
+
expect(order.build()).toStrictEqual(orderStruct);
|
|
92
|
+
});
|
|
115
93
|
it('should get limit order typed data', () => {
|
|
116
94
|
const order = new limit_order_1.LimitOrder({
|
|
117
95
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -119,7 +97,7 @@ describe('Limit Order', () => {
|
|
|
119
97
|
makingAmount: '1000000000000000000',
|
|
120
98
|
takingAmount: '1420000000',
|
|
121
99
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
122
|
-
})
|
|
100
|
+
});
|
|
123
101
|
expect(order.getTypedData()).toStrictEqual({
|
|
124
102
|
domain: {
|
|
125
103
|
chainId: 1,
|
|
@@ -202,8 +180,8 @@ describe('Limit Order', () => {
|
|
|
202
180
|
}
|
|
203
181
|
]
|
|
204
182
|
}
|
|
205
|
-
})
|
|
206
|
-
})
|
|
183
|
+
});
|
|
184
|
+
});
|
|
207
185
|
it('should get limit order hash', () => {
|
|
208
186
|
const order = new limit_order_1.LimitOrder({
|
|
209
187
|
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
@@ -211,10 +189,8 @@ describe('Limit Order', () => {
|
|
|
211
189
|
makingAmount: '1000000000000000000',
|
|
212
190
|
takingAmount: '1420000000',
|
|
213
191
|
maker: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
214
|
-
})
|
|
215
|
-
expect(order.getOrderHash()).toBe(
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
})
|
|
220
|
-
//# sourceMappingURL=limit-order.spec.js.map
|
|
192
|
+
});
|
|
193
|
+
expect(order.getOrderHash()).toBe('0x4bdb758d3d4b265367c461cdb12b2fbe92fd8f2bcc9423393e9da4490d6157c4');
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
//# sourceMappingURL=limit-order.spec.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export declare const DynamicField: {
|
|
2
|
-
readonly makerAssetData: 0
|
|
3
|
-
readonly takerAssetData: 1
|
|
4
|
-
readonly getMakingAmount: 2
|
|
5
|
-
readonly getTakingAmount: 3
|
|
6
|
-
readonly predicate: 4
|
|
7
|
-
readonly permit: 5
|
|
8
|
-
readonly preInteraction: 6
|
|
9
|
-
readonly postInteraction: 7
|
|
10
|
-
}
|
|
2
|
+
readonly makerAssetData: 0;
|
|
3
|
+
readonly takerAssetData: 1;
|
|
4
|
+
readonly getMakingAmount: 2;
|
|
5
|
+
readonly getTakingAmount: 3;
|
|
6
|
+
readonly predicate: 4;
|
|
7
|
+
readonly permit: 5;
|
|
8
|
+
readonly preInteraction: 6;
|
|
9
|
+
readonly postInteraction: 7;
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.DynamicField = void 0
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamicField = void 0;
|
|
4
4
|
exports.DynamicField = {
|
|
5
5
|
makerAssetData: 0,
|
|
6
6
|
takerAssetData: 1,
|
|
@@ -10,5 +10,5 @@ exports.DynamicField = {
|
|
|
10
10
|
permit: 5,
|
|
11
11
|
preInteraction: 6,
|
|
12
12
|
postInteraction: 7
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=constants.js.map
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './parser'
|
|
2
|
-
export * from './types'
|
|
3
|
-
export * from './constants'
|
|
1
|
+
export * from './parser';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './constants';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const tslib_1 = require(
|
|
4
|
-
tslib_1.__exportStar(require(
|
|
5
|
-
tslib_1.__exportStar(require(
|
|
6
|
-
tslib_1.__exportStar(require(
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./parser"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./types"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./constants"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import {ParsedInteractions} from './types'
|
|
2
|
-
export declare function parseInteractions(
|
|
3
|
-
offsets: string,
|
|
4
|
-
interactions: string
|
|
5
|
-
): ParsedInteractions
|
|
1
|
+
import { ParsedInteractions } from './types';
|
|
2
|
+
export declare function parseInteractions(offsets: string, interactions: string): ParsedInteractions;
|
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.parseInteractions = void 0
|
|
4
|
-
const utils_1 = require(
|
|
5
|
-
const constants_1 = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseInteractions = void 0;
|
|
4
|
+
const utils_1 = require("../../utils");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
6
|
function parseInteractions(offsets, interactions) {
|
|
7
|
-
const offsetsBN = (0, utils_1.toBN)(offsets)
|
|
8
|
-
const parsedInteractions = {}
|
|
9
|
-
interactions = (0, utils_1.trim0x)(interactions)
|
|
7
|
+
const offsetsBN = (0, utils_1.toBN)(offsets);
|
|
8
|
+
const parsedInteractions = {};
|
|
9
|
+
interactions = (0, utils_1.trim0x)(interactions);
|
|
10
10
|
for (const interactionName in constants_1.DynamicField) {
|
|
11
|
-
const field = interactionName
|
|
12
|
-
parsedInteractions[field] = parseInteractionForField(
|
|
13
|
-
offsetsBN,
|
|
14
|
-
interactions,
|
|
15
|
-
constants_1.DynamicField[field]
|
|
16
|
-
)
|
|
11
|
+
const field = interactionName;
|
|
12
|
+
parsedInteractions[field] = parseInteractionForField(offsetsBN, interactions, constants_1.DynamicField[field]);
|
|
17
13
|
}
|
|
18
|
-
return parsedInteractions
|
|
14
|
+
return parsedInteractions;
|
|
19
15
|
}
|
|
20
|
-
exports.parseInteractions = parseInteractions
|
|
16
|
+
exports.parseInteractions = parseInteractions;
|
|
21
17
|
function parseInteractionForField(offsets, interactions, field) {
|
|
22
|
-
const {fromByte, toByte} = getOffsetForInteraction(offsets, field)
|
|
23
|
-
return '0x' + interactions.slice(fromByte * 2, toByte * 2)
|
|
18
|
+
const { fromByte, toByte } = getOffsetForInteraction(offsets, field);
|
|
19
|
+
return '0x' + interactions.slice(fromByte * 2, toByte * 2);
|
|
24
20
|
}
|
|
25
21
|
function getOffsetForInteraction(offsets, field) {
|
|
26
|
-
const fromByteBN =
|
|
27
|
-
|
|
28
|
-
const toByteBN = offsets.shrn(field * 32).maskn(32)
|
|
22
|
+
const fromByteBN = field === 0 ? '0' : offsets.shrn((field - 1) * 32).maskn(32);
|
|
23
|
+
const toByteBN = offsets.shrn(field * 32).maskn(32);
|
|
29
24
|
return {
|
|
30
25
|
fromByte: parseInt(fromByteBN.toString()),
|
|
31
26
|
toByte: parseInt(toByteBN.toString())
|
|
32
|
-
}
|
|
27
|
+
};
|
|
33
28
|
}
|
|
34
|
-
//# sourceMappingURL=parser.js.map
|
|
29
|
+
//# sourceMappingURL=parser.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {DynamicField} from './constants'
|
|
2
|
-
export declare type InteractionField = keyof typeof DynamicField
|
|
3
|
-
export declare type ParsedInteractions = Record<InteractionField, string
|
|
1
|
+
import { DynamicField } from './constants';
|
|
2
|
+
export declare type InteractionField = keyof typeof DynamicField;
|
|
3
|
+
export declare type ParsedInteractions = Record<InteractionField, string>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -2,28 +2,24 @@ export declare class PredicateFactory {
|
|
|
2
2
|
/**
|
|
3
3
|
* timestampBelow(uint256)
|
|
4
4
|
*/
|
|
5
|
-
private static TIMESTAMP_BELOW_SELECTOR
|
|
5
|
+
private static TIMESTAMP_BELOW_SELECTOR;
|
|
6
6
|
/**
|
|
7
7
|
* timestampBelowAndNonceEquals(uint256 timeNonceAccount)
|
|
8
8
|
*/
|
|
9
|
-
private static TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR
|
|
9
|
+
private static TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR;
|
|
10
10
|
/**
|
|
11
11
|
* @param deadline timestamp in seconds (order expiration time)
|
|
12
12
|
*/
|
|
13
|
-
static timestampBelow(deadline: number): string
|
|
13
|
+
static timestampBelow(deadline: number): string;
|
|
14
14
|
/**
|
|
15
15
|
* @param address limit order creator address
|
|
16
16
|
* @param nonce sequence number for order cancellation
|
|
17
17
|
* @param deadline timestamp in seconds (order expiration time)
|
|
18
18
|
*/
|
|
19
|
-
static timestampBelowAndNonceEquals(
|
|
20
|
-
address: string,
|
|
21
|
-
nonce: string | number,
|
|
22
|
-
deadline: number
|
|
23
|
-
): string
|
|
19
|
+
static timestampBelowAndNonceEquals(address: string, nonce: string | number, deadline: number): string;
|
|
24
20
|
/**
|
|
25
21
|
* @param predicate predicate field from parsed order's interactions
|
|
26
22
|
* @returns {number} expiration time in seconds in case it exists in predicate
|
|
27
23
|
*/
|
|
28
|
-
static parseExpirationTime(predicate: string): number | null
|
|
24
|
+
static parseExpirationTime(predicate: string): number | null;
|
|
29
25
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.PredicateFactory = void 0
|
|
4
|
-
const bignumber_1 = require(
|
|
5
|
-
const utils_1 = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PredicateFactory = void 0;
|
|
4
|
+
const bignumber_1 = require("@ethersproject/bignumber");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
6
|
class PredicateFactory {
|
|
7
7
|
/**
|
|
8
8
|
* @param deadline timestamp in seconds (order expiration time)
|
|
@@ -11,11 +11,8 @@ class PredicateFactory {
|
|
|
11
11
|
const timeHex = bignumber_1.BigNumber.from(deadline)
|
|
12
12
|
.toHexString()
|
|
13
13
|
.substring(2)
|
|
14
|
-
.padStart(64, '0')
|
|
15
|
-
return (
|
|
16
|
-
(0, utils_1.add0x)(PredicateFactory.TIMESTAMP_BELOW_SELECTOR) +
|
|
17
|
-
timeHex
|
|
18
|
-
)
|
|
14
|
+
.padStart(64, '0');
|
|
15
|
+
return (0, utils_1.add0x)(PredicateFactory.TIMESTAMP_BELOW_SELECTOR) + timeHex;
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
18
|
* @param address limit order creator address
|
|
@@ -27,12 +24,9 @@ class PredicateFactory {
|
|
|
27
24
|
.or((0, utils_1.toBN)(nonce).shln(160))
|
|
28
25
|
.or((0, utils_1.toBN)(deadline).shln(208))
|
|
29
26
|
.toString('hex')
|
|
30
|
-
.padStart(64, '0')
|
|
31
|
-
return (
|
|
32
|
-
|
|
33
|
-
PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR
|
|
34
|
-
) + timeNonceAccountHex
|
|
35
|
-
)
|
|
27
|
+
.padStart(64, '0');
|
|
28
|
+
return ((0, utils_1.add0x)(PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR) +
|
|
29
|
+
timeNonceAccountHex);
|
|
36
30
|
}
|
|
37
31
|
/**
|
|
38
32
|
* @param predicate predicate field from parsed order's interactions
|
|
@@ -40,37 +34,27 @@ class PredicateFactory {
|
|
|
40
34
|
*/
|
|
41
35
|
static parseExpirationTime(predicate) {
|
|
42
36
|
if (predicate.includes(PredicateFactory.TIMESTAMP_BELOW_SELECTOR)) {
|
|
43
|
-
const dataAfterSelector = predicate.split(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const deadlineSec = bignumber_1.BigNumber.from(
|
|
47
|
-
'0x' + dataAfterSelector.substring(0, 64)
|
|
48
|
-
).toString()
|
|
49
|
-
return +deadlineSec
|
|
37
|
+
const dataAfterSelector = predicate.split(PredicateFactory.TIMESTAMP_BELOW_SELECTOR)[1];
|
|
38
|
+
const deadlineSec = bignumber_1.BigNumber.from('0x' + dataAfterSelector.substring(0, 64)).toString();
|
|
39
|
+
return +deadlineSec;
|
|
50
40
|
}
|
|
51
|
-
if (
|
|
52
|
-
predicate.
|
|
53
|
-
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR
|
|
58
|
-
)[1]
|
|
59
|
-
const funcData = '0x' + dataAfterSelector.substring(0, 64)
|
|
60
|
-
const info = (0, utils_1.toBN)(funcData)
|
|
61
|
-
const dateSec = info.shrn(160 + (208 - 160)).toString()
|
|
62
|
-
return +dateSec
|
|
41
|
+
if (predicate.includes(PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR)) {
|
|
42
|
+
const dataAfterSelector = predicate.split(PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR)[1];
|
|
43
|
+
const funcData = '0x' + dataAfterSelector.substring(0, 64);
|
|
44
|
+
const info = (0, utils_1.toBN)(funcData);
|
|
45
|
+
const dateSec = info.shrn(160 + (208 - 160)).toString();
|
|
46
|
+
return +dateSec;
|
|
63
47
|
}
|
|
64
|
-
return null
|
|
48
|
+
return null;
|
|
65
49
|
}
|
|
66
50
|
}
|
|
67
|
-
exports.PredicateFactory = PredicateFactory
|
|
51
|
+
exports.PredicateFactory = PredicateFactory;
|
|
68
52
|
/**
|
|
69
53
|
* timestampBelow(uint256)
|
|
70
54
|
*/
|
|
71
|
-
PredicateFactory.TIMESTAMP_BELOW_SELECTOR = '63592c2b'
|
|
55
|
+
PredicateFactory.TIMESTAMP_BELOW_SELECTOR = '63592c2b';
|
|
72
56
|
/**
|
|
73
57
|
* timestampBelowAndNonceEquals(uint256 timeNonceAccount)
|
|
74
58
|
*/
|
|
75
|
-
PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR = '2cc2878d'
|
|
76
|
-
//# sourceMappingURL=predicate-factory.js.map
|
|
59
|
+
PredicateFactory.TIMESTAMP_BELOW_AND_NONCE_EQUALS_SELECTOR = '2cc2878d';
|
|
60
|
+
//# sourceMappingURL=predicate-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
|
@@ -1,50 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const predicate_factory_1 = require(
|
|
4
|
-
const utils_1 = require(
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const predicate_factory_1 = require("./predicate-factory");
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
5
|
describe('Predicate Factory', () => {
|
|
6
|
-
jest.spyOn(Date, 'now').mockReturnValue(1673549418040)
|
|
6
|
+
jest.spyOn(Date, 'now').mockReturnValue(1673549418040);
|
|
7
7
|
it('should create timestampBelow predicate', () => {
|
|
8
|
-
const expirationTime = (0, utils_1.toSec)(Date.now()) + 60
|
|
9
|
-
const predicate =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
'0x63592c2b0000000000000000000000000000000000000000000000000000000063c056a6'
|
|
13
|
-
)
|
|
14
|
-
})
|
|
8
|
+
const expirationTime = (0, utils_1.toSec)(Date.now()) + 60;
|
|
9
|
+
const predicate = predicate_factory_1.PredicateFactory.timestampBelow(expirationTime);
|
|
10
|
+
expect(predicate).toBe('0x63592c2b0000000000000000000000000000000000000000000000000000000063c056a6');
|
|
11
|
+
});
|
|
15
12
|
it('should create timestampBelowAndNonceEquals predicate', () => {
|
|
16
|
-
const account = '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
17
|
-
const nonce = '1'
|
|
18
|
-
const expirationTime = (0, utils_1.toSec)(Date.now()) + 60
|
|
19
|
-
const predicate =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
nonce,
|
|
23
|
-
expirationTime
|
|
24
|
-
)
|
|
25
|
-
expect(predicate).toBe(
|
|
26
|
-
'0x2cc2878d000063c056a600000000000100000000219ab540356cbb839cbe05303d7705fa'
|
|
27
|
-
)
|
|
28
|
-
})
|
|
13
|
+
const account = '0x00000000219ab540356cbb839cbe05303d7705fa';
|
|
14
|
+
const nonce = '1';
|
|
15
|
+
const expirationTime = (0, utils_1.toSec)(Date.now()) + 60;
|
|
16
|
+
const predicate = predicate_factory_1.PredicateFactory.timestampBelowAndNonceEquals(account, nonce, expirationTime);
|
|
17
|
+
expect(predicate).toBe('0x2cc2878d000063c056a600000000000100000000219ab540356cbb839cbe05303d7705fa');
|
|
18
|
+
});
|
|
29
19
|
it('should parse timestampBelow predicate expiration time', () => {
|
|
30
|
-
const predicate =
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
expect(expirationTime).toBe(1673549478)
|
|
35
|
-
})
|
|
20
|
+
const predicate = '0x63592c2b0000000000000000000000000000000000000000000000000000000063c056a6';
|
|
21
|
+
const expirationTime = predicate_factory_1.PredicateFactory.parseExpirationTime(predicate);
|
|
22
|
+
expect(expirationTime).toBe(1673549478);
|
|
23
|
+
});
|
|
36
24
|
it('should parse timestampBelowAndNonceEquals predicate expiration time', () => {
|
|
37
|
-
const predicate =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
expect(expirationTime).toBe(1673549478)
|
|
42
|
-
})
|
|
25
|
+
const predicate = '0x2cc2878d000063c056a600000000000100000000219ab540356cbb839cbe05303d7705fa';
|
|
26
|
+
const expirationTime = predicate_factory_1.PredicateFactory.parseExpirationTime(predicate);
|
|
27
|
+
expect(expirationTime).toBe(1673549478);
|
|
28
|
+
});
|
|
43
29
|
it('should return null on non exising expiration time', () => {
|
|
44
|
-
const predicate = '0x12345678'
|
|
45
|
-
const expirationTime =
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
//# sourceMappingURL=predicate-factory.spec.js.map
|
|
30
|
+
const predicate = '0x12345678';
|
|
31
|
+
const expirationTime = predicate_factory_1.PredicateFactory.parseExpirationTime(predicate);
|
|
32
|
+
expect(expirationTime).toBe(null);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
//# sourceMappingURL=predicate-factory.spec.js.map
|
package/limit-order/types.d.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
export declare type OrderInfoData = {
|
|
2
|
-
makerAsset: string
|
|
3
|
-
takerAsset: string
|
|
4
|
-
makingAmount: string
|
|
5
|
-
takingAmount: string
|
|
6
|
-
maker: string
|
|
7
|
-
salt?: string
|
|
8
|
-
allowedSender?: string
|
|
9
|
-
receiver?: string
|
|
10
|
-
}
|
|
2
|
+
makerAsset: string;
|
|
3
|
+
takerAsset: string;
|
|
4
|
+
makingAmount: string;
|
|
5
|
+
takingAmount: string;
|
|
6
|
+
maker: string;
|
|
7
|
+
salt?: string;
|
|
8
|
+
allowedSender?: string;
|
|
9
|
+
receiver?: string;
|
|
10
|
+
};
|
|
11
11
|
export declare type InteractionsData = {
|
|
12
|
-
makerAssetData?: string
|
|
13
|
-
takerAssetData?: string
|
|
14
|
-
getMakingAmount?: string
|
|
15
|
-
getTakingAmount?: string
|
|
16
|
-
predicate?: string
|
|
17
|
-
permit?: string
|
|
18
|
-
preInteraction?: string
|
|
19
|
-
postInteraction?: string
|
|
20
|
-
}
|
|
12
|
+
makerAssetData?: string;
|
|
13
|
+
takerAssetData?: string;
|
|
14
|
+
getMakingAmount?: string;
|
|
15
|
+
getTakingAmount?: string;
|
|
16
|
+
predicate?: string;
|
|
17
|
+
permit?: string;
|
|
18
|
+
preInteraction?: string;
|
|
19
|
+
postInteraction?: string;
|
|
20
|
+
};
|
|
21
21
|
export declare type LimitOrderV3Struct = {
|
|
22
|
-
salt: string
|
|
23
|
-
makerAsset: string
|
|
24
|
-
takerAsset: string
|
|
25
|
-
maker: string
|
|
26
|
-
receiver: string
|
|
27
|
-
allowedSender: string
|
|
28
|
-
makingAmount: string
|
|
29
|
-
takingAmount: string
|
|
30
|
-
offsets: string
|
|
31
|
-
interactions: string
|
|
32
|
-
}
|
|
22
|
+
salt: string;
|
|
23
|
+
makerAsset: string;
|
|
24
|
+
takerAsset: string;
|
|
25
|
+
maker: string;
|
|
26
|
+
receiver: string;
|
|
27
|
+
allowedSender: string;
|
|
28
|
+
makingAmount: string;
|
|
29
|
+
takingAmount: string;
|
|
30
|
+
offsets: string;
|
|
31
|
+
interactions: string;
|
|
32
|
+
};
|
package/limit-order/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
//# sourceMappingURL=types.js.map
|
package/limit-order/utils.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function buildSalt(): string
|
|
1
|
+
export declare function buildSalt(): string;
|
package/limit-order/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.buildSalt = void 0
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildSalt = void 0;
|
|
4
4
|
function buildSalt() {
|
|
5
|
-
return Math.round(Math.random() * Date.now()) + ''
|
|
5
|
+
return Math.round(Math.random() * Date.now()) + '';
|
|
6
6
|
}
|
|
7
|
-
exports.buildSalt = buildSalt
|
|
8
|
-
//# sourceMappingURL=utils.js.map
|
|
7
|
+
exports.buildSalt = buildSalt;
|
|
8
|
+
//# sourceMappingURL=utils.js.map
|