utils#getFullDisplayBalance TypeScript Examples

The following examples show how to use utils#getFullDisplayBalance. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DpiStakeModal.tsx    From index-ui with MIT License 5 votes vote down vote up
StakeModal: React.FC<StakeModalProps> = ({
  isOpen,
  onDismiss,
  onStake,
}) => {
  const [val, setVal] = useState('')
  const { uniswapEthDpiLpBalance } = useBalances()

  const fullBalance = useMemo(() => {
    return getFullDisplayBalance(fromWei(uniswapEthDpiLpBalance), 0)
  }, [uniswapEthDpiLpBalance])

  const handleChange = useCallback(
    (e: React.FormEvent<HTMLInputElement>) => {
      setVal(e.currentTarget.value)
    },
    [setVal]
  )

  const handleSelectMax = useCallback(() => {
    setVal(fullBalance)
  }, [fullBalance, setVal])

  const handleStakeClick = useCallback(() => {
    onStake(val)
  }, [onStake, val])

  return (
    <Modal isOpen={isOpen}>
      <ModalTitle text='Stake' />
      <ModalContent>
        <TokenInput
          value={val}
          onSelectMax={handleSelectMax}
          onChange={handleChange}
          max={fullBalance}
          symbol='Uniswap ETH/DPI LP Tokens'
        />
      </ModalContent>
      <ModalActions>
        <Button onClick={onDismiss} text='Cancel' variant='secondary' />
      </ModalActions>
    </Modal>
  )
}
Example #2
Source File: GmiStakeModal.tsx    From index-ui with MIT License 5 votes vote down vote up
StakeModal: React.FC<StakeModalProps> = ({
  isOpen,
  onDismiss,
  onStake,
}) => {
  const [val, setVal] = useState('')
  const { gmiBalance } = useBalances()

  const fullBalance = useMemo(() => {
    return getFullDisplayBalance(fromWei(gmiBalance), 0)
  }, [gmiBalance])

  const handleChange = useCallback(
    (e: React.FormEvent<HTMLInputElement>) => {
      setVal(e.currentTarget.value)
    },
    [setVal]
  )

  const handleSelectMax = useCallback(() => {
    setVal(fullBalance)
  }, [fullBalance, setVal])

  const handleStakeClick = useCallback(() => {
    onStake(val)
  }, [onStake, val])

  return (
    <Modal isOpen={isOpen}>
      <ModalTitle text='Stake' />
      <ModalContent>
        <TokenInput
          value={val}
          onSelectMax={handleSelectMax}
          onChange={handleChange}
          max={fullBalance}
          symbol='GMI Tokens'
        />
      </ModalContent>
      <ModalActions>
        <Button onClick={onDismiss} text='Cancel' variant='secondary' />
        <Button
          disabled={!val || !Number(val)}
          onClick={handleStakeClick}
          text='Stake'
          variant={!val || !Number(val) ? 'secondary' : 'default'}
        />
      </ModalActions>
    </Modal>
  )
}
Example #3
Source File: MviStakeModal.tsx    From index-ui with MIT License 5 votes vote down vote up
MviStakeModal: React.FC<MviStakeModalProps> = ({
  isOpen,
  onDismiss,
  onStake,
}) => {
  const [val, setVal] = useState('')
  const { uniswapEthMviLpBalance } = useBalances()

  const fullBalance = useMemo(() => {
    return getFullDisplayBalance(fromWei(uniswapEthMviLpBalance), 0)
  }, [uniswapEthMviLpBalance])

  const handleChange = useCallback(
    (e: React.FormEvent<HTMLInputElement>) => {
      setVal(e.currentTarget.value)
    },
    [setVal]
  )

  const handleSelectMax = useCallback(() => {
    setVal(fullBalance)
  }, [fullBalance, setVal])

  const handleStakeClick = useCallback(() => {
    onStake(val)
  }, [onStake, val])

  return (
    <Modal isOpen={isOpen}>
      <ModalTitle text='Stake' />
      <ModalContent>
        <TokenInput
          value={val}
          onSelectMax={handleSelectMax}
          onChange={handleChange}
          max={fullBalance}
          symbol='Uniswap ETH/MVI LP Tokens'
        />
      </ModalContent>
      <ModalActions>
        <Button onClick={onDismiss} text='Cancel' variant='secondary' />
        <Button
          disabled={!val || !Number(val)}
          onClick={handleStakeClick}
          text='Stake'
          variant={!val || !Number(val) ? 'secondary' : 'default'}
        />
      </ModalActions>
    </Modal>
  )
}