Install from npm:
npm install zilswap-sdk
Initialize the sdk based on the required network, then call the required methods which will automatically map and call the corresponding smart contract correct transitions.
import { Zilswap } from 'zilswap-sdk'
(async () => {
const zilswap = new Zilswap(Network.TestNet)
await zilswap.initialize()
await zilswap.addLiquidity('SWTH', '42', '42')
await zilswap.teardown()
})()
All public Zilswap methods can be found on the Zilswap
SDK object.
All public Zilo methods can be found on the Zilo
SDK object.
Full typescript definitions can also be found in the Modules.
The following is a list of methods to quickly get you started:
approveTokenTransferIfRequired
- approves transfers to zilswap for the given token contract, if the current approval amount is insufficient.addLiquidity
- adds liquidity to the poolremoveLiquidity
- removes liquidity to the poolswapWithExactInput
- swaps a token for another token, specifying the exact amount that should be given.swapWithExactOutput
- swaps a token for another token, specifying the exact amount that should be received.getAppState
- gets the current dApp stategetPool
- gets the reserve values for a poolgetObservedTxs
- gets the txs that the SDK is observingaddToken
- adds a token that is not in the pre-built listobserveTx
- observe a zilliqa blockchain txsetDeadlineBlocks
- set the number of blocks before a transition sent by the SDK to expirestoUnitless
- converts a human amount into a unitless integer that is used by Scilla.toUnit
- converts a unitless integer used by scilla into a human readable amount.getRatesForInput
- get the current exchange rates for a pool by giving an input amount.getRatesForOutput
- get the current exchange rates for a pool by giving an output amount.PRIVATE_KEY=xxx yarn run test
Generate documentation with typedoc. Install with:
npm i typedoc typedoc-plugin-markdown --global
then run:
typedoc --out ./doc ./src --excludePrivate --excludeNotExported --plugin typedoc-plugin-markdown
Please review the contribution guidelines before contributing or opening pull requests.