Universal Adapter
Full reference for the Universal Adapter (SwapRouter) — the single entry point for atomically swapping any whitelisted token and depositing the proceeds into an Upshift vault.
The Universal Adapter is a standalone periphery contract that lets a caller atomically swap any whitelisted token through any whitelisted DEX aggregator and deposit the proceeds into an Upshift vault, in one transaction. It also accepts plain deposits and native-token deposits.
The contract never holds funds between transactions. Any residual balance found at the start of a call is swept, and any dust left at the end is refunded.
It is deposit-only — redemptions go through the vault itself, documented in the vault interface.
This reference is generated from the verified source of the live deployment (
SwapRouter.sol, solcv0.8.26). Every signature, constant, event, and error below is present on-chain.
Deployment
| Chain | Address | Wrapped native |
|---|---|---|
| Ethereum | 0xC11c6d8fD8FfFB2045d57b149125C44414d8160B | WETH |
| Base | 0x261c97E80C105F85BBbe1416E6eC67C76B9910E2 | WETH |
| Avalanche | 0x3ECc92b2244210BF09485a398f680255E80CC393 | WAVAX |
| HyperEVM | 0x1766f1F4C80756c0985ae93E3cf5cA5024bdAE6F | WHYPE |
| Monad | 0xF47ce4B8df30bc3B3b6cc21Fe1552A2198A4A4F7 | WMON |
| Flare | 0xe4c219e5966e97A2bF92464F1BAdB9EbAb3164bb | WFLR |
| Citrea | 0x5B02d6B43fED3EE010741712553F2423A256E9cf | WCBTC |
| Fluent | 0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0 | WETH |
Every deployment runs the same contract. Only Ethereum has a DEX aggregator
enabled (ParaSwap). On the other chains, deposit and depositNativeToken work,
but the swap functions have no route.
Retired deployments
These earlier routers are no longer used by the SDK or the Upshift app. Do not integrate against them.
| Chain | Address |
|---|---|
| Ethereum | 0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0 (v1) |
| Ethereum | 0x5ce697Fc962eD2C3f31A42e2A24f287c227E65d4 |
| HyperEVM | 0xF47ce4B8df30bc3B3b6cc21Fe1552A2198A4A4F7 (v1) |
| HyperEVM | 0x2A9F5A2CA9d318D3913D96e0c019412631C249c8 |
The same address can be live on one chain and retired on another — check the chain, not just the address.
How it works
There is no vault registry. Every deposit names the vault and its type
(1 ERC-4626, 2 Tokenized Vault V2). The adapter reads the vault's asset()
and deposits into exactly the vault the caller passed. Any vault that implements
the matching deposit function works, without an owner setup step.
Plain deposits skip the token whitelist. deposit and depositNativeToken
accept any asset the vault itself accepts — the vault decides. The
whitelistedTokens(token) list gates only swaps: both the input and the output
of every swap leg. Only tokens with 6, 8, or 18 decimals can be whitelisted.
Each DEX aggregator needs a router path. enableRouter stores two things: the
address the adapter approves tokens to (tokenTransferProxies(router), which is
the router itself when the aggregator has no separate proxy), and one authorized
4-byte selector.
The selector allowlist is a deliberate safety boundary. The router address is
whitelisted but the swap payload is fully caller-controlled, so without it a caller
could aim a crafted payload at any function on the whitelisted router — including
its approve or transfer — and reach the adapter's own token approvals. Only
isAuthorizedSelector(router, selector) pairs are callable.
An origin code is optional. Passing bytes32(0) means no referral fee. A
non-zero code must be registered or the call reverts with InvalidOrigin. See
Fee Sharing for how partners get one.
Fee order of operations
Two fees exist: the Upshift swap fee, set per vault with setVaultSwapFee
(zero unless set) and paid to feesCollector, and the partner origin fee,
set per origin code and paid to that origin's collector. Which apply depends on
the entry point:
| Entry point | Swap fee | Origin fee |
|---|---|---|
deposit | — | ✓ |
depositNativeToken | — | ✓ |
swapAndDeposit | ✓ per leg | ✓ per leg |
swapAndDepositNativeToken | ✓ | ✓ |
On the swap paths the swap fee is taken from the swap output first, then the origin fee from what remains, and the vault receives the rest. Both are deducted before shares are minted, so the depositor's shares reflect the net amount. Fees are read at execution time.
Trust model
- Not upgradeable. No proxy and no
delegatecall. The wrapped native token isimmutable, set in the constructor. - No custody. Funds are pulled from
msg.senderand deposited in the same call. The vault mints the shares straight toreceiverAddr. A routed deposit gets the same shares and redemption rights as a direct vault deposit. - Owner powers. One
owner()address can pause deposits, change the token and router allowlists, change the fee collector, set fees up to the7000bps caps, and manage origin codes. It cannot move user funds or vault shares.transferOwnershipis single-step.
Constants
| Name | Value | Meaning |
|---|---|---|
BPS_DENOMINATOR | 10000 | Basis-point denominator for both fees. |
MAX_SWAP_FEE_BPS | 7000 | Ceiling on a vault's swap fee. |
MAX_ORIGIN_FEE_BPS | 7000 | Ceiling on an origin fee. |
MAX_SWAPS | 9 | Swap legs allowed in one swapAndDeposit. |
VAULT_TYPE_ERC4626 | 1 | Vault type: standard ERC-4626. |
VAULT_TYPE_TOKENIZED_VAULT_V2 | 2 | Vault type: Tokenized Vault V2 (multi-asset). |
NATIVE_TOKEN_ADDRESS | 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE | Native-token sentinel, per ERC-7528. |
Deposit functions
All four are nonReentrant, require the contract to be unpaused, and return the
shares minted to receiverAddr.
Every one runs the same common validation first: a non-zero originCode must be
registered (InvalidOrigin), receiverAddr must not be zero or the adapter itself
(InvalidReceiver), vaultType must be 1 or 2 (InvalidVaultType), the
vault's asset() must not be zero (InvalidVault), and it must not be the native
sentinel (NativeReferenceAssetNotSupported).
For an ERC-4626 vault the deposited asset must equal the vault's asset(),
otherwise the call reverts with AssetNotAcceptedByVault. A Tokenized Vault V2
receives deposit(asset, amount, receiver) and accepts whatever its own assets
whitelist allows.
deposit
Deposits an ERC-20 into the vault. No swap, so no swap fee, and no token whitelist check.
function deposit(
bytes32 originCode,
uint256 depositAmount,
address vaultAddr,
uint8 vaultType,
address assetAddr,
address receiverAddr
) external returns (uint256 shares);| Name | Type | Description |
|---|---|---|
originCode | bytes32 | Origin code, or bytes32(0) for none. |
depositAmount | uint256 | Amount to pull from msg.sender. |
vaultAddr | address | The vault to deposit into. |
vaultType | uint8 | 1 ERC-4626, 2 Tokenized Vault V2. |
assetAddr | address | The asset to deposit. The vault must accept it. |
receiverAddr | address | Receives the shares. |
Reverts with ZeroAmount on a zero amount and ZeroSharesReceived if the vault
mints nothing.
depositNativeToken
Wraps msg.value into the chain's wrapped native token and deposits that. No swap
fee applies on this path.
function depositNativeToken(bytes32 originCode, address vaultAddr, uint8 vaultType, address receiverAddr)
external
payable
returns (uint256 shares);Requires a non-zero msg.value (ZeroAmount). Reverts with NativeSwapFailed if
wrapping does not credit exactly msg.value. Any dust is refunded to msg.sender.
swapAndDeposit
Runs one to MAX_SWAPS atomic swaps and deposits each leg's output into the vault,
returning the summed shares.
function swapAndDeposit(
bytes32 originCode,
address vaultAddr,
uint8 vaultType,
address receiverAddr,
SwapParams[] calldata swapParams
) external returns (uint256 shares);| Name | Type | Description |
|---|---|---|
originCode | bytes32 | Origin code, or bytes32(0) for none. |
vaultAddr | address | The vault to deposit into. |
vaultType | uint8 | 1 ERC-4626, 2 Tokenized Vault V2. |
receiverAddr | address | Receives the shares. |
swapParams | SwapParams[] | One entry per swap leg. |
Each leg is validated before anything executes: tokenIn must differ from
tokenOut (InvalidPair), amountIn must be non-zero (ZeroAmount), tokenOut
must not be the native sentinel (OutputTokenCannotBeNativeToken), payload must
be at least 4 bytes (InvalidPayload), the router must have a registered path
(InvalidRouter), and both tokens must be whitelisted
(InputTokenNotWhitelisted / OutputTokenNotWhitelisted).
Then, per leg: the payload's selector must be authorized for that router
(InvalidNotWhitelisted), minAmountOut must be non-zero
(MissingSlippageProtection), amountIn is pulled from msg.sender, the router
is called with the payload (SwapFailed on revert), and the output is measured by
balance delta. Output below minAmountOut reverts with SlippageError; an
unchanged input balance reverts with InputTokenNotSwapped.
Because output is measured by balance difference rather than trusted from the router's return value, a payload that routes proceeds elsewhere fails the slippage check rather than succeeding silently.
Reverts with EmptySwapParams on an empty array and TooManySwaps above
MAX_SWAPS. Excess input tokens are refunded to msg.sender at the end.
swapAndDepositNativeToken
Wraps msg.value and deposits it. Unlike depositNativeToken, this path charges
the vault's swap fee.
function swapAndDepositNativeToken(bytes32 originCode, address vaultAddr, uint8 vaultType, address receiverAddr)
external
payable
returns (uint256 shares);Same requirements and reverts as depositNativeToken, plus the swap fee deduction.
Read functions
| Function | Returns | Description |
|---|---|---|
vaultSwapFees(address vault) | uint256 | The vault's swap fee in bps. Zero unless the owner set one. |
origins(bytes32 code) | (uint256 originFee, address originFeeCollector) | An origin's fee in bps and its collector. Zero collector means unregistered. |
whitelistedTokens(address token) | bool | Whether the token may be used in a swap leg. |
tokenTransferProxies(address router) | address | The address the adapter approves tokens to for that router. Zero means no path. |
isAuthorizedSelector(address router, bytes4 selector) | bool | Whether that selector may be called on that router. |
feesCollector() | address | Recipient of Upshift swap fees. |
wrappedNativeTokenAddress() | address | The chain's wrapped native token (immutable). |
isPaused() | bool | Whether deposits are paused. |
owner() | address | The contract owner. |
There is no getOrigin function — read the origins mapping directly.
Administrative functions
The constructor sets the owner, feesCollector, and the wrapped native token.
Every function below is onlyOwner and nonReentrant.
| Function | Description |
|---|---|
pause() / unPause() | Halt or resume all deposit entry points. |
setVaultSwapFee(address vaultAddr, uint256 swapFee) | Set a vault's swap fee. Reverts with SwapFeeTooHigh above MAX_SWAP_FEE_BPS. |
enableToken(IERC20Metadata token) | Whitelist a token for swaps. Rejects any token whose decimals are not 6, 8, or 18 (InvalidErc20Token). |
disableToken(address tokenAddr) | Remove a token from the whitelist. |
enableRouter(address routerAddr, address tokenApprovalAddr, bytes4 authorizedSelector) | Register a router path and authorize one selector on it. |
disableRouter(address routerAddr, bytes4 authorizedSelector) | Remove a router path and de-authorize the selector. |
addOrigin(bytes32 originCode, uint256 originFee, address originFeeCollector) | Register an origin. The code must be non-zero, the collector must not be zero or the adapter, and the fee must not exceed MAX_ORIGIN_FEE_BPS. A zero fee is allowed. |
updateOrigin(bytes32 originCode, uint256 originFee, address originFeeCollector) | Change an existing origin's fee or collector. Reverts with InvalidOrigin if the code was never registered. |
revokeOrigin(bytes32 originCode) | Delete an origin. Subsequent deposits carrying it revert with InvalidOrigin. |
updateFeesCollector(address newFeesCollectorAddr) | Change the Upshift fee recipient. Reverts with FeesCollectorNoOp if unchanged. |
transferOwnership(address newOwner) | Transfer ownership in one step. |
addOrigin, updateOrigin, and revokeOrigin revert with ContractIsPaused
while the adapter is paused.
Events
// Lifecycle
event ContractPaused();
event ContractResumed();
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
// Registry
event VaultSwapFeeUpdated(address indexed vaultAddr, uint256 swapFee);
event TokenEnabled(address indexed tokenAddr);
event TokenDisabled(address indexed tokenAddr);
event RouterPathEnabled(address indexed routerAddr, address indexed tokenApprovalAddr);
event RouterPathDisabled(address indexed routerAddr);
event FeesCollectorUpdated(address indexed newAddr);
// Origins
event OriginAdded(bytes32 indexed originCode, uint256 originFee, address originFeeCollector);
event OriginUpdated(bytes32 indexed originCode, uint256 originFee, address originFeeCollector);
event OriginRevoked(bytes32 indexed originCode);
// Deposits
event DepositRouted(
address sender,
address indexed vaultAddr,
bytes32 indexed originCode,
address indexed receiverAddr,
address assetAddr,
uint256 grossAmount, // before the origin fee; for swaps, the output after the swap fee
uint256 depositedAmount, // what reached the vault
uint256 shares,
uint256 originFeeBps,
uint256 originFeeAmount,
address originFeeCollector,
uint256 swapFeeAmount
);
// Residual handling
event ResidualBalanceSwept(address indexed token, address indexed to, uint256 amount);
event ResidualRefund(address indexed token, address indexed to, uint256 amount);DepositRouted fires on every deposit — once per swap leg on swapAndDeposit —
including deposits with no fee or no origin code. The vault also emits its own
Deposit. The SDK's getSwapRouterDepositResult resolves what a deposit produced.
Errors
Configuration and access
| Error | Cause |
|---|---|
ContractIsPaused | The adapter is paused. |
ContractNotPaused | unPause on an unpaused contract. |
OwnerOnly | Caller is not the owner. |
OwnerAddressRequired | Zero address passed to transferOwnership. |
ReentrancyGuardReentrantCall | Reentrant call. |
ZeroAddress / InvalidAddress | A required address was zero, or was the adapter itself. |
InvalidReceiver | receiverAddr is zero or the adapter itself. |
FeesCollectorNoOp | updateFeesCollector called with the current value. |
Vaults and tokens
| Error | Cause |
|---|---|
InvalidVault | The vault's asset() returned the zero address. |
InvalidVaultType | vaultType is neither 1 nor 2. |
InvalidErc20Token | Token decimals are not 6, 8, or 18. |
TokenAlreadyEnabled / TokenAlreadyDisabled | Redundant whitelist change. |
AssetNotAcceptedByVault | ERC-4626 vault given an asset other than its asset(). |
ZeroSharesReceived | The vault minted zero shares. |
NativeReferenceAssetNotSupported | The vault's asset() is the native sentinel. |
Swaps
| Error | Cause |
|---|---|
EmptySwapParams | No swap legs supplied. |
TooManySwaps | More than MAX_SWAPS legs. |
InvalidPair | A leg's tokenIn equals its tokenOut. |
ZeroAmount | A zero deposit amount, msg.value, or leg amountIn. |
InvalidPayload | A leg's payload is shorter than 4 bytes. |
OutputTokenCannotBeNativeToken | A leg's tokenOut is the native sentinel. |
InputTokenNotWhitelisted | A leg's input token is not whitelisted. Carries the token. |
OutputTokenNotWhitelisted | A leg's output token is not whitelisted. Carries the token. |
InvalidRouter | The router has no registered path. |
InvalidRouterPath | Zero or self address passed to enableRouter. Carries both addresses. |
RouterPathAlreadyDisabled | disableRouter on a router with no path. |
SelectorRequired | Zero selector passed to enableRouter. |
InvalidNotWhitelisted | The payload's selector is not authorized on that router. |
MissingSlippageProtection | A leg's minAmountOut is zero. |
SlippageError | Swap output was below minAmountOut. Carries the token, actual output, and minimum. |
InputTokenNotSwapped | The input balance did not change — the router consumed nothing. |
SwapFailed | The router call reverted. Carries its return data. |
NativeSwapFailed | Wrapping the native token did not credit msg.value. |
Fees and origins
| Error | Cause |
|---|---|
InvalidOrigin | A non-zero origin code is not registered or was revoked. Also thrown by addOrigin on a zero code. |
OriginAlreadyExists | addOrigin on an existing code — use updateOrigin. |
InvalidFeeCollector | An origin's collector is zero or the adapter itself. |
OriginFeeTooHigh | The fee exceeds MAX_ORIGIN_FEE_BPS at registration, or would consume the entire deposit at deposit time. |
OriginFeeTooLow | The deposit is small enough that the origin fee would round to zero. |
SwapFeeTooHigh | setVaultSwapFee given a fee above MAX_SWAP_FEE_BPS. |
SwapFeeAmountTooLow | The swap output is small enough that the swap fee would round to zero. |
NativeTokenTransferFailed is declared on the interface but is not reachable in
this deployment.
Structs
struct SwapParams {
address tokenIn;
address tokenOut;
uint256 amountIn;
uint256 minAmountOut; // must be non-zero
address router; // must have a registered path
bytes payload; // encoded swap call; its selector must be authorized
}
struct OriginEntry {
uint256 originFee; // bps
address originFeeCollector;
}Integrating
Most integrations should go through the SDK rather than encoding calls by hand — it resolves the vault's reference asset and type, picks the right entry point, builds and pins the swap quote, and handles approvals. See EVM actions and, for partner fee sharing, Fee Sharing.