mirror of
https://github.com/labrinyang/lp-terminal.git
synced 2026-07-27 21:27:43 +00:00
4e317eff6d
Static SPA over UP33 (ve(3,3)) + the official Uniswap v2/v3 deployments: browse and add liquidity across all three, manage CL/v2 positions, one-token ZAP adds, aggregator vs native swaps, and LP-based limit orders. Ships with a zero-dependency pool indexer for uniswap discovery. Browser-wallet signing only; no key material anywhere.
22 lines
784 B
TypeScript
22 lines
784 B
TypeScript
import { useQuery } from '@tanstack/react-query'
|
|
import { parseUnits } from 'viem'
|
|
import { ADDR } from '../config/addresses'
|
|
import { kyberRoute } from '../lib/kyber'
|
|
|
|
/** USD price of 1 UP via a kyber UP->USDG quote (display only) */
|
|
export function useUpPrice() {
|
|
return useQuery({
|
|
queryKey: ['upPrice'],
|
|
refetchInterval: 60_000,
|
|
staleTime: 50_000,
|
|
retry: 1,
|
|
queryFn: async () => {
|
|
// applyFee: false — this is a price display, not an executable quote
|
|
const r = await kyberRoute(ADDR.UP, ADDR.USDG, parseUnits('1', 18), { applyFee: false })
|
|
const usd = Number(r.routeSummary.amountOutUsd ?? NaN)
|
|
if (Number.isFinite(usd) && usd > 0) return usd
|
|
return Number(r.routeSummary.amountOut) / 1e6 // USDG has 6 decimals
|
|
},
|
|
})
|
|
}
|