@tetherto/wdk-protocol-swap-velora-evm
Note : This package is currently in beta. Please test thoroughly in development environments before using in production.
A secure and straightforward package that lets EVM wallet accounts swap tokens using the Velora aggregator. This package provides a clean SDK for token swaps on EVM chains, supporting both standard wallets and ERC-4337 smart accounts.
This module can be managed by the @tetherto/wdk suite, which provides a unified interface for managing multiple WDK wallet and protocol modules across different blockchains.
🔍 About WDK
This module is part of the WDK (Wallet Development Kit) project, which enables developers to build secure, non-custodial wallets with unified blockchain access and complete user control.
For documentation on the complete WDK ecosystem, see https://docs.wallet.tether.io .
🌟 Features
Token Swapping via Valora Dex
Account Abstraction: Works with standard EVM wallets and ERC‑4337 smart accounts
Fee Controls: Optional swapMaxFee to cap gas costs
USDT Mainnet Handling: Allowance reset to 0 before approve when needed
TypeScript Definitions
Provider Flexibility: Works with JSON‑RPC URLs and EIP‑1193 providers
⬇️ Installation
npm install @tetherto/wdk-protocol-swap-velora-evm
🚀 Quick Start
Direct Usage
ERC‑4337 Smart Account
📚 API Reference
ParaSwapProtocolEvm
Main class for ParaSwap token swaps on EVM.
Constructor
Parameters:
account (WalletAccountEvm | WalletAccountEvmErc4337 | WalletAccountReadOnlyEvm | WalletAccountReadOnlyEvmErc4337)
config (object, optional):
swapMaxFee (bigint, optional): maximum total gas fee allowed
Example:
Methods
Method Description Returns swap(options, config?)Swaps a token pair Promise<{hash: string, fee: bigint, tokenInAmount: bigint, tokenOutAmount: bigint, approveHash?, resetAllowanceHash?}>quoteSwap(options, config?)Quotes swap fee and amounts Promise<{fee: bigint, tokenInAmount: bigint, tokenOutAmount: bigint}>
swap(options, config?)
Execute a swap.
Options:
tokenIn (string): address of token to sell
tokenOut (string): address of token to buy
tokenInAmount (bigint, optional): exact input amount
tokenOutAmount (bigint, optional): exact output amount
to (string, optional): recipient (default: your address)
Config (ERC‑4337 only):
paymasterToken (string, optional): token to pay gas
swapMaxFee (bigint, optional): override fee cap
Returns:
Standard account: { hash, fee, tokenInAmount, tokenOutAmount, approveHash, resetAllowanceHash? }
ERC‑4337 account: { hash, fee, tokenInAmount, tokenOutAmount } (approve bundled)
Notes:
On Ethereum mainnet, selling USDT may first set allowance to 0, then approve.
Requires an attached provider.
Requires a non-read-only account to send swaps.
Example:
quoteSwap(options, config?)
Get swap fee and amounts without sending a transaction.
Options are the same as swap.
Returns: { fee, tokenInAmount, tokenOutAmount }
Config (ERC‑4337 only):
paymasterToken (string, optional): token to pay gas
Works with read-only accounts.
🌐 Supported Networks
Works on EVM networks supported by ParaSwap. You will need a working RPC provider.
🔒 Security Considerations
Seed Phrase Security: Keep your seed phrase safe and never share it
Provider Security: Use trusted RPC endpoints
Approval Safety: USDT on mainnet may reset allowance to 0 before approval
Fee Limits: Use swapMaxFee to prevent high gas costs
Quote First: Get a quote before swapping
🛠️ Development
Building
Testing
📜 License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
🆘 Support
For support, please open an issue on the GitHub repository.