| 56 | } |
| 57 | |
| 58 | export function useLaunchpadDetail(launchpad: Launchpad, duration: Duration) { |
| 59 | const config = LaunchpadConfig[launchpad] |
| 60 | const url = `${LaunchpadDetailUrl}/${duration}?launchpads=${config.launchpad}` |
| 61 | const { data, isLoading, isValidating, error, mutate } = useSWR( |
| 62 | url, |
| 63 | getLaunchpadDetail, |
| 64 | { |
| 65 | onSuccess: data => { |
| 66 | if (data) { |
| 67 | if (prevData.current.length > 0) { |
| 68 | data.forEach((item: PoolInfo) => { |
| 69 | if ( |
| 70 | !prevData.current.some( |
| 71 | t => t.baseAsset.id === item.baseAsset.id |
| 72 | ) |
| 73 | ) { |
| 74 | item.latest = true |
| 75 | } |
| 76 | }) |
| 77 | } |
| 78 | prevData.current = data |
| 79 | } |
| 80 | }, |
| 81 | } |
| 82 | ) |
| 83 | |
| 84 | const prevData = useRef<PoolInfo[]>([]) |
| 85 | |
| 86 | return { |
| 87 | data, |
| 88 | isLoading, |
| 89 | isValidating, |
| 90 | error, |
| 91 | mutate, |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | export function useTrending(duration: Duration) { |
| 96 | const url = `${TrendingUrl}/${duration}` |