Skip to content

forward native price requests to autopilot #3831

@MartinquaXD

Description

@MartinquaXD

Background

The orderbook(s) and the autopilot run as separate processes but both need access to native prices. Unfortunately they don't share the same underlying native price cache which can lead to inconsistencies - especially for niche tokens.
For example the orderbook could be able to fetch a native price and allow an order to be placed. Then the autopilot will pick up the order from the DB and try to fetch the native price as well. If a token is very niche there might only be 1 solver supporting it and it's possible that it serves the orderbook request correctly but rate limits the autopilot request.

To fix this we need to have 1 native price cache that all services can use. Ideally we'd move all the quoting logic into a separate service and make it use a Redis cache (in case we need to scale the service horizontally).
However that is a lot of work and we can get a pretty reasonably approximation with a lot less effort.

For that we just need to make the orderbook forward the native price requests to the autopilot. This will then cause the autopilot cache to be the 1 shared cache for all the processes.

Details

Changes needed:

  • add axum server to autopilot to handle /native_price requests
  • make the orderbook forward requests to a configurable URL
    • add CLI argument for native price endpoint in orderbook
  • adjust infra repo
    • add service for autopilot to make it addressable in the cluster (if that doesn't already exist)
    • add CLI args to orderbook
  • adjust e2e tests (for most tests it should just be a matter of using the new arg in the orderbook, but there are probably some tests that only spawn an orderbook and now need the autopilot as well)

Acceptance criteria

autopilot ultimately handles all native price requests

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions