Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(farm-api): kv cache for v3 lp liquidity (#7503)
<!-- Before opening a pull request, please read the [contributing guidelines](https://github.com/pancakeswap/pancake-frontend/blob/develop/CONTRIBUTING.md) first --> <!-- copilot:all --> ### <samp>🤖 Generated by Copilot at 629bf57</samp> ### Summary 🌐🚀🌊 <!-- 1. 🌐 - This emoji represents the Cloudflare KV storage, which is a global key-value store that can be used to cache and retrieve data across different regions and edge locations. This emoji is suitable for the new functionality to cache and retrieve the liquidity data of the V3 farms from the Cloudflare KV storage. 2. 🚀 - This emoji represents the improved performance and reliability of the V3 farm API endpoints, which can benefit from the caching logic and reduce the number of requests to the V3 subgraph. This emoji is suitable for the caching logic added to the V3 farm API endpoints in `v3.ts`. 3. 🌊 - This emoji represents the liquidity data of the V3 farms, which is the main information that is cached and retrieved from the Cloudflare KV storage. This emoji is suitable for the new key and the new function to generate it, and the new methods in the `FarmKV` class. --> This pull request enhances the farms API by adding caching functionality for the V3 farms using Cloudflare KV storage. It modifies the `kv.ts` and `v3.ts` files in the `apis/farms/src` directory to implement the caching logic and the key generation for the V3 farms. This aims to improve the performance and reliability of the V3 farm API endpoints. > _Sing, O Muse, of the cunning code that cached the V3 farms_ > _And saved them in the Cloudflare KV, the swift and spacious store_ > _That `FarmKV`, the skillful class, could fetch with ease and charm_ > _And serve them to the endpoints in `v3.ts`, the faithful and the sure_ ### Walkthrough * Add and use `FarmKV` class to cache V3 farm liquidity data to Cloudflare KV storage ([link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-f92f8cf858e10219e605f61b907de60ad84991ed3a05cb7e3ec9f0d6764ba689L8-R24), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-f92f8cf858e10219e605f61b907de60ad84991ed3a05cb7e3ec9f0d6764ba689R38), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-f92f8cf858e10219e605f61b907de60ad84991ed3a05cb7e3ec9f0d6764ba689L51-R75), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126R13), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L207-R245), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L280-R396), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L378-R440)) * Handle errors and fallbacks when querying V3 subgraph for V3 farm liquidity data ([link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L143-R144), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L154-R155), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L280-R396), [link](https://github.com/pancakeswap/pancake-frontend/pull/7503/files?diff=unified&w=0#diff-0e56562b1a287487ad933f04eb8867f8afbccfc461716cc24e9ddad41d614126L378-R440))
- Loading branch information