@1delta/trade-sdk
v0.1.7
Published
1Delta Trade SDK for handling cross-chain swaps and bridges
Downloads
716
Readme
@1delta/trade-sdk
A TypeScript SDK for token swaps and bridge operations.
Installation
pnpm add @1delta/trade-sdkFeatures
- Token swaps
- Bridge operations
- Support for multiple DEX aggregators and bridges
- Type-safe API with TypeScript support
Basic Usage
import { initialize, fetchBridgeTrade, fetchAggregatorTrade, Bridge } from '@1delta/trade-sdk';
import { WalletClient } from 'viem';
// Initialize the SDK
await initialize({
isProductionEnv: true,
loadChainData: true,
loadSquidData: true,
load1deltaConfigs: true
});
// Set up wallet client
const walletClient: WalletClient = /* your wallet client */;
setWalletClient(walletClient);
// Fetch a bridge trade
const trade = await fetchBridgeTrade({
bridge: Bridge.ACROSS,
input: {
fromCurrency: fromToken,
toCurrency: toToken,
amount: '1000000000000000000', // 1.0 in wei
receiver: '0x...',
caller: '0x...',
slippage: 0.5, // 0.5%
}
});API
initialize(config: SdkConfig): Promise<void>
Initializes the SDK with the given configuration.
setWalletClient(walletClient: WalletClient): void
Sets the wallet client for transaction signing.
fetchBridgeTrade(input: BridgeInput): Promise<GenericTrade>
Fetches a bridge trade quote.
fetchAggregatorTrade(aggregator: TradeAggregator, input: AggregatorApiInput): Promise<GenericTrade>
Fetches a trade quote from a DEX aggregator.
