aftermath-ts-sdk 1.1.76 → 1.1.78
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/apiHelpers/transactionsApiHelpers.d.ts +8 -0
- package/dist/general/apiHelpers/transactionsApiHelpers.d.ts.map +1 -1
- package/dist/general/apiHelpers/transactionsApiHelpers.js +73 -0
- package/dist/general/providers/aftermath.d.ts +6 -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 +2 -0
- package/dist/general/providers/aftermathApi.d.ts.map +1 -1
- package/dist/general/providers/aftermathApi.js +4 -0
- package/dist/general/types/castingTypes.d.ts +1 -0
- package/dist/general/types/castingTypes.d.ts.map +1 -1
- package/dist/general/types/configTypes.d.ts +13 -0
- package/dist/general/types/configTypes.d.ts.map +1 -1
- package/dist/general/types/generalTypes.d.ts +1 -0
- package/dist/general/types/generalTypes.d.ts.map +1 -1
- package/dist/general/utils/casting.d.ts +2 -0
- package/dist/general/utils/casting.d.ts.map +1 -1
- package/dist/general/utils/casting.js +2 -0
- package/dist/packages/dca/api/dcaApi.d.ts +44 -0
- package/dist/packages/dca/api/dcaApi.d.ts.map +1 -0
- package/dist/packages/dca/api/dcaApi.js +215 -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 +170 -0
- package/dist/packages/dca/api/dcaApiCastingTypes.d.ts +132 -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 +87 -0
- package/dist/packages/dca/dca.d.ts.map +1 -0
- package/dist/packages/dca/dca.js +138 -0
- package/dist/packages/dca/dcaTypes.d.ts +130 -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/multisig/api/multisigApi.d.ts +2 -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 +3 -0
- package/dist/packages/multisig/multisig.d.ts +2 -0
- package/dist/packages/multisig/multisig.d.ts.map +1 -0
- package/dist/packages/multisig/multisig.js +37 -0
- package/dist/packages/multisig/multisigTypes.d.ts +2 -0
- package/dist/packages/multisig/multisigTypes.d.ts.map +1 -0
- package/dist/packages/multisig/multisigTypes.js +13 -0
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts +19 -14
- package/dist/packages/perpetuals/api/perpetualsApi.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApi.js +403 -362
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts +1 -0
- package/dist/packages/perpetuals/api/perpetualsApiCasting.d.ts.map +1 -1
- package/dist/packages/perpetuals/api/perpetualsApiCasting.js +5 -3
- package/dist/packages/perpetuals/perpetuals.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.d.ts +16 -4
- package/dist/packages/perpetuals/perpetualsAccount.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsAccount.js +50 -22
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts +7 -6
- package/dist/packages/perpetuals/perpetualsCastingTypes.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.d.ts +3 -33
- package/dist/packages/perpetuals/perpetualsMarket.d.ts.map +1 -1
- package/dist/packages/perpetuals/perpetualsMarket.js +8 -184
- package/dist/packages/perpetuals/perpetualsTypes.d.ts +69 -20
- package/dist/packages/perpetuals/perpetualsTypes.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.d.ts +0 -2
- package/dist/packages/router/api/routerApi.d.ts.map +1 -1
- package/dist/packages/router/api/routerApi.js +7 -48
- package/package.json +2 -2
|
@@ -0,0 +1,170 @@
|
|
|
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: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
|
|
17
|
+
owner: utils_1.Helpers.addLeadingZeroesToType(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.closedDcaOrderEventFromOnChain = (eventOnChain) => {
|
|
35
|
+
const fields = eventOnChain.parsedJson;
|
|
36
|
+
return {
|
|
37
|
+
orderId: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
|
|
38
|
+
owner: utils_1.Helpers.addLeadingZeroesToType(fields.user),
|
|
39
|
+
remainingValue: BigInt(fields.remaining_amount),
|
|
40
|
+
inputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.input_type).toString()),
|
|
41
|
+
outputType: utils_1.Helpers.addLeadingZeroesToType("0x" + Buffer.from(fields.output_type).toString()),
|
|
42
|
+
gasValue: BigInt(fields.gas_amount),
|
|
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.executedTradeEventFromOnChain = (eventOnChain) => {
|
|
56
|
+
const fields = eventOnChain.parsedJson;
|
|
57
|
+
return {
|
|
58
|
+
orderId: utils_1.Helpers.addLeadingZeroesToType(fields.order_id),
|
|
59
|
+
user: utils_1.Helpers.addLeadingZeroesToType(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 = utils_1.Helpers.addLeadingZeroesToType(String(response.coin_sell));
|
|
79
|
+
const outputCoinType = utils_1.Helpers.addLeadingZeroesToType(String(response.coin_buy));
|
|
80
|
+
const strategy = BigInt(response.min_amount_out) === BigInt(0) &&
|
|
81
|
+
BigInt(response.max_amount_out) === utils_1.Casting.u64MaxBigInt
|
|
82
|
+
? undefined
|
|
83
|
+
: {
|
|
84
|
+
minPrice: BigInt(response.min_amount_out),
|
|
85
|
+
maxPrice: 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
|
+
return _a.createdOrderTradeEventOnIndexer(trade, inputCoinType, outputCoinType);
|
|
97
|
+
});
|
|
98
|
+
const started = tradesPrepared.length > 0
|
|
99
|
+
? {
|
|
100
|
+
timestamp: tradesPrepared[0].tnxDate,
|
|
101
|
+
digest: tradesPrepared[0].tnxDigest,
|
|
102
|
+
}
|
|
103
|
+
: {
|
|
104
|
+
timestamp: Number(response.next_execution_timestamp_ms),
|
|
105
|
+
digest: "",
|
|
106
|
+
};
|
|
107
|
+
const lastTrade = tradesPrepared.length > 0
|
|
108
|
+
? {
|
|
109
|
+
timestamp: tradesPrepared[tradesPrepared.length - 1].tnxDate,
|
|
110
|
+
digest: tradesPrepared[tradesPrepared.length - 1]
|
|
111
|
+
.tnxDigest,
|
|
112
|
+
}
|
|
113
|
+
: undefined;
|
|
114
|
+
return {
|
|
115
|
+
objectId: utils_1.Helpers.addLeadingZeroesToType(response.order_object_id),
|
|
116
|
+
overview: {
|
|
117
|
+
allocatedCoin: {
|
|
118
|
+
coin: inputCoinType,
|
|
119
|
+
amount: BigInt(response.coin_sell_amount),
|
|
120
|
+
},
|
|
121
|
+
buyCoin: {
|
|
122
|
+
coin: outputCoinType,
|
|
123
|
+
amount: totalBought,
|
|
124
|
+
},
|
|
125
|
+
averagePrice: tradesPrepared.length > 0
|
|
126
|
+
? totalBought / BigInt(tradesPrepared.length)
|
|
127
|
+
: BigInt(0),
|
|
128
|
+
totalSpent: totalSpent,
|
|
129
|
+
intervalMs: Number(response.frequency_ms),
|
|
130
|
+
totalTrades: totalOrdersAmount,
|
|
131
|
+
tradesRemaining: ordersLeft,
|
|
132
|
+
maxSlippageBps: Number(response.slippage),
|
|
133
|
+
strategy: strategy,
|
|
134
|
+
progress: progress,
|
|
135
|
+
recipient: utils_1.Helpers.addLeadingZeroesToType(response.recipient),
|
|
136
|
+
created: {
|
|
137
|
+
time: response.created.timestamp,
|
|
138
|
+
tnxDigest: response.created.tx_digest,
|
|
139
|
+
},
|
|
140
|
+
nextTrade: {
|
|
141
|
+
time: started.timestamp,
|
|
142
|
+
tnxDigest: started.digest,
|
|
143
|
+
},
|
|
144
|
+
lastExecutedTrade: lastTrade
|
|
145
|
+
? {
|
|
146
|
+
time: lastTrade.timestamp,
|
|
147
|
+
tnxDigest: lastTrade.digest,
|
|
148
|
+
}
|
|
149
|
+
: undefined,
|
|
150
|
+
},
|
|
151
|
+
trades: tradesPrepared,
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
DcaApiCasting.createdOrderTradeEventOnIndexer = (response, inputCoinType, outputCoinType) => {
|
|
155
|
+
const inputAmount = BigInt(response.input_amount);
|
|
156
|
+
const outputAmount = BigInt(response.output_amount);
|
|
157
|
+
return {
|
|
158
|
+
allocatedCoin: {
|
|
159
|
+
coin: inputCoinType,
|
|
160
|
+
amount: inputAmount,
|
|
161
|
+
},
|
|
162
|
+
buyCoin: {
|
|
163
|
+
coin: outputCoinType,
|
|
164
|
+
amount: outputAmount,
|
|
165
|
+
},
|
|
166
|
+
tnxDigest: response.event.tx_digest,
|
|
167
|
+
tnxDate: response.event.timestamp,
|
|
168
|
+
rate: undefined,
|
|
169
|
+
};
|
|
170
|
+
};
|
|
@@ -0,0 +1,132 @@
|
|
|
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_amount: BigIntAsString;
|
|
39
|
+
input_type: Uint8Array;
|
|
40
|
+
output_type: Uint8Array;
|
|
41
|
+
gas_amount: 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_amount: BigIntAsString;
|
|
55
|
+
input_type: Uint8Array;
|
|
56
|
+
output_amount: BigIntAsString;
|
|
57
|
+
output_type: Uint8Array;
|
|
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
|
+
recipient: SuiAddress;
|
|
75
|
+
created: {
|
|
76
|
+
timestamp: Timestamp;
|
|
77
|
+
tx_digest: TransactionDigest;
|
|
78
|
+
};
|
|
79
|
+
average_price: BigIntAsString;
|
|
80
|
+
min_amount_out: BigIntAsString;
|
|
81
|
+
max_amount_out: BigIntAsString;
|
|
82
|
+
next_execution_timestamp_ms: string;
|
|
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
|
+
recipient: SuiAddress;
|
|
102
|
+
frequency_ms: string;
|
|
103
|
+
delay_timestamp_ms: string;
|
|
104
|
+
amount_per_trade: string;
|
|
105
|
+
max_allowable_slippage_bps: number;
|
|
106
|
+
min_amount_out: string;
|
|
107
|
+
max_amount_out: string;
|
|
108
|
+
number_of_trades: number;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
export type DcaIndexerOrderCreateResponse = {
|
|
112
|
+
tx_data: SerializedTransaction;
|
|
113
|
+
};
|
|
114
|
+
export type DcaIndexerOrderCloseRequest = {
|
|
115
|
+
wallet_address: string;
|
|
116
|
+
signature: string;
|
|
117
|
+
bytes: string;
|
|
118
|
+
};
|
|
119
|
+
export type DcaIndexerOrderCloseResponse = boolean;
|
|
120
|
+
export type DcaIndexerUserRequest = {
|
|
121
|
+
wallet_address: string;
|
|
122
|
+
};
|
|
123
|
+
export type DcaIndexerUserResponse = {
|
|
124
|
+
public_key?: string;
|
|
125
|
+
};
|
|
126
|
+
export type DcaIndexerCreateUserRequest = {
|
|
127
|
+
wallet_address: string;
|
|
128
|
+
signature: string;
|
|
129
|
+
bytes: string;
|
|
130
|
+
};
|
|
131
|
+
export type DcaIndexerCreateUserResponse = boolean;
|
|
132
|
+
//# 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,EACN,cAAc,EACd,QAAQ,EACR,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,UAAU,EACV,SAAS,EACT,iBAAiB,EACjB,MAAM,gBAAgB,CAAC;AAMxB,MAAM,WAAW,qBAAqB;IACrC,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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AC1C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACN,UAAU,EAAE,eAAe,CAAC;QAC5B,eAAe,EAAE,QAAQ,CAAC;QAC1B,gBAAgB,EAAE,QAAQ,CAAC;QAC3B,QAAQ,EAAE,eAAe,CAAC;QAC1B,KAAK,EAAE,UAAU,CAAC;QAClB,SAAS,EAAE,UAAU,CAAC;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,kBAAkB,EAAE,MAAM,CAAC;QAC3B,gBAAgB,EAAE,MAAM,CAAC;QACzB,0BAA0B,EAAE,MAAM,CAAC;QACnC,cAAc,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,MAAM,CAAC;QACvB,gBAAgB,EAAE,MAAM,CAAC;KACzB,CAAC;CACF,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC3C,OAAO,EAAE,qBAAqB,CAAC;CAC/B,CAAC;AAMF,MAAM,MAAM,2BAA2B,GAAG;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAMnD,MAAM,MAAM,qBAAqB,GAAG;IACnC,cAAc,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACpC,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAMF,MAAM,MAAM,2BAA2B,GAAG;IACzC,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,4BAA4B,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { ObjectId, SuiNetwork } from "../../types";
|
|
2
|
+
import { Caller } from "../../general/utils/caller";
|
|
3
|
+
import { AftermathApi } from "../../general/providers";
|
|
4
|
+
import { SuiAddress } from "../../types";
|
|
5
|
+
import { ApiDCAsOwnedBody, DcaOrdersObject, ApiDcaTransactionForCreateOrderBody, ApiDcaTransactionForCloseOrderBody, DcaOrderObject, ApiDcaCreateUserBody } from "./dcaTypes";
|
|
6
|
+
import { Transaction } from "@mysten/sui/transactions";
|
|
7
|
+
export declare class Dca extends Caller {
|
|
8
|
+
readonly network?: SuiNetwork | undefined;
|
|
9
|
+
private readonly Provider?;
|
|
10
|
+
static readonly constants: {
|
|
11
|
+
gasAmount: bigint;
|
|
12
|
+
};
|
|
13
|
+
constructor(network?: SuiNetwork | undefined, Provider?: AftermathApi | undefined);
|
|
14
|
+
/**
|
|
15
|
+
* Fetches the API for dollar cost averaging orders list.
|
|
16
|
+
* @async
|
|
17
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
18
|
+
* @returns { Promise<DcaOrdersObject> } A promise that resolves to object with array of fetched events for active and past dca's.
|
|
19
|
+
*/
|
|
20
|
+
getAllDcaOrders(inputs: ApiDCAsOwnedBody): Promise<DcaOrdersObject>;
|
|
21
|
+
/**
|
|
22
|
+
* Fetches the API for dollar cost averaging active orders list.
|
|
23
|
+
* @async
|
|
24
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
25
|
+
* @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for active dca's.
|
|
26
|
+
*/
|
|
27
|
+
getActiveDcaOrders(inputs: {
|
|
28
|
+
walletAddress: SuiAddress;
|
|
29
|
+
}): Promise<DcaOrderObject[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Fetches the API for dollar cost averaging past orders list.
|
|
32
|
+
* @async
|
|
33
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
34
|
+
* @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for past dca's.
|
|
35
|
+
*/
|
|
36
|
+
getPastDcaOrders(inputs: {
|
|
37
|
+
walletAddress: SuiAddress;
|
|
38
|
+
}): Promise<DcaOrderObject[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Fetches the API transaction for creating DCA order.
|
|
41
|
+
* @param { ApiDcaTransactionForCreateOrderBody } inputs - The inputs for the transaction.
|
|
42
|
+
* @returns { Promise<Transaction> } A promise that resolves with the API transaction.
|
|
43
|
+
*/
|
|
44
|
+
getCreateDcaOrderTx(inputs: ApiDcaTransactionForCreateOrderBody): Promise<Transaction>;
|
|
45
|
+
/**
|
|
46
|
+
* Fetches the API for canceling DCA order.
|
|
47
|
+
* @param inputs - The inputs for the transaction.
|
|
48
|
+
* @returns { Promise<boolean> } A promise that resolves with transaction execution status.
|
|
49
|
+
*/
|
|
50
|
+
closeDcaOrder(inputs: ApiDcaTransactionForCloseOrderBody): Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Method for getting the cancelation dca order message to sign.
|
|
53
|
+
* @param inputs - The inputs for the message.
|
|
54
|
+
* @returns Message to sign.
|
|
55
|
+
*/
|
|
56
|
+
closeDcaOrderMessageToSign(inputs: {
|
|
57
|
+
orderId: ObjectId;
|
|
58
|
+
}): {
|
|
59
|
+
action: string;
|
|
60
|
+
order_object_id: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Method for getting the creation user message to sign.
|
|
64
|
+
* @param inputs - The inputs for the message.
|
|
65
|
+
* @returns Message to sign.
|
|
66
|
+
*/
|
|
67
|
+
createUserAccountMessageToSign(): {
|
|
68
|
+
action: string;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Fetches the API for users public key.
|
|
72
|
+
* @async
|
|
73
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
74
|
+
* @returns { Promise<string | undefined> } A promise that resolves users public key.
|
|
75
|
+
*/
|
|
76
|
+
getUserPublicKey(inputs: {
|
|
77
|
+
walletAddress: SuiAddress;
|
|
78
|
+
}): Promise<string | undefined>;
|
|
79
|
+
/**
|
|
80
|
+
* Fetches the API to create users public key.
|
|
81
|
+
* @async
|
|
82
|
+
* @param { ApiDcaCreateUserBody } inputs - The inputs for creating users public key on BE side.
|
|
83
|
+
* @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
|
|
84
|
+
*/
|
|
85
|
+
createUserPublicKey(inputs: ApiDcaCreateUserBody): Promise<boolean>;
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=dca.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dca.d.ts","sourceRoot":"","sources":["../../../src/packages/dca/dca.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACnD,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,eAAe,EACf,mCAAmC,EACnC,kCAAkC,EAClC,cAAc,EACd,oBAAoB,EACpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEvD,qBAAa,GAAI,SAAQ,MAAM;aAcb,OAAO,CAAC;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;IAV3B,gBAAuB,SAAS;;MAE9B;gBAOe,OAAO,CAAC,wBAAY,EACnB,QAAQ,CAAC,0BAAc;IASzC;;;;;OAKG;IAEU,eAAe,CAAC,MAAM,EAAE,gBAAgB;IAOrD;;;;;OAKG;IAEU,kBAAkB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAOrE;;;;;OAKG;IAEU,gBAAgB,CAAC,MAAM,EAAE;QAAE,aAAa,EAAE,UAAU,CAAA;KAAE;IAWnE;;;;OAIG;IAEU,mBAAmB,CAC/B,MAAM,EAAE,mCAAmC,GACzC,OAAO,CAAC,WAAW,CAAC;IAOvB;;;;OAIG;IAEU,aAAa,CACzB,MAAM,EAAE,kCAAkC,GACxC,OAAO,CAAC,OAAO,CAAC;IAWnB;;;;OAIG;IAEI,0BAA0B,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,QAAQ,CAAA;KAAE,GAAG;QACjE,MAAM,EAAE,MAAM,CAAC;QACf,eAAe,EAAE,MAAM,CAAC;KACxB;IAOD;;;;OAIG;IAEI,8BAA8B,IAAI;QACxC,MAAM,EAAE,MAAM,CAAC;KACf;IAUD;;;;;OAKG;IAEU,gBAAgB,CAAC,MAAM,EAAE;QACrC,aAAa,EAAE,UAAU,CAAC;KAC1B,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAS/B;;;;;OAKG;IAEU,mBAAmB,CAC/B,MAAM,EAAE,oBAAoB,GAC1B,OAAO,CAAC,OAAO,CAAC;CAMnB"}
|
|
@@ -0,0 +1,138 @@
|
|
|
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
|
+
// =========================================================================
|
|
24
|
+
// Class Objects
|
|
25
|
+
// =========================================================================
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the API for dollar cost averaging orders list.
|
|
28
|
+
* @async
|
|
29
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
30
|
+
* @returns { Promise<DcaOrdersObject> } A promise that resolves to object with array of fetched events for active and past dca's.
|
|
31
|
+
*/
|
|
32
|
+
getAllDcaOrders(inputs) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
return this.fetchApi("orders", inputs);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the API for dollar cost averaging active orders list.
|
|
39
|
+
* @async
|
|
40
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
41
|
+
* @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for active dca's.
|
|
42
|
+
*/
|
|
43
|
+
getActiveDcaOrders(inputs) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.fetchApi("orders/active", inputs);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Fetches the API for dollar cost averaging past orders list.
|
|
50
|
+
* @async
|
|
51
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
52
|
+
* @returns { Promise<DcaOrderObject[]> } A promise that resolves to object with array of fetched events for past dca's.
|
|
53
|
+
*/
|
|
54
|
+
getPastDcaOrders(inputs) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
return this.fetchApi("orders/past", inputs);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
// =========================================================================
|
|
60
|
+
// Transactions
|
|
61
|
+
// =========================================================================
|
|
62
|
+
/**
|
|
63
|
+
* Fetches the API transaction for creating DCA order.
|
|
64
|
+
* @param { ApiDcaTransactionForCreateOrderBody } inputs - The inputs for the transaction.
|
|
65
|
+
* @returns { Promise<Transaction> } A promise that resolves with the API transaction.
|
|
66
|
+
*/
|
|
67
|
+
getCreateDcaOrderTx(inputs) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return this.fetchApiTransaction("transactions/create-order", inputs);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Fetches the API for canceling DCA order.
|
|
74
|
+
* @param inputs - The inputs for the transaction.
|
|
75
|
+
* @returns { Promise<boolean> } A promise that resolves with transaction execution status.
|
|
76
|
+
*/
|
|
77
|
+
closeDcaOrder(inputs) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return this.fetchApi(`interactions/close-order`, inputs);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
// =========================================================================
|
|
83
|
+
// Interactions
|
|
84
|
+
// =========================================================================
|
|
85
|
+
/**
|
|
86
|
+
* Method for getting the cancelation dca order message to sign.
|
|
87
|
+
* @param inputs - The inputs for the message.
|
|
88
|
+
* @returns Message to sign.
|
|
89
|
+
*/
|
|
90
|
+
closeDcaOrderMessageToSign(inputs) {
|
|
91
|
+
return {
|
|
92
|
+
action: "CANCEL_DCA_ORDER",
|
|
93
|
+
order_object_id: inputs.orderId,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Method for getting the creation user message to sign.
|
|
98
|
+
* @param inputs - The inputs for the message.
|
|
99
|
+
* @returns Message to sign.
|
|
100
|
+
*/
|
|
101
|
+
createUserAccountMessageToSign() {
|
|
102
|
+
return {
|
|
103
|
+
action: "CREATE_DCA_ACCOUNT",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// =========================================================================
|
|
107
|
+
// User Public Key
|
|
108
|
+
// =========================================================================
|
|
109
|
+
/**
|
|
110
|
+
* Fetches the API for users public key.
|
|
111
|
+
* @async
|
|
112
|
+
* @param { ApiDCAsOwnedBody } inputs - An object containing the walletAddress.
|
|
113
|
+
* @returns { Promise<string | undefined> } A promise that resolves users public key.
|
|
114
|
+
*/
|
|
115
|
+
getUserPublicKey(inputs) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
return this.fetchApi(`public-key`, inputs);
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Fetches the API to create users public key.
|
|
122
|
+
* @async
|
|
123
|
+
* @param { ApiDcaCreateUserBody } inputs - The inputs for creating users public key on BE side.
|
|
124
|
+
* @returns { Promise<boolean> } A promise that resolves to result if user pk has been created.
|
|
125
|
+
*/
|
|
126
|
+
createUserPublicKey(inputs) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return this.fetchApi(`save-public-key`, inputs);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.Dca = Dca;
|
|
133
|
+
// =========================================================================
|
|
134
|
+
// Constants
|
|
135
|
+
// =========================================================================
|
|
136
|
+
Dca.constants = {
|
|
137
|
+
gasAmount: BigInt(50000000),
|
|
138
|
+
};
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ObjectId, SuiAddress } from "../../types";
|
|
2
|
+
import { CoinType } from "../coin/coinTypes";
|
|
3
|
+
import { Balance, Event, Timestamp, TransactionDigest } from "../../general/types/generalTypes";
|
|
4
|
+
export interface ApiDcaInitializeOrdertStrategyBody {
|
|
5
|
+
minPrice: Balance;
|
|
6
|
+
maxPrice: Balance;
|
|
7
|
+
}
|
|
8
|
+
export interface ApiDcaTransactionForCreateOrderBody {
|
|
9
|
+
walletAddress: SuiAddress;
|
|
10
|
+
allocateCoinType: CoinType;
|
|
11
|
+
allocateCoinAmount: Balance;
|
|
12
|
+
buyCoinType: CoinType;
|
|
13
|
+
frequencyMs: Timestamp;
|
|
14
|
+
tradesAmount: number;
|
|
15
|
+
strategy?: ApiDcaInitializeOrdertStrategyBody;
|
|
16
|
+
isSponsoredTx?: boolean;
|
|
17
|
+
delayTimeMs: Timestamp;
|
|
18
|
+
maxAllowableSlippageBps: number;
|
|
19
|
+
coinPerTradeAmount: Balance;
|
|
20
|
+
customRecipient?: SuiAddress;
|
|
21
|
+
}
|
|
22
|
+
export interface ApiDcaTransactionForCloseOrderBody {
|
|
23
|
+
walletAddress: SuiAddress;
|
|
24
|
+
bytes: string;
|
|
25
|
+
signature: string;
|
|
26
|
+
}
|
|
27
|
+
export interface DcaOrderTradeObject {
|
|
28
|
+
allocatedCoin: {
|
|
29
|
+
coin: CoinType;
|
|
30
|
+
amount: Balance;
|
|
31
|
+
};
|
|
32
|
+
buyCoin: {
|
|
33
|
+
coin: CoinType;
|
|
34
|
+
amount: Balance;
|
|
35
|
+
};
|
|
36
|
+
tnxDigest: TransactionDigest;
|
|
37
|
+
tnxDate: Timestamp;
|
|
38
|
+
rate: number | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface DcaOrdertStrategyObject {
|
|
41
|
+
minPrice: Balance;
|
|
42
|
+
maxPrice: Balance;
|
|
43
|
+
}
|
|
44
|
+
export interface DcaOrderOverviewObject {
|
|
45
|
+
allocatedCoin: {
|
|
46
|
+
coin: CoinType;
|
|
47
|
+
amount: Balance;
|
|
48
|
+
};
|
|
49
|
+
buyCoin: {
|
|
50
|
+
coin: CoinType;
|
|
51
|
+
amount: Balance;
|
|
52
|
+
};
|
|
53
|
+
averagePrice: Balance;
|
|
54
|
+
totalSpent: Balance;
|
|
55
|
+
intervalMs: Timestamp;
|
|
56
|
+
totalTrades: number;
|
|
57
|
+
tradesRemaining: number;
|
|
58
|
+
maxSlippageBps: number;
|
|
59
|
+
strategy?: DcaOrdertStrategyObject;
|
|
60
|
+
recipient?: SuiAddress;
|
|
61
|
+
progress: number;
|
|
62
|
+
created: {
|
|
63
|
+
time: Timestamp;
|
|
64
|
+
tnxDigest: TransactionDigest;
|
|
65
|
+
};
|
|
66
|
+
nextTrade: {
|
|
67
|
+
time: Timestamp;
|
|
68
|
+
tnxDigest: TransactionDigest;
|
|
69
|
+
};
|
|
70
|
+
lastExecutedTrade?: {
|
|
71
|
+
time: Timestamp;
|
|
72
|
+
tnxDigest: TransactionDigest;
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export interface DcaOrderObject {
|
|
76
|
+
objectId: ObjectId;
|
|
77
|
+
overview: DcaOrderOverviewObject;
|
|
78
|
+
trades: DcaOrderTradeObject[];
|
|
79
|
+
}
|
|
80
|
+
export interface DcaOrdersObject {
|
|
81
|
+
active: DcaOrderObject[];
|
|
82
|
+
past: DcaOrderObject[];
|
|
83
|
+
}
|
|
84
|
+
export interface DcaCreatedOrderEvent extends Event {
|
|
85
|
+
orderId: ObjectId;
|
|
86
|
+
owner: ObjectId;
|
|
87
|
+
inputValue: Balance;
|
|
88
|
+
inputType: CoinType;
|
|
89
|
+
outputType: CoinType;
|
|
90
|
+
gasValue: Balance;
|
|
91
|
+
frequencyMs: Timestamp;
|
|
92
|
+
startTimestampMs: Timestamp;
|
|
93
|
+
amountPerTrade: Balance;
|
|
94
|
+
maxAllowableSlippageBps: Balance;
|
|
95
|
+
minAmountOut: Balance;
|
|
96
|
+
maxAmountOut: Balance;
|
|
97
|
+
remainingTrades: bigint;
|
|
98
|
+
}
|
|
99
|
+
export interface DcaClosedOrderEvent extends Event {
|
|
100
|
+
orderId: ObjectId;
|
|
101
|
+
owner: ObjectId;
|
|
102
|
+
remainingValue: Balance;
|
|
103
|
+
inputType: CoinType;
|
|
104
|
+
outputType: CoinType;
|
|
105
|
+
gasValue: Balance;
|
|
106
|
+
frequencyMs: Timestamp;
|
|
107
|
+
lastTradeTimestampMs: Timestamp;
|
|
108
|
+
amountPerTrade: Balance;
|
|
109
|
+
maxAllowableSlippageBps: Balance;
|
|
110
|
+
minAmountOut: Balance;
|
|
111
|
+
maxAmountOut: Balance;
|
|
112
|
+
remainingTrades: bigint;
|
|
113
|
+
}
|
|
114
|
+
export interface DcaExecutedTradeEvent extends Event {
|
|
115
|
+
orderId: ObjectId;
|
|
116
|
+
user: ObjectId;
|
|
117
|
+
inputType: CoinType;
|
|
118
|
+
inputAmount: Balance;
|
|
119
|
+
outputType: CoinType;
|
|
120
|
+
outputAmount: Balance;
|
|
121
|
+
}
|
|
122
|
+
export interface ApiDcaCreateUserBody {
|
|
123
|
+
walletAddress: SuiAddress;
|
|
124
|
+
bytes: string;
|
|
125
|
+
signature: string;
|
|
126
|
+
}
|
|
127
|
+
export interface ApiDCAsOwnedBody {
|
|
128
|
+
walletAddress: SuiAddress;
|
|
129
|
+
}
|
|
130
|
+
//# 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,SAAS,EACT,iBAAiB,EACjB,MAAM,kCAAkC,CAAC;AAM1C,MAAM,WAAW,kCAAkC;IAClD,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,mCAAmC;IACnD,aAAa,EAAE,UAAU,CAAC;IAC1B,gBAAgB,EAAE,QAAQ,CAAC;IAC3B,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,QAAQ,CAAC;IACtB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,kCAAkC,CAAC;IAC9C,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,EAAE,SAAS,CAAC;IACvB,uBAAuB,EAAE,MAAM,CAAC;I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