Skip to content

Commit 1953b0f

Browse files
authored
Merge pull request #11 from VenusProtocol/docs/factories
[VEN-764][VEN-765][VEN-766][VEN-767] docs: add factories reference
2 parents eddec9a + 65644d0 commit 1953b0f

File tree

4 files changed

+122
-0
lines changed

4 files changed

+122
-0
lines changed

isolated-lending/factories/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Factories
2+
3+
Factories are the contracts that deploy interest rate models and VToken proxies. [PoolRegistry](../pool-registry.md) uses these factories to create the necessary contracts when a new market is added to a pool.
4+
5+
There are two contracts for interest rate models:
6+
* [WhitePaperInterestRateModelFactory](./white-paper-interest-rate-model-factory.md) deploys a linear interest rate model
7+
* [JumpRateModelFactory](./jump-rate-model-factory.md) deploys a piecewise linear interest rate model with a steep increase when the utilization is high
8+
9+
[VTokenProxyFactory](./vtoken-proxy-factory.md) deploys an upgradeable proxy for the market itself. Contrary to the Core Pool, Isolated Pools uses a standard OpenZeppelin proxy for all contracts including VToken. All markets are upgradeable in Venus Isolated Pools.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# JumpRateModelFactory
2+
3+
A factory for Jump Rate Model, an interest rate model with a steep increase after a certain utilization threshold called __kink__ is reached. This rate model uses the following formula for the borrow rate:
4+
5+
* $borrow\_rate(u)=a_1 \cdot u + b$, when $u<kink$
6+
* $borrow\_rate(u)=a_1 \cdot kink + a_2 \cdot (u-kink) + b$, otherwise
7+
8+
The parameters of this interest rate model can be adjusted by the owner.
9+
10+
## deploy
11+
12+
```solidity
13+
function deploy(
14+
uint256 baseRatePerYear,
15+
uint256 multiplierPerYear,
16+
uint256 jumpMultiplierPerYear,
17+
uint256 kink_,
18+
address owner_
19+
) external returns (JumpRateModelV2)
20+
```
21+
22+
Deploys a new Jump Rate Model.
23+
24+
#### Parameters
25+
26+
| Name | Type | Description |
27+
| ---- | ---- | ----------- |
28+
| `baseRatePerYear` | uint256 | $b$, the base interest rate which is the y-intercept when utilization rate is 0 |
29+
| `multiplierPerYear` | uint256 | $a_1$, the multiplier of utilization rate that gives the slope of the interest rate |
30+
| `jumpMultiplierPerYear` | uint256 | $a_2$, the multiplier of utilization rate after hitting a specified utilization point |
31+
| `kink_` | uint256 | $kink$, the utilization point at which the jump multiplier is applied |
32+
| `owner_` | address | the address that can adjust the interest rate model parameters |
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# VTokenProxyFactory
2+
3+
This factory deploys a ERC-1967 compliant transparent proxy and initializes it with the implementation of VToken.
4+
5+
## deploy
6+
7+
```solidity
8+
function deployVTokenProxy(
9+
VTokenArgs memory input
10+
) external returns (VToken)
11+
```
12+
13+
#### Parameters
14+
15+
| Name | Type | Description |
16+
| ---- | ---- | ----------- |
17+
| `input` | VTokenArgs memory | `VTokenArgs` struct with the parameters for the new market |
18+
19+
The parameters are defined as follows:
20+
```
21+
struct VTokenArgs {
22+
address underlying_;
23+
ComptrollerInterface comptroller_;
24+
InterestRateModel interestRateModel_;
25+
uint256 initialExchangeRateMantissa_;
26+
string name_;
27+
string symbol_;
28+
uint8 decimals_;
29+
address payable admin_;
30+
AccessControlManager accessControlManager_;
31+
VTokenInterface.RiskManagementInit riskManagement;
32+
address vTokenProxyAdmin_;
33+
VToken tokenImplementation_;
34+
}
35+
36+
struct RiskManagementInit {
37+
address shortfall;
38+
address payable riskFund;
39+
address payable protocolShareReserve;
40+
}
41+
```
42+
43+
| Name | Type | Description |
44+
| ---- | ---- | ----------- |
45+
| `underlying_` | address | The underlying BEP-20 token to list |
46+
| `comptroller_` | address | The pool Comptroller |
47+
| `interestRateModel_` | address | Interest rate model to use |
48+
| `initialExchangeRateMantissa_` | uint256 | The vToken to underlying exchange rate to start with |
49+
| `name_` | address | vToken name (usually it's "Venus " + underlying name) |
50+
| `symbol_` | address | vToken symbol (usually it's "v" + underlying symbol) |
51+
| `decimals_` | address | vToken decimals (the convention is to use 8 decimals for vTokens) |
52+
| `admin_` | address | vToken admin (should be Governance). Note that this is **not** the upgradeability administrator |
53+
| `accessControlManager_` | address | [AccessControlManager](../governance/access-control-manager.md) contract |
54+
| `riskManagement` | RiskManagementInit | Addreses of the [Shortfall](../shortfall.md), [Risk Fund](../risk-fund.md), and [Protocol Share Reserve](../protocol-share-reserve.md) contracts |
55+
| `vTokenProxyAdmin_` | address | The address of the upgradeability admin |
56+
| `tokenImplementation_` | address | voken implementation contract |
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# WhitePaperInterestRateModelFactory
2+
3+
A factory for WhitePaperInterestRateModel, a simple model where the borrow rate depends linearly on the utilization:
4+
5+
$borrow\_rate(u) = a \cdot u + b$
6+
7+
The parameters of this interest rate model can not be updated after deployment. Pool risk managers need to deploy another interest rate model to change the curve.
8+
9+
## deploy
10+
11+
```solidity
12+
function deploy(
13+
uint256 baseRatePerYear,
14+
uint256 multiplierPerYear
15+
) external returns (WhitePaperInterestRateModel)
16+
```
17+
18+
19+
20+
#### Parameters
21+
22+
| Name | Type | Description |
23+
| ---- | ---- | ----------- |
24+
| `baseRatePerYear` | uint256 | $b$, the base interest rate which is the y-intercept when utilization rate is 0 |
25+
| `multiplierPerYear` | uint256 | $a_1$, the multiplier of utilization rate that gives the slope of the interest rate |

0 commit comments

Comments
 (0)