- Ethereum Virtual Machine
- Solana Virtual Machine
Swap Function
Contract:0x57AB1E2c6289aCe985Bd5c5571EbF6d98CD41Ab7 (Key Addresses)Function Signature
Parameters
Preconditions
- The caller must have approved the Stableswapper contract to spend at least
amountInoftokenIn(ERC-20approve) - Both
tokenInandtokenOutmust be listed and swappable - The SWAP feature flag must be enabled
- If the ALLOWLIST feature is enabled,
msg.sendermust be allowlisted amountInandminAmountOutmust be greater than zerotokenInandtokenOutmust be different addressesrecipientmust not be the zero address
Fee Model
Fees are charged on the input token and deducted before the 1:1 swap calculation.Example: Swapping 100 USDC with a 1% fee (100 basis points):
- User sends: 100 USDC
- Fee: 1 USDC (sent to fee recipient)
- User receives: 99 of the output token (normalized for decimals)
View Functions
Token State
Fee Configuration
Access Control
Feature flag values:
Events
Error Reference
Roles
The contract uses role-based access control. These roles are managed by theDEFAULT_ADMIN_ROLE holder.What to read next
Examples
Code samples for common swap scenarios
Quickstart
Get up and running in 10 minutes
Key Addresses
Program IDs and deployed addresses
Production Readiness
Helper functions and best practices