@@ -205,37 +205,21 @@ protected override async Task<ExchangeOrderBook> OnGetOrderBookAsync(string mark
205
205
/// Account status (is account Unified) needed in some private end-points (e.g. OnGetAmountsAvailableToTradeAsync or GetRecentOrderAsync).
206
206
/// Better be set with constructor. If it's not set, this method will be used to get the account status.
207
207
/// </summary>
208
- public async Task GetAccountInfo ( )
208
+ public async Task GetAccountUnifiedStatusAsync ( )
209
209
{
210
- try
211
- {
212
- JObject result = await MakeJsonRequestAsync < JObject > ( "/v5/account/info" , null , await GetNoncePayloadAsync ( ) ) ;
213
- int statusId = result [ "unifiedMarginStatus" ] . ConvertInvariant < int > ( ) ;
214
- IsUnifiedAccount = statusId switch
215
- {
216
- 1 => false ,
217
- 2 => MarketCategory == MarketCategory . Linear || MarketCategory == MarketCategory . Option ,
218
- 3 => MarketCategory == MarketCategory . Linear || MarketCategory == MarketCategory . Option || MarketCategory == MarketCategory . Spot ,
219
- _ => throw new ArgumentOutOfRangeException ( $ "statusId is { statusId } ") ,
220
- } ;
221
- }
222
- catch ( APIException e )
223
- {
224
- if ( e . Message . Contains ( "3400026" ) ) // for some reason bybit returns an {code:3400026, message:'account not exist'} error if account is not unified
225
- {
226
- IsUnifiedAccount = false ;
227
- }
228
- else
229
- {
230
- throw ;
231
- }
232
- }
210
+ JObject result = await MakeJsonRequestAsync < JObject > ( "/v5/user/query-api" , null , await GetNoncePayloadAsync ( ) ) ;
211
+ IsUnifiedAccount = result [ "unified" ] . ConvertInvariant < int > ( ) == 1 || result [ "uta" ] . ConvertInvariant < int > ( ) == 1 ;
212
+ }
213
+ public async Task < DateTime > GetAPIKeyExpirationDateAsync ( )
214
+ {
215
+ JObject result = await MakeJsonRequestAsync < JObject > ( "/v5/user/query-api" , null , await GetNoncePayloadAsync ( ) ) ;
216
+ return CryptoUtility . ParseTimestamp ( result [ "expiredAt" ] , TimestampType . Iso8601UTC ) ;
233
217
}
234
218
protected override async Task < Dictionary < string , decimal > > OnGetAmountsAvailableToTradeAsync ( )
235
219
{
236
220
if ( IsUnifiedAccount == null )
237
221
{
238
- await GetAccountInfo ( ) ;
222
+ await GetAccountUnifiedStatusAsync ( ) ;
239
223
}
240
224
var payload = await GetNoncePayloadAsync ( ) ;
241
225
string accType = MarketCategory == MarketCategory . Inverse ? "CONTRACT" :
@@ -388,7 +372,7 @@ public async Task<ExchangeOrderResult> GetRecentOrderAsync(string orderId, strin
388
372
}
389
373
if ( IsUnifiedAccount == null )
390
374
{
391
- await GetAccountInfo ( ) ;
375
+ await GetAccountUnifiedStatusAsync ( ) ;
392
376
}
393
377
Dictionary < string , object > payload = await GetNoncePayloadAsync ( ) ;
394
378
payload . Add ( "symbol" , marketSymbol ) ;
0 commit comments