Skip to content

Commit 3694300

Browse files
authored
Merge pull request #6 from VenusProtocol/pool-registry-documentation
[VEN-758] feat: PoolRegistry documentation
2 parents b4b7aca + c8eb29c commit 3694300

File tree

1 file changed

+399
-0
lines changed

1 file changed

+399
-0
lines changed

isolated-lending/pool-registry.md

Lines changed: 399 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,399 @@
1+
# Pool Registry
2+
3+
## Introduction
4+
The pool registry maintains the isolated lending pools directory and performs actions like creating and registering new lending pools, adding new markets to existing pools, setting and updating the pool metadata, and providing getter methods to retrieve pool information.
5+
6+
![Isolated Pools Diagram](../.gitbook/assets/isolated-pools.png)
7+
8+
## Details
9+
10+
Isolated lending has three main components: PoolRegistry, pools, and markets. The PoolRegistry is responsible for managing pools. It can create new pools, update pool metadata and manage markets within pools. PoolRegistry contains getter methods to get the details of any existing pool like `getVTokenForAsset` and `getPoolsSupportedByAsset`. It also contains methods for updating pool metadata (`updatePoolMetadata`) and setting pool name (`setPoolName`). Users can bookmark pools using the `bookmarkPool` method and get a list of the all bookmarked pools through the `getBookmarks` method.
11+
12+
Pool metadata includes risk rating, category, logo url, and description. It is set by calling `updatePoolMetadata` and retrieved through `getVenusPoolMetadata`. Risk rating is determined off chain through risk analysis by Venus with the intention of helping users navigate pools based on their risk tolerance.
13+
14+
The directory of pools is managed through two mappings: `_poolByComptroller` which is a hashmap with the comptroller address as the key and `VenusPool` as the value and `_poolsByID` which is an array of comptroller addresses. Individual pools can be accessed by calling `getPoolByComptroller` with the pool's comptroller address. `_poolsByID` is used to iterate through all of the pools.
15+
16+
PoolRegistry also contains a map of asset addresses called `_supportedPools` that maps to an array of assets suppored by each pool. This array of pools by asset is retrieved by calling `getPoolsSupportedByAsset`.
17+
18+
### Pools
19+
20+
PoolRegistry registers new isolated pools in the directory with the `createRegistryPool` method. It creates a proxy for the comptroller, sets the `msg.sender` as the `admin` of the comptroller and configuration values for the `closeFactor`, `liquidationIncentive`, `minLiquidatableCollateral`, and `priceOracle`, before adding the pool to the directory. More details on Pools can be found under the [Pool](../isolated-lending/pool.md) page.
21+
22+
### Markets
23+
Isolated pools are composed of independent markets with specific assets and custom risk management configurations according to their markets.
24+
25+
To add a new market to a lending pool, the PoolRegistry first deploys the JumpRate or WhitePaperInterestRate factory as an interest rate model to calculate the interest for the borrowers and lenders according to the available liquidity of the protocol. You can read more about interest rate models under [Protocol Math](../guides/protocol-math.md). The upgradable vToken is then deployed to handle all the transactions within the market and finally the market is listed in the pool through `_supportMarket` method.
26+
27+
Markets are covered in more detail under [VTokens](core-pool/vtokens.md)
28+
29+
30+
# Solidity API
31+
32+
## Pool Registry
33+
34+
### initialize
35+
36+
37+
```solidity
38+
function initialize(
39+
VBep20ImmutableProxyFactory _vTokenFactory,
40+
JumpRateModelFactory _jumpRateFactory,
41+
WhitePaperInterestRateModelFactory _whitePaperFactory,
42+
Shortfall _shortfall,
43+
address payable riskFund_,
44+
address payable protocolShareReserve_
45+
) public initializer
46+
```
47+
48+
49+
50+
Initializes the deployer to owner. Set all the required contracts to pool registry.
51+
52+
53+
54+
#### Parameters
55+
56+
57+
58+
| Name | Type | Description |
59+
| ---- | ---- | ----------- |
60+
| _vTokenFactory | VBep20ImmutableProxyFactory | VBep20 proxy factory to deploy vTokens. |
61+
| _jumpRateFactory | JumpRateModelFactory | Jump rate model factory as Interest rate model. |
62+
| _whitePaperFactory | WhitePaperInterestRateModelFactory | white paper rate model factory as Interest rate model. |
63+
| _shortfall | Shortfall | shortfall contract. |
64+
| riskFund_ | address | riskFund contract address. |
65+
| protocolShareReserve_ | address | protocolShareReserve contract address. |
66+
67+
68+
#### Return Values
69+
70+
71+
72+
| Name | Type | Description |
73+
| ---- | ---- | ----------- |
74+
| [0] | bool | false if the user account cannot call the particular contract function |
75+
76+
77+
### createRegistryPool
78+
79+
80+
81+
```solidity
82+
function createRegistryPool(
83+
string memory name,
84+
address implementation,
85+
uint256 closeFactor,
86+
uint256 liquidationIncentive,
87+
address priceOracle
88+
) external virtual onlyOwner returns (uint256, address)
89+
```
90+
91+
92+
93+
Deploys a new venus pool and adds to the directory, by taking all the required inputs
94+
95+
{% hint style="info" %}
96+
Can only be called by the _owner_.
97+
{% endhint %}
98+
99+
100+
#### Parameters
101+
102+
103+
104+
| Name | Type | Description |
105+
| ---- | ---- | ----------- |
106+
| name | string | The name of the pool. |
107+
| implementation | address | The Comptroller implementation address. |
108+
| closeFactor | uint256 | The pool's close factor (scaled by 1e18). |
109+
| liquidationIncentive | uint256 | The pool's liquidation incentive (scaled by 1e18). |
110+
| priceOracle | address | The pool's PriceOracle address. |
111+
112+
113+
#### Return Values
114+
115+
116+
117+
| Name | Type | Description |
118+
| ---- | ---- | ----------- |
119+
| [0] | uint256 | The index of the registered Venus pool. |
120+
| [1] | address | The comptroller's proxy address. |
121+
122+
123+
### setPoolName
124+
125+
126+
127+
```solidity
128+
function setPoolName(uint256 poolId, string calldata name)
129+
external
130+
```
131+
132+
133+
Modify existing Venus pool name.
134+
135+
{% hint style="info" %}
136+
Can be called by the _owner_ or _comptroller admin_.
137+
{% endhint %}
138+
139+
#### Parameters
140+
141+
142+
143+
| Name | Type | Description |
144+
| ---- | ---- | ----------- |
145+
| poolId | uint256 | The Id of the registered pool. |
146+
| name | string | The new name of the pool to be updated. |
147+
148+
149+
150+
### bookmarkPool
151+
152+
153+
154+
```solidity
155+
function bookmarkPool(address comptroller)
156+
external
157+
```
158+
159+
160+
Bookmarks a Venus pool Comptroller(proxy) contract addresses.
161+
162+
163+
164+
#### Parameters
165+
166+
167+
168+
| Name | Type | Description |
169+
| ---- | ---- | ----------- |
170+
| comptroller | address | Address of the comptroller to be bookmarked |
171+
172+
173+
174+
### getAllPools
175+
176+
177+
```solidity
178+
function getAllPools() external view returns (VenusPool[] memory)
179+
```
180+
181+
182+
183+
To get the details of all the registered pools in the directory.
184+
185+
186+
#### Return Values
187+
188+
189+
190+
| Name | Type | Description |
191+
| ---- | ---- | ----------- |
192+
| [0] | array of VenusPool | Arrays of all Venus pools' data. |
193+
194+
195+
196+
### getVenusPoolMetadata
197+
198+
199+
200+
201+
```solidity
202+
function getVenusPoolMetadata(uint256 poolId)
203+
external
204+
view
205+
returns (VenusPoolMetaData memory)
206+
```
207+
208+
209+
210+
Get the registered pool Meta data by pool ID.
211+
212+
213+
#### Parameters
214+
215+
216+
217+
| Name | Type | Description |
218+
| ---- | ---- | ----------- |
219+
| comptroller | address | comptroller address of the pool. |
220+
221+
222+
#### Return Values
223+
224+
225+
226+
| Name | Type | Description |
227+
| ---- | ---- | ----------- |
228+
| [0] | VenusPoolMetaData | Meta data of the Venus pool |
229+
230+
231+
232+
### getBookmarks
233+
234+
235+
```solidity
236+
function getBookmarks(address account)
237+
external
238+
view
239+
returns (address[] memory)
240+
```
241+
242+
243+
244+
Get the book marked pools by the account.
245+
246+
247+
#### Parameters
248+
249+
250+
251+
| Name | Type | Description |
252+
| ---- | ---- | ----------- |
253+
| account | address | Account address. |
254+
255+
256+
#### Return Values
257+
258+
259+
260+
| Name | Type | Description |
261+
| ---- | ---- | ----------- |
262+
| [0] | array | Array of the pools' addresses. |
263+
264+
265+
266+
267+
### addMarket
268+
269+
270+
271+
```solidity
272+
function addMarket(
273+
AddMarketInput memory input
274+
) external
275+
```
276+
277+
278+
Add a market to an existing venus pool.
279+
280+
{% hint style="info" %}
281+
Can only be called by the _owner_.
282+
{% endhint %}
283+
284+
285+
#### Parameters
286+
287+
288+
289+
| Name | Type | Description |
290+
| ---- | ---- | ----------- |
291+
| input | AddMarketInput | Details of the market to be added. |
292+
293+
294+
#### Return Values
295+
296+
297+
298+
| Name | Type | Description |
299+
| ---- | ---- | ----------- |
300+
| [0] | VenusPoolMetaData | Meta data of the Venus pool |
301+
302+
303+
304+
### getVTokenForAsset
305+
306+
307+
308+
```solidity
309+
function getVTokenForAsset(uint256 poolId, address asset)
310+
external
311+
view
312+
returns (address)
313+
```
314+
315+
316+
Add a market to an existing venus pool.
317+
318+
319+
#### Parameters
320+
321+
322+
323+
| Name | Type | Description |
324+
| ---- | ---- | ----------- |
325+
| poolId | uint256 | Pool ID of the existing pool. |
326+
| asset | address | Address of the underlying asset. |
327+
328+
329+
#### Return Values
330+
331+
332+
333+
| Name | Type | Description |
334+
| ---- | ---- | ----------- |
335+
| [0] | address | Address of the vToken. |
336+
337+
338+
339+
### getPoolsSupportedByAsset
340+
341+
342+
343+
```solidity
344+
function getPoolsSupportedByAsset(address asset)
345+
external
346+
view
347+
returns (uint256[] memory)
348+
```
349+
350+
351+
Get pools which supports the given asset as input.
352+
353+
354+
#### Parameters
355+
356+
357+
358+
| Name | Type | Description |
359+
| ---- | ---- | ----------- |
360+
| asset | address | Address of the underlying asset. |
361+
362+
363+
#### Return Values
364+
365+
366+
367+
| Name | Type | Description |
368+
| ---- | ---- | ----------- |
369+
| [0] | uint256[] | Array of the pools' addresses. |
370+
371+
372+
373+
### updatePoolMetadata
374+
375+
376+
377+
```solidity
378+
function updatePoolMetadata(uint256 poolId, VenusPoolMetaData memory _metadata)
379+
external
380+
onlyOwner
381+
```
382+
383+
384+
Update metadata of an existing pool
385+
386+
{% hint style="info" %}
387+
Can only be called by the _owner_.
388+
{% endhint %}
389+
390+
391+
#### Parameters
392+
393+
394+
395+
| Name | Type | Description |
396+
| ---- | ---- | ----------- |
397+
| poolId | uint256 | Pool ID of the existing pool. |
398+
| _metadata | VenusPoolMetaData | Meta data to be updated. |
399+

0 commit comments

Comments
 (0)