n8n-nodes-bitget 1.0.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/COMMERCIAL_LICENSE.md +31 -0
- package/LICENSE +46 -0
- package/LICENSING_FAQ.md +18 -0
- package/README.md +356 -0
- package/dist/credentials/BitgetApi.credentials.d.ts +8 -0
- package/dist/credentials/BitgetApi.credentials.d.ts.map +1 -0
- package/dist/credentials/BitgetApi.credentials.js +67 -0
- package/dist/credentials/BitgetApi.credentials.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/nodes/Bitget/Bitget.node.d.ts +6 -0
- package/dist/nodes/Bitget/Bitget.node.d.ts.map +1 -0
- package/dist/nodes/Bitget/Bitget.node.js +994 -0
- package/dist/nodes/Bitget/Bitget.node.js.map +1 -0
- package/dist/nodes/Bitget/BitgetTrigger.node.d.ts +6 -0
- package/dist/nodes/Bitget/BitgetTrigger.node.d.ts.map +1 -0
- package/dist/nodes/Bitget/BitgetTrigger.node.js +576 -0
- package/dist/nodes/Bitget/BitgetTrigger.node.js.map +1 -0
- package/dist/nodes/Bitget/actions/copyTrading/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/copyTrading/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/copyTrading/index.js +519 -0
- package/dist/nodes/Bitget/actions/copyTrading/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/earn/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/earn/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/earn/index.js +326 -0
- package/dist/nodes/Bitget/actions/earn/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/futuresAccount/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/futuresAccount/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/futuresAccount/index.js +335 -0
- package/dist/nodes/Bitget/actions/futuresAccount/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/futuresTrading/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/futuresTrading/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/futuresTrading/index.js +933 -0
- package/dist/nodes/Bitget/actions/futuresTrading/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/marketData/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/marketData/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/marketData/index.js +303 -0
- package/dist/nodes/Bitget/actions/marketData/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/spotAccount/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/spotAccount/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/spotAccount/index.js +314 -0
- package/dist/nodes/Bitget/actions/spotAccount/index.js.map +1 -0
- package/dist/nodes/Bitget/actions/spotTrading/index.d.ts +4 -0
- package/dist/nodes/Bitget/actions/spotTrading/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/actions/spotTrading/index.js +575 -0
- package/dist/nodes/Bitget/actions/spotTrading/index.js.map +1 -0
- package/dist/nodes/Bitget/bitget.svg +11 -0
- package/dist/nodes/Bitget/constants/index.d.ts +90 -0
- package/dist/nodes/Bitget/constants/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/constants/index.js +127 -0
- package/dist/nodes/Bitget/constants/index.js.map +1 -0
- package/dist/nodes/Bitget/transport/index.d.ts +22 -0
- package/dist/nodes/Bitget/transport/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/transport/index.js +267 -0
- package/dist/nodes/Bitget/transport/index.js.map +1 -0
- package/dist/nodes/Bitget/types/BitgetTypes.d.ts +396 -0
- package/dist/nodes/Bitget/types/BitgetTypes.d.ts.map +1 -0
- package/dist/nodes/Bitget/types/BitgetTypes.js +74 -0
- package/dist/nodes/Bitget/types/BitgetTypes.js.map +1 -0
- package/dist/nodes/Bitget/utils/index.d.ts +76 -0
- package/dist/nodes/Bitget/utils/index.d.ts.map +1 -0
- package/dist/nodes/Bitget/utils/index.js +210 -0
- package/dist/nodes/Bitget/utils/index.js.map +1 -0
- package/package.json +92 -0
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
export declare const BITGET_API_BASE_URL = "https://api.bitget.com";
|
|
2
|
+
export declare const ENDPOINTS: {
|
|
3
|
+
readonly SPOT_ACCOUNT_ASSETS: "/api/v2/spot/account/assets";
|
|
4
|
+
readonly SPOT_ACCOUNT_BILLS: "/api/v2/spot/account/bills";
|
|
5
|
+
readonly SPOT_WALLET_TRANSFER: "/api/v2/spot/wallet/transfer";
|
|
6
|
+
readonly SPOT_WALLET_TRANSFER_RECORDS: "/api/v2/spot/wallet/transfer-records";
|
|
7
|
+
readonly SPOT_TRADE_PLACE_ORDER: "/api/v2/spot/trade/place-order";
|
|
8
|
+
readonly SPOT_TRADE_BATCH_ORDERS: "/api/v2/spot/trade/batch-orders";
|
|
9
|
+
readonly SPOT_TRADE_CANCEL_ORDER: "/api/v2/spot/trade/cancel-order";
|
|
10
|
+
readonly SPOT_TRADE_BATCH_CANCEL: "/api/v2/spot/trade/batch-cancel-order";
|
|
11
|
+
readonly SPOT_TRADE_OPEN_ORDERS: "/api/v2/spot/trade/unfilled-orders";
|
|
12
|
+
readonly SPOT_TRADE_HISTORY_ORDERS: "/api/v2/spot/trade/history-orders";
|
|
13
|
+
readonly SPOT_TRADE_ORDER_INFO: "/api/v2/spot/trade/orderInfo";
|
|
14
|
+
readonly SPOT_TRADE_FILLS: "/api/v2/spot/trade/fills";
|
|
15
|
+
readonly FUTURES_ACCOUNT: "/api/v2/mix/account/account";
|
|
16
|
+
readonly FUTURES_ACCOUNTS: "/api/v2/mix/account/accounts";
|
|
17
|
+
readonly FUTURES_POSITIONS: "/api/v2/mix/position/all-position";
|
|
18
|
+
readonly FUTURES_SINGLE_POSITION: "/api/v2/mix/position/single-position";
|
|
19
|
+
readonly FUTURES_SET_LEVERAGE: "/api/v2/mix/account/set-leverage";
|
|
20
|
+
readonly FUTURES_SET_MARGIN_MODE: "/api/v2/mix/account/set-margin-mode";
|
|
21
|
+
readonly FUTURES_BILLS: "/api/v2/mix/account/bill";
|
|
22
|
+
readonly FUTURES_PLACE_ORDER: "/api/v2/mix/order/place-order";
|
|
23
|
+
readonly FUTURES_BATCH_ORDERS: "/api/v2/mix/order/batch-place-order";
|
|
24
|
+
readonly FUTURES_MODIFY_ORDER: "/api/v2/mix/order/modify-order";
|
|
25
|
+
readonly FUTURES_CANCEL_ORDER: "/api/v2/mix/order/cancel-order";
|
|
26
|
+
readonly FUTURES_CANCEL_ALL_ORDERS: "/api/v2/mix/order/cancel-all-orders";
|
|
27
|
+
readonly FUTURES_OPEN_ORDERS: "/api/v2/mix/order/orders-pending";
|
|
28
|
+
readonly FUTURES_HISTORY_ORDERS: "/api/v2/mix/order/orders-history";
|
|
29
|
+
readonly FUTURES_FILLS: "/api/v2/mix/order/fills";
|
|
30
|
+
readonly FUTURES_PLACE_PLAN_ORDER: "/api/v2/mix/order/place-plan-order";
|
|
31
|
+
readonly FUTURES_CANCEL_PLAN_ORDER: "/api/v2/mix/order/cancel-plan-order";
|
|
32
|
+
readonly FUTURES_PLAN_ORDERS: "/api/v2/mix/order/orders-plan-pending";
|
|
33
|
+
readonly COPY_TRADERS: "/api/v2/copy/mix-trader/trader-list";
|
|
34
|
+
readonly COPY_TRADER_POSITIONS: "/api/v2/copy/mix-trader/query-current-orders";
|
|
35
|
+
readonly COPY_FOLLOW_TRADER: "/api/v2/copy/mix-follower/set-follow";
|
|
36
|
+
readonly COPY_UNFOLLOW_TRADER: "/api/v2/copy/mix-follower/cancel-follow";
|
|
37
|
+
readonly COPY_FOLLOW_SETTINGS: "/api/v2/copy/mix-follower/query-settings";
|
|
38
|
+
readonly COPY_UPDATE_SETTINGS: "/api/v2/copy/mix-follower/update-settings";
|
|
39
|
+
readonly COPY_FOLLOWER_HISTORY: "/api/v2/copy/mix-follower/query-history-orders";
|
|
40
|
+
readonly COPY_CLOSE_POSITION: "/api/v2/copy/mix-follower/close-positions";
|
|
41
|
+
readonly MARKET_TICKERS: "/api/v2/spot/market/tickers";
|
|
42
|
+
readonly MARKET_TICKER: "/api/v2/spot/market/ticker";
|
|
43
|
+
readonly MARKET_ORDERBOOK: "/api/v2/spot/market/orderbook";
|
|
44
|
+
readonly MARKET_CANDLES: "/api/v2/spot/market/candles";
|
|
45
|
+
readonly MARKET_TRADES: "/api/v2/spot/market/fills";
|
|
46
|
+
readonly MARKET_SYMBOLS: "/api/v2/spot/public/symbols";
|
|
47
|
+
readonly MARKET_SERVER_TIME: "/api/v2/public/time";
|
|
48
|
+
readonly FUTURES_MARKET_TICKERS: "/api/v2/mix/market/tickers";
|
|
49
|
+
readonly FUTURES_MARKET_TICKER: "/api/v2/mix/market/ticker";
|
|
50
|
+
readonly FUTURES_MARKET_ORDERBOOK: "/api/v2/mix/market/depth";
|
|
51
|
+
readonly FUTURES_MARKET_CANDLES: "/api/v2/mix/market/candles";
|
|
52
|
+
readonly FUTURES_MARKET_TRADES: "/api/v2/mix/market/fills";
|
|
53
|
+
readonly FUTURES_MARKET_SYMBOLS: "/api/v2/mix/market/contracts";
|
|
54
|
+
readonly EARN_PRODUCTS: "/api/v2/earn/savings/product";
|
|
55
|
+
readonly EARN_SUBSCRIBE: "/api/v2/earn/savings/subscribe";
|
|
56
|
+
readonly EARN_REDEEM: "/api/v2/earn/savings/redeem";
|
|
57
|
+
readonly EARN_SUBSCRIPTIONS: "/api/v2/earn/savings/assets";
|
|
58
|
+
readonly EARN_HISTORY: "/api/v2/earn/savings/records";
|
|
59
|
+
};
|
|
60
|
+
export declare const ERROR_MESSAGES: {
|
|
61
|
+
readonly INVALID_API_KEY: "Invalid API key. Please check your credentials.";
|
|
62
|
+
readonly INVALID_SIGNATURE: "Invalid signature. Please check your secret key.";
|
|
63
|
+
readonly INVALID_TIMESTAMP: "Invalid timestamp. Please check your system time.";
|
|
64
|
+
readonly API_KEY_EXPIRED: "API key has expired. Please generate a new one.";
|
|
65
|
+
readonly PERMISSION_DENIED: "Permission denied. Check your API key permissions.";
|
|
66
|
+
readonly RATE_LIMITED: "Rate limit exceeded. Please wait before retrying.";
|
|
67
|
+
readonly IP_NOT_WHITELISTED: "IP not whitelisted. Add your IP to the API key settings.";
|
|
68
|
+
readonly INSUFFICIENT_BALANCE: "Insufficient balance for this operation.";
|
|
69
|
+
readonly ORDER_NOT_FOUND: "Order not found.";
|
|
70
|
+
readonly ORDER_ALREADY_CANCELLED: "Order has already been cancelled.";
|
|
71
|
+
readonly POSITION_NOT_FOUND: "Position not found.";
|
|
72
|
+
readonly LEVERAGE_EXCEEDS_LIMIT: "Leverage exceeds the maximum allowed for this pair.";
|
|
73
|
+
readonly UNKNOWN_ERROR: "An unknown error occurred. Please try again.";
|
|
74
|
+
};
|
|
75
|
+
export declare const ERROR_CODE_MAP: Record<string, string>;
|
|
76
|
+
export declare const DEFAULTS: {
|
|
77
|
+
readonly PAGE_SIZE: 100;
|
|
78
|
+
readonly MAX_BATCH_ORDERS: 50;
|
|
79
|
+
readonly MIN_LEVERAGE: 1;
|
|
80
|
+
readonly MAX_LEVERAGE: 125;
|
|
81
|
+
readonly MAX_RETRY_ATTEMPTS: 3;
|
|
82
|
+
readonly RETRY_DELAY_MS: 1000;
|
|
83
|
+
};
|
|
84
|
+
export declare const RATE_LIMITS: {
|
|
85
|
+
readonly DEFAULT: 10;
|
|
86
|
+
readonly ORDERS: 10;
|
|
87
|
+
readonly MARKET_DATA: 20;
|
|
88
|
+
readonly ACCOUNT: 10;
|
|
89
|
+
};
|
|
90
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../nodes/Bitget/constants/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,mBAAmB,2BAA2B,CAAC;AAG5D,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwEZ,CAAC;AAGX,eAAO,MAAM,cAAc;;;;;;;;;;;;;;CAcjB,CAAC;AAGX,eAAO,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAcjD,CAAC;AAGF,eAAO,MAAM,QAAQ;;;;;;;CAOX,CAAC;AAGX,eAAO,MAAM,WAAW;;;;;CAKd,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Velocity BPA, LLC
|
|
4
|
+
* Licensed under the Business Source License 1.1
|
|
5
|
+
* Commercial use requires a separate commercial license.
|
|
6
|
+
* See LICENSE file for details.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.RATE_LIMITS = exports.DEFAULTS = exports.ERROR_CODE_MAP = exports.ERROR_MESSAGES = exports.ENDPOINTS = exports.BITGET_API_BASE_URL = void 0;
|
|
10
|
+
// API Configuration
|
|
11
|
+
exports.BITGET_API_BASE_URL = 'https://api.bitget.com';
|
|
12
|
+
// API Endpoints
|
|
13
|
+
exports.ENDPOINTS = {
|
|
14
|
+
// Spot Account
|
|
15
|
+
SPOT_ACCOUNT_ASSETS: '/api/v2/spot/account/assets',
|
|
16
|
+
SPOT_ACCOUNT_BILLS: '/api/v2/spot/account/bills',
|
|
17
|
+
SPOT_WALLET_TRANSFER: '/api/v2/spot/wallet/transfer',
|
|
18
|
+
SPOT_WALLET_TRANSFER_RECORDS: '/api/v2/spot/wallet/transfer-records',
|
|
19
|
+
// Spot Trading
|
|
20
|
+
SPOT_TRADE_PLACE_ORDER: '/api/v2/spot/trade/place-order',
|
|
21
|
+
SPOT_TRADE_BATCH_ORDERS: '/api/v2/spot/trade/batch-orders',
|
|
22
|
+
SPOT_TRADE_CANCEL_ORDER: '/api/v2/spot/trade/cancel-order',
|
|
23
|
+
SPOT_TRADE_BATCH_CANCEL: '/api/v2/spot/trade/batch-cancel-order',
|
|
24
|
+
SPOT_TRADE_OPEN_ORDERS: '/api/v2/spot/trade/unfilled-orders',
|
|
25
|
+
SPOT_TRADE_HISTORY_ORDERS: '/api/v2/spot/trade/history-orders',
|
|
26
|
+
SPOT_TRADE_ORDER_INFO: '/api/v2/spot/trade/orderInfo',
|
|
27
|
+
SPOT_TRADE_FILLS: '/api/v2/spot/trade/fills',
|
|
28
|
+
// Futures Account
|
|
29
|
+
FUTURES_ACCOUNT: '/api/v2/mix/account/account',
|
|
30
|
+
FUTURES_ACCOUNTS: '/api/v2/mix/account/accounts',
|
|
31
|
+
FUTURES_POSITIONS: '/api/v2/mix/position/all-position',
|
|
32
|
+
FUTURES_SINGLE_POSITION: '/api/v2/mix/position/single-position',
|
|
33
|
+
FUTURES_SET_LEVERAGE: '/api/v2/mix/account/set-leverage',
|
|
34
|
+
FUTURES_SET_MARGIN_MODE: '/api/v2/mix/account/set-margin-mode',
|
|
35
|
+
FUTURES_BILLS: '/api/v2/mix/account/bill',
|
|
36
|
+
// Futures Trading
|
|
37
|
+
FUTURES_PLACE_ORDER: '/api/v2/mix/order/place-order',
|
|
38
|
+
FUTURES_BATCH_ORDERS: '/api/v2/mix/order/batch-place-order',
|
|
39
|
+
FUTURES_MODIFY_ORDER: '/api/v2/mix/order/modify-order',
|
|
40
|
+
FUTURES_CANCEL_ORDER: '/api/v2/mix/order/cancel-order',
|
|
41
|
+
FUTURES_CANCEL_ALL_ORDERS: '/api/v2/mix/order/cancel-all-orders',
|
|
42
|
+
FUTURES_OPEN_ORDERS: '/api/v2/mix/order/orders-pending',
|
|
43
|
+
FUTURES_HISTORY_ORDERS: '/api/v2/mix/order/orders-history',
|
|
44
|
+
FUTURES_FILLS: '/api/v2/mix/order/fills',
|
|
45
|
+
FUTURES_PLACE_PLAN_ORDER: '/api/v2/mix/order/place-plan-order',
|
|
46
|
+
FUTURES_CANCEL_PLAN_ORDER: '/api/v2/mix/order/cancel-plan-order',
|
|
47
|
+
FUTURES_PLAN_ORDERS: '/api/v2/mix/order/orders-plan-pending',
|
|
48
|
+
// Copy Trading
|
|
49
|
+
COPY_TRADERS: '/api/v2/copy/mix-trader/trader-list',
|
|
50
|
+
COPY_TRADER_POSITIONS: '/api/v2/copy/mix-trader/query-current-orders',
|
|
51
|
+
COPY_FOLLOW_TRADER: '/api/v2/copy/mix-follower/set-follow',
|
|
52
|
+
COPY_UNFOLLOW_TRADER: '/api/v2/copy/mix-follower/cancel-follow',
|
|
53
|
+
COPY_FOLLOW_SETTINGS: '/api/v2/copy/mix-follower/query-settings',
|
|
54
|
+
COPY_UPDATE_SETTINGS: '/api/v2/copy/mix-follower/update-settings',
|
|
55
|
+
COPY_FOLLOWER_HISTORY: '/api/v2/copy/mix-follower/query-history-orders',
|
|
56
|
+
COPY_CLOSE_POSITION: '/api/v2/copy/mix-follower/close-positions',
|
|
57
|
+
// Market Data
|
|
58
|
+
MARKET_TICKERS: '/api/v2/spot/market/tickers',
|
|
59
|
+
MARKET_TICKER: '/api/v2/spot/market/ticker',
|
|
60
|
+
MARKET_ORDERBOOK: '/api/v2/spot/market/orderbook',
|
|
61
|
+
MARKET_CANDLES: '/api/v2/spot/market/candles',
|
|
62
|
+
MARKET_TRADES: '/api/v2/spot/market/fills',
|
|
63
|
+
MARKET_SYMBOLS: '/api/v2/spot/public/symbols',
|
|
64
|
+
MARKET_SERVER_TIME: '/api/v2/public/time',
|
|
65
|
+
// Futures Market Data
|
|
66
|
+
FUTURES_MARKET_TICKERS: '/api/v2/mix/market/tickers',
|
|
67
|
+
FUTURES_MARKET_TICKER: '/api/v2/mix/market/ticker',
|
|
68
|
+
FUTURES_MARKET_ORDERBOOK: '/api/v2/mix/market/depth',
|
|
69
|
+
FUTURES_MARKET_CANDLES: '/api/v2/mix/market/candles',
|
|
70
|
+
FUTURES_MARKET_TRADES: '/api/v2/mix/market/fills',
|
|
71
|
+
FUTURES_MARKET_SYMBOLS: '/api/v2/mix/market/contracts',
|
|
72
|
+
// Earn
|
|
73
|
+
EARN_PRODUCTS: '/api/v2/earn/savings/product',
|
|
74
|
+
EARN_SUBSCRIBE: '/api/v2/earn/savings/subscribe',
|
|
75
|
+
EARN_REDEEM: '/api/v2/earn/savings/redeem',
|
|
76
|
+
EARN_SUBSCRIPTIONS: '/api/v2/earn/savings/assets',
|
|
77
|
+
EARN_HISTORY: '/api/v2/earn/savings/records',
|
|
78
|
+
};
|
|
79
|
+
// Error Messages
|
|
80
|
+
exports.ERROR_MESSAGES = {
|
|
81
|
+
INVALID_API_KEY: 'Invalid API key. Please check your credentials.',
|
|
82
|
+
INVALID_SIGNATURE: 'Invalid signature. Please check your secret key.',
|
|
83
|
+
INVALID_TIMESTAMP: 'Invalid timestamp. Please check your system time.',
|
|
84
|
+
API_KEY_EXPIRED: 'API key has expired. Please generate a new one.',
|
|
85
|
+
PERMISSION_DENIED: 'Permission denied. Check your API key permissions.',
|
|
86
|
+
RATE_LIMITED: 'Rate limit exceeded. Please wait before retrying.',
|
|
87
|
+
IP_NOT_WHITELISTED: 'IP not whitelisted. Add your IP to the API key settings.',
|
|
88
|
+
INSUFFICIENT_BALANCE: 'Insufficient balance for this operation.',
|
|
89
|
+
ORDER_NOT_FOUND: 'Order not found.',
|
|
90
|
+
ORDER_ALREADY_CANCELLED: 'Order has already been cancelled.',
|
|
91
|
+
POSITION_NOT_FOUND: 'Position not found.',
|
|
92
|
+
LEVERAGE_EXCEEDS_LIMIT: 'Leverage exceeds the maximum allowed for this pair.',
|
|
93
|
+
UNKNOWN_ERROR: 'An unknown error occurred. Please try again.',
|
|
94
|
+
};
|
|
95
|
+
// Error Code Mapping
|
|
96
|
+
exports.ERROR_CODE_MAP = {
|
|
97
|
+
'00000': 'Success',
|
|
98
|
+
'40001': exports.ERROR_MESSAGES.INVALID_API_KEY,
|
|
99
|
+
'40002': exports.ERROR_MESSAGES.INVALID_SIGNATURE,
|
|
100
|
+
'40003': exports.ERROR_MESSAGES.INVALID_TIMESTAMP,
|
|
101
|
+
'40004': exports.ERROR_MESSAGES.API_KEY_EXPIRED,
|
|
102
|
+
'40005': exports.ERROR_MESSAGES.PERMISSION_DENIED,
|
|
103
|
+
'40006': exports.ERROR_MESSAGES.RATE_LIMITED,
|
|
104
|
+
'40007': exports.ERROR_MESSAGES.IP_NOT_WHITELISTED,
|
|
105
|
+
'43001': exports.ERROR_MESSAGES.INSUFFICIENT_BALANCE,
|
|
106
|
+
'43002': exports.ERROR_MESSAGES.ORDER_NOT_FOUND,
|
|
107
|
+
'43003': exports.ERROR_MESSAGES.ORDER_ALREADY_CANCELLED,
|
|
108
|
+
'45001': exports.ERROR_MESSAGES.POSITION_NOT_FOUND,
|
|
109
|
+
'45002': exports.ERROR_MESSAGES.LEVERAGE_EXCEEDS_LIMIT,
|
|
110
|
+
};
|
|
111
|
+
// Default Values
|
|
112
|
+
exports.DEFAULTS = {
|
|
113
|
+
PAGE_SIZE: 100,
|
|
114
|
+
MAX_BATCH_ORDERS: 50,
|
|
115
|
+
MIN_LEVERAGE: 1,
|
|
116
|
+
MAX_LEVERAGE: 125,
|
|
117
|
+
MAX_RETRY_ATTEMPTS: 3,
|
|
118
|
+
RETRY_DELAY_MS: 1000,
|
|
119
|
+
};
|
|
120
|
+
// Rate Limits (requests per second)
|
|
121
|
+
exports.RATE_LIMITS = {
|
|
122
|
+
DEFAULT: 10,
|
|
123
|
+
ORDERS: 10,
|
|
124
|
+
MARKET_DATA: 20,
|
|
125
|
+
ACCOUNT: 10,
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/Bitget/constants/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,oBAAoB;AACP,QAAA,mBAAmB,GAAG,wBAAwB,CAAC;AAE5D,gBAAgB;AACH,QAAA,SAAS,GAAG;IACvB,eAAe;IACf,mBAAmB,EAAE,6BAA6B;IAClD,kBAAkB,EAAE,4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,OAAO,EAAE,sBAAc,CAAC,eAAe;IACvC,OAAO,EAAE,sBAAc,CAAC,uBAAuB;IAC/C,OAAO,EAAE,sBAAc,CAAC,kBAAkB;IAC1C,OAAO,EAAE,sBAAc,CAAC,sBAAsB;CAC/C,CAAC;AAEF,iBAAiB;AACJ,QAAA,QAAQ,GAAG;IACtB,SAAS,EAAE,GAAG;IACd,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,CAAC;IACf,YAAY,EAAE,GAAG;IACjB,kBAAkB,EAAE,CAAC;IACrB,cAAc,EAAE,IAAI;CACZ,CAAC;AAEX,oCAAoC;AACvB,QAAA,WAAW,GAAG;IACzB,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,EAAE;IACV,WAAW,EAAE,EAAE;IACf,OAAO,EAAE,EAAE;CACH,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IExecuteFunctions, ILoadOptionsFunctions, IHookFunctions, IWebhookFunctions, IPollFunctions, IHttpRequestMethods } from 'n8n-workflow';
|
|
2
|
+
/**
|
|
3
|
+
* Generate HMAC-SHA256 signature for Bitget API
|
|
4
|
+
*/
|
|
5
|
+
export declare function generateSignature(timestamp: string, method: string, requestPath: string, body: string, secretKey: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Make authenticated request to Bitget API
|
|
8
|
+
*/
|
|
9
|
+
export declare function bitgetApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions | IPollFunctions, method: IHttpRequestMethods, endpoint: string, body?: Record<string, any>, query?: Record<string, any>): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Make authenticated request with retry logic
|
|
12
|
+
*/
|
|
13
|
+
export declare function bitgetApiRequestWithRetry(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions | IPollFunctions, method: IHttpRequestMethods, endpoint: string, body?: Record<string, any>, query?: Record<string, any>, maxRetries?: number): Promise<any>;
|
|
14
|
+
/**
|
|
15
|
+
* Make paginated request to Bitget API
|
|
16
|
+
*/
|
|
17
|
+
export declare function bitgetApiRequestAllItems(this: IExecuteFunctions, method: IHttpRequestMethods, endpoint: string, body?: Record<string, any>, query?: Record<string, any>, itemsKey?: string, idKey?: string, maxItems?: number): Promise<any[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Make unauthenticated request to Bitget API (for public endpoints)
|
|
20
|
+
*/
|
|
21
|
+
export declare function bitgetPublicApiRequest(this: IExecuteFunctions | ILoadOptionsFunctions | IHookFunctions | IWebhookFunctions | IPollFunctions, method: IHttpRequestMethods, endpoint: string, query?: Record<string, any>): Promise<any>;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../nodes/Bitget/transport/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EAEpB,MAAM,cAAc,CAAC;AAqBtB;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,MAAM,GAChB,MAAM,CAIR;AA0DD;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,cAAc,GAAG,iBAAiB,GAAG,cAAc,EACrG,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC9B,OAAO,CAAC,GAAG,CAAC,CAwDd;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,cAAc,GAAG,iBAAiB,GAAG,cAAc,EACrG,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC/B,UAAU,SAAI,GACb,OAAO,CAAC,GAAG,CAAC,CA2Bd;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,iBAAiB,EACvB,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC9B,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EAC/B,QAAQ,SAAS,EACjB,KAAK,SAAY,EACjB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,GAAG,EAAE,CAAC,CAiDhB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,iBAAiB,GAAG,qBAAqB,GAAG,cAAc,GAAG,iBAAiB,GAAG,cAAc,EACrG,MAAM,EAAE,mBAAmB,EAC3B,QAAQ,EAAE,MAAM,EAChB,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAC9B,OAAO,CAAC,GAAG,CAAC,CAsCd"}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) Velocity BPA, LLC
|
|
4
|
+
* Licensed under the Business Source License 1.1
|
|
5
|
+
* Commercial use requires a separate commercial license.
|
|
6
|
+
* See LICENSE file for details.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
20
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
21
|
+
}) : function(o, v) {
|
|
22
|
+
o["default"] = v;
|
|
23
|
+
});
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.generateSignature = generateSignature;
|
|
43
|
+
exports.bitgetApiRequest = bitgetApiRequest;
|
|
44
|
+
exports.bitgetApiRequestWithRetry = bitgetApiRequestWithRetry;
|
|
45
|
+
exports.bitgetApiRequestAllItems = bitgetApiRequestAllItems;
|
|
46
|
+
exports.bitgetPublicApiRequest = bitgetPublicApiRequest;
|
|
47
|
+
const crypto = __importStar(require("crypto"));
|
|
48
|
+
const constants_1 = require("../constants");
|
|
49
|
+
const utils_1 = require("../utils");
|
|
50
|
+
// Log licensing notice once on module load
|
|
51
|
+
let licenseNoticeLogged = false;
|
|
52
|
+
function logLicenseNotice() {
|
|
53
|
+
if (!licenseNoticeLogged) {
|
|
54
|
+
console.warn(`[Velocity BPA Licensing Notice]
|
|
55
|
+
|
|
56
|
+
This n8n node is licensed under the Business Source License 1.1 (BSL 1.1).
|
|
57
|
+
|
|
58
|
+
Use of this node by for-profit organizations in production environments requires a commercial license from Velocity BPA.
|
|
59
|
+
|
|
60
|
+
For licensing information, visit https://velobpa.com/licensing or contact licensing@velobpa.com.`);
|
|
61
|
+
licenseNoticeLogged = true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Generate HMAC-SHA256 signature for Bitget API
|
|
66
|
+
*/
|
|
67
|
+
function generateSignature(timestamp, method, requestPath, body, secretKey) {
|
|
68
|
+
const prehash = timestamp + method.toUpperCase() + requestPath + body;
|
|
69
|
+
const hash = crypto.createHmac('sha256', secretKey).update(prehash).digest('base64');
|
|
70
|
+
return hash;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Get Bitget API credentials
|
|
74
|
+
*/
|
|
75
|
+
async function getCredentials(context) {
|
|
76
|
+
const credentials = await context.getCredentials('bitgetApi');
|
|
77
|
+
return {
|
|
78
|
+
apiKey: credentials.apiKey,
|
|
79
|
+
secretKey: credentials.secretKey,
|
|
80
|
+
passphrase: credentials.passphrase,
|
|
81
|
+
environment: credentials.environment || 'production',
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Build request headers with authentication
|
|
86
|
+
*/
|
|
87
|
+
function buildHeaders(credentials, timestamp, signature) {
|
|
88
|
+
const headers = {
|
|
89
|
+
'ACCESS-KEY': credentials.apiKey,
|
|
90
|
+
'ACCESS-SIGN': signature,
|
|
91
|
+
'ACCESS-TIMESTAMP': timestamp,
|
|
92
|
+
'ACCESS-PASSPHRASE': credentials.passphrase,
|
|
93
|
+
'Content-Type': 'application/json',
|
|
94
|
+
locale: 'en-US',
|
|
95
|
+
};
|
|
96
|
+
if (credentials.environment === 'demo') {
|
|
97
|
+
headers['paptrading'] = '1';
|
|
98
|
+
}
|
|
99
|
+
return headers;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Handle Bitget API errors
|
|
103
|
+
*/
|
|
104
|
+
function handleApiError(response) {
|
|
105
|
+
if (response.code !== '00000') {
|
|
106
|
+
const errorMessage = constants_1.ERROR_CODE_MAP[response.code] || response.msg || constants_1.ERROR_MESSAGES.UNKNOWN_ERROR;
|
|
107
|
+
throw new Error(`Bitget API Error: ${errorMessage} (Code: ${response.code})`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Make authenticated request to Bitget API
|
|
112
|
+
*/
|
|
113
|
+
async function bitgetApiRequest(method, endpoint, body = {}, query = {}) {
|
|
114
|
+
// Log licensing notice once
|
|
115
|
+
logLicenseNotice();
|
|
116
|
+
const credentials = await getCredentials(this);
|
|
117
|
+
const timestamp = Date.now().toString();
|
|
118
|
+
// Clean up empty values
|
|
119
|
+
const cleanedQuery = (0, utils_1.removeEmptyProperties)(query);
|
|
120
|
+
const cleanedBody = (0, utils_1.removeEmptyProperties)(body);
|
|
121
|
+
// Build request path with query string
|
|
122
|
+
let requestPath = endpoint;
|
|
123
|
+
if (Object.keys(cleanedQuery).length > 0) {
|
|
124
|
+
requestPath += '?' + (0, utils_1.buildQueryString)(cleanedQuery);
|
|
125
|
+
}
|
|
126
|
+
// Build body string for signature
|
|
127
|
+
const bodyString = Object.keys(cleanedBody).length > 0 ? JSON.stringify(cleanedBody) : '';
|
|
128
|
+
// Generate signature
|
|
129
|
+
const signature = generateSignature(timestamp, method, requestPath, bodyString, credentials.secretKey);
|
|
130
|
+
// Build request options
|
|
131
|
+
const options = {
|
|
132
|
+
method,
|
|
133
|
+
uri: `${constants_1.BITGET_API_BASE_URL}${requestPath}`,
|
|
134
|
+
headers: buildHeaders(credentials, timestamp, signature),
|
|
135
|
+
json: true,
|
|
136
|
+
};
|
|
137
|
+
// Add body if present
|
|
138
|
+
if (Object.keys(cleanedBody).length > 0) {
|
|
139
|
+
options.body = cleanedBody;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const response = (await this.helpers.request(options));
|
|
143
|
+
// Handle API errors
|
|
144
|
+
handleApiError(response);
|
|
145
|
+
return response.data;
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
// Check for rate limiting
|
|
149
|
+
if (error.statusCode === 429 || (error.message && error.message.includes('40006'))) {
|
|
150
|
+
throw new Error('Rate limit exceeded. Please wait before retrying.');
|
|
151
|
+
}
|
|
152
|
+
// Re-throw formatted error
|
|
153
|
+
if (error.message?.startsWith('Bitget API Error:')) {
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`Bitget API Request Failed: ${error.message || 'Unknown error'}`);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Make authenticated request with retry logic
|
|
161
|
+
*/
|
|
162
|
+
async function bitgetApiRequestWithRetry(method, endpoint, body = {}, query = {}, maxRetries = 3) {
|
|
163
|
+
let lastError;
|
|
164
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
165
|
+
try {
|
|
166
|
+
return await bitgetApiRequest.call(this, method, endpoint, body, query);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
lastError = error;
|
|
170
|
+
// Don't retry on authentication errors
|
|
171
|
+
const noRetryErrors = ['40001', '40002', '40003', '40004', '40005', '40007'];
|
|
172
|
+
if (noRetryErrors.some((code) => error.message?.includes(code))) {
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
// Don't retry on last attempt
|
|
176
|
+
if (attempt === maxRetries) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
// Exponential backoff
|
|
180
|
+
const delay = Math.pow(2, attempt - 1) * 1000;
|
|
181
|
+
await (0, utils_1.sleep)(delay);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
throw lastError;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Make paginated request to Bitget API
|
|
188
|
+
*/
|
|
189
|
+
async function bitgetApiRequestAllItems(method, endpoint, body = {}, query = {}, itemsKey = 'data', idKey = 'orderId', maxItems) {
|
|
190
|
+
const items = [];
|
|
191
|
+
let hasMore = true;
|
|
192
|
+
let lastId;
|
|
193
|
+
while (hasMore) {
|
|
194
|
+
const currentQuery = { ...query };
|
|
195
|
+
if (lastId) {
|
|
196
|
+
currentQuery.idLessThan = lastId;
|
|
197
|
+
}
|
|
198
|
+
const response = await bitgetApiRequest.call(this, method, endpoint, body, currentQuery);
|
|
199
|
+
// Handle different response structures
|
|
200
|
+
let responseItems;
|
|
201
|
+
if (Array.isArray(response)) {
|
|
202
|
+
responseItems = response;
|
|
203
|
+
}
|
|
204
|
+
else if (response && typeof response === 'object' && itemsKey in response) {
|
|
205
|
+
responseItems = response[itemsKey] || [];
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
responseItems = response ? [response] : [];
|
|
209
|
+
}
|
|
210
|
+
if (responseItems.length === 0) {
|
|
211
|
+
hasMore = false;
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
items.push(...responseItems);
|
|
215
|
+
// Check if we've reached the max items
|
|
216
|
+
if (maxItems && items.length >= maxItems) {
|
|
217
|
+
hasMore = false;
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
// Get the last ID for pagination
|
|
221
|
+
const lastItem = responseItems[responseItems.length - 1];
|
|
222
|
+
lastId = lastItem?.[idKey];
|
|
223
|
+
// If we got fewer items than the limit, we've reached the end
|
|
224
|
+
const limit = query.limit || 100;
|
|
225
|
+
if (responseItems.length < limit) {
|
|
226
|
+
hasMore = false;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return maxItems ? items.slice(0, maxItems) : items;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Make unauthenticated request to Bitget API (for public endpoints)
|
|
233
|
+
*/
|
|
234
|
+
async function bitgetPublicApiRequest(method, endpoint, query = {}) {
|
|
235
|
+
// Log licensing notice once
|
|
236
|
+
logLicenseNotice();
|
|
237
|
+
// Clean up empty values
|
|
238
|
+
const cleanedQuery = (0, utils_1.removeEmptyProperties)(query);
|
|
239
|
+
// Build request path with query string
|
|
240
|
+
let requestPath = endpoint;
|
|
241
|
+
if (Object.keys(cleanedQuery).length > 0) {
|
|
242
|
+
requestPath += '?' + (0, utils_1.buildQueryString)(cleanedQuery);
|
|
243
|
+
}
|
|
244
|
+
// Build request options
|
|
245
|
+
const options = {
|
|
246
|
+
method,
|
|
247
|
+
uri: `${constants_1.BITGET_API_BASE_URL}${requestPath}`,
|
|
248
|
+
headers: {
|
|
249
|
+
'Content-Type': 'application/json',
|
|
250
|
+
locale: 'en-US',
|
|
251
|
+
},
|
|
252
|
+
json: true,
|
|
253
|
+
};
|
|
254
|
+
try {
|
|
255
|
+
const response = (await this.helpers.request(options));
|
|
256
|
+
// Handle API errors
|
|
257
|
+
handleApiError(response);
|
|
258
|
+
return response.data;
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (error.message?.startsWith('Bitget API Error:')) {
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
throw new Error(`Bitget API Request Failed: ${error.message || 'Unknown error'}`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../nodes/Bitget/transport/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCH,8CAUC;AA6DD,4CA8DC;AAKD,8DAkCC;AAKD,4DA0DC;AAKD,wDA2CC;AA5TD,+CAAiC;AAU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