32 lines
1.4 KiB
Dart
32 lines
1.4 KiB
Dart
// ============================================================
|
|
// TradingProvider — 交易 Riverpod Providers
|
|
// ============================================================
|
|
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import '../../../../core/network/api_client.dart';
|
|
|
|
// ── 市场列表 ──────────────────────────────────────────────────
|
|
|
|
final marketListProvider = FutureProvider.autoDispose((ref) async {
|
|
final api = ApiClient.instance;
|
|
final resp = await api.get('/api/v1/trading/markets');
|
|
return resp.data['data'];
|
|
});
|
|
|
|
// ── 订单簿 ────────────────────────────────────────────────────
|
|
|
|
final orderBookProvider =
|
|
FutureProvider.autoDispose.family<dynamic, String>((ref, marketId) async {
|
|
final api = ApiClient.instance;
|
|
final resp = await api.get('/api/v1/trading/orderbook/$marketId');
|
|
return resp.data['data'];
|
|
});
|
|
|
|
// ── 我的挂单 ──────────────────────────────────────────────────
|
|
|
|
final myOpenOrdersProvider = FutureProvider.autoDispose((ref) async {
|
|
final api = ApiClient.instance;
|
|
final resp = await api.get('/api/v1/trading/orders', queryParameters: {'status': 'OPEN'});
|
|
return resp.data['data'];
|
|
});
|