Skip to content

Commit

Permalink
feat(app): Consider fee when assessing usable balance
Browse files Browse the repository at this point in the history
  • Loading branch information
luckysori committed Jul 5, 2023
1 parent 1e25231 commit 23ca9e3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mobile/lib/features/trade/trade_bottom_sheet_tab.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ class _TradeBottomSheetTabState extends State<TradeBottomSheetTab> {
});
}

if (usableBalance < margin) {
Amount fee = provider.orderMatchingFee(direction) ?? Amount.zero();
if (usableBalance < margin + fee.sats) {
return "Insufficient balance";
}

Expand Down
4 changes: 4 additions & 0 deletions mobile/lib/features/trade/trade_value_change_notifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class TradeValuesChangeNotifier extends ChangeNotifier implements Subscriber {
}
}

Amount? orderMatchingFee(Direction direction) {
return fromDirection(direction).fee;
}

void updateQuantity(Direction direction, double quantity) {
fromDirection(direction).updateQuantity(quantity);
notifyListeners();
Expand Down

0 comments on commit 23ca9e3

Please sign in to comment.