1.0.6 • Published 7 months ago

biosol-sdk v1.0.6

Weekly downloads
-
License
ISC
Repository
github
Last release
7 months ago

Bioswap SDK

Bioswap is a lightweight and easy-to-use SDK for interacting with token swaps on the Solana blockchain. It provides functionality for liquidity providers, traders, and developers to seamlessly exchange tokens from decentralized pools of Bioswap Pool.

Key Features:

Get Swapped Amount: get swapped token amount in advance.
Token Swaps: Instantly swap tokens in liquidity pools.

Installation

npm i bioswap-sdk

Tech Stacks

Node.js latest version

@coral-xyz/anchor: "^0.29.0",
@solana/web3.js: "^1.95.2",
@solana/spl-token: "^0.4.8"

@solana/wallet-adapter-react: "^0.15.35",
@solana/wallet-adapter-react-ui: "^0.9.35",

How it works

example method to use swap function

const Bioswap = require('bioswap-sdk')

const signer = // From PrivateKey or Phantom

const fromToken = "So11111111111111111111111111111111111111112";
const toToken = "BLLbAtSHFpgkSaUGmSQnjafnhebt8XPncaeYrpEgWoVk";
const amount = 1;
const rpcUrl = ""
const slippage = 3
const lookupTable = undefined

const bioswap = new Bioswap(rpcUrl, slippage,lookupTable, 1_000_000)
<!-- If you don't pass rpcUrl it will be default mainnet RPC url -->
<!-- If you don't pass slippage, it will be 3% automatically -->
<!-- If you don't pass fee, it will be 20_000 automatically -->
<!-- If you don't pass lookupTable, it will be undefined automatically -->

const init = async () => {
    const message = await bioswap.swap(wallet.pubkey, fromToken, toToken, amount);
    const transaction = new VersionedTransaction(message.message);
    const signedTxn = await signer.signTransaction(transaction);
    const tx = await connection.sendTransaction(signedTxn, {
      skipPreflight: true,
    });

    console.log(tx);
}
init()

example method to use getSwappedAmount function in Node.js with PrivateKey

const Bioswap = require('bioswap-sdk')

const signer = // From PrivateKey or Phantom

const fromToken = "So11111111111111111111111111111111111111112";
const toToken = "BLLbAtSHFpgkSaUGmSQnjafnhebt8XPncaeYrpEgWoVk";
const amount = 1;
const rpcUrl = ""
const slippage = 3

const bioswap = new Bioswap(rpcUrl, slippage)
<!-- If you don't pass rpcUrl it will be default mainnet RPC url -->
<!-- If you don't pass slippage, it will be 3% automatically -->

const init = async () => {
    const message = await bioswap.getSwappedAmount(wallet.pubkey, fromToken, toToken, amount);
    const transaction = new VersionedTransaction(message);
    const signedTxn = await signer.signTransaction(transaction);
    const tx = await connection.sendTransaction(signedTxn, {
      skipPreflight: true,
    });

    console.log(tx);
}
init()
1.0.2

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago