Skip to content

Commit

Permalink
Merge pull request #1899 from get10101/chore/enforce-smallest-channel…
Browse files Browse the repository at this point in the history
…-size

chore: Enforce minimum quantity to 500 on dlc channel open
  • Loading branch information
bonomat authored Jan 25, 2024
2 parents 09ef46d + 1648cfe commit ab6df80
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 13 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion mobile/lib/common/init_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ List<SingleChildWidget> createProviders() {

var providers = [
ChangeNotifierProvider(create: (context) {
return TradeValuesChangeNotifier(tradeValuesService, channelInfoService);
return TradeValuesChangeNotifier(tradeValuesService);
}),
ChangeNotifierProvider(create: (context) => AmountDenominationChangeNotifier()),
ChangeNotifierProvider(create: (context) => SubmitOrderChangeNotifier(OrderService())),
Expand Down
6 changes: 2 additions & 4 deletions mobile/lib/features/trade/trade_value_change_notifier.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -12,21 +11,20 @@ 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;
late final TradeValues _sellTradeValues;

Price? _price;

TradeValuesChangeNotifier(this.tradeValuesService, this.channelInfoService) {
TradeValuesChangeNotifier(this.tradeValuesService) {
_buyTradeValues = _initOrder(Direction.long);
_sellTradeValues = _initOrder(Direction.short);
}

TradeValues _initOrder(Direction direction) {
Amount defaultQuantity = Amount(100);
Amount defaultQuantity = Amount(500);
Leverage defaultLeverage = Leverage(2);

switch (direction) {
Expand Down
4 changes: 3 additions & 1 deletion mobile/native/src/channel_trade_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ pub fn channel_trade_constraints() -> Result<TradeConstraints> {
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
Expand Down
4 changes: 0 additions & 4 deletions mobile/native/src/ln_dlc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1144,10 +1144,6 @@ pub fn get_signed_dlc_channel() -> Result<Option<SignedChannel>> {
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())
}

Expand Down
4 changes: 1 addition & 3 deletions mobile/test/trade_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit ab6df80

Please sign in to comment.