Skip to content

add perp/spot market update notifcations #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

wphan
Copy link
Member

@wphan wphan commented May 22, 2025

More reactive use cases may benefit from being notified whenever a market account is updated. This PR adds DriftClient::perp_market_watch and DriftClient::spot_market_watch which returns a tokio::sync:watch that notifies the market_index of the updated account

@wphan wphan changed the title add perp/spot market watch add perp/spot market update notifcations May 22, 2025
Comment on lines +160 to +165
pub async fn subscribe_markets(
&self,
markets: &[MarketId],
on_account: Option<Arc<Box<OnAccountFn>>>,
) -> SdkResult<()> {
self.backend.subscribe_markets(markets, on_account).await
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub async fn subscribe_markets(
&self,
markets: &[MarketId],
on_account: Option<Arc<Box<OnAccountFn>>>,
) -> SdkResult<()> {
self.backend.subscribe_markets(markets, on_account).await
pub async fn subscribe_markets_with_callback(
&self,
markets: &[MarketId],
on_account: Option<Arc<Box<OnAccountFn>>>,
) -> SdkResult<()> {
self.backend.subscribe_markets(markets, on_account).await

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be good to keep the existing api unchanged, use new method only when user wants the callback

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.

2 participants