class StakingWalletBalance {
  final String coinUnit;
  final String availableBalance;
  final String lockedBalance;
  /// 已释放总量（与 coinUnit 同单位，如 iBit）
  final String releasedTotal;
  final String? availableBalanceUsdt;
  final String? lockedBalanceUsdt;

  const StakingWalletBalance({
    required this.coinUnit,
    required this.availableBalance,
    required this.lockedBalance,
    this.releasedTotal = '0',
    this.availableBalanceUsdt,
    this.lockedBalanceUsdt,
  });

  factory StakingWalletBalance.empty(String coinUnit) {
    return StakingWalletBalance(
      coinUnit: coinUnit.toUpperCase(),
      availableBalance: '0',
      lockedBalance: '0',
      releasedTotal: '0',
    );
  }

  factory StakingWalletBalance.fromJson(Map<String, dynamic> json) {
    return StakingWalletBalance(
      coinUnit: '${json['coinUnit'] ?? ''}'.toUpperCase(),
      availableBalance: '${json['availableBalance'] ?? '0'}',
      lockedBalance: '${json['lockedBalance'] ?? '0'}',
      releasedTotal: '${json['releasedTotal'] ?? json['released_total'] ?? '0'}',
      availableBalanceUsdt: json['availableBalanceUsdt']?.toString(),
      lockedBalanceUsdt: json['lockedBalanceUsdt']?.toString(),
    );
  }
}
