Swap SDK
We’re excited to launch the public release of StellaSwap’s Development Kit (SDK 😉), a tool that allows developers & projects to interact with StellaSwap’s DEX and access our deep-liquidity. As the most-used DEX on Polkadot, we’re proud to be the schelling point of native assets and users wanting to trade & stake in a familiar EVM-environment.
Overview of our SDK
Our public SDK provides functionality for integrating swaps on Moonbeam into any app or plugin. Moonbeam is the leading EVM parachain in Polkadot, and therefore taps on the best of Polkadot’s security and Ethereum’s convenience.
Developers and projects can integrate our our DEX for various applications that leverages on our liquidity. Our SDK features a range of useful documentation and APRs that entails technical specifications and code samples.
Description
The @stellaswap/swap-sdk provides functionality for integrating swap on Moonbeam into any app or plugin. StellaSwap SDK allows end-users to exchange tokens seamlessly on Moonbeam network.
Features
Uses state-of-the-art Hybrid Router
Utilizes Stable, V2, V3 AMMs
Error Handling
Installation
To install the package, use npm or yarn:
Usage
Importing the SDK
First, import the SDK.
Allowance
This helps to check allowance of tokenAddress against spender, it will return allowed number if there is any.
Approve
To perform approve pass desired value as amountIn
and for unlimited approval use 0
. In response, it returns transaction hash.
Get Quote
To get amountOut
of a trade use getQuote
. For account
it can be null if user is not connected. For native asset pass ETH
as token0Addr
or token1Addr
.
Response
To filter out amountOut
use quote.result.amountOut
. For the rest of the response, it includes;
Complete trade path.
Execution with commands and inputs
Swap
This can executes actual swap, for native asset pass ETH
as token0Addr
or token1Addr
.
Swap Native to ERC20
To swap native to ERC20, pass token0Addr
as ETH
and token1Addr
as erc20 address.
Swap ERC20 to ERC20
To swap native to ERC20, pass token0Addr
as erc20 address and token1Addr
as erc20 address.
Example for getPermit2Signature
getPermit2Signature
Dependencies
axios
@uniswap/permit2-sdk
Configuration
The SDK is pre-configured to be used with the Moonbeam mainnet and doesn't require an API key.
Error Handling
The SDK includes basic error handling. All methods return Promises, so you can use .catch()
to handle errors as you see fit.
Contribution
Feel free to submit issues and enhancement requests.
Last updated