@anrmk/str-package 0.1.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.
Files changed (62) hide show
  1. package/README.md +29 -0
  2. package/dist/TChallengeProgress-DkZ0Q0Zu.d.cts +79 -0
  3. package/dist/TChallengeProgress-e8E5Z7Tn.d.ts +79 -0
  4. package/dist/chunk-CDWBE6PZ.js +264 -0
  5. package/dist/chunk-CDWBE6PZ.js.map +1 -0
  6. package/dist/chunk-GIWOOWDE.js +39 -0
  7. package/dist/chunk-GIWOOWDE.js.map +1 -0
  8. package/dist/chunk-PGGSZUQW.js +98 -0
  9. package/dist/chunk-PGGSZUQW.js.map +1 -0
  10. package/dist/chunk-VPBFPI5B.js +15 -0
  11. package/dist/chunk-VPBFPI5B.js.map +1 -0
  12. package/dist/enums-CvsmYKeP.d.cts +19 -0
  13. package/dist/enums-CvsmYKeP.d.ts +19 -0
  14. package/dist/index.cjs +416 -0
  15. package/dist/index.cjs.map +1 -0
  16. package/dist/index.d.cts +9 -0
  17. package/dist/index.d.ts +9 -0
  18. package/dist/index.js +6 -0
  19. package/dist/index.js.map +1 -0
  20. package/dist/providers/bybit/index.cjs +279 -0
  21. package/dist/providers/bybit/index.cjs.map +1 -0
  22. package/dist/providers/bybit/index.d.cts +16 -0
  23. package/dist/providers/bybit/index.d.ts +16 -0
  24. package/dist/providers/bybit/index.js +4 -0
  25. package/dist/providers/bybit/index.js.map +1 -0
  26. package/dist/types/bybit/index.cjs +4 -0
  27. package/dist/types/bybit/index.cjs.map +1 -0
  28. package/dist/types/bybit/index.d.cts +211 -0
  29. package/dist/types/bybit/index.d.ts +211 -0
  30. package/dist/types/bybit/index.js +3 -0
  31. package/dist/types/bybit/index.js.map +1 -0
  32. package/dist/types/challenge/index.cjs +4 -0
  33. package/dist/types/challenge/index.cjs.map +1 -0
  34. package/dist/types/challenge/index.d.cts +114 -0
  35. package/dist/types/challenge/index.d.ts +114 -0
  36. package/dist/types/challenge/index.js +3 -0
  37. package/dist/types/challenge/index.js.map +1 -0
  38. package/dist/types/index.cjs +4 -0
  39. package/dist/types/index.cjs.map +1 -0
  40. package/dist/types/index.d.cts +8 -0
  41. package/dist/types/index.d.ts +8 -0
  42. package/dist/types/index.js +3 -0
  43. package/dist/types/index.js.map +1 -0
  44. package/dist/utils/bybitHelper.cjs +17 -0
  45. package/dist/utils/bybitHelper.cjs.map +1 -0
  46. package/dist/utils/bybitHelper.d.cts +6 -0
  47. package/dist/utils/bybitHelper.d.ts +6 -0
  48. package/dist/utils/bybitHelper.js +3 -0
  49. package/dist/utils/bybitHelper.js.map +1 -0
  50. package/dist/utils/challengeHelper.cjs +119 -0
  51. package/dist/utils/challengeHelper.cjs.map +1 -0
  52. package/dist/utils/challengeHelper.d.cts +18 -0
  53. package/dist/utils/challengeHelper.d.ts +18 -0
  54. package/dist/utils/challengeHelper.js +4 -0
  55. package/dist/utils/challengeHelper.js.map +1 -0
  56. package/dist/utils/helper.cjs +43 -0
  57. package/dist/utils/helper.cjs.map +1 -0
  58. package/dist/utils/helper.d.cts +5 -0
  59. package/dist/utils/helper.d.ts +5 -0
  60. package/dist/utils/helper.js +3 -0
  61. package/dist/utils/helper.js.map +1 -0
  62. package/package.json +76 -0
@@ -0,0 +1,211 @@
1
+ import { I as IBybitAccountType, b as IBybitUnifiedMarginStatus, a as IBybitCoinType } from '../../enums-CvsmYKeP.js';
2
+
3
+ type IBybitWalletAccount = {
4
+ accountIMRate: string;
5
+ totalMaintenanceMarginByMp: string;
6
+ totalInitialMargin: string;
7
+ accountType: IBybitAccountType;
8
+ accountMMRate: string;
9
+ accountMMRateByMp: string;
10
+ accountIMRateByMp: string;
11
+ totalInitialMarginByMp: string;
12
+ totalMaintenanceMargin: string;
13
+ totalEquity: string;
14
+ totalMarginBalance: string;
15
+ totalAvailableBalance: string;
16
+ totalPerpUPL: string;
17
+ totalWalletBalance: string;
18
+ accountLTV: string;
19
+ coin: IBybitCoinBalance[];
20
+ };
21
+ type IBybitCoinBalance = {
22
+ availableToBorrow: string;
23
+ bonus: string;
24
+ accruedInterest: string;
25
+ availableToWithdraw: string;
26
+ totalOrderIM: string;
27
+ equity: string;
28
+ totalPositionMM: string;
29
+ usdValue: string;
30
+ spotHedgingQty: string;
31
+ unrealisedPnl: string;
32
+ collateralSwitch: boolean;
33
+ borrowAmount: string;
34
+ totalPositionIM: string;
35
+ walletBalance: string;
36
+ cumRealisedPnl: string;
37
+ locked: string;
38
+ marginCollateral: boolean;
39
+ coin: string;
40
+ spotBorrow: string;
41
+ };
42
+
43
+ type IBybitClosedPnl = {
44
+ symbol: string;
45
+ orderId: string;
46
+ side: string;
47
+ qty: string;
48
+ orderPrice: string;
49
+ orderType: string;
50
+ execType: string;
51
+ closedSize: string;
52
+ cumEntryValue: string;
53
+ avgEntryPrice: string;
54
+ cumExitValue: string;
55
+ avgExitPrice: string;
56
+ closedPnl: string;
57
+ fillCount: string;
58
+ leverage: string;
59
+ createdTime: string;
60
+ updatedTime: string;
61
+ openFee: string;
62
+ closeFee: string;
63
+ };
64
+
65
+ type IBybitCredentials = {
66
+ apiKey: string;
67
+ apiSecret: string;
68
+ };
69
+
70
+ type IBybitApiKeyInfo = {
71
+ id: string;
72
+ note: string;
73
+ apiKey: string;
74
+ readOnly: number;
75
+ permissions: IBybitApiKeyPermissions;
76
+ ips: string[];
77
+ type: number;
78
+ deadlineDay: number;
79
+ expiredAt: string;
80
+ createdAt: string;
81
+ uta: number;
82
+ userID: number;
83
+ inviterID: number;
84
+ vipLevel: string;
85
+ mktMakerLevel: string;
86
+ affiliateID: number;
87
+ rsaPublicKey: string;
88
+ isMaster: boolean;
89
+ parentUid: string;
90
+ kycLevel: string;
91
+ kycRegion: string;
92
+ };
93
+ type IBybitApiKeyPermissions = {
94
+ ContractTrade?: string[];
95
+ Spot?: string[];
96
+ Wallet?: string[];
97
+ Options?: string[];
98
+ Derivatives?: string[];
99
+ Exchange?: string[];
100
+ Earn?: string[];
101
+ FiatP2P?: string[];
102
+ FiatBitPay?: string[];
103
+ FiatConvertBroker?: string[];
104
+ BitCard?: string[];
105
+ ByXPost?: string[];
106
+ Affiliate?: string[];
107
+ BlockTrade?: string[];
108
+ FiatBybitPay?: string[];
109
+ NFT?: string[];
110
+ CopyTrading?: string[];
111
+ };
112
+
113
+ type IBybitAccountInfo = {
114
+ unifiedMarginStatus: IBybitUnifiedMarginStatus | number;
115
+ marginMode: "ISOLATED_MARGIN" | "REGULAR_MARGIN" | "PORTFOLIO_MARGIN";
116
+ isMasterTrader: boolean;
117
+ spotHedgingStatus: "ON" | "OFF";
118
+ updatedTime: string;
119
+ dcpStatus?: "ON" | "OFF";
120
+ timeWindow?: number;
121
+ smpGroup?: number;
122
+ };
123
+
124
+ type IBybitPositionInfo = {
125
+ challengeId: string;
126
+ positionIdx: number;
127
+ riskId: number;
128
+ riskLimitValue: string;
129
+ symbol: string;
130
+ side: string;
131
+ size: string;
132
+ avgPrice: string;
133
+ positionValue: string;
134
+ tradeMode: number;
135
+ positionStatus: string;
136
+ autoAddMargin: number;
137
+ adlRankIndicator: number;
138
+ leverage: string;
139
+ positionBalance: string;
140
+ markPrice: string;
141
+ liqPrice: string;
142
+ bustPrice: string;
143
+ positionMM: string;
144
+ positionIM: string;
145
+ tpslMode: string;
146
+ takeProfit: string;
147
+ stopLoss: string;
148
+ trailingStop: string;
149
+ unrealisedPnl: string;
150
+ curRealisedPnl: string;
151
+ cumRealisedPnl: string;
152
+ seq: number;
153
+ isReduceOnly: boolean;
154
+ mmrSysUpdatedTime: string;
155
+ leverageSysUpdatedTime: string;
156
+ sessionAvgPrice: string;
157
+ createdTime: string;
158
+ updatedTime: string;
159
+ };
160
+
161
+ type IBybitDemoApplyMoneyItem = {
162
+ coin: IBybitCoinType;
163
+ amountStr: string;
164
+ };
165
+ type IBybitDemoApplyMoneyRequest = {
166
+ adjustType?: 0 | 1;
167
+ utaDemoApplyMoney: IBybitDemoApplyMoneyItem[];
168
+ };
169
+ type IBybitDemoApplyMoneyPayload = IBybitDemoApplyMoneyRequest & {
170
+ challengeId?: string;
171
+ };
172
+ type IBybitDemoApplyMoney = {
173
+ resultCode: string;
174
+ utaDemoApplyMoneyConfig: IBybitDemoApplyMoneyItem[];
175
+ orderStatus: string;
176
+ retMsg: string;
177
+ };
178
+
179
+ type IBybitApiResponse<T> = {
180
+ retCode: number;
181
+ retMsg?: string;
182
+ result?: T | any;
183
+ time: number;
184
+ };
185
+ type IBybitApiResponseList<T> = {
186
+ nextPageCursor?: string;
187
+ list?: T[];
188
+ };
189
+ type IBybitResponse = {
190
+ updatedAt: number;
191
+ };
192
+ type IBybitWalletResponse = IBybitResponse & {
193
+ topic: string;
194
+ list?: IBybitWalletAccount[];
195
+ };
196
+ type IBybitClosedPnlRequest = {
197
+ credentials: IBybitCredentials;
198
+ category: string;
199
+ symbol?: string;
200
+ startTime?: number;
201
+ endTime?: number;
202
+ limit?: number;
203
+ cursor?: string;
204
+ };
205
+ type IBybitClosedPnlResponse = {
206
+ category: string;
207
+ list?: IBybitClosedPnl[];
208
+ nextPageCursor?: string;
209
+ };
210
+
211
+ export { type IBybitAccountInfo, IBybitAccountType, type IBybitApiKeyInfo, type IBybitApiResponse, type IBybitApiResponseList, type IBybitClosedPnl, type IBybitClosedPnlRequest, type IBybitClosedPnlResponse, type IBybitCoinBalance, IBybitCoinType, type IBybitCredentials, type IBybitDemoApplyMoneyItem, type IBybitDemoApplyMoneyPayload, type IBybitDemoApplyMoneyRequest, type IBybitDemoApplyMoney as IBybitDemoApplyMoneyResponse, type IBybitPositionInfo, type IBybitWalletAccount, type IBybitWalletResponse };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,114 @@
1
+ import { b as TChallengeProgress, c as TChallengeWalletBalance } from '../../TChallengeProgress-DkZ0Q0Zu.cjs';
2
+ export { T as TChallengeClosedPnl, a as TChallengeClosedPnlStatistics } from '../../TChallengeProgress-DkZ0Q0Zu.cjs';
3
+ export { TSyncResponse } from '../index.cjs';
4
+ import '../../enums-CvsmYKeP.cjs';
5
+
6
+ type TChallengeType = "ONE_STEP" | "TWO_STEPS";
7
+ type TChallengeMode = "VERIFICATION" | "CHALLENGE" | "FUNDED";
8
+ type TTradingType = "Futures" | "Spot" | "Margin" | "Options";
9
+ type TDrawdownType = "Trailing" | "Fixed";
10
+ type TChallengeCapital = 5000 | 10000 | 25000 | 50000 | 100000 | 200000;
11
+ type TChallengeProvider = "BYBIT" | "CLEO";
12
+ type TChallengeRule = {
13
+ name: string;
14
+ type: TChallengeType;
15
+ mode: TChallengeMode;
16
+ tradingPeriod: string;
17
+ minTradingDays: number;
18
+ stopLossRequired: boolean;
19
+ dailyDrawdownPct: number;
20
+ maxLossPct: number;
21
+ minLossPct: number;
22
+ profitTargetPct: number;
23
+ feePolicy: string;
24
+ prohibitedActions: string[] | null;
25
+ };
26
+
27
+ type TChallengeAccountInfo = {
28
+ challengeId: string;
29
+ unifiedMarginStatus: number;
30
+ marginMode: string;
31
+ isMasterTrader: boolean;
32
+ spotHedgingStatus: "ON" | "OFF";
33
+ updatedAt: string;
34
+ };
35
+
36
+ type TChallengeApiKeyInfo = {};
37
+
38
+ type TChallengePositionInfo = {
39
+ symbol: string;
40
+ positionIdx: number;
41
+ side: string;
42
+ size: number;
43
+ avgPrice: number;
44
+ positionValue: number;
45
+ leverage: number;
46
+ markPrice: number;
47
+ liqPrice: number;
48
+ bustPrice: number;
49
+ positionIm: number;
50
+ positionMm: number;
51
+ takeProfit: number;
52
+ stopLoss: number;
53
+ unrealisedPnl: number;
54
+ cumRealisedPnl: number;
55
+ curRealisedPnl: number;
56
+ adlRankIndicator: number;
57
+ positionStatus: string;
58
+ createdTime: string;
59
+ updatedTime: string;
60
+ syncedAt: string;
61
+ };
62
+
63
+ type TChallengeItem = {
64
+ id?: string;
65
+ challengeId: string;
66
+ ctype: TChallengeType;
67
+ capital: number;
68
+ currency: string;
69
+ ttype: TTradingType;
70
+ ddtype: TDrawdownType;
71
+ status: string;
72
+ provider: string;
73
+ startDate: string;
74
+ endDate: string;
75
+ apiKey: string;
76
+ apiSecret: string;
77
+ daysActive: number;
78
+ daysRemaining: number;
79
+ hasCredentials: boolean;
80
+ apiKeyHint?: string;
81
+ stats?: TChallengeStatistics;
82
+ progress?: TChallengeProgress;
83
+ rule?: TChallengeRule;
84
+ wallet?: TChallengeWalletBalance;
85
+ };
86
+ type TChallengeListItem = {
87
+ id: string;
88
+ capital: number | null;
89
+ currency: string | null;
90
+ ttype: TTradingType | null;
91
+ ddtype: TDrawdownType | null;
92
+ status: string;
93
+ provider: string;
94
+ startDate: string;
95
+ endDate: string | null;
96
+ daysActive: number | null;
97
+ daysRemaining: number | null;
98
+ apiKeyHint?: string;
99
+ hasCredentials: boolean;
100
+ stats?: TChallengeStatistics | null;
101
+ progress?: TChallengeProgress | null;
102
+ rule?: TChallengeRule | null;
103
+ wallet?: TChallengeWalletBalance | null;
104
+ };
105
+
106
+ type TChallengeStatistics = {
107
+ equity: number;
108
+ balance: number;
109
+ dailyDrawdown: number;
110
+ maxDrawdown: number;
111
+ currency?: string;
112
+ };
113
+
114
+ export { type TChallengeAccountInfo, type TChallengeApiKeyInfo, type TChallengeCapital, type TChallengeItem, type TChallengeListItem, type TChallengeMode, type TChallengePositionInfo, TChallengeProgress, type TChallengeProvider, type TChallengeRule, type TChallengeStatistics, type TChallengeType, TChallengeWalletBalance, type TDrawdownType, type TTradingType };
@@ -0,0 +1,114 @@
1
+ import { b as TChallengeProgress, c as TChallengeWalletBalance } from '../../TChallengeProgress-e8E5Z7Tn.js';
2
+ export { T as TChallengeClosedPnl, a as TChallengeClosedPnlStatistics } from '../../TChallengeProgress-e8E5Z7Tn.js';
3
+ export { TSyncResponse } from '../index.js';
4
+ import '../../enums-CvsmYKeP.js';
5
+
6
+ type TChallengeType = "ONE_STEP" | "TWO_STEPS";
7
+ type TChallengeMode = "VERIFICATION" | "CHALLENGE" | "FUNDED";
8
+ type TTradingType = "Futures" | "Spot" | "Margin" | "Options";
9
+ type TDrawdownType = "Trailing" | "Fixed";
10
+ type TChallengeCapital = 5000 | 10000 | 25000 | 50000 | 100000 | 200000;
11
+ type TChallengeProvider = "BYBIT" | "CLEO";
12
+ type TChallengeRule = {
13
+ name: string;
14
+ type: TChallengeType;
15
+ mode: TChallengeMode;
16
+ tradingPeriod: string;
17
+ minTradingDays: number;
18
+ stopLossRequired: boolean;
19
+ dailyDrawdownPct: number;
20
+ maxLossPct: number;
21
+ minLossPct: number;
22
+ profitTargetPct: number;
23
+ feePolicy: string;
24
+ prohibitedActions: string[] | null;
25
+ };
26
+
27
+ type TChallengeAccountInfo = {
28
+ challengeId: string;
29
+ unifiedMarginStatus: number;
30
+ marginMode: string;
31
+ isMasterTrader: boolean;
32
+ spotHedgingStatus: "ON" | "OFF";
33
+ updatedAt: string;
34
+ };
35
+
36
+ type TChallengeApiKeyInfo = {};
37
+
38
+ type TChallengePositionInfo = {
39
+ symbol: string;
40
+ positionIdx: number;
41
+ side: string;
42
+ size: number;
43
+ avgPrice: number;
44
+ positionValue: number;
45
+ leverage: number;
46
+ markPrice: number;
47
+ liqPrice: number;
48
+ bustPrice: number;
49
+ positionIm: number;
50
+ positionMm: number;
51
+ takeProfit: number;
52
+ stopLoss: number;
53
+ unrealisedPnl: number;
54
+ cumRealisedPnl: number;
55
+ curRealisedPnl: number;
56
+ adlRankIndicator: number;
57
+ positionStatus: string;
58
+ createdTime: string;
59
+ updatedTime: string;
60
+ syncedAt: string;
61
+ };
62
+
63
+ type TChallengeItem = {
64
+ id?: string;
65
+ challengeId: string;
66
+ ctype: TChallengeType;
67
+ capital: number;
68
+ currency: string;
69
+ ttype: TTradingType;
70
+ ddtype: TDrawdownType;
71
+ status: string;
72
+ provider: string;
73
+ startDate: string;
74
+ endDate: string;
75
+ apiKey: string;
76
+ apiSecret: string;
77
+ daysActive: number;
78
+ daysRemaining: number;
79
+ hasCredentials: boolean;
80
+ apiKeyHint?: string;
81
+ stats?: TChallengeStatistics;
82
+ progress?: TChallengeProgress;
83
+ rule?: TChallengeRule;
84
+ wallet?: TChallengeWalletBalance;
85
+ };
86
+ type TChallengeListItem = {
87
+ id: string;
88
+ capital: number | null;
89
+ currency: string | null;
90
+ ttype: TTradingType | null;
91
+ ddtype: TDrawdownType | null;
92
+ status: string;
93
+ provider: string;
94
+ startDate: string;
95
+ endDate: string | null;
96
+ daysActive: number | null;
97
+ daysRemaining: number | null;
98
+ apiKeyHint?: string;
99
+ hasCredentials: boolean;
100
+ stats?: TChallengeStatistics | null;
101
+ progress?: TChallengeProgress | null;
102
+ rule?: TChallengeRule | null;
103
+ wallet?: TChallengeWalletBalance | null;
104
+ };
105
+
106
+ type TChallengeStatistics = {
107
+ equity: number;
108
+ balance: number;
109
+ dailyDrawdown: number;
110
+ maxDrawdown: number;
111
+ currency?: string;
112
+ };
113
+
114
+ export { type TChallengeAccountInfo, type TChallengeApiKeyInfo, type TChallengeCapital, type TChallengeItem, type TChallengeListItem, type TChallengeMode, type TChallengePositionInfo, TChallengeProgress, type TChallengeProvider, type TChallengeRule, type TChallengeStatistics, type TChallengeType, TChallengeWalletBalance, type TDrawdownType, type TTradingType };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,4 @@
1
+ 'use strict';
2
+
3
+ //# sourceMappingURL=index.cjs.map
4
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
@@ -0,0 +1,8 @@
1
+ type TSyncResponse<T> = {
2
+ success: boolean;
3
+ message?: string;
4
+ data?: T | null;
5
+ timestamp?: string | number;
6
+ };
7
+
8
+ export type { TSyncResponse };
@@ -0,0 +1,8 @@
1
+ type TSyncResponse<T> = {
2
+ success: boolean;
3
+ message?: string;
4
+ data?: T | null;
5
+ timestamp?: string | number;
6
+ };
7
+
8
+ export type { TSyncResponse };
@@ -0,0 +1,3 @@
1
+
2
+ //# sourceMappingURL=index.js.map
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var crypto = require('crypto');
4
+ var process = require('process');
5
+
6
+ // src/utils/bybitHelper.ts
7
+ var BYBIT_RECV_WINDOW_TIMEOUT_MS = process.env.NEXT_PUBLIC_BYBIT_RECV_WINDOW_TIMEOUT_MS ?? "5000";
8
+ function signBybitRequest(apiSecret, apiKey, queryString) {
9
+ const timestamp = Date.now().toString();
10
+ const payload = `${timestamp}${apiKey}${BYBIT_RECV_WINDOW_TIMEOUT_MS}${queryString ?? ""}`;
11
+ const signature = crypto.createHmac("sha256", apiSecret).update(payload).digest("hex");
12
+ return { signature, timestamp };
13
+ }
14
+
15
+ exports.signBybitRequest = signBybitRequest;
16
+ //# sourceMappingURL=bybitHelper.cjs.map
17
+ //# sourceMappingURL=bybitHelper.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/bybitHelper.ts"],"names":["env","createHmac"],"mappings":";;;;;;AAGA,IAAM,4BAAA,GACJA,YAAI,wCAAA,IAA4C,MAAA;AAE3C,SAAS,gBAAA,CACd,SAAA,EACA,MAAA,EACA,WAAA,EACA;AACA,EAAA,MAAM,SAAA,GAAY,IAAA,CAAK,GAAA,EAAI,CAAE,QAAA,EAAS;AACtC,EAAA,MAAM,OAAA,GAAU,GAAG,SAAS,CAAA,EAAG,MAAM,CAAA,EAAG,4BAA4B,CAAA,EAAG,WAAA,IAAe,EAAE,CAAA,CAAA;AACxF,EAAA,MAAM,SAAA,GAAYC,kBAAW,QAAA,EAAU,SAAS,EAC7C,MAAA,CAAO,OAAO,CAAA,CACd,MAAA,CAAO,KAAK,CAAA;AAEf,EAAA,OAAO,EAAE,WAAW,SAAA,EAAU;AAChC","file":"bybitHelper.cjs","sourcesContent":["import { createHmac } from \"crypto\";\nimport { env } from \"node:process\";\n\nconst BYBIT_RECV_WINDOW_TIMEOUT_MS =\n env.NEXT_PUBLIC_BYBIT_RECV_WINDOW_TIMEOUT_MS ?? \"5000\";\n\nexport function signBybitRequest(\n apiSecret: string,\n apiKey: string,\n queryString?: string,\n) {\n const timestamp = Date.now().toString();\n const payload = `${timestamp}${apiKey}${BYBIT_RECV_WINDOW_TIMEOUT_MS}${queryString ?? \"\"}`;\n const signature = createHmac(\"sha256\", apiSecret)\n .update(payload)\n .digest(\"hex\");\n\n return { signature, timestamp };\n}\n"]}
@@ -0,0 +1,6 @@
1
+ declare function signBybitRequest(apiSecret: string, apiKey: string, queryString?: string): {
2
+ signature: string;
3
+ timestamp: string;
4
+ };
5
+
6
+ export { signBybitRequest };
@@ -0,0 +1,6 @@
1
+ declare function signBybitRequest(apiSecret: string, apiKey: string, queryString?: string): {
2
+ signature: string;
3
+ timestamp: string;
4
+ };
5
+
6
+ export { signBybitRequest };
@@ -0,0 +1,3 @@
1
+ export { signBybitRequest } from '../chunk-VPBFPI5B.js';
2
+ //# sourceMappingURL=bybitHelper.js.map
3
+ //# sourceMappingURL=bybitHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"bybitHelper.js"}
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ // src/utils/helper.ts
4
+ var isSameUtcDay = (left, right) => {
5
+ if (!left || !right) {
6
+ return false;
7
+ }
8
+ const normalizedLeft = left.trim();
9
+ const normalizedRight = right.trim();
10
+ if (!normalizedLeft || !normalizedRight) {
11
+ return false;
12
+ }
13
+ const leftDate = new Date(normalizedLeft);
14
+ const rightDate = new Date(normalizedRight);
15
+ if (Number.isNaN(leftDate.getTime()) || Number.isNaN(rightDate.getTime())) {
16
+ return false;
17
+ }
18
+ return leftDate.toISOString().slice(0, 10) === rightDate.toISOString().slice(0, 10);
19
+ };
20
+
21
+ // src/utils/challengeHelper.ts
22
+ var createDefaultWallet = (challengeId = "", capital = 0) => ({
23
+ challengeId,
24
+ accountType: "UNIFIED" /* UNIFIED */,
25
+ totalEquity: 0,
26
+ totalPerpUpl: 0,
27
+ totalWalletBalance: 0,
28
+ totalAvailableBalance: 0,
29
+ capital,
30
+ equity: 0,
31
+ usdValue: 0,
32
+ unrealisedPnl: 0,
33
+ walletBalance: 0,
34
+ availableToWithdraw: 0,
35
+ coin: "USDT" /* USDT */,
36
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
37
+ });
38
+ var createDefaultProgress = (challengeId = "", currentEquity = 0) => ({
39
+ challengeId,
40
+ currentEquity,
41
+ currentTotalLoss: 0,
42
+ currentTradingDays: 0,
43
+ currentDailyDrawdown: 0,
44
+ currentProfitTarget: 0,
45
+ dailyStartingEquity: 0,
46
+ dailyStartingUpdatedAt: (/* @__PURE__ */ new Date()).toISOString(),
47
+ maxDailyEquity: 0,
48
+ minDailyEquity: 0,
49
+ maxUpdatedAt: (/* @__PURE__ */ new Date()).toISOString(),
50
+ minUpdatedAt: (/* @__PURE__ */ new Date()).toISOString()
51
+ });
52
+ var currentTradingDaysCountCalculation = async (closedPnlData, minPositionSize) => {
53
+ if (!closedPnlData || closedPnlData.length === 0) {
54
+ return 0;
55
+ }
56
+ const closedPnlGrouped = closedPnlData.reduce(
57
+ (acc, trade) => {
58
+ const day = trade.updatedTime.split("T")[0];
59
+ if (!acc[day]) {
60
+ acc[day] = [];
61
+ }
62
+ acc[day].push(trade);
63
+ return acc;
64
+ },
65
+ {}
66
+ );
67
+ return await Object.values(closedPnlGrouped).reduce((count, dayTrades) => {
68
+ const hasQualifyingTrade = dayTrades.some((trade) => {
69
+ const entryValue = trade.cumEntryValue;
70
+ const closedPnL = trade.closedPnl;
71
+ const passesSize = entryValue >= minPositionSize;
72
+ const minRequiredPnL = entryValue * 0.01;
73
+ const passesPnL = Math.abs(closedPnL) >= minRequiredPnL;
74
+ return passesSize && passesPnL;
75
+ });
76
+ return hasQualifyingTrade ? count + 1 : count;
77
+ }, 0);
78
+ };
79
+ var currentDailyEquity = (wallet, progress) => {
80
+ const today = (/* @__PURE__ */ new Date()).toISOString();
81
+ const startDate = (/* @__PURE__ */ new Date()).setUTCHours(0, 0, 0, 0);
82
+ const startDateStr = new Date(startDate).toISOString();
83
+ const { equity, unrealisedPnl } = wallet;
84
+ const {
85
+ dailyStartingEquity,
86
+ maxDailyEquity,
87
+ minDailyEquity,
88
+ dailyStartingUpdatedAt,
89
+ maxUpdatedAt,
90
+ minUpdatedAt
91
+ } = progress;
92
+ let isSameDay = isSameUtcDay(dailyStartingUpdatedAt, startDateStr);
93
+ const newDailyStartingUpdatedAt = isSameDay ? dailyStartingUpdatedAt : startDateStr;
94
+ const newDailyStartingEquity = isSameDay ? dailyStartingEquity : equity;
95
+ isSameDay = isSameUtcDay(maxUpdatedAt, today);
96
+ let newMaxUpdatedAt = isSameDay ? maxUpdatedAt : today;
97
+ const newMaxDailyEquity = Math.max(isSameDay ? maxDailyEquity : equity, equity);
98
+ isSameDay = isSameUtcDay(minUpdatedAt, today);
99
+ const newMinUpdatedAt = isSameDay ? minUpdatedAt : today;
100
+ const newMinDailyEquity = Math.min(isSameDay ? minDailyEquity : equity, equity);
101
+ const dailyEquityDrawdown = equity - newMaxDailyEquity;
102
+ return {
103
+ currentEquity: equity,
104
+ currentDailyDrawdown: dailyEquityDrawdown,
105
+ dailyStartingEquity: newDailyStartingEquity,
106
+ dailyStartingUpdatedAt: newDailyStartingUpdatedAt.slice(0, 10),
107
+ maxDailyEquity: newMaxDailyEquity,
108
+ maxUpdatedAt: newMaxUpdatedAt,
109
+ minDailyEquity: newMinDailyEquity,
110
+ minUpdatedAt: newMinUpdatedAt
111
+ };
112
+ };
113
+
114
+ exports.createDefaultProgress = createDefaultProgress;
115
+ exports.createDefaultWallet = createDefaultWallet;
116
+ exports.currentDailyEquity = currentDailyEquity;
117
+ exports.currentTradingDaysCountCalculation = currentTradingDaysCountCalculation;
118
+ //# sourceMappingURL=challengeHelper.cjs.map
119
+ //# sourceMappingURL=challengeHelper.cjs.map