Skip to content
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

Websocket type activeAssetCtx can return wrong channel type activeSpotAssetCtx #88

Open
syahrul12345 opened this issue Feb 19, 2025 · 3 comments

Comments

@syahrul12345
Copy link

When subscribing for asset contexts, but the coin is a spot market:

{"method":"subscribe","subscription":{"type":"activeAssetCtx","coin":"@107"}}

The return value has a different channel type of activeSpotAssetCtx
The example payload is this:

{
    "channel": "activeSpotAssetCtx",
    "data": {
        "coin": "@107",
        "ctx": {
            "prevDayPx": "23.993",
            "dayNtlVlm": "228614808.04913011",
            "markPx": "23.277",
            "midPx": "23.281",
            "circulatingSupply": "334395529.28086698",
            "coin": "@107",
            "totalSupply": "999840322.48575342",
            "dayBaseVlm": "9756716.93999999"
        }
    }
}

The rust sdk is unable to handle this case. I will create a PR to handle this if this is indeed a bug

@syahrul12345
Copy link
Author

let (sender, mut receiver) = unbounded_channel();
    info_client
        .subscribe(
            Subscription::ActiveAssetCtx {
                coin: "@107".to_string(),
            },
            sender,
        )
        .await
        .unwrap();
    tokio::spawn(async move {
        while let Some(msg) = receiver.recv().await {
            //Never enters
            println!("Received active asset ctx: {:?}", msg);
        }
    });

The problem lies with the mismatch between type and channel, when the subscription is first created, activeAssetCtx is used as an identifier, but after receiving the response from the websocket endpoint, because channel is of activeSpotAssetCtx, it uses this as an identifier, which doesnt exist when the subscription was first created

@namn-grg
Copy link
Contributor

Hey @syahrul12345 yes seems this is bug, pls make a PR with fix if you want :)

@syahrul12345
Copy link
Author

alright, probably will create this tomorrow morning

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

No branches or pull requests

2 participants