@@ -205,37 +205,21 @@ protected override async Task<ExchangeOrderBook> OnGetOrderBookAsync(string mark
205205 /// Account status (is account Unified) needed in some private end-points (e.g. OnGetAmountsAvailableToTradeAsync or GetRecentOrderAsync).
206206 /// Better be set with constructor. If it's not set, this method will be used to get the account status.
207207 /// </summary>
208- public async Task GetAccountInfo ( )
208+ public async Task GetAccountUnifiedStatusAsync ( )
209209 {
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 ) ;
233217 }
234218 protected override async Task < Dictionary < string , decimal > > OnGetAmountsAvailableToTradeAsync ( )
235219 {
236220 if ( IsUnifiedAccount == null )
237221 {
238- await GetAccountInfo ( ) ;
222+ await GetAccountUnifiedStatusAsync ( ) ;
239223 }
240224 var payload = await GetNoncePayloadAsync ( ) ;
241225 string accType = MarketCategory == MarketCategory . Inverse ? "CONTRACT" :
@@ -388,7 +372,7 @@ public async Task<ExchangeOrderResult> GetRecentOrderAsync(string orderId, strin
388372 }
389373 if ( IsUnifiedAccount == null )
390374 {
391- await GetAccountInfo ( ) ;
375+ await GetAccountUnifiedStatusAsync ( ) ;
392376 }
393377 Dictionary < string , object > payload = await GetNoncePayloadAsync ( ) ;
394378 payload . Add ( "symbol" , marketSymbol ) ;
0 commit comments