Skip to content

Commit bfadd3c

Browse files
kkirkacoreyar
authored andcommitted
docs: add liquidator reference
1 parent 1db3d3a commit bfadd3c

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

core-pool/admins.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Admins and ownership
2+
3+
Most of our contracts have a dedicated admin. The admin of most of the contracts is Governance. The admin can be changed with a two-step procedure that guarantees there's no error during transferring the rights.
4+
5+
The interface is similar but for historical reasons some of the contracts do not revert in case of failure. These contracts return 0 if the transaction was successful and an error code otherwise.
6+
7+
## _setPendingAdmin
8+
9+
```
10+
function _setPendingAdmin(
11+
address newPendingAdmin
12+
) external [returns (uint256 error)];
13+
```
14+
15+
Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer. The function is only callable by admin.
16+
17+
## _acceptAdmin
18+
19+
```solidity
20+
function _acceptAdmin() external [returns (uint256)];
21+
```
22+
23+
Accepts transfer of admin rights. The function is only callable by pendingAdmin.

core-pool/liquidator.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Liquidator
2+
3+
Liquidator contract is the only publicly accessible interface for liquidations in the core pool.
4+
5+
Liquidator contract was introduced in [VIP-64](https://app.venus.io/governance/proposal/64) so that the protocol could capture a part of the liquidation revenue. It has a unified interface for VAI, BNB and BEP-20 token liquidations.
6+
7+
## liquidateBorrow
8+
9+
```
10+
function liquidateBorrow(
11+
address vToken,
12+
address borrower,
13+
uint256 repayAmount,
14+
VToken vTokenCollateral
15+
) external payable;
16+
```
17+
18+
Liquidates a borrow and splits the seized amount between treasury and liquidator. The liquidators should use this interface instead of calling `vToken.liquidateBorrow(...)` directly. Reverts on errors.
19+
20+
Note: For BNB borrows `msg.value` must be equal to repayAmount; for all other borrows msg.value must be zero.
21+
22+
To use this function, the liquidator has to `approve` the underlying asset to Liquidator (unless the underlying asset is BNB).
23+
24+
#### Parameters
25+
26+
| Name | Type | Description |
27+
| ---- | ---- | ----------- |
28+
| `vToken` | address | Borrowed vToken (or VAIUnitroller for VAI) |
29+
| `borrower` | address | The address of the borrower |
30+
| `repayAmount` | uint256 | The amount to repay on behalf of the borrower |
31+
| `vTokenCollateral` | address | The collateral vToken to seize |
32+
33+
## setTreasuryPercent
34+
35+
```
36+
function setTreasuryPercent(
37+
uint256 newTreasuryPercentMantissa
38+
) external onlyAdmin;
39+
```
40+
41+
Sets the new percent of the seized amount that goes to treasury. Should be less than or equal to `comptroller.liquidationIncentiveMantissa() - 1e18`.
42+
43+
Only callable by the admin (Governance).
44+
45+
#### Parameters
46+
47+
| Name | Type | Description |
48+
| ---- | ---- | ----------- |
49+
| `newTreasuryPercentMantissa` | uint256 | New treasury percent (scaled by 10^18). |
50+
51+
## _setPendingAdmin, _acceptAdmin
52+
53+
The admin is updated via the regular [two-step procedure](./admins.md). `_setPendingAdmin` and `_acceptAdmin` do not return any value and revert on errors.

0 commit comments

Comments
 (0)