Git Product home page Git Product logo

relayer's People

Contributors

cap10bad avatar carry-element avatar compojoom avatar fdmota avatar georgeroman avatar ipeleg avatar jadendurnford avatar jfrazier-eth avatar lljxx1 avatar nofir avatar tv3636 avatar vikinatora avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

relayer's Issues

Republish all Wyvern2.3 orders

It's possible that for whatever reason, some orders that are cached in the open sea indexer were not properly published to the indexer. We should republish them all, just in case.

Notes:

  • Only need Wyvern2.3, because all 2.2 orders are invalid
  • The indexer should quickly skip any orders it already has, so the easiest way is probably just to republish all
  • We should log how many orders were actually missing, just out of curiosity

Should connect with George to see if he already has a script for this

Get ALL historical sell orders

Go back in time to get ALL open sea orders, and have them ready in our DB. When adding a new collection, it gets orders from here, rather than Open Sea itself.

Improved Open Sea Resyncing

Currently, we have an API for resyncing Open Sea orders in a collection, which uses the Assets API to refetch. This is a) inefficient (because you need to check ALL tokens in collection) and b) getting deprecated.

Going forward, Open Sea will no longer include orders in the Assets API, and only allow fetching orders 1 token at a time. So we need to adjust our strategy accordingly.

Here is the plan:

  1. Create a job queue for fetching open sea orders 1 token at a time
  2. Update the existing collection resync API to use the Events API
  3. Create an API for triggering a resync of a single token (a new feature, that should be easy with the above changes)

The Events API can be filtered to events of type created in order to know which tokens had orders created on them the recently. We would then add those tokens into the queue for resyncing. The nice thing about this method is that we don't need to check every token. We can focus on recent listings, which are most likely where we missed something. The API should fetch X events (using pagination), with X being dynamically passed in the API, and a default of 300 (1 page worth).

Note, the events API may return the same token multiple times, if it got listed multiple times. So we should make sure that each token is only checked once (at the API level, or at the queue level)

Trim data stored in Orders table

Right now the open sea indexer stores the whole order object from open sea, including all asset metadata. While it's handy to be able to access this data, it takes up a lot of space in the database.

I am in the process of syncing data to Snowflake for analysis, and the sync has been running for over 7 days because there's so much data. Going forward, lets only store data that we would need to publish orders to the open order book. The simplest way to implement this is probably to remove the "asset" field from the JSON, as that's all just metadata that can be gotten from elsewhere, and takes up a lot space

Open Sea Bidder

We will quite likely want to do our own in-house market making, in order to improve liquidity. As part of this, it might be helpful to be able to place collection-wide bids on Open Sea, in order to acquire inventory that we then sell through Reservoir (e.g. if someone has bid 4 eth on Reservoir, we try bidding 3.5 eth on open sea, and then filling the reservoir order).

To execute this, we need a very simple system that keeps track of the offers we want to place on various collections. It then runs in a loop, placing bids on one token at a time, and refreshing as bids expire. It's quite possible we could build this entirely on top of Open Zeppelin Defender.

Redundant LooksRare order ingestion

We should adopt a system similar to Open Sea, with one bleeding edge query at the tip, and a backup safe query that uses time ranges on a delay.

More robust Open Sea real-time ingesting

  • Real-time scraping that checks once a second for new order at the tip (no pagination because not reliable)
  • More resilient scraping using listing time ranges, a few minutes behind the tip

Latency Monitoring

  • Save the date created for new orders
  • Listen to OpenSea websocket and save the new listing events in a table (maker, contract, token, price, listing time, created time)

The goal is to compare timestamps to better understand where latency is introduced.

Rarible order redundancy check

We should have a process that periodically fetches all the orders for a couple of high volume collections, to verify that no orders were missing from our regular indexing process. If an order is found that the indexer had not previously seen, it should trigger an alarm.

One exception might be that the order was brand new, and the regular indexer hadn't got to it yet, so we should handle that case.

Get rid of old SDK

The OpenSea Indexer is still using the old SDK @georgeroman/wyvern-v2-sdk. We should ditch that in favor of the new SDK @reservoir0x/sdk.

Faster fast sync

When we are re-syncing a collection, we could first fetch the best price for every token from the floor API. This would give us a baseline to check events against.

If an event returns a listing with a price that is equal or higher than what we already have for that token, ignore it. We only care about the lowest order per token, so this suggests we either have it already, or it's low priority. It would allow us to look back further in time, or check more collections, while minimizing the order lookup requests. If we want, the api could still have the option to do a deep scan that checked every event

Use OpenSea events to catch missed orders

  • Every second, look for events that are more than 10 seconds old and don't have a corresponding order
  • Put these tokens into to token lookup queue for manual querying
  • Mark the event as processed to avoid processing it again
  • Potentially we can revert the token lookup queue to fetch 20 tokens at a time, because Open Sea backed off deprecating this functionality (last I checked)

Open Sea backfill

We should re-index everything Open Sea, back to the beginning of time (which is only a few weeks ago, due to their recent contract upgrade). This will catch any orders that we missed along the way. George has done in this in the past, so can coordinate with him.

We should log how many new orders were discovered, so we can understand the extent of any issues.

Long term, we might want a continuous backfill process for redundancy. This might actually be the most efficient way to proactively catch missing orders, rather than attempting to do by collection. But let's do one manually for now.

Use job queues

The OpenSea Indexer runs everything in a single process and in some cases it fails to persist state across deploys (eg. the process of fetching and relaying orders to the indexer will stop if a new deployment is triggered and the current instance dies). We should switch to using job queues, as we have for the indexer, in order to be more efficient (eg. allow multiple processes) and more resilient (eg. persist state across deployments).

More frequent Open Sea polling

  • Poll every 5 seconds, getting 5 seconds worth of orders
  • Leave a buffer from current time, to ensure each 5 second batch is "complete"
  • If we need to paginate, publish it as a new job in the queue
  • Process jobs sequentially or once per second (whichever is best for avoiding limits)
  • Put pagination jobs at the front of the queue, so it mostly stays in order

Fast Open Sea Sync

Sometimes, for various reasons, we want to go directly to open sea to check for orders, to make sure we have everything. Right now, that requires checking every single token in a collection. As an alternative, we could use the events API to fetch the last X tokens that were listed for sale, and then only fetch orders for those tokens.

It feels like 200 is a reasonable number of listings to fetch. It would take 10 requests to get the listings, then 10 to get the orders, for 20 total. A big improvement over the 500 requests required to check all tokens in a 10k collection. But this can be the default, and we should probably make it so that X is a parameter you can pass in when calling the API.

One more thing to consider is whether to do it based on contracts or collections. Collections is convenient, but requires us to have identical collection ids to open sea. This is mostly the case, but not sure we want tight coupling. Problem with doing it by contract is that in some cases (e.g. art blocks), there can be many tokens in the contract.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.