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
|
(defn new->old-route-path
|
||||||
[new-path]
|
[new-path]
|
||||||
(let [bonder-fees (-> new-path :tx-bonder-fees money/bignumber)
|
(let [to-bignumber (fn [k] (-> new-path k money/bignumber))]
|
||||||
token-fees (-> new-path :tx-token-fees money/bignumber)]
|
{:approval-fee (to-bignumber :approval-fee)
|
||||||
{:from (:from-chain new-path)
|
: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-locked (:amount-in-locked new-path)
|
||||||
:amount-in (:amount-in new-path)
|
:amount-in (:amount-in new-path)
|
||||||
:max-amount-in (:max-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-contract-address (:approval-contract-address new-path)
|
||||||
:approval-required (:approval-required new-path)
|
:approval-required (:approval-required new-path)
|
||||||
:estimated-time (:estimated-time 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)
|
:to (:to-chain new-path)
|
||||||
:bonder-fees bonder-fees
|
|
||||||
:approval-amount-required (:approval-amount-required new-path)
|
:approval-amount-required (:approval-amount-required new-path)
|
||||||
;; :cost () ;; tbd not used on desktop
|
;; :cost () ;; tbd not used on desktop
|
||||||
:token-fees token-fees
|
|
||||||
:gas-amount (:tx-gas-amount new-path)}))
|
:gas-amount (:tx-gas-amount new-path)}))
|
||||||
|
|
||||||
(defn tokens-never-loaded?
|
(defn tokens-never-loaded?
|
||||||
|
|
|
@ -126,7 +126,7 @@
|
||||||
(let [swap-proposal (:swap-proposal swap)]
|
(let [swap-proposal (:swap-proposal swap)]
|
||||||
(reduce dissoc
|
(reduce dissoc
|
||||||
swap-proposal
|
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
|
(rf/reg-sub
|
||||||
:wallet/swap-amount
|
:wallet/swap-amount
|
||||||
|
@ -310,20 +310,27 @@
|
||||||
:token asset-to-pay-with-current-account-balance
|
:token asset-to-pay-with-current-account-balance
|
||||||
:prices-per-token prices-per-token})))
|
: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
|
(rf/reg-sub
|
||||||
:wallet/approval-gas-fees
|
:wallet/approval-gas-fees
|
||||||
:<- [:wallet/current-viewing-account]
|
:<- [:wallet/current-viewing-account]
|
||||||
:<- [:wallet/swap-proposal]
|
:<- [:wallet/swap-approval-fee]
|
||||||
:<- [:profile/currency]
|
:<- [:profile/currency]
|
||||||
:<- [:wallet/prices-per-token]
|
:<- [: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)
|
(let [tokens (:tokens account)
|
||||||
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
token-for-fees (first (filter #(= (string/lower-case (:symbol %))
|
||||||
(string/lower-case constants/token-for-fees-symbol))
|
(string/lower-case constants/token-for-fees-symbol))
|
||||||
tokens))
|
tokens))
|
||||||
fee-in-fiat (utils/calculate-token-fiat-value
|
fee-in-fiat (utils/calculate-token-fiat-value
|
||||||
{:currency currency
|
{:currency currency
|
||||||
:balance approval-gas-fees
|
:balance approval-fee
|
||||||
:token token-for-fees
|
:token token-for-fees
|
||||||
:prices-per-token prices-per-token})]
|
:prices-per-token prices-per-token})]
|
||||||
fee-in-fiat)))
|
fee-in-fiat)))
|
||||||
|
|
Loading…
Reference in New Issue