Universal Adapter

This contract provides a single entry-point for atomic swaps, deposits and redemptions.

State Variables

_isConfigured

Indicates if the contract was configured.

bool internal _isConfigured;

isPaused

Indicates whether the smart contract is paused or not.

bool public isPaused;

feesCollector

The address of the fees collector.

address public feesCollector;

uniswapRouterAddress

The address of the Uniswap router.

address public uniswapRouterAddress;

vaultReferenceAsset

The reference asset of each whitelisted vault, in the form (vault address => reference asset)

origins

The whitelisted referrers, in the form (origin code => info)

swapFees

The swap fee of each vault, in the form (vault address => swap fee)

whitelistedTokens

The list of whitelisted tokens

whitelistedRouters

The list of whitelisted routers for atomic swaps

Functions

constructor

ifConfigured

Throws if the contract was not configured

ifNotConfigured

Throws if the contract was configured already

ifNotPaused

Throws if the contract is not paused

ifPaused

Throws if the contract is paused

ifVaultEnabled

Throws if the vault specified is not enabled

configure

Configures the smart contract.

Throws if the contract was already configured.

Parameters

Name
Type
Description

ownerAddr

address

The new owner of the smart contract.

newFeesCollectorAddr

address

The address of the fees collector.

setUniswapRouterAddress

Sets the address of the Uniswap router

Passing the zero address disables the Uniswap router

Parameters

Name
Type
Description

newUniswapRouterAddress

address

The address of the Uniswap router

pause

Pauses the smart contract.

unPause

Resumes (unpauses) the smart contract.

discontinue

Discontinues the use of this smart contract.

The contract is no longer usable after calling this function.

enableVaults

Enables the vaults specified.

Parameters

Name
Type
Description

vaultAddresses

address[]

The list of vaults to enable.

newSwapFees

uint256[]

The swap fee applicable to each vault.

disableVaults

Disables the vaults specified.

Parameters

Name
Type
Description

vaultAddresses

address[]

The list of vaults to disable.

setSwapFee

Sets the swap fee of the vault specified.

Parameters

Name
Type
Description

vaultAddr

address

The address of the ERC-4626 vault.

fee

uint256

The fee applicable to swaps, expressed in bps. It can be zero.

updateFeesCollector

Updates the address of the fees collector.

Parameters

Name
Type
Description

newFeesCollectorAddr

address

The address of the new fees collector.

enableSwapInputTokens

Allows the tokens specified to be used during an atomic swap.

This function prevents the fee collector and origin collectors from receiving unauthorized tokens.

Parameters

Name
Type
Description

tokenAddresses

address[]

The list of tokens to enable. These tokens can be used during a swap.

disableSwapInputTokens

Prevents the tokens specified to be used during an atomic swap.

Parameters

Name
Type
Description

tokenAddresses

address[]

The list of tokens to disable. These tokens cannot be used during a swap.

enableRouter

Enables the router address specified.

Throws if you pass the address of the Uniswap router.

Parameters

Name
Type
Description

routerAddr

address

The address of the router.

disableRouter

Disables the router address specified.

This function allows you to disable a router.

Parameters

Name
Type
Description

routerAddr

address

The router to disable.

addOrigin

Enables a new referrer.

Reverts if the referrer already exists.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer.

originFee

uint256

The fee taken by the referrer, expressed in bps. It can be zero.

originFeeCollector

address

The fee collector of the referrer.

updateOrigin

Updates the settings of the referrer specified.

Reverts if the referrer does not exist.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer.

originFee

uint256

The fee taken by the referrer, expressed in bps. It can be zero.

originFeeCollector

address

The fee collector of the referrer.

revokeOrigin

Disables the referrer specified.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer.

swapAndDeposit

Swaps the tokens specified via Uniswap V3 and deposits the resulting outcome in a given vault.

This overload runs the swap via Uniswap V3.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

vaultAddr

address

The address of the ERC-4626 vault.

receiverAddr

address

The address of the receiver. This address receives the LP tokens.

swaps

SingleHopItem[]

The list of atomic swaps to perform.

Returns

Name
Type
Description

shares

uint256

The number of shares acquired.

swapAmountOut

uint256

The amount of reference assets swapped via Uniswap V3. Any applicable fees are deducted from this amount.

swapAndDeposit

Swaps the tokens specified through a whitelisted router and deposits the resulting outcome in a given vault.

This overload runs the swap through an abstract call.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

vaultAddr

address

The address of the ERC-4626 vault.

receiverAddr

address

The address of the receiver. This address receives the LP tokens.

tokenApprovalAddr

address

The address of the token approver.

routerAddr

address

The address of the router capable of running the atomic swap.

items

OffchainSwapInfo[]

The swaps to perform.

Returns

Name
Type
Description

shares

uint256

The number of shares acquired.

swapAmountOut

uint256

The amount of reference assets swapped through the abstract calls specified. Any applicable fees are deducted from this amount.

deposit

Deposits the reference asset in the vault specified.

Origin fees may apply, depending on the origin. The swap fee is not applicable.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

depositAmount

uint256

The deposit amount.

vaultAddr

address

The address of the ERC-4626 vault.

receiverAddr

address

The address of the receiver. This address receives the LP tokens.

Returns

Name
Type
Description

shares

uint256

The number of shares acquired.

requestRedeem

Requests a redemption from the vault specified.

Parameters

Name
Type
Description

shares

uint256

The number of shares to redeem.

receiverAddr

address

The address of the receiver.

holderAddr

address

The address of the tokens holder.

vaultAddr

address

The address of the ERC-4626 vault.

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

Returns

Name
Type
Description

assets

uint256

The amount of assets that can be claimed for this specific withdrawal request.

claimableEpoch

uint256

The date at which the assets become claimable. This is expressed as a Unix epoch.

claim

Allows any public address to process the scheduled withdrawal requests of the receiver specified.

Throws if the receiving address is not the legitimate address you registered via "requestRedeem()"

Parameters

Name
Type
Description

year

uint256

The year component of the claim. It can be a past date.

month

uint256

The month component of the claim. It can be a past date.

day

uint256

The day component of the claim. It can be a past date.

receiverAddr

address

The address of the legitimate receiver of the funds.

vaultAddr

address

The address of the ERC-4626 vault.

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

Returns

Name
Type
Description

shares

uint256

uint256 The effective number of shares (LP tokens) that were burnt from the vault.

assets

uint256

uint256 The effective amount of reference assets that were transfered to the receiver.

instantRedeem

Redeems the number of shares specified, instantly.

Parameters

Name
Type
Description

shares

uint256

The number of shares to redeem.

receiverAddr

address

The address of the receiver.

vaultAddr

address

The address of the ERC-4626 vault.

originCode

bytes32

The code of the referrer, if any. Pass zero bytes32 if there is no referrer at all.

getOrigin

Gets the details of the referrer specified.

Parameters

Name
Type
Description

originCode

bytes32

The code of the referrer.

Returns

Name
Type
Description

originFee

uint256

The fee taken by the referrer, expressed in bps.

originFeeCollector

address

The fee collector of the referrer.

_deposit

Applies origin fees and deposits the reference asset in the vault

_applyOriginFees

Applies origin fees. The fee is applied if -and only if- the origin code is valid.

_applySwapFees

Applies the respective swap fee

_swapViaUniswapV3

Runs a swap via Uniswap V3

_swapViaOffchainCall

Runs a swap based on the off-chain quote specified

Events

ContractPaused

ContractResumed

ContractDiscontinued

ContractConfigured

TokenEnabled

TokenDisabled

VaultEnabled

VaultDisabled

FeesCollectorUpdated

SwapFeeUpdated

SwapFeeApplied

Deposit

OriginFeeApplied

RedemptionRequested

RedemptionClaimed

InstantRedeption

OriginAdded

OriginUpdated

OriginRevoked

Errors

InvalidOrigin

OriginAlreadyExists

RouterNotSet

InvalidRouter

InvalidTokenApprovalAddress

InvalidVault

UnsupportedVault

InvalidFeeCollector

FeeCollectorNotSet

VaultTokenNotAllowed

InvalidFee

InvalidToken

LengthMismatch

AddressRequired

ContractIsPaused

ContractNotPaused

InvalidReceiver

SwapFailed

SwapFailedNoReason

TokenNotWhitelisted

SlippageCheckFailed

OriginFeeTooHigh

SwapFeeTooHigh

NotConfigured

AlreadyConfigured

AmountTooLow

Structs

OriginEntry

SingleHopItem

OffchainSwapInfo

Last updated