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

Collateral does not work for delegated trading with subaccount ID #109

Open
utgarda opened this issue Feb 18, 2025 · 9 comments
Open

Collateral does not work for delegated trading with subaccount ID #109

utgarda opened this issue Feb 18, 2025 · 9 comments

Comments

@utgarda
Copy link
Contributor

utgarda commented Feb 18, 2025

With delegated trading, are collateral and leverage supposed to work?

curl 172.17.0.1:8080/v2/collateral
# {"total":"0.000009","free":"0.000009"}

curl 172.17.0.1:8080/v2/leverage
# {"leverage":"0"}

curl '172.17.0.1:8080/v2/collateral?subAccountId=1'
# {"code":500,"reason":"market data unavailable. subscribe market: spot/22"}

curl '172.17.0.1:8080/v2/leverage?subAccountId=1'
# {"code":500,"reason":"market data unavailable. subscribe market: spot/22"}


curl '172.17.0.1:8080/v2/positions?subAccountId=1'
{"spot":[{"amount":"1034.613065","type":"deposit","marketIndex":0},{"amount":"0.003850106","type":"deposit","marketIndex":1},{"amount":"10.551171","type":"borrow","marketIndex":22}],"perp":[{"amount":"4.3","averageEntry":"200.3483","marketIndex":0}]}
@jordy25519
Copy link
Collaborator

jordy25519 commented Feb 18, 2025

I think this issue is caused by gateway missing some market data subscriptions.
gateway auto subscribes to all the markets where the user has a position at startup but only on the default sub-account.
since this is on another sub-account its not subscribed to the necessary markets

to fix, start gateway with a --markets flag e.g. --markets pyusd,btc-perp
pass it all the spot and/or perp markets that are not included from sub-account 0.

gateway used to subscribe to all drift markets but that was causing rate-limit issues and unnecessary resource use for many users, so now gateway only subscribes to fixed set of markets determined at startup.

maybe could add a flag like --active-sub-accounts 1,2,3 for user to get this automatically aswell.

@utgarda
Copy link
Contributor Author

utgarda commented Feb 18, 2025

Can we get collateral for markets after subscribing to them via websockets? Subscribing to all markets on start isn't great, as you pointed out, but later it's useful to get collateral for any market available.

@Borlandini
Copy link

Borlandini commented Feb 19, 2025

Subscription to usdt stopped working today btw, gateway just terminates without any errors when trying to subscribe to usdt. Probably it's a temporary error caused to drift program, idk.

@jordy25519
Copy link
Collaborator

Subscription to usdt stopped working today btw, gateway just terminates without any errors when trying to subscribe to usdt. Probably it's a temporary error caused to drift program, idk.

maybe this is related to recent program update: pls try https://github.com/drift-labs/gateway/releases/tag/v1.3.4 and lmk if its still an issue.

@jordy25519
Copy link
Collaborator

Can we get collateral for markets after subscribing to them via websockets? Subscribing to all markets on start isn't great, as you pointed out, but later it's useful to get collateral for any market available.

yeah adding some dynamic handling for the market subscriptions will be good.

In most cases, the set of markets being traded/used as collateral is known beforehand.
quick fix is to supply any markets logged as 'missing' at gateway startup: --markets pyusd,new-perp

@Borlandini
Copy link

Borlandini commented Feb 20, 2025

maybe this is related to recent program update: pls try https://github.com/drift-labs/gateway/releases/tag/v1.3.4 and lmk if its still an issue.

unfortunately the same gateway behavior when trying to subscribe to usdt 🙁

@jordy25519
Copy link
Collaborator

maybe this is related to recent program update: pls try https://github.com/drift-labs/gateway/releases/tag/v1.3.4 and lmk if its still an issue.

unfortunately the same gateway behavior when trying to subscribe to usdt 🙁

can you try run with --verbose and provide any relevant logs? I am unable to reproduce the issue

@jordy25519
Copy link
Collaborator

jordy25519 commented Feb 21, 2025

maybe this is related to recent program update: pls try https://github.com/drift-labs/gateway/releases/tag/v1.3.4 and lmk if its still an issue.

unfortunately the same gateway behavior when trying to subscribe to usdt 🙁

there was an issue with latest docker image, hopefully its resolved with latest docker pull ghcr.io/drift-labs/gateway:1.3.5

if instead you built gateway locally and linked drift-ffi-sys, then please update that: https://github.com/drift-labs/drift-ffi-sys/releases/tag/v2.110.0

@Borlandini
Copy link

there was an issue with latest docker image, hopefully its resolved with latest docker pull ghcr.io/drift-labs/gateway:1.3.5

if instead you built gateway locally and linked drift-ffi-sys, then please update that: https://github.com/drift-labs/drift-ffi-sys/releases/tag/v2.110.0

It's works fine, thank you.

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

3 participants