Skip to content

/price/:assetA/:assetB/history pools testnet and mainnet rows into one OHLCV series #208

Open

Description

@Miracle656

src/api/rest.ts:160-170 queries price_aggregates on pair_key alone:

SELECT bucket, window, vwap, sdex_vwap, amm_vwap, volume, trade_count,
       open_price, close_price, high_price, low_price
  FROM price_aggregates
 WHERE pair_key = $1 AND window = $2
 ORDER BY bucket DESC
 LIMIT $3

price_aggregates is written per network, so on an instance where ENABLED_NETWORKS covers both chains the returned buckets interleave testnet and mainnet rows for the same pair_key. A caller gets one OHLCV series that is not a series of anything — and because the route takes no network parameter, there is no way to ask for the one they meant.

Same class as the /basket problem #181 is addressing on that route. A price with the wrong network is worse than no price.

Fix: filter on network, read it from req.network ?? activeNetwork the way /price/:assetA/:assetB and /prices/history already do, echo the answered network back in the response, and add NetworkQuery to the route's openapi.yaml entry plus the network field to its response schema. A test with rows for both networks at the same pair_key and bucket, asserting only one network's rows come back, is what proves it.

The README already describes this under "Still reading across both networks"; this issue is to close it rather than document it.

Found while reviewing #179, which correctly left network off this route's spec entry because the route genuinely ignores it today.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions