This directory contains a command-line utility for testing specific HumbleSwap SDK functionality.
Before you begin, make sure you run npm run build
in the top-level (./humble-sdk
) directory.
This will output a build file to a new ./lib
directory, which this current ./cli
depends on.
Once that's done, install some dependencies in here:
$. npm i
Now you can see the full list of available actions with:
$. npm run test
See additional info below.
All tests run against Algorand TestNet. You can change this by passing a custom providerEnv
property into
the initHumbleSDK
call in ./index.mjs
.
You will likely want to list pools first, so that you have values to pass into the other tests. To do so, run:
$. npm run test
This will spin up an account and subscribe to the SDK's pool stream. All values received will be printed on your terminal as it runs.
Note: this test is configured with an auto-timeout. You can change the length of this timeout (as well as the maximum number of pools fetched) in
./runAnnouncerTest.mjs
This test does not require a funded account. To fetch and display data for a single Token, run:
$. npm run test TOKEN=tokenId
Replace tokenId
with your token Id of choice.
Worth noting: this technically tests something that the SDK depends upon, not the SDK itself.
This test does not require a funded account. To fetch and display data for a single Liquidity Pool, run:
$. npm run test POOL=poolId [ N2NN=1 ]
Replace poolId
with the pool id of choice. If the pool contains ALGO
, add the parameter N2NN=1
.
Notes: double-check your
N2NN
flag if you know the pool exists, but the pool fetch returnsnull
.
This test requires a funded account, as well as pool data. See List Pools or
Fetch Pool to print out pool data to your terminal.
To add liquidity to a Pool, run:
$. npm run test KEY="mnemonic phrase" POOL= AMTA= TOKA= TOKB= ACTION=
ACTION
: One ofadd
orwithdraw
. Case-sensitive.KEY
: Your mnemonic phrase.POOL
: Pool Id (application id for pool smart contract)AMTA
: Amount you are paying in to tokenA
of pool.
For example, this would mean you are paying this muchFOO
into aFOO/BAZ
poolTOKA
: Id of pool Token A. Must matchtokenAId
in the pool matching IDPOOL
.
For example, this would be the id ofFOO
in aFOO/BAZ
poolTOKB
: Id of pool Token B. Must matchtokenBId
in the pool matching IDPOOL
.
For example, this would be the id ofBAZ
in aFOO/BAZ
pool
This test requires a funded account, as well as pool data. See List Pools or
Fetch Pool to print out pool data to your terminal.
To swap between two Tokens in a pool, run:
$. npm run test KEY="mnemonic phrase" POOL= AMTA= TOKA= TOKB=
KEY
: Your mnemonic phrase.POOL
: Pool Id (application id for pool smart contract)AMTA
: Amount you are paying inTOKA
: Id of Token you are paying in.
Must match eithertokenAId
ortokenBId
in the pool matching IDPOOL
TOKB
: Id of Token you expect to receive
Must match eithertokenAId
ortokenBId
in the pool matching IDPOOL
You can get the POOL
, AMTA
, TOKA
, and TOKB
parameters by fetching a pool.
See List Pools or Fetch Pool for more on that.