-
- {`1 ${asset.symbol} =`}
-
-
+
+ {props.max && props.maxText && (
+ <>
+
+ {`${props.maxText}:`}
+
+
+
+ >
+ )}
void
@@ -24,6 +25,7 @@ interface SingleProps extends Props {
interface SelectProps extends Props {
max?: BigNumber
+ maxText?: string
asset?: Asset
onChangeAsset: (asset: Asset) => void
hasSelect: boolean
@@ -82,6 +84,7 @@ export default function TokenInputWithSlider(props: SingleProps | SelectProps) {
onChangeAsset={(asset: Asset, max: BigNumber) => onAssetChange(asset, max)}
amount={amount}
max={max}
+ maxText={props.maxText || ''}
className='mb-4'
disabled={props.disabled}
hasSelect={props.hasSelect}
diff --git a/src/hooks/useIsOpenArray.tsx b/src/hooks/useIsOpenArray.tsx
new file mode 100644
index 00000000..67048e34
--- /dev/null
+++ b/src/hooks/useIsOpenArray.tsx
@@ -0,0 +1,16 @@
+import { useState } from 'react'
+
+export default function useIsOpenArray(length: number, allowMultiple: boolean) {
+ const [isOpen, setIsOpen] = useState(Array.from({ length }, (_, i) => i === 0))
+
+ function toggleOpen(index: number) {
+ setIsOpen((prev) => {
+ return prev.map((_, i) => {
+ if (i === index) return !prev[i]
+ return allowMultiple ? prev[i] : false
+ })
+ })
+ }
+
+ return [isOpen, toggleOpen] as const
+}
diff --git a/src/hooks/usePrice.tsx b/src/hooks/usePrice.tsx
new file mode 100644
index 00000000..89918301
--- /dev/null
+++ b/src/hooks/usePrice.tsx
@@ -0,0 +1,7 @@
+import usePrices from './usePrices'
+
+export default function usePrice(denom: string) {
+ const { data: prices } = usePrices()
+
+ return prices.find((coin) => coin.denom === denom)?.amount ?? 0
+}