diff --git a/simulations/vip-536/abi/Beacon.json b/simulations/vip-536/abi/Beacon.json new file mode 100644 index 000000000..fe7f3e52f --- /dev/null +++ b/simulations/vip-536/abi/Beacon.json @@ -0,0 +1,51 @@ +[ + { + "inputs": [{ "internalType": "address", "name": "implementation_", "type": "address" }], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "internalType": "address", "name": "implementation", "type": "address" }], + "name": "Upgraded", + "type": "event" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newImplementation", "type": "address" }], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/simulations/vip-536/arbitrumone.ts b/simulations/vip-536/arbitrumone.ts new file mode 100644 index 000000000..ac8b446fe --- /dev/null +++ b/simulations/vip-536/arbitrumone.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testForkedNetworkVipCommands } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM, + SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, +} from "../../vips/vip-536/bscmainnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM = "0x07801d54906Be49517DfDEd26c89A81fb94e504B"; + +forking(356227715, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM); + }); + }); + + testForkedNetworkVipCommands("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM); + }); + }); +}); diff --git a/simulations/vip-536/arbitrumsepolia.ts b/simulations/vip-536/arbitrumsepolia.ts new file mode 100644 index 000000000..6821832cf --- /dev/null +++ b/simulations/vip-536/arbitrumsepolia.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testForkedNetworkVipCommands } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM, + SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, +} from "../../vips/vip-536/bsctestnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM = "0x4ea44b72e00e942b259a6a3720Cf1B8776b9fe93"; + +forking(172142261, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM); + }); + }); + + testForkedNetworkVipCommands("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM); + }); + }); +}); diff --git a/simulations/vip-536/bscmainnet.ts b/simulations/vip-536/bscmainnet.ts new file mode 100644 index 000000000..3cfb132ce --- /dev/null +++ b/simulations/vip-536/bscmainnet.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testVip } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC, + SINGLE_TOKEN_CONVERTER_BEACON_BSC, +} from "../../vips/vip-536/bscmainnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_BSC = "0x40ed28180Df01FdeB957224E4A5415704B9D5990"; + +forking(53537328, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_BSC, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_BSC); + }); + }); + + testVip("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC); + }); + }); +}); diff --git a/simulations/vip-536/bsctestnet.ts b/simulations/vip-536/bsctestnet.ts new file mode 100644 index 000000000..162e08de8 --- /dev/null +++ b/simulations/vip-536/bsctestnet.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testVip } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC, + SINGLE_TOKEN_CONVERTER_BEACON_BSC, +} from "../../vips/vip-536/bsctestnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_BSC = "0x42Ec3Eb6F23460dFDfa3aE5688f3415CDfE0C6AD"; + +forking(57758332, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_BSC, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_BSC); + }); + }); + + testVip("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC); + }); + }); +}); diff --git a/simulations/vip-536/ethereum.ts b/simulations/vip-536/ethereum.ts new file mode 100644 index 000000000..1dbfb9ec6 --- /dev/null +++ b/simulations/vip-536/ethereum.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testForkedNetworkVipCommands } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM, + SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, +} from "../../vips/vip-536/bscmainnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM = "0x95de59aD391589603DF33F81B53C4d894D8e5545"; + +forking(22895432, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM); + }); + }); + + testForkedNetworkVipCommands("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("RiskFundConverter and SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM); + }); + }); +}); diff --git a/simulations/vip-536/sepolia.ts b/simulations/vip-536/sepolia.ts new file mode 100644 index 000000000..b14020e7d --- /dev/null +++ b/simulations/vip-536/sepolia.ts @@ -0,0 +1,40 @@ +import { expect } from "chai"; +import { Contract } from "ethers"; +import { ethers } from "hardhat"; +import { expectEvents } from "src/utils"; +import { forking, testForkedNetworkVipCommands } from "src/vip-framework"; + +import vip536, { + NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM, + SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, +} from "../../vips/vip-536/bsctestnet"; +import BEACON_ABI from "./abi/Beacon.json"; + +const OLD_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM = "0xb13409Cbf2b3420856DD577AE2FcC4a4Cd6d9F1e"; + +forking(8733498, async () => { + const provider = ethers.provider; + let beacon: Contract; + + before(async () => { + beacon = new ethers.Contract(SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, BEACON_ABI, provider); + }); + + describe("Pre-VIP behavior", () => { + it("SingleTokenConverter should have old implementation", async () => { + expect(await beacon.implementation()).to.equal(OLD_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM); + }); + }); + + testForkedNetworkVipCommands("VIP-536", await vip536(), { + callbackAfterExecution: async (txResponse: any) => { + await expectEvents(txResponse, [BEACON_ABI], ["Upgraded"], [1]); + }, + }); + + describe("Post-VIP behavior", () => { + it("RiskFundConverter and SingleTokenConverter should have new implementation", async () => { + expect(await beacon.implementation()).to.equal(NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM); + }); + }); +}); diff --git a/vips/vip-536/bscmainnet.ts b/vips/vip-536/bscmainnet.ts new file mode 100644 index 000000000..577090f51 --- /dev/null +++ b/vips/vip-536/bscmainnet.ts @@ -0,0 +1,47 @@ +import { LzChainId, ProposalType } from "src/types"; +import { makeProposal } from "src/utils"; + +export const SINGLE_TOKEN_CONVERTER_BEACON_BSC = "0x4c9D57b05B245c40235D720A5f3A592f3DfF11ca"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC = "0xF96363e03D175eEcc6A965f117e1497EAe878d29"; +export const SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM = "0x5C0b5D09388F2BA6441E74D40666C4d96e4527D1"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM = "0x560E50dc157E7140C0E5bdF46e586c658C8A066c"; +export const SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM = "0x993900Ab4ef4092e5B76d4781D09A2732086F0F0"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM = "0x2EE413F4e060451CB25AeD5Cdd348F430aa79105"; + +export const vip536 = () => { + const meta = { + version: "v2", + title: "VIP-3328 upgrades the implementation of token converters", + description: ` + This VIP upgrades the implementation of SingleTokenConverter for bsc, ethereum and arbitrum.`, + forDescription: "I agree that Venus Protocol should proceed with this proposal", + againstDescription: "I do not think that Venus Protocol should proceed with this proposal", + abstainDescription: "I am indifferent to whether Venus Protocol proceeds or not", + }; + + return makeProposal( + [ + { + target: SINGLE_TOKEN_CONVERTER_BEACON_BSC, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC], + }, + { + target: SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM], + dstChainId: LzChainId.ethereum, + }, + { + target: SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM], + dstChainId: LzChainId.arbitrumone, + }, + ], + meta, + ProposalType.REGULAR, + ); +}; + +export default vip536; diff --git a/vips/vip-536/bsctestnet.ts b/vips/vip-536/bsctestnet.ts new file mode 100644 index 000000000..b6f544920 --- /dev/null +++ b/vips/vip-536/bsctestnet.ts @@ -0,0 +1,47 @@ +import { LzChainId, ProposalType } from "src/types"; +import { makeProposal } from "src/utils"; + +export const SINGLE_TOKEN_CONVERTER_BEACON_BSC = "0xD2410D8B581D37c5B474CD9Ee0C15F02138AC028"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC = "0x892A70c9D9f946c0CB2b148f40B95Ba0024e8968"; +export const SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM = "0xb86e532a5333d413A1c35d86cCdF1484B40219eF"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM = "0x04444eAc8811140A3B22814a2203F6908d0708ad"; +export const SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM = "0xC77D0F75f1e4e3720DA1D2F5D809F439125a2Fd4"; +export const NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM = "0xcf78eB1806660F0D001F786C66f294DADb9F95b0"; + +export const vip536 = () => { + const meta = { + version: "v2", + title: "VIP-3328 upgrades the implementation of token converters", + description: ` + This VIP upgrades the implementation of SingleTokenConverter on bsc, ethereum and arbitrum.`, + forDescription: "I agree that Venus Protocol should proceed with this proposal", + againstDescription: "I do not think that Venus Protocol should proceed with this proposal", + abstainDescription: "I am indifferent to whether Venus Protocol proceeds or not", + }; + + return makeProposal( + [ + { + target: SINGLE_TOKEN_CONVERTER_BEACON_BSC, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_BSC], + }, + { + target: SINGLE_TOKEN_CONVERTER_BEACON_ETHEREUM, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_ETHEREUM], + dstChainId: LzChainId.sepolia, + }, + { + target: SINGLE_TOKEN_CONVERTER_BEACON_ARBITRUM, + signature: "upgradeTo(address)", + params: [NEW_SINGLE_TOKEN_CONVERTER_IMP_ARBITRUM], + dstChainId: LzChainId.arbitrumsepolia, + }, + ], + meta, + ProposalType.REGULAR, + ); +}; + +export default vip536;