From 5a1b251cf52f4d75983f79100ddae12d60ff1211 Mon Sep 17 00:00:00 2001 From: Jesus Lanchas Date: Thu, 19 Oct 2023 12:27:52 +0200 Subject: [PATCH] feat: add description for VIP setting VBNBAdmin --- .../vip-189-testnet}/abi/ERC20.json | 0 .../vip-189-testnet}/abi/PSR.json | 0 .../vip-189-testnet}/abi/ProxyAdmin.json | 0 .../vip-189-testnet}/abi/vBNB.json | 0 .../vip-189-testnet}/abi/vBNBAdmin.json | 0 .../vip-189-testnet}/simulation.ts | 4 +- .../vip-189}/abi/ERC20.json | 0 .../vip-152 => vip-189/vip-189}/abi/PSR.json | 0 .../vip-189}/abi/ProxyAdmin.json | 0 .../vip-189}/abi/RiskFund.json | 0 .../vip-152 => vip-189/vip-189}/abi/vBNB.json | 0 .../vip-189}/abi/vBNBAdmin.json | 0 .../vip-152 => vip-189/vip-189}/simulation.ts | 4 +- vips/vip-152.ts | 107 ------------ .../vip-189-testnet.ts} | 6 +- vips/vip-189/vip-189.ts | 153 ++++++++++++++++++ 16 files changed, 160 insertions(+), 114 deletions(-) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/abi/ERC20.json (100%) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/abi/PSR.json (100%) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/abi/ProxyAdmin.json (100%) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/abi/vBNB.json (100%) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/abi/vBNBAdmin.json (100%) rename simulations/{vip-152/vip-152-testnet => vip-189/vip-189-testnet}/simulation.ts (97%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/ERC20.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/PSR.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/ProxyAdmin.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/RiskFund.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/vBNB.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/abi/vBNBAdmin.json (100%) rename simulations/{vip-152/vip-152 => vip-189/vip-189}/simulation.ts (98%) delete mode 100644 vips/vip-152.ts rename vips/{vip-152-testnet.ts => vip-189/vip-189-testnet.ts} (96%) create mode 100644 vips/vip-189/vip-189.ts diff --git a/simulations/vip-152/vip-152-testnet/abi/ERC20.json b/simulations/vip-189/vip-189-testnet/abi/ERC20.json similarity index 100% rename from simulations/vip-152/vip-152-testnet/abi/ERC20.json rename to simulations/vip-189/vip-189-testnet/abi/ERC20.json diff --git a/simulations/vip-152/vip-152-testnet/abi/PSR.json b/simulations/vip-189/vip-189-testnet/abi/PSR.json similarity index 100% rename from simulations/vip-152/vip-152-testnet/abi/PSR.json rename to simulations/vip-189/vip-189-testnet/abi/PSR.json diff --git a/simulations/vip-152/vip-152-testnet/abi/ProxyAdmin.json b/simulations/vip-189/vip-189-testnet/abi/ProxyAdmin.json similarity index 100% rename from simulations/vip-152/vip-152-testnet/abi/ProxyAdmin.json rename to simulations/vip-189/vip-189-testnet/abi/ProxyAdmin.json diff --git a/simulations/vip-152/vip-152-testnet/abi/vBNB.json b/simulations/vip-189/vip-189-testnet/abi/vBNB.json similarity index 100% rename from simulations/vip-152/vip-152-testnet/abi/vBNB.json rename to simulations/vip-189/vip-189-testnet/abi/vBNB.json diff --git a/simulations/vip-152/vip-152-testnet/abi/vBNBAdmin.json b/simulations/vip-189/vip-189-testnet/abi/vBNBAdmin.json similarity index 100% rename from simulations/vip-152/vip-152-testnet/abi/vBNBAdmin.json rename to simulations/vip-189/vip-189-testnet/abi/vBNBAdmin.json diff --git a/simulations/vip-152/vip-152-testnet/simulation.ts b/simulations/vip-189/vip-189-testnet/simulation.ts similarity index 97% rename from simulations/vip-152/vip-152-testnet/simulation.ts rename to simulations/vip-189/vip-189-testnet/simulation.ts index a653c1774..c4defd0d1 100644 --- a/simulations/vip-152/vip-152-testnet/simulation.ts +++ b/simulations/vip-189/vip-189-testnet/simulation.ts @@ -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"; @@ -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]); diff --git a/simulations/vip-152/vip-152/abi/ERC20.json b/simulations/vip-189/vip-189/abi/ERC20.json similarity index 100% rename from simulations/vip-152/vip-152/abi/ERC20.json rename to simulations/vip-189/vip-189/abi/ERC20.json diff --git a/simulations/vip-152/vip-152/abi/PSR.json b/simulations/vip-189/vip-189/abi/PSR.json similarity index 100% rename from simulations/vip-152/vip-152/abi/PSR.json rename to simulations/vip-189/vip-189/abi/PSR.json diff --git a/simulations/vip-152/vip-152/abi/ProxyAdmin.json b/simulations/vip-189/vip-189/abi/ProxyAdmin.json similarity index 100% rename from simulations/vip-152/vip-152/abi/ProxyAdmin.json rename to simulations/vip-189/vip-189/abi/ProxyAdmin.json diff --git a/simulations/vip-152/vip-152/abi/RiskFund.json b/simulations/vip-189/vip-189/abi/RiskFund.json similarity index 100% rename from simulations/vip-152/vip-152/abi/RiskFund.json rename to simulations/vip-189/vip-189/abi/RiskFund.json diff --git a/simulations/vip-152/vip-152/abi/vBNB.json b/simulations/vip-189/vip-189/abi/vBNB.json similarity index 100% rename from simulations/vip-152/vip-152/abi/vBNB.json rename to simulations/vip-189/vip-189/abi/vBNB.json diff --git a/simulations/vip-152/vip-152/abi/vBNBAdmin.json b/simulations/vip-189/vip-189/abi/vBNBAdmin.json similarity index 100% rename from simulations/vip-152/vip-152/abi/vBNBAdmin.json rename to simulations/vip-189/vip-189/abi/vBNBAdmin.json diff --git a/simulations/vip-152/vip-152/simulation.ts b/simulations/vip-189/vip-189/simulation.ts similarity index 98% rename from simulations/vip-152/vip-152/simulation.ts rename to simulations/vip-189/vip-189/simulation.ts index 37b6a9ec3..d88017681 100644 --- a/simulations/vip-152/vip-152/simulation.ts +++ b/simulations/vip-189/vip-189/simulation.ts @@ -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"; @@ -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]); diff --git a/vips/vip-152.ts b/vips/vip-152.ts deleted file mode 100644 index 5b4474b5e..000000000 --- a/vips/vip-152.ts +++ /dev/null @@ -1,107 +0,0 @@ -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 vip152 = () => { - const meta = { - version: "v2", - title: "Change vBNB admin to vBNBAdmin and Setup Protocol Share Reserve", - description: ``, - forDescription: "I agree that Venus Protocol should proceed with setting the vBNB admin and setting up PSR", - againstDescription: - "I do not think that Venus Protocol should proceed with setting the vBNB admin and setting up PSR", - abstainDescription: - "I am indifferent to whether Venus Protocol proceeds with setting the vBNB admin and setting up PSR", - }; - - 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, - ); -}; diff --git a/vips/vip-152-testnet.ts b/vips/vip-189/vip-189-testnet.ts similarity index 96% rename from vips/vip-152-testnet.ts rename to vips/vip-189/vip-189-testnet.ts index c382df906..02c051dc1 100644 --- a/vips/vip-152-testnet.ts +++ b/vips/vip-189/vip-189-testnet.ts @@ -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"; @@ -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", diff --git a/vips/vip-189/vip-189.ts b/vips/vip-189/vip-189.ts new file mode 100644 index 000000000..9fb8da69e --- /dev/null +++ b/vips/vip-189/vip-189.ts @@ -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, + ); +};