From 6571a37c3186bb5e7d0bd7f575b75c944bfd4597 Mon Sep 17 00:00:00 2001 From: Richard Holzeis Date: Thu, 25 Jan 2024 12:06:00 +0100 Subject: [PATCH 1/3] docs: Remove todo about first signed dlc channel At the moment we can be certain that there will ever only be one **signed** dlc channel. A previous channel that has been closed on-chain is not in a signed state and will not be returned by this function. Use `list_dlc_channels` to get also non-signed dlc channels. Note, its not safe to use `first` on the `list_dlc_channels` function. --- mobile/native/src/ln_dlc/mod.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mobile/native/src/ln_dlc/mod.rs b/mobile/native/src/ln_dlc/mod.rs index 35b8da655..76f5def31 100644 --- a/mobile/native/src/ln_dlc/mod.rs +++ b/mobile/native/src/ln_dlc/mod.rs @@ -909,10 +909,6 @@ pub fn get_signed_dlc_channel() -> Result> { let node = state::get_node(); let signed_channels = node.inner.list_signed_dlc_channels()?; - - // TODO: Can we assume that the first DLC channel is the one we care about? We assume that we - // can only have one DLC channel at a time (for now), but what if the previous DLC channel is - // still being closed on-chain? Ok(signed_channels.first().cloned()) } From 448fe5500e8f654b1d3c9b8c4b824aee551150dd Mon Sep 17 00:00:00 2001 From: Richard Holzeis Date: Thu, 25 Jan 2024 12:18:41 +0100 Subject: [PATCH 2/3] chore(mobile): Remove unused service --- mobile/lib/common/init_service.dart | 2 +- mobile/lib/features/trade/trade_value_change_notifier.dart | 4 +--- mobile/test/trade_test.dart | 4 +--- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/mobile/lib/common/init_service.dart b/mobile/lib/common/init_service.dart index ed4fa358a..41a2cd81a 100644 --- a/mobile/lib/common/init_service.dart +++ b/mobile/lib/common/init_service.dart @@ -44,7 +44,7 @@ List createProviders() { var providers = [ ChangeNotifierProvider(create: (context) { - return TradeValuesChangeNotifier(tradeValuesService, channelInfoService); + return TradeValuesChangeNotifier(tradeValuesService); }), ChangeNotifierProvider(create: (context) => AmountDenominationChangeNotifier()), ChangeNotifierProvider(create: (context) => SubmitOrderChangeNotifier(OrderService())), diff --git a/mobile/lib/features/trade/trade_value_change_notifier.dart b/mobile/lib/features/trade/trade_value_change_notifier.dart index b287a8a34..bb0006d2f 100644 --- a/mobile/lib/features/trade/trade_value_change_notifier.dart +++ b/mobile/lib/features/trade/trade_value_change_notifier.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:get_10101/bridge_generated/bridge_definitions.dart' as bridge; -import 'package:get_10101/common/application/channel_info_service.dart'; import 'package:get_10101/common/application/event_service.dart'; import 'package:get_10101/common/domain/model.dart'; import 'package:get_10101/common/dummy_values.dart'; @@ -12,7 +11,6 @@ import 'package:get_10101/features/trade/domain/trade_values.dart'; class TradeValuesChangeNotifier extends ChangeNotifier implements Subscriber { final TradeValuesService tradeValuesService; - final ChannelInfoService channelInfoService; // The trade values are represented as Order domain, because that's essentially what they are late final TradeValues _buyTradeValues; @@ -20,7 +18,7 @@ class TradeValuesChangeNotifier extends ChangeNotifier implements Subscriber { Price? _price; - TradeValuesChangeNotifier(this.tradeValuesService, this.channelInfoService) { + TradeValuesChangeNotifier(this.tradeValuesService) { _buyTradeValues = _initOrder(Direction.long); _sellTradeValues = _initOrder(Direction.short); } diff --git a/mobile/test/trade_test.dart b/mobile/test/trade_test.dart index c20dddc48..b9512c3ff 100644 --- a/mobile/test/trade_test.dart +++ b/mobile/test/trade_test.dart @@ -137,9 +137,7 @@ void main() { positionChangeNotifier.price = Price(bid: 30000.0, ask: 30000.0); await tester.pumpWidget(MultiProvider(providers: [ - ChangeNotifierProvider( - create: (context) => - TradeValuesChangeNotifier(tradeValueService, channelConstraintsService)), + ChangeNotifierProvider(create: (context) => TradeValuesChangeNotifier(tradeValueService)), ChangeNotifierProvider(create: (context) => submitOrderChangeNotifier), ChangeNotifierProvider(create: (context) => OrderChangeNotifier(orderService)), ChangeNotifierProvider(create: (context) => positionChangeNotifier), From 1648cfe6bd9384b5b019d8956132b1ee0efb0027 Mon Sep 17 00:00:00 2001 From: Richard Holzeis Date: Thu, 25 Jan 2024 13:03:52 +0100 Subject: [PATCH 3/3] chore: Enforce minimum quantity to 500 on dlc channel open. --- CHANGELOG.md | 2 ++ mobile/lib/features/trade/trade_value_change_notifier.dart | 2 +- mobile/native/src/channel_trade_constraints.rs | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 72fea5dc6..d4023eaf4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Chore: Enforce minimum quantity to 500 on dlc channel open + ## [1.8.0] - 2024-01-23 - Chore: move telegram link into toplevel of settings so that it can be found easier diff --git a/mobile/lib/features/trade/trade_value_change_notifier.dart b/mobile/lib/features/trade/trade_value_change_notifier.dart index bb0006d2f..5c21a8da3 100644 --- a/mobile/lib/features/trade/trade_value_change_notifier.dart +++ b/mobile/lib/features/trade/trade_value_change_notifier.dart @@ -24,7 +24,7 @@ class TradeValuesChangeNotifier extends ChangeNotifier implements Subscriber { } TradeValues _initOrder(Direction direction) { - Amount defaultQuantity = Amount(100); + Amount defaultQuantity = Amount(500); Leverage defaultLeverage = Leverage(2); switch (direction) { diff --git a/mobile/native/src/channel_trade_constraints.rs b/mobile/native/src/channel_trade_constraints.rs index 8b97b050e..595ccb1e8 100644 --- a/mobile/native/src/channel_trade_constraints.rs +++ b/mobile/native/src/channel_trade_constraints.rs @@ -7,9 +7,11 @@ pub fn channel_trade_constraints() -> Result { let lsp_config = crate::state::try_get_lsp_config().context("We can't trade without LSP config")?; + let signed_channel = ln_dlc::get_signed_dlc_channel()?; + // TODO(bonomat): retrieve these values from the coordinator. This can come from the liquidity // options. - let min_quantity = 100; + let min_quantity = signed_channel.map(|_| 100).unwrap_or(500); // TODO(bonomat): this logic should be removed once we have our liquidity options again and the // on-boarding logic. For now we take the highest liquidity option