@1inch/fusion-sdk 0.0.5 → 0.0.6
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/api/fusion-api.d.ts +25 -16
- package/api/fusion-api.js +36 -26
- 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 +479 -395
- package/api/orders/order-api.spec.js.map +1 -1
- package/api/orders/orders.api.d.ts +24 -10
- package/api/orders/orders.api.js +30 -28
- package/api/orders/orders.request.d.ts +22 -18
- package/api/orders/orders.request.js +40 -31
- package/api/orders/types.d.ts +59 -57
- package/api/orders/types.js +17 -16
- package/api/orders/types.js.map +1 -1
- 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 +28 -21
- package/api/params.d.ts +3 -1
- package/api/params.js +25 -19
- 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 +19 -17
- 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 +6 -6
- package/api/quoter/quote/order-params.js +12 -12
- package/api/quoter/quote/quote.d.ts +26 -21
- package/api/quoter/quote/quote.js +85 -52
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quote/types.d.ts +4 -4
- package/api/quoter/quote/types.js +3 -3
- package/api/quoter/quoter.api.d.ts +12 -9
- 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 +32 -23
- 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 +28 -26
- package/api/quoter/types.d.ts +45 -44
- package/api/quoter/types.js +10 -10
- package/api/quoter/types.js.map +1 -1
- package/api/relayer/index.d.ts +3 -3
- package/api/relayer/index.js +7 -7
- package/api/relayer/relayer.api.d.ts +12 -9
- 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 +96 -79
- 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 +17 -15
- package/api/types.js +3 -3
- package/auction-calculator/auction-calculator.d.ts +22 -13
- package/auction-calculator/auction-calculator.js +70 -45
- package/auction-calculator/auction-calculator.spec.d.ts +1 -1
- package/auction-calculator/auction-calculator.spec.js +45 -32
- package/auction-calculator/calc.d.ts +8 -2
- 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 +34 -23
- package/auction-salt/auction.salt.spec.d.ts +1 -1
- package/auction-salt/auction.salt.spec.js +38 -27
- 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 +33 -14
- 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 +33 -22
- 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 +36 -23
- package/auction-suffix/auction-suffix.spec.d.ts +1 -1
- package/auction-suffix/auction-suffix.spec.js +20 -15
- package/auction-suffix/constants.d.ts +1 -1
- package/auction-suffix/constants.js +5 -5
- package/auction-suffix/encoder.d.ts +15 -6
- package/auction-suffix/encoder.js +45 -28
- 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 +30 -17
- package/auction-suffix/parser/errors.d.ts +1 -2
- package/auction-suffix/parser/errors.js +6 -7
- package/auction-suffix/parser/index.d.ts +4 -4
- package/auction-suffix/parser/index.js +8 -8
- package/auction-suffix/parser/parser.d.ts +28 -8
- package/auction-suffix/parser/parser.js +162 -81
- 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 +6 -3
- 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 +15 -10
- 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 +36 -23
- package/connector/blockchain/web3-provider-connector.d.ts +13 -8
- package/connector/blockchain/web3-provider-connector.js +12 -9
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/web3-provider.connector.spec.js +37 -26
- 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 +37 -31
- 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 +10 -6
- package/constants.js +23 -16
- package/fusion-order/fusion-order.d.ts +17 -7
- package/fusion-order/fusion-order.js +14 -12
- package/fusion-order/fusion-order.spec.d.ts +1 -1
- package/fusion-order/fusion-order.spec.js +27 -22
- 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 +10 -9
- package/limit-order/eip712/domain.js +28 -23
- package/limit-order/eip712/eip712.types.d.ts +19 -15
- 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 +17 -6
- package/limit-order/eip712/order-typed-data-builder.js +34 -19
- 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 +31 -25
- package/limit-order/limit-order.js +103 -50
- package/limit-order/limit-order.spec.d.ts +1 -1
- package/limit-order/limit-order.spec.js +75 -51
- 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 +5 -2
- package/limit-order/parser/parser.js +23 -18
- package/limit-order/parser/types.d.ts +3 -3
- package/limit-order/parser/types.js +3 -3
- package/limit-order/predicate-factory.d.ts +9 -5
- package/limit-order/predicate-factory.js +40 -24
- package/limit-order/predicate-factory.spec.d.ts +1 -1
- package/limit-order/predicate-factory.spec.js +44 -29
- 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 +29 -11
- package/sdk/sdk.js +48 -38
- 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 +26 -12
- package/settlement/encoders/index.d.ts +3 -3
- package/settlement/encoders/index.js +7 -7
- package/settlement/encoders/settlement.encoder.d.ts +13 -4
- package/settlement/encoders/settlement.encoder.js +41 -19
- package/settlement/index.d.ts +4 -4
- package/settlement/index.js +8 -8
- package/settlement/settlement.d.ts +8 -5
- package/settlement/settlement.js +28 -14
- package/settlement/settlement.spec.d.ts +1 -1
- package/settlement/settlement.spec.js +45 -35
- package/settlement/signature-patcher.d.ts +1 -1
- package/settlement/signature-patcher.js +19 -16
- package/settlement/types.d.ts +13 -13
- package/settlement/types.js +3 -3
- package/utils.d.ts +6 -6
- package/utils.js +29 -23
- package/validations.d.ts +2 -2
- package/validations.js +14 -15
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function encodeSettleOrders(
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import {FillOrderParamsExtended} from '../types'
|
|
2
|
+
export declare function encodeSettleOrders(
|
|
3
|
+
params: FillOrderParamsExtended
|
|
4
|
+
): string
|
|
5
|
+
export declare function buildResolveOrdersBytes(
|
|
6
|
+
settlementContract: string,
|
|
7
|
+
resolverContract: string,
|
|
8
|
+
executionBytes: string
|
|
9
|
+
): string
|
|
10
|
+
export declare function buildRecursiveFillInteraction(
|
|
11
|
+
settlementContract: string,
|
|
12
|
+
params: FillOrderParamsExtended
|
|
13
|
+
): string
|
|
@@ -1,26 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.buildRecursiveFillInteraction =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.buildRecursiveFillInteraction =
|
|
4
|
+
exports.buildResolveOrdersBytes =
|
|
5
|
+
exports.encodeSettleOrders =
|
|
6
|
+
void 0
|
|
7
|
+
const tslib_1 = require('tslib')
|
|
8
|
+
const web3_eth_abi_1 = tslib_1.__importDefault(require('web3-eth-abi'))
|
|
9
|
+
const constants_1 = require('./constants')
|
|
10
|
+
const utils_1 = require('../../utils')
|
|
11
|
+
const fill_order_encoder_1 = require('./fill-order.encoder')
|
|
9
12
|
function encodeSettleOrders(params) {
|
|
10
|
-
const encodedOrder = (0, fill_order_encoder_1.encodeFillOrder)(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
const encodedOrder = (0, fill_order_encoder_1.encodeFillOrder)(
|
|
14
|
+
params
|
|
15
|
+
).substring(10)
|
|
16
|
+
return (
|
|
17
|
+
constants_1.SETTLE_ORDERS_SELECTOR +
|
|
18
|
+
(0, utils_1.trim0x)(
|
|
19
|
+
web3_eth_abi_1.default.encodeParameters(
|
|
20
|
+
['bytes'],
|
|
21
|
+
[(0, utils_1.add0x)(encodedOrder)]
|
|
22
|
+
)
|
|
23
|
+
)
|
|
24
|
+
)
|
|
13
25
|
}
|
|
14
|
-
exports.encodeSettleOrders = encodeSettleOrders
|
|
15
|
-
function buildResolveOrdersBytes(
|
|
16
|
-
|
|
26
|
+
exports.encodeSettleOrders = encodeSettleOrders
|
|
27
|
+
function buildResolveOrdersBytes(
|
|
28
|
+
settlementContract,
|
|
29
|
+
resolverContract,
|
|
30
|
+
executionBytes
|
|
31
|
+
) {
|
|
32
|
+
return (
|
|
33
|
+
settlementContract +
|
|
17
34
|
'01' +
|
|
18
35
|
(0, utils_1.trim0x)(resolverContract) +
|
|
19
|
-
(0, utils_1.trim0x)(executionBytes)
|
|
36
|
+
(0, utils_1.trim0x)(executionBytes)
|
|
37
|
+
)
|
|
20
38
|
}
|
|
21
|
-
exports.buildResolveOrdersBytes = buildResolveOrdersBytes
|
|
39
|
+
exports.buildResolveOrdersBytes = buildResolveOrdersBytes
|
|
22
40
|
function buildRecursiveFillInteraction(settlementContract, params) {
|
|
23
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
settlementContract +
|
|
43
|
+
'00' +
|
|
44
|
+
(0, fill_order_encoder_1.encodeFillOrder)(params).substring(10)
|
|
45
|
+
)
|
|
24
46
|
}
|
|
25
|
-
exports.buildRecursiveFillInteraction = buildRecursiveFillInteraction
|
|
26
|
-
//# sourceMappingURL=settlement.encoder.js.map
|
|
47
|
+
exports.buildRecursiveFillInteraction = buildRecursiveFillInteraction
|
|
48
|
+
//# sourceMappingURL=settlement.encoder.js.map
|
package/settlement/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './encoders'
|
|
2
|
-
export * from './settlement'
|
|
3
|
-
export * from './signature-patcher'
|
|
4
|
-
export * from './types'
|
|
1
|
+
export * from './encoders'
|
|
2
|
+
export * from './settlement'
|
|
3
|
+
export * from './signature-patcher'
|
|
4
|
+
export * from './types'
|
package/settlement/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
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
|
-
tslib_1.__exportStar(require(
|
|
8
|
-
//# 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('./encoders'), exports)
|
|
5
|
+
tslib_1.__exportStar(require('./settlement'), exports)
|
|
6
|
+
tslib_1.__exportStar(require('./signature-patcher'), exports)
|
|
7
|
+
tslib_1.__exportStar(require('./types'), exports)
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {FillOrderParams, SettlementConfig} from './types'
|
|
2
2
|
export declare class Settlement {
|
|
3
|
-
private readonly config
|
|
4
|
-
constructor(config: SettlementConfig)
|
|
5
|
-
static new(config: SettlementConfig): Settlement
|
|
6
|
-
encodeSettleOrders(
|
|
3
|
+
private readonly config
|
|
4
|
+
constructor(config: SettlementConfig)
|
|
5
|
+
static new(config: SettlementConfig): Settlement
|
|
6
|
+
encodeSettleOrders(
|
|
7
|
+
orders: FillOrderParams[],
|
|
8
|
+
resolverExecutionBytes: string
|
|
9
|
+
): string
|
|
7
10
|
}
|
package/settlement/settlement.js
CHANGED
|
@@ -1,26 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.Settlement = void 0
|
|
4
|
-
const settlement_encoder_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.Settlement = void 0
|
|
4
|
+
const settlement_encoder_1 = require('./encoders/settlement.encoder')
|
|
5
5
|
class Settlement {
|
|
6
6
|
constructor(config) {
|
|
7
|
-
this.config = config
|
|
7
|
+
this.config = config
|
|
8
8
|
}
|
|
9
9
|
static new(config) {
|
|
10
|
-
return new Settlement(config)
|
|
10
|
+
return new Settlement(config)
|
|
11
11
|
}
|
|
12
12
|
encodeSettleOrders(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
// sorted by: orders[0] executes first, orders[orders.length - 1] executes last
|
|
14
|
+
orders,
|
|
15
|
+
resolverExecutionBytes
|
|
16
|
+
) {
|
|
17
|
+
const finalActionBytes = (0,
|
|
18
|
+
settlement_encoder_1.buildResolveOrdersBytes)(
|
|
19
|
+
this.config.settlementContract,
|
|
20
|
+
this.config.resolverContract,
|
|
21
|
+
resolverExecutionBytes
|
|
22
|
+
)
|
|
16
23
|
const interaction = orders
|
|
17
24
|
.slice(1)
|
|
18
25
|
.reverse()
|
|
19
26
|
.reduce((acc, fillParams) => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
27
|
+
return (0, settlement_encoder_1.buildRecursiveFillInteraction)(
|
|
28
|
+
this.config.settlementContract,
|
|
29
|
+
Object.assign(Object.assign({}, fillParams), {
|
|
30
|
+
interaction: acc
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
}, finalActionBytes)
|
|
34
|
+
return (0, settlement_encoder_1.encodeSettleOrders)(
|
|
35
|
+
Object.assign(Object.assign({}, orders[0]), {interaction})
|
|
36
|
+
)
|
|
23
37
|
}
|
|
24
38
|
}
|
|
25
|
-
exports.Settlement = Settlement
|
|
26
|
-
//# sourceMappingURL=settlement.js.map
|
|
39
|
+
exports.Settlement = Settlement
|
|
40
|
+
//# sourceMappingURL=settlement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const settlement_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
const settlement_1 = require('./settlement')
|
|
4
4
|
describe('Settlement', () => {
|
|
5
|
-
const resolverContract = '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1'
|
|
6
|
-
const settlementContract = '0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
5
|
+
const resolverContract = '0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1'
|
|
6
|
+
const settlementContract = '0xa88800cd213da5ae406ce248380802bd53b47647'
|
|
7
7
|
it('should encode settlement', () => {
|
|
8
8
|
const settlement = settlement_1.Settlement.new({
|
|
9
9
|
resolverContract,
|
|
10
10
|
settlementContract
|
|
11
|
-
})
|
|
11
|
+
})
|
|
12
12
|
const limitOrder0 = {
|
|
13
13
|
salt: '618054093254',
|
|
14
14
|
makerAsset: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
|
|
@@ -18,10 +18,12 @@ describe('Settlement', () => {
|
|
|
18
18
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
19
19
|
makingAmount: '1000000000000000000',
|
|
20
20
|
takingAmount: '1000000000000000000',
|
|
21
|
-
offsets:
|
|
21
|
+
offsets:
|
|
22
|
+
'9813420589127697917471531885823684359047649055178615469676279994777600',
|
|
22
23
|
// eslint-disable-next-line max-len
|
|
23
|
-
interactions:
|
|
24
|
-
|
|
24
|
+
interactions:
|
|
25
|
+
'0x20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d43070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
|
|
26
|
+
}
|
|
25
27
|
const limitOrder1 = {
|
|
26
28
|
salt: '618054093254',
|
|
27
29
|
makerAsset: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
|
|
@@ -31,31 +33,39 @@ describe('Settlement', () => {
|
|
|
31
33
|
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
32
34
|
makingAmount: '1000000000000000000',
|
|
33
35
|
takingAmount: '1000000000000000000',
|
|
34
|
-
offsets:
|
|
36
|
+
offsets:
|
|
37
|
+
'9813420589127697917471531885823684359047649055178615469676279994777600',
|
|
35
38
|
// eslint-disable-next-line max-len
|
|
36
|
-
interactions:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
39
|
+
interactions:
|
|
40
|
+
'0x20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d43070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
|
|
41
|
+
}
|
|
42
|
+
const calldata = settlement.encodeSettleOrders(
|
|
43
|
+
[
|
|
44
|
+
{
|
|
45
|
+
order: limitOrder0,
|
|
46
|
+
makingAmount: '12345',
|
|
47
|
+
takingAmount: '0',
|
|
48
|
+
thresholdAmount: '12342343242342342342424324234242',
|
|
49
|
+
signature:
|
|
50
|
+
'0xaefe4201b2a66009b0f2976a638f54d6f6a63b0fdcfdc289523c7ea6220c7ab13d1af9de1b85701cfff745b96742e9e4c3b29057adcac8f3b62de7b1a4eb110d1b',
|
|
51
|
+
target: resolverContract
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
order: limitOrder1,
|
|
55
|
+
makingAmount: '678910',
|
|
56
|
+
takingAmount: '0',
|
|
57
|
+
thresholdAmount: '12342343242342342342424324234242',
|
|
58
|
+
signature:
|
|
59
|
+
'0x123e4201b2a66009b0f2976a638f54d6f6a63b0fdcfdc289523c7ea6220c7ab13d1af9de1b85701cfff745b96742e9e4c3b29057adcac8f3b62de7b1a4eb110d1b',
|
|
60
|
+
target: resolverContract
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
'0x123456'
|
|
64
|
+
)
|
|
56
65
|
expect(calldata).toBe(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
})
|
|
61
|
-
|
|
66
|
+
// eslint-disable-next-line max-len
|
|
67
|
+
'0x0965d04b000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008e000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000030390000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009bc8430b2577b5a268bb3c5c0200000000000000000000000084d99aa569d93a9ca187d83734c8c4a519c4e9b10000000000000000000000000000000000000000000000000000008fe6e509c6000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d4307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400000000016c0000016c0000016c0000016c000000880000004400000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000016c20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d4307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040aefe4201b2a66009b0f2976a638f54d6f6a63b0fdcfdc289523c7ea6220c7ab13d1af9de1b85701cfff745b96742e9e4c3b29057adcac8f3b62de7b1a4eb110d0000000000000000000000000000000000000000000000000000000000000495a88800cd213da5ae406ce248380802bd53b476470000000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000003c0000000000000000000000000000000000000000000000000000000000000042000000000000000000000000000000000000000000000000000000000000a5bfe0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000009bc8430b2577b5a268bb3c5c0200000000000000000000000084d99aa569d93a9ca187d83734c8c4a519c4e9b10000000000000000000000000000000000000000000000000000008fe6e509c6000000000000000000000000e9e7cea3dedca5984780bafc599bd69add087d56000000000000000000000000111111111117dc0aa78b770fa6a738034120c302000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d4307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400000000016c0000016c0000016c0000016c000000880000004400000000000000000000000000000000000000000000000000000000000000000000000000000140000000000000000000000000000000000000000000000000000000000000016c20b83f2d0000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a76400007e2d21830000000000000000000000000000000000000000000000000de0b6b3a76400000000000000000000000000000000000000000000000000000de0b6b3a7640000bfa7514300000000000000000000000000000000000000000000000000000068000000240000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000006863592c2b0000000000000000000000000000000000000000000000000000000063593ad9cf6fc6e3000000000000000000000000fb3c7eb936caa12b5a884d612393969a557d4307000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040123e4201b2a66009b0f2976a638f54d6f6a63b0fdcfdc289523c7ea6220c7ab13d1af9de1b85701cfff745b96742e9e4c3b29057adcac8f3b62de7b1a4eb110d000000000000000000000000000000000000000000000000000000000000002ca88800cd213da5ae406ce248380802bd53b476470184d99aa569d93a9ca187d83734c8c4a519c4e9b112345600000000000000000000000000000000000000000000000000000000000000'
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
//# sourceMappingURL=settlement.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function patchSignature(signature: string): string
|
|
1
|
+
export declare function patchSignature(signature: string): string
|
|
@@ -1,29 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.patchSignature = void 0
|
|
4
|
-
const tslib_1 = require(
|
|
5
|
-
const bn_js_1 = tslib_1.__importDefault(require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.patchSignature = void 0
|
|
4
|
+
const tslib_1 = require('tslib')
|
|
5
|
+
const bn_js_1 = tslib_1.__importDefault(require('bn.js'))
|
|
6
6
|
function patchSignature(signature) {
|
|
7
|
-
const isGnosisSafe = signature === '0x'
|
|
7
|
+
const isGnosisSafe = signature === '0x'
|
|
8
8
|
if (isGnosisSafe) {
|
|
9
|
-
return signature
|
|
9
|
+
return signature
|
|
10
10
|
}
|
|
11
11
|
// with 0x (64 len)
|
|
12
12
|
if (signature.length === 130) {
|
|
13
|
-
return signature
|
|
13
|
+
return signature
|
|
14
14
|
}
|
|
15
15
|
if (signature.length > 132) {
|
|
16
|
-
return signature
|
|
16
|
+
return signature
|
|
17
17
|
}
|
|
18
|
-
const sig = signature.substr(0, 130)
|
|
19
|
-
const lastByte = signature.substr(130, 2)
|
|
18
|
+
const sig = signature.substr(0, 130)
|
|
19
|
+
const lastByte = signature.substr(130, 2)
|
|
20
20
|
if (lastByte.toLowerCase() === '1b' || lastByte === '00') {
|
|
21
|
-
return sig
|
|
21
|
+
return sig
|
|
22
22
|
}
|
|
23
23
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
24
|
// @ts-ignore
|
|
25
|
-
const bnSig = new bn_js_1.default(sig.substring(2 + 64), 'hex').setn(
|
|
26
|
-
|
|
25
|
+
const bnSig = new bn_js_1.default(sig.substring(2 + 64), 'hex').setn(
|
|
26
|
+
255,
|
|
27
|
+
true
|
|
28
|
+
)
|
|
29
|
+
return sig.substring(0, 2 + 64) + bnSig.toString('hex')
|
|
27
30
|
}
|
|
28
|
-
exports.patchSignature = patchSignature
|
|
29
|
-
//# sourceMappingURL=signature-patcher.js.map
|
|
31
|
+
exports.patchSignature = patchSignature
|
|
32
|
+
//# sourceMappingURL=signature-patcher.js.map
|
package/settlement/types.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {LimitOrderV3Struct} from '../limit-order'
|
|
2
2
|
export declare type SettlementConfig = {
|
|
3
|
-
resolverContract: string
|
|
4
|
-
settlementContract: string
|
|
5
|
-
}
|
|
3
|
+
resolverContract: string
|
|
4
|
+
settlementContract: string
|
|
5
|
+
}
|
|
6
6
|
export declare type FillOrderParams = {
|
|
7
|
-
order: LimitOrderV3Struct
|
|
8
|
-
signature: string
|
|
9
|
-
makingAmount: string
|
|
10
|
-
takingAmount: string
|
|
11
|
-
thresholdAmount: string
|
|
12
|
-
target: string
|
|
13
|
-
}
|
|
7
|
+
order: LimitOrderV3Struct
|
|
8
|
+
signature: string
|
|
9
|
+
makingAmount: string
|
|
10
|
+
takingAmount: string
|
|
11
|
+
thresholdAmount: string
|
|
12
|
+
target: string
|
|
13
|
+
}
|
|
14
14
|
export declare type FillOrderParamsExtended = FillOrderParams & {
|
|
15
|
-
interaction: string
|
|
16
|
-
}
|
|
15
|
+
interaction: string
|
|
16
|
+
}
|
package/settlement/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/utils.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import BN from 'bn.js'
|
|
2
|
-
export declare const isNativeCurrency: (address: string) => boolean
|
|
3
|
-
export declare function toSec(time: number | string | Date): number
|
|
4
|
-
export declare function toBN(val: number | string): BN
|
|
5
|
-
export declare function trim0x(data: string): string
|
|
6
|
-
export declare function add0x(data: string): string
|
|
1
|
+
import BN from 'bn.js'
|
|
2
|
+
export declare const isNativeCurrency: (address: string) => boolean
|
|
3
|
+
export declare function toSec(time: number | string | Date): number
|
|
4
|
+
export declare function toBN(val: number | string): BN
|
|
5
|
+
export declare function trim0x(data: string): string
|
|
6
|
+
export declare function add0x(data: string): string
|
package/utils.js
CHANGED
|
@@ -1,41 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.add0x =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.add0x =
|
|
4
|
+
exports.trim0x =
|
|
5
|
+
exports.toBN =
|
|
6
|
+
exports.toSec =
|
|
7
|
+
exports.isNativeCurrency =
|
|
8
|
+
void 0
|
|
9
|
+
const tslib_1 = require('tslib')
|
|
10
|
+
const bn_js_1 = tslib_1.__importDefault(require('bn.js'))
|
|
11
|
+
const constants_1 = require('./constants')
|
|
12
|
+
const isNativeCurrency = (address) =>
|
|
13
|
+
address.toLowerCase() === constants_1.NATIVE_CURRENCY
|
|
14
|
+
exports.isNativeCurrency = isNativeCurrency
|
|
9
15
|
function toSec(time) {
|
|
10
|
-
const t = time instanceof Date ? time.getTime() : time
|
|
11
|
-
return Math.floor(+t / 1000)
|
|
16
|
+
const t = time instanceof Date ? time.getTime() : time
|
|
17
|
+
return Math.floor(+t / 1000)
|
|
12
18
|
}
|
|
13
|
-
exports.toSec = toSec
|
|
19
|
+
exports.toSec = toSec
|
|
14
20
|
function toBN(val) {
|
|
15
21
|
if (typeof val === 'number') {
|
|
16
22
|
if (!Number.isSafeInteger(val)) {
|
|
17
|
-
throw new Error('integer is not safe')
|
|
23
|
+
throw new Error('integer is not safe')
|
|
18
24
|
}
|
|
19
|
-
return new bn_js_1.default(val)
|
|
25
|
+
return new bn_js_1.default(val)
|
|
20
26
|
}
|
|
21
27
|
if (val.startsWith('0x')) {
|
|
22
|
-
return new bn_js_1.default(trim0x(val), 'hex')
|
|
28
|
+
return new bn_js_1.default(trim0x(val), 'hex')
|
|
23
29
|
}
|
|
24
|
-
return new bn_js_1.default(val)
|
|
30
|
+
return new bn_js_1.default(val)
|
|
25
31
|
}
|
|
26
|
-
exports.toBN = toBN
|
|
32
|
+
exports.toBN = toBN
|
|
27
33
|
function trim0x(data) {
|
|
28
34
|
if (data.startsWith('0x')) {
|
|
29
|
-
return data.substring(2)
|
|
35
|
+
return data.substring(2)
|
|
30
36
|
}
|
|
31
|
-
return data
|
|
37
|
+
return data
|
|
32
38
|
}
|
|
33
|
-
exports.trim0x = trim0x
|
|
39
|
+
exports.trim0x = trim0x
|
|
34
40
|
function add0x(data) {
|
|
35
41
|
if (data.includes('0x')) {
|
|
36
|
-
return data
|
|
42
|
+
return data
|
|
37
43
|
}
|
|
38
|
-
return '0x' + data
|
|
44
|
+
return '0x' + data
|
|
39
45
|
}
|
|
40
|
-
exports.add0x = add0x
|
|
41
|
-
//# sourceMappingURL=utils.js.map
|
|
46
|
+
exports.add0x = add0x
|
|
47
|
+
//# sourceMappingURL=utils.js.map
|
package/validations.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare function isValidAddress(address: string): boolean
|
|
2
|
-
export declare function isValidAmount(value: string): boolean
|
|
1
|
+
export declare function isValidAddress(address: string): boolean
|
|
2
|
+
export declare function isValidAmount(value: string): boolean
|
package/validations.js
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.isValidAmount = exports.isValidAddress = void 0
|
|
4
|
-
const tslib_1 = require(
|
|
5
|
-
const web3_1 = tslib_1.__importDefault(require(
|
|
6
|
-
const bignumber_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.isValidAmount = exports.isValidAddress = void 0
|
|
4
|
+
const tslib_1 = require('tslib')
|
|
5
|
+
const web3_1 = tslib_1.__importDefault(require('web3'))
|
|
6
|
+
const bignumber_1 = require('@ethersproject/bignumber')
|
|
7
7
|
function isValidAddress(address) {
|
|
8
|
-
return web3_1.default.utils.isAddress(address)
|
|
8
|
+
return web3_1.default.utils.isAddress(address)
|
|
9
9
|
}
|
|
10
|
-
exports.isValidAddress = isValidAddress
|
|
10
|
+
exports.isValidAddress = isValidAddress
|
|
11
11
|
function isValidAmount(value) {
|
|
12
12
|
try {
|
|
13
|
-
const amount = bignumber_1.BigNumber.from(value)
|
|
14
|
-
return amount.gt(0)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return false;
|
|
13
|
+
const amount = bignumber_1.BigNumber.from(value)
|
|
14
|
+
return amount.gt(0)
|
|
15
|
+
} catch (e) {
|
|
16
|
+
return false
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
|
-
exports.isValidAmount = isValidAmount
|
|
21
|
-
//# sourceMappingURL=validations.js.map
|
|
19
|
+
exports.isValidAmount = isValidAmount
|
|
20
|
+
//# sourceMappingURL=validations.js.map
|