@1inch/fusion-sdk 0.0.4 → 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 +2 -3
- 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
package/api/params.js
CHANGED
|
@@ -1,27 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.concatQueryParams = void 0
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.concatQueryParams = void 0
|
|
4
4
|
function concatQueryParams(params) {
|
|
5
5
|
if (!params) {
|
|
6
|
-
return ''
|
|
6
|
+
return ''
|
|
7
7
|
}
|
|
8
|
-
const keys = Object.keys(params)
|
|
8
|
+
const keys = Object.keys(params)
|
|
9
9
|
if (keys.length === 0) {
|
|
10
|
-
return ''
|
|
10
|
+
return ''
|
|
11
11
|
}
|
|
12
|
-
return (
|
|
12
|
+
return (
|
|
13
|
+
'?' +
|
|
13
14
|
keys
|
|
14
15
|
.reduce((a, k) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
if (!params[k]) {
|
|
17
|
+
return a
|
|
18
|
+
}
|
|
19
|
+
const value = params[k]
|
|
20
|
+
a.push(
|
|
21
|
+
k +
|
|
22
|
+
'=' +
|
|
23
|
+
encodeURIComponent(
|
|
24
|
+
Array.isArray(value) ? value.join(',') : value
|
|
25
|
+
)
|
|
26
|
+
)
|
|
27
|
+
return a
|
|
28
|
+
}, [])
|
|
29
|
+
.join('&')
|
|
30
|
+
)
|
|
25
31
|
}
|
|
26
|
-
exports.concatQueryParams = concatQueryParams
|
|
27
|
-
//# sourceMappingURL=params.js.map
|
|
32
|
+
exports.concatQueryParams = concatQueryParams
|
|
33
|
+
//# sourceMappingURL=params.js.map
|
package/api/quoter/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export * from './quote/index'
|
|
2
|
-
export * from './quoter.request'
|
|
3
|
-
export * from './quoter.api'
|
|
4
|
-
export * from './types'
|
|
5
|
-
export * from './preset'
|
|
1
|
+
export * from './quote/index'
|
|
2
|
+
export * from './quoter.request'
|
|
3
|
+
export * from './quoter.api'
|
|
4
|
+
export * from './types'
|
|
5
|
+
export * from './preset'
|
package/api/quoter/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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
|
-
tslib_1.__exportStar(require(
|
|
9
|
-
//# 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('./quote/index'), exports)
|
|
5
|
+
tslib_1.__exportStar(require('./quoter.request'), exports)
|
|
6
|
+
tslib_1.__exportStar(require('./quoter.api'), exports)
|
|
7
|
+
tslib_1.__exportStar(require('./types'), exports)
|
|
8
|
+
tslib_1.__exportStar(require('./preset'), exports)
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/api/quoter/preset.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {AuctionPoint, PresetData} from './types'
|
|
2
|
+
import {AuctionSalt} from '../../auction-salt'
|
|
3
3
|
export declare class Preset {
|
|
4
|
-
readonly auctionDuration: number
|
|
5
|
-
readonly startAuctionIn: number
|
|
6
|
-
readonly bankFee: string
|
|
7
|
-
readonly initialRateBump: number
|
|
8
|
-
readonly auctionStartAmount: string
|
|
9
|
-
readonly auctionEndAmount: string
|
|
10
|
-
readonly tokenFee: string
|
|
11
|
-
readonly points: AuctionPoint[]
|
|
12
|
-
constructor(preset: PresetData)
|
|
13
|
-
createAuctionSalt(additionalWaitPeriod?: number): AuctionSalt
|
|
14
|
-
calcAuctionStartTime(additionalWaitPeriod?: number): number
|
|
4
|
+
readonly auctionDuration: number
|
|
5
|
+
readonly startAuctionIn: number
|
|
6
|
+
readonly bankFee: string
|
|
7
|
+
readonly initialRateBump: number
|
|
8
|
+
readonly auctionStartAmount: string
|
|
9
|
+
readonly auctionEndAmount: string
|
|
10
|
+
readonly tokenFee: string
|
|
11
|
+
readonly points: AuctionPoint[]
|
|
12
|
+
constructor(preset: PresetData)
|
|
13
|
+
createAuctionSalt(additionalWaitPeriod?: number): AuctionSalt
|
|
14
|
+
calcAuctionStartTime(additionalWaitPeriod?: number): number
|
|
15
15
|
}
|
package/api/quoter/preset.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.Preset = void 0
|
|
4
|
-
const auction_salt_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.Preset = void 0
|
|
4
|
+
const auction_salt_1 = require('../../auction-salt')
|
|
5
5
|
class Preset {
|
|
6
6
|
constructor(preset) {
|
|
7
|
-
this.auctionDuration = preset.auctionDuration
|
|
8
|
-
this.startAuctionIn = preset.startAuctionIn
|
|
9
|
-
this.bankFee = preset.bankFee
|
|
10
|
-
this.initialRateBump = preset.initialRateBump
|
|
11
|
-
this.auctionStartAmount = preset.auctionStartAmount
|
|
12
|
-
this.auctionEndAmount = preset.auctionEndAmount
|
|
13
|
-
this.tokenFee = preset.tokenFee
|
|
14
|
-
this.points = preset.points
|
|
7
|
+
this.auctionDuration = preset.auctionDuration
|
|
8
|
+
this.startAuctionIn = preset.startAuctionIn
|
|
9
|
+
this.bankFee = preset.bankFee
|
|
10
|
+
this.initialRateBump = preset.initialRateBump
|
|
11
|
+
this.auctionStartAmount = preset.auctionStartAmount
|
|
12
|
+
this.auctionEndAmount = preset.auctionEndAmount
|
|
13
|
+
this.tokenFee = preset.tokenFee
|
|
14
|
+
this.points = preset.points
|
|
15
15
|
}
|
|
16
16
|
createAuctionSalt(additionalWaitPeriod = 0) {
|
|
17
17
|
return new auction_salt_1.AuctionSalt({
|
|
@@ -19,13 +19,15 @@ class Preset {
|
|
|
19
19
|
auctionStartTime: this.calcAuctionStartTime(additionalWaitPeriod),
|
|
20
20
|
initialRateBump: this.initialRateBump,
|
|
21
21
|
bankFee: this.bankFee
|
|
22
|
-
})
|
|
22
|
+
})
|
|
23
23
|
}
|
|
24
24
|
calcAuctionStartTime(additionalWaitPeriod = 0) {
|
|
25
|
-
return (
|
|
25
|
+
return (
|
|
26
|
+
Math.floor(Date.now() / 1000) +
|
|
26
27
|
additionalWaitPeriod +
|
|
27
|
-
this.startAuctionIn
|
|
28
|
+
this.startAuctionIn
|
|
29
|
+
)
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
exports.Preset = Preset
|
|
31
|
-
//# sourceMappingURL=preset.js.map
|
|
32
|
+
exports.Preset = Preset
|
|
33
|
+
//# sourceMappingURL=preset.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './order-params'
|
|
2
|
-
export * from './quote'
|
|
3
|
-
export * from './types'
|
|
1
|
+
export * from './order-params'
|
|
2
|
+
export * from './quote'
|
|
3
|
+
export * from './types'
|
|
@@ -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('./order-params'), exports)
|
|
5
|
+
tslib_1.__exportStar(require('./quote'), exports)
|
|
6
|
+
tslib_1.__exportStar(require('./types'), exports)
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {PresetEnum} from '../types'
|
|
2
|
+
import {FusionOrderParamsData} from './types'
|
|
3
3
|
export declare class FusionOrderParams {
|
|
4
|
-
readonly preset: PresetEnum
|
|
5
|
-
readonly receiver: string
|
|
6
|
-
constructor(params: FusionOrderParamsData)
|
|
7
|
-
static new(params?: FusionOrderParamsData): FusionOrderParams
|
|
4
|
+
readonly preset: PresetEnum
|
|
5
|
+
readonly receiver: string
|
|
6
|
+
constructor(params: FusionOrderParamsData)
|
|
7
|
+
static new(params?: FusionOrderParamsData): FusionOrderParams
|
|
8
8
|
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.FusionOrderParams = void 0
|
|
4
|
-
const types_1 = require(
|
|
5
|
-
const constants_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.FusionOrderParams = void 0
|
|
4
|
+
const types_1 = require('../types')
|
|
5
|
+
const constants_1 = require('../../../constants')
|
|
6
6
|
class FusionOrderParams {
|
|
7
7
|
constructor(params) {
|
|
8
|
-
this.preset = types_1.PresetEnum.fast
|
|
9
|
-
this.receiver = constants_1.ZERO_ADDRESS
|
|
8
|
+
this.preset = types_1.PresetEnum.fast
|
|
9
|
+
this.receiver = constants_1.ZERO_ADDRESS
|
|
10
10
|
if (params.preset) {
|
|
11
|
-
this.preset = params.preset
|
|
11
|
+
this.preset = params.preset
|
|
12
12
|
}
|
|
13
13
|
if (params.receiver) {
|
|
14
|
-
this.receiver = params.receiver
|
|
14
|
+
this.receiver = params.receiver
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
static new(params) {
|
|
18
|
-
return new FusionOrderParams(params || {})
|
|
18
|
+
return new FusionOrderParams(params || {})
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
exports.FusionOrderParams = FusionOrderParams
|
|
22
|
-
//# sourceMappingURL=order-params.js.map
|
|
21
|
+
exports.FusionOrderParams = FusionOrderParams
|
|
22
|
+
//# sourceMappingURL=order-params.js.map
|
|
@@ -1,23 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import {Cost, PresetEnum, QuoterResponse} from '../types'
|
|
2
|
+
import {Preset} from '../preset'
|
|
3
|
+
import {FusionOrder} from '../../../fusion-order'
|
|
4
|
+
import {NetworkEnum} from '../../../constants'
|
|
5
|
+
import {QuoterRequest} from '../quoter.request'
|
|
6
|
+
import {FusionOrderParamsData} from './types'
|
|
7
7
|
export declare class Quote {
|
|
8
|
-
private readonly network
|
|
9
|
-
private readonly params
|
|
10
|
-
readonly fromTokenAmount: string
|
|
11
|
-
readonly feeToken: string
|
|
12
|
-
readonly presets: Record<PresetEnum, Preset
|
|
13
|
-
readonly
|
|
14
|
-
readonly
|
|
15
|
-
readonly
|
|
16
|
-
readonly
|
|
17
|
-
readonly
|
|
18
|
-
readonly
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
8
|
+
private readonly network
|
|
9
|
+
private readonly params
|
|
10
|
+
readonly fromTokenAmount: string
|
|
11
|
+
readonly feeToken: string
|
|
12
|
+
readonly presets: Record<PresetEnum, Preset>
|
|
13
|
+
readonly recommendedPreset: PresetEnum
|
|
14
|
+
readonly toTokenAmount: string
|
|
15
|
+
readonly prices: Cost
|
|
16
|
+
readonly volume: Cost
|
|
17
|
+
readonly whitelist: string[]
|
|
18
|
+
readonly settlementAddress: string
|
|
19
|
+
readonly quoteId: string | null
|
|
20
|
+
constructor(
|
|
21
|
+
network: NetworkEnum,
|
|
22
|
+
params: QuoterRequest,
|
|
23
|
+
response: QuoterResponse
|
|
24
|
+
)
|
|
25
|
+
createFusionOrder(paramsData?: FusionOrderParamsData): FusionOrder
|
|
26
|
+
getPreset(type?: PresetEnum): Preset
|
|
27
|
+
private buildUnwrapPostInteractionIfNeeded
|
|
23
28
|
}
|
|
@@ -1,73 +1,106 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.Quote = void 0
|
|
4
|
-
const types_1 = require(
|
|
5
|
-
const preset_1 = require(
|
|
6
|
-
const auction_suffix_1 = require(
|
|
7
|
-
const fusion_order_1 = require(
|
|
8
|
-
const utils_1 = require(
|
|
9
|
-
const constants_1 = require(
|
|
10
|
-
const interactions_factory_1 = require(
|
|
11
|
-
const order_params_1 = require(
|
|
12
|
-
const predicate_factory_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.Quote = void 0
|
|
4
|
+
const types_1 = require('../types')
|
|
5
|
+
const preset_1 = require('../preset')
|
|
6
|
+
const auction_suffix_1 = require('../../../auction-suffix')
|
|
7
|
+
const fusion_order_1 = require('../../../fusion-order')
|
|
8
|
+
const utils_1 = require('../../../utils')
|
|
9
|
+
const constants_1 = require('../../../constants')
|
|
10
|
+
const interactions_factory_1 = require('../../../limit-order/interactions-factory')
|
|
11
|
+
const order_params_1 = require('./order-params')
|
|
12
|
+
const predicate_factory_1 = require('../../../limit-order/predicate-factory')
|
|
13
13
|
class Quote {
|
|
14
14
|
constructor(network, params, response) {
|
|
15
|
-
this.network = network
|
|
16
|
-
this.params = params
|
|
17
|
-
this.fromTokenAmount = response.fromTokenAmount
|
|
18
|
-
this.feeToken = response.feeToken
|
|
15
|
+
this.network = network
|
|
16
|
+
this.params = params
|
|
17
|
+
this.fromTokenAmount = response.fromTokenAmount
|
|
18
|
+
this.feeToken = response.feeToken
|
|
19
19
|
this.presets = {
|
|
20
|
-
[types_1.PresetEnum.fast]: new preset_1.Preset(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
20
|
+
[types_1.PresetEnum.fast]: new preset_1.Preset(
|
|
21
|
+
response.presets.fast
|
|
22
|
+
),
|
|
23
|
+
[types_1.PresetEnum.medium]: new preset_1.Preset(
|
|
24
|
+
response.presets.medium
|
|
25
|
+
),
|
|
26
|
+
[types_1.PresetEnum.slow]: new preset_1.Preset(
|
|
27
|
+
response.presets.slow
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
this.toTokenAmount = response.toTokenAmount
|
|
31
|
+
this.prices = response.prices
|
|
32
|
+
this.volume = response.volume
|
|
33
|
+
this.quoteId = response.quoteId
|
|
34
|
+
this.whitelist = response.whitelist
|
|
35
|
+
this.settlementAddress = response.settlementAddress
|
|
36
|
+
console.log(response.recommended_preset)
|
|
37
|
+
this.recommendedPreset = response.recommended_preset
|
|
30
38
|
}
|
|
31
39
|
createFusionOrder(paramsData) {
|
|
32
|
-
const params = order_params_1.FusionOrderParams.new(
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
const params = order_params_1.FusionOrderParams.new({
|
|
41
|
+
preset:
|
|
42
|
+
(paramsData === null || paramsData === void 0
|
|
43
|
+
? void 0
|
|
44
|
+
: paramsData.preset) || this.recommendedPreset,
|
|
45
|
+
receiver:
|
|
46
|
+
paramsData === null || paramsData === void 0
|
|
47
|
+
? void 0
|
|
48
|
+
: paramsData.receiver
|
|
49
|
+
})
|
|
50
|
+
const preset = this.getPreset(params.preset)
|
|
51
|
+
const salt = preset.createAuctionSalt()
|
|
35
52
|
const suffix = new auction_suffix_1.AuctionSuffix({
|
|
36
53
|
points: preset.points,
|
|
37
54
|
whitelist: this.whitelist.map((resolver) => ({
|
|
38
55
|
address: resolver,
|
|
39
56
|
allowance: 0
|
|
40
57
|
}))
|
|
41
|
-
})
|
|
42
|
-
const takerAsset = (0, utils_1.isNativeCurrency)(
|
|
58
|
+
})
|
|
59
|
+
const takerAsset = (0, utils_1.isNativeCurrency)(
|
|
60
|
+
this.params.toTokenAddress
|
|
61
|
+
)
|
|
43
62
|
? constants_1.WRAPPER_ADDRESS_MAP[this.network]
|
|
44
|
-
: this.params.toTokenAddress
|
|
45
|
-
const takerAssetReceiver = (0, utils_1.isNativeCurrency)(
|
|
63
|
+
: this.params.toTokenAddress
|
|
64
|
+
const takerAssetReceiver = (0, utils_1.isNativeCurrency)(
|
|
65
|
+
this.params.toTokenAddress
|
|
66
|
+
)
|
|
46
67
|
? constants_1.UNWRAPPER_CONTRACT_ADDRESS_MAP[this.network]
|
|
47
|
-
: params.receiver
|
|
48
|
-
return new fusion_order_1.FusionOrder(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
68
|
+
: params.receiver
|
|
69
|
+
return new fusion_order_1.FusionOrder(
|
|
70
|
+
{
|
|
71
|
+
makerAsset: this.params.fromTokenAddress,
|
|
72
|
+
takerAsset,
|
|
73
|
+
makingAmount: this.fromTokenAmount,
|
|
74
|
+
takingAmount: preset.auctionEndAmount,
|
|
75
|
+
maker: this.params.walletAddress,
|
|
76
|
+
receiver: takerAssetReceiver,
|
|
77
|
+
allowedSender: this.settlementAddress
|
|
78
|
+
},
|
|
79
|
+
salt,
|
|
80
|
+
suffix,
|
|
81
|
+
{
|
|
82
|
+
postInteraction: this.buildUnwrapPostInteractionIfNeeded(
|
|
83
|
+
params.receiver
|
|
84
|
+
),
|
|
85
|
+
// todo: add nonce validation and change hardcoded extended deadline
|
|
86
|
+
predicate: predicate_factory_1.PredicateFactory.timestampBelow(
|
|
87
|
+
salt.auctionStartTime + salt.duration + 32
|
|
88
|
+
)
|
|
89
|
+
}
|
|
90
|
+
)
|
|
61
91
|
}
|
|
62
92
|
getPreset(type = types_1.PresetEnum.fast) {
|
|
63
|
-
return this.presets[type]
|
|
93
|
+
return this.presets[type]
|
|
64
94
|
}
|
|
65
95
|
buildUnwrapPostInteractionIfNeeded(receiver) {
|
|
66
96
|
if (!(0, utils_1.isNativeCurrency)(this.params.toTokenAddress)) {
|
|
67
|
-
return undefined
|
|
97
|
+
return undefined
|
|
68
98
|
}
|
|
69
|
-
return interactions_factory_1.InteractionsFactory.unwrap(
|
|
99
|
+
return interactions_factory_1.InteractionsFactory.unwrap(
|
|
100
|
+
constants_1.WRAPPER_ADDRESS_MAP[this.network],
|
|
101
|
+
receiver || this.params.walletAddress
|
|
102
|
+
)
|
|
70
103
|
}
|
|
71
104
|
}
|
|
72
|
-
exports.Quote = Quote
|
|
73
|
-
//# sourceMappingURL=quote.js.map
|
|
105
|
+
exports.Quote = Quote
|
|
106
|
+
//# sourceMappingURL=quote.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../../src/api/quoter/quote/quote.ts"],"names":[],"mappings":";;;AAAA,oCAAyD;AACzD,sCAAgC;AAChC,4DAAqD;AACrD,wDAAiD;AACjD,0CAA+C;AAC/C,kDAI2B;AAC3B,oFAA6E;AAE7E,iDAAgD;AAEhD,8EAAuE;AAEvE,MAAa,KAAK;
|
|
1
|
+
{"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../../src/api/quoter/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AAQ,EAAE,kBAAkB;YAC5B,aAAa,EAAE,IAAI,CAAC,iBAAiB;SACxC,EACD,IAAI,EACJ,MAAM,EACN;YACI,eAAe,EAAE,IAAI,CAAC,kCAAkC,CACpD,MAAM,CAAC,QAAQ,CAClB;YACD,oEAAoE;YACpE,SAAS,EAAE,oCAAgB,CAAC,cAAc,CACtC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,QAAQ,GAAG,EAAE,CAC7C;SACJ,CACJ,CAAA;IACL,CAAC;IAED,SAAS,CAAC,IAAI,GAAG,kBAAU,CAAC,IAAI;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;IAC7B,CAAC;IAEO,kCAAkC,CACtC,QAA4B;QAE5B,IAAI,CAAC,IAAA,wBAAgB,EAAC,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE;YAC/C,OAAO,SAAS,CAAA;SACnB;QAED,OAAO,0CAAmB,CAAC,MAAM,CAC7B,+BAAmB,CAAC,IAAI,CAAC,OAAO,CAAC,EACjC,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,aAAa,CACxC,CAAA;IACL,CAAC;CACJ;AA7GD,sBA6GC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {PresetEnum} from '../types'
|
|
2
2
|
export declare type FusionOrderParamsData = {
|
|
3
|
-
preset?: PresetEnum
|
|
4
|
-
receiver?: string
|
|
5
|
-
}
|
|
3
|
+
preset?: PresetEnum
|
|
4
|
+
receiver?: string
|
|
5
|
+
}
|
|
@@ -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
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {AxiosProviderConnector, HttpProviderConnector} from '../../connector'
|
|
2
|
+
import {QuoterRequest} from './quoter.request'
|
|
3
|
+
import {QuoterApiConfig} from './types'
|
|
4
|
+
import {Quote} from './quote'
|
|
5
5
|
export declare class QuoterApi {
|
|
6
|
-
private readonly config
|
|
7
|
-
private readonly httpClient
|
|
8
|
-
constructor(config: QuoterApiConfig, httpClient: HttpProviderConnector)
|
|
9
|
-
static new(
|
|
10
|
-
|
|
6
|
+
private readonly config
|
|
7
|
+
private readonly httpClient
|
|
8
|
+
constructor(config: QuoterApiConfig, httpClient: HttpProviderConnector)
|
|
9
|
+
static new(
|
|
10
|
+
config: QuoterApiConfig,
|
|
11
|
+
httpClient?: AxiosProviderConnector
|
|
12
|
+
): QuoterApi
|
|
13
|
+
getQuote(params: QuoterRequest): Promise<Quote>
|
|
11
14
|
}
|
package/api/quoter/quoter.api.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
3
|
-
exports.QuoterApi = void 0
|
|
4
|
-
const tslib_1 = require(
|
|
5
|
-
const connector_1 = require(
|
|
6
|
-
const params_1 = require(
|
|
7
|
-
const quote_1 = require(
|
|
1
|
+
'use strict'
|
|
2
|
+
Object.defineProperty(exports, '__esModule', {value: true})
|
|
3
|
+
exports.QuoterApi = void 0
|
|
4
|
+
const tslib_1 = require('tslib')
|
|
5
|
+
const connector_1 = require('../../connector')
|
|
6
|
+
const params_1 = require('../params')
|
|
7
|
+
const quote_1 = require('./quote')
|
|
8
8
|
class QuoterApi {
|
|
9
9
|
constructor(config, httpClient) {
|
|
10
|
-
this.config = config
|
|
11
|
-
this.httpClient = httpClient
|
|
10
|
+
this.config = config
|
|
11
|
+
this.httpClient = httpClient
|
|
12
12
|
}
|
|
13
13
|
static new(config, httpClient = new connector_1.AxiosProviderConnector()) {
|
|
14
|
-
return new QuoterApi(config, httpClient)
|
|
14
|
+
return new QuoterApi(config, httpClient)
|
|
15
15
|
}
|
|
16
16
|
getQuote(params) {
|
|
17
17
|
return tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
const err = params.validate()
|
|
18
|
+
const err = params.validate()
|
|
19
19
|
if (err) {
|
|
20
|
-
throw new Error(err)
|
|
20
|
+
throw new Error(err)
|
|
21
21
|
}
|
|
22
|
-
const queryParams = (0, params_1.concatQueryParams)(params.build())
|
|
23
|
-
const url = `${this.config.url}/v1.0/${this.config.network}/quote/receive/${queryParams}
|
|
24
|
-
const res = yield this.httpClient.get(url)
|
|
25
|
-
return new quote_1.Quote(this.config.network, params, res)
|
|
26
|
-
})
|
|
22
|
+
const queryParams = (0, params_1.concatQueryParams)(params.build())
|
|
23
|
+
const url = `${this.config.url}/v1.0/${this.config.network}/quote/receive/${queryParams}`
|
|
24
|
+
const res = yield this.httpClient.get(url)
|
|
25
|
+
return new quote_1.Quote(this.config.network, params, res)
|
|
26
|
+
})
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
exports.QuoterApi = QuoterApi
|
|
30
|
-
//# sourceMappingURL=quoter.api.js.map
|
|
29
|
+
exports.QuoterApi = QuoterApi
|
|
30
|
+
//# sourceMappingURL=quoter.api.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {}
|