Skip to content

reader::get_funding_rate_info reads storage with the wrong token key, unlike get_funding_info #397

Description

@abayomicornelius

Problem

In contracts/reader/src/lib.rs, get_funding_info correctly loads the market first and builds its keys with market.long_token/market.short_token. Directly below it, get_funding_rate_info never loads the market at all and instead builds its funding/OI keys using the market_token address itself as the collateral_token parameter both key-builder functions expect. Nothing in the protocol ever writes funding/OI data under (market_token, market_token) — real writes are keyed by (market_token, long_token)/(market_token, short_token).

Why it matters

get_funding_rate_info is documented as a per-hour funding rate view for the frontend but will read empty/zero storage slots on any real market, silently returning stale/incorrect data to whatever dashboard consumes it. There is no test for this function, so the bug is unguarded.

Suggested fix

Load the market at the top of get_funding_rate_info and use market.long_token/market.short_token in place of market_token for the key-builder calls, exactly as get_funding_info does.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions