@masterpeach/aggregator-sdk
v0.4.0
Published
TypeScript SDK for DEX Aggregator on BSC
Readme
Peach Aggregator SDK
TypeScript SDK for BSC swaps through the Peach Execution Router, using ethers v6.
npm install @masterpeach/[email protected] ethers@^6Quote and transaction in one call
import { BSC_MAINNET_CONFIG, PeachClient } from "@masterpeach/aggregator-sdk";
const client = new PeachClient(BSC_MAINNET_CONFIG);
// tokenIn, tokenOut, amount and executor come from your connected wallet and order.
const prepared = await client.swap({
from: tokenIn, target: tokenOut, amount, executor,
slippageBps: 50, deadlineSecs: 300,
});
console.log(prepared.expectAmountOut, prepared.tx.amountOutMin);swap() returns quote amounts and validated transaction data from one API request. It does not approve tokens or send a transaction. After the user accepts the returned terms, check approval and submit this same result with executeSwap(prepared, signer). See Quickstart for approval, expiry and receipt handling.
Amounts are exact-input bigint values in input-token base units. payer and recipient default to executor; Direct swaps require payer and executor to match. Routing and fee settings are top-level parameters.
For different payer/executor accounts, use prepareDelegatedSwap → signPayerAuthorization → buildDelegatedSwap, then submit the built result. Preparation returns the quote and authorization; build does not re-quote.
Documentation
- Overview
- Quickstart
- Quotes and Routing
- Direct Swaps
- Delegated Swaps
- Native BNB
- Fees and Slippage
- Client Configuration
- SDK Reference
- Changelog
0.4.0 adds the recommended swap(params) entry point. prepareDirectSwap(params) remains compatible and returns the same result.
License
MIT
