Skip to content

Mimic Pyth Pro latest price endpoint - #169

Merged
hacheigriega merged 1 commit into
mainfrom
feat/pyth-latest-price
Oct 6, 2026
Merged

hacheigriega merged 1 commit into
mainfrom
feat/pyth-latest-price

Conversation

@hacheigriega

@hacheigriega hacheigriega commented Sep 4, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Injective OP is currently using POST /v1/latest_price REST endpoint of Pyth Pro through standard upstream module. This PR provides a way to mimic that endpoint through the Pyth Lazer module.

Explanation of Changes

We make fetchFromModule optional for Pyth Lazer module route schema. If it is omitted in the route configuration, the module will use this new POST body-based request handling.

Testing

{
	"modules": [
		{
			"type": "pyth-lazer",
			"name": "pyth",
			"pythLazerApiKeyEnvKey": "PYTH_LAZER_API_KEY",
			"priceFeedIds": [{ "name": "BTC/USD", "id": 1 }],
			"priceFeedsCleanupTtl": "20 seconds",
			"priceFeedsCleanupInterval": "10 seconds"
		}
	],
	"routes": [
		{
			"type": "pyth-lazer",
			"moduleName": "pyth",
			"path": "/v1/latest_price",
			"method": "POST",
			"channel": "real_time"
		}
	]
}
curl -sX POST http://localhost:5384/proxy/v1/latest_price \
  -H "Content-Type: application/json" \
  -d '{"priceFeedIds": [1,5]}' | jq

curl -sX POST http://localhost:5384/proxy/v1/latest_price \
  -H "Content-Type: application/json" \
  -d '{"priceFeedSymbols": ["Equity.US.AMD/USD"]}' | jq

Related PRs and Issues

Supersedes #137

@hacheigriega
hacheigriega force-pushed the feat/pyth-latest-price branch 2 times, most recently from b0513b8 to 0ec3a92 Compare September 4, 2026 15:12
@Thomasvdam

Copy link
Copy Markdown
Contributor

I'm not entirely sure if this is what we want/need but it might be sufficient if we're mindful of the limitations.

If I remember correctly the original idea of this was to enable the module to serve as a drop in replacement of a 'regular' Pyth Pro REST proxy. All Fast data proxies for Pyth Pro are currently using the REST interface so there are some latency concerns there. This implementation only provides support for a single route so we'd have to make sure that this is the only thing existing OPs are using and be mindful that future OPs can't use any other REST endpoints.

@hacheigriega

Copy link
Copy Markdown
Contributor Author

This implementation only provides support for a single route so we'd have to make sure that this is the only thing existing OPs are using and be mindful that future OPs can't use any other REST endpoints.

Currently Injective seems to be the only one using Pyth Pro DP. While the DP is configured to support any paths, the only path that is being used is the POST /v1/latest_price route that this PR tries to mimic.

@Thomasvdam

Copy link
Copy Markdown
Contributor

This implementation only provides support for a single route so we'd have to make sure that this is the only thing existing OPs are using and be mindful that future OPs can't use any other REST endpoints.

Currently Injective seems to be the only one using Pyth Pro DP. While the DP is configured to support any paths, the only path that is being used is the POST /v1/latest_price route that this PR tries to mimic.

In that case it could be worth considering to update the OP and injective data proxy.. Then remove all Pyth Pro REST references from the oracle-programs and from now on only use the Websocket module? What's your take?

@hacheigriega

Copy link
Copy Markdown
Contributor Author

In that case it could be worth considering to update the OP and injective data proxy.. Then remove all Pyth Pro REST references from the oracle-programs and from now on only use the Websocket module? What's your take?

If we're allowed to do that, yeah that would certainly be preferable to this PR. I assumed @jasperdg implemented this because modifying the OP and injective DP was not an option

@hacheigriega
hacheigriega force-pushed the feat/pyth-latest-price branch from 0ec3a92 to 2d56581 Compare September 8, 2026 19:12
@mariocao
mariocao requested a review from a team September 14, 2026 10:28
@hacheigriega
hacheigriega marked this pull request as draft September 21, 2026 13:08
@hacheigriega
hacheigriega force-pushed the feat/pyth-latest-price branch 2 times, most recently from 7734392 to 009d1c9 Compare September 21, 2026 18:13
@hacheigriega
hacheigriega marked this pull request as ready for review September 21, 2026 18:13
@hacheigriega hacheigriega changed the title Pyth Lazer latest price request using POST body Mimic Pyth Pro latest price endpoint Sep 21, 2026
@mariocao

mariocao commented Oct 6, 2026

Copy link
Copy Markdown
Member

Any update on this PR?
My take is that I don't think we can or should change the already deployed OPs, but make it backwards compatible.

@hacheigriega
hacheigriega force-pushed the feat/pyth-latest-price branch from 009d1c9 to c9c2fe7 Compare October 6, 2026 12:39
Pyth Lazer module now provides POST body-based request handling that
mimics Pyth Pro's POST `/v1/latest_price` endpoint if fetchFromModule
is not configured.
@hacheigriega
hacheigriega force-pushed the feat/pyth-latest-price branch from c9c2fe7 to b462bbb Compare October 6, 2026 13:22
@hacheigriega

Copy link
Copy Markdown
Contributor Author

Any update on this PR? My take is that I don't think we can or should change the already deployed OPs, but make it backwards compatible.

I am thinking to spin up a new data proxy to test using the existing OP inputs, and, if this works, we replace our Pyth Pro DP deployments with this. From the OP's perspective, nothing should change.

@hacheigriega
hacheigriega merged commit b462bbb into main Oct 6, 2026
2 checks passed
@hacheigriega
hacheigriega deleted the feat/pyth-latest-price branch October 6, 2026 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants