Reservoir / MM Goal: > Create a Node.js proxy for some of the Mavis Market API that conforms to the spec of the Reservoir API. We have a website [Forgotten Market](https://v2.forgotten.market) and it's mostly on ETH. We have plenty of API requests that already use Reservoir in our React app and we don't want to have to re-write them all just to support assets on Ronin. ![Screenshot 2024-06-19 at 10.36.34 AM](https://hackmd.io/_uploads/ryTQsdg8R.png) ## MILESTONES: Your job is to: 1. **BACKEND** Write routes within our Next.js server that proxies requests to Sky Mavis, but adapts the format to be the same as what we're already using in our app. (Write tests to make sure the relevant data is there) 2. **FRONTEND** Update the frontend to load from this data - if the backend is perfectly implemented, this should only take an hour or two You can do these things independently, but in reality, you might find the backend is easier to do alongside the frontend. It's up to you. ## Sky Mavis API Resources * [npm package `mavis-market-core`]( https://www.npmjs.com/package/@sky-mavis/mavis-market-core) * [Mavis Market SDK Live demo](https://mavis-market-sdk.vercel.app) * [Mavis Market SDK Main Repo](https://github.com/skymavis/mavis-market-sdk) * [Mavis Market SDK Code example]( https://github.com/skymavis/mavis-market-sdk/tree/main/packages/core/example) UPDATE: there is also a GraphQL API ``` query MyQuery { erc721Tokens( from: 1774 size: 2 tokenAddress: "0xb806028b6ebc35926442770a8a8a7aeab6e2ce5c" auctionType: All ) { results { tokenId owner attributes cdnImage numActiveOffers order { basePrice currentPrice } offers { basePrice currentPrice } } } tokenData(tokenAddress: "0xb806028b6ebc35926442770a8a8a7aeab6e2ce5c") { minPrice tokenAddress totalItems totalListing } } ``` Endpoint: https://api-gateway.skymavis.com/graphql/mavis-marketplace API key header is `x-api-key` with value `rHoH... ASK DOTTA OR NISKI` ## Reservoir API Resources * [Reservoir API Overview](https://docs.reservoir.tools/reference/overview) ## The Routes We Need Based on the analysis of the provided file, here is a detailed list of all unique API routes and parameters used to call the Reservoir API: ### API Routes and Parameters 1. **Route**: `/collections/v7` - **Parameters**: - `contract` (string, used as query parameter) - `sortBy` (string, e.g., `30DayVolume`, `7DayVolume`, `1DayVolume`) - `normalizeRoyalties` (boolean) - `limit` (number) - `collectionsSetId` (optional, string) - `community` (optional, string) - `includeSalesCount` (boolean) - `id` (string, used as query parameter) 2. **Route**: `/tokens/v6` - **Parameters**: - `collection` (string) - `sortBy` (string, e.g., `floorAskPrice`) - `sortDirection` (string, e.g., `asc`) - `limit` (number) - `normalizeRoyalties` (boolean) - `includeDynamicPricing` (boolean) - `includeAttributes` (boolean) - `includeQuantity` (boolean) - `includeLastSale` (boolean) **RETURN TYPES**: You'll have to look them up. Because you're adapting one API to another, obviously not every single value will apply. Make sure we have the data we need for displaying on the website and use your judgement for the other parts. ## Write Tests Write tests to make sure the data is adapted correctly and you have the data needed ## Create a Mock Ronin Network Reservoir already supports configuring different chains. Reservoir doesn't support Ronin, of course, but what we're going to do is make our frontend think our proxy routes are reservoir support. See `utils/chain.ts`: ![Screenshot_2024-06-17_at_4.15.13_PM](https://hackmd.io/_uploads/BkO8YXArA.png) So we need to create a new version for Ronin's Mavis Market - but the URL will point to 'localhost'. > Also note that Sky Mavis uses the RON token for the `listingCurrencies` so add `ron` as a currency as well ## Test Collection ![Screenshot 2024-06-19 at 10.37.04 AM](https://hackmd.io/_uploads/ByZOideIR.png) A good collection to test is [CyberKongs](https://marketplace.skymavis.com/collections/0x1f7c16fce4fc894143afb5545bf04f676bf7dcf3) This is collection `0x1f7c16fce4fc894143afb5545bf04f676bf7dcf3` In our code, Reservoir often wants a 'collection set' - we don't need that (or you can mock it in the API routes). But the point is feel free to hard code that collection somewhere - we don't need dynamic collections. The idea is you should be able to display this collection within Forgotten Market, and we can just substitute our own collection when needed. All of the trait filtering, market data, etc. should work ## Success Criteria - there are API routes in our Next.js app that proxy a reservoir request, call out to mavis market, convert the data back to the reservoir output format - there are unit tests for this format - there is a ronin network chain config - you can view the cyberkongs collection with live market pricing data and it renders in our market ## Guidelines - It's up to you to figure out some of the missing details above by research or asking - for example, I haven't defined the complete return types of the Reservoir API - you'll need to track this down - We'll chat on Discord - if you have any questions, ask them - Regular daily communication on what you've accomplished, what you're working on, and where your stuck is key ## NEXT STEPS Ask Dotta for acces to the repo and we'll get you setup