Created
July 12, 2022 08:57
-
-
Save sergeysova/c5c79fbcab58ddbb83e507ddce70d1d5 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
useEffect(() => { | |
const durationMs = parseDuration(duration ?? ''); | |
if (durationMs && selectedToken) { | |
const durationSeconds = new Decimal(durationMs).div(1000); | |
const speedInYocto = new Decimal(amountToStream) | |
.div(durationSeconds) | |
.toFixed(); | |
setValue('speed', speedInYocto); | |
} else { | |
setValue('speed', '0'); | |
} | |
}, [setValue, duration, amountToStream, selectedToken]); | |
const speedInHuman = useMemo(() => { | |
if (selectedToken && speed !== '0') { | |
const formatter = new TokenFormatter(selectedToken.decimals); | |
return formatter.tokensPerMeaningfulPeriod(speed); | |
} | |
return { formattedValue: '0', unit: 'second' }; | |
}, [speed, selectedToken]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment