speed up swap page

This commit is contained in:
tjs 2022-06-28 13:38:21 -04:00
parent 9a920e7120
commit 57b3e1bf4d
1 changed files with 8 additions and 13 deletions

View File

@ -191,24 +191,19 @@ const JupiterForm: FunctionComponent = () => {
} }
}, [inputTokenInfo, formValue.amount]) }, [inputTokenInfo, formValue.amount])
const { routeMap, allTokenMints, routes, loading, exchange, error, refresh } = const { routeMap, routes, loading, exchange, error, refresh } = useJupiter({
useJupiter({ ...formValue,
...formValue, amount: amountInDecimal ? amountInDecimal : 0,
amount: amountInDecimal ? amountInDecimal : 0, slippage,
slippage, })
})
useEffect(() => { useEffect(() => {
// Fetch token list from Jupiter API // Fetch token list from Jupiter API
fetch(TOKEN_LIST_URL['mainnet-beta']) fetch(TOKEN_LIST_URL['mainnet-beta'])
.then((response) => response.json()) .then((response) => response.json())
.then((result) => { .then((result) => setTokens(result))
const tokens = allTokenMints.map((mint) => }, [])
result.find((item) => item?.address === mint)
)
setTokens(tokens)
})
}, [allTokenMints])
useEffect(() => { useEffect(() => {
if (routes) { if (routes) {