UpshiftDocs

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, solc v0.8.26). Every signature, constant, event, and error below is present on-chain.

Deployment

ChainAddressWrapped native
Ethereum0xC11c6d8fD8FfFB2045d57b149125C44414d8160BWETH
Base0x261c97E80C105F85BBbe1416E6eC67C76B9910E2WETH
Avalanche0x3ECc92b2244210BF09485a398f680255E80CC393WAVAX
HyperEVM0x1766f1F4C80756c0985ae93E3cf5cA5024bdAE6FWHYPE
Monad0xF47ce4B8df30bc3B3b6cc21Fe1552A2198A4A4F7WMON
Flare0xe4c219e5966e97A2bF92464F1BAdB9EbAb3164bbWFLR
Citrea0x5B02d6B43fED3EE010741712553F2423A256E9cfWCBTC
Fluent0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0WETH

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.

ChainAddress
Ethereum0xAC771209FF2b71EECfF6E85a9AD01db8Ff2618B0 (v1)
Ethereum0x5ce697Fc962eD2C3f31A42e2A24f287c227E65d4
HyperEVM0xF47ce4B8df30bc3B3b6cc21Fe1552A2198A4A4F7 (v1)
HyperEVM0x2A9F5A2CA9d318D3913D96e0c019412631C249c8

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 pointSwap feeOrigin 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 is immutable, set in the constructor.
  • No custody. Funds are pulled from msg.sender and deposited in the same call. The vault mints the shares straight to receiverAddr. 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 the 7000 bps caps, and manage origin codes. It cannot move user funds or vault shares. transferOwnership is single-step.

Constants

NameValueMeaning
BPS_DENOMINATOR10000Basis-point denominator for both fees.
MAX_SWAP_FEE_BPS7000Ceiling on a vault's swap fee.
MAX_ORIGIN_FEE_BPS7000Ceiling on an origin fee.
MAX_SWAPS9Swap legs allowed in one swapAndDeposit.
VAULT_TYPE_ERC46261Vault type: standard ERC-4626.
VAULT_TYPE_TOKENIZED_VAULT_V22Vault type: Tokenized Vault V2 (multi-asset).
NATIVE_TOKEN_ADDRESS0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeENative-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);
NameTypeDescription
originCodebytes32Origin code, or bytes32(0) for none.
depositAmountuint256Amount to pull from msg.sender.
vaultAddraddressThe vault to deposit into.
vaultTypeuint81 ERC-4626, 2 Tokenized Vault V2.
assetAddraddressThe asset to deposit. The vault must accept it.
receiverAddraddressReceives 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);
NameTypeDescription
originCodebytes32Origin code, or bytes32(0) for none.
vaultAddraddressThe vault to deposit into.
vaultTypeuint81 ERC-4626, 2 Tokenized Vault V2.
receiverAddraddressReceives the shares.
swapParamsSwapParams[]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

FunctionReturnsDescription
vaultSwapFees(address vault)uint256The 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)boolWhether the token may be used in a swap leg.
tokenTransferProxies(address router)addressThe address the adapter approves tokens to for that router. Zero means no path.
isAuthorizedSelector(address router, bytes4 selector)boolWhether that selector may be called on that router.
feesCollector()addressRecipient of Upshift swap fees.
wrappedNativeTokenAddress()addressThe chain's wrapped native token (immutable).
isPaused()boolWhether deposits are paused.
owner()addressThe 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.

FunctionDescription
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

ErrorCause
ContractIsPausedThe adapter is paused.
ContractNotPausedunPause on an unpaused contract.
OwnerOnlyCaller is not the owner.
OwnerAddressRequiredZero address passed to transferOwnership.
ReentrancyGuardReentrantCallReentrant call.
ZeroAddress / InvalidAddressA required address was zero, or was the adapter itself.
InvalidReceiverreceiverAddr is zero or the adapter itself.
FeesCollectorNoOpupdateFeesCollector called with the current value.

Vaults and tokens

ErrorCause
InvalidVaultThe vault's asset() returned the zero address.
InvalidVaultTypevaultType is neither 1 nor 2.
InvalidErc20TokenToken decimals are not 6, 8, or 18.
TokenAlreadyEnabled / TokenAlreadyDisabledRedundant whitelist change.
AssetNotAcceptedByVaultERC-4626 vault given an asset other than its asset().
ZeroSharesReceivedThe vault minted zero shares.
NativeReferenceAssetNotSupportedThe vault's asset() is the native sentinel.

Swaps

ErrorCause
EmptySwapParamsNo swap legs supplied.
TooManySwapsMore than MAX_SWAPS legs.
InvalidPairA leg's tokenIn equals its tokenOut.
ZeroAmountA zero deposit amount, msg.value, or leg amountIn.
InvalidPayloadA leg's payload is shorter than 4 bytes.
OutputTokenCannotBeNativeTokenA leg's tokenOut is the native sentinel.
InputTokenNotWhitelistedA leg's input token is not whitelisted. Carries the token.
OutputTokenNotWhitelistedA leg's output token is not whitelisted. Carries the token.
InvalidRouterThe router has no registered path.
InvalidRouterPathZero or self address passed to enableRouter. Carries both addresses.
RouterPathAlreadyDisableddisableRouter on a router with no path.
SelectorRequiredZero selector passed to enableRouter.
InvalidNotWhitelistedThe payload's selector is not authorized on that router.
MissingSlippageProtectionA leg's minAmountOut is zero.
SlippageErrorSwap output was below minAmountOut. Carries the token, actual output, and minimum.
InputTokenNotSwappedThe input balance did not change — the router consumed nothing.
SwapFailedThe router call reverted. Carries its return data.
NativeSwapFailedWrapping the native token did not credit msg.value.

Fees and origins

ErrorCause
InvalidOriginA non-zero origin code is not registered or was revoked. Also thrown by addOrigin on a zero code.
OriginAlreadyExistsaddOrigin on an existing code — use updateOrigin.
InvalidFeeCollectorAn origin's collector is zero or the adapter itself.
OriginFeeTooHighThe fee exceeds MAX_ORIGIN_FEE_BPS at registration, or would consume the entire deposit at deposit time.
OriginFeeTooLowThe deposit is small enough that the origin fee would round to zero.
SwapFeeTooHighsetVaultSwapFee given a fee above MAX_SWAP_FEE_BPS.
SwapFeeAmountTooLowThe 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.