Interaction of Vesper Pool and Strategy Contracts
Preliminary draft
Note: This section is preliminary & has not been reviewed. Updates coming soon.

Vesper Framework Levels

The architectural framework of Vesper Pool smart contracts has evolved over time. Each iteration of the framework is denoted by a version number. The table below lists attributes of the framework versions.
Version
Main features
V1
Each pool associated with 1 strategy
V2
Pools can have multiple strategies
V3
Withdrawal function separated from claimable rewards
V4
Gas savings on user interactions
V5
Fee structure changed to universal platform fee
Vesper's modular architecture allows for upgrading of pools from one framework version to another. At any time contracts of different framework levels may coexist in the Vesper ecosystem, but over time all tend to be upgraded to the most current version.

A Schematic Overview of flow control in Vesper V3

The diagram below illustrates how various contracts interact in the V3 framework. The description that follows gives a high-level overview of these processes work. More detailed explanations will be forthcoming soon.
Schematic overview of Vesper Smart Contracts
The Pool block represents an implementation of the VPool contract.
Pool rewards is a module for calculating and storing any VSP rewards associated with the pool.
The Pool Accountant keeps track of the strategies used by the pool.
Strategy represents one or more strategy contract for deploying assets to generate yield.
Let’s assume this vesper pool is vDAI pool meaning user will deposit DAI and receive vDAI in return based on pricePerShare at the time of deposit
The Target Protocol block represents the protocol to which the pool's assets have been sent, such as, for instance, Curve, Compound or Yearn.
Deposit:
  1. 1.
    The user initiates deposit of DAI in vDAI pool.
  2. 2.
    If the PoolRewards contract exists, the pool sends an update to to the PoolRewards contract, notifying it that the user is depositing in the pool.
  3. 3.
    The pool issues shares of vDAI, also known as claim tokens, to the user.
Withdraw:
a. The user initiates withdrawal of DAI. To do this, the user must hold vDAI in their wallet.
b. If the PoolRewards contract exists, then the pool sends an update that the user is withdrawing from the pool, and rewards are calculated.
c. The pool maintains a local reserve of DAI in order to cover withdrawals. If the pool's reserve holds sufficient funds to cover the withdrawal, it burns the user's share of vDAI, and transfers to the user an equivalent amount of DAI. Otherwise, if the local reserve does not have sufficient DAI on hand, the pool initiates withdrawal from one or more strategies.
d. A strategy does not hold any collateral, (DAI in this case), so it withdraws DAI from target protocol.
Rebalance:
i. Only the keeper can call rebalance on strategies.
ii. Strategies gather data to generate profit/loss and payback statements. In case of profit and/or payback, strategy will withdraw funds from target protocol, given it has deposited funds previously.
iii. The Strategy sends profit/loss and payback statements to the pool.
iv. The Pool passes this information to the PoolAccountant, which is responsible for doing all bookkeeping.
v. The PoolAccountant sends the final standing of the strategy back to the pool and the pool decides whether to give more funds to the strategy or take back from the strategy.
vi. If the strategy has received funds from the pool, it deposits these new funds in the target protocol; otherwise it must withdraw from the target protocol to give funds back to the pool.