diff --git a/lib/src/babel_binance_base.dart b/lib/src/babel_binance_base.dart index d3f80fd..5babc5f 100644 --- a/lib/src/babel_binance_base.dart +++ b/lib/src/babel_binance_base.dart @@ -55,8 +55,8 @@ class Binance { spot.market.dispose(); futuresUsd.dispose(); margin.dispose(); - testnetSpot.dispose(); - testnetFutures.dispose(); + // Note: TestnetSpot and TestnetFuturesUsd don't have dispose methods + // as they are composed of sub-classes that handle their own cleanup } } diff --git a/lib/src/binance_base.dart b/lib/src/binance_base.dart index d01c412..bc3807c 100644 --- a/lib/src/binance_base.dart +++ b/lib/src/binance_base.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'dart:io'; import 'dart:async'; import 'package:http/http.dart' as http; import 'package:crypto/crypto.dart'; diff --git a/lib/src/rate_limiting/rate_limiter.dart b/lib/src/rate_limiting/rate_limiter.dart index 576aee2..2260aa7 100644 --- a/lib/src/rate_limiting/rate_limiter.dart +++ b/lib/src/rate_limiting/rate_limiter.dart @@ -19,7 +19,6 @@ class RateLimiter { // Order count tracking int _orderCountToday = 0; - DateTime _orderCountResetTime = DateTime.now(); RateLimiter({ RateLimitConfig? config, @@ -126,7 +125,6 @@ class RateLimiter { /// Reset daily order count void _resetDailyOrderCount() { _orderCountToday = 0; - _orderCountResetTime = DateTime.now(); } /// Get current rate limit status diff --git a/lib/src/rate_limiting/token_bucket.dart b/lib/src/rate_limiting/token_bucket.dart index 832cd97..f861a26 100644 --- a/lib/src/rate_limiting/token_bucket.dart +++ b/lib/src/rate_limiting/token_bucket.dart @@ -81,11 +81,3 @@ class TokenBucket { _lastRefill = DateTime.now(); } } - -extension on double { - double clamp(num min, num max) { - if (this < min) return min.toDouble(); - if (this > max) return max.toDouble(); - return this; - } -} diff --git a/lib/src/websocket/websocket_stream.dart b/lib/src/websocket/websocket_stream.dart index 9333146..4571aaf 100644 --- a/lib/src/websocket/websocket_stream.dart +++ b/lib/src/websocket/websocket_stream.dart @@ -59,6 +59,9 @@ class BinanceWebSocketStream { return DateTime.now().difference(_connectedAt!); } + /// Last time a pong was received (for connection health monitoring) + DateTime? get lastPongTime => _lastPongReceived; + /// Connect to WebSocket Future connect() async { if (_isDisposed) throw StateError('Stream is disposed');