@sweepr/sdk
v0.1.0
Published
TypeScript SDK for Sweepr partner sweep integrations
Maintainers
Readme
@sweepr/sdk
TypeScript SDK for Sweepr partner integrations.
V1 supports the current partner API surface, including Solana/off-chain partner accounting. V2 supports EVM partner preview builds with signed on-chain fee splitting through SweeprBatchV5PartnerFees.
Install
npm install @sweepr/sdk viemInitialize
import { Sweepr } from '@sweepr/sdk';
const sweepr = new Sweepr({
apiKey: process.env.SWEEPR_API_KEY!,
version: 'v2',
});API keys are issued by Sweepr admins in the first release. Self-service key creation is not part of V1/V2 launch.
EVM V2 Flow
const build = await sweepr.sweep.build({
chain: 'base',
wallet: userAddress,
tokens,
outputMint,
slippageBps: 100,
});
const valid = await sweepr.evm.verifyFeeAuthorization(build);
if (!valid) throw new Error('Invalid Sweepr fee authorization');
const permitSignature = await walletClient.signTypedData({
account: userAddress,
domain: build.permit2.domain,
types: build.permit2.types,
primaryType: build.permit2.primaryType,
message: build.permit2.values,
});
const tx = sweepr.evm.finalizeV2Transaction(build, permitSignature);
const txHash = await walletClient.sendTransaction({
account: userAddress,
to: tx.to,
data: tx.data,
value: BigInt(tx.value),
});
await sweepr.sweep.confirm(build.sweepId, txHash);Security Checks
verifyFeeAuthorization checks:
- Sweepr fee authorization signature
- authorization deadline
- fee cap
- partner share cap
- optional expected partner recipient
The V5 contract also verifies the EIP-712 domain, user, output token, nonce, deadline, fee cap, recipients, and configured fee signer on-chain.
