Updated on 2026-08-14

This commit is contained in:
Tangem 2025-10-22 22:05:13 +05:00
parent 8c258d0b7c
commit aa6f185cd1
19 changed files with 343 additions and 205 deletions

View file

@ -1106,6 +1106,7 @@
<string name="story_web3_title">Compatible con Web 3.0</string>
<string name="sui_not_enough_coin_for_fee_description">Se requiere una transacción entrante de al menos %1$s para proceder</string>
<string name="sui_not_enough_coin_for_fee_title">Fondos insuficientes</string>
<string name="swap_approve_description">Al aprobar, permites que el contrato inteligente use tus tokens en futuras transacciones.</string>
<string name="swap_fixed_rate">Tasa Fija</string>
<string name="swap_give_permission_fee_footer">La red cobrará una tasa de aprobación del token para verificar que usted autoriza el uso de su token para el intercambio.</string>
<string name="swap_promo_text">Intercambie más tokens a mejores tasas directamente en su billetera.</string>
@ -1400,6 +1401,7 @@
<string name="wc_alert_wrong_card_title">Tenemos algún tipo de problema</string>
<string name="wc_all_dapps_disconnected">Todas las dApps desconectadas</string>
<string name="wc_allow_to_spend">Permitir gastar</string>
<string name="wc_approve_description">Al aprobar, permites que la dApp o el contrato inteligente utilicen los tokens en futuras transacciones.</string>
<string name="wc_common_address">Dirección</string>
<string name="wc_common_connect">Conectar</string>
<string name="wc_common_loading">Cargando</string>

View file

@ -1080,6 +1080,7 @@
<string name="story_web3_title">Compatible avec Web 3.0</string>
<string name="sui_not_enough_coin_for_fee_description">Une transaction entrante d\'au moins de %1$s est requise pour continuer</string>
<string name="sui_not_enough_coin_for_fee_title">Fonds insuffisants</string>
<string name="swap_approve_description">En approuvant, vous autorisez le contrat intelligent à utiliser vos jetons dans de futures transactions.</string>
<string name="swap_fixed_rate">Taux fixe</string>
<string name="swap_give_permission_fee_footer">Le réseau facturera des frais d\'approbation de jeton pour vérifier que vous autorisez l\'utilisation de votre jeton pour l\'échange.</string>
<string name="swap_promo_text">Échangez plus de jetons à de meilleurs taux directement dans votre portefeuille.</string>
@ -1386,6 +1387,7 @@
<string name="wc_alert_wrong_card_title">Nous avons un problème.</string>
<string name="wc_all_dapps_disconnected">Toutes les dApps sont déconnectées</string>
<string name="wc_allow_to_spend">Autoriser à dépenser</string>
<string name="wc_approve_description">En approuvant, vous autorisez la dApp ou le contrat intelligent à utiliser les jetons dans de futures transactions.</string>
<string name="wc_common_address">Adresse</string>
<string name="wc_common_connect">Connecter</string>
<string name="wc_common_loading">Chargement</string>
@ -1453,4 +1455,5 @@
<string name="xtz_withdrawal_message_ignore">Non, envoyer toute la somme</string>
<string name="xtz_withdrawal_message_reduce">Réduire de %s XTZ</string>
<string name="xtz_withdrawal_message_warning">Pour ne pas payer un fraid de commissions élevé la prochaine fois que vous rechargez votre portefeuille, veuillez réduire le montant de %s XTZ</string>
<string name="yield_module_fee_policy_sheet_fee_note">Des frais de réseau d\'environ %1$s (%2$s) seront déduits de chaque recharge future, sans dépasser votre limite de %3$s (%4$s).</string>
</resources>

View file

@ -23,6 +23,8 @@
<string name="account_archived_recover_error_title">アカウントを復元できません</string>
<string name="account_archived_title">アーカイブ済み</string>
<string name="account_could_not_archive">アカウントをアーカイブできませんでした。しばらくしてからもう一度お試しください。</string>
<string name="account_could_not_archive_referral_program_message">このアカウントは紹介プログラムに参加しています。</string>
<string name="account_could_not_archive_referral_program_title">このアカウントはアーカイブできません。</string>
<string name="account_could_not_create">アカウントを作成できませんでした。しばらくしてからもう一度お試しください。</string>
<string name="account_create_success_message">アカウントを作成しました</string>
<string name="account_details_archive">アカウントをアーカイブする</string>
@ -42,6 +44,8 @@
<string name="account_form_title_edit">アカウントを編集</string>
<string name="account_label_tokens_info">%1$s ( %2$s内)</string>
<string name="account_main_account_title">メインアカウント</string>
<string name="account_recover_limit_dialog_description">すでにアクティブアカウントの上限%1$s件を超えています。復元するには、1つをアーカイブしてください。</string>
<string name="account_recover_limit_dialog_title">アカウントを復元できません</string>
<string name="account_recover_success_message">アカウントが回復しました</string>
<string name="account_reorder_description">アカウントを長押しして並べ替える</string>
<string name="account_unsaved_dialog_action_first">編集を続ける</string>
@ -546,6 +550,7 @@
<string name="hw_backup_section_other_title">その他の方法</string>
<string name="hw_backup_seed_description">秘密鍵をオフラインで安全に保存する物理デバイス。</string>
<string name="hw_backup_seed_title">リカバリーフレーズ</string>
<string name="hw_backup_to_upgrade_description">ウォレットをハードウェアにアップグレードするには、まずバックアップしてください。</string>
<string name="hw_create_keys_title">鍵はアプリに保存されます</string>
<string name="hw_create_seed_title">シードフレーズのバックアップ</string>
<string name="hw_create_title">モバイルウォレットを作成する</string>
@ -1303,6 +1308,8 @@
<string name="tangem_pay_transaction_fee_notification_text">この手数料は、送金処理にかかるコストをカバーするためのものです。</string>
<string name="tangem_pay_withdrawal">出金</string>
<string name="tangempay_card_details_change_pin">PINを変更する</string>
<string name="tangempay_card_details_change_pin_success_description">カードは支払いの準備が整いました。</string>
<string name="tangempay_card_details_change_pin_success_title">PINコードを作成しました</string>
<string name="tangempay_card_details_error_text">データの読み込みに失敗しました。しばらくしてからもう一度お試しください。</string>
<string name="tangempay_card_details_freeze_card">カードの一時停止</string>
<string name="tangempay_card_details_hide_text">非表示</string>
@ -1733,8 +1740,9 @@
<string name="xtz_withdrawal_message_ignore">いいえ、すべて送信します</string>
<string name="xtz_withdrawal_message_reduce">%s XTZを減らす</string>
<string name="xtz_withdrawal_message_warning">次回ウォレットにチャージするときに手数料の増加を避けるには、金額を%s XTZ減らしてください。</string>
<string name="yield_module_alert_title">%sはAaveに預けられています</string>
<string name="yield_module_amount_not_transfered_to_aave_title">受け取った金額%1$s %2$sはAaveに入金されませんでした。</string>
<string name="yield_module_alert_description">あなたの資金は現在Aaveプロトコルに供給されていますが、いつでも管理できます。</string>
<string name="yield_module_alert_title">%sはAaveに供給されています</string>
<string name="yield_module_amount_not_transfered_to_aave_title">Aaveへの%1$s %2$sの供給は保留中です</string>
<string name="yield_module_approve_needed_notification_cta">承認する</string>
<string name="yield_module_approve_needed_notification_description">前回の承認に問題があったため、新しい承認が必要です。手続き方法を選択してください。</string>
<string name="yield_module_approve_needed_notification_title">承認が必要</string>
@ -1748,62 +1756,63 @@
<string name="yield_module_earn_badge">年利%1$s%%</string>
<string name="yield_module_earn_sheet_available_title">利用可能</string>
<string name="yield_module_earn_sheet_current_apy_title">現在のAPY</string>
<string name="yield_module_earn_sheet_fee_description">貸付のためにチャージする際は、ネットワーク手数料が金額から差し引かれます(手数料は常に%1$s以下です</string>
<string name="yield_module_earn_sheet_fee_description">貸付のために入金する際は、残高から%1$s以下のネットワーク手数料が差し引かれます</string>
<string name="yield_module_earn_sheet_high_fee_description">現在、ネットワーク手数料が高すぎるため貸付を実行できません。手数料が%1$s以下に下がり次第、資金が供給されます。</string>
<string name="yield_module_earn_sheet_my_funds_title">私の資金</string>
<string name="yield_module_earn_sheet_provider_description">あなたの%1$sはAaveに預けられ、利息が付きます。あなたは%2$sトークンを保有しており、これは残高を表し、時間の経過とともに増加します。入金すると、資金はAaveに預け入れられ、取引手数料を差し引いた利息が付きます。</string>
<string name="yield_module_earn_sheet_provider_description">あなたの%1$sはAaveに預けられ、利息が付きます。あなたは%2$sトークンを保有しており、これは残高を表し、時間の経過とともに増加します。入金すると資金はAaveに供給され、取引手数料を差し引いた利息が付きます。</string>
<string name="yield_module_earn_sheet_title">利回りを得る</string>
<string name="yield_module_earn_sheet_total_earnings_title">総収益</string>
<string name="yield_module_earn_sheet_transfers_title">Aaveへの送金</string>
<string name="yield_module_explore_sheet_explore_aave_button_title">Aaveの詳細を見る</string>
<string name="yield_module_fee_policy_sheet_current_fee_note">これは%sの現在の供給手数料です。実際のコストは受取画面に表示されます。</string>
<string name="yield_module_fee_policy_sheet_current_fee_note">これは%sの現在の供給手数料です。実際のコストはアクティベーションタブに表示されます。</string>
<string name="yield_module_fee_policy_sheet_current_fee_title">現在の手数料</string>
<string name="yield_module_fee_policy_sheet_description">今後の%sの入金はすべて、取引手数料が差し引かれて自動的にAaveに供給されます。</string>
<string name="yield_module_fee_policy_sheet_fee_note">今後のチャージごとに、おおよそ%1$s%2$sのネットワーク手数料が差し引かれますが、上限の%3$s%4$sを超えることはありません。</string>
<string name="yield_module_fee_policy_sheet_max_fee_note">ネットワーク手数料が上限手数料を超えた場合、手数料が下がるまで取引は成立しません。この制限は後で変更できます。</string>
<string name="yield_module_fee_policy_sheet_max_fee_title">最大手数料</string>
<string name="yield_module_fee_policy_sheet_min_amount_note">取引手数料は入金額の4%未満である必要があります。残高がこの条件を満たすのに十分な金額になった場合にのみ、TangemはAaveに資金を送ります。</string>
<string name="yield_module_fee_policy_sheet_min_amount_note">最小金額は現在のネットワーク手数料に基づいて計算されており、手数料が4を超えないように設定されています。その結果、最小金額は%1$s%2$sとなります。</string>
<string name="yield_module_fee_policy_sheet_min_amount_title">最低入金額</string>
<string name="yield_module_fee_policy_sheet_title">手数料ポリシー</string>
<string name="yield_module_fee_policy_tangem_service_fee_title">Tangemはまた、得られた利回りに対して3%のサービス手数料を差し引きます。</string>
<string name="yield_module_high_fee_error">ネットワーク手数料が下がるか、残高が必要な最低額に達すると、自動的にAaveへ送金されます。</string>
<string name="yield_module_high_fee_error">ネットワーク手数料が下がるか、残高が最低必要額に達すると、資金は自動的にAaveに供給されます。</string>
<string name="yield_module_historical_returns">過去のリターン</string>
<string name="yield_module_main_view_approve_notification_description">ここに説明を入力してください。1〜3行が理想的です。[プレースホルダー]</string>
<string name="yield_module_main_view_approve_notification_title">トークン承認が必要</string>
<string name="yield_module_main_view_approve_notification_title">トークン承認が必要</string>
<string name="yield_module_network_fee_unreachable_notification_description">ネットワーク接続を確認してください</string>
<string name="yield_module_network_fee_unreachable_notification_title">ネットワーク手数料についての情報にアクセスできません</string>
<string name="yield_module_promo_screen_auto_balance_subtitle">アカウントへの入金はすべて自動的にAaveに貸し出されます。</string>
<string name="yield_module_promo_screen_auto_balance_title">残高は自動的に計算されます</string>
<string name="yield_module_promo_screen_auto_balance_subtitle">あなたが行うすべての入金は、自動的にAaveへ供給されます。</string>
<string name="yield_module_promo_screen_auto_balance_title">Aaveへの自動送金</string>
<string name="yield_module_promo_screen_cash_out_subtitle">いつでも、即座に資金を送信、交換、売却できます。</string>
<string name="yield_module_promo_screen_cash_out_title">いつでも資金にアクセス可能</string>
<string name="yield_module_promo_screen_how_it_works_button_title">使い方</string>
<string name="yield_module_promo_screen_self_custodial_subtitle">Aaveは、総額819億ドル以上の資産を管理する分散型プロトコルです。</string>
<string name="yield_module_promo_screen_self_custodial_title">分散型・自己管理型</string>
<string name="yield_module_promo_screen_terms_disclaimer">サービスを利用することにより、プロバイダー\n %1$sおよび%2$sに同意したことになります</string>
<string name="yield_module_promo_screen_terms_disclaimer">このサービスを利用することにより、プロバイダー\n%1$sおよび%2$sに同意するものとします</string>
<string name="yield_module_promo_screen_title">Aave を接続</string>
<string name="yield_module_promo_screen_variable_rate_info">Aave %1$s%% • 変動金利</string>
<string name="yield_module_provider">Aave</string>
<string name="yield_module_rate_info_sheet_chart_average">平均%s</string>
<string name="yield_module_rate_info_sheet_chart_title">昨年のリターン</string>
<string name="yield_module_rate_info_sheet_description">現在の金利は常に変動し、リアルタイムの需要と供給に基づいて、AAVEオンチェーンスマートコントラクトによって自動的に計算されます。</string>
<string name="yield_module_rate_info_sheet_description">現在の金利は常に変動し、リアルタイムの需要と供給に基づいて、Aaveオンチェーンスマートコントラクトによって自動的に計算されます。</string>
<string name="yield_module_rate_info_sheet_powered_by">提供</string>
<string name="yield_module_rate_info_sheet_title">金利は変動します</string>
<string name="yield_module_receive_sheet_description">入金すると、資金は自動的にAaveに送金され、利息が付き始めます。取引手数料として%s相当の少額の手数料が差し引かれます。</string>
<string name="yield_module_receive_sheet_description">入金すると、資金は自動的にAaveに送金され、利息が付き始めます。%sが取引手数料として差し引かれます。</string>
<string name="yield_module_start_earning">資産を供給する</string>
<string name="yield_module_start_earning_sheet_description">%sはAaveに供給され、すぐに利用可能になります</string>
<string name="yield_module_start_earning_sheet_description">%sはAaveに供給されますが、管理可能な状態のままになります。</string>
<string name="yield_module_start_earning_sheet_fee_policy">手数料ポリシーを見る</string>
<string name="yield_module_start_earning_sheet_next_deposits">次回以降の入金は自動的にAaveに供給されます。</string>
<string name="yield_module_start_earning_sheet_next_deposits">次回の入金は自動的にAaveに供給されます。</string>
<string name="yield_module_status_active">アクティブ</string>
<string name="yield_module_status_paused">停止中</string>
<string name="yield_module_stop_earning">利回りモードを無効にする</string>
<string name="yield_module_stop_earning_sheet_description">オフにすると、Aaveから資金が引き出され、ウォレットの%sに戻され、報酬の獲得が停止されます。</string>
<string name="yield_module_stop_earning_sheet_description">これをオフにすると、Aave からウォレットの %s に資金が引き出され、報酬の獲得が停止します。</string>
<string name="yield_module_stop_earning_sheet_fee_note">出金金額からネットワーク手数料が差し引かれます。</string>
<string name="yield_module_supply_apr">供給APY</string>
<string name="yield_module_token_details_earn_notification_apy">APY</string>
<string name="yield_module_token_details_earn_notification_description">自分で管理しながら、資金をバックグラウンドで運用しましょう。</string>
<string name="yield_module_token_details_earn_notification_description">自分で管理しながら、資金に働かせましょう。</string>
<string name="yield_module_token_details_earn_notification_earning_on_your_balance_subtitle">利息は自動的に発生します</string>
<string name="yield_module_token_details_earn_notification_earning_on_your_balance_title">利回りモード</string>
<string name="yield_module_token_details_earn_notification_processing">入金の処理中</string>
<string name="yield_module_token_details_earn_notification_title">残高を活用</string>
<string name="yield_module_token_details_earn_notification_title">資産を有効活用しましょう</string>
<string name="yield_module_transfer_mode_automatic">自動</string>
<string name="yield_module_unable_to_cover_fee_description">取引のネットワーク手数料をカバーするために、 %1$s %2$sを入金してください</string>
<string name="yield_module_unable_to_cover_fee_title">%s手数料を支払えません</string>

View file

@ -1494,6 +1494,7 @@
<string name="wc_alert_wrong_card_title">Похоже, возникла проблема</string>
<string name="wc_all_dapps_disconnected">Все dapps отключены</string>
<string name="wc_allow_to_spend">Разрешение на использование</string>
<string name="wc_approve_description">Подтверждая, вы разрешаете смарт-контракту использовать ваши токены в будущих транзакциях.</string>
<string name="wc_common_address">Адрес</string>
<string name="wc_common_connect">Подключение</string>
<string name="wc_common_loading">Загрузка</string>

View file

@ -1086,6 +1086,7 @@
<string name="story_web3_title">Web 3.0 сумісність</string>
<string name="sui_not_enough_coin_for_fee_description">Для відправки потрібна вхідна транзакція на суму не менше %1$s</string>
<string name="sui_not_enough_coin_for_fee_title">Недостатньо коштів</string>
<string name="swap_approve_description">Підтверджуючи, ви дозволяєте смартконтракту використовувати ваші токени в майбутніх транзакціях.</string>
<string name="swap_give_permission_fee_footer">Мережа стягує комісію за схвалення токену за підтвердження, що саме ви дозволяєте використовувати ваш токен для обміну.</string>
<string name="swap_promo_text">Обмінюйте більше токенів за вигіднішим курсом прямо у своєму гаманці.</string>
<string name="swap_promo_title">З\'явився новий провайдер обмінів!</string>
@ -1366,6 +1367,7 @@
<string name="wc_alert_wrong_card_description">Обрана не вірна картка або кільце</string>
<string name="wc_alert_wrong_card_title">Схоже, виникла проблема</string>
<string name="wc_all_dapps_disconnected">Усі dApps відключені</string>
<string name="wc_approve_description">Підтверджуючи, ви дозволяєте dApp або смартконтракту використовувати токени в майбутніх транзакціях.</string>
<string name="wc_common_address">Адреса</string>
<string name="wc_common_connect">Підключення</string>
<string name="wc_common_network">Мережа</string>

View file

@ -44,6 +44,8 @@
<string name="account_form_title_edit">Edit account</string>
<string name="account_label_tokens_info">%1$s in %2$s</string>
<string name="account_main_account_title">Main account</string>
<string name="account_recover_limit_dialog_description">You have already exceeded the limit of %1$s active accounts. Archive one to recover</string>
<string name="account_recover_limit_dialog_title">Cant recover account</string>
<string name="account_recover_success_message">Account recovered</string>
<string name="account_reorder_description">Long tap on an account to reorder accounts</string>
<string name="account_unsaved_dialog_action_first">Keep Editing</string>
@ -1837,10 +1839,11 @@
<string name="yield_module_fee_policy_sheet_current_fee_note">This is the current supply fee on %s. The actual cost will be shown on the activation tab.</string>
<string name="yield_module_fee_policy_sheet_current_fee_title">Current fee</string>
<string name="yield_module_fee_policy_sheet_description">All future %s deposits will be supplied to Aave automatically, with the transaction fee deducted.</string>
<string name="yield_module_fee_policy_sheet_fee_note">An approximate network fee of %1$s (%2$s) will be deducted from each future top-up, and it wont exceed your %3$s (%4$s) limit.</string>
<string name="yield_module_fee_policy_sheet_max_fee_note">If network fees rise above maximum fee, the transaction wont go through until they decrease. You can change this limit later.</string>
<string name="yield_module_fee_policy_sheet_max_fee_title">Maximum fee</string>
<string name="yield_module_fee_policy_sheet_min_amount_note">This is the lowest amount that can be supplied to Aave. To keep the yield mode profitable, we wont supply assets when network fees exceed 4% of the amount.</string>
<string name="yield_module_fee_policy_sheet_min_amount_title">Minimal deposit</string>
<string name="yield_module_fee_policy_sheet_min_amount_note">The minimum amount is calculated from the current network fee to ensure it does not exceed 4%%, which makes the minimum %1$s (%2$s).</string>
<string name="yield_module_fee_policy_sheet_min_amount_title">Minimum top-up</string>
<string name="yield_module_fee_policy_sheet_title">Fee policy</string>
<string name="yield_module_fee_policy_tangem_service_fee_title">Tangem also takes a 3% service fee on yield earned.</string>
<string name="yield_module_high_fee_error">Your funds will be automatically supplied to Aave once network fees are lower or your balance meets the minimum required amount.</string>
@ -1849,7 +1852,7 @@
<string name="yield_module_main_view_approve_notification_title">Token approvals needed</string>
<string name="yield_module_network_fee_unreachable_notification_description">Check your network connection</string>
<string name="yield_module_network_fee_unreachable_notification_title">Network fee info unreachable</string>
<string name="yield_module_promo_screen_auto_balance_subtitle">Every deposit you make will be suplied to Aave automatically.</string>
<string name="yield_module_promo_screen_auto_balance_subtitle">Every deposit you make will be supplied to Aave automatically.</string>
<string name="yield_module_promo_screen_auto_balance_title">Auto-Transfer to Aave</string>
<string name="yield_module_promo_screen_cash_out_subtitle">Send, swap, or sell your funds instantly, anytime you want.</string>
<string name="yield_module_promo_screen_cash_out_title">Access your funds anytime</string>

View file

@ -13,10 +13,12 @@ internal sealed class YieldSupplyFeeUM {
data object Error : YieldSupplyFeeUM()
data class Content(
val transactionDataList: ImmutableList<TransactionData.Uncompiled>,
val feeValue: TextReference,
val currentNetworkFeeValue: TextReference,
val maxNetworkFeeValue: TextReference,
val minAmountFeeValue: TextReference,
val feeFiatValue: TextReference,
val tokenFeeFiatValue: TextReference,
val maxNetworkFeeFiatValue: TextReference,
val minTopUpFiatValue: TextReference,
val feeNoteValue: TextReference = TextReference.EMPTY,
val minFeeNoteValue: TextReference = TextReference.EMPTY,
) : YieldSupplyFeeUM()
}

View file

@ -3,11 +3,13 @@ package com.tangem.features.yield.supply.impl.common.ui
import android.content.res.Configuration
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.key
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.LinkAnnotation
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.withLink
@ -85,13 +87,17 @@ internal fun YieldSupplyActionContent(
),
) {
val fee = when (val yieldSupplyFeeUM = yieldSupplyActionUM.yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.feeValue
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.feeFiatValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.common_network_fee_title),
value = fee,
modifier = Modifier.fillMaxWidth()
.clip(RoundedCornerShape(14.dp))
.background(TangemTheme.colors.background.action)
.padding(horizontal = 16.dp, vertical = 12.dp),
)
}
}
@ -138,10 +144,11 @@ private class YieldSupplyActionContentPreviewProvider : PreviewParameterProvider
currencyIconState = CurrencyIconState.Loading,
yieldSupplyFeeUM = YieldSupplyFeeUM.Content(
transactionDataList = persistentListOf(),
feeValue = stringReference("0.00020 ETH • \$0.99"),
currentNetworkFeeValue = stringReference("1.45 USDT • \$1.45"),
maxNetworkFeeValue = stringReference("8.50 USDT • \$8.50"),
minAmountFeeValue = stringReference("50 USDT • \$50"),
feeFiatValue = stringReference("$0.99"),
tokenFeeFiatValue = stringReference("$1.45"),
maxNetworkFeeFiatValue = stringReference("$8.50"),
minTopUpFiatValue = stringReference("$50"),
feeNoteValue = TextReference.EMPTY,
),
isPrimaryButtonEnabled = false,
isTransactionSending = false,

View file

@ -1,17 +1,12 @@
package com.tangem.features.yield.supply.impl.common.ui
import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import com.tangem.core.ui.components.SpacerWMax
@ -23,15 +18,11 @@ import com.tangem.core.ui.res.TangemTheme
import com.tangem.features.yield.supply.impl.R
@Composable
internal fun YieldSupplyFeeRow(title: TextReference, value: TextReference?) {
internal fun YieldSupplyFeeRow(title: TextReference, value: TextReference?, modifier: Modifier = Modifier) {
Row(
horizontalArrangement = Arrangement.spacedBy(12.dp),
verticalAlignment = Alignment.CenterVertically,
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(14.dp))
.background(TangemTheme.colors.background.action)
.padding(horizontal = 16.dp, vertical = 12.dp),
modifier = modifier,
) {
Text(
text = title.resolveReference(),

View file

@ -14,6 +14,7 @@ internal data class YieldSupplyActiveContentUM(
val minAmount: TextReference?,
val currentFee: TextReference?,
val feeDescription: TextReference?,
val minFeeDescription: TextReference?,
val apy: TextReference? = null,
val isHighFee: Boolean = false,
)

View file

@ -12,7 +12,6 @@ import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
import com.tangem.domain.appcurrency.model.AppCurrency
@ -25,11 +24,13 @@ import com.tangem.domain.yield.supply.usecase.YieldSupplyGetCurrentFeeUseCase
import com.tangem.domain.yield.supply.usecase.YieldSupplyGetMaxFeeUseCase
import com.tangem.features.yield.supply.api.analytics.YieldSupplyAnalytics
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.impl.common.formatter.YieldSupplyAmountFormatter
import com.tangem.features.yield.supply.impl.subcomponents.active.YieldSupplyActiveComponent
import com.tangem.features.yield.supply.impl.subcomponents.active.entity.YieldSupplyActiveContentUM
import com.tangem.features.yield.supply.impl.subcomponents.active.model.transformers.YieldSupplyActiveMinAmountTransformer
import com.tangem.features.yield.supply.impl.subcomponents.active.model.transformers.YieldSupplyActiveFeeContentTransformer
import com.tangem.utils.StringsSigns.DASH_SIGN
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.transformer.update
import kotlinx.collections.immutable.ImmutableList
import kotlinx.collections.immutable.persistentListOf
import kotlinx.collections.immutable.toPersistentList
@ -75,6 +76,7 @@ internal class YieldSupplyActiveModel @Inject constructor(
currentFee = null,
feeDescription = null,
isHighFee = false,
minFeeDescription = null,
),
)
@ -202,20 +204,19 @@ internal class YieldSupplyActiveModel @Inject constructor(
params.userWallet,
cryptoCurrencyStatusFlow.value,
).onRight { minAmount ->
val minAmountTextReference = YieldSupplyAmountFormatter(
cryptoCurrencyStatusFlow.value.currency,
appCurrency,
).invoke(
feeValue = minAmount,
fiatRate = cryptoCurrencyStatusFlow.value.value.fiatRate,
showCrypto = false,
uiState.update(
YieldSupplyActiveMinAmountTransformer(
cryptoCurrencyStatus = cryptoCurrencyStatusFlow.value,
appCurrency = appCurrency,
minAmount = minAmount,
),
)
uiState.update {
it.copy(minAmount = minAmountTextReference)
}
}.onLeft {
uiState.update {
it.copy(minAmount = TextReference.Str(DASH_SIGN))
it.copy(
minAmount = TextReference.Str(DASH_SIGN),
feeDescription = null,
)
}
}
}
@ -235,33 +236,23 @@ internal class YieldSupplyActiveModel @Inject constructor(
cryptoCurrencyStatus = cryptoStatus,
).getOrNull()
val currentFeeText = currentFee?.let {
YieldSupplyAmountFormatter(
cryptoStatus.currency,
appCurrency,
).invoke(
feeValue = it,
fiatRate = cryptoStatus.value.fiatRate,
showCrypto = false,
if (currentFee != null && maxFee != null) {
uiState.update(
YieldSupplyActiveFeeContentTransformer(
cryptoCurrencyStatus = cryptoStatus,
appCurrency = appCurrency,
feeValue = currentFee,
maxNetworkFee = maxFee,
),
)
}
val isHighFee = if (currentFee != null && maxFee != null) currentFee > maxFee else false
val maxFiatFee = maxFee?.multiply(cryptoStatus.value.fiatRate)
.format { fiat(appCurrency.code, appCurrency.symbol) }
val feeDescription = if (isHighFee) {
resourceReference(R.string.yield_module_earn_sheet_high_fee_description, wrappedList(maxFiatFee))
} else {
resourceReference(R.string.yield_module_earn_sheet_fee_description, wrappedList(maxFiatFee))
}
uiState.update {
it.copy(
currentFee = currentFeeText ?: stringReference(DASH_SIGN),
isHighFee = isHighFee,
feeDescription = feeDescription,
)
uiState.update {
it.copy(
currentFee = stringReference(DASH_SIGN),
feeDescription = null,
isHighFee = false,
)
}
}
}
}

View file

@ -0,0 +1,57 @@
package com.tangem.features.yield.supply.impl.subcomponents.active.model.transformers
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.core.ui.extensions.TextReference
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.impl.subcomponents.active.entity.YieldSupplyActiveContentUM
import com.tangem.utils.transformer.Transformer
import java.math.BigDecimal
/**
* Computes fee description and current fee values for Active screen based on token rates.
*/
internal class YieldSupplyActiveFeeContentTransformer(
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
private val appCurrency: AppCurrency,
private val feeValue: BigDecimal,
private val maxNetworkFee: BigDecimal,
) : Transformer<YieldSupplyActiveContentUM> {
override fun transform(prevState: YieldSupplyActiveContentUM): YieldSupplyActiveContentUM {
val cryptoCurrency = cryptoCurrencyStatus.currency
val tokenFiatRate = cryptoCurrencyStatus.value.fiatRate
val tokenCryptoFeeValueText = feeValue.format { crypto(cryptoCurrency) }
val tokenFiatFee = tokenFiatRate?.let(feeValue::multiply)
val tokenFiatFeeValueText = tokenFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) }
val maxFeeCryptoValueText = maxNetworkFee.format { crypto(cryptoCurrency) }
val maxFiatFee = tokenFiatRate?.let { rate -> maxNetworkFee.multiply(rate) }
val maxFiatFeeValueText = maxFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) }
val feeNoteValue: TextReference = resourceReference(
id = R.string.yield_module_fee_policy_sheet_fee_note,
formatArgs = wrappedList(
stringReference(tokenFiatFeeValueText),
stringReference(tokenCryptoFeeValueText),
stringReference(maxFiatFeeValueText),
stringReference(maxFeeCryptoValueText),
),
)
val isHighFee = feeValue > maxNetworkFee
return prevState.copy(
currentFee = stringReference(tokenFiatFeeValueText),
feeDescription = feeNoteValue,
isHighFee = isHighFee,
)
}
}

View file

@ -0,0 +1,46 @@
package com.tangem.features.yield.supply.impl.subcomponents.active.model.transformers
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.impl.subcomponents.active.entity.YieldSupplyActiveContentUM
import com.tangem.utils.transformer.Transformer
import java.math.BigDecimal
/**
* Computes and sets minimum amount (fiat) and fee description note
*/
internal class YieldSupplyActiveMinAmountTransformer(
private val cryptoCurrencyStatus: CryptoCurrencyStatus,
private val appCurrency: AppCurrency,
private val minAmount: BigDecimal,
) : Transformer<YieldSupplyActiveContentUM> {
override fun transform(prevState: YieldSupplyActiveContentUM): YieldSupplyActiveContentUM {
val cryptoCurrency = cryptoCurrencyStatus.currency
val tokenFiatRate = cryptoCurrencyStatus.value.fiatRate
val minAmountCryptoText = minAmount.format { crypto(cryptoCurrency) }
val minAmountFiat = tokenFiatRate?.let(minAmount::multiply)
val minAmountFiatText = minAmountFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val minFeeNoteValue = resourceReference(
id = R.string.yield_module_fee_policy_sheet_min_amount_note,
formatArgs = wrappedList(
minAmountFiatText,
minAmountCryptoText,
),
)
return prevState.copy(
minAmount = stringReference(minAmountFiatText),
minFeeDescription = minFeeNoteValue,
)
}
}

View file

@ -91,12 +91,14 @@ internal fun YieldSupplyActiveContent(
)
}
Text(
modifier = Modifier.padding(horizontal = 12.dp),
text = stringResourceSafe(R.string.yield_module_fee_policy_sheet_min_amount_note),
style = TangemTheme.typography.caption2,
color = TangemTheme.colors.text.tertiary,
)
AnimatedVisibility(state.minFeeDescription != null) {
Text(
modifier = Modifier.padding(horizontal = 12.dp),
text = state.minFeeDescription?.resolveReference().orEmpty(),
style = TangemTheme.typography.caption2,
color = TangemTheme.colors.text.tertiary,
)
}
}
}
@ -376,6 +378,10 @@ private class YieldSupplyActiveBottomSheetPreviewProvider : PreviewParameterProv
),
apy = stringReference("5,14%"),
isHighFee = true,
minFeeDescription = stringReference(
"The network fee is currently too high to execute lending." +
"Funds will be supplied once it drops to \$12 or below. ",
),
),
)
}

View file

@ -10,7 +10,6 @@ import com.tangem.core.decompose.model.ParamsContainer
import com.tangem.core.navigation.url.UrlOpener
import com.tangem.core.ui.components.currency.icon.converter.CryptoCurrencyToIconStateConverter
import com.tangem.core.ui.extensions.*
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.GetSelectedAppCurrencyUseCase
@ -33,7 +32,7 @@ import com.tangem.features.yield.supply.impl.subcomponents.approve.YieldSupplyAp
import com.tangem.features.yield.supply.impl.subcomponents.notifications.YieldSupplyNotificationsComponent
import com.tangem.features.yield.supply.impl.subcomponents.notifications.YieldSupplyNotificationsUpdateTrigger
import com.tangem.features.yield.supply.impl.subcomponents.notifications.entity.YieldSupplyNotificationData
import com.tangem.utils.StringsSigns.DOT
import com.tangem.core.ui.extensions.TextReference
import com.tangem.utils.TangemBlogUrlBuilder
import com.tangem.utils.coroutines.CoroutineDispatcherProvider
import com.tangem.utils.transformer.update
@ -220,7 +219,6 @@ internal class YieldSupplyApproveModel @Inject constructor(
val feeFiatValue = feeCryptoCurrencyStatus.value.fiatRate?.let { rate ->
feeCryptoValue?.multiply(rate)
}
val cryptoFee = feeCryptoValue.format { crypto(feeCryptoCurrencyStatus.currency) }
val fiatFee = feeFiatValue.format { fiat(appCurrency.code, appCurrency.symbol) }
uiState.update {
@ -233,14 +231,11 @@ internal class YieldSupplyApproveModel @Inject constructor(
transactionDataList = persistentListOf(
approvalTransitionData.copy(fee = transactionFee.normal),
),
feeValue = combinedReference(
stringReference(cryptoFee),
stringReference(" $DOT "),
stringReference(fiatFee),
),
currentNetworkFeeValue = TextReference.EMPTY,
maxNetworkFeeValue = TextReference.EMPTY,
minAmountFeeValue = TextReference.EMPTY,
feeFiatValue = stringReference(fiatFee),
tokenFeeFiatValue = TextReference.EMPTY,
maxNetworkFeeFiatValue = TextReference.EMPTY,
minTopUpFiatValue = TextReference.EMPTY,
feeNoteValue = TextReference.EMPTY,
),
)
}

View file

@ -38,7 +38,6 @@ internal class YieldSupplyFeePolicyComponent(
YieldSupplyFeePolicyContent(
yieldSupplyFeeUM = uiState.yieldSupplyFeeUM,
tokenSymbol = params.cryptoCurrency.symbol,
networkName = params.cryptoCurrency.network.name,
modifier = modifier,
)
}

View file

@ -6,10 +6,12 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
@ -34,7 +36,6 @@ import kotlinx.collections.immutable.persistentListOf
internal fun YieldSupplyFeePolicyContent(
yieldSupplyFeeUM: YieldSupplyFeeUM,
tokenSymbol: String,
networkName: String,
modifier: Modifier = Modifier,
) {
Column(
@ -62,68 +63,51 @@ internal fun YieldSupplyFeePolicyContent(
modifier = Modifier.padding(horizontal = 16.dp),
)
SpacerH24()
FooterContainer(
footer = resourceReference(
id = R.string.yield_module_fee_policy_sheet_min_amount_note,
formatArgs = wrappedList(networkName),
),
paddingValues = PaddingValues(
top = 8.dp,
start = 12.dp,
end = 12.dp,
),
) {
val minAmount = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.minAmountFeeValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_min_amount_title),
value = minAmount,
)
}
MinFeeNote(yieldSupplyFeeUM)
SpacerH16()
val feeNote = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.feeNoteValue
YieldSupplyFeeUM.Error -> null
YieldSupplyFeeUM.Loading -> null
}
FooterContainer(
footer = resourceReference(
id = R.string.yield_module_fee_policy_sheet_current_fee_note,
formatArgs = wrappedList(networkName),
),
footer = feeNote,
paddingValues = PaddingValues(
top = 8.dp,
start = 12.dp,
end = 12.dp,
),
) {
val currentFee = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.currentNetworkFeeValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
Column(
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(14.dp))
.background(TangemTheme.colors.background.action)
.padding(horizontal = 16.dp),
) {
val currentFee = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.tokenFeeFiatValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_current_fee_title),
value = currentFee,
modifier = Modifier.padding(vertical = 12.dp),
)
val maxFee = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.maxNetworkFeeFiatValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_max_fee_title),
value = maxFee,
modifier = Modifier.padding(vertical = 12.dp),
)
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_current_fee_title),
value = currentFee,
)
}
SpacerH16()
FooterContainer(
footer = resourceReference(R.string.yield_module_fee_policy_sheet_max_fee_note),
paddingValues = PaddingValues(
top = 8.dp,
start = 12.dp,
end = 12.dp,
),
) {
val maxFee = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.maxNetworkFeeValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_max_fee_title),
value = maxFee,
)
}
SpacerH8()
Text(
text = stringResourceSafe(R.string.yield_module_fee_policy_tangem_service_fee_title),
style = TangemTheme.typography.caption2,
@ -139,6 +123,38 @@ internal fun YieldSupplyFeePolicyContent(
}
}
@Composable
private fun MinFeeNote(yieldSupplyFeeUM: YieldSupplyFeeUM) {
val minFeeNote = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.feeNoteValue
YieldSupplyFeeUM.Error -> null
YieldSupplyFeeUM.Loading -> null
}
FooterContainer(
footer = minFeeNote,
paddingValues = PaddingValues(
top = 8.dp,
start = 12.dp,
end = 12.dp,
),
) {
val minAmount = when (yieldSupplyFeeUM) {
is YieldSupplyFeeUM.Content -> yieldSupplyFeeUM.minTopUpFiatValue
YieldSupplyFeeUM.Error -> stringReference(StringsSigns.DASH_SIGN)
YieldSupplyFeeUM.Loading -> null
}
YieldSupplyFeeRow(
title = resourceReference(R.string.yield_module_fee_policy_sheet_min_amount_title),
value = minAmount,
modifier = Modifier
.fillMaxWidth()
.clip(RoundedCornerShape(14.dp))
.background(TangemTheme.colors.background.action)
.padding(horizontal = 16.dp, vertical = 12.dp),
)
}
}
// region Preview
@Composable
@Preview(showBackground = true, widthDp = 360)
@ -148,13 +164,21 @@ private fun YieldSupplyFeePolicyContent_Preview() {
YieldSupplyFeePolicyContent(
yieldSupplyFeeUM = YieldSupplyFeeUM.Content(
transactionDataList = persistentListOf(),
feeValue = stringReference("0.0001 ETH • \$1.45"),
maxNetworkFeeValue = stringReference("8.50 USDT • \$8.50"),
currentNetworkFeeValue = stringReference("1.45 USDT • \$1.45"),
minAmountFeeValue = stringReference("50 USDT • \$50"),
feeFiatValue = stringReference("$1.45"),
maxNetworkFeeFiatValue = stringReference("$8.50"),
tokenFeeFiatValue = stringReference("$1.45"),
minTopUpFiatValue = stringReference("$50"),
feeNoteValue = resourceReference(
id = R.string.yield_module_fee_policy_sheet_fee_note,
formatArgs = wrappedList(
stringReference("$1.45"),
stringReference("1.46 USDT"),
stringReference("$8.50"),
stringReference("8.50 USDT"),
),
),
),
tokenSymbol = "USDT",
networkName = "Ethereum",
modifier = Modifier.background(TangemTheme.colors.background.primary),
)
}

View file

@ -1,17 +1,17 @@
package com.tangem.features.yield.supply.impl.subcomponents.startearning.model.transformers
import com.tangem.blockchain.common.TransactionData
import com.tangem.core.ui.extensions.combinedReference
import com.tangem.core.ui.extensions.resourceReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.extensions.wrappedList
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.features.yield.supply.impl.R
import com.tangem.features.yield.supply.impl.common.entity.YieldSupplyActionUM
import com.tangem.features.yield.supply.impl.common.entity.YieldSupplyFeeUM
import com.tangem.features.yield.supply.impl.common.formatter.YieldSupplyAmountFormatter
import com.tangem.utils.StringsSigns.DOT
import com.tangem.utils.transformer.Transformer
import kotlinx.collections.immutable.toPersistentList
import java.math.BigDecimal
@ -29,30 +29,46 @@ internal class YieldSupplyStartEarningFeeContentTransformer(
) : Transformer<YieldSupplyActionUM> {
override fun transform(prevState: YieldSupplyActionUM): YieldSupplyActionUM {
val cryptoCurrency = cryptoCurrencyStatus.currency
val fiatRate = cryptoCurrencyStatus.value.fiatRate
val tokenFiatRate = cryptoCurrencyStatus.value.fiatRate
val feeFiatRate = feeCryptoCurrencyStatus.value.fiatRate
val crypto = feeValue.format { crypto(feeCryptoCurrencyStatus.currency) }
val fiatFeeValue = feeFiatRate?.let(feeValue::multiply)
val feeFiat = feeFiatRate?.let(feeValue::multiply)
val feeFiatValueText = feeFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val fiat = fiatFeeValue.format { fiat(appCurrency.code, appCurrency.symbol) }
val tokenCryptoFeeValue = fiatRate?.let { rate ->
fiatFeeValue?.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP)
val tokenCryptoFee = tokenFiatRate?.let { rate ->
feeFiat?.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP)
}
val tokenCryptoFeeValueText = tokenCryptoFee.format { crypto(cryptoCurrency) }
val tokenFiatFee = feeFiat // same fiat amount
val tokenFiatFeeValueText = tokenFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) }
val tokenCryptoFee = tokenCryptoFeeValue.format { crypto(cryptoCurrency) }
val maxCryptoFee = maxNetworkFee.format { crypto(cryptoCurrency) }
val maxFiatFeeValue = fiatRate?.let { rate ->
maxNetworkFee.divide(rate, cryptoCurrency.decimals, RoundingMode.HALF_UP)
val maxFeeCryptoValueText = maxNetworkFee.format { crypto(cryptoCurrency) }
val maxFiatFee = tokenFiatRate?.let { rate ->
maxNetworkFee.multiply(rate)
}
val maxFiatFee = maxFiatFeeValue.format { fiat(appCurrency.code, appCurrency.symbol) }
val maxFiatFeeValueText = maxFiatFee.format { fiat(appCurrency.code, appCurrency.symbol) }
val minAmountTextReference = YieldSupplyAmountFormatter(
cryptoCurrency,
appCurrency,
).invoke(minAmount, cryptoCurrencyStatus.value.fiatRate)
val minAmountCryptoText = minAmount.format { crypto(cryptoCurrency) }
val minAmountFiat = tokenFiatRate?.let(minAmount::multiply)
val minAmountFiatText = minAmountFiat.format { fiat(appCurrency.code, appCurrency.symbol) }
val feeNoteValue = resourceReference(
id = R.string.yield_module_fee_policy_sheet_fee_note,
formatArgs = wrappedList(
tokenFiatFeeValueText,
tokenCryptoFeeValueText,
maxFiatFeeValueText,
maxFeeCryptoValueText,
),
)
val minFeeNoteValue = resourceReference(
id = R.string.yield_module_fee_policy_sheet_min_amount_note,
formatArgs = wrappedList(
minAmountFiatText,
minAmountCryptoText,
),
)
return if (cryptoCurrencyStatus.value is CryptoCurrencyStatus.Loading) {
prevState.copy(yieldSupplyFeeUM = YieldSupplyFeeUM.Loading)
@ -60,22 +76,12 @@ internal class YieldSupplyStartEarningFeeContentTransformer(
prevState.copy(
yieldSupplyFeeUM = YieldSupplyFeeUM.Content(
transactionDataList = updatedTransactionList.toPersistentList(),
feeValue = combinedReference(
stringReference(crypto),
stringReference(" $DOT "),
stringReference(fiat),
),
currentNetworkFeeValue = combinedReference(
stringReference(tokenCryptoFee),
stringReference(" $DOT "),
stringReference(fiat),
),
maxNetworkFeeValue = combinedReference(
stringReference(maxCryptoFee),
stringReference(" $DOT "),
stringReference(maxFiatFee),
),
minAmountFeeValue = minAmountTextReference,
feeFiatValue = stringReference(feeFiatValueText),
tokenFeeFiatValue = stringReference(tokenFiatFeeValueText),
maxNetworkFeeFiatValue = stringReference(maxFiatFeeValueText),
minTopUpFiatValue = stringReference(minAmountFiatText),
feeNoteValue = feeNoteValue,
minFeeNoteValue = minFeeNoteValue,
),
)
}

View file

@ -2,16 +2,13 @@ package com.tangem.features.yield.supply.impl.subcomponents.stopearning.model.tr
import com.tangem.blockchain.common.TransactionData
import com.tangem.core.ui.extensions.TextReference
import com.tangem.core.ui.extensions.combinedReference
import com.tangem.core.ui.extensions.stringReference
import com.tangem.core.ui.format.bigdecimal.crypto
import com.tangem.core.ui.format.bigdecimal.fiat
import com.tangem.core.ui.format.bigdecimal.format
import com.tangem.domain.appcurrency.model.AppCurrency
import com.tangem.domain.models.currency.CryptoCurrencyStatus
import com.tangem.features.yield.supply.impl.common.entity.YieldSupplyActionUM
import com.tangem.features.yield.supply.impl.common.entity.YieldSupplyFeeUM
import com.tangem.utils.StringsSigns.DOT
import com.tangem.utils.transformer.Transformer
import kotlinx.collections.immutable.toPersistentList
import java.math.BigDecimal
@ -24,11 +21,10 @@ internal class YieldSupplyStopEarningFeeContentTransformer(
private val feeValue: BigDecimal,
) : Transformer<YieldSupplyActionUM> {
override fun transform(prevState: YieldSupplyActionUM): YieldSupplyActionUM {
val feeFiatValue = feeCryptoCurrencyStatus.value.fiatRate?.let { rate ->
val feeFiatValueRaw = feeCryptoCurrencyStatus.value.fiatRate?.let { rate ->
feeValue.multiply(rate)
}
val cryptoFee = feeValue.format { crypto(feeCryptoCurrencyStatus.currency) }
val fiatFee = feeFiatValue.format { fiat(appCurrency.code, appCurrency.symbol) }
val fiatFeeText = feeFiatValueRaw.format { fiat(appCurrency.code, appCurrency.symbol) }
return if (cryptoCurrencyStatus.value is CryptoCurrencyStatus.Loading) {
prevState.copy(yieldSupplyFeeUM = YieldSupplyFeeUM.Loading)
@ -37,14 +33,11 @@ internal class YieldSupplyStopEarningFeeContentTransformer(
isPrimaryButtonEnabled = true,
yieldSupplyFeeUM = YieldSupplyFeeUM.Content(
transactionDataList = transactions.toPersistentList(),
feeValue = combinedReference(
stringReference(cryptoFee),
stringReference(" $DOT "),
stringReference(fiatFee),
),
currentNetworkFeeValue = TextReference.EMPTY,
maxNetworkFeeValue = TextReference.EMPTY,
minAmountFeeValue = TextReference.EMPTY,
feeFiatValue = stringReference(fiatFeeText),
tokenFeeFiatValue = TextReference.EMPTY,
maxNetworkFeeFiatValue = TextReference.EMPTY,
minTopUpFiatValue = TextReference.EMPTY,
feeNoteValue = TextReference.EMPTY,
),
)
}