-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #569 from threshold-network/calculate-threshold-fe…
…e-for-redemption Calculate Threshold Fee for redemption In this PR I've added the calculations for threshold fee and estimated BTC that will be received from redemption. ### Changes: - Rename `getEstimatedFees` function to `getEstimatedDepositFees`, - Create ` getEstimatedRedemptionFees` function in `TBTC` class, - Create `useRedemptionEstimatedFees` hook that will retrieve the values from `getEstimatedRedemptionFees` function, - Display threshold fee and estimated btc amount in proper places in the dApp during a redemption flow.
- Loading branch information
Showing
11 changed files
with
186 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
export * from "./useRevealDepositTransaction" | ||
export * from "./useTBTCDepositDataFromLocalStorage" | ||
export * from "./useTBTCVaultContract" | ||
export * from "./useSubscribeToOptimisticMintingFinalizedEvent" | ||
export * from "./useSubsribeToDepositRevealedEvent" | ||
export * from "./useSubscribeToOptimisticMintingRequestedEvent" | ||
export * from "./useFetchDepositDetails" | ||
export * from "./useFetchRecentDeposits" | ||
export * from "./useFetchTBTCMetrics" | ||
export * from "./useRedemptionEstimatedFees" | ||
export * from "./useRequestRedemption" | ||
export * from "./useRevealDepositTransaction" | ||
export * from "./useSubscribeToOptimisticMintingFinalizedEvent" | ||
export * from "./useSubscribeToOptimisticMintingRequestedEvent" | ||
export * from "./useSubscribeToRedemptionRequestedEvent" | ||
export * from "./useSubsribeToDepositRevealedEvent" | ||
export * from "./useTBTCDepositDataFromLocalStorage" | ||
export * from "./useTBTCVaultContract" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useEffect, useState } from "react" | ||
import { useThreshold } from "../../contexts/ThresholdContext" | ||
|
||
export const useRedemptionEstimatedFees = (unmintedAmount: string) => { | ||
const threshold = useThreshold() | ||
const [estimatedBTCAmount, setEstimatedBTCAmount] = useState< | ||
string | undefined | ||
>(undefined) | ||
const [thresholdNetworkFee, setThresholdNetworkFee] = useState< | ||
string | undefined | ||
>(undefined) | ||
|
||
useEffect(() => { | ||
const getEstimatedRedemptionFees = async () => { | ||
const { treasuryFee, estimatedAmountToBeReceived } = | ||
await threshold.tbtc.getEstimatedRedemptionFees(unmintedAmount) | ||
|
||
setThresholdNetworkFee(treasuryFee) | ||
setEstimatedBTCAmount(estimatedAmountToBeReceived) | ||
} | ||
|
||
getEstimatedRedemptionFees() | ||
}, [unmintedAmount, threshold]) | ||
|
||
return { estimatedBTCAmount, thresholdNetworkFee } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.