ttxd-alpha
v1.0.0
Published
An SDK for building applications on top of V2,V3 and Solana exchanges
Downloads
78
Readme
TT-Alpha SDK
The latest version of the SDK is used in production in the DEX Interfaces, but it is considered Alpha testing software and may contain bugs or change significantly between patch versions.
Features
- Multi-chain & multi-DEX support: Currently supports Ethereum, BNB Chain, Polygon, and Base, with more chains coming soon.
- Modular architecture: Add additional DEXes and blockchains without refactoring core logic.
- Lightweight: Designed for high performance, the SDK offers minimal overhead.
This ttxd-alpha SDK provides a unified way to interact with Uniswap V2, Uniswap V3, PancakeSwap, QuickSwap, SushiSwap, and Raydium V2 exchanges across multiple blockchains. With simple functions, you can swap tokens and manage liquidity seamlessly across Ethereum, BSC, Polygon, Base, and Solana.
Installation
Make sure you have Node.js installed. To install the SDK, run:
npm install ttxd-alpha
Examples of Using the SDK
1. V2 Exchanges: Uniswap V2
This example demonstrates a swap on Uniswap V2, but the same code works for other V2 exchanges by simply changing the exchange name and chainId.
import { swapV2 } from 'ttxd-alpha';
const provider = new ethers.providers.JsonRpcProvider('RPC URL'); // JsonRpcProvider instance
const signer = new ethers.Wallet('YOUR_PRIVATE_KEY', provider); // Wallet instance
(async () => {
await swapV2({
chainId: ChainId.Base, // ChainId
exchange: "uniswapv2",
token1: new Token(), // Token instance
token2: new Token(), // Token instance
amount: '1000000', // 1 USDC (raw amount)
provider,
signer,
});
})();
Supported V2 Exchanges
| Exchange | Supported Networks | |-----------------|-----------------------------------| | "uniswapv2" | Ethereum, BSC, Polygon, Base | | "pancakeswapv2" | Ethereum, BSC, Base | | "quickswapv2" | Polygon | | "sushiswapv2" | Ethereum, BSC, Polygon |
2. V3 Exchanges: Uniswap V3
The following example demonstrates a swap using Uniswap V3. Similarly, it works for other V3 exchanges with minor changes.
import { swapV3 } from 'ttxd-alpha';
const provider = new ethers.providers.JsonRpcProvider('RPC URL'); // JsonRpcProvider instance
const signer = new ethers.Wallet('YOUR_PRIVATE_KEY', provider); // Wallet instance
(async () => {
await swapV3({
chainId: ChainId.BASE, //ChainId
exchange: "uniswapv3",
tokenIn: new Token(), // Token instance
tokenOut: new Token(), // Token instance
fee: 500, // Pool fee
amountIn: '1000000', // 1 USDC (raw amount)
provider,
signer,
});
})();
Supported V3 Exchanges
| Exchange | Supported Networks | |-----------------|-----------------------------------| | "uniswapv3" | Ethereum, BSC, Polygon, Base | | "pancakeswapv3" | BSC, Base |
3. Solana : Raydium V2
This example demonstrates a swap using Raydium V2 on Solana. Raydium works with Pool IDs, so you must provide a specific pool ID and amount for the swap.
import { swapRaydium } from 'ttxd-alpha';
(async () => {
await swapRaydium({
poolId: 'POOL_ID', // Example pool ID
amountIn: 0.005, // Amount in SOL
privateKey: 'YOUR_PRIVATE_KEY', // Wallet private key
});
})();
Supported Solana Exchanges "raydiumv2" - Solana
License
This project is licensed under the MIT License.