Skip to content

Commit

Permalink
fix: added ethereum vip
Browse files Browse the repository at this point in the history
  • Loading branch information
web3rover committed Aug 8, 2024
1 parent 35f585e commit 3390ebd
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 25 deletions.
5 changes: 0 additions & 5 deletions multisig/proposals/arbitrumone/vip-010/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ const vip010 = () => {
signature: "_setPendingAdmin(address)",
params: [arbitrumone.NORMAL_TIMELOCK],
},
{
target: arbitrumone.XVS_VAULT_PROXY,
signature: "_setPendingAdmin(address)",
params: [arbitrumone.NORMAL_TIMELOCK],
},

// Revoke permissions
{
Expand Down
40 changes: 40 additions & 0 deletions multisig/proposals/ethereum/vip-053/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { makeProposal } from "src/utils";

const { ethereum } = NETWORK_ADDRESSES;

export const ETHEREUM_ACM = "0x230058da2D23eb8836EC5DB7037ef7250c56E25E";

const vip053 = () => {
return makeProposal([
{
target: ethereum.XVS_VAULT_PROXY,
signature: "_setPendingAdmin(address)",
params: [ethereum.NORMAL_TIMELOCK],
},

// Revoke permissions
{
target: ETHEREUM_ACM,
signature: "revokeCallPermission(address,string,address)",
params: [ethereum.XVS_VAULT_PROXY, "add(address,uint256,address,uint256,uint256)", ethereum.GUARDIAN],
},
{
target: ETHEREUM_ACM,
signature: "revokeCallPermission(address,string,address)",
params: [ethereum.XVS_VAULT_PROXY, "set(address,uint256,uint256)", ethereum.GUARDIAN],
},
{
target: ETHEREUM_ACM,
signature: "revokeCallPermission(address,string,address)",
params: [ethereum.XVS_VAULT_PROXY, "setRewardAmountPerBlockOrSecond(address,uint256)", ethereum.GUARDIAN],
},
{
target: ETHEREUM_ACM,
signature: "revokeCallPermission(address,string,address)",
params: [ethereum.XVS_VAULT_PROXY, "setWithdrawalLockingPeriod(address,uint256,uint256)", ethereum.GUARDIAN],
},
]);
};

export default vip053;
1 change: 1 addition & 0 deletions multisig/simulations/ethereum/vip-053/abi/XVSVault.json

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions multisig/simulations/ethereum/vip-053/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { expect } from "chai";
import { Contract } from "ethers";
import { ethers } from "hardhat";
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { forking, pretendExecutingVip } from "src/vip-framework";

import vip053 from "../../../proposals/ethereum/vip-053";
import XVS_VAULT_ABI from "./abi/XVSVault.json";

const { ethereum } = NETWORK_ADDRESSES;

const NORMAL_TIMELOCK = ethereum.NORMAL_TIMELOCK;

forking(20482219, async () => {
const provider = ethers.provider;
let xvsVault: Contract;

describe("Pre-VIP behavior", async () => {
before(async () => {
xvsVault = new ethers.Contract(ethereum.XVS_VAULT_PROXY, XVS_VAULT_ABI, provider);
});

it("should have no pending owner", async () => {
expect(await xvsVault.pendingAdmin()).to.equal(ethers.constants.AddressZero);
});
});

describe("Post-VIP behavior", async () => {
before(async () => {
await pretendExecutingVip(await vip053());
});

it("correct pending owner", async () => {
expect(await xvsVault.pendingAdmin()).to.equal(NORMAL_TIMELOCK);
});
});
});
1 change: 1 addition & 0 deletions simulations/vip-349/abi/XVSVaultProxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"error","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"detail","type":"uint256"}],"name":"Failure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"NewPendingImplementation","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_acceptImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"_setPendingImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"pendingXVSVaultImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]
10 changes: 7 additions & 3 deletions simulations/vip-349/arbitrumone.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { expect } from "chai";
import { Contract } from "ethers";
import { ethers } from "hardhat";
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { expectEvents } from "src/utils";
Expand All @@ -8,22 +7,27 @@ import { forking, pretendExecutingVip, testForkedNetworkVipCommands } from "src/
import vip010 from "../../multisig/proposals/arbitrumone/vip-010";
import vip349 from "../../vips/vip-349/bscmainnet";
import ACCESS_CONTROL_MANAGER_ABI from "./abi/AccessControlManager_ABI.json";
import XVS_VAULT_PROXY_ABI from "./abi/XVSVaultProxy.json";

const { arbitrumone } = NETWORK_ADDRESSES;

forking(230362555, async () => {
const provider = ethers.provider;
const xvsVaultProxy = new ethers.Contract(arbitrumone.XVS_VAULT_PROXY, XVS_VAULT_PROXY_ABI, provider);

before(async () => {
await pretendExecutingVip(await vip010());
});

testForkedNetworkVipCommands("vip349 configures XVS Vault admin", await vip349(), {
testForkedNetworkVipCommands("vip349", await vip349(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [ACCESS_CONTROL_MANAGER_ABI], ["PermissionGranted"], [10]);
await expectEvents(txResponse, [ACCESS_CONTROL_MANAGER_ABI], ["PermissionGranted"], [6]);
},
});

describe("Post-VIP behaviour", async () => {
it("should have the correct pending owner", async () => {
expect(await xvsVaultProxy.admin()).to.equal(arbitrumone.NORMAL_TIMELOCK);
});
});
});
33 changes: 33 additions & 0 deletions simulations/vip-349/ethereum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { expect } from "chai";
import { ethers } from "hardhat";
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { expectEvents } from "src/utils";
import { forking, pretendExecutingVip, testForkedNetworkVipCommands } from "src/vip-framework";

import vip053 from "../../multisig/proposals/ethereum/vip-053";
import vip349 from "../../vips/vip-349/bscmainnet";
import ACCESS_CONTROL_MANAGER_ABI from "./abi/AccessControlManager_ABI.json";
import XVS_VAULT_PROXY_ABI from "./abi/XVSVaultProxy.json";

const { ethereum } = NETWORK_ADDRESSES;

forking(20482219, async () => {
const provider = ethers.provider;
const xvsVaultProxy = new ethers.Contract(ethereum.XVS_VAULT_PROXY, XVS_VAULT_PROXY_ABI, provider);

before(async () => {
await pretendExecutingVip(await vip053());
});

testForkedNetworkVipCommands("vip349", await vip349(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [ACCESS_CONTROL_MANAGER_ABI], ["PermissionGranted"], [6]);
},
});

describe("Post-VIP behaviour", async () => {
it("should have the correct pending owner", async () => {
expect(await xvsVaultProxy.admin()).to.equal(ethereum.NORMAL_TIMELOCK);
});
});
});
157 changes: 157 additions & 0 deletions simulations/vip-350/abi/AccessControlManager_ABI.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
[
{ "inputs": [], "stateMutability": "nonpayable", "type": "constructor" },
{
"anonymous": false,
"inputs": [
{ "indexed": false, "internalType": "address", "name": "account", "type": "address" },
{ "indexed": false, "internalType": "address", "name": "contractAddress", "type": "address" },
{ "indexed": false, "internalType": "string", "name": "functionSig", "type": "string" }
],
"name": "PermissionGranted",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{ "indexed": false, "internalType": "address", "name": "account", "type": "address" },
{ "indexed": false, "internalType": "address", "name": "contractAddress", "type": "address" },
{ "indexed": false, "internalType": "string", "name": "functionSig", "type": "string" }
],
"name": "PermissionRevoked",
"type": "event"
},
{
"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": "address", "name": "account", "type": "address" },
{ "internalType": "address", "name": "contractAddress", "type": "address" },
{ "internalType": "string", "name": "functionSig", "type": "string" }
],
"name": "hasPermission",
"outputs": [{ "internalType": "bool", "name": "", "type": "bool" }],
"stateMutability": "view",
"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"
}
]
1 change: 1 addition & 0 deletions simulations/vip-350/abi/XVSVaultProxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"error","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"info","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"detail","type":"uint256"}],"name":"Failure","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"NewAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newImplementation","type":"address"}],"name":"NewImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"NewPendingAdmin","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldPendingImplementation","type":"address"},{"indexed":false,"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"NewPendingImplementation","type":"event"},{"payable":true,"stateMutability":"payable","type":"fallback"},{"constant":false,"inputs":[],"name":"_acceptAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[],"name":"_acceptImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingAdmin","type":"address"}],"name":"_setPendingAdmin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newPendingImplementation","type":"address"}],"name":"_setPendingImplementation","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"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":[],"name":"pendingXVSVaultImplementation","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"}]
25 changes: 25 additions & 0 deletions simulations/vip-350/arbitrumone.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from "chai";

Check failure on line 1 in simulations/vip-350/arbitrumone.ts

View workflow job for this annotation

GitHub Actions / lint

'expect' is defined but never used. Allowed unused vars must match /^_.+/u
import { ethers } from "hardhat";
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { expectEvents } from "src/utils";
import { forking, pretendExecutingVip, testForkedNetworkVipCommands } from "src/vip-framework";

import vip010 from "../../multisig/proposals/arbitrumone/vip-010";
import vip350 from "../../vips/vip-350/bscmainnet";
import ACCESS_CONTROL_MANAGER_ABI from "./abi/AccessControlManager_ABI.json";

const { arbitrumone } = NETWORK_ADDRESSES;

Check failure on line 11 in simulations/vip-350/arbitrumone.ts

View workflow job for this annotation

GitHub Actions / lint

'arbitrumone' is assigned a value but never used. Allowed unused vars must match /^_.+/u

forking(230362555, async () => {
const provider = ethers.provider;

Check failure on line 14 in simulations/vip-350/arbitrumone.ts

View workflow job for this annotation

GitHub Actions / lint

'provider' is assigned a value but never used. Allowed unused vars must match /^_.+/u

before(async () => {
await pretendExecutingVip(await vip010());
});

testForkedNetworkVipCommands("vip350", await vip350(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [ACCESS_CONTROL_MANAGER_ABI], ["PermissionGranted"], [6]);
},
});
});
25 changes: 25 additions & 0 deletions simulations/vip-350/ethereum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect } from "chai";

Check failure on line 1 in simulations/vip-350/ethereum.ts

View workflow job for this annotation

GitHub Actions / lint

'expect' is defined but never used. Allowed unused vars must match /^_.+/u
import { ethers } from "hardhat";
import { NETWORK_ADDRESSES } from "src/networkAddresses";
import { expectEvents } from "src/utils";
import { forking, pretendExecutingVip, testForkedNetworkVipCommands } from "src/vip-framework";

import vip053 from "../../multisig/proposals/ethereum/vip-053";
import vip350 from "../../vips/vip-350/bscmainnet";
import ACCESS_CONTROL_MANAGER_ABI from "./abi/AccessControlManager_ABI.json";

const { ethereum } = NETWORK_ADDRESSES;

Check failure on line 11 in simulations/vip-350/ethereum.ts

View workflow job for this annotation

GitHub Actions / lint

'ethereum' is assigned a value but never used. Allowed unused vars must match /^_.+/u

forking(20482317, async () => {
const provider = ethers.provider;

Check failure on line 14 in simulations/vip-350/ethereum.ts

View workflow job for this annotation

GitHub Actions / lint

'provider' is assigned a value but never used. Allowed unused vars must match /^_.+/u

before(async () => {
await pretendExecutingVip(await vip053());
});

testForkedNetworkVipCommands("vip350", await vip350(), {
callbackAfterExecution: async txResponse => {
await expectEvents(txResponse, [ACCESS_CONTROL_MANAGER_ABI], ["PermissionGranted"], [6]);
},
});
});
Loading

0 comments on commit 3390ebd

Please sign in to comment.