cake_wallet/lib/exchange/exchange_provider.dart
Omar Hatem c50eeee58b
CW 68 exchange automatic rate selector (#472)
* Add 'Exchange provider picker'
Save user selections

* Save user's exchange providers selection

* Add text for selected providers availability

* Fix selected providers not updating

* Load limits based on highest maximum in the selected providers

* Change received and deposit amount to be the best value from the selected providers

* Add provider name next to Trade ID
Set selected provider based on amount calculated

* Grey out providers who doesn't support selected currency pair

* Fix disabled providers

* Add Provider logo in Confirm Screen

* Only choose a provider if it satisfies its limits

* Fix amount validation

* Fix typo in error message

* Add a queue of possible exchange providers sorted by the best rate to try next if one failed

* Fix string locale typo

* Add Localization for other languages

* Add Placeholder text when there are no providers selected

* Check Exchange provider availability before creating a trade

* Fix "Fixed Rate" changing unconditionally

* Enable "convert to" field regardless of the provider

* Remove "Choose one" from providers picker

* Merge Master

* Fix Conflicts with master

* Add missing isEnabled field in simple swap provider
2022-09-01 15:12:38 +01:00

28 lines
1 KiB
Dart

import 'package:flutter/foundation.dart';
import 'package:cw_core/crypto_currency.dart';
import 'package:cake_wallet/exchange/trade_request.dart';
import 'package:cake_wallet/exchange/exchange_pair.dart';
import 'package:cake_wallet/exchange/limits.dart';
import 'package:cake_wallet/exchange/trade.dart';
import 'package:cake_wallet/exchange/exchange_provider_description.dart';
abstract class ExchangeProvider {
ExchangeProvider({this.pairList});
String get title;
List<ExchangePair> pairList;
ExchangeProviderDescription description;
bool get isAvailable;
bool get isEnabled;
@override
String toString() => title;
Future<Limits> fetchLimits(
{CryptoCurrency from, CryptoCurrency to, bool isFixedRateMode});
Future<Trade> createTrade({TradeRequest request, bool isFixedRateMode});
Future<Trade> findTradeById({@required String id});
Future<double> calculateAmount({CryptoCurrency from, CryptoCurrency to,
double amount, bool isFixedRateMode, bool isReceiveAmount});
Future<bool> checkIsAvailable();
}