aftermath-ts-sdk 1.1.72 → 1.1.74-dca.0
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/dist/general/prices/router/routerPricesApi.js +4 -4
- package/dist/general/providers/aftermath.d.ts +8 -0
- package/dist/general/providers/aftermath.d.ts.map +1 -1
- package/dist/general/providers/aftermath.js +8 -0
- package/dist/general/providers/aftermathApi.d.ts +4 -0
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +4 -0
- package/dist/general/types/configTypes.d.ts +23 -0
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/utils/casting.d.ts +5 -1
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +19 -0
- package/dist/general/utils/helpers.d.ts +2 -1
- package/dist/general/utils/helpers.d.ts.map +1 -1
- package/dist/general/utils/helpers.js +11 -0
- package/dist/packages/dca/api/dcaApi.d.ts +52 -0
- package/dist/packages/dca/api/dcaApi.d.ts.map +1 -0
- package/dist/packages/dca/api/dcaApi.js +221 -0
- package/dist/packages/dca/api/dcaApiCasting.d.ts +11 -0
- package/dist/packages/dca/api/dcaApiCasting.d.ts.map +1 -0
- package/dist/packages/dca/api/dcaApiCasting.js +164 -0
- package/dist/packages/dca/api/dcaApiCastingTypes.d.ts +119 -0
- package/dist/packages/dca/api/dcaApiCastingTypes.d.ts.map +1 -0
- package/dist/packages/dca/api/dcaApiCastingTypes.js +2 -0
- package/dist/packages/dca/dca.d.ts +66 -0
- package/dist/packages/dca/dca.d.ts.map +1 -0
- package/dist/packages/dca/dca.js +122 -0
- package/dist/packages/dca/dcaTypes.d.ts +129 -0
- package/dist/packages/dca/dcaTypes.d.ts.map +1 -0
- package/dist/packages/dca/dcaTypes.js +2 -0
- package/dist/packages/dca/index.d.ts +2 -0
- package/dist/packages/dca/index.d.ts.map +1 -0
- package/dist/packages/dca/index.js +17 -0
- package/dist/packages/farms/api/farmsApiCasting.d.ts.map +1 -1
- package/dist/packages/farms/api/farmsApiCasting.js +4 -4
- package/dist/packages/farms/farms.d.ts.map +1 -1
- package/dist/packages/farms/farms.js +12 -2
- package/dist/packages/multisig/api/multisigApi.d.ts +10 -0
- package/dist/packages/multisig/api/multisigApi.d.ts.map +1 -0
- package/dist/packages/multisig/api/multisigApi.js +49 -0
- package/dist/packages/multisig/index.d.ts +2 -0
- package/dist/packages/multisig/index.d.ts.map +1 -0
- package/dist/packages/multisig/index.js +17 -0
- package/dist/packages/multisig/multisig.d.ts +18 -0
- package/dist/packages/multisig/multisig.d.ts.map +1 -0
- package/dist/packages/multisig/multisig.js +48 -0
- package/dist/packages/multisig/multisigTypes.d.ts +9 -0
- package/dist/packages/multisig/multisigTypes.d.ts.map +1 -0
- package/dist/packages/multisig/multisigTypes.js +2 -0
- package/dist/packages/nftAmm/api/nftAmmApi.js +4 -4
- package/dist/packages/pools/api/poolsApi.d.ts +200 -128
- package/dist/packages/pools/api/poolsApi.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApi.js +540 -307
- package/dist/packages/pools/api/poolsApiCasting.d.ts +9 -6
- package/dist/packages/pools/api/poolsApiCasting.d.ts.map +1 -1
- package/dist/packages/pools/api/poolsApiCasting.js +51 -31
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts +23 -1
- package/dist/packages/pools/api/poolsApiCastingTypes.d.ts.map +1 -1
- package/dist/packages/pools/pool.d.ts +43 -29
- package/dist/packages/pools/pool.d.ts.map +1 -1
- package/dist/packages/pools/pool.js +109 -49
- package/dist/packages/pools/pools.d.ts +5 -2
- package/dist/packages/pools/pools.d.ts.map +1 -1
- package/dist/packages/pools/pools.js +9 -2
- package/dist/packages/pools/poolsTypes.d.ts +34 -3
- package/dist/packages/pools/poolsTypes.d.ts.map +1 -1
- package/dist/packages/pools/utils/cmmmCalculations.d.ts.map +1 -1
- package/dist/packages/pools/utils/cmmmCalculations.js +9 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DcaCancelledOrderEvent, DcaCreatedOrderEvent, DcaExecutedTradeEvent, DcaOrderObject, DcaOrderTradeObject } from "../dcaTypes";
|
|
2
|
+
import { DcaClosedOrderEventOnChain, DcaCreatedOrderEventOnChain, DcaExecutedTradeEventOnChain, DcaIndexerOrderResponse, DcaIndexerOrderTradeResponse } from "./dcaApiCastingTypes";
|
|
3
|
+
import { Balance } from "../../../types";
|
|
4
|
+
export declare class DcaApiCasting {
|
|
5
|
+
static createdDcaOrderEventFromOnChain: (eventOnChain: DcaCreatedOrderEventOnChain) => DcaCreatedOrderEvent;
|
|
6
|
+
static cancelledDcaOrderEventFromChain: (eventOnChain: DcaClosedOrderEventOnChain) => DcaCancelledOrderEvent;
|
|
7
|
+
static executedTradeEventFromChain: (eventOnChain: DcaExecutedTradeEventOnChain) => DcaExecutedTradeEvent;
|
|
8
|
+
static createdOrderEventOnIndexer: (response: DcaIndexerOrderResponse) => DcaOrderObject;
|
|
9
|
+
static createdOrderTradeEventOnIndexer: (response: DcaIndexerOrderTradeResponse, inputCounType: string, outputCoinType: string, totalSpent: Balance) => DcaOrderTradeObject;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=dcaApiCasting.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcaApiCasting.d.ts","sourceRoot":"","sources":["../../../../src/packages/dca/api/dcaApiCasting.ts"],"names":[],"mappings":"AACA,OAAO,EACN,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,EACd,mBAAmB,EAEnB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,0BAA0B,EAC1B,2BAA2B,EAC3B,4BAA4B,EAC5B,uBAAuB,EACvB,4BAA4B,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC,qBAAa,aAAa;IAMzB,OAAc,+BAA+B,iDAE1C,oBAAoB,CAwBrB;IAEF,OAAc,+BAA+B,gDAE1C,sBAAsB,CAsBvB;IAEF,OAAc,2BAA2B,kDAEtC,qBAAqB,CAiBtB;IAMF,OAAc,0BAA0B,aAC7B,uBAAuB,KAC/B,cAAc,CAuFf;IAEF,OAAc,+BAA+B,aAClC,4BAA4B,iBACvB,MAAM,kBACL,MAAM,cACV,OAAO,KACjB,mBAAmB,CAepB;CACF"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var _a;
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.DcaApiCasting = void 0;
|
|
5
|
+
const utils_1 = require("../../../general/utils");
|
|
6
|
+
class DcaApiCasting {
|
|
7
|
+
}
|
|
8
|
+
exports.DcaApiCasting = DcaApiCasting;
|
|
9
|
+
_a = DcaApiCasting;
|
|
10
|
+
// =========================================================================
|
|
11
|
+
// Chain Event objects
|
|
12
|
+
// =========================================================================
|
|
13
|
+
DcaApiCasting.createdDcaOrderEventFromOnChain = (eventOnChain) => {
|
|
14
|
+
const fields = eventOnChain.parsedJson;
|
|
15
|
+
return {
|
|
16
|
+
orderId: fields.order_id,
|
|
17
|
+
owner: fields.user,
|
|
18
|
+
inputValue: BigInt(fields.input_amount),
|
|
19
|
+
inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
|
|
20
|
+
outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
|
|
21
|
+
gasValue: BigInt(fields.gas_amount),
|
|
22
|
+
frequencyMs: Number(fields.frequency_ms),
|
|
23
|
+
startTimestampMs: Number(fields.start_timestamp_ms),
|
|
24
|
+
amountPerTrade: BigInt(fields.amount_per_trade),
|
|
25
|
+
maxAllowableSlippageBps: BigInt(fields.max_allowable_slippage_bps),
|
|
26
|
+
minAmountOut: BigInt(fields.min_amount_out),
|
|
27
|
+
maxAmountOut: BigInt(fields.max_amount_out),
|
|
28
|
+
remainingTrades: BigInt(fields.remaining_trades),
|
|
29
|
+
timestamp: eventOnChain.timestampMs,
|
|
30
|
+
txnDigest: eventOnChain.id.txDigest,
|
|
31
|
+
type: eventOnChain.type,
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
DcaApiCasting.cancelledDcaOrderEventFromChain = (eventOnChain) => {
|
|
35
|
+
const fields = eventOnChain.parsedJson;
|
|
36
|
+
return {
|
|
37
|
+
orderId: fields.order_id,
|
|
38
|
+
owner: fields.user,
|
|
39
|
+
remainingValue: BigInt(fields.remaining_value),
|
|
40
|
+
inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + fields.input_type),
|
|
41
|
+
outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + fields.output_type),
|
|
42
|
+
gasValue: BigInt(fields.gas_value),
|
|
43
|
+
frequencyMs: Number(fields.frequency_ms),
|
|
44
|
+
lastTradeTimestampMs: Number(fields.last_trade_timestamp_ms),
|
|
45
|
+
amountPerTrade: BigInt(fields.amount_per_trade),
|
|
46
|
+
maxAllowableSlippageBps: BigInt(fields.max_allowable_slippage_bps),
|
|
47
|
+
minAmountOut: BigInt(fields.min_amount_out),
|
|
48
|
+
maxAmountOut: BigInt(fields.max_amount_out),
|
|
49
|
+
remainingTrades: BigInt(fields.remaining_trades),
|
|
50
|
+
timestamp: eventOnChain.timestampMs,
|
|
51
|
+
txnDigest: eventOnChain.id.txDigest,
|
|
52
|
+
type: eventOnChain.type,
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
DcaApiCasting.executedTradeEventFromChain = (eventOnChain) => {
|
|
56
|
+
const fields = eventOnChain.parsedJson;
|
|
57
|
+
return {
|
|
58
|
+
orderId: fields.order_id,
|
|
59
|
+
user: fields.user,
|
|
60
|
+
inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
|
|
61
|
+
inputAmount: BigInt(fields.input_amount),
|
|
62
|
+
outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
|
|
63
|
+
outputAmount: BigInt(fields.output_amount),
|
|
64
|
+
timestamp: eventOnChain.timestampMs,
|
|
65
|
+
txnDigest: eventOnChain.id.txDigest,
|
|
66
|
+
type: eventOnChain.type,
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
// =========================================================================
|
|
70
|
+
// Indexer
|
|
71
|
+
// =========================================================================
|
|
72
|
+
DcaApiCasting.createdOrderEventOnIndexer = (response) => {
|
|
73
|
+
const totalOrdersAmount = Number(response.orders_num);
|
|
74
|
+
const ordersLeft = Number(response.orders_left);
|
|
75
|
+
const progress = totalOrdersAmount > 0
|
|
76
|
+
? (totalOrdersAmount - ordersLeft) / totalOrdersAmount
|
|
77
|
+
: 1;
|
|
78
|
+
const inputCoinType = String(response.coin_sell);
|
|
79
|
+
const outputCoinType = String(response.coin_buy);
|
|
80
|
+
const strategy = Number(response.min_amount_out) === 0 &&
|
|
81
|
+
BigInt(response.max_amount_out) === utils_1.Casting.u64MaxBigInt
|
|
82
|
+
? undefined
|
|
83
|
+
: {
|
|
84
|
+
priceMin: BigInt(response.min_amount_out),
|
|
85
|
+
priceMax: BigInt(response.max_amount_out),
|
|
86
|
+
};
|
|
87
|
+
const { totalSpent, totalBought } = response.trades.reduce((total, order) => {
|
|
88
|
+
total.totalSpent += BigInt(order.input_amount);
|
|
89
|
+
total.totalBought += BigInt(order.output_amount);
|
|
90
|
+
return total;
|
|
91
|
+
}, {
|
|
92
|
+
totalSpent: BigInt(0),
|
|
93
|
+
totalBought: BigInt(0)
|
|
94
|
+
});
|
|
95
|
+
const tradesPrepared = response.trades.map((trade) => {
|
|
96
|
+
const tradePrepared = _a.createdOrderTradeEventOnIndexer(trade, inputCoinType, outputCoinType, totalSpent);
|
|
97
|
+
return tradePrepared;
|
|
98
|
+
});
|
|
99
|
+
const started = tradesPrepared.length > 0 ? {
|
|
100
|
+
timestamp: tradesPrepared[0].tnxDate,
|
|
101
|
+
digest: tradesPrepared[0].tnxDigest,
|
|
102
|
+
} : undefined;
|
|
103
|
+
const lastTrade = tradesPrepared.length > 0 ? {
|
|
104
|
+
timestamp: tradesPrepared[tradesPrepared.length - 1].tnxDate,
|
|
105
|
+
digest: tradesPrepared[tradesPrepared.length - 1].tnxDigest,
|
|
106
|
+
} : undefined;
|
|
107
|
+
return {
|
|
108
|
+
objectId: response.order_object_id,
|
|
109
|
+
overview: {
|
|
110
|
+
allocatedCoin: {
|
|
111
|
+
coin: inputCoinType,
|
|
112
|
+
amount: BigInt(response.coin_sell_amount),
|
|
113
|
+
},
|
|
114
|
+
buyCoin: {
|
|
115
|
+
coin: outputCoinType,
|
|
116
|
+
amount: totalBought,
|
|
117
|
+
},
|
|
118
|
+
averagePrice: tradesPrepared.length > 0
|
|
119
|
+
? totalBought / BigInt(tradesPrepared.length)
|
|
120
|
+
: BigInt(0),
|
|
121
|
+
totalSpent: totalSpent,
|
|
122
|
+
interval: BigInt(response.frequency_ms),
|
|
123
|
+
totalTrades: totalOrdersAmount,
|
|
124
|
+
tradesRemaining: ordersLeft,
|
|
125
|
+
maxSlippage: BigInt(response.slippage),
|
|
126
|
+
strategy: strategy,
|
|
127
|
+
progress: progress,
|
|
128
|
+
recipient: response.recipient,
|
|
129
|
+
created: {
|
|
130
|
+
time: response.created.timestamp,
|
|
131
|
+
tnxDigest: response.created.tx_digest,
|
|
132
|
+
},
|
|
133
|
+
started: started
|
|
134
|
+
? {
|
|
135
|
+
time: started.timestamp,
|
|
136
|
+
tnxDigest: started.digest,
|
|
137
|
+
}
|
|
138
|
+
: undefined,
|
|
139
|
+
lastExecutedTradeTime: lastTrade
|
|
140
|
+
? {
|
|
141
|
+
time: lastTrade.timestamp,
|
|
142
|
+
tnxDigest: lastTrade.digest,
|
|
143
|
+
}
|
|
144
|
+
: undefined,
|
|
145
|
+
},
|
|
146
|
+
trades: tradesPrepared,
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
DcaApiCasting.createdOrderTradeEventOnIndexer = (response, inputCounType, outputCoinType, totalSpent) => {
|
|
150
|
+
const rate = totalSpent > 0 ? Number(BigInt(response.input_amount) / totalSpent) : 0;
|
|
151
|
+
return {
|
|
152
|
+
allocatedCoin: {
|
|
153
|
+
coin: inputCounType,
|
|
154
|
+
amount: BigInt(response.input_amount),
|
|
155
|
+
},
|
|
156
|
+
buyCoin: {
|
|
157
|
+
coin: outputCoinType,
|
|
158
|
+
amount: BigInt(response.output_amount),
|
|
159
|
+
},
|
|
160
|
+
tnxDigest: response.event.tx_digest,
|
|
161
|
+
tnxDate: response.event.timestamp,
|
|
162
|
+
rate: rate
|
|
163
|
+
};
|
|
164
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { EventOnChain } from "../../../general/types/castingTypes";
|
|
2
|
+
import { BigIntAsString, CoinType, ObjectId, SerializedTransaction, ServiceCoinData, SuiAddress, Timestamp, TransactionDigest } from "../../../types";
|
|
3
|
+
export interface DcaOrderFieldsOnChain {
|
|
4
|
+
id: ObjectId;
|
|
5
|
+
user: ObjectId;
|
|
6
|
+
recipient: ObjectId;
|
|
7
|
+
balance: BigIntAsString;
|
|
8
|
+
frequency_ms: BigIntAsString;
|
|
9
|
+
last_trade_timestamp_ms: BigIntAsString;
|
|
10
|
+
amount_per_trade: BigIntAsString;
|
|
11
|
+
max_allowable_slippage_bps: BigIntAsString;
|
|
12
|
+
min_amount_out: BigIntAsString;
|
|
13
|
+
max_amount_out: BigIntAsString;
|
|
14
|
+
remaining_trades: BigIntAsString;
|
|
15
|
+
gas: BigIntAsString;
|
|
16
|
+
}
|
|
17
|
+
export type DcaCreatedOrderEventOnChain = EventOnChain<{
|
|
18
|
+
order_id: ObjectId;
|
|
19
|
+
user: ObjectId;
|
|
20
|
+
recipient: ObjectId;
|
|
21
|
+
user_pk: Uint8Array;
|
|
22
|
+
input_amount: BigIntAsString;
|
|
23
|
+
input_type: Uint8Array;
|
|
24
|
+
output_type: Uint8Array;
|
|
25
|
+
gas_amount: BigIntAsString;
|
|
26
|
+
frequency_ms: BigIntAsString;
|
|
27
|
+
start_timestamp_ms: BigIntAsString;
|
|
28
|
+
amount_per_trade: BigIntAsString;
|
|
29
|
+
max_allowable_slippage_bps: BigIntAsString;
|
|
30
|
+
min_amount_out: BigIntAsString;
|
|
31
|
+
max_amount_out: BigIntAsString;
|
|
32
|
+
remaining_trades: BigIntAsString;
|
|
33
|
+
}>;
|
|
34
|
+
export type DcaClosedOrderEventOnChain = EventOnChain<{
|
|
35
|
+
order_id: ObjectId;
|
|
36
|
+
user: ObjectId;
|
|
37
|
+
recipient: ObjectId;
|
|
38
|
+
remaining_value: BigIntAsString;
|
|
39
|
+
input_type: Uint8Array;
|
|
40
|
+
output_type: Uint8Array;
|
|
41
|
+
gas_value: BigIntAsString;
|
|
42
|
+
frequency_ms: BigIntAsString;
|
|
43
|
+
last_trade_timestamp_ms: BigIntAsString;
|
|
44
|
+
amount_per_trade: BigIntAsString;
|
|
45
|
+
max_allowable_slippage_bps: BigIntAsString;
|
|
46
|
+
min_amount_out: BigIntAsString;
|
|
47
|
+
max_amount_out: BigIntAsString;
|
|
48
|
+
remaining_trades: BigIntAsString;
|
|
49
|
+
}>;
|
|
50
|
+
export type DcaExecutedTradeEventOnChain = EventOnChain<{
|
|
51
|
+
order_id: ObjectId;
|
|
52
|
+
user: ObjectId;
|
|
53
|
+
recipient: ObjectId;
|
|
54
|
+
input_type: Uint8Array;
|
|
55
|
+
input_amount: BigIntAsString;
|
|
56
|
+
output_type: Uint8Array;
|
|
57
|
+
output_amount: BigIntAsString;
|
|
58
|
+
}>;
|
|
59
|
+
export type DcaIndexerOrdersRequest = {
|
|
60
|
+
sender: SuiAddress;
|
|
61
|
+
};
|
|
62
|
+
export type DcaIndexerOrdersResponse = {
|
|
63
|
+
orders: DcaIndexerOrderResponse[];
|
|
64
|
+
};
|
|
65
|
+
export type DcaIndexerOrderResponse = {
|
|
66
|
+
order_object_id: ObjectId;
|
|
67
|
+
coin_sell: String;
|
|
68
|
+
coin_sell_amount: BigIntAsString;
|
|
69
|
+
coin_buy: String;
|
|
70
|
+
orders_num: BigIntAsString;
|
|
71
|
+
orders_left: BigIntAsString;
|
|
72
|
+
frequency_ms: BigIntAsString;
|
|
73
|
+
slippage: BigIntAsString;
|
|
74
|
+
total_spent: BigIntAsString;
|
|
75
|
+
recipient: SuiAddress;
|
|
76
|
+
created: {
|
|
77
|
+
timestamp: Timestamp;
|
|
78
|
+
tx_digest: TransactionDigest;
|
|
79
|
+
};
|
|
80
|
+
average_price: BigIntAsString;
|
|
81
|
+
min_amount_out: BigIntAsString;
|
|
82
|
+
max_amount_out: BigIntAsString;
|
|
83
|
+
trades: DcaIndexerOrderTradeResponse[];
|
|
84
|
+
};
|
|
85
|
+
export type DcaIndexerOrderTradeResponse = {
|
|
86
|
+
input_amount: BigIntAsString;
|
|
87
|
+
output_amount: BigIntAsString;
|
|
88
|
+
event: {
|
|
89
|
+
timestamp: Timestamp;
|
|
90
|
+
tx_digest: TransactionDigest;
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
export type DcaIndexerOrderCreateRequest = {
|
|
94
|
+
tx_kind: string;
|
|
95
|
+
order: {
|
|
96
|
+
input_coin: ServiceCoinData;
|
|
97
|
+
input_coin_type: CoinType;
|
|
98
|
+
output_coin_type: CoinType;
|
|
99
|
+
gas_coin: ServiceCoinData;
|
|
100
|
+
owner: SuiAddress;
|
|
101
|
+
user_pk: string;
|
|
102
|
+
recipient: SuiAddress;
|
|
103
|
+
frequency_ms: string;
|
|
104
|
+
delay_timestamp_ms: string;
|
|
105
|
+
amount_per_trade: string;
|
|
106
|
+
max_allowable_slippage_bps: number;
|
|
107
|
+
min_amount_out: string;
|
|
108
|
+
max_amount_out: string;
|
|
109
|
+
number_of_trades: number;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
export type DcaIndexerOrderCreateResponse = {
|
|
113
|
+
tx_data: SerializedTransaction;
|
|
114
|
+
};
|
|
115
|
+
export type DcaIndexerOrderCancelRequest = {
|
|
116
|
+
order_object_id: ObjectId;
|
|
117
|
+
};
|
|
118
|
+
export type DcaIndexerOrderCancelResponse = {};
|
|
119
|
+
//# sourceMappingURL=dcaApiCastingTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcaApiCastingTypes.d.ts","sourceRoot":"","sources":["../../../../src/packages/dca/api/dcaApiCastingTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACnE,OAAO,EACH,cAAc,EACd,QAAQ,EAAC,QAAQ,EACjB,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,SAAS,EACT,iBAAiB,EACpB,MAAM,gBAAgB,CAAC;AAOxB,MAAM,WAAW,qBAAqB;IAClC,EAAE,EAAE,QAAQ,CAAC;IACb,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,cAAc,CAAC;IACxB,YAAY,EAAE,cAAc,CAAC;IAC7B,uBAAuB,EAAE,cAAc,CAAC;IACxC,gBAAgB,EAAE,cAAc,CAAC;IACjC,0BAA0B,EAAE,cAAc,CAAC;IAC3C,cAAc,EAAE,cAAc,CAAC;IAC/B,cAAc,EAAE,cAAc,CAAC;IAC/B,gBAAgB,EAAE,cAAc,CAAC;IACjC,GAAG,EAAE,cAAc,CAAC;CACvB;AAMD,MAAM,MAAM,2BAA2B,GAAG,YAAY,CAAC;IACtD,QAAQ,EAAE,QAAQ,CAAC;IAChB,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,QAAQ,CAAC;IACpB,OAAO,EAAE,UAAU,CAAC;IACvB,YAAY,EAAE,cAAc,CAAC;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,WAAW,EAAE,UAAU,CAAC;IACxB,UAAU,EAAE,cAAc,CAAC;IAC3B,YAAY,EAAE,cAAc,CAAC;IAC1B,kBAAkB,EAAE,cAAc,CAAC;IACn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,GAAG;IACxC,OAAO,EAAE,qBAAqB,CAAC;CAClC,CAAA;AAMD,MAAM,MAAM,4BAA4B,GAAG;IACvC,eAAe,EAAE,QAAQ,CAAC;CAC7B,CAAA;AAED,MAAM,MAAM,6BAA6B,GAAG,EAAG,CAAA"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { SuiNetwork } from "../../types";
|
|
2
|
+
import { Caller } from "../../general/utils/caller";
|
|
3
|
+
import { AftermathApi } from "../../general/providers";
|
|
4
|
+
import { SuiAddress } from "../../types";
|
|
5
|
+
import { ApiDCAsOwnedBody, ApiDcaTransactionForCancelOrderBody, DcaOrdersObject, ApiDcaTransactionForCreateOrderBody } from "./dcaTypes";
|
|
6
|
+
import { DcaIndexerOrderCancelRequest, DcaIndexerOrderCancelResponse } from "./api/dcaApiCastingTypes";
|
|
7
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
8
|
+
export declare class Dca extends Caller {
|
|
9
|
+
readonly network?: SuiNetwork | undefined;
|
|
10
|
+
private readonly Provider?;
|
|
11
|
+
constructor(network?: SuiNetwork | undefined, Provider?: AftermathApi | undefined);
|
|
12
|
+
/**
|
|
13
|
+
* Fetches the API for dollar cost averaging orders list.
|
|
14
|
+
* @async
|
|
15
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
16
|
+
* @returns { Promise<DcaOrdersObject> } A promise that resolves to object with array of fetched events for active and past dca's.
|
|
17
|
+
*/
|
|
18
|
+
getAllDcaOrders(inputs: ApiDCAsOwnedBody): Promise<DcaOrdersObject>;
|
|
19
|
+
/**
|
|
20
|
+
* Fetches the API for dollar cost averaging active orders list.
|
|
21
|
+
* @async
|
|
22
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
23
|
+
* @returns {Promise<DcaOrdersObject>} A promise that resolves to object with array of fetched events for active dca's.
|
|
24
|
+
*/
|
|
25
|
+
getActiveDcaOrders(inputs: {
|
|
26
|
+
walletAddress: SuiAddress;
|
|
27
|
+
}): Promise<DcaOrdersObject>;
|
|
28
|
+
/**
|
|
29
|
+
* Fetches the API for dollar cost averaging past orders list.
|
|
30
|
+
* @async
|
|
31
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
32
|
+
* @returns {Promise<DcaOrdersObject>} A promise that resolves to object with array of fetched events for past dca's.
|
|
33
|
+
*/
|
|
34
|
+
getPastDcaOrders(inputs: {
|
|
35
|
+
walletAddress: SuiAddress;
|
|
36
|
+
}): Promise<DcaOrdersObject>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetches backend to stop / delay order execution on BE before executing canceling TX onchain.
|
|
39
|
+
* @async
|
|
40
|
+
* @param { ObjectId } inputs - An object containing the DCA object identificator.
|
|
41
|
+
* @returns {Promise<DcaIndexerOrderCancelResponse>} A promise that resolves to result of delaying
|
|
42
|
+
*/
|
|
43
|
+
createOrderExecutionPause(inputs: DcaIndexerOrderCancelRequest): Promise<DcaIndexerOrderCancelResponse>;
|
|
44
|
+
/**
|
|
45
|
+
* Fetches the API transaction for creating DCA order.
|
|
46
|
+
* @param inputs - The inputs for the transaction.
|
|
47
|
+
* @returns A promise that resolves with the API transaction.
|
|
48
|
+
*/
|
|
49
|
+
getCreateDcaOrderTx(inputs: ApiDcaTransactionForCreateOrderBody): Promise<Transaction>;
|
|
50
|
+
/**
|
|
51
|
+
* Fetches the API transaction for canceling DCA order.
|
|
52
|
+
* @param inputs - The inputs for the transaction.
|
|
53
|
+
* @returns A promise that resolves with the API transaction.
|
|
54
|
+
*/
|
|
55
|
+
getCancelDcaOrderTx(inputs: ApiDcaTransactionForCancelOrderBody): Promise<Transaction>;
|
|
56
|
+
/**
|
|
57
|
+
* Fetches address by SuiNS domain
|
|
58
|
+
* @async
|
|
59
|
+
* @param string domainName - An object containing the walletAddress.
|
|
60
|
+
* @returns {Promise<string | undefined | null>} A promise that resolves to a
|
|
61
|
+
* string object with wallet address if it exist
|
|
62
|
+
*/
|
|
63
|
+
getNameServiceAddress(domainName: string): Promise<string | undefined | null>;
|
|
64
|
+
private useProvider;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=dca.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dca.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/dca.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACN,gBAAgB,EAChB,mCAAmC,EACnC,eAAe,EACf,mCAAmC,EACnC,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,4BAA4B,EAAE,6BAA6B,EAAE,MAAM,0BAA0B,CAAC;AACvG,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qBAAa,GAAI,SAAQ,MAAM;aAOb,OAAO,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBADV,OAAO,CAAC,wBAAY,EACnB,QAAQ,CAAC,0BAAc;IASzC;;;;;OAKG;IAEU,eAAe,CAAC,MAAM,EAAE,gBAAgB;IAIrD;;;;;OAKG;IAEa,kBAAkB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAC;KAAE;IAIzE;;;;;OAKG;IAEa,gBAAgB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAC;KAAE;IAIvE;;;;;OAKG;IACU,yBAAyB,CAAC,MAAM,EAAE,4BAA4B;IAW3E;;;;OAIG;IAEa,mBAAmB,CAAC,MAAM,EAAE,mCAAmC,GAAG,OAAO,CAAC,WAAW,CAAC;IAOtG;;;;OAIG;IAEU,mBAAmB,CAAC,MAAM,EAAE,mCAAmC;IAW5E;;;;;;OAMG;IAEU,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAU1F,OAAO,CAAC,WAAW,CAIjB;CACF"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Dca = void 0;
|
|
13
|
+
const caller_1 = require("../../general/utils/caller");
|
|
14
|
+
class Dca extends caller_1.Caller {
|
|
15
|
+
// =========================================================================
|
|
16
|
+
// Constructor
|
|
17
|
+
// =========================================================================
|
|
18
|
+
constructor(network, Provider) {
|
|
19
|
+
super(network, "dca");
|
|
20
|
+
this.network = network;
|
|
21
|
+
this.Provider = Provider;
|
|
22
|
+
// =========================================================================
|
|
23
|
+
// Private Helpers
|
|
24
|
+
// =========================================================================
|
|
25
|
+
this.useProvider = () => {
|
|
26
|
+
var _a;
|
|
27
|
+
const provider = (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.Dca();
|
|
28
|
+
if (!provider)
|
|
29
|
+
throw new Error("missing AftermathApi Provider");
|
|
30
|
+
return provider;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
// =========================================================================
|
|
34
|
+
// Class Objects
|
|
35
|
+
// =========================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Fetches the API for dollar cost averaging orders list.
|
|
38
|
+
* @async
|
|
39
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
40
|
+
* @returns { Promise<DcaOrdersObject> } A promise that resolves to object with array of fetched events for active and past dca's.
|
|
41
|
+
*/
|
|
42
|
+
getAllDcaOrders(inputs) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
return this.fetchApi("", inputs);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Fetches the API for dollar cost averaging active orders list.
|
|
49
|
+
* @async
|
|
50
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
51
|
+
* @returns {Promise<DcaOrdersObject>} A promise that resolves to object with array of fetched events for active dca's.
|
|
52
|
+
*/
|
|
53
|
+
getActiveDcaOrders(inputs) {
|
|
54
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
+
return this.fetchApi("owned-active-orders", inputs);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Fetches the API for dollar cost averaging past orders list.
|
|
60
|
+
* @async
|
|
61
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
62
|
+
* @returns {Promise<DcaOrdersObject>} A promise that resolves to object with array of fetched events for past dca's.
|
|
63
|
+
*/
|
|
64
|
+
getPastDcaOrders(inputs) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
return this.fetchApi("owned-past-orders", inputs);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Fetches backend to stop / delay order execution on BE before executing canceling TX onchain.
|
|
71
|
+
* @async
|
|
72
|
+
* @param { ObjectId } inputs - An object containing the DCA object identificator.
|
|
73
|
+
* @returns {Promise<DcaIndexerOrderCancelResponse>} A promise that resolves to result of delaying
|
|
74
|
+
*/
|
|
75
|
+
createOrderExecutionPause(inputs) {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
return this.fetchApi("pause-order-execution", inputs);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
// =========================================================================
|
|
81
|
+
// Transactions
|
|
82
|
+
// =========================================================================
|
|
83
|
+
/**
|
|
84
|
+
* Fetches the API transaction for creating DCA order.
|
|
85
|
+
* @param inputs - The inputs for the transaction.
|
|
86
|
+
* @returns A promise that resolves with the API transaction.
|
|
87
|
+
*/
|
|
88
|
+
getCreateDcaOrderTx(inputs) {
|
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
+
return this.fetchApiTransaction("transactions/create-order", inputs);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Fetches the API transaction for canceling DCA order.
|
|
95
|
+
* @param inputs - The inputs for the transaction.
|
|
96
|
+
* @returns A promise that resolves with the API transaction.
|
|
97
|
+
*/
|
|
98
|
+
getCancelDcaOrderTx(inputs) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
return this.fetchApiTransaction("transactions/cancel-order", inputs);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
// =========================================================================
|
|
104
|
+
// Helpers
|
|
105
|
+
// =========================================================================
|
|
106
|
+
/**
|
|
107
|
+
* Fetches address by SuiNS domain
|
|
108
|
+
* @async
|
|
109
|
+
* @param string domainName - An object containing the walletAddress.
|
|
110
|
+
* @returns {Promise<string | undefined | null>} A promise that resolves to a
|
|
111
|
+
* string object with wallet address if it exist
|
|
112
|
+
*/
|
|
113
|
+
getNameServiceAddress(domainName) {
|
|
114
|
+
var _a;
|
|
115
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
116
|
+
return (_a = this.Provider) === null || _a === void 0 ? void 0 : _a.provider.resolveNameServiceAddress({
|
|
117
|
+
name: domainName
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
exports.Dca = Dca;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { ObjectId, SuiAddress } from "../../types";
|
|
2
|
+
import { CoinType } from "../coin/coinTypes";
|
|
3
|
+
import { Balance, Event, IFixed, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
|
|
4
|
+
export type DcaOrderTrades = DcaOrderTradeObject[];
|
|
5
|
+
export interface ApiDcaInitializeOrdertStrategyBody {
|
|
6
|
+
priceMin: Balance;
|
|
7
|
+
priceMax: Balance;
|
|
8
|
+
}
|
|
9
|
+
export interface ApiDcaTransactionForCreateOrderBody {
|
|
10
|
+
walletAddress: SuiAddress;
|
|
11
|
+
allocateCoinType: CoinType;
|
|
12
|
+
allocateCoinAmount: Balance;
|
|
13
|
+
buyCoinType: CoinType;
|
|
14
|
+
frequencyMs: Timestamp;
|
|
15
|
+
tradesAmount: number;
|
|
16
|
+
straregy?: ApiDcaInitializeOrdertStrategyBody;
|
|
17
|
+
isSponsoredTx?: boolean;
|
|
18
|
+
delayTimeMs: Timestamp;
|
|
19
|
+
maxAllowableSlippageBps: Balance;
|
|
20
|
+
coinPerTradeAmount: Balance;
|
|
21
|
+
publicKey: string;
|
|
22
|
+
customRecipient?: SuiAddress;
|
|
23
|
+
}
|
|
24
|
+
export interface ApiDcaTransactionForCancelOrderBody {
|
|
25
|
+
walletAddress: SuiAddress;
|
|
26
|
+
buyCoinType: CoinType;
|
|
27
|
+
allocateCoinType: CoinType;
|
|
28
|
+
orderId: SuiAddress;
|
|
29
|
+
userPublicKey: string;
|
|
30
|
+
}
|
|
31
|
+
export interface DcaOrderTradeObject {
|
|
32
|
+
allocatedCoin: {
|
|
33
|
+
coin: CoinType;
|
|
34
|
+
amount: Balance;
|
|
35
|
+
};
|
|
36
|
+
buyCoin: {
|
|
37
|
+
coin: CoinType;
|
|
38
|
+
amount: Balance;
|
|
39
|
+
};
|
|
40
|
+
tnxDigest: TransactionDigest;
|
|
41
|
+
tnxDate: Timestamp;
|
|
42
|
+
rate: number;
|
|
43
|
+
}
|
|
44
|
+
export interface DcaOrdertStrategyObject {
|
|
45
|
+
priceMin: Balance;
|
|
46
|
+
priceMax: Balance;
|
|
47
|
+
}
|
|
48
|
+
export interface DcaOrderOverviewObject {
|
|
49
|
+
allocatedCoin: {
|
|
50
|
+
coin: CoinType;
|
|
51
|
+
amount: Balance;
|
|
52
|
+
};
|
|
53
|
+
buyCoin: {
|
|
54
|
+
coin: CoinType;
|
|
55
|
+
amount: Balance;
|
|
56
|
+
};
|
|
57
|
+
averagePrice: Balance;
|
|
58
|
+
totalSpent: Balance;
|
|
59
|
+
interval: IFixed;
|
|
60
|
+
totalTrades: number;
|
|
61
|
+
tradesRemaining: number;
|
|
62
|
+
maxSlippage: Balance;
|
|
63
|
+
strategy?: DcaOrdertStrategyObject;
|
|
64
|
+
recipient?: SuiAddress;
|
|
65
|
+
progress: number;
|
|
66
|
+
created: {
|
|
67
|
+
time: Timestamp | undefined;
|
|
68
|
+
tnxDigest: TransactionDigest;
|
|
69
|
+
};
|
|
70
|
+
started?: {
|
|
71
|
+
time: Timestamp | undefined;
|
|
72
|
+
tnxDigest: TransactionDigest;
|
|
73
|
+
};
|
|
74
|
+
lastExecutedTradeTime?: {
|
|
75
|
+
time: Timestamp | undefined;
|
|
76
|
+
tnxDigest: TransactionDigest;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export interface DcaOrderObject {
|
|
80
|
+
objectId: ObjectId;
|
|
81
|
+
overview: DcaOrderOverviewObject;
|
|
82
|
+
trades: DcaOrderTrades;
|
|
83
|
+
}
|
|
84
|
+
export interface DcaOrdersObject {
|
|
85
|
+
active: DcaOrderObject[];
|
|
86
|
+
past: DcaOrderObject[];
|
|
87
|
+
}
|
|
88
|
+
export interface DcaCreatedOrderEvent extends Event {
|
|
89
|
+
orderId: ObjectId;
|
|
90
|
+
owner: ObjectId;
|
|
91
|
+
inputValue: Balance;
|
|
92
|
+
inputType: CoinType;
|
|
93
|
+
outputType: CoinType;
|
|
94
|
+
gasValue: Balance;
|
|
95
|
+
frequencyMs: Timestamp;
|
|
96
|
+
startTimestampMs: Timestamp;
|
|
97
|
+
amountPerTrade: Balance;
|
|
98
|
+
maxAllowableSlippageBps: Balance;
|
|
99
|
+
minAmountOut: Balance;
|
|
100
|
+
maxAmountOut: Balance;
|
|
101
|
+
remainingTrades: IFixed;
|
|
102
|
+
}
|
|
103
|
+
export interface DcaCancelledOrderEvent extends Event {
|
|
104
|
+
orderId: ObjectId;
|
|
105
|
+
owner: ObjectId;
|
|
106
|
+
remainingValue: Balance;
|
|
107
|
+
inputType: CoinType;
|
|
108
|
+
outputType: CoinType;
|
|
109
|
+
gasValue: Balance;
|
|
110
|
+
frequencyMs: Timestamp;
|
|
111
|
+
lastTradeTimestampMs: Timestamp;
|
|
112
|
+
amountPerTrade: Balance;
|
|
113
|
+
maxAllowableSlippageBps: Balance;
|
|
114
|
+
minAmountOut: Balance;
|
|
115
|
+
maxAmountOut: Balance;
|
|
116
|
+
remainingTrades: IFixed;
|
|
117
|
+
}
|
|
118
|
+
export interface DcaExecutedTradeEvent extends Event {
|
|
119
|
+
orderId: ObjectId;
|
|
120
|
+
user: ObjectId;
|
|
121
|
+
inputType: CoinType;
|
|
122
|
+
inputAmount: Balance;
|
|
123
|
+
outputType: CoinType;
|
|
124
|
+
outputAmount: Balance;
|
|
125
|
+
}
|
|
126
|
+
export interface ApiDCAsOwnedBody {
|
|
127
|
+
walletAddress: SuiAddress;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=dcaTypes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dcaTypes.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/dcaTypes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,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AAQ,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,SAAS,CAAC;IACpB,gBAAgB,EAAE,SAAS,CAAC;IAC5B,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,EAAE,OAAO,CAAC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAuB,SAAQ,KAAK;IACpD,OAAO,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,QAAQ,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,SAAS,CAAC;IACpB,oBAAoB,EAAE,SAAS,CAAC;IAChC,cAAc,EAAE,OAAO,CAAC;IACxB,uBAAuB,EAAE,OAAO,CAAC;IACjC,YAAY,EAAE,OAAO,CAAC;IACtB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAsB,SAAQ,KAAK;IACnD,OAAO,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;IACf,SAAS,EAAE,QAAQ,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,QAAQ,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;CACzB;AAMD,MAAM,WAAW,gBAAgB;IAChC,aAAa,EAAE,UAAU,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./dca"), exports);
|