A PancakeSwap integration provider for BinkOS that enables seamless token swaps on BNB Chain through the PancakeSwap decentralized exchange.
The PancakeSwap provider implements the swap provider interface for BinkOS, enabling direct integration with PancakeSwap's liquidity pools and smart contracts. It provides optimized routing, accurate price quotes, and efficient token swaps on BNB Chain.
-
🥞 PancakeSwap Integration: Direct access to PancakeSwap's functionality
- Token swaps
- Price quotes
- Liquidity pool information
- Smart routing
-
⚡ BNB Chain Support: Native support for BNB Chain operations
-
💰 Optimal Routing: Best price discovery across liquidity pools
-
🔒 Secure Transactions: Safe and reliable swap execution
-
🔌 Plugin Ready: Seamless integration with BinkOS swap plugin
# Install as a dependency in your project
pnpm add @binkai/pancakeswap-provider
# Install required peer dependencies
pnpm add @binkai/core ethers
Here's how to integrate and use the PancakeSwap provider with BinkOS:
import { PancakeSwapProvider } from '@binkai/pancakeswap-provider';
import { ethers } from 'ethers';
// Initialize provider with RPC and chain ID
const provider = new ethers.JsonRpcProvider('https://bsc-dataseed1.binance.org');
const pancakeswap = new PancakeSwapProvider(provider, 56); // 56 is BNB Chain's chainId
// Use with swap plugin
const swapPlugin = new SwapPlugin();
await swapPlugin.initialize({
defaultSlippage: 0.5,
defaultChain: 'bnb',
providers: [pancakeswap],
supportedChains: ['bnb'],
});
// Register with BinkOS agent
await agent.registerPlugin(swapPlugin);
// Execute swap operations
const result = await agent.execute({
input: 'Buy BINK from exactly 0.0001 BNB with 0.5% slippage on bnb chain',
});
For a complete working example with all providers configured and advanced usage scenarios, see examples/basic/src/example.ts
The provider can be configured with the following parameters:
interface PancakeSwapProviderConfig {
provider: ethers.Provider; // Ethers provider instance
chainId: number; // Chain ID (56 for BNB Chain)
}
The PancakeSwap provider supports the following operations:
- Token swaps with exact input
- Token swaps with exact output
- Price quotes and estimations
- Slippage protection
- Multi-hop routing
Required configuration:
// Initialize with BNB Chain RPC
const provider = new ethers.JsonRpcProvider('https://bsc-dataseed1.binance.org');
const chainId = 56; // BNB Chain
The provider supports all tokens available on PancakeSwap, including:
- Native BNB
- BEP-20 tokens
- Popular trading pairs
- Newly listed tokens
The provider implements comprehensive error handling for common scenarios:
- Insufficient liquidity
- Price impact too high
- Transaction failures
- Network issues
# Install dependencies
pnpm install
# Build the provider
pnpm build
# Run tests
pnpm test
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This package is part of the BinkOS project. All rights reserved.
- @binkai/core - Core BinkOS functionality
- @binkai/swap-plugin - Swap plugin for BinkOS