Skip to content

Commit

Permalink
feat: add description for VIP setting VBNBAdmin
Browse files Browse the repository at this point in the history
  • Loading branch information
chechu committed Oct 19, 2023
1 parent ffc3694 commit 5a1b251
Show file tree
Hide file tree
Showing 16 changed files with 160 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ethers } from "hardhat";

import { expectEvents } from "../../../src/utils";
import { forking, testVip } from "../../../src/vip-framework";
import { vip152Testnet } from "../../../vips/vip-152-testnet";
import { vip189Testnet } from "../../../vips/vip-189/vip-189-testnet";
import ERC20_ABI from "./abi/ERC20.json";
import PSR_ABI from "./abi/PSR.json";
import PROXY_ADMIN_ABI from "./abi/ProxyAdmin.json";
Expand Down Expand Up @@ -46,7 +46,7 @@ forking(34112000, () => {
});
});

testVip("VIP-152", vip152Testnet(), {
testVip("VIP-189", vip189Testnet(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [PSR_ABI], ["DistributionConfigAdded"], [4]);
await expectEvents(txResponse, [PSR_ABI], ["PoolRegistryUpdated"], [1]);
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ethers } from "hardhat";

import { expectEvents } from "../../../src/utils";
import { forking, testVip } from "../../../src/vip-framework";
import { vip152 } from "../../../vips/vip-152";
import { vip189 } from "../../../vips/vip-189/vip-189";
import ERC20_ABI from "./abi/ERC20.json";
import PSR_ABI from "./abi/PSR.json";
import PROXY_ADMIN_ABI from "./abi/ProxyAdmin.json";
Expand Down Expand Up @@ -73,7 +73,7 @@ forking(32659660, () => {
});
});

testVip("VIP-152", vip152(), {
testVip("VIP-189", vip189(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [PSR_ABI], ["DistributionConfigAdded"], [4]);
await expectEvents(txResponse, [PSR_ABI], ["PoolRegistryUpdated"], [1]);
Expand Down
107 changes: 0 additions & 107 deletions vips/vip-152.ts

This file was deleted.

6 changes: 3 additions & 3 deletions vips/vip-152-testnet.ts → vips/vip-189/vip-189-testnet.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ProposalType } from "../src/types";
import { makeProposal } from "../src/utils";
import { ProposalType } from "../../src/types";
import { makeProposal } from "../../src/utils";

const RISK_FUND = "0x487CeF72dacABD7E12e633bb3B63815a386f7012";
const NEW_RISK_FUND_IMPLEMENTATION = "0x1E7DEC93C77740c2bB46daf87ef42056E388dA14";
Expand All @@ -14,7 +14,7 @@ const TREASURY = "0x8b293600c50d6fbdc6ed4251cc75ece29880276f";
const VBNBAdmin = "0x04109575c1dbB4ac2e59e60c783800ea10441BBe";
const vBNB_ADDRESS = "0x2E7222e51c0f6e98610A1543Aa3836E092CDe62c";

export const vip152Testnet = () => {
export const vip189Testnet = () => {
const meta = {
version: "v2",
title: "Change vBNB admin to vBNBAdmin and Setup Protocol Share Reserve",
Expand Down
153 changes: 153 additions & 0 deletions vips/vip-189/vip-189.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { ProposalType } from "../../src/types";
import { makeProposal } from "../../src/utils";

const vBNB_ADDRESS = "0xA07c5b74C9B40447a954e1466938b865b6BBea36";
const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396";
const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555";
const VBNBAdmin_ADDRESS = "0x9A7890534d9d91d473F28cB97962d176e2B65f1d";
const PSR = "0xCa01D5A9A248a830E9D93231e791B1afFed7c446";
const RISK_FUND = "0xdF31a28D68A2AB381D42b380649Ead7ae2A76E42";
const TREASURY = "0xf322942f644a996a617bd29c16bd7d231d9f35e9";
const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02";
const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d";
const POOL_REGISTRY = "0x9F7b01A536aFA00EF10310A162877fd792cD0666";
const NEW_RISK_FUND_IMPLEMENTATION = "0x0E8Ef0EC1e0C109c5B5249CcefB703A414835eaC";
const PROXY_ADMIN = "0x6beb6D2695B67FEb73ad4f172E8E2975497187e4";

export const vip189 = () => {
const meta = {
version: "v2",
title: "VIP-189 Automatic income allocation: deployment stage 1",
description: `#### Summary
If passed, this VIP will change the admin of the [VBNB market in the Core pool](https://bscscan.com/address/0xA07c5b74C9B40447a954e1466938b865b6BBea36), from the [Normal Timelock](https://bscscan.com/address/0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396) contract to the new contract [VBNBAdmin](https://bscscan.com/address/0x9A7890534d9d91d473F28cB97962d176e2B65f1d). Moreover, it will upgrade the implementation of the [RiskFund](https://bscscan.com/address/0xdF31a28D68A2AB381D42b380649Ead7ae2A76E42) contract, to support funds from the Core pool.
#### Description
This VIP is part of the proposal [Automatic Income Allocation & Token Converter](https://community.venus.io/t/automatic-income-allocation-token-converter/3702), published in the Venus community forum. At this time, it only affects the reserves generated by the VBNB market in the Core pool as the BNB contract is not upgradable and need to be dealt with separately.
The new VBNBAdmin will be authorized to reduce the reserves of the VBNB market, and send them to the new [ProtocolShareReserve](https://bscscan.com/address/0xCa01D5A9A248a830E9D93231e791B1afFed7c446) contract, where distribution rules are configured following the [protocol tokenomics](https://docs-v4.venus.io/governance/tokenomics):
- 40% to the RiskFund contract
- 40% to the [Venus Treasury](https://bscscan.com/address/0xf322942f644a996a617bd29c16bd7d231d9f35e9) contract
- 10% to the Venus Prime Program. This 10% will be sent temporarily to the Venus Treasury, until the Venus Prime contract is ready.
- 10% for the XVS Vault rewards. This 10% will be sent temporarily to the Venus Treasury, until the [Token Converter contracts](https://community.venus.io/t/automatic-income-allocation-token-converter/3702) are ready.
With this change, BNB reserve transfers will be performed in a permissionless fashion.
Moreover, VBNBAdmin wraps the BNB reserves into [WBNB](https://bscscan.com/address/0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c), so the downstream contracts do not have to deal with native tokens anymore, simplifying the logic.
There will be a second stage for the Automatic Income Allocation, proposed in the following days, where the markets of the Core pool and the markets of the Isolated pools will start using this new ProtocolShareReserve contract.
The owner of the VBNBAdmin contract is the Normal Timelock. The owner of the new ProtocolShareReserve contract is also the Normal Timelock.
**Security and additional considerations**
We applied the following security procedures for this upgrade:
- **VBNB configuration post upgrade**: in a simulation environment, validating the configuration of the VBNB contract is the expected one after the VIP
- **Reduce reserves from the VBNB contract**: in a simulation environment, validating the BNB reserves are distributed as expected to the different destinations: RiskFund and Venus Treasury
- **Deployment on testnet**: the same VBNBAdmin and ProtocolShareReserve contracts were deployed and configured to testnet, and used in the Venus Protocol testnet deployment
- **Audit: Quantstamp, Certik, Peckshield and Fairyproof have audited the deployed code**
**Audit reports**
- [Quantstamp audit report (2023/09/13)](https://github.com/VenusProtocol/venus-protocol/blob/9ef8901dfef84a11338751881fd10a2d36c576ad/audits/058_automatic_income_allocation_quantstamp_20230913.pdf)
- [Certik audit audit report (2023/09/12)](https://github.com/VenusProtocol/venus-protocol/blob/90f913fd345c24c60efa613ab5ab7e633b7aa07a/audits/059_automatic_income_allocation_certik_20230912.pdf)
- [Peckshield audit report (2023/08/12)](https://github.com/VenusProtocol/venus-protocol/blob/90f913fd345c24c60efa613ab5ab7e633b7aa07a/audits/054_automatic_income_allocation_peckshield_20230812.pdf)
- [Fairyproof audit report (2023/08/03)](https://github.com/VenusProtocol/venus-protocol/blob/90f913fd345c24c60efa613ab5ab7e633b7aa07a/audits/050_automatic_income_allocation_fairyproof_20230803.pdf)
**Deployed contracts on main net**
- [VBNBAdmin](https://bscscan.com/address/0x9A7890534d9d91d473F28cB97962d176e2B65f1d)
- New [ProtocolShareReserve](https://bscscan.com/address/0xCa01D5A9A248a830E9D93231e791B1afFed7c446)
**References**
- [Pull request with the VBNBAdmin contract](https://github.com/VenusProtocol/venus-protocol/pull/289)
- [Simulation post upgrade](https://github.com/VenusProtocol/vips/pull/53)
- [Documentation](https://docs-v4.venus.io/technical-reference/reference-technical-articles/automatic-income-allocation)`,
forDescription: "Execute this proposal",
againstDescription: "Do not execute this proposal",
abstainDescription: "Indifferent to execution",
};

return makeProposal(
[
{
target: PROXY_ADMIN,
signature: "upgrade(address,address)",
params: [RISK_FUND, NEW_RISK_FUND_IMPLEMENTATION],
},
{
target: VBNBAdmin_ADDRESS,
signature: "acceptOwnership()",
params: [],
},
{
target: vBNB_ADDRESS,
signature: "_setPendingAdmin(address)",
params: [VBNBAdmin_ADDRESS],
},
{
target: VBNBAdmin_ADDRESS,
signature: "_acceptAdmin()",
params: [],
},
{
target: PSR,
signature: "acceptOwnership()",
params: [],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "addOrUpdateDistributionConfigs(DistributionConfig[])", NORMAL_TIMELOCK],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "addOrUpdateDistributionConfigs(DistributionConfig[])", FAST_TRACK_TIMELOCK],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "addOrUpdateDistributionConfigs(DistributionConfig[])", CRITICAL_TIMELOCK],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "removeDistributionConfig(Schema,address)", CRITICAL_TIMELOCK],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "removeDistributionConfig(Schema,address)", FAST_TRACK_TIMELOCK],
},
{
target: ACM,
signature: "giveCallPermission(address,string,address)",
params: [PSR, "removeDistributionConfig(Schema,address)", NORMAL_TIMELOCK],
},
{
target: PSR,
signature: "addOrUpdateDistributionConfigs((uint8,uint8,address)[])",
params: [
[
[0, 40, RISK_FUND],
[0, 60, TREASURY],
[1, 50, RISK_FUND],
[1, 50, TREASURY],
],
],
},
{
target: PSR,
signature: "setPoolRegistry(address)",
params: [POOL_REGISTRY],
},
],
meta,
ProposalType.REGULAR,
);
};

0 comments on commit 5a1b251

Please sign in to comment.