Skip to content

Commit

Permalink
trigger request user confirm on negative price shift
Browse files Browse the repository at this point in the history
  • Loading branch information
bigboydiamonds committed Sep 23, 2024
1 parent 383519d commit f74ca92
Showing 1 changed file with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,15 @@ export const useConfirmNewBridgePrice = () => {
}

const calculateOutputRelativeDifference = (
quoteA?: BridgeQuote,
quoteB?: BridgeQuote
currentQuote?: BridgeQuote,
previousQuote?: BridgeQuote
) => {
if (!quoteA?.outputAmountString || !quoteB?.outputAmountString) return null
if (!currentQuote?.outputAmountString || !previousQuote?.outputAmountString) {
return null
}

const outputA = parseFloat(quoteA.outputAmountString)
const outputB = parseFloat(quoteB.outputAmountString)
const currentOutput = parseFloat(currentQuote.outputAmountString)
const previousOutput = parseFloat(currentQuote.outputAmountString)

return Math.abs(outputA - outputB) / outputB
return previousOutput - currentOutput / previousOutput
}

0 comments on commit f74ca92

Please sign in to comment.