NPM Package
Introduction to the @karrotcapital/spiderswap NPM Package
The @karrotcapital/spiderswap NPM package is your key to integrating Carbium’s decentralized exchange aggregator directly into your JavaScript or TypeScript applications. This lightweight package empowers developers to interact with Carbium’s API for token swaps, liquidity management, and advanced trading features with ease.
Whether you’re building DeFi dashboards, trading bots, or custom integrations for the Solana ecosystem, @karrotcapital/spiderswap provides the tools and flexibility needed to scale your project.
Getting Started
Installation
Install the package using NPM:
npm install @karrotcapital/spiderswap
Setting Up
Import the package and initialize the Spiderswap client with your API key:
// Using ES Modules
import Spiderswap from '@karrotcapital/spiderswap';
// OR using CommonJS
const Spiderswap = require('@karrotcapital/spiderswap');
// Initialize Spiderswap with your API key
const spiderswap = new Spiderswap('YourApiKey');
Using the Package
1. Fetching Token Swap Quotes
Get real-time quotes for any token pair with minimal setup:
// Example: Get a quote for swapping 1 SOL to USDC
spiderswap.getSwapQuote('SOL', 'USDC', 1.0).then((quote) => {
console.log('Price for 1 SOL to USDC:', quote);
}).catch((error) => {
console.error('Error fetching quote:', error);
});
2. Executing Token Swaps
Execute a token swap directly from your application:
// Example: Execute a swap
spiderswap.executeSwap('SOL', 'USDC', 1.0, 'your_wallet_address').then((result) => {
console.log('Swap executed:', result);
}).catch((error) => {
console.error('Error executing swap:', error);
});
3. Customization and Advanced Features
Tailor the package to your specific needs with additional parameters for slippage tolerance, route customization, and more. Check the official documentation for advanced use cases.
Why Choose This Package?
- Developer-Friendly Integration: Quick and intuitive setup with minimal configuration.
- High Performance: Optimized for low-latency interactions with Carbium’s API.
- Versatile Applications: Ideal for trading bots, analytics platforms, and custom DeFi solutions.
Updated 16 days ago