Skip to content

Commit

Permalink
fix: 🐛 Fix lp token fiat calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
redDwarf03 committed Oct 31, 2024
1 parent 5cbbd37 commit 1a5ec56
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
flutter 3.24.3-stable
flutter 3.24.4-stable
nodejs 21.2.0
5 changes: 3 additions & 2 deletions lib/application/aeswap/dex_token.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,17 @@ Future<double> _estimateLPTokenInFiat(
final amounts = await ref.watch(
DexTokensProviders.getRemoveAmounts(poolAddress, lpTokenAmount).future,
);

if (fiatValueToken1 > 0 && fiatValueToken2 > 0) {
return amounts.token1 * fiatValueToken1 + amounts.token2 * fiatValueToken2;
}

if (fiatValueToken1 > 0 && fiatValueToken2 == 0) {
return (amounts.token1 + amounts.token2) * fiatValueToken1;
return (2 * amounts.token1) * fiatValueToken1;
}

if (fiatValueToken1 == 0 && fiatValueToken2 > 0) {
return (amounts.token1 + amounts.token2) * fiatValueToken2;
return (2 * amounts.token2) * fiatValueToken2;
}

return 0;
Expand Down
8 changes: 4 additions & 4 deletions lib/ui/views/tokens_list/layouts/components/token_detail.dart
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class _TokenDetailState extends ConsumerState<TokenDetail> {
AutoSizeText(
minFontSize: 5,
wrapWords: false,
'${widget.aeToken.balance.formatNumber(precision: 8)} ${widget.aeToken.balance > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
'${widget.aeToken.balance.formatNumber(precision: widget.aeToken.balance > 1 ? 4 : 8)} ${widget.aeToken.balance > 1 ? AppLocalizations.of(context)!.lpTokens : AppLocalizations.of(context)!.lpToken}',
style:
AppTextStyles.bodyMedium(
context,
Expand Down Expand Up @@ -372,7 +372,7 @@ class _TokenDetailState extends ConsumerState<TokenDetail> {
AutoSizeText(
minFontSize: 5,
overflow: TextOverflow.ellipsis,
'${widget.aeToken.balance.formatNumber(precision: 8)} ${widget.aeToken.symbol.reduceSymbol(lengthMax: 6)}',
'${widget.aeToken.balance.formatNumber(precision: widget.aeToken.balance > 1 ? 4 : 8)} ${widget.aeToken.symbol.reduceSymbol(lengthMax: 6)}',
style: AppTextStyles.bodyMedium(
context,
),
Expand Down Expand Up @@ -407,15 +407,15 @@ class _TokenDetailState extends ConsumerState<TokenDetail> {
AutoSizeText(
minFontSize: 5,
wrapWords: false,
'${widget.aeToken.balance.formatNumber(precision: 8)} ${widget.aeToken.lpTokenPair!.token1.symbol.reduceSymbol()}/${widget.aeToken.lpTokenPair!.token2.symbol.reduceSymbol()}',
'${widget.aeToken.balance.formatNumber(precision: widget.aeToken.balance > 1 ? 4 : 8)} ${widget.aeToken.lpTokenPair!.token1.symbol.reduceSymbol()}/${widget.aeToken.lpTokenPair!.token2.symbol.reduceSymbol()}',
style:
AppTextStyles.bodyMedium(context),
)
else
AutoSizeText(
minFontSize: 5,
wrapWords: false,
'${widget.aeToken.balance.formatNumber(precision: 8)} ${widget.aeToken.symbol.reduceSymbol(lengthMax: 10)}',
'${widget.aeToken.balance.formatNumber(precision: widget.aeToken.balance > 1 ? 4 : 8)} ${widget.aeToken.symbol.reduceSymbol(lengthMax: 10)}',
style:
AppTextStyles.bodyMedium(context),
),
Expand Down

0 comments on commit 1a5ec56

Please sign in to comment.