tiagosiebler / binance

Node.js & JavaScript SDK for Binance REST APIs & WebSockets, with TypeScript & browser support, integration tests, beautification & more.
MIT License
747 stars 266 forks source link

Result returned by a call to getNotionalAndLeverageBrackets() #310

Closed posman closed 1 year ago

posman commented 1 year ago

This is not a bug, just an observation

According to Binance API https://binance-docs.github.io/apidocs/futures/en/#notional-and-leverage-brackets-user_data, the endpoint leverageBracket will return an array when called without a symbol and a JSON object when called with a symbol.

But the method getNotionalAndLeverageBrackets() in USDMClient it's returning an array in both cases. When called with a symbol, returns an array of length = 1

Everything is working fine. Just something to take in account. (I know people's code will break if a change is made to the function)

tiagosiebler commented 1 year ago

Interesting observation - I see it too. There's no custom logic here doing that to-array mapping in my SDK, seems like that's how the API itself is responding.

What I'll actually do here is update the return type for that method to always be an array: Promise<SymbolLeverageBracketsResult[]>. Not really a breaking change since that's how the API itself responds, not a new transformation from the SDK, and will make for a less fussy implementation for anyone using typescript. Thanks for pointing it out.

tiagosiebler commented 1 year ago

Fixed in v2.5.0 (via #311)