Provisioner

Inherits: IProvisioner, Auth2Step, ReentrancyGuardTransient

Entry and exit point for {MultiDepositorVault}. Handles all deposits and redemptions Uses {IPriceAndFeeCalculator} to convert between tokens and vault units. Supports both sync and async deposits; only async redeems. Manages deposit caps, refund timeouts, and request replay protection. All assets must flow through this contract to enter or exit the vault. Sync deposits are processed instantly, but stay refundable for a period of time. Async requests can either be solved by authorized solvers, going through the vault, or directly by anyone willing to pay units (for deposits) or tokens (for redeems), pocketing the solver tip, always paid in tokens

State Variables

PRICE_FEE_CALCULATOR

The price and fee calculator contract

IPriceAndFeeCalculator public immutable PRICE_FEE_CALCULATOR;

MULTI_DEPOSITOR_VAULT

The multi depositor vault contract

address public immutable MULTI_DEPOSITOR_VAULT;

tokensDetails

Mapping of token to token details

mapping(IERC20 token => TokenDetails details) public tokensDetails;

depositCap

Maximum total value of deposits in numeraire terms

uint256 public depositCap;

depositRefundTimeout

Time period in seconds during which sync deposits can be refunded

uint256 public depositRefundTimeout;

syncDepositHashes

Mapping of active sync deposit hashes

True if a sync deposit is active with the hashed parameters

mapping(bytes32 syncDepositHash => bool exists) public syncDepositHashes;

asyncDepositHashes

Mapping of async deposit hash to its existence

True if deposit request exists, false if it was refunded or solved

mapping(bytes32 asyncDepositHash => bool exists) public asyncDepositHashes;

asyncRedeemHashes

Mapping of async redeem hash to its existence

True if redeem request exists, false if it was refunded or solved

mapping(bytes32 asyncRedeemHash => bool exists) public asyncRedeemHashes;

userUnitsRefundableUntil

Mapping of user address to timestamp until which their units are locked

mapping(address user => uint256 unitsLockedUntil) public userUnitsRefundableUntil;

Functions

anyoneButVault

Ensures the caller is not the vault

modifier anyoneButVault();

constructor

constructor(
    IPriceAndFeeCalculator priceAndFeeCalculator,
    address multiDepositorVault,
    address owner_,
    Authority authority_
) Auth2Step(owner_, authority_);

deposit

Deposit tokens directly into the vault

MUST revert if tokensIn is 0, minUnitsOut is 0, or sync deposits are disabled

function deposit(IERC20 token, uint256 tokensIn, uint256 minUnitsOut)
    external
    anyoneButVault
    returns (uint256 unitsOut);

Parameters

Name
Type
Description

token

IERC20

The token to deposit

tokensIn

uint256

The amount of tokens to deposit

minUnitsOut

uint256

The minimum amount of units expected

Returns

Name
Type
Description

unitsOut

uint256

The amount of shares minted to the receiver

mint

Mint exact amount of units by depositing required tokens

function mint(IERC20 token, uint256 unitsOut, uint256 maxTokensIn) external anyoneButVault returns (uint256 tokensIn);

Parameters

Name
Type
Description

token

IERC20

The token to deposit

unitsOut

uint256

The exact amount of units to mint

maxTokensIn

uint256

Maximum amount of tokens willing to deposit

Returns

Name
Type
Description

tokensIn

uint256

The amount of tokens used to mint the requested shares

refundDeposit

Refund a deposit within the refund period

Only callable by authorized addresses

function refundDeposit(address sender, IERC20 token, uint256 tokenAmount, uint256 unitsAmount, uint256 refundableUntil)
    external
    requiresAuth;

Parameters

Name
Type
Description

sender

address

The original depositor

token

IERC20

The deposited token

tokenAmount

uint256

The amount of tokens deposited

unitsAmount

uint256

The amount of units minted

refundableUntil

uint256

Timestamp until which refund is possible

requestDeposit

Create a new deposit request to be solved by solvers

function requestDeposit(
    IERC20 token,
    uint256 tokensIn,
    uint256 minUnitsOut,
    uint256 solverTip,
    uint256 deadline,
    uint256 maxPriceAge,
    bool isFixedPrice
) external anyoneButVault;

Parameters

Name
Type
Description

token

IERC20

The token to deposit

tokensIn

uint256

The amount of tokens to deposit

minUnitsOut

uint256

The minimum amount of units expected

solverTip

uint256

The tip offered to the solver

deadline

uint256

Duration in seconds for which the request is valid

maxPriceAge

uint256

Maximum age of price data that solver can use

isFixedPrice

bool

Whether the request is a fixed price request

requestRedeem

Create a new redeem request to be solved by solvers

function requestRedeem(
    IERC20 token,
    uint256 unitsIn,
    uint256 minTokensOut,
    uint256 solverTip,
    uint256 deadline,
    uint256 maxPriceAge,
    bool isFixedPrice
) external anyoneButVault;

Parameters

Name
Type
Description

token

IERC20

The token to receive

unitsIn

uint256

The amount of units to redeem

minTokensOut

uint256

The minimum amount of tokens expected

solverTip

uint256

The tip offered to the solver

deadline

uint256

Duration in seconds for which the request is valid

maxPriceAge

uint256

Maximum age of price data that solver can use

isFixedPrice

bool

Whether the request is a fixed price request

refundRequest

Refund an expired deposit or redeem request

Can only be called after request deadline has passed

function refundRequest(IERC20 token, Request calldata request) external nonReentrant;

Parameters

Name
Type
Description

token

IERC20

The token involved in the request

request

Request

The request to refund

solveRequestsVault

Solve multiple requests using vault's liquidity

Only callable by authorized addresses

function solveRequestsVault(IERC20 token, Request[] calldata requests) external requiresAuth nonReentrant;

Parameters

Name
Type
Description

token

IERC20

The token for which to solve requests

requests

Request[]

Array of requests to solve

solveRequestsDirect

Solve multiple requests using solver's own liquidity

function solveRequestsDirect(IERC20 token, Request[] calldata requests) external nonReentrant;

Parameters

Name
Type
Description

token

IERC20

The token for which to solve requests

requests

Request[]

Array of requests to solve

setDepositDetails

Update deposit parameters

function setDepositDetails(uint256 depositCap_, uint256 depositRefundTimeout_) external requiresAuth;

Parameters

Name
Type
Description

depositCap_

uint256

New maximum total value that can be deposited

depositRefundTimeout_

uint256

New time window for deposit refunds

setTokenDetails

Update token parameters

function setTokenDetails(IERC20 token, TokenDetails calldata details) external requiresAuth;

Parameters

Name
Type
Description

token

IERC20

The token to update

details

TokenDetails

removeToken

Removes token from provisioner

function removeToken(IERC20 token) external requiresAuth;

Parameters

Name
Type
Description

token

IERC20

The token to be removed

maxDeposit

Return maximum amount that can still be deposited

function maxDeposit() external view returns (uint256);

Returns

Name
Type
Description

<none>

uint256

Amount of deposit capacity remaining

areUserUnitsLocked

Check if a user's units are currently locked

function areUserUnitsLocked(address user) external view returns (bool);

Parameters

Name
Type
Description

user

address

The address to check

Returns

Name
Type
Description

<none>

bool

True if user's units are locked, false otherwise

getDepositHash

Computes the hash for a sync deposit

function getDepositHash(address user, IERC20 token, uint256 tokenAmount, uint256 unitsAmount, uint256 refundableUntil)
    external
    pure
    returns (bytes32);

Parameters

Name
Type
Description

user

address

The address making the deposit

token

IERC20

The token being deposited

tokenAmount

uint256

The amount of tokens to deposit

unitsAmount

uint256

Minimum amount of units to receive

refundableUntil

uint256

The timestamp until which the deposit is refundable

Returns

Name
Type
Description

<none>

bytes32

The hash of the deposit

getRequestHash

Computes the hash for a generic request

function getRequestHash(IERC20 token, Request calldata request) external pure returns (bytes32);

Parameters

Name
Type
Description

token

IERC20

The token involved in the request

request

Request

The request struct

Returns

Name
Type
Description

<none>

bytes32

The hash of the request

_syncDeposit

Handles a synchronous deposit, records the deposit hash, and enters the vault

Reverts if the deposit hash already exists. Sets the refundable period for the user

function _syncDeposit(IERC20 token, uint256 tokenAmount, uint256 unitAmount) internal;

Parameters

Name
Type
Description

token

IERC20

The ERC20 token to deposit

tokenAmount

uint256

The amount of tokens to deposit

unitAmount

uint256

The amount of vault units to mint for the user

_solveDepositVaultAutoPrice

Solves an async deposit request for the vault, transfering tokens or refunding as needed

  • Returns 0 if any of:

  • price age is too high, emits PriceAgeExceeded

  • request hash is not set, emits InvalidRequestHash

  • units out is less than min required, emits AmountBoundExceeded

  • deposit cap would be exceeded, emits DepositCapExceeded

  • If deadline not passed, processes deposit and emits DepositSolved

  • If deadline passed, refunds and emits DepositRefunded

  • Always unsets hash after processing*

function _solveDepositVaultAutoPrice(
    IERC20 token,
    uint256 depositMultiplier,
    Request calldata request,
    uint256 priceAge,
    uint256 index
) internal returns (uint256 solverTip);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being deposited

depositMultiplier

uint256

The multiplier (in BPS) applied to the deposit for premium calculation

request

Request

The deposit request struct containing all user parameters

priceAge

uint256

The age of the price data used for conversion

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

solverTip

uint256

The tip amount paid to the solver, or 0 if not processed

_solveDepositVaultFixedPrice

Solves a fixed price deposit request for the vault, transfering tokens or refunding as needed

User gets exactly min units out, but may over‑fund, the difference is paid to the solver as a tip

  • Returns 0 if any of:

  • price age is too high, emits PriceAgeExceeded

  • request hash is not set, emits InvalidRequestHash

  • tokens needed exceed the maximum allowed, emits AmountBoundExceeded

  • deposit cap would be exceeded, emits DepositCapExceeded

  • If deadline not passed, processes deposit and emits DepositSolved

  • If deadline passed, refunds and emits DepositRefunded

  • Always unsets hash after processing*

function _solveDepositVaultFixedPrice(
    IERC20 token,
    uint256 depositMultiplier,
    Request calldata request,
    uint256 priceAge,
    uint256 index
) internal returns (uint256 solverTip);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being deposited

depositMultiplier

uint256

The multiplier (in BPS) applied to the deposit for premium calculation

request

Request

The deposit request struct containing all user parameters

priceAge

uint256

The age of the price data used for conversion

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

solverTip

uint256

The tip amount paid to the solver, or 0 if not processed

_solveRedeemVaultAutoPrice

Solves an async redeem request for the vault, transfering tokens or refunding as needed

  • Returns 0 if any of:

  • price age is too high, emits PriceAgeExceeded

  • request hash is not set, emits InvalidRequestHash

  • token out after premium is less than min required, emits AmountBoundExceeded

  • If deadline not passed, processes redeem and emits RedeemSolved

  • If deadline passed, refunds and emits RedeemRefunded

  • Always unsets hash after processing*

function _solveRedeemVaultAutoPrice(
    IERC20 token,
    uint256 redeemMultiplier,
    Request calldata request,
    uint256 priceAge,
    uint256 index
) internal returns (uint256 solverTip);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being redeemed

redeemMultiplier

uint256

The multiplier (in BPS) applied to the redeem for premium calculation

request

Request

The redeem request struct containing all user parameters

priceAge

uint256

The age of the price data used for conversion

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

solverTip

uint256

The tip amount paid to the solver, or 0 if not processed

_solveRedeemVaultFixedPrice

Solves a fixed price redeem request for the vault, transfering tokens or refunding as needed

User gets exactly min tokens out, but may under‑fund, the difference is paid to the solver as a tip

  • Returns 0 if any of:

  • price age is too high, emits PriceAgeExceeded

  • request hash is not set, emits InvalidRequestHash

  • If deadline not passed, processes redeem and emits RedeemSolved

  • If deadline passed, refunds and emits RedeemRefunded

  • Always unsets hash after processing*

function _solveRedeemVaultFixedPrice(
    IERC20 token,
    uint256 redeemMultiplier,
    Request calldata request,
    uint256 priceAge,
    uint256 index
) internal returns (uint256 solverTip);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being redeemed

redeemMultiplier

uint256

The multiplier (in BPS) applied to the redeem for premium calculation

request

Request

The redeem request struct containing all user parameters

priceAge

uint256

The age of the price data used for conversion

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

solverTip

uint256

The tip amount paid to the solver, or 0 if not processed

_solveDepositDirect

Solves a direct deposit request, transfering tokens and units between users

  • Returns early if any of:

  • request hash is not set, emits InvalidRequestHash

  • If deadline not passed, transfers units and tokens, emits DepositSolved

  • If deadline passed, refunds tokens, emits DepositRefunded

  • Always unsets hash after processing*

function _solveDepositDirect(IERC20 token, Request calldata request) internal;

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being deposited

request

Request

The deposit request struct containing all user parameters

_solveRedeemDirect

Solves a direct redeem request, transfering tokens and units between users

  • Returns early if:

  • request hash is not set, emits InvalidRequestHash

  • If deadline not passed, transfers units and tokens, emits RedeemSolved

  • If deadline passed, refunds units, emits RedeemRefunded

  • Always unsets hash after processing*

function _solveRedeemDirect(IERC20 token, Request calldata request) internal;

Parameters

Name
Type
Description

token

IERC20

The ERC20 token being redeemed

request

Request

The redeem request struct containing all user parameters

_guardPriceAge

Checks if the price age exceeds the maximum allowed and emits an event if so

function _guardPriceAge(uint256 priceAge, uint256 maxPriceAge, uint256 index) internal returns (bool);

Parameters

Name
Type
Description

priceAge

uint256

The difference between when price was measured and submitted onchain

maxPriceAge

uint256

The maximum allowed price age

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

<none>

bool

True if price age is too high, false otherwise

_guardInvalidRequestHash

Checks if the request hash exists and emits an event if not

function _guardInvalidRequestHash(bool hashExists, bytes32 requestHash) internal returns (bool);

Parameters

Name
Type
Description

hashExists

bool

Whether the hash exists

requestHash

bytes32

The request hash

Returns

Name
Type
Description

<none>

bool

True if hash does not exist, false otherwise

_guardInsufficientTokensForTip

Checks if there are enough tokens for the solver tip and emits an event if not

function _guardInsufficientTokensForTip(uint256 tokens, uint256 solverTip, uint256 index) internal returns (bool);

Parameters

Name
Type
Description

tokens

uint256

The number of tokens

solverTip

uint256

The solver tip amount

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

<none>

bool

True if not enough tokens for tip, false otherwise

_guardAmountBound

Checks if the amount is less than the bound and emits an event if so

function _guardAmountBound(uint256 amount, uint256 bound, uint256 index) internal returns (bool);

Parameters

Name
Type
Description

amount

uint256

The actual amount

bound

uint256

The minimum required amount

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

<none>

bool

True if amount is less than bound, false otherwise

_guardDepositCapExceeded

Checks if the deposit cap would be exceeded and emits an event if so

function _guardDepositCapExceeded(uint256 totalUnits, uint256 index) internal returns (bool);

Parameters

Name
Type
Description

totalUnits

uint256

The total units after deposit

index

uint256

The index of the request in the given solving batch

Returns

Name
Type
Description

<none>

bool

True if deposit cap would be exceeded, false otherwise

_requireSyncDepositsEnabled

Reverts if sync deposits are not enabled for the token

function _requireSyncDepositsEnabled(IERC20 token) internal view returns (TokenDetails storage tokenDetails);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token to check

Returns

Name
Type
Description

tokenDetails

TokenDetails

The token details storage reference

_requireDepositCapNotExceeded

Reverts if deposit cap would be exceeded by adding units

function _requireDepositCapNotExceeded(uint256 units) internal view;

Parameters

Name
Type
Description

units

uint256

The number of units to add

_isDepositCapExceeded

Checks if deposit cap would be exceeded by adding units

function _isDepositCapExceeded(uint256 units) internal view returns (bool);

Parameters

Name
Type
Description

units

uint256

The number of units to add

Returns

Name
Type
Description

<none>

bool

True if deposit cap would be exceeded, false otherwise

_tokensToUnitsFloorIfActive

Converts token amount to units, applying multiplier and flooring

function _tokensToUnitsFloorIfActive(IERC20 token, uint256 tokens, uint256 multiplier)
    internal
    view
    returns (uint256);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token

tokens

uint256

The amount of tokens

multiplier

uint256

The multiplier to apply

Returns

Name
Type
Description

<none>

uint256

The resulting units (floored)

_unitsToTokensFloorIfActive

Converts units to token amount, applying multiplier and flooring

function _unitsToTokensFloorIfActive(IERC20 token, uint256 units, uint256 multiplier) internal view returns (uint256);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token

units

uint256

The amount of units

multiplier

uint256

The multiplier to apply

Returns

Name
Type
Description

<none>

uint256

The resulting token amount (floored)

_unitsToTokensCeilIfActive

Converts units to token amount, applying multiplier and ceiling

function _unitsToTokensCeilIfActive(IERC20 token, uint256 units, uint256 multiplier) internal view returns (uint256);

Parameters

Name
Type
Description

token

IERC20

The ERC20 token

units

uint256

The amount of units

multiplier

uint256

The multiplier to apply

Returns

Name
Type
Description

<none>

uint256

The resulting token amount (ceiled)

_getDepositHash

Get the hash of a deposit

Since refundableUntil is block.timestamp + depositRefundTimeout (which is subject to change), it's theoretically possible to have a hash collision, but the probability is negligible and we optimize for the common case

function _getDepositHash(address user, IERC20 token, uint256 tokenAmount, uint256 unitsAmount, uint256 refundableUntil)
    internal
    pure
    returns (bytes32);

Parameters

Name
Type
Description

user

address

The user who made the deposit

token

IERC20

The token that was deposited

tokenAmount

uint256

The amount of tokens deposited

unitsAmount

uint256

The amount of units received

refundableUntil

uint256

The timestamp at which the deposit can be refunded

Returns

Name
Type
Description

<none>

bytes32

The hash of the deposit

_getRequestHashParams

Get the hash of a request from parameters

function _getRequestHashParams(
    IERC20 token,
    address user,
    RequestType requestType,
    uint256 tokens,
    uint256 units,
    uint256 solverTip,
    uint256 deadline,
    uint256 maxPriceAge
) internal pure returns (bytes32);

Parameters

Name
Type
Description

token

IERC20

The token that was deposited or redeemed

user

address

The user who made the request

requestType

RequestType

The type of request

tokens

uint256

The amount of tokens in the request

units

uint256

The amount of units in the request

solverTip

uint256

The tip paid to the solver

deadline

uint256

The deadline of the request

maxPriceAge

uint256

The maximum age of the price data

Returns

Name
Type
Description

<none>

bytes32

The hash of the request

_getRequestHash

Get the hash of a request

function _getRequestHash(IERC20 token, Request calldata request) internal pure returns (bytes32);

Parameters

Name
Type
Description

token

IERC20

The token that was deposited or redeemed

request

Request

The request to get the hash of

Returns

Name
Type
Description

<none>

bytes32

The hash of the request

_isRequestTypeDeposit

Returns true if the request type is a deposit

function _isRequestTypeDeposit(RequestType requestType) internal pure returns (bool);

Parameters

Name
Type
Description

requestType

RequestType

The request type

Returns

Name
Type
Description

<none>

bool

True if deposit, false otherwise

_isRequestTypeAutoPrice

Returns true if the request type is fixed price

function _isRequestTypeAutoPrice(RequestType requestType) internal pure returns (bool);

Parameters

Name
Type
Description

requestType

RequestType

The request type

Returns

Name
Type
Description

<none>

bool

True if fixed price, false otherwise

Last updated