From 2a2b46749ecdfde42278016e62ab28277af09d65 Mon Sep 17 00:00:00 2001 From: Jesus Lanchas Date: Wed, 18 Oct 2023 18:57:51 +0200 Subject: [PATCH] feat: add VIP to adjust the APR in the XVSVault for Q4 2023 --- .../abi/IAccessControlManager_ABI.json | 126 ++++ simulations/vip-188/abi/xvsVault.json | 556 ++++++++++++++++++ simulations/vip-188/simulations.ts | 64 ++ vips/vip-188.ts | 53 ++ 4 files changed, 799 insertions(+) create mode 100644 simulations/vip-188/abi/IAccessControlManager_ABI.json create mode 100644 simulations/vip-188/abi/xvsVault.json create mode 100644 simulations/vip-188/simulations.ts create mode 100644 vips/vip-188.ts diff --git a/simulations/vip-188/abi/IAccessControlManager_ABI.json b/simulations/vip-188/abi/IAccessControlManager_ABI.json new file mode 100644 index 000000000..687d32137 --- /dev/null +++ b/simulations/vip-188/abi/IAccessControlManager_ABI.json @@ -0,0 +1,126 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], + "name": "getRoleAdmin", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "contractAddress", "type": "address" }, + { "internalType": "string", "name": "functionSig", "type": "string" }, + { "internalType": "address", "name": "accountToPermit", "type": "address" } + ], + "name": "giveCallPermission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "grantRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "hasRole", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "string", "name": "functionSig", "type": "string" } + ], + "name": "isAllowedToCall", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "renounceRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "contractAddress", "type": "address" }, + { "internalType": "string", "name": "functionSig", "type": "string" }, + { "internalType": "address", "name": "accountToRevoke", "type": "address" } + ], + "name": "revokeCallPermission", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" }], + "name": "supportsInterface", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-188/abi/xvsVault.json b/simulations/vip-188/abi/xvsVault.json new file mode 100644 index 000000000..d6ce21c08 --- /dev/null +++ b/simulations/vip-188/abi/xvsVault.json @@ -0,0 +1,556 @@ +[ + { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "oldAdmin", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newAdmin", "type": "address" } + ], + "name": "AdminTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "delegator", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "fromDelegate", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "toDelegate", "type": "address" } + ], + "name": "DelegateChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "delegate", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "previousBalance", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newBalance", "type": "uint256" } + ], + "name": "DelegateVotesChangedV2", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "ExecutedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": true, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "allocPoints", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "rewardPerBlock", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "lockPeriod", "type": "uint256" } + ], + "name": "PoolAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "oldAllocPoints", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newAllocPoints", "type": "uint256" } + ], + "name": "PoolUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "user", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "ReqestedWithdrawal", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "oldReward", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newReward", "type": "uint256" } + ], + "name": "RewardAmountUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldXvs", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "oldStore", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newXvs", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newStore", "type": "address" } + ], + "name": "StoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "rewardToken", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "pid", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "oldPeriod", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newPeriod", "type": "uint256" } + ], + "name": "WithdrawalLockingPeriodUpdated", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DELEGATION_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "contract XVSVaultProxy", "name": "xvsVaultProxy", "type": "address" }], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_allocPoint", "type": "uint256" }, + { "internalType": "contract IBEP20", "name": "_token", "type": "address" }, + { "internalType": "uint256", "name": "_rewardPerBlock", "type": "uint256" }, + { "internalType": "uint256", "name": "_lockPeriod", "type": "uint256" } + ], + "name": "add", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "admin", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "burnAdmin", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint32", "name": "", "type": "uint32" } + ], + "name": "checkpoints", + "outputs": [ + { "internalType": "uint32", "name": "fromBlock", "type": "uint32" }, + { "internalType": "uint96", "name": "votes", "type": "uint96" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "delegatee", "type": "address" }], + "name": "delegate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "delegatee", "type": "address" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "delegateBySig", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "delegates", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "deposit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "executeWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getAdmin", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "getCurrentVotes", + "outputs": [{ "internalType": "uint96", "name": "", "type": "uint96" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "getEligibleWithdrawalAmount", + "outputs": [{ "internalType": "uint256", "name": "withdrawalAmount", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "account", "type": "address" }, + { "internalType": "uint256", "name": "blockNumber", "type": "uint256" } + ], + "name": "getPriorVotes", + "outputs": [{ "internalType": "uint96", "name": "", "type": "uint96" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "getRequestedAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "getUserInfo", + "outputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "rewardDebt", "type": "uint256" }, + { "internalType": "uint256", "name": "pendingWithdrawals", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "getWithdrawalRequests", + "outputs": [ + { + "components": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" }, + { "internalType": "uint256", "name": "lockedUntil", "type": "uint256" } + ], + "internalType": "struct XVSVaultStorageV1.WithdrawalRequest[]", + "name": "", + "type": "tuple[]" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "implementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "_rewardToken", "type": "address" }], + "name": "massUpdatePools", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "numCheckpoints", + "outputs": [{ "internalType": "uint32", "name": "", "type": "uint32" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingAdmin", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "address", "name": "_user", "type": "address" } + ], + "name": "pendingReward", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "pendingXVSVaultImplementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "name": "poolInfos", + "outputs": [ + { "internalType": "contract IBEP20", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "allocPoint", "type": "uint256" }, + { "internalType": "uint256", "name": "lastRewardBlock", "type": "uint256" }, + { "internalType": "uint256", "name": "accRewardPerShare", "type": "uint256" }, + { "internalType": "uint256", "name": "lockPeriod", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "rewardToken", "type": "address" }], + "name": "poolLength", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_amount", "type": "uint256" } + ], + "name": "requestWithdrawal", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "rewardTokenAmountsPerBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_allocPoint", "type": "uint256" } + ], + "name": "set", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_rewardAmount", "type": "uint256" } + ], + "name": "setRewardAmountPerBlock", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" }, + { "internalType": "uint256", "name": "_newPeriod", "type": "uint256" } + ], + "name": "setWithdrawalLockingPeriod", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_xvs", "type": "address" }, + { "internalType": "address", "name": "_xvsStore", "type": "address" } + ], + "name": "setXvsStore", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "totalAllocPoints", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_rewardToken", "type": "address" }, + { "internalType": "uint256", "name": "_pid", "type": "uint256" } + ], + "name": "updatePool", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "xvsStore", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-188/simulations.ts b/simulations/vip-188/simulations.ts new file mode 100644 index 000000000..c4c48675b --- /dev/null +++ b/simulations/vip-188/simulations.ts @@ -0,0 +1,64 @@ +import { expect } from "chai"; +import { ethers } from "hardhat"; + +import { expectEvents, initMainnetUser } from "../../src/utils"; +import { forking, testVip } from "../../src/vip-framework"; +import { vip188 } from "../../vips/vip-188"; +import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; +import XVS_VAULT_ABI from "./abi/xvsVault.json"; + +const XVS = "0xcF6BB5389c92Bdda8a3747Ddb454cB7a64626C63"; +const XVS_VAULT_PROXY = "0x051100480289e704d20e9DB4804837068f3f9204"; +const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; +const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; +const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; + +forking(32715679, () => { + const provider = ethers.provider; + let xvsVault: ethers.Contract; + let xvsVaultSigner: Signer; + let accessControlManager: ethers.Contract; + + before(async () => { + xvsVault = new ethers.Contract(XVS_VAULT_PROXY, XVS_VAULT_ABI, provider); + xvsVaultSigner = await initMainnetUser(XVS_VAULT_PROXY, ethers.utils.parseEther("1")); + accessControlManager = new ethers.Contract(ACM, ACM_ABI, provider); + }); + + describe("Pre-VIP behavior", async () => { + it("has reward amount set to 1780 XVS/day", async () => { + const rewardAmount = await xvsVault.rewardTokenAmountsPerBlock(XVS); + expect(rewardAmount).to.equal("61805555555555555"); // 1780 XVS per day + }); + }); + + testVip("VIP-188", vip188(), { + callbackAfterExecution: async txResponse => { + await expectEvents(txResponse, [XVS_VAULT_ABI], ["RewardAmountUpdated"], [1]); + await expectEvents(txResponse, [ACM_ABI], ["RoleGranted"], [2]); + }, + }); + + describe("Post-VIP behavior", async () => { + it("should have updated the reward amount to 1440 XVS/day", async () => { + const rewardAmount = await xvsVault.rewardTokenAmountsPerBlock(XVS); + const blocksPerDay = ethers.BigNumber.from("28800"); + const expectedXvsPerDay = ethers.utils.parseUnits("1440", 18); + const expectedXvsPerBlock = expectedXvsPerDay.div(blocksPerDay); + expect(rewardAmount).to.equal(expectedXvsPerBlock); // 1440 XVS per day + }); + + it("XVS VAULT Permissions", async () => { + expect( + await accessControlManager + .connect(xvsVaultSigner) + .isAllowedToCall(CRITICAL_TIMELOCK, "setRewardAmountPerBlock(address,uint256)"), + ).equals(true); + expect( + await accessControlManager + .connect(xvsVaultSigner) + .isAllowedToCall(FAST_TRACK_TIMELOCK, "setRewardAmountPerBlock(address,uint256)"), + ).equals(true); + }); + }); +}); diff --git a/vips/vip-188.ts b/vips/vip-188.ts new file mode 100644 index 000000000..dc2f28017 --- /dev/null +++ b/vips/vip-188.ts @@ -0,0 +1,53 @@ +import { ProposalType } from "../src/types"; +import { makeProposal } from "../src/utils"; + +const XVS_VAULT_PROXY = "0x051100480289e704d20e9DB4804837068f3f9204"; +const XVS = "0xcF6BB5389c92Bdda8a3747Ddb454cB7a64626C63"; +const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; + +const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; +const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; + +const grant = (target: string, signature: string, caller: string) => ({ + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [target, signature, caller], +}); + +export const vip188 = () => { + const meta = { + version: "v2", + title: "VIP-188 Update XVS Distributions APR based on Q3 Buyback results", + description: `#### Summary + +This VIP will perform the following actions: + +- Set the new XVS Vault distribution speed to 1,440 XVS/day +- Authorize Fast-track and Critical timelock contracts to adjust the XVS Vault distribution speed in the future + +#### Description + +Our latest [buyback](https://app.venus.io/#/governance/proposal/183) earlier this month for the amount of approximately USD $191,000 resulted in the buyback of 39,844.98 XVS at an average buy price of $4.79. These XVS were [already sent](https://bscscan.com/tx/0xccc066ce68a82e7df1ed66002d376f0dc3772f1074cdcf707fcabe3f64b0a7a9) to the XVS Vault rewards distribution wallet. + +Due to the slight delay in performing the buyback off-chain, we were not able to adjust the XVS Vault distribution APR until this VIP and more XVS have been distributed in the earlier weeks, thus the need to further lower the APR for the remainder of this quarter to compensate for the extra XVS that were already distributed. + +The new distribution speed will be 1,440 XVS per day for a period of 81 Days. resulting in an APR of 7.91%.`, + forDescription: "I agree, Venus Protocol should immediately proceed with these adjustments.", + againstDescription: "I do not think that Venus Protocol should proceed with these adjustments", + abstainDescription: "I am indifferent to whether Venus Protocol proceeds with these adjustments or not", + }; + + return makeProposal( + [ + { + target: XVS_VAULT_PROXY, + signature: "setRewardAmountPerBlock(address,uint256)", + params: [XVS, "50000000000000000"], + }, + grant(XVS_VAULT_PROXY, "setRewardAmountPerBlock(address,uint256)", FAST_TRACK_TIMELOCK), + grant(XVS_VAULT_PROXY, "setRewardAmountPerBlock(address,uint256)", CRITICAL_TIMELOCK), + ], + meta, + ProposalType.REGULAR, + ); +};