Overview
Vendor Finance aims to be the most flexible and permissionless platform that will empower anyone to become a lender and set their own terms.
General Architecture
PoolFactory.sol is the main contract and the entry point into the Vendor Finance system. This factory contract allows our users to deploy any type of lending pool we currently support.
Oracle.sol is the aggregator we wrote that accumulates the prices for the assets supported by our protocol. Note that Vendor finance does not require oracles to operate. Currently this oracle contract is integrated with Chainlink feeds.
FeesManager.sol this contract is responsible for keeping tack of the current fee rates of each individual lending pool. This contract exists in order to isolate fee calculation logic from lending pools, so that lenders could chose any fee model and we would not have to adjust implementations for each model.
PositionTracker.sol is a contract that keeps the record of each users borrow and lend positions. While we do utilize graph heavily, we have also noticed a suboptimal performance causing users to get confused of why they would not see their just deployed pools for a minute or sometimes longer. While we will continue to rely on graph for aggregation of all pools across the system, lenders and borrowers should be able to see their positions immediately.
utils/GenericUtils.sol is a library with the most frequently used functions and check that could be used by most lending pool types. Ex: token transfers and collateral price checks.
Pools
As it was mentioned earlier PoolFactory.sol can deploy different types of lending or borrowing pools. All the different types of pools can be found in the pools/
folder in our code repo. All types of pools are grouped in folders and consist of three files. Let's consider the example of LendingPool.sol - the most standard pool type Vendor offers with one lender and many borrowers.
First file you will see is the interface file. It contains and method signatures that are specific to this pool. Do not expect to see much there, as most signatures are already declared in IGenericPool.sol.
The next file is the utils file. This file contains a fair bit of logic that is specific to this type of the pool. This allows us to greatly reduce the bytecode size of the pool contract while sacrificing the cost of transactions unfortunately. We pay respect to old school and do not modify storage in library.
The last and final file in the folder is the main implementation of the pool. It is an implementation contract with an initializer since all deployed pools are proxies. You could read more on that in the Pool Types section.
Strategies
Every single strategy is located in the strategies/
folder of the code repo. All of them are compliant with the IStrategy.sol interface. All strategies are a collection of hooks that are triggered before or after each collateral or lend token transfer. Each strategy also contains methods for returning available balance of the lend and collateral tokens. Read more on strategies here.