@1inch/fusion-sdk 0.0.6 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/api/fusion-api.d.ts +16 -25
- package/api/fusion-api.js +26 -36
- package/api/index.d.ts +4 -4
- package/api/index.js +8 -8
- package/api/orders/index.d.ts +3 -3
- package/api/orders/index.js +7 -7
- package/api/orders/order-api.spec.d.ts +1 -1
- package/api/orders/order-api.spec.js +397 -479
- package/api/orders/orders.api.d.ts +10 -24
- package/api/orders/orders.api.js +28 -30
- package/api/orders/orders.request.d.ts +18 -22
- package/api/orders/orders.request.js +31 -40
- package/api/orders/types.d.ts +58 -59
- package/api/orders/types.js +16 -17
- package/api/pagination.d.ts +7 -7
- package/api/pagination.js +10 -10
- package/api/pagination.spec.d.ts +1 -1
- package/api/pagination.spec.js +21 -28
- package/api/params.d.ts +1 -3
- package/api/params.js +19 -25
- package/api/quoter/index.d.ts +5 -5
- package/api/quoter/index.js +9 -9
- package/api/quoter/preset.d.ts +13 -13
- package/api/quoter/preset.js +17 -19
- package/api/quoter/quote/index.d.ts +3 -3
- package/api/quoter/quote/index.js +7 -7
- package/api/quoter/quote/order-params.d.ts +7 -6
- package/api/quoter/quote/order-params.js +13 -12
- package/api/quoter/quote/order-params.js.map +1 -1
- package/api/quoter/quote/quote.d.ts +22 -26
- package/api/quoter/quote/quote.js +59 -84
- package/api/quoter/quote/quote.js.map +1 -1
- package/api/quoter/quote/types.d.ts +5 -4
- package/api/quoter/quote/types.js +3 -3
- package/api/quoter/quoter.api.d.ts +9 -12
- package/api/quoter/quoter.api.js +19 -19
- package/api/quoter/quoter.api.spec.d.ts +1 -1
- package/api/quoter/quoter.api.spec.js +24 -30
- package/api/quoter/quoter.api.spec.js.map +1 -1
- package/api/quoter/quoter.request.d.ts +11 -11
- package/api/quoter/quoter.request.js +26 -28
- package/api/quoter/types.d.ts +45 -45
- package/api/quoter/types.js +10 -10
- package/api/relayer/index.d.ts +3 -3
- package/api/relayer/index.js +7 -7
- package/api/relayer/relayer.api.d.ts +9 -12
- package/api/relayer/relayer.api.js +13 -13
- package/api/relayer/relayer.api.spec.d.ts +1 -1
- package/api/relayer/relayer.api.spec.js +79 -96
- package/api/relayer/relayer.request.d.ts +8 -8
- package/api/relayer/relayer.request.js +10 -10
- package/api/relayer/types.d.ts +9 -9
- package/api/relayer/types.js +3 -3
- package/api/types.d.ts +15 -17
- package/api/types.js +3 -3
- package/auction-calculator/auction-calculator.d.ts +13 -22
- package/auction-calculator/auction-calculator.js +45 -70
- package/auction-calculator/auction-calculator.spec.d.ts +1 -1
- package/auction-calculator/auction-calculator.spec.js +32 -45
- package/auction-calculator/calc.d.ts +2 -8
- package/auction-calculator/calc.js +12 -12
- package/auction-calculator/constants.d.ts +1 -1
- package/auction-calculator/constants.js +5 -5
- package/auction-calculator/index.d.ts +3 -3
- package/auction-calculator/index.js +7 -7
- package/auction-salt/auction-salt.d.ts +9 -9
- package/auction-salt/auction-salt.js +23 -34
- package/auction-salt/auction.salt.spec.d.ts +1 -1
- package/auction-salt/auction.salt.spec.js +27 -38
- package/auction-salt/index.d.ts +3 -3
- package/auction-salt/index.js +7 -7
- package/auction-salt/parser/constants.d.ts +9 -9
- package/auction-salt/parser/constants.js +14 -33
- package/auction-salt/parser/index.d.ts +2 -2
- package/auction-salt/parser/index.js +6 -6
- package/auction-salt/parser/parser.d.ts +6 -6
- package/auction-salt/parser/parser.js +22 -33
- package/auction-salt/types.d.ts +6 -6
- package/auction-salt/types.js +3 -3
- package/auction-suffix/auction-suffix.d.ts +9 -9
- package/auction-suffix/auction-suffix.js +23 -36
- package/auction-suffix/auction-suffix.spec.d.ts +1 -1
- package/auction-suffix/auction-suffix.spec.js +15 -20
- package/auction-suffix/constants.d.ts +1 -1
- package/auction-suffix/constants.js +5 -5
- package/auction-suffix/encoder.d.ts +6 -15
- package/auction-suffix/encoder.js +28 -45
- package/auction-suffix/index.d.ts +5 -5
- package/auction-suffix/index.js +9 -9
- package/auction-suffix/parser/constants.d.ts +13 -13
- package/auction-suffix/parser/constants.js +17 -30
- package/auction-suffix/parser/errors.d.ts +2 -1
- package/auction-suffix/parser/errors.js +7 -6
- package/auction-suffix/parser/index.d.ts +4 -4
- package/auction-suffix/parser/index.js +8 -8
- package/auction-suffix/parser/parser.d.ts +8 -28
- package/auction-suffix/parser/parser.js +81 -162
- package/auction-suffix/parser/types.d.ts +22 -22
- package/auction-suffix/parser/types.js +3 -3
- package/auction-suffix/types.d.ts +12 -12
- package/auction-suffix/types.js +3 -3
- package/connector/blockchain/blockchain-provider.connector.d.ts +3 -6
- package/connector/blockchain/blockchain-provider.connector.js +3 -3
- package/connector/blockchain/index.d.ts +3 -3
- package/connector/blockchain/index.js +7 -7
- package/connector/blockchain/private-key-provider.connector.d.ts +10 -15
- package/connector/blockchain/private-key-provider.connector.js +12 -12
- package/connector/blockchain/private-key-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/private-key-provider.connector.spec.js +23 -36
- package/connector/blockchain/web3-provider-connector.d.ts +8 -13
- package/connector/blockchain/web3-provider-connector.js +9 -12
- package/connector/blockchain/web3-provider.connector.spec.d.ts +1 -1
- package/connector/blockchain/web3-provider.connector.spec.js +26 -37
- package/connector/http/axios-provider.connector.d.ts +3 -3
- package/connector/http/axios-provider.connector.js +13 -13
- package/connector/http/axios-provider.connector.spec.d.ts +1 -1
- package/connector/http/axios-provider.connector.spec.js +31 -37
- package/connector/http/http-provider.connector.d.ts +2 -2
- package/connector/http/http-provider.connector.js +3 -3
- package/connector/http/index.d.ts +2 -2
- package/connector/http/index.js +6 -6
- package/connector/index.d.ts +2 -2
- package/connector/index.js +6 -6
- package/constants.d.ts +6 -10
- package/constants.js +16 -23
- package/fusion-order/fusion-order.d.ts +7 -17
- package/fusion-order/fusion-order.js +12 -14
- package/fusion-order/fusion-order.spec.d.ts +1 -1
- package/fusion-order/fusion-order.spec.js +22 -27
- package/fusion-order/index.d.ts +1 -1
- package/fusion-order/index.js +5 -5
- package/index.d.ts +11 -11
- package/index.js +15 -15
- package/limit-order/eip712/domain.d.ts +9 -10
- package/limit-order/eip712/domain.js +23 -28
- package/limit-order/eip712/eip712.types.d.ts +15 -19
- package/limit-order/eip712/eip712.types.js +3 -3
- package/limit-order/eip712/index.d.ts +3 -3
- package/limit-order/eip712/index.js +7 -7
- package/limit-order/eip712/order-typed-data-builder.d.ts +6 -17
- package/limit-order/eip712/order-typed-data-builder.js +19 -34
- package/limit-order/index.d.ts +4 -4
- package/limit-order/index.js +8 -8
- package/limit-order/interactions-factory.d.ts +1 -1
- package/limit-order/interactions-factory.js +6 -6
- package/limit-order/limit-order.d.ts +25 -31
- package/limit-order/limit-order.js +50 -103
- package/limit-order/limit-order.spec.d.ts +1 -1
- package/limit-order/limit-order.spec.js +51 -75
- package/limit-order/parser/constants.d.ts +9 -9
- package/limit-order/parser/constants.js +5 -5
- package/limit-order/parser/index.d.ts +3 -3
- package/limit-order/parser/index.js +7 -7
- package/limit-order/parser/parser.d.ts +2 -5
- package/limit-order/parser/parser.js +18 -23
- package/limit-order/parser/types.d.ts +3 -3
- package/limit-order/parser/types.js +3 -3
- package/limit-order/predicate-factory.d.ts +5 -9
- package/limit-order/predicate-factory.js +24 -40
- package/limit-order/predicate-factory.spec.d.ts +1 -1
- package/limit-order/predicate-factory.spec.js +29 -44
- package/limit-order/types.d.ts +29 -29
- package/limit-order/types.js +3 -3
- package/limit-order/utils.d.ts +1 -1
- package/limit-order/utils.js +6 -6
- package/package.json +1 -1
- package/sdk/index.d.ts +2 -2
- package/sdk/index.js +6 -6
- package/sdk/sdk.d.ts +11 -29
- package/sdk/sdk.js +40 -49
- package/sdk/sdk.js.map +1 -1
- package/sdk/types.d.ts +27 -27
- package/sdk/types.js +3 -3
- package/settlement/encoders/constants.d.ts +1 -1
- package/settlement/encoders/constants.js +5 -5
- package/settlement/encoders/fill-order.encoder.d.ts +2 -2
- package/settlement/encoders/fill-order.encoder.js +12 -26
- package/settlement/encoders/index.d.ts +3 -3
- package/settlement/encoders/index.js +7 -7
- package/settlement/encoders/settlement.encoder.d.ts +5 -13
- package/settlement/encoders/settlement.encoder.js +38 -42
- package/settlement/encoders/settlement.encoder.js.map +1 -1
- package/settlement/index.d.ts +4 -4
- package/settlement/index.js +8 -8
- package/settlement/settlement.d.ts +6 -8
- package/settlement/settlement.js +20 -28
- package/settlement/settlement.js.map +1 -1
- package/settlement/settlement.spec.d.ts +1 -1
- package/settlement/settlement.spec.js +41 -45
- package/settlement/settlement.spec.js.map +1 -1
- package/settlement/signature-patcher.d.ts +1 -1
- package/settlement/signature-patcher.js +16 -19
- package/settlement/types.d.ts +13 -13
- package/settlement/types.js +3 -3
- package/utils.d.ts +6 -6
- package/utils.js +23 -29
- package/validations.d.ts +2 -2
- package/validations.js +15 -14
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 {AuctionPoint, PresetData} from './types'
|
|
2
|
-
import {AuctionSalt} from '../../auction-salt'
|
|
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,15 +19,13 @@ 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 (
|
|
26
|
-
Math.floor(Date.now() / 1000) +
|
|
25
|
+
return (Math.floor(Date.now() / 1000) +
|
|
27
26
|
additionalWaitPeriod +
|
|
28
|
-
this.startAuctionIn
|
|
29
|
-
)
|
|
27
|
+
this.startAuctionIn);
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
|
-
exports.Preset = Preset
|
|
33
|
-
//# sourceMappingURL=preset.js.map
|
|
30
|
+
exports.Preset = Preset;
|
|
31
|
+
//# 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,9 @@
|
|
|
1
|
-
import {PresetEnum} from '../types'
|
|
2
|
-
import {FusionOrderParamsData} from './types'
|
|
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
|
-
|
|
7
|
-
|
|
4
|
+
readonly preset: PresetEnum;
|
|
5
|
+
readonly receiver: string;
|
|
6
|
+
readonly permit: string | undefined;
|
|
7
|
+
constructor(params: FusionOrderParamsData);
|
|
8
|
+
static new(params?: FusionOrderParamsData): FusionOrderParams;
|
|
8
9
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
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
|
+
this.permit = params.permit;
|
|
16
17
|
}
|
|
17
18
|
static new(params) {
|
|
18
|
-
return new FusionOrderParams(params || {})
|
|
19
|
+
return new FusionOrderParams(params || {});
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
|
-
exports.FusionOrderParams = FusionOrderParams
|
|
22
|
-
//# sourceMappingURL=order-params.js.map
|
|
22
|
+
exports.FusionOrderParams = FusionOrderParams;
|
|
23
|
+
//# sourceMappingURL=order-params.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-params.js","sourceRoot":"","sources":["../../../../src/api/quoter/quote/order-params.ts"],"names":[],"mappings":";;;AAAA,oCAAmC;AACnC,kDAA+C;AAG/C,MAAa,iBAAiB;
|
|
1
|
+
{"version":3,"file":"order-params.js","sourceRoot":"","sources":["../../../../src/api/quoter/quote/order-params.ts"],"names":[],"mappings":";;;AAAA,oCAAmC;AACnC,kDAA+C;AAG/C,MAAa,iBAAiB;IAO1B,YAAY,MAA6B;QANzB,WAAM,GAAe,kBAAU,CAAC,IAAI,CAAA;QAEpC,aAAQ,GAAW,wBAAY,CAAA;QAK3C,IAAI,MAAM,CAAC,MAAM,EAAE;YACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;SAC9B;QAED,IAAI,MAAM,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAA;SAClC;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAA;IAC/B,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,MAA8B;QACrC,OAAO,IAAI,iBAAiB,CAAC,MAAM,IAAI,EAAE,CAAC,CAAA;IAC9C,CAAC;CACJ;AAtBD,8CAsBC"}
|
|
@@ -1,28 +1,24 @@
|
|
|
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'
|
|
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 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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
)
|
|
25
|
-
createFusionOrder(paramsData?: FusionOrderParamsData): FusionOrder
|
|
26
|
-
getPreset(type?: PresetEnum): Preset
|
|
27
|
-
private buildUnwrapPostInteractionIfNeeded
|
|
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(network: NetworkEnum, params: QuoterRequest, response: QuoterResponse);
|
|
21
|
+
createFusionOrder(paramsData?: FusionOrderParamsData): FusionOrder;
|
|
22
|
+
getPreset(type?: PresetEnum): Preset;
|
|
23
|
+
private buildUnwrapPostInteractionIfNeeded;
|
|
28
24
|
}
|
|
@@ -1,106 +1,81 @@
|
|
|
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
|
-
|
|
30
|
-
this.
|
|
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
|
|
20
|
+
[types_1.PresetEnum.fast]: new preset_1.Preset(response.presets.fast),
|
|
21
|
+
[types_1.PresetEnum.medium]: new preset_1.Preset(response.presets.medium),
|
|
22
|
+
[types_1.PresetEnum.slow]: new preset_1.Preset(response.presets.slow)
|
|
23
|
+
};
|
|
24
|
+
this.toTokenAmount = response.toTokenAmount;
|
|
25
|
+
this.prices = response.prices;
|
|
26
|
+
this.volume = response.volume;
|
|
27
|
+
this.quoteId = response.quoteId;
|
|
28
|
+
this.whitelist = response.whitelist;
|
|
29
|
+
this.settlementAddress = response.settlementAddress;
|
|
30
|
+
this.recommendedPreset = response.recommended_preset;
|
|
38
31
|
}
|
|
39
32
|
createFusionOrder(paramsData) {
|
|
40
33
|
const params = order_params_1.FusionOrderParams.new({
|
|
41
|
-
preset:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
? void 0
|
|
48
|
-
: paramsData.receiver
|
|
49
|
-
})
|
|
50
|
-
const preset = this.getPreset(params.preset)
|
|
51
|
-
const salt = preset.createAuctionSalt()
|
|
34
|
+
preset: (paramsData === null || paramsData === void 0 ? void 0 : paramsData.preset) || this.recommendedPreset,
|
|
35
|
+
receiver: paramsData === null || paramsData === void 0 ? void 0 : paramsData.receiver,
|
|
36
|
+
permit: paramsData === null || paramsData === void 0 ? void 0 : paramsData.permit
|
|
37
|
+
});
|
|
38
|
+
const preset = this.getPreset(params.preset);
|
|
39
|
+
const salt = preset.createAuctionSalt();
|
|
52
40
|
const suffix = new auction_suffix_1.AuctionSuffix({
|
|
53
41
|
points: preset.points,
|
|
54
42
|
whitelist: this.whitelist.map((resolver) => ({
|
|
55
43
|
address: resolver,
|
|
56
44
|
allowance: 0
|
|
57
45
|
}))
|
|
58
|
-
})
|
|
59
|
-
const takerAsset = (0, utils_1.isNativeCurrency)(
|
|
60
|
-
this.params.toTokenAddress
|
|
61
|
-
)
|
|
46
|
+
});
|
|
47
|
+
const takerAsset = (0, utils_1.isNativeCurrency)(this.params.toTokenAddress)
|
|
62
48
|
? constants_1.WRAPPER_ADDRESS_MAP[this.network]
|
|
63
|
-
: this.params.toTokenAddress
|
|
64
|
-
const takerAssetReceiver = (0, utils_1.isNativeCurrency)(
|
|
65
|
-
this.params.toTokenAddress
|
|
66
|
-
)
|
|
49
|
+
: this.params.toTokenAddress;
|
|
50
|
+
const takerAssetReceiver = (0, utils_1.isNativeCurrency)(this.params.toTokenAddress)
|
|
67
51
|
? constants_1.UNWRAPPER_CONTRACT_ADDRESS_MAP[this.network]
|
|
68
|
-
: params.receiver
|
|
69
|
-
return new fusion_order_1.FusionOrder(
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
)
|
|
52
|
+
: params.receiver;
|
|
53
|
+
return new fusion_order_1.FusionOrder({
|
|
54
|
+
makerAsset: this.params.fromTokenAddress,
|
|
55
|
+
takerAsset,
|
|
56
|
+
makingAmount: this.fromTokenAmount,
|
|
57
|
+
takingAmount: preset.auctionEndAmount,
|
|
58
|
+
maker: this.params.walletAddress,
|
|
59
|
+
receiver: takerAssetReceiver,
|
|
60
|
+
allowedSender: this.settlementAddress
|
|
61
|
+
}, salt, suffix, {
|
|
62
|
+
postInteraction: this.buildUnwrapPostInteractionIfNeeded(params.receiver),
|
|
63
|
+
// todo: add nonce validation and change hardcoded extended deadline
|
|
64
|
+
predicate: predicate_factory_1.PredicateFactory.timestampBelow(salt.auctionStartTime + salt.duration + 32),
|
|
65
|
+
permit: params.permit
|
|
66
|
+
? this.params.fromTokenAddress + params.permit.substring(2)
|
|
67
|
+
: undefined
|
|
68
|
+
});
|
|
91
69
|
}
|
|
92
70
|
getPreset(type = types_1.PresetEnum.fast) {
|
|
93
|
-
return this.presets[type]
|
|
71
|
+
return this.presets[type];
|
|
94
72
|
}
|
|
95
73
|
buildUnwrapPostInteractionIfNeeded(receiver) {
|
|
96
74
|
if (!(0, utils_1.isNativeCurrency)(this.params.toTokenAddress)) {
|
|
97
|
-
return undefined
|
|
75
|
+
return undefined;
|
|
98
76
|
}
|
|
99
|
-
return interactions_factory_1.InteractionsFactory.unwrap(
|
|
100
|
-
constants_1.WRAPPER_ADDRESS_MAP[this.network],
|
|
101
|
-
receiver || this.params.walletAddress
|
|
102
|
-
)
|
|
77
|
+
return interactions_factory_1.InteractionsFactory.unwrap(constants_1.WRAPPER_ADDRESS_MAP[this.network], receiver || this.params.walletAddress);
|
|
103
78
|
}
|
|
104
79
|
}
|
|
105
|
-
exports.Quote = Quote
|
|
106
|
-
//# sourceMappingURL=quote.js.map
|
|
80
|
+
exports.Quote = Quote;
|
|
81
|
+
//# 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;IAqBd,YACqB,OAAoB,EACpB,MAAqB,EACtC,QAAwB;QAFP,YAAO,GAAP,OAAO,CAAa;QACpB,WAAM,GAAN,MAAM,CAAe;QAGtC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC,eAAe,CAAA;QAC/C,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAA;QACjC,IAAI,CAAC,OAAO,GAAG;YACX,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;YACpD,CAAC,kBAAU,CAAC,MAAM,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;YACxD,CAAC,kBAAU,CAAC,IAAI,CAAC,EAAE,IAAI,eAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC;SACvD,CAAA;QACD,IAAI,CAAC,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAA;QAC3C,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,OAAO,CAAA;QAC/B,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CA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U;YACV,YAAY,EAAE,IAAI,CAAC,eAAe;YAClC,YAAY,EAAE,MAAM,CAAC,gBAAgB;YACrC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,aAAa;YAChC,QAAQ,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;YACD,MAAM,EAAE,MAAM,CAAC,MAAM;gBACjB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;gBAC3D,CAAC,CAAC,SAAS;SAClB,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;AAhHD,sBAgHC"}
|
|
@@ -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,14 +1,11 @@
|
|
|
1
|
-
import {AxiosProviderConnector, HttpProviderConnector} from '../../connector'
|
|
2
|
-
import {QuoterRequest} from './quoter.request'
|
|
3
|
-
import {QuoterApiConfig} from './types'
|
|
4
|
-
import {Quote} from './quote'
|
|
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
|
-
|
|
11
|
-
httpClient?: AxiosProviderConnector
|
|
12
|
-
): QuoterApi
|
|
13
|
-
getQuote(params: QuoterRequest): Promise<Quote>
|
|
6
|
+
private readonly config;
|
|
7
|
+
private readonly httpClient;
|
|
8
|
+
constructor(config: QuoterApiConfig, httpClient: HttpProviderConnector);
|
|
9
|
+
static new(config: QuoterApiConfig, httpClient?: AxiosProviderConnector): QuoterApi;
|
|
10
|
+
getQuote(params: QuoterRequest): Promise<Quote>;
|
|
14
11
|
}
|
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 {};
|
|
@@ -1,17 +1,17 @@
|
|
|
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(
|
|
7
|
-
const types_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");
|
|
8
8
|
describe('Quoter API', () => {
|
|
9
9
|
const params = quoter_request_1.QuoterRequest.new({
|
|
10
10
|
fromTokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
11
11
|
toTokenAddress: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
|
|
12
12
|
amount: '1000000000000000000000',
|
|
13
13
|
walletAddress: '0x00000000219ab540356cbb839cbe05303d7705fa'
|
|
14
|
-
})
|
|
14
|
+
});
|
|
15
15
|
const ResponseMock = {
|
|
16
16
|
fromTokenAmount: '1000000000000000000000',
|
|
17
17
|
recommended_preset: types_1.PresetEnum.medium,
|
|
@@ -82,30 +82,24 @@ describe('Quoter API', () => {
|
|
|
82
82
|
'0x84d99aa569d93a9ca187d83734c8c4a519c4e9b1',
|
|
83
83
|
'0xcfa62f77920d6383be12c91c71bd403599e1116f'
|
|
84
84
|
]
|
|
85
|
-
}
|
|
86
|
-
const QuoterResponseMock = new quote_1.Quote(1, params, ResponseMock)
|
|
85
|
+
};
|
|
86
|
+
const QuoterResponseMock = new quote_1.Quote(1, params, ResponseMock);
|
|
87
87
|
const httpProvider = {
|
|
88
88
|
get: jest.fn().mockImplementationOnce(() => {
|
|
89
|
-
return Promise.resolve(ResponseMock)
|
|
89
|
+
return Promise.resolve(ResponseMock);
|
|
90
90
|
}),
|
|
91
91
|
post: jest.fn().mockImplementation(() => {
|
|
92
|
-
return Promise.resolve(null)
|
|
92
|
+
return Promise.resolve(null);
|
|
93
93
|
})
|
|
94
|
-
}
|
|
95
|
-
it('should get quote with disabled estimate', () =>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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
|
|
94
|
+
};
|
|
95
|
+
it('should get quote with disabled estimate', () => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const quoter = quoter_api_1.QuoterApi.new({
|
|
97
|
+
url: 'https://test.com/quoter',
|
|
98
|
+
network: 1
|
|
99
|
+
}, httpProvider);
|
|
100
|
+
const res = yield quoter.getQuote(params);
|
|
101
|
+
expect(res).toStrictEqual(QuoterResponseMock);
|
|
102
|
+
expect(httpProvider.get).toHaveBeenCalledWith('https://test.com/quoter/v1.0/1/quote/receive/?fromTokenAddress=0x6b175474e89094c44da98b954eedeac495271d0f&toTokenAddress=0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2&amount=1000000000000000000000&walletAddress=0x00000000219ab540356cbb839cbe05303d7705fa');
|
|
103
|
+
}));
|
|
104
|
+
});
|
|
105
|
+
//# 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;AAC7B,
|
|
1
|
+
{"version":3,"file":"quoter.api.spec.js","sourceRoot":"","sources":["../../../src/api/quoter/quoter.api.spec.ts"],"names":[],"mappings":";;;AAAA,6CAAsC;A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