11import { useState } from 'react'
22import { useAccount , useBalance , useSendTransaction } from 'wagmi'
33import { usePrevious } from './hooks/usePrevious.ts'
4- import { getConsensusBalance , waitForConsensusBalance , waitForSapphireBalance } from './utils/getBalances'
4+ import {
5+ fromBaseUnitsToTrackEventCents ,
6+ getConsensusBalance ,
7+ waitForConsensusBalance ,
8+ waitForSapphireBalance ,
9+ } from './utils/getBalances'
510import { useBlockNavigatingAway } from './utils/useBlockNavigatingAway'
611import { transferToConsensus } from './withdraw/transferToConsensus'
712import { useGenerateSapphireAccount } from './withdraw/useGenerateSapphireAccount'
813import { minimalWithdrawableAmount , withdrawToConsensus } from './withdraw/withdrawToConsensus'
914import { trackEvent } from 'fathom-client'
15+ import { consensusConfig } from './utils/oasisConfig.ts'
1016
1117// Use global variable here, due to step4 using different context(not in sync with react hooks)
1218let isInputModeGlobal = true
@@ -82,7 +88,7 @@ export function useWithdraw() {
8288 const amountToWithdraw2 = await waitForConsensusBalance ( generatedConsensusAccount . address , 0n )
8389
8490 trackEvent ( 'withdrawal flow started' , {
85- _value : Number ( amountToWithdraw2 . formatted ) ,
91+ _value : fromBaseUnitsToTrackEventCents ( amountToWithdraw2 . raw , consensusConfig . decimals ) ,
8692 } )
8793
8894 const preWithdrawConsensusBalance = await getConsensusBalance ( consensusAddress )
@@ -99,7 +105,7 @@ export function useWithdraw() {
99105 } )
100106
101107 trackEvent ( 'withdrawal flow finished' , {
102- _value : Number ( amountToWithdraw2 . formatted ) ,
108+ _value : fromBaseUnitsToTrackEventCents ( amountToWithdraw2 . raw , consensusConfig . decimals ) ,
103109 } )
104110
105111 allowNavigatingAway ( ) // Stop blocking unless new transfer comes in
0 commit comments