reach-sh / humble-sdk

A Javascript library for interacting with the HumbleSwap DEx
https://app.humble.sh
10 stars 1 forks source link

How do I get the pool address to supply to fetchLiquidityPool() ? #40

Closed giuliop closed 2 years ago

giuliop commented 2 years ago

I suppose the website should show it in the Pools section but I can't find it

giuliop commented 2 years ago

of course I can interact with the pool and check the application id on a block explorer but I guess there should be an easier way :)

LogioTek commented 2 years ago

It would be nice to be able to get pool(s) just by supplying 2 asset IDs.

MrJackdaw commented 2 years ago

Hello @giuliop and @LogioTek: apologies for the late response. All HumbleSwap data is on the blockchain, so there are no [in-house] RESTful APIs for listing data at the moment.

Short answer

The Humble SDK gives you tools to build a find-pool-by-token-ids mechanism: the catch (re: what @LogioTek suggests) is that you have to build it yourself.

Longer answer

I just gave a lengthy explanation here that [peripherally] shows how you can subscribe to a stream of pools. When you first connect to it, the subscribeToPoolStream function will fetch as many pools as it "hears" exist. Even after it stops emitting data, it will continue to listen and send new stuff as long as you don't terminate it. You can route this data into a cache, local db, or state manager of choice.

You should ideally do this soon after initializing the SDK, so that the data can be stored and used in other operations. But (unlike initHumbleSDK) you can call subscribeToPoolStream at any time.

Let me know if this helps!