@microcosmmoney/portal-react 3.13.0 → 3.13.1
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/main-portal/components/mining/MiningModal.js +1 -1
- package/dist/main-portal/components/providers/SolanaWalletProvider.js +1 -1
- package/dist/main-portal/components/resources/public-mining-modal.js +1 -1
- package/dist/main-portal/hooks/useAuth.js +3 -2
- package/dist/main-portal/lib/api/index.d.ts +2 -9
- package/dist/main-portal/lib/api/index.js +17 -210
- package/package.json +1 -1
- package/dist/main-portal/hooks/useMarketData.d.ts +0 -9
- package/dist/main-portal/hooks/useMarketData.js +0 -32
- package/dist/main-portal/hooks/usePriceHistory.d.ts +0 -9
- package/dist/main-portal/hooks/usePriceHistory.js +0 -36
- package/dist/main-portal/lib/analytics/hooks.d.ts +0 -139
- package/dist/main-portal/lib/analytics/hooks.js +0 -277
- package/dist/main-portal/lib/analytics/index.d.ts +0 -2
- package/dist/main-portal/lib/analytics/index.js +0 -19
- package/dist/main-portal/lib/analytics/types.d.ts +0 -611
- package/dist/main-portal/lib/analytics/types.js +0 -2
- package/dist/main-portal/lib/api/account.d.ts +0 -39
- package/dist/main-portal/lib/api/account.js +0 -86
- package/dist/main-portal/lib/api/admin.d.ts +0 -78
- package/dist/main-portal/lib/api/admin.js +0 -195
- package/dist/main-portal/lib/api/analytics.d.ts +0 -217
- package/dist/main-portal/lib/api/analytics.js +0 -55
- package/dist/main-portal/lib/api/dexscreener.d.ts +0 -126
- package/dist/main-portal/lib/api/dexscreener.js +0 -139
- package/dist/main-portal/lib/api/geckoterminal.d.ts +0 -10
- package/dist/main-portal/lib/api/geckoterminal.js +0 -43
- package/dist/main-portal/lib/api/mcc-holders.d.ts +0 -130
- package/dist/main-portal/lib/api/mcc-holders.js +0 -47
- package/dist/main-portal/lib/api/org-service-proxy.d.ts +0 -7
- package/dist/main-portal/lib/api/org-service-proxy.js +0 -55
- package/dist/main-portal/lib/api/strategies.d.ts +0 -101
- package/dist/main-portal/lib/api/strategies.js +0 -87
- package/dist/main-portal/lib/exchanges/config.d.ts +0 -34
- package/dist/main-portal/lib/exchanges/config.js +0 -185
- package/dist/main-portal/lib/exchanges/hooks/index.d.ts +0 -5
- package/dist/main-portal/lib/exchanges/hooks/index.js +0 -10
- package/dist/main-portal/lib/exchanges/hooks/useBinanceData.d.ts +0 -15
- package/dist/main-portal/lib/exchanges/hooks/useBinanceData.js +0 -216
- package/dist/main-portal/lib/exchanges/hooks/useBinanceDialogs.d.ts +0 -32
- package/dist/main-portal/lib/exchanges/hooks/useBinanceDialogs.js +0 -395
- package/dist/main-portal/lib/exchanges/hooks/useUserExchanges.d.ts +0 -15
- package/dist/main-portal/lib/exchanges/hooks/useUserExchanges.js +0 -51
- package/dist/main-portal/lib/exchanges/index.d.ts +0 -4
- package/dist/main-portal/lib/exchanges/index.js +0 -21
- package/dist/main-portal/lib/exchanges/types.d.ts +0 -102
- package/dist/main-portal/lib/exchanges/types.js +0 -2
- package/dist/main-portal/lib/exchanges/utils.d.ts +0 -1
- package/dist/main-portal/lib/exchanges/utils.js +0 -10
- package/dist/main-portal/lib/gcp-secrets.d.ts +0 -7
- package/dist/main-portal/lib/gcp-secrets.js +0 -45
- package/dist/main-portal/lib/mockWallet.d.ts +0 -130
- package/dist/main-portal/lib/mockWallet.js +0 -284
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDistributeHistory = exports.distributeParams = exports.previewGroupRules = exports.refreshGroup = exports.reviewGroupStrategies = exports.removeStrategiesFromGroup = exports.addStrategiesToGroup = exports.getGroupStrategies = exports.deleteGroup = exports.updateGroup = exports.createGroup = exports.getGroup = exports.getGroups = exports.deleteTemplate = exports.updateTemplate = exports.createTemplate = exports.getTemplate = exports.getTemplates = exports.getBatchHistory = exports.batchUpdateStrategies = exports.batchPreviewStrategies = exports.getEnergyHistory = exports.getEnergyOrders = exports.updateStrategy = exports.deleteStrategy = exports.createStrategy = exports.stopStrategy = exports.startStrategy = exports.getStrategyDetails = exports.getStrategies = void 0;
|
|
4
|
-
// AI-generated · AI-managed · AI-maintained
|
|
5
|
-
const core_1 = require("./core");
|
|
6
|
-
const getStrategies = () => (0, core_1.fetchApi)('/strategies');
|
|
7
|
-
exports.getStrategies = getStrategies;
|
|
8
|
-
const getStrategyDetails = (strategyId) => (0, core_1.fetchApi)(`/strategies/${strategyId}`);
|
|
9
|
-
exports.getStrategyDetails = getStrategyDetails;
|
|
10
|
-
const startStrategy = (strategyId) => (0, core_1.fetchApi)(`/strategies/${strategyId}/start`, { method: 'POST' });
|
|
11
|
-
exports.startStrategy = startStrategy;
|
|
12
|
-
const stopStrategy = (strategyId) => (0, core_1.fetchApi)(`/strategies/${strategyId}/stop`, { method: 'POST' });
|
|
13
|
-
exports.stopStrategy = stopStrategy;
|
|
14
|
-
const createStrategy = (strategyParams) => (0, core_1.fetchApi)('/strategies', {
|
|
15
|
-
method: 'POST',
|
|
16
|
-
body: JSON.stringify(strategyParams)
|
|
17
|
-
});
|
|
18
|
-
exports.createStrategy = createStrategy;
|
|
19
|
-
const deleteStrategy = (strategyId) => (0, core_1.fetchApi)(`/strategies/${strategyId}`, { method: 'DELETE' });
|
|
20
|
-
exports.deleteStrategy = deleteStrategy;
|
|
21
|
-
const updateStrategy = (strategyId, params) => (0, core_1.fetchApi)(`/strategies/${strategyId}`, {
|
|
22
|
-
method: 'PUT',
|
|
23
|
-
body: JSON.stringify(params)
|
|
24
|
-
});
|
|
25
|
-
exports.updateStrategy = updateStrategy;
|
|
26
|
-
const getEnergyOrders = (strategyId, includeHistory = false) => (0, core_1.fetchApi)(`/strategies/${strategyId}/energy-orders${includeHistory ? '?include_history=true' : ''}`);
|
|
27
|
-
exports.getEnergyOrders = getEnergyOrders;
|
|
28
|
-
const getEnergyHistory = (strategyId, page = 1, pageSize = 50) => (0, core_1.fetchApi)(`/strategies/${strategyId}/energy-history?page=${page}&page_size=${pageSize}`);
|
|
29
|
-
exports.getEnergyHistory = getEnergyHistory;
|
|
30
|
-
const batchPreviewStrategies = (filters) => (0, core_1.fetchApi)('/strategies/batch/preview', {
|
|
31
|
-
method: 'POST',
|
|
32
|
-
body: JSON.stringify({ filters })
|
|
33
|
-
});
|
|
34
|
-
exports.batchPreviewStrategies = batchPreviewStrategies;
|
|
35
|
-
const batchUpdateStrategies = (strategyIds, paramPath, paramValue, filters) => (0, core_1.fetchApi)('/strategies/batch/update', {
|
|
36
|
-
method: 'POST',
|
|
37
|
-
body: JSON.stringify({
|
|
38
|
-
strategy_ids: strategyIds,
|
|
39
|
-
param_path: paramPath,
|
|
40
|
-
param_value: paramValue,
|
|
41
|
-
filters: filters || {}
|
|
42
|
-
})
|
|
43
|
-
});
|
|
44
|
-
exports.batchUpdateStrategies = batchUpdateStrategies;
|
|
45
|
-
const getBatchHistory = (limit = 20) => (0, core_1.fetchApi)(`/strategies/batch/history?limit=${limit}`);
|
|
46
|
-
exports.getBatchHistory = getBatchHistory;
|
|
47
|
-
const getTemplates = () => (0, core_1.fetchApi)('/strategies/templates');
|
|
48
|
-
exports.getTemplates = getTemplates;
|
|
49
|
-
const getTemplate = (templateId) => (0, core_1.fetchApi)(`/strategies/templates/${templateId}`);
|
|
50
|
-
exports.getTemplate = getTemplate;
|
|
51
|
-
const createTemplate = (data) => (0, core_1.fetchApi)('/strategies/templates', { method: 'POST', body: JSON.stringify(data) });
|
|
52
|
-
exports.createTemplate = createTemplate;
|
|
53
|
-
const updateTemplate = (templateId, data) => (0, core_1.fetchApi)(`/strategies/templates/${templateId}`, { method: 'PUT', body: JSON.stringify(data) });
|
|
54
|
-
exports.updateTemplate = updateTemplate;
|
|
55
|
-
const deleteTemplate = (templateId) => (0, core_1.fetchApi)(`/strategies/templates/${templateId}`, { method: 'DELETE' });
|
|
56
|
-
exports.deleteTemplate = deleteTemplate;
|
|
57
|
-
const getGroups = () => (0, core_1.fetchApi)('/strategies/groups');
|
|
58
|
-
exports.getGroups = getGroups;
|
|
59
|
-
const getGroup = (groupId) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}`);
|
|
60
|
-
exports.getGroup = getGroup;
|
|
61
|
-
const createGroup = (data) => (0, core_1.fetchApi)('/strategies/groups', { method: 'POST', body: JSON.stringify(data) });
|
|
62
|
-
exports.createGroup = createGroup;
|
|
63
|
-
const updateGroup = (groupId, data) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}`, { method: 'PUT', body: JSON.stringify(data) });
|
|
64
|
-
exports.updateGroup = updateGroup;
|
|
65
|
-
const deleteGroup = (groupId) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}`, { method: 'DELETE' });
|
|
66
|
-
exports.deleteGroup = deleteGroup;
|
|
67
|
-
const getGroupStrategies = (groupId, page = 1, pageSize = 50, needsReview) => {
|
|
68
|
-
let url = `/strategies/groups/${groupId}/strategies?page=${page}&page_size=${pageSize}`;
|
|
69
|
-
if (needsReview !== undefined)
|
|
70
|
-
url += `&needs_review=${needsReview}`;
|
|
71
|
-
return (0, core_1.fetchApi)(url);
|
|
72
|
-
};
|
|
73
|
-
exports.getGroupStrategies = getGroupStrategies;
|
|
74
|
-
const addStrategiesToGroup = (groupId, strategyIds) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}/strategies`, { method: 'POST', body: JSON.stringify({ strategy_ids: strategyIds }) });
|
|
75
|
-
exports.addStrategiesToGroup = addStrategiesToGroup;
|
|
76
|
-
const removeStrategiesFromGroup = (groupId, strategyIds) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}/strategies`, { method: 'DELETE', body: JSON.stringify({ strategy_ids: strategyIds }) });
|
|
77
|
-
exports.removeStrategiesFromGroup = removeStrategiesFromGroup;
|
|
78
|
-
const reviewGroupStrategies = (groupId, strategyIds, action) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}/review`, { method: 'POST', body: JSON.stringify({ strategy_ids: strategyIds, action }) });
|
|
79
|
-
exports.reviewGroupStrategies = reviewGroupStrategies;
|
|
80
|
-
const refreshGroup = (groupId) => (0, core_1.fetchApi)(`/strategies/groups/${groupId}/refresh`, { method: 'POST' });
|
|
81
|
-
exports.refreshGroup = refreshGroup;
|
|
82
|
-
const previewGroupRules = (rules) => (0, core_1.fetchApi)('/strategies/groups/preview', { method: 'POST', body: JSON.stringify({ rules }) });
|
|
83
|
-
exports.previewGroupRules = previewGroupRules;
|
|
84
|
-
const distributeParams = (data) => (0, core_1.fetchApi)('/strategies/distribute', { method: 'POST', body: JSON.stringify(data) });
|
|
85
|
-
exports.distributeParams = distributeParams;
|
|
86
|
-
const getDistributeHistory = (limit = 50) => (0, core_1.fetchApi)(`/strategies/distribute/history?limit=${limit}`);
|
|
87
|
-
exports.getDistributeHistory = getDistributeHistory;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
export type ExchangeType = 'cex' | 'dex';
|
|
2
|
-
export type AuthType = 'api_key' | 'wallet';
|
|
3
|
-
export interface ExchangeConfig {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
displayName: string;
|
|
7
|
-
type: ExchangeType;
|
|
8
|
-
authType: AuthType;
|
|
9
|
-
enabled: boolean;
|
|
10
|
-
priority: number;
|
|
11
|
-
authFields: {
|
|
12
|
-
apiKey?: boolean;
|
|
13
|
-
secretKey?: boolean;
|
|
14
|
-
passphrase?: boolean;
|
|
15
|
-
privateKey?: boolean;
|
|
16
|
-
walletAddress?: boolean;
|
|
17
|
-
};
|
|
18
|
-
features: {
|
|
19
|
-
spot: boolean;
|
|
20
|
-
futures: boolean;
|
|
21
|
-
margin: boolean;
|
|
22
|
-
};
|
|
23
|
-
logoUrl?: string;
|
|
24
|
-
helpUrl?: string;
|
|
25
|
-
testnetUrl?: string;
|
|
26
|
-
}
|
|
27
|
-
export declare const EXCHANGE_CONFIGS: Record<string, ExchangeConfig>;
|
|
28
|
-
export declare function getEnabledExchanges(): ExchangeConfig[];
|
|
29
|
-
export declare function getCEXExchanges(): ExchangeConfig[];
|
|
30
|
-
export declare function getDEXExchanges(): ExchangeConfig[];
|
|
31
|
-
export declare function getExchangeConfig(exchangeId: string): ExchangeConfig | undefined;
|
|
32
|
-
export declare function requiresPassphrase(exchangeId: string): boolean;
|
|
33
|
-
export declare function isDEX(exchangeId: string): boolean;
|
|
34
|
-
export declare function getAuthFields(exchangeId: string): string[];
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EXCHANGE_CONFIGS = void 0;
|
|
4
|
-
exports.getEnabledExchanges = getEnabledExchanges;
|
|
5
|
-
exports.getCEXExchanges = getCEXExchanges;
|
|
6
|
-
exports.getDEXExchanges = getDEXExchanges;
|
|
7
|
-
exports.getExchangeConfig = getExchangeConfig;
|
|
8
|
-
exports.requiresPassphrase = requiresPassphrase;
|
|
9
|
-
exports.isDEX = isDEX;
|
|
10
|
-
exports.getAuthFields = getAuthFields;
|
|
11
|
-
exports.EXCHANGE_CONFIGS = {
|
|
12
|
-
binance: {
|
|
13
|
-
id: 'binance',
|
|
14
|
-
name: 'Binance',
|
|
15
|
-
displayName: '币安',
|
|
16
|
-
type: 'cex',
|
|
17
|
-
authType: 'api_key',
|
|
18
|
-
enabled: true,
|
|
19
|
-
priority: 1,
|
|
20
|
-
authFields: {
|
|
21
|
-
apiKey: true,
|
|
22
|
-
secretKey: true,
|
|
23
|
-
},
|
|
24
|
-
features: {
|
|
25
|
-
spot: true,
|
|
26
|
-
futures: true,
|
|
27
|
-
margin: true,
|
|
28
|
-
},
|
|
29
|
-
helpUrl: 'https://www.binance.com/zh-CN/support/faq/how-to-create-api-keys-on-binance-360002502072',
|
|
30
|
-
},
|
|
31
|
-
bybit: {
|
|
32
|
-
id: 'bybit',
|
|
33
|
-
name: 'Bybit',
|
|
34
|
-
displayName: 'Bybit',
|
|
35
|
-
type: 'cex',
|
|
36
|
-
authType: 'api_key',
|
|
37
|
-
enabled: true,
|
|
38
|
-
priority: 2,
|
|
39
|
-
authFields: {
|
|
40
|
-
apiKey: true,
|
|
41
|
-
secretKey: true,
|
|
42
|
-
},
|
|
43
|
-
features: {
|
|
44
|
-
spot: true,
|
|
45
|
-
futures: true,
|
|
46
|
-
margin: false,
|
|
47
|
-
},
|
|
48
|
-
helpUrl: 'https://www.bybit.com/zh-TW/help-center/bybitHC_Article/?id=000001966',
|
|
49
|
-
},
|
|
50
|
-
okx: {
|
|
51
|
-
id: 'okx',
|
|
52
|
-
name: 'OKX',
|
|
53
|
-
displayName: 'OKX',
|
|
54
|
-
type: 'cex',
|
|
55
|
-
authType: 'api_key',
|
|
56
|
-
enabled: true,
|
|
57
|
-
priority: 3,
|
|
58
|
-
authFields: {
|
|
59
|
-
apiKey: true,
|
|
60
|
-
secretKey: true,
|
|
61
|
-
passphrase: true,
|
|
62
|
-
},
|
|
63
|
-
features: {
|
|
64
|
-
spot: true,
|
|
65
|
-
futures: true,
|
|
66
|
-
margin: true,
|
|
67
|
-
},
|
|
68
|
-
helpUrl: 'https://www.okx.com/zh-hans/help/how-do-i-create-an-api-key',
|
|
69
|
-
},
|
|
70
|
-
bitget: {
|
|
71
|
-
id: 'bitget',
|
|
72
|
-
name: 'Bitget',
|
|
73
|
-
displayName: 'Bitget',
|
|
74
|
-
type: 'cex',
|
|
75
|
-
authType: 'api_key',
|
|
76
|
-
enabled: true,
|
|
77
|
-
priority: 4,
|
|
78
|
-
authFields: {
|
|
79
|
-
apiKey: true,
|
|
80
|
-
secretKey: true,
|
|
81
|
-
passphrase: true,
|
|
82
|
-
},
|
|
83
|
-
features: {
|
|
84
|
-
spot: true,
|
|
85
|
-
futures: true,
|
|
86
|
-
margin: false,
|
|
87
|
-
},
|
|
88
|
-
helpUrl: 'https://www.bitget.com/zh-CN/academy/how-to-create-api-key',
|
|
89
|
-
},
|
|
90
|
-
hyperliquid: {
|
|
91
|
-
id: 'hyperliquid',
|
|
92
|
-
name: 'Hyperliquid',
|
|
93
|
-
displayName: 'Hyperliquid',
|
|
94
|
-
type: 'dex',
|
|
95
|
-
authType: 'wallet',
|
|
96
|
-
enabled: true,
|
|
97
|
-
priority: 5,
|
|
98
|
-
authFields: {
|
|
99
|
-
privateKey: true,
|
|
100
|
-
walletAddress: true,
|
|
101
|
-
},
|
|
102
|
-
features: {
|
|
103
|
-
spot: false,
|
|
104
|
-
futures: true,
|
|
105
|
-
margin: false,
|
|
106
|
-
},
|
|
107
|
-
helpUrl: 'https://hyperliquid.gitbook.io/hyperliquid-docs',
|
|
108
|
-
},
|
|
109
|
-
aster: {
|
|
110
|
-
id: 'aster',
|
|
111
|
-
name: 'Aster',
|
|
112
|
-
displayName: 'Aster DEX',
|
|
113
|
-
type: 'dex',
|
|
114
|
-
authType: 'wallet',
|
|
115
|
-
enabled: true,
|
|
116
|
-
priority: 6,
|
|
117
|
-
authFields: {
|
|
118
|
-
privateKey: true,
|
|
119
|
-
walletAddress: true,
|
|
120
|
-
},
|
|
121
|
-
features: {
|
|
122
|
-
spot: false,
|
|
123
|
-
futures: true,
|
|
124
|
-
margin: false,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
lighter: {
|
|
128
|
-
id: 'lighter',
|
|
129
|
-
name: 'Lighter',
|
|
130
|
-
displayName: 'Lighter',
|
|
131
|
-
type: 'dex',
|
|
132
|
-
authType: 'wallet',
|
|
133
|
-
enabled: true,
|
|
134
|
-
priority: 7,
|
|
135
|
-
authFields: {
|
|
136
|
-
privateKey: true,
|
|
137
|
-
walletAddress: true,
|
|
138
|
-
},
|
|
139
|
-
features: {
|
|
140
|
-
spot: false,
|
|
141
|
-
futures: true,
|
|
142
|
-
margin: false,
|
|
143
|
-
},
|
|
144
|
-
helpUrl: 'https://docs.lighter.xyz/',
|
|
145
|
-
},
|
|
146
|
-
};
|
|
147
|
-
function getEnabledExchanges() {
|
|
148
|
-
return Object.values(exports.EXCHANGE_CONFIGS)
|
|
149
|
-
.filter(config => config.enabled)
|
|
150
|
-
.sort((a, b) => a.priority - b.priority);
|
|
151
|
-
}
|
|
152
|
-
function getCEXExchanges() {
|
|
153
|
-
return getEnabledExchanges().filter(config => config.type === 'cex');
|
|
154
|
-
}
|
|
155
|
-
function getDEXExchanges() {
|
|
156
|
-
return getEnabledExchanges().filter(config => config.type === 'dex');
|
|
157
|
-
}
|
|
158
|
-
function getExchangeConfig(exchangeId) {
|
|
159
|
-
return exports.EXCHANGE_CONFIGS[exchangeId.toLowerCase()];
|
|
160
|
-
}
|
|
161
|
-
function requiresPassphrase(exchangeId) {
|
|
162
|
-
const config = getExchangeConfig(exchangeId);
|
|
163
|
-
return config?.authFields.passphrase ?? false;
|
|
164
|
-
}
|
|
165
|
-
function isDEX(exchangeId) {
|
|
166
|
-
const config = getExchangeConfig(exchangeId);
|
|
167
|
-
return config?.type === 'dex';
|
|
168
|
-
}
|
|
169
|
-
function getAuthFields(exchangeId) {
|
|
170
|
-
const config = getExchangeConfig(exchangeId);
|
|
171
|
-
if (!config)
|
|
172
|
-
return [];
|
|
173
|
-
const fields = [];
|
|
174
|
-
if (config.authFields.apiKey)
|
|
175
|
-
fields.push('apiKey');
|
|
176
|
-
if (config.authFields.secretKey)
|
|
177
|
-
fields.push('secretKey');
|
|
178
|
-
if (config.authFields.passphrase)
|
|
179
|
-
fields.push('passphrase');
|
|
180
|
-
if (config.authFields.privateKey)
|
|
181
|
-
fields.push('privateKey');
|
|
182
|
-
if (config.authFields.walletAddress)
|
|
183
|
-
fields.push('walletAddress');
|
|
184
|
-
return fields;
|
|
185
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { useBinanceData } from './useBinanceData';
|
|
2
|
-
export type { UseBinanceDataReturn } from './useBinanceData';
|
|
3
|
-
export { useBinanceDialogs } from './useBinanceDialogs';
|
|
4
|
-
export type { UseBinanceDialogsReturn, DialogType } from './useBinanceDialogs';
|
|
5
|
-
export { useUserExchanges } from './useUserExchanges';
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useUserExchanges = exports.useBinanceDialogs = exports.useBinanceData = void 0;
|
|
4
|
-
// AI-generated · AI-managed · AI-maintained
|
|
5
|
-
var useBinanceData_1 = require("./useBinanceData");
|
|
6
|
-
Object.defineProperty(exports, "useBinanceData", { enumerable: true, get: function () { return useBinanceData_1.useBinanceData; } });
|
|
7
|
-
var useBinanceDialogs_1 = require("./useBinanceDialogs");
|
|
8
|
-
Object.defineProperty(exports, "useBinanceDialogs", { enumerable: true, get: function () { return useBinanceDialogs_1.useBinanceDialogs; } });
|
|
9
|
-
var useUserExchanges_1 = require("./useUserExchanges");
|
|
10
|
-
Object.defineProperty(exports, "useUserExchanges", { enumerable: true, get: function () { return useUserExchanges_1.useUserExchanges; } });
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AccountBalance, Position, OpenOrder, Trade, GroupedPosition, GroupedOrders, GroupedTrades } from "../types";
|
|
2
|
-
export interface UseBinanceDataReturn {
|
|
3
|
-
userId: string | null;
|
|
4
|
-
accountBalance: AccountBalance | null;
|
|
5
|
-
positions: Position[];
|
|
6
|
-
openOrders: OpenOrder[];
|
|
7
|
-
trades: Trade[];
|
|
8
|
-
groupedPositions: GroupedPosition[];
|
|
9
|
-
groupedOrders: GroupedOrders[];
|
|
10
|
-
groupedTrades: GroupedTrades[];
|
|
11
|
-
loading: boolean;
|
|
12
|
-
error: string | null;
|
|
13
|
-
fetchData: () => Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
export declare function useBinanceData(): UseBinanceDataReturn;
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// AI-generated · AI-managed · AI-maintained
|
|
3
|
-
"use client";
|
|
4
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
5
|
-
if (k2 === undefined) k2 = k;
|
|
6
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
7
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
8
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
9
|
-
}
|
|
10
|
-
Object.defineProperty(o, k2, desc);
|
|
11
|
-
}) : (function(o, m, k, k2) {
|
|
12
|
-
if (k2 === undefined) k2 = k;
|
|
13
|
-
o[k2] = m[k];
|
|
14
|
-
}));
|
|
15
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
16
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
17
|
-
}) : function(o, v) {
|
|
18
|
-
o["default"] = v;
|
|
19
|
-
});
|
|
20
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
21
|
-
var ownKeys = function(o) {
|
|
22
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
23
|
-
var ar = [];
|
|
24
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
25
|
-
return ar;
|
|
26
|
-
};
|
|
27
|
-
return ownKeys(o);
|
|
28
|
-
};
|
|
29
|
-
return function (mod) {
|
|
30
|
-
if (mod && mod.__esModule) return mod;
|
|
31
|
-
var result = {};
|
|
32
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
33
|
-
__setModuleDefault(result, mod);
|
|
34
|
-
return result;
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.useBinanceData = useBinanceData;
|
|
39
|
-
const react_1 = require("react");
|
|
40
|
-
const auth_service_1 = require("../../auth-service");
|
|
41
|
-
function useBinanceData() {
|
|
42
|
-
const [userId, setUserId] = (0, react_1.useState)(null);
|
|
43
|
-
const [loading, setLoading] = (0, react_1.useState)(true);
|
|
44
|
-
const [error, setError] = (0, react_1.useState)(null);
|
|
45
|
-
const [accountBalance, setAccountBalance] = (0, react_1.useState)(null);
|
|
46
|
-
const [positions, setPositions] = (0, react_1.useState)([]);
|
|
47
|
-
const [openOrders, setOpenOrders] = (0, react_1.useState)([]);
|
|
48
|
-
const [trades, setTrades] = (0, react_1.useState)([]);
|
|
49
|
-
(0, react_1.useEffect)(() => {
|
|
50
|
-
const unsubscribe = (0, auth_service_1.onAuthChange)((user) => {
|
|
51
|
-
if (user?.uid) {
|
|
52
|
-
setUserId(user.uid);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
setUserId(null);
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
return () => unsubscribe();
|
|
59
|
-
}, []);
|
|
60
|
-
const fetchData = (0, react_1.useCallback)(async () => {
|
|
61
|
-
if (!userId)
|
|
62
|
-
return;
|
|
63
|
-
setLoading(true);
|
|
64
|
-
setError(null);
|
|
65
|
-
try {
|
|
66
|
-
const { getCurrentUserToken } = await Promise.resolve().then(() => __importStar(require('../../auth-service')));
|
|
67
|
-
const token = await getCurrentUserToken();
|
|
68
|
-
if (!token) {
|
|
69
|
-
setError("用户未登录");
|
|
70
|
-
setLoading(false);
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
const balanceRes = (0, auth_service_1.guardAuthResponse)(await fetch(`/api/exchanges/binance/account`, {
|
|
74
|
-
headers: {
|
|
75
|
-
'Authorization': `Bearer ${token}`
|
|
76
|
-
}
|
|
77
|
-
}));
|
|
78
|
-
if (balanceRes.ok) {
|
|
79
|
-
const data = await balanceRes.json();
|
|
80
|
-
setAccountBalance(data);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const errorData = await balanceRes.json();
|
|
84
|
-
throw new Error(errorData.error || '获取账户信息失败');
|
|
85
|
-
}
|
|
86
|
-
const positionsRes = (0, auth_service_1.guardAuthResponse)(await fetch(`/api/exchanges/binance/positions`, {
|
|
87
|
-
headers: {
|
|
88
|
-
'Authorization': `Bearer ${token}`
|
|
89
|
-
}
|
|
90
|
-
}));
|
|
91
|
-
if (positionsRes.ok) {
|
|
92
|
-
const data = await positionsRes.json();
|
|
93
|
-
setPositions(data.positions || []);
|
|
94
|
-
}
|
|
95
|
-
const ordersRes = (0, auth_service_1.guardAuthResponse)(await fetch(`/api/exchanges/binance/orders`, {
|
|
96
|
-
headers: {
|
|
97
|
-
'Authorization': `Bearer ${token}`
|
|
98
|
-
}
|
|
99
|
-
}));
|
|
100
|
-
if (ordersRes.ok) {
|
|
101
|
-
const data = await ordersRes.json();
|
|
102
|
-
setOpenOrders(data.orders || []);
|
|
103
|
-
}
|
|
104
|
-
const tradesRes = (0, auth_service_1.guardAuthResponse)(await fetch(`/api/exchanges/binance/history`, {
|
|
105
|
-
headers: {
|
|
106
|
-
'Authorization': `Bearer ${token}`
|
|
107
|
-
}
|
|
108
|
-
}));
|
|
109
|
-
if (tradesRes.ok) {
|
|
110
|
-
const data = await tradesRes.json();
|
|
111
|
-
setTrades(data.trades || []);
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (err) {
|
|
115
|
-
setError(err instanceof Error ? err.message : "获取数据失败");
|
|
116
|
-
}
|
|
117
|
-
finally {
|
|
118
|
-
setLoading(false);
|
|
119
|
-
}
|
|
120
|
-
}, [userId]);
|
|
121
|
-
(0, react_1.useEffect)(() => {
|
|
122
|
-
if (userId) {
|
|
123
|
-
fetchData();
|
|
124
|
-
}
|
|
125
|
-
}, [userId, fetchData]);
|
|
126
|
-
const getGroupedPositions = (0, react_1.useCallback)(() => {
|
|
127
|
-
const groups = new Map();
|
|
128
|
-
positions.forEach(pos => {
|
|
129
|
-
if (!groups.has(pos.symbol)) {
|
|
130
|
-
groups.set(pos.symbol, {
|
|
131
|
-
symbol: pos.symbol,
|
|
132
|
-
totalUnrealizedProfit: 0,
|
|
133
|
-
orders: []
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
const group = groups.get(pos.symbol);
|
|
137
|
-
if (pos.side === "LONG") {
|
|
138
|
-
group.longPosition = pos;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
group.shortPosition = pos;
|
|
142
|
-
}
|
|
143
|
-
group.totalUnrealizedProfit += pos.unrealizedProfit;
|
|
144
|
-
});
|
|
145
|
-
openOrders.forEach(order => {
|
|
146
|
-
if (groups.has(order.symbol)) {
|
|
147
|
-
groups.get(order.symbol).orders.push(order);
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
groups.forEach(group => {
|
|
151
|
-
group.orders.sort((a, b) => {
|
|
152
|
-
const timeA = typeof a.time === 'number' ? a.time : new Date(a.time).getTime();
|
|
153
|
-
const timeB = typeof b.time === 'number' ? b.time : new Date(b.time).getTime();
|
|
154
|
-
return timeB - timeA;
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
return Array.from(groups.values()).sort((a, b) => b.totalUnrealizedProfit - a.totalUnrealizedProfit);
|
|
158
|
-
}, [positions, openOrders]);
|
|
159
|
-
const getGroupedOrders = (0, react_1.useCallback)(() => {
|
|
160
|
-
const groups = new Map();
|
|
161
|
-
openOrders.forEach(order => {
|
|
162
|
-
if (!groups.has(order.symbol)) {
|
|
163
|
-
groups.set(order.symbol, {
|
|
164
|
-
symbol: order.symbol,
|
|
165
|
-
orders: [],
|
|
166
|
-
totalQuantity: 0
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
const group = groups.get(order.symbol);
|
|
170
|
-
group.orders.push(order);
|
|
171
|
-
group.totalQuantity += order.quantity - order.filled;
|
|
172
|
-
});
|
|
173
|
-
groups.forEach(group => {
|
|
174
|
-
group.orders.sort((a, b) => {
|
|
175
|
-
const timeA = typeof a.time === 'number' ? a.time : new Date(a.time).getTime();
|
|
176
|
-
const timeB = typeof b.time === 'number' ? b.time : new Date(b.time).getTime();
|
|
177
|
-
return timeB - timeA;
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
return Array.from(groups.values()).sort((a, b) => b.orders.length - a.orders.length);
|
|
181
|
-
}, [openOrders]);
|
|
182
|
-
const getGroupedTrades = (0, react_1.useCallback)(() => {
|
|
183
|
-
const groups = new Map();
|
|
184
|
-
trades.forEach(trade => {
|
|
185
|
-
if (!groups.has(trade.symbol)) {
|
|
186
|
-
groups.set(trade.symbol, {
|
|
187
|
-
symbol: trade.symbol,
|
|
188
|
-
trades: [],
|
|
189
|
-
totalRealizedPnl: 0,
|
|
190
|
-
totalVolume: 0
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
const group = groups.get(trade.symbol);
|
|
194
|
-
group.trades.push(trade);
|
|
195
|
-
group.totalRealizedPnl += trade.realizedPnl;
|
|
196
|
-
group.totalVolume += trade.quantity;
|
|
197
|
-
});
|
|
198
|
-
groups.forEach(group => {
|
|
199
|
-
group.trades.sort((a, b) => b.time - a.time);
|
|
200
|
-
});
|
|
201
|
-
return Array.from(groups.values()).sort((a, b) => b.totalRealizedPnl - a.totalRealizedPnl);
|
|
202
|
-
}, [trades]);
|
|
203
|
-
return {
|
|
204
|
-
userId,
|
|
205
|
-
accountBalance,
|
|
206
|
-
positions,
|
|
207
|
-
openOrders,
|
|
208
|
-
trades,
|
|
209
|
-
groupedPositions: getGroupedPositions(),
|
|
210
|
-
groupedOrders: getGroupedOrders(),
|
|
211
|
-
groupedTrades: getGroupedTrades(),
|
|
212
|
-
loading,
|
|
213
|
-
error,
|
|
214
|
-
fetchData
|
|
215
|
-
};
|
|
216
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { OpenOrder, Position, CleanupProgress, CleanupPreview } from "../types";
|
|
2
|
-
export type DialogType = 'cancel' | 'modify' | 'add' | 'close' | 'cleanup' | null;
|
|
3
|
-
export interface UseBinanceDialogsReturn {
|
|
4
|
-
dialogOpen: boolean;
|
|
5
|
-
dialogType: DialogType;
|
|
6
|
-
selectedOrder: OpenOrder | null;
|
|
7
|
-
selectedPosition: Position | null;
|
|
8
|
-
dialogLoading: boolean;
|
|
9
|
-
inputPrice: string;
|
|
10
|
-
inputQuantity: string;
|
|
11
|
-
orderType: 'MARKET' | 'LIMIT';
|
|
12
|
-
cleanupSymbol: string;
|
|
13
|
-
cleanupPreview: CleanupPreview | null;
|
|
14
|
-
cleanupLoading: boolean;
|
|
15
|
-
cleanupJobId: string | null;
|
|
16
|
-
cleanupProgress: CleanupProgress | null;
|
|
17
|
-
setInputPrice: (value: string) => void;
|
|
18
|
-
setInputQuantity: (value: string) => void;
|
|
19
|
-
setOrderType: (value: 'MARKET' | 'LIMIT') => void;
|
|
20
|
-
handleOpenCancelDialog: (order: OpenOrder) => void;
|
|
21
|
-
handleOpenModifyDialog: (order: OpenOrder) => void;
|
|
22
|
-
handleOpenAddDialog: (position: Position) => void;
|
|
23
|
-
handleOpenCloseDialog: (position: Position) => void;
|
|
24
|
-
handleOpenCleanupDialog: (symbol: string) => Promise<void>;
|
|
25
|
-
handleCloseDialog: () => void;
|
|
26
|
-
handleCancelOrder: () => Promise<void>;
|
|
27
|
-
handleModifyOrder: () => Promise<void>;
|
|
28
|
-
handleAddPosition: () => Promise<void>;
|
|
29
|
-
handleClosePosition: () => Promise<void>;
|
|
30
|
-
handleExecuteCleanup: () => Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
export declare function useBinanceDialogs(fetchData: () => Promise<void>): UseBinanceDialogsReturn;
|