CW-674: Enhance Exchange Flow - Add estimated receive amount and amount currency to Confirm Sending Details Page (#1547)

* fix: Improve exchange flow by adding a timeout to the call to fetch rate from providers

* fix: Adjust time limit for fetching rate to 7 seconds and add timelimit to fetching limits

* fix: Make fetch limits a Future.wait

* feat: Add currency for amount and estimated receive amount to confirm sending page for exchange

* fix: Remove unneeded code

* fix: Modify receive amount to reflect value coming from the individual exchange providers if available and ensure receiveAmount is calculated based on selected exchange provider's rate
This commit is contained in:
David Adegoke 2024-07-23 01:20:55 +01:00 committed by GitHub
parent 1b109ac702
commit 5c9f176d18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 174 additions and 122 deletions

View file

@ -40,7 +40,7 @@ class ThorChainExchangeProvider extends ExchangeProvider {
static const _txInfoPath = '/thorchain/tx/status/';
static const _affiliateName = 'cakewallet';
static const _affiliateBps = '175';
static const _nameLookUpPath= 'v2/thorname/lookup/';
static const _nameLookUpPath = 'v2/thorname/lookup/';
final Box<Trade> tradesStore;
@ -137,19 +137,27 @@ class ThorChainExchangeProvider extends ExchangeProvider {
final inputAddress = responseJSON['inbound_address'] as String?;
final memo = responseJSON['memo'] as String?;
final directAmountOutResponse = responseJSON['expected_amount_out'] as String?;
String? receiveAmount;
if (directAmountOutResponse != null) {
receiveAmount = _thorChainAmountToDouble(directAmountOutResponse).toString();
}
return Trade(
id: '',
from: request.fromCurrency,
to: request.toCurrency,
provider: description,
inputAddress: inputAddress,
createdAt: DateTime.now(),
amount: request.fromAmount,
state: TradeState.notFound,
payoutAddress: request.toAddress,
memo: memo,
isSendAll: isSendAll);
id: '',
from: request.fromCurrency,
to: request.toCurrency,
provider: description,
inputAddress: inputAddress,
createdAt: DateTime.now(),
amount: request.fromAmount,
receiveAmount: receiveAmount ?? request.toAmount,
state: TradeState.notFound,
payoutAddress: request.toAddress,
memo: memo,
isSendAll: isSendAll,
);
}
@override
@ -234,7 +242,6 @@ class ThorChainExchangeProvider extends ExchangeProvider {
return chainToAddressMap;
}
Future<Map<String, dynamic>> _getSwapQuote(Map<String, String> params) async {
Uri uri = Uri.https(_baseNodeURL, _quotePath, params);