@rainbow-ic/sunbeam
v0.0.25
Published
multiple ICP dexes lib
Downloads
14
Readme
Sunbeam SDK
Sunbeam SDK is a TypeScript library for interacting with decentralized exchanges (DEXs) on the Internet Computer (IC) blockchain. It provides a unified interface for interacting with different DEXs like KongSwap and ICPSwap.
Features
- List tokens and pools
- Get pool information
- Prepare and execute swaps
- Retrieve transaction history
Installation
To install the Sunbeam SDK, use npm or yarn:
npm i @rainbow-ic/sunbeamTable of Contents
Usage
Importing the SDK
import { KongSwap, ICPSwap } from "@rainbow-ic/sunbeam";Initializing a DEX
KongSwap
import { HttpAgent } from "@dfinity/agent";
import { KongSwap } from "@rainbow-ic/sunbeam";
const agent = new HttpAgent({ host: "https://ic0.app" });
const kongSwap = new KongSwap({ agent });ICPSwap
import { HttpAgent } from "@dfinity/agent";
import { ICPSwap } from "@rainbow-ic/sunbeam";
const agent = new HttpAgent({ host: "https://ic0.app" });
const icpSwap = new ICPSwap({ agent });Listing Tokens
KongSwap
https://github.com/rainbow-ic/sunbeam-example/blob/main/src/list_pool_and_token.ts#L8
ICPSwap
https://github.com/rainbow-ic/sunbeam-example/blob/main/src/list_pool_and_token.ts#L8
Listing Pools
KongSwap
https://github.com/rainbow-ic/sunbeam-example/blob/main/src/list_pool_and_token.ts#L29
ICPSwap
https://github.com/rainbow-ic/sunbeam-example/blob/main/src/list_pool_and_token.ts#L54
Getting Pool Information
KongSwap
const pool = await kongSwap.getPoolByAddress("pool-address");
if (pool) {
const poolInfo = pool.getPoolInfo();
console.log(poolInfo);
}ICPSwap
const pool = await icpSwap.getPoolByAddress("pool-address");
if (pool) {
const poolInfo = pool.getPoolInfo();
console.log(poolInfo);
}Preparing and Executing a Swap
KongSwap
ICPSwap
Getting Transaction History
KongSwap
const transactions = await kongSwap.getTransactions();
console.log(transactions);ICPSwap
This is not implement yet
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the MIT License.
This README provides an overview of the including installation instructions, usage examples, and information on contributing and licensing.