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

Confusing fetchLiquidityPool usage. #108

Open
guanzo opened this issue Nov 11, 2022 · 1 comment
Open

Confusing fetchLiquidityPool usage. #108

guanzo opened this issue Nov 11, 2022 · 1 comment

Comments

@guanzo
Copy link

guanzo commented Nov 11, 2022

So I tried out the includeTokens and tokens params and ended up thoroughly confused.

First off, the docs are contradictory.

https://reach-sh.github.io/humble-sdk/LIQUIDITY-POOLS.html#fetchliquiditypool-parameters

opts.includeTokens: (optional) Whether to fetch pool tokens as well. If set to false, you MUST provide a pair of token objects to the function using the param below
opts.tokens: (optional) Pool Tokens. Required when includeTokens is “true”

First it says, if includeTokens is false, then tokens is required.
Then the next line says the complete opposite, if includeTokens is true, then tokens is required.

Which is it? It's the former.


Next, the function should default includeTokens to true. It currently defaults to falsy, which is surprising behavior because that now means the tokens param must be passed or else the function fails. So tokens isn't really optional anymore.

The function should "just work" with the minimal params, that means it should fetch tokens by default. If the user chooses to provide tokens, they should opt into that feature by passing includeTokens=false.


Lastly, if the user chooses to provide tokens, how should the 2 tokens be ordered in the array? Order matters because it affects the swap quote. If you pass the wrong order, you get the wrong quote.

Even better, have the sdk ensure the token order is correct so the user doesn't have to worry about it. It knows the IDs of tokenA and tokenB, so it can easily sort the tokens param if its out of order. It can also do some basic validation, like if the passed tokens have the wrong ID.

@MrJackdaw
Copy link
Contributor

Thanks for pointing out the documentation errors. We introduced the includeTokens parameter specifically to limit requests, because there were complaints that the SDK made too many requests. We will take your very helpful suggestions into account as we work on the next release.

Please let me know if you have any other concerns. Cheers!

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