fix: show accurate approval fee for swaps (#21718)
This commit is contained in:
parent
d0deb94bf3
commit
0c25b77e54
|
@ -233,9 +233,12 @@
|
|||
|
||||
(defn new->old-route-path
|
||||
[new-path]
|
||||
(let [bonder-fees (-> new-path :tx-bonder-fees money/bignumber)
|
||||
token-fees (-> new-path :tx-token-fees money/bignumber)]
|
||||
{:from (:from-chain new-path)
|
||||
(let [to-bignumber (fn [k] (-> new-path k money/bignumber))]
|
||||
{:approval-fee (to-bignumber :approval-fee)
|
||||
:approval-l-1-fee (to-bignumber :approval-l-1-fee)
|
||||
:bonder-fees (to-bignumber :tx-bonder-fees)
|
||||
:token-fees (to-bignumber :tx-token-fees)
|
||||
:from (:from-chain new-path)
|
||||
:amount-in-locked (:amount-in-locked new-path)
|
||||
:amount-in (:amount-in new-path)
|
||||
:max-amount-in (:max-amount-in new-path)
|
||||
|
@ -273,15 +276,9 @@
|
|||
:approval-contract-address (:approval-contract-address new-path)
|
||||
:approval-required (:approval-required new-path)
|
||||
:estimated-time (:estimated-time new-path)
|
||||
:approval-gas-fees (* (money/wei->ether (get-in new-path
|
||||
[:suggested-levels-for-max-fees-per-gas
|
||||
:medium]))
|
||||
(:approval-gas-amount new-path))
|
||||
:to (:to-chain new-path)
|
||||
:bonder-fees bonder-fees
|
||||
:approval-amount-required (:approval-amount-required new-path)
|
||||
;; :cost () ;; tbd not used on desktop
|
||||
:token-fees token-fees
|
||||
:gas-amount (:tx-gas-amount new-path)}))
|
||||
|
||||
(defn tokens-never-loaded?
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
(let [swap-proposal (:swap-proposal swap)]
|
||||
(reduce dissoc
|
||||
swap-proposal
|
||||
[:gas-fees :gas-amount :token-fees :bonder-fees :approval-gas-fees]))))
|
||||
[:gas-fees :gas-amount :token-fees :bonder-fees :approval-fee :approval-l-1-fee]))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/swap-amount
|
||||
|
@ -310,20 +310,27 @@
|
|||
:token asset-to-pay-with-current-account-balance
|
||||
:prices-per-token prices-per-token})))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/swap-approval-fee
|
||||
:<- [:wallet/swap-proposal]
|
||||
(fn [{:keys [approval-fee approval-l-1-fee]}]
|
||||
(money/add (money/wei->ether approval-fee)
|
||||
(money/wei->ether approval-l-1-fee))))
|
||||
|
||||
(rf/reg-sub
|
||||
:wallet/approval-gas-fees
|
||||
:<- [:wallet/current-viewing-account]
|
||||
:<- [:wallet/swap-proposal]
|
||||
:<- [:wallet/swap-approval-fee]
|
||||
:<- [:profile/currency]
|
||||
:<- [:wallet/prices-per-token]
|
||||
(fn [[account {:keys [approval-gas-fees]} currency prices-per-token]]
|
||||
(fn [[account approval-fee currency prices-per-token]]
|
||||
(let [tokens (:tokens account)
|
||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||
(string/lower-case constants/token-for-fees-symbol))
|
||||
tokens))
|
||||
fee-in-fiat (utils/calculate-token-fiat-value
|
||||
{:currency currency
|
||||
:balance approval-gas-fees
|
||||
:balance approval-fee
|
||||
:token token-for-fees
|
||||
:prices-per-token prices-per-token})]
|
||||
fee-in-fiat)))
|
||||
|
|
Loading…
Reference in New Issue