@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,18 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const tslib_1 = require(
|
|
4
|
-
const quoter_api_1 = require(
|
|
5
|
-
const quoter_request_1 = require(
|
|
6
|
-
const quote_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
const tslib_1 = require('tslib')
|
|
4
|
+
const quoter_api_1 = require('./quoter.api')
|
|
5
|
+
const quoter_request_1 = require('./quoter.request')
|
|
6
|
+
const quote_1 = require('./quote')
|
|
7
|
+
const types_1 = require('./types')
|
|
7
8
|
describe('Quoter API', () => {
|
|
8
9
|
const params = quoter_request_1.QuoterRequest.new({
|
|
9
10
|
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
10
11
|
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
11
12
|
amount: '1000000000000000000000',
|
|
12
13
|
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
13
|
-
})
|
|
14
|
-
const
|
|
14
|
+
})
|
|
15
|
+
const ResponseMock = {
|
|
15
16
|
fromTokenAmount: '1000000000000000000000',
|
|
17
|
+
recommended_preset: types_1.PresetEnum.medium,
|
|
16
18
|
feeToken: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
17
19
|
presets: {
|
|
18
20
|
fast: {
|
|
@@ -80,23 +82,30 @@ describe('Quoter API', () => {
|
|
|
80
82
|
'0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
|
|
81
83
|
'0xcfa62f77920d6383be12c91c71bd403599e1116f'
|
|
82
84
|
]
|
|
83
|
-
}
|
|
85
|
+
}
|
|
86
|
+
const QuoterResponseMock = new quote_1.Quote(1, params, ResponseMock)
|
|
84
87
|
const httpProvider = {
|
|
85
88
|
get: jest.fn().mockImplementationOnce(() => {
|
|
86
|
-
return Promise.resolve(
|
|
89
|
+
return Promise.resolve(ResponseMock)
|
|
87
90
|
}),
|
|
88
91
|
post: jest.fn().mockImplementation(() => {
|
|
89
|
-
return Promise.resolve(null)
|
|
92
|
+
return Promise.resolve(null)
|
|
90
93
|
})
|
|
91
|
-
}
|
|
92
|
-
it('should get quote with disabled estimate', () =>
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
94
|
+
}
|
|
95
|
+
it('should get quote with disabled estimate', () =>
|
|
96
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
97
|
+
const quoter = quoter_api_1.QuoterApi.new(
|
|
98
|
+
{
|
|
99
|
+
url: 'https://test.com/quoter',
|
|
100
|
+
network: 1
|
|
101
|
+
},
|
|
102
|
+
httpProvider
|
|
103
|
+
)
|
|
104
|
+
const res = yield quoter.getQuote(params)
|
|
105
|
+
expect(res).toStrictEqual(QuoterResponseMock)
|
|
106
|
+
expect(httpProvider.get).toHaveBeenCalledWith(
|
|
107
|
+
'https://test.com/quoter/v1.0/1/quote/receive/?fromTokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&toTokenAddress=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&amount=1000000000000000000000&walletAddress=0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
108
|
+
)
|
|
109
|
+
}))
|
|
110
|
+
})
|
|
111
|
+
//# sourceMappingURL=quoter.api.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quoter.api.spec.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter.api.spec.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;AACtC,qDAA8C;AAE9C,mCAA6B;
|
|
1
|
+
{"version":3,"file":"quoter.api.spec.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter.api.spec.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {QuoterRequestParams} from './types'
|
|
2
2
|
export declare class QuoterRequest {
|
|
3
|
-
readonly fromTokenAddress: string
|
|
4
|
-
readonly toTokenAddress: string
|
|
5
|
-
readonly amount: string
|
|
6
|
-
readonly walletAddress: string
|
|
7
|
-
readonly enableEstimate: boolean
|
|
8
|
-
readonly permit: string | undefined
|
|
9
|
-
constructor(params: QuoterRequestParams)
|
|
10
|
-
static new(params: QuoterRequestParams): QuoterRequest
|
|
11
|
-
validate(): string | null
|
|
12
|
-
build(): QuoterRequestParams
|
|
3
|
+
readonly fromTokenAddress: string
|
|
4
|
+
readonly toTokenAddress: string
|
|
5
|
+
readonly amount: string
|
|
6
|
+
readonly walletAddress: string
|
|
7
|
+
readonly enableEstimate: boolean
|
|
8
|
+
readonly permit: string | undefined
|
|
9
|
+
constructor(params: QuoterRequestParams)
|
|
10
|
+
static new(params: QuoterRequestParams): QuoterRequest
|
|
11
|
+
validate(): string | null
|
|
12
|
+
build(): QuoterRequestParams
|
|
13
13
|
}
|
|
@@ -1,45 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.QuoterRequest = void 0
|
|
4
|
-
const utils_1 = require(
|
|
5
|
-
const constants_1 = require(
|
|
6
|
-
const validations_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.QuoterRequest = void 0
|
|
4
|
+
const utils_1 = require('../../utils')
|
|
5
|
+
const constants_1 = require('../../constants')
|
|
6
|
+
const validations_1 = require('../../validations')
|
|
7
7
|
class QuoterRequest {
|
|
8
8
|
constructor(params) {
|
|
9
|
-
this.fromTokenAddress = params.fromTokenAddress.toLowerCase()
|
|
10
|
-
this.toTokenAddress = params.toTokenAddress.toLowerCase()
|
|
11
|
-
this.amount = params.amount
|
|
12
|
-
this.walletAddress = params.walletAddress.toLowerCase()
|
|
13
|
-
this.enableEstimate = params.enableEstimate || false
|
|
14
|
-
this.permit = params.permit
|
|
9
|
+
this.fromTokenAddress = params.fromTokenAddress.toLowerCase()
|
|
10
|
+
this.toTokenAddress = params.toTokenAddress.toLowerCase()
|
|
11
|
+
this.amount = params.amount
|
|
12
|
+
this.walletAddress = params.walletAddress.toLowerCase()
|
|
13
|
+
this.enableEstimate = params.enableEstimate || false
|
|
14
|
+
this.permit = params.permit
|
|
15
15
|
}
|
|
16
16
|
static new(params) {
|
|
17
|
-
return new QuoterRequest(params)
|
|
17
|
+
return new QuoterRequest(params)
|
|
18
18
|
}
|
|
19
19
|
validate() {
|
|
20
20
|
if ((0, utils_1.isNativeCurrency)(this.fromTokenAddress)) {
|
|
21
|
-
return `cannot swap ${constants_1.NATIVE_CURRENCY}: wrap native currency to it's wrapper fist
|
|
21
|
+
return `cannot swap ${constants_1.NATIVE_CURRENCY}: wrap native currency to it's wrapper fist`
|
|
22
22
|
}
|
|
23
|
-
if (
|
|
24
|
-
this.
|
|
25
|
-
|
|
23
|
+
if (
|
|
24
|
+
this.fromTokenAddress === constants_1.ZERO_ADDRESS ||
|
|
25
|
+
this.toTokenAddress === constants_1.ZERO_ADDRESS
|
|
26
|
+
) {
|
|
27
|
+
return `replace ${constants_1.ZERO_ADDRESS} with ${constants_1.NATIVE_CURRENCY}`
|
|
26
28
|
}
|
|
27
29
|
if (this.fromTokenAddress === this.toTokenAddress) {
|
|
28
|
-
return 'fromTokenAddress and toTokenAddress should be different'
|
|
30
|
+
return 'fromTokenAddress and toTokenAddress should be different'
|
|
29
31
|
}
|
|
30
32
|
if (!(0, validations_1.isValidAddress)(this.fromTokenAddress)) {
|
|
31
|
-
return `${this.fromTokenAddress} is invalid fromTokenAddress
|
|
33
|
+
return `${this.fromTokenAddress} is invalid fromTokenAddress`
|
|
32
34
|
}
|
|
33
35
|
if (!(0, validations_1.isValidAddress)(this.toTokenAddress)) {
|
|
34
|
-
return `${this.toTokenAddress} is invalid toTokenAddress
|
|
36
|
+
return `${this.toTokenAddress} is invalid toTokenAddress`
|
|
35
37
|
}
|
|
36
38
|
if (!(0, validations_1.isValidAddress)(this.walletAddress)) {
|
|
37
|
-
return `${this.walletAddress} is invalid walletAddress
|
|
39
|
+
return `${this.walletAddress} is invalid walletAddress`
|
|
38
40
|
}
|
|
39
41
|
if (!(0, validations_1.isValidAmount)(this.amount)) {
|
|
40
|
-
return `${this.amount} is invalid amount
|
|
42
|
+
return `${this.amount} is invalid amount`
|
|
41
43
|
}
|
|
42
|
-
return null
|
|
44
|
+
return null
|
|
43
45
|
}
|
|
44
46
|
build() {
|
|
45
47
|
return {
|
|
@@ -49,8 +51,8 @@ class QuoterRequest {
|
|
|
49
51
|
walletAddress: this.walletAddress,
|
|
50
52
|
enableEstimate: this.enableEstimate,
|
|
51
53
|
permit: this.permit
|
|
52
|
-
}
|
|
54
|
+
}
|
|
53
55
|
}
|
|
54
56
|
}
|
|
55
|
-
exports.QuoterRequest = QuoterRequest
|
|
56
|
-
//# sourceMappingURL=quoter.request.js.map
|
|
57
|
+
exports.QuoterRequest = QuoterRequest
|
|
58
|
+
//# sourceMappingURL=quoter.request.js.map
|
package/api/quoter/types.d.ts
CHANGED
|
@@ -1,54 +1,55 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {NetworkEnum} from '../../constants'
|
|
2
2
|
export declare type QuoterRequestParams = {
|
|
3
|
-
fromTokenAddress: string
|
|
4
|
-
toTokenAddress: string
|
|
5
|
-
amount: string
|
|
6
|
-
walletAddress: string
|
|
7
|
-
enableEstimate?: boolean
|
|
8
|
-
permit?: string
|
|
9
|
-
}
|
|
3
|
+
fromTokenAddress: string
|
|
4
|
+
toTokenAddress: string
|
|
5
|
+
amount: string
|
|
6
|
+
walletAddress: string
|
|
7
|
+
enableEstimate?: boolean
|
|
8
|
+
permit?: string
|
|
9
|
+
}
|
|
10
10
|
export declare type QuoterApiConfig = {
|
|
11
|
-
network: NetworkEnum
|
|
12
|
-
url: string
|
|
13
|
-
}
|
|
11
|
+
network: NetworkEnum
|
|
12
|
+
url: string
|
|
13
|
+
}
|
|
14
14
|
export declare type QuoterResponse = {
|
|
15
|
-
fromTokenAmount: string
|
|
16
|
-
feeToken: string
|
|
17
|
-
presets: QuoterPresets
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
fromTokenAmount: string
|
|
16
|
+
feeToken: string
|
|
17
|
+
presets: QuoterPresets
|
|
18
|
+
recommended_preset: PresetEnum
|
|
19
|
+
toTokenAmount: string
|
|
20
|
+
prices: Cost
|
|
21
|
+
volume: Cost
|
|
22
|
+
settlementAddress: string
|
|
23
|
+
whitelist: string[]
|
|
24
|
+
quoteId: string | null
|
|
25
|
+
}
|
|
25
26
|
export declare type QuoterPresets = {
|
|
26
|
-
fast: PresetData
|
|
27
|
-
medium: PresetData
|
|
28
|
-
slow: PresetData
|
|
29
|
-
}
|
|
27
|
+
fast: PresetData
|
|
28
|
+
medium: PresetData
|
|
29
|
+
slow: PresetData
|
|
30
|
+
}
|
|
30
31
|
export declare type PresetData = {
|
|
31
|
-
auctionDuration: number
|
|
32
|
-
startAuctionIn: number
|
|
33
|
-
bankFee: string
|
|
34
|
-
initialRateBump: number
|
|
35
|
-
auctionStartAmount: string
|
|
36
|
-
auctionEndAmount: string
|
|
37
|
-
tokenFee: string
|
|
38
|
-
points: AuctionPoint[]
|
|
39
|
-
}
|
|
32
|
+
auctionDuration: number
|
|
33
|
+
startAuctionIn: number
|
|
34
|
+
bankFee: string
|
|
35
|
+
initialRateBump: number
|
|
36
|
+
auctionStartAmount: string
|
|
37
|
+
auctionEndAmount: string
|
|
38
|
+
tokenFee: string
|
|
39
|
+
points: AuctionPoint[]
|
|
40
|
+
}
|
|
40
41
|
export declare type AuctionPoint = {
|
|
41
|
-
delay: number
|
|
42
|
-
coefficient: number
|
|
43
|
-
}
|
|
42
|
+
delay: number
|
|
43
|
+
coefficient: number
|
|
44
|
+
}
|
|
44
45
|
export declare type Cost = {
|
|
45
46
|
usd: {
|
|
46
|
-
fromToken: string
|
|
47
|
-
toToken: string
|
|
48
|
-
}
|
|
49
|
-
}
|
|
47
|
+
fromToken: string
|
|
48
|
+
toToken: string
|
|
49
|
+
}
|
|
50
|
+
}
|
|
50
51
|
export declare enum PresetEnum {
|
|
51
|
-
fast =
|
|
52
|
-
medium =
|
|
53
|
-
slow =
|
|
52
|
+
fast = 'fast',
|
|
53
|
+
medium = 'medium',
|
|
54
|
+
slow = 'slow'
|
|
54
55
|
}
|
package/api/quoter/types.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.PresetEnum = void 0
|
|
4
|
-
var PresetEnum
|
|
5
|
-
(function (PresetEnum) {
|
|
6
|
-
PresetEnum[
|
|
7
|
-
PresetEnum[
|
|
8
|
-
PresetEnum[
|
|
9
|
-
})(PresetEnum = exports.PresetEnum || (exports.PresetEnum = {}))
|
|
10
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.PresetEnum = void 0
|
|
4
|
+
var PresetEnum
|
|
5
|
+
;(function (PresetEnum) {
|
|
6
|
+
PresetEnum['fast'] = 'fast'
|
|
7
|
+
PresetEnum['medium'] = 'medium'
|
|
8
|
+
PresetEnum['slow'] = 'slow'
|
|
9
|
+
})((PresetEnum = exports.PresetEnum || (exports.PresetEnum = {})))
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
package/api/quoter/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/quoter/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/quoter/types.ts"],"names":[],"mappings":";;;AA0DA,IAAY,UAIX;AAJD,WAAY,UAAU;IAClB,2BAAa,CAAA;IACb,+BAAiB,CAAA;IACjB,2BAAa,CAAA;AACjB,CAAC,EAJW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAIrB"}
|
package/api/relayer/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './relayer.request'
|
|
2
|
-
export * from './relayer.api'
|
|
3
|
-
export * from './types'
|
|
1
|
+
export * from './relayer.request'
|
|
2
|
+
export * from './relayer.api'
|
|
3
|
+
export * from './types'
|
package/api/relayer/index.js
CHANGED
|
@@ -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('./relayer.request'), exports)
|
|
5
|
+
tslib_1.__exportStar(require('./relayer.api'), exports)
|
|
6
|
+
tslib_1.__exportStar(require('./types'), exports)
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {AxiosProviderConnector, HttpProviderConnector} from '../../connector'
|
|
2
|
+
import {RelayerRequest} from './relayer.request'
|
|
3
|
+
import {RelayerApiConfig} from './types'
|
|
4
4
|
export declare class RelayerApi {
|
|
5
|
-
private readonly config
|
|
6
|
-
private readonly httpClient
|
|
7
|
-
constructor(config: RelayerApiConfig, httpClient: HttpProviderConnector)
|
|
8
|
-
static new(
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
private readonly config
|
|
6
|
+
private readonly httpClient
|
|
7
|
+
constructor(config: RelayerApiConfig, httpClient: HttpProviderConnector)
|
|
8
|
+
static new(
|
|
9
|
+
config: RelayerApiConfig,
|
|
10
|
+
httpClient?: AxiosProviderConnector
|
|
11
|
+
): RelayerApi
|
|
12
|
+
submit(params: RelayerRequest): Promise<void>
|
|
13
|
+
submitBatch(params: RelayerRequest[]): Promise<void>
|
|
11
14
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.RelayerApi = void 0
|
|
4
|
-
const connector_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.RelayerApi = void 0
|
|
4
|
+
const connector_1 = require('../../connector')
|
|
5
5
|
class RelayerApi {
|
|
6
6
|
constructor(config, httpClient) {
|
|
7
|
-
this.config = config
|
|
8
|
-
this.httpClient = httpClient
|
|
7
|
+
this.config = config
|
|
8
|
+
this.httpClient = httpClient
|
|
9
9
|
}
|
|
10
10
|
static new(config, httpClient = new connector_1.AxiosProviderConnector()) {
|
|
11
|
-
return new RelayerApi(config, httpClient)
|
|
11
|
+
return new RelayerApi(config, httpClient)
|
|
12
12
|
}
|
|
13
13
|
submit(params) {
|
|
14
|
-
const url = `${this.config.url}/v1.0/${this.config.network}/order/submit
|
|
15
|
-
return this.httpClient.post(url, params)
|
|
14
|
+
const url = `${this.config.url}/v1.0/${this.config.network}/order/submit`
|
|
15
|
+
return this.httpClient.post(url, params)
|
|
16
16
|
}
|
|
17
17
|
submitBatch(params) {
|
|
18
|
-
const url = `${this.config.url}/v1.0/${this.config.network}/order/submit/many
|
|
19
|
-
return this.httpClient.post(url, params)
|
|
18
|
+
const url = `${this.config.url}/v1.0/${this.config.network}/order/submit/many`
|
|
19
|
+
return this.httpClient.post(url, params)
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
exports.RelayerApi = RelayerApi
|
|
23
|
-
//# sourceMappingURL=relayer.api.js.map
|
|
22
|
+
exports.RelayerApi = RelayerApi
|
|
23
|
+
//# sourceMappingURL=relayer.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|
|
@@ -1,85 +1,102 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
const tslib_1 = require(
|
|
4
|
-
const relayer_api_1 = require(
|
|
5
|
-
const relayer_request_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
const tslib_1 = require('tslib')
|
|
4
|
+
const relayer_api_1 = require('./relayer.api')
|
|
5
|
+
const relayer_request_1 = require('./relayer.request')
|
|
6
6
|
describe('Relayer API', () => {
|
|
7
7
|
const httpProvider = {
|
|
8
8
|
get: jest.fn().mockImplementationOnce(() => {
|
|
9
|
-
return Promise.resolve()
|
|
9
|
+
return Promise.resolve()
|
|
10
10
|
}),
|
|
11
11
|
post: jest.fn().mockImplementation(() => {
|
|
12
|
-
return Promise.resolve()
|
|
12
|
+
return Promise.resolve()
|
|
13
13
|
})
|
|
14
|
-
}
|
|
15
|
-
it('should submit one order', () =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
14
|
+
}
|
|
15
|
+
it('should submit one order', () =>
|
|
16
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
17
|
+
const quoter = relayer_api_1.RelayerApi.new(
|
|
18
|
+
{
|
|
19
|
+
url: 'https://test.com/relayer',
|
|
20
|
+
network: 1
|
|
21
|
+
},
|
|
22
|
+
httpProvider
|
|
23
|
+
)
|
|
24
|
+
const orderData = {
|
|
25
|
+
order: {
|
|
26
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
27
|
+
interactions:
|
|
28
|
+
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
|
|
29
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
30
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
31
|
+
makingAmount: '1000000000000000000',
|
|
32
|
+
offsets: '0',
|
|
33
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
34
|
+
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
|
|
35
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
36
|
+
takingAmount: '1420000000'
|
|
37
|
+
},
|
|
38
|
+
signature: '0x123signature-here789',
|
|
39
|
+
quoteId: '9a43c86d-f3d7-45b9-8cb6-803d2bdfa08b'
|
|
40
|
+
}
|
|
41
|
+
const params = relayer_request_1.RelayerRequest.new(orderData)
|
|
42
|
+
yield quoter.submit(params)
|
|
43
|
+
expect(httpProvider.post).toHaveBeenCalledWith(
|
|
44
|
+
'https://test.com/relayer/v1.0/1/order/submit',
|
|
45
|
+
orderData
|
|
46
|
+
)
|
|
47
|
+
}))
|
|
48
|
+
it('should submit two orders order', () =>
|
|
49
|
+
tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
const quoter = relayer_api_1.RelayerApi.new(
|
|
51
|
+
{
|
|
52
|
+
url: 'https://test.com/relayer',
|
|
53
|
+
network: 1
|
|
54
|
+
},
|
|
55
|
+
httpProvider
|
|
56
|
+
)
|
|
57
|
+
const orderData1 = {
|
|
58
|
+
order: {
|
|
59
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
60
|
+
interactions:
|
|
61
|
+
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
|
|
62
|
+
maker: '0x00000000219ab540356cbb839cbe05303d7705fa',
|
|
63
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
64
|
+
makingAmount: '1000000000000000000',
|
|
65
|
+
offsets: '0',
|
|
66
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
67
|
+
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
|
|
68
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
69
|
+
takingAmount: '1420000000'
|
|
70
|
+
},
|
|
71
|
+
signature: '0x123signature-here789',
|
|
72
|
+
quoteId: '9a43c86d-f3d7-45b9-8cb6-803d2bdfa08b'
|
|
73
|
+
}
|
|
74
|
+
const orderData2 = {
|
|
75
|
+
order: {
|
|
76
|
+
allowedSender: '0x0000000000000000000000000000000000000000',
|
|
77
|
+
interactions:
|
|
78
|
+
'0x000c004e200000000000000000219ab540356cbb839cbe05303d7705faf486570009',
|
|
79
|
+
maker: '0x12345678219ab540356cbb839cbe05303d771111',
|
|
80
|
+
makerAsset: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
81
|
+
makingAmount: '1000000000000000000',
|
|
82
|
+
offsets: '0',
|
|
83
|
+
receiver: '0x0000000000000000000000000000000000000000',
|
|
84
|
+
salt: '45118768841948961586167738353692277076075522015101619148498725069326976558864',
|
|
85
|
+
takerAsset: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
86
|
+
takingAmount: '1420000000'
|
|
87
|
+
},
|
|
88
|
+
signature: '0x123signature-2-here789',
|
|
89
|
+
quoteId: '1a36c861-ffd7-45b9-1cb6-403d3bdfa084'
|
|
90
|
+
}
|
|
91
|
+
const params = [
|
|
92
|
+
relayer_request_1.RelayerRequest.new(orderData1),
|
|
93
|
+
relayer_request_1.RelayerRequest.new(orderData2)
|
|
94
|
+
]
|
|
95
|
+
yield quoter.submitBatch(params)
|
|
96
|
+
expect(httpProvider.post).toHaveBeenCalledWith(
|
|
97
|
+
'https://test.com/relayer/v1.0/1/order/submit/many',
|
|
98
|
+
params
|
|
99
|
+
)
|
|
100
|
+
}))
|
|
101
|
+
})
|
|
102
|
+
//# sourceMappingURL=relayer.api.spec.js.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {RelayerRequestParams} from './types'
|
|
2
|
+
import {LimitOrderV3Struct} from '../../limit-order'
|
|
3
3
|
export declare class RelayerRequest {
|
|
4
|
-
readonly order: LimitOrderV3Struct
|
|
5
|
-
readonly signature: string
|
|
6
|
-
readonly quoteId: string
|
|
7
|
-
constructor(params: RelayerRequestParams)
|
|
8
|
-
static new(params: RelayerRequestParams): RelayerRequest
|
|
9
|
-
build(): RelayerRequestParams
|
|
4
|
+
readonly order: LimitOrderV3Struct
|
|
5
|
+
readonly signature: string
|
|
6
|
+
readonly quoteId: string
|
|
7
|
+
constructor(params: RelayerRequestParams)
|
|
8
|
+
static new(params: RelayerRequestParams): RelayerRequest
|
|
9
|
+
build(): RelayerRequestParams
|
|
10
10
|
}
|