While Sommelier Cellars support multiple positions, they are designed to receive user deposits in a single base asset. This asset is defined by the cellar's holding position (see "Position Ordering and Max Positions" for more information). For instance, although a cellar may hold positions in USDC, WBTC, and ETH, if the Cellar's base asset is USDC, then all deposits must be delivered in USDC. It is up to the strategist to allocate new deposits out of the holding position to match the target allocation of the Cellar's strategy.
For more user flexibility and streamlined UX, integrators and UI developers are encouraged to use the CellarRouter, a smart contract that provides atomic swap-and-deposit functionality for Sommelier Cellars. Using the function
depositAndSwap, users can provide any ERC20 asset, along with a swap path for swapping from that asset into the Cellar's asset. The CellarRouter contract will perform the required swap, deposit to the Cellar, and grant the Cellar shares to the end user, as well as any leftover tokens unused by the swap.
Swapping is also permitted after withdrawing from Cellars, using
withdrawAndSwap. Like the deposit functionality, users can provide a swap path from the Cellar's asset to any desired ERC20, and have their Cellar shares withdrawn and delivered in the asset of their choice.
In addition to traditional approvals,
depositAndSwapWithPermitprovide ERC20Permit functionality for tokens. Tokens that support permits can be deposited or withdrawn from Cellars without pre-approval.
In order to prevent malicious usage of the
shareLockPeriodin Sommelier Cellars, third-party deposits are not supported by default. By default, each address can only credit Cellar shares to themselves when depositing.
In order to provide flexibility for integrator contracts and other specific use cases, the Registry maintains a mapping of
approvedForDepositOnBehalf, where the keys marked
truerepresent addresses that can deposit to Cellars on behalf of other addresses. When this functionality is used, the "approved" contract will provide tokens, and the target address will be credit with Cellar shares.
In order to integrate a
CellarRouterdeployment with Sommelier Cellars, governance must set
approvedForDepositOnBehalffor the given CellarRouter deployment to
truein the Registry. The CellarRouter works by first withdrawing the user's tokens, swapping them, and making the Cellar deposit on behalf of the end user.