From 67b99d830f6419008ba1951be38339caeea02430 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Tue, 20 Jun 2023 20:21:26 +0300 Subject: [PATCH 01/13] add simulation for psm_usdt deployment --- .../abi/IAccessControlManager_ABI.json | 126 ++++ .../abi/VAIController_ABI.json | 534 +++++++++++++++++ .../vip-130/vip-130-testnet/abi/VAI_ABI.json | 563 ++++++++++++++++++ .../vip-130/vip-130-testnet/simulations.ts | 66 ++ .../abi/IAccessControlManager_ABI.json | 126 ++++ .../vip-130/abi/VAIController_ABI.json | 534 +++++++++++++++++ simulations/vip-130/vip-130/abi/VAI_ABI.json | 563 ++++++++++++++++++ simulations/vip-130/vip-130/simulations.ts | 68 +++ vips/vip-130-testnet.ts | 106 ++++ 9 files changed, 2686 insertions(+) create mode 100644 simulations/vip-130/vip-130-testnet/abi/IAccessControlManager_ABI.json create mode 100644 simulations/vip-130/vip-130-testnet/abi/VAIController_ABI.json create mode 100644 simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json create mode 100644 simulations/vip-130/vip-130-testnet/simulations.ts create mode 100644 simulations/vip-130/vip-130/abi/IAccessControlManager_ABI.json create mode 100644 simulations/vip-130/vip-130/abi/VAIController_ABI.json create mode 100644 simulations/vip-130/vip-130/abi/VAI_ABI.json create mode 100644 simulations/vip-130/vip-130/simulations.ts create mode 100644 vips/vip-130-testnet.ts diff --git a/simulations/vip-130/vip-130-testnet/abi/IAccessControlManager_ABI.json b/simulations/vip-130/vip-130-testnet/abi/IAccessControlManager_ABI.json new file mode 100644 index 000000000..687d32137 --- /dev/null +++ b/simulations/vip-130/vip-130-testnet/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-130/vip-130-testnet/abi/VAIController_ABI.json b/simulations/vip-130/vip-130-testnet/abi/VAIController_ABI.json new file mode 100644 index 000000000..283f2ad8a --- /dev/null +++ b/simulations/vip-130/vip-130-testnet/abi/VAIController_ABI.json @@ -0,0 +1,534 @@ +[ + { + "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": "liquidator", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "borrower", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "repayAmount", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "vTokenCollateral", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "seizeTokens", "type": "uint256" } + ], + "name": "LiquidateVAI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "minter", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "feeAmount", "type": "uint256" } + ], + "name": "MintFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "minter", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "mintVAIAmount", "type": "uint256" } + ], + "name": "MintVAI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldAccessControlAddress", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newAccessControlAddress", "type": "address" } + ], + "name": "NewAccessControl", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ComptrollerInterface", + "name": "oldComptroller", + "type": "address" + }, + { "indexed": false, "internalType": "contract ComptrollerInterface", "name": "newComptroller", "type": "address" } + ], + "name": "NewComptroller", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldTreasuryAddress", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newTreasuryAddress", "type": "address" } + ], + "name": "NewTreasuryAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldTreasuryGuardian", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newTreasuryGuardian", "type": "address" } + ], + "name": "NewTreasuryGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldTreasuryPercent", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newTreasuryPercent", "type": "uint256" } + ], + "name": "NewTreasuryPercent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldBaseRateMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newBaseRateMantissa", "type": "uint256" } + ], + "name": "NewVAIBaseRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldFloatRateMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newFlatRateMantissa", "type": "uint256" } + ], + "name": "NewVAIFloatRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldMintCap", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newMintCap", "type": "uint256" } + ], + "name": "NewVAIMintCap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldReceiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newReceiver", "type": "address" } + ], + "name": "NewVAIReceiver", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "payer", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "borrower", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "repayVAIAmount", "type": "uint256" } + ], + "name": "RepayVAI", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "INITIAL_VAI_MINT_INDEX", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "contract VAIUnitroller", "name": "unitroller", "type": "address" }], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "contract ComptrollerInterface", "name": "comptroller_", "type": "address" }], + "name": "_setComptroller", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "newTreasuryGuardian", "type": "address" }, + { "internalType": "address", "name": "newTreasuryAddress", "type": "address" }, + { "internalType": "uint256", "name": "newTreasuryPercent", "type": "uint256" } + ], + "name": "_setTreasuryData", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControl", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "accrueVAIInterest", + "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": true, + "inputs": [], + "name": "baseRateMantissa", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "comptroller", + "outputs": [{ "internalType": "contract ComptrollerInterface", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "floatRateMantissa", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumber", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlocksPerYear", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "minter", "type": "address" }], + "name": "getMintableVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "borrower", "type": "address" }, + { "internalType": "uint256", "name": "repayAmount", "type": "uint256" } + ], + "name": "getVAICalculateRepayAmount", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "minter", "type": "address" }], + "name": "getVAIMinterInterestIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "getVAIRepayAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIRepayRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIRepayRatePerBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isVenusVAIInitialized", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "borrower", "type": "address" }, + { "internalType": "uint256", "name": "repayAmount", "type": "uint256" }, + { "internalType": "contract VTokenInterface", "name": "vTokenCollateral", "type": "address" } + ], + "name": "liquidateVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "mintCap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "mintVAIAmount", "type": "uint256" }], + "name": "mintVAI", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "pastVAIInterest", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "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": "pendingVAIControllerImplementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "receiver", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "repayVAIAmount", "type": "uint256" }], + "name": "repayVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newAccessControlAddress", "type": "address" }], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "newBaseRateMantissa", "type": "uint256" }], + "name": "setBaseRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "newFloatRateMantissa", "type": "uint256" }], + "name": "setFloatRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "_mintCap", "type": "uint256" }], + "name": "setMintCap", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newReceiver", "type": "address" }], + "name": "setReceiver", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryGuardian", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryPercent", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiControllerImplementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiMintIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "venusVAIMinterIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "venusVAIState", + "outputs": [ + { "internalType": "uint224", "name": "index", "type": "uint224" }, + { "internalType": "uint32", "name": "block", "type": "uint32" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json b/simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json new file mode 100644 index 000000000..369b77adb --- /dev/null +++ b/simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json @@ -0,0 +1,563 @@ +[ + { + "inputs": [ + { + "internalType": "uint256", + "name": "chainId_", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "guy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": true, + "inputs": [ + { + "indexed": true, + "internalType": "bytes4", + "name": "sig", + "type": "bytes4" + }, + { + "indexed": true, + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg1", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg2", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LogNote", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "guy", + "type": "address" + } + ], + "name": "deny", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "move", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "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": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "pull", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "push", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "guy", + "type": "address" + } + ], + "name": "rely", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "wards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-130/vip-130-testnet/simulations.ts b/simulations/vip-130/vip-130-testnet/simulations.ts new file mode 100644 index 000000000..868927c30 --- /dev/null +++ b/simulations/vip-130/vip-130-testnet/simulations.ts @@ -0,0 +1,66 @@ +import { expect } from "chai"; +import { parseUnits } from "ethers/lib/utils"; +import { ethers } from "hardhat"; +import { initMainnetUser } from "../../../src/utils"; +import { forking, testVip } from "../../../src/vip-framework"; +import { vip130 } from "../../../vips/vip-130-testnet"; +import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; +import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; +import VAI_ABI from "./abi/VAI_ABI.json"; +import { Signer } from "ethers"; + +const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; +const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; +const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; +const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; +const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; +const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; +const PSM_USDT = "0x6A79A72d78004dABbBa870Dd2Da6C142c78a3d06"; +const BASE_RATE_MANTISSA = parseUnits("2.72", 18); + +forking(30860798, () => { + const provider = ethers.provider; + let vai: ethers.Contract; + let vaiControllerProxy: ethers.Contract; + let accessControlManager: ethers.Contract; + let psmSigner: Signer; + + before(async () => { + vai = new ethers.Contract(VAI, VAI_ABI, provider); + vaiControllerProxy = new ethers.Contract(VAI_CONTROLLER_PROXY, VAI_CONTROLLER_ABI, provider); + accessControlManager = new ethers.Contract(ACM, ACM_ABI, provider); + psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); + }); + + testVip("VIP-130 Add Peg Stability (USDT)", vip130()); + describe("Post-VIP behavior", async () => { + it("Verify PSM_USDT is admin of VAI contract", async () => { + const check = await vai.wards(PSM_USDT); + expect(check).equals(1); + }); + + it("Verify access control setup", async () => { + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "pause()")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "resume()")).equals(true); + + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(FAST_TRACK_TIMELOCK, "pause()")).equals( + true, + ); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(FAST_TRACK_TIMELOCK, "resume()")).equals( + true, + ); + + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)")).equals(true); + + }); + + it("Verify new VAI base rate is 2.72%", async () => { + const currentBaseRate = await vaiControllerProxy.baseRateMantissa(); + expect(currentBaseRate).equals(BASE_RATE_MANTISSA); + }); + }); +}); diff --git a/simulations/vip-130/vip-130/abi/IAccessControlManager_ABI.json b/simulations/vip-130/vip-130/abi/IAccessControlManager_ABI.json new file mode 100644 index 000000000..687d32137 --- /dev/null +++ b/simulations/vip-130/vip-130/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-130/vip-130/abi/VAIController_ABI.json b/simulations/vip-130/vip-130/abi/VAIController_ABI.json new file mode 100644 index 000000000..283f2ad8a --- /dev/null +++ b/simulations/vip-130/vip-130/abi/VAIController_ABI.json @@ -0,0 +1,534 @@ +[ + { + "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": "liquidator", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "borrower", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "repayAmount", "type": "uint256" }, + { "indexed": false, "internalType": "address", "name": "vTokenCollateral", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "seizeTokens", "type": "uint256" } + ], + "name": "LiquidateVAI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "minter", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "feeAmount", "type": "uint256" } + ], + "name": "MintFee", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "minter", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "mintVAIAmount", "type": "uint256" } + ], + "name": "MintVAI", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldAccessControlAddress", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newAccessControlAddress", "type": "address" } + ], + "name": "NewAccessControl", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "contract ComptrollerInterface", + "name": "oldComptroller", + "type": "address" + }, + { "indexed": false, "internalType": "contract ComptrollerInterface", "name": "newComptroller", "type": "address" } + ], + "name": "NewComptroller", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldTreasuryAddress", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newTreasuryAddress", "type": "address" } + ], + "name": "NewTreasuryAddress", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldTreasuryGuardian", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newTreasuryGuardian", "type": "address" } + ], + "name": "NewTreasuryGuardian", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldTreasuryPercent", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newTreasuryPercent", "type": "uint256" } + ], + "name": "NewTreasuryPercent", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldBaseRateMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newBaseRateMantissa", "type": "uint256" } + ], + "name": "NewVAIBaseRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldFloatRateMantissa", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newFlatRateMantissa", "type": "uint256" } + ], + "name": "NewVAIFloatRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldMintCap", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newMintCap", "type": "uint256" } + ], + "name": "NewVAIMintCap", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldReceiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newReceiver", "type": "address" } + ], + "name": "NewVAIReceiver", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "payer", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "borrower", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "repayVAIAmount", "type": "uint256" } + ], + "name": "RepayVAI", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "INITIAL_VAI_MINT_INDEX", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "contract VAIUnitroller", "name": "unitroller", "type": "address" }], + "name": "_become", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "contract ComptrollerInterface", "name": "comptroller_", "type": "address" }], + "name": "_setComptroller", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "newTreasuryGuardian", "type": "address" }, + { "internalType": "address", "name": "newTreasuryAddress", "type": "address" }, + { "internalType": "uint256", "name": "newTreasuryPercent", "type": "uint256" } + ], + "name": "_setTreasuryData", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "accessControl", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "accrueVAIInterest", + "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": true, + "inputs": [], + "name": "baseRateMantissa", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "comptroller", + "outputs": [{ "internalType": "contract ComptrollerInterface", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "floatRateMantissa", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlockNumber", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getBlocksPerYear", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "minter", "type": "address" }], + "name": "getMintableVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "borrower", "type": "address" }, + { "internalType": "uint256", "name": "repayAmount", "type": "uint256" } + ], + "name": "getVAICalculateRepayAmount", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "minter", "type": "address" }], + "name": "getVAIMinterInterestIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "getVAIRepayAmount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIRepayRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getVAIRepayRatePerBlock", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "initialize", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "isVenusVAIInitialized", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "borrower", "type": "address" }, + { "internalType": "uint256", "name": "repayAmount", "type": "uint256" }, + { "internalType": "contract VTokenInterface", "name": "vTokenCollateral", "type": "address" } + ], + "name": "liquidateVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "mintCap", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "mintVAIAmount", "type": "uint256" }], + "name": "mintVAI", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "pastVAIInterest", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "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": "pendingVAIControllerImplementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "receiver", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "repayVAIAmount", "type": "uint256" }], + "name": "repayVAI", + "outputs": [ + { "internalType": "uint256", "name": "", "type": "uint256" }, + { "internalType": "uint256", "name": "", "type": "uint256" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newAccessControlAddress", "type": "address" }], + "name": "setAccessControl", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "newBaseRateMantissa", "type": "uint256" }], + "name": "setBaseRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "newFloatRateMantissa", "type": "uint256" }], + "name": "setFloatRate", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "uint256", "name": "_mintCap", "type": "uint256" }], + "name": "setMintCap", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [{ "internalType": "address", "name": "newReceiver", "type": "address" }], + "name": "setReceiver", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryGuardian", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "treasuryPercent", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiControllerImplementation", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "vaiMintIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "venusVAIMinterIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "venusVAIState", + "outputs": [ + { "internalType": "uint224", "name": "index", "type": "uint224" }, + { "internalType": "uint32", "name": "block", "type": "uint32" } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-130/vip-130/abi/VAI_ABI.json b/simulations/vip-130/vip-130/abi/VAI_ABI.json new file mode 100644 index 000000000..369b77adb --- /dev/null +++ b/simulations/vip-130/vip-130/abi/VAI_ABI.json @@ -0,0 +1,563 @@ +[ + { + "inputs": [ + { + "internalType": "uint256", + "name": "chainId_", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "guy", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": true, + "inputs": [ + { + "indexed": true, + "internalType": "bytes4", + "name": "sig", + "type": "bytes4" + }, + { + "indexed": true, + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg1", + "type": "bytes32" + }, + { + "indexed": true, + "internalType": "bytes32", + "name": "arg2", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "LogNote", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": true, + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "guy", + "type": "address" + } + ], + "name": "deny", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "mint", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "move", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "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": false, + "inputs": [ + { + "internalType": "address", + "name": "holder", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "nonce", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "expiry", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "allowed", + "type": "bool" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "pull", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "usr", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "push", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "guy", + "type": "address" + } + ], + "name": "rely", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "internalType": "address", + "name": "src", + "type": "address" + }, + { + "internalType": "address", + "name": "dst", + "type": "address" + }, + { + "internalType": "uint256", + "name": "wad", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "version", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "wards", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-130/vip-130/simulations.ts b/simulations/vip-130/vip-130/simulations.ts new file mode 100644 index 000000000..f277a3024 --- /dev/null +++ b/simulations/vip-130/vip-130/simulations.ts @@ -0,0 +1,68 @@ +import { expect } from "chai"; +import { parseUnits } from "ethers/lib/utils"; +import { ethers } from "hardhat"; +import { initMainnetUser } from "../../../src/utils"; +import { forking, testVip } from "../../../src/vip-framework"; +import { vip130 } from "../../../vips/vip-130-testnet"; +import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; +import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; +import VAI_ABI from "./abi/VAI_ABI.json"; +import { Signer } from "ethers"; + +const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; +const VAI_CONTROLLER_PROXY = "0x004065D34C6b18cE4370ced1CeBDE94865DbFAFE"; +const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; +const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; +const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; +const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; +//TODO: insert mainnet address when PSM_USDT is deployed on mainnet +const PSM_USDT = ""; +const BASE_RATE_MANTISSA = parseUnits("2.72", 18); + +//TODO: insert block number after deployment of PSM_USDT +forking(30853771, () => { + const provider = ethers.provider; + let vai: ethers.Contract; + let vaiControllerProxy: ethers.Contract; + let accessControlManager: ethers.Contract; + let psmSigner: Signer; + + before(async () => { + vai = new ethers.Contract(VAI, VAI_ABI, provider); + vaiControllerProxy = new ethers.Contract(VAI_CONTROLLER_PROXY, VAI_CONTROLLER_ABI, provider); + accessControlManager = new ethers.Contract(ACM, ACM_ABI, provider); + psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); + }); + + testVip("VIP-130 Add Peg Stability (USDT)", vip130()); + describe("Post-VIP behavior", async () => { + it("Verify PSM_USDT is admin of VAI contract", async () => { + const check = await vai.wards(PSM_USDT); + expect(check).equals(1); + }); + + it("Verify access control setup", async () => { + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "pause()")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "resume()")).equals(true); + + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(FAST_TRACK_TIMELOCK, "pause()")).equals( + true, + ); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(FAST_TRACK_TIMELOCK, "resume()")).equals( + true, + ); + + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)")).equals(true); + + }); + + it("Verify new VAI base rate is 2.72%", async () => { + const currentBaseRate = await vaiControllerProxy.baseRateMantissa(); + expect(currentBaseRate).equals(BASE_RATE_MANTISSA); + }); + }); +}); diff --git a/vips/vip-130-testnet.ts b/vips/vip-130-testnet.ts new file mode 100644 index 000000000..dc1d35aa0 --- /dev/null +++ b/vips/vip-130-testnet.ts @@ -0,0 +1,106 @@ +import { parseUnits } from "ethers/lib/utils"; +import { ProposalType } from "../src/types"; +import { makeProposal } from "../src/utils"; + + +const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA" +const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; +const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; +const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; +const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; +const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; +const PSM_USDT = "0x6A79A72d78004dABbBa870Dd2Da6C142c78a3d06"; +const BASE_RATE_MANTISSA = parseUnits("2.72", 18); + +export const vip130 = () => { + const meta = { + version: "v2", + title: "VIP-130 Add Peg Stability (USDT)", + description: ` + Add the Peg Stability Contract as an admin in the VAI contract: VAI.rely(pegStabilityAddress) + Grant the Normal timelock contracts role to change the feeIn and feeOut, vaiMintCap, comptroller, venusTreasury variables within the PSM instance. + Grant the Critical and Fast-track timelock contracts roles to pause and resume the created PSM instance. + `, + forDescription: "I agree that Venus Protocol should proceed with the Add Peg Stability (USDT)", + againstDescription: "I do not think that Venus Protocol should proceed with the Add Peg Stability (USDT)", + abstainDescription: "I am indifferent to whether Venus Protocol proceeds with the Add Peg Stability (USDT) or not", + }; + + return makeProposal( + [ + { + target: PSM_USDT, + signature: "acceptOwnership()", + params: [], + }, + + { + target: VAI, + signature: "rely(address)", + params: [PSM_USDT], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setFeeIn(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setFeeOut(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setVaiMintCap(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setComptroller(address)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setVenusTreasury(address)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", FAST_TRACK_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", CRITICAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", FAST_TRACK_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", CRITICAL_TIMELOCK], + }, + + { + target: VAI_CONTROLLER_PROXY, + signature: "setBaseRate(uint256)", + params: [BASE_RATE_MANTISSA], + }, + ], + meta, + ProposalType.REGULAR, + ); +}; From 81b1131af8553ff01d8976dbdaf762ddd0642c1a Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 21 Jun 2023 16:22:27 +0300 Subject: [PATCH 02/13] change PSM address --- simulations/vip-130/vip-130-testnet/simulations.ts | 4 ++-- vips/vip-130-testnet.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/simulations/vip-130/vip-130-testnet/simulations.ts b/simulations/vip-130/vip-130-testnet/simulations.ts index 868927c30..e49f082b7 100644 --- a/simulations/vip-130/vip-130-testnet/simulations.ts +++ b/simulations/vip-130/vip-130-testnet/simulations.ts @@ -15,10 +15,10 @@ const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; -const PSM_USDT = "0x6A79A72d78004dABbBa870Dd2Da6C142c78a3d06"; +const PSM_USDT = "0x2822E0Ac03e64F7BA26e0aCb79EC0B6336e9CA2A"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); -forking(30860798, () => { +forking(30883314, () => { const provider = ethers.provider; let vai: ethers.Contract; let vaiControllerProxy: ethers.Contract; diff --git a/vips/vip-130-testnet.ts b/vips/vip-130-testnet.ts index dc1d35aa0..4d672b565 100644 --- a/vips/vip-130-testnet.ts +++ b/vips/vip-130-testnet.ts @@ -9,7 +9,7 @@ const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; -const PSM_USDT = "0x6A79A72d78004dABbBa870Dd2Da6C142c78a3d06"; +const PSM_USDT = "0x2822E0Ac03e64F7BA26e0aCb79EC0B6336e9CA2A"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); export const vip130 = () => { From d922802a2f75978f435e1a08be4cf22ac37f7f4c Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 21 Jun 2023 16:58:03 +0300 Subject: [PATCH 03/13] refactor: format code --- .../vip-130/vip-130-testnet/simulations.ts | 24 +++++++++++++------ simulations/vip-130/vip-130/simulations.ts | 24 +++++++++++++------ vips/vip-130-testnet.ts | 4 ++-- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/simulations/vip-130/vip-130-testnet/simulations.ts b/simulations/vip-130/vip-130-testnet/simulations.ts index e49f082b7..2199d6a28 100644 --- a/simulations/vip-130/vip-130-testnet/simulations.ts +++ b/simulations/vip-130/vip-130-testnet/simulations.ts @@ -1,13 +1,14 @@ import { expect } from "chai"; +import { Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; + import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; import { vip130 } from "../../../vips/vip-130-testnet"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; -import { Signer } from "ethers"; const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; @@ -50,12 +51,21 @@ forking(30883314, () => { true, ); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)")).equals(true); - + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)"), + ).equals(true); }); it("Verify new VAI base rate is 2.72%", async () => { diff --git a/simulations/vip-130/vip-130/simulations.ts b/simulations/vip-130/vip-130/simulations.ts index f277a3024..984c1349b 100644 --- a/simulations/vip-130/vip-130/simulations.ts +++ b/simulations/vip-130/vip-130/simulations.ts @@ -1,13 +1,14 @@ import { expect } from "chai"; +import { Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; + import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; import { vip130 } from "../../../vips/vip-130-testnet"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; -import { Signer } from "ethers"; const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; const VAI_CONTROLLER_PROXY = "0x004065D34C6b18cE4370ced1CeBDE94865DbFAFE"; @@ -52,12 +53,21 @@ forking(30853771, () => { true, ); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)")).equals(true); - + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeIn(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setFeeOut(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)"), + ).equals(true); + expect( + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)"), + ).equals(true); }); it("Verify new VAI base rate is 2.72%", async () => { diff --git a/vips/vip-130-testnet.ts b/vips/vip-130-testnet.ts index 4d672b565..8b085944f 100644 --- a/vips/vip-130-testnet.ts +++ b/vips/vip-130-testnet.ts @@ -1,9 +1,9 @@ import { parseUnits } from "ethers/lib/utils"; + import { ProposalType } from "../src/types"; import { makeProposal } from "../src/utils"; - -const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA" +const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; From a31312fa61494c5b3efe78a78d3439c4800fd2ed Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 21 Jun 2023 17:37:05 +0300 Subject: [PATCH 04/13] change vip number and add vip for mainnet --- .../abi/IAccessControlManager_ABI.json | 0 .../abi/VAIController_ABI.json | 0 .../vip-131-testnet}/abi/VAI_ABI.json | 0 .../vip-131-testnet}/simulations.ts | 2 +- .../abi/IAccessControlManager_ABI.json | 0 .../vip-131}/abi/VAIController_ABI.json | 0 .../vip-131}/abi/VAI_ABI.json | 0 .../vip-131}/simulations.ts | 2 +- .../vip-131-testnet.ts} | 4 +- vips/vip-131/vip-131.ts | 106 ++++++++++++++++++ 10 files changed, 110 insertions(+), 4 deletions(-) rename simulations/{vip-130/vip-130-testnet => vip-131/vip-131-testnet}/abi/IAccessControlManager_ABI.json (100%) rename simulations/{vip-130/vip-130-testnet => vip-131/vip-131-testnet}/abi/VAIController_ABI.json (100%) rename simulations/{vip-130/vip-130-testnet => vip-131/vip-131-testnet}/abi/VAI_ABI.json (100%) rename simulations/{vip-130/vip-130-testnet => vip-131/vip-131-testnet}/simulations.ts (98%) rename simulations/{vip-130/vip-130 => vip-131/vip-131}/abi/IAccessControlManager_ABI.json (100%) rename simulations/{vip-130/vip-130 => vip-131/vip-131}/abi/VAIController_ABI.json (100%) rename simulations/{vip-130/vip-130 => vip-131/vip-131}/abi/VAI_ABI.json (100%) rename simulations/{vip-130/vip-130 => vip-131/vip-131}/simulations.ts (98%) rename vips/{vip-130-testnet.ts => vip-131/vip-131-testnet.ts} (97%) create mode 100644 vips/vip-131/vip-131.ts diff --git a/simulations/vip-130/vip-130-testnet/abi/IAccessControlManager_ABI.json b/simulations/vip-131/vip-131-testnet/abi/IAccessControlManager_ABI.json similarity index 100% rename from simulations/vip-130/vip-130-testnet/abi/IAccessControlManager_ABI.json rename to simulations/vip-131/vip-131-testnet/abi/IAccessControlManager_ABI.json diff --git a/simulations/vip-130/vip-130-testnet/abi/VAIController_ABI.json b/simulations/vip-131/vip-131-testnet/abi/VAIController_ABI.json similarity index 100% rename from simulations/vip-130/vip-130-testnet/abi/VAIController_ABI.json rename to simulations/vip-131/vip-131-testnet/abi/VAIController_ABI.json diff --git a/simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json b/simulations/vip-131/vip-131-testnet/abi/VAI_ABI.json similarity index 100% rename from simulations/vip-130/vip-130-testnet/abi/VAI_ABI.json rename to simulations/vip-131/vip-131-testnet/abi/VAI_ABI.json diff --git a/simulations/vip-130/vip-130-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts similarity index 98% rename from simulations/vip-130/vip-130-testnet/simulations.ts rename to simulations/vip-131/vip-131-testnet/simulations.ts index 2199d6a28..a7152fb10 100644 --- a/simulations/vip-130/vip-130-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -5,7 +5,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip130 } from "../../../vips/vip-130-testnet"; +import { vip130 } from "../../../vips/vip-131/vip-130-testnet"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; diff --git a/simulations/vip-130/vip-130/abi/IAccessControlManager_ABI.json b/simulations/vip-131/vip-131/abi/IAccessControlManager_ABI.json similarity index 100% rename from simulations/vip-130/vip-130/abi/IAccessControlManager_ABI.json rename to simulations/vip-131/vip-131/abi/IAccessControlManager_ABI.json diff --git a/simulations/vip-130/vip-130/abi/VAIController_ABI.json b/simulations/vip-131/vip-131/abi/VAIController_ABI.json similarity index 100% rename from simulations/vip-130/vip-130/abi/VAIController_ABI.json rename to simulations/vip-131/vip-131/abi/VAIController_ABI.json diff --git a/simulations/vip-130/vip-130/abi/VAI_ABI.json b/simulations/vip-131/vip-131/abi/VAI_ABI.json similarity index 100% rename from simulations/vip-130/vip-130/abi/VAI_ABI.json rename to simulations/vip-131/vip-131/abi/VAI_ABI.json diff --git a/simulations/vip-130/vip-130/simulations.ts b/simulations/vip-131/vip-131/simulations.ts similarity index 98% rename from simulations/vip-130/vip-130/simulations.ts rename to simulations/vip-131/vip-131/simulations.ts index 984c1349b..47f40b1a7 100644 --- a/simulations/vip-130/vip-130/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -5,7 +5,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip130 } from "../../../vips/vip-130-testnet"; +import { vip130 } from "../../../vips/vip-131/vip-130"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; diff --git a/vips/vip-130-testnet.ts b/vips/vip-131/vip-131-testnet.ts similarity index 97% rename from vips/vip-130-testnet.ts rename to vips/vip-131/vip-131-testnet.ts index 8b085944f..9408ba062 100644 --- a/vips/vip-130-testnet.ts +++ b/vips/vip-131/vip-131-testnet.ts @@ -1,7 +1,7 @@ import { parseUnits } from "ethers/lib/utils"; -import { ProposalType } from "../src/types"; -import { makeProposal } from "../src/utils"; +import { ProposalType } from "../../src/types"; +import { makeProposal } from "../../src/utils"; const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; diff --git a/vips/vip-131/vip-131.ts b/vips/vip-131/vip-131.ts new file mode 100644 index 000000000..992935885 --- /dev/null +++ b/vips/vip-131/vip-131.ts @@ -0,0 +1,106 @@ +import { parseUnits } from "ethers/lib/utils"; + +import { ProposalType } from "../../src/types"; +import { makeProposal } from "../../src/utils"; + +const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; +const VAI_CONTROLLER_PROXY = "0x004065D34C6b18cE4370ced1CeBDE94865DbFAFE"; +const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; +const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; +const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; +const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; +const PSM_USDT = ""; +const BASE_RATE_MANTISSA = parseUnits("2.72", 18); + +export const vip130 = () => { + const meta = { + version: "v2", + title: "VIP-130 Add Peg Stability (USDT)", + description: ` + Add the Peg Stability Contract as an admin in the VAI contract: VAI.rely(pegStabilityAddress) + Grant the Normal timelock contracts role to change the feeIn and feeOut, vaiMintCap, comptroller, venusTreasury variables within the PSM instance. + Grant the Critical and Fast-track timelock contracts roles to pause and resume the created PSM instance. + `, + forDescription: "I agree that Venus Protocol should proceed with the Add Peg Stability (USDT)", + againstDescription: "I do not think that Venus Protocol should proceed with the Add Peg Stability (USDT)", + abstainDescription: "I am indifferent to whether Venus Protocol proceeds with the Add Peg Stability (USDT) or not", + }; + + return makeProposal( + [ + { + target: PSM_USDT, + signature: "acceptOwnership()", + params: [], + }, + + { + target: VAI, + signature: "rely(address)", + params: [PSM_USDT], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setFeeIn(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setFeeOut(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setVaiMintCap(uint256)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setComptroller(address)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "setVenusTreasury(address)", NORMAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", FAST_TRACK_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", CRITICAL_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", FAST_TRACK_TIMELOCK], + }, + + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", CRITICAL_TIMELOCK], + }, + + { + target: VAI_CONTROLLER_PROXY, + signature: "setBaseRate(uint256)", + params: [BASE_RATE_MANTISSA], + }, + ], + meta, + ProposalType.REGULAR, + ); +}; From 736222184c0c574f427edf38c215124659bfc2cd Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 21 Jun 2023 18:12:31 +0300 Subject: [PATCH 05/13] refactor: change VIP number in VIP description and rename variables --- simulations/vip-131/vip-131-testnet/simulations.ts | 4 ++-- simulations/vip-131/vip-131/simulations.ts | 4 ++-- vips/vip-131/vip-131-testnet.ts | 4 ++-- vips/vip-131/vip-131.ts | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/simulations/vip-131/vip-131-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts index a7152fb10..b86aa3209 100644 --- a/simulations/vip-131/vip-131-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -5,7 +5,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip130 } from "../../../vips/vip-131/vip-130-testnet"; +import { vip131Testnet } from "../../../vips/vip-131/vip-131-testnet"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; @@ -33,7 +33,7 @@ forking(30883314, () => { psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); }); - testVip("VIP-130 Add Peg Stability (USDT)", vip130()); + testVip("VIP-130 Add Peg Stability (USDT)", vip131Testnet()); describe("Post-VIP behavior", async () => { it("Verify PSM_USDT is admin of VAI contract", async () => { const check = await vai.wards(PSM_USDT); diff --git a/simulations/vip-131/vip-131/simulations.ts b/simulations/vip-131/vip-131/simulations.ts index 47f40b1a7..c3d280a77 100644 --- a/simulations/vip-131/vip-131/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -5,7 +5,7 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip130 } from "../../../vips/vip-131/vip-130"; +import { vip131 } from "../../../vips/vip-131/vip-131"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; @@ -35,7 +35,7 @@ forking(30853771, () => { psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); }); - testVip("VIP-130 Add Peg Stability (USDT)", vip130()); + testVip("VIP-130 Add Peg Stability (USDT)", vip131()); describe("Post-VIP behavior", async () => { it("Verify PSM_USDT is admin of VAI contract", async () => { const check = await vai.wards(PSM_USDT); diff --git a/vips/vip-131/vip-131-testnet.ts b/vips/vip-131/vip-131-testnet.ts index 9408ba062..2d5d64304 100644 --- a/vips/vip-131/vip-131-testnet.ts +++ b/vips/vip-131/vip-131-testnet.ts @@ -12,10 +12,10 @@ const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; const PSM_USDT = "0x2822E0Ac03e64F7BA26e0aCb79EC0B6336e9CA2A"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); -export const vip130 = () => { +export const vip131Testnet = () => { const meta = { version: "v2", - title: "VIP-130 Add Peg Stability (USDT)", + title: "VIP-131 Add Peg Stability (USDT)", description: ` Add the Peg Stability Contract as an admin in the VAI contract: VAI.rely(pegStabilityAddress) Grant the Normal timelock contracts role to change the feeIn and feeOut, vaiMintCap, comptroller, venusTreasury variables within the PSM instance. diff --git a/vips/vip-131/vip-131.ts b/vips/vip-131/vip-131.ts index 992935885..566e06d32 100644 --- a/vips/vip-131/vip-131.ts +++ b/vips/vip-131/vip-131.ts @@ -12,10 +12,10 @@ const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; const PSM_USDT = ""; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); -export const vip130 = () => { +export const vip131 = () => { const meta = { version: "v2", - title: "VIP-130 Add Peg Stability (USDT)", + title: "VIP-131 Add Peg Stability (USDT)", description: ` Add the Peg Stability Contract as an admin in the VAI contract: VAI.rely(pegStabilityAddress) Grant the Normal timelock contracts role to change the feeIn and feeOut, vaiMintCap, comptroller, venusTreasury variables within the PSM instance. From a962c90c8fd74be435f88407e674b18f0027e7e1 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 21 Jun 2023 21:06:41 +0300 Subject: [PATCH 06/13] refactor: add PSM address for mainnet VIP and block number for the simulation --- simulations/vip-131/vip-131/simulations.ts | 6 ++---- vips/vip-131/vip-131.ts | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/simulations/vip-131/vip-131/simulations.ts b/simulations/vip-131/vip-131/simulations.ts index c3d280a77..b83ca5b0c 100644 --- a/simulations/vip-131/vip-131/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -16,12 +16,10 @@ const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; -//TODO: insert mainnet address when PSM_USDT is deployed on mainnet -const PSM_USDT = ""; +const PSM_USDT = "0x93dB3f46e1DC91c2b9D8Bc7443790bB4699c0E81"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); -//TODO: insert block number after deployment of PSM_USDT -forking(30853771, () => { +forking(29298113, () => { const provider = ethers.provider; let vai: ethers.Contract; let vaiControllerProxy: ethers.Contract; diff --git a/vips/vip-131/vip-131.ts b/vips/vip-131/vip-131.ts index 566e06d32..4cd39fd40 100644 --- a/vips/vip-131/vip-131.ts +++ b/vips/vip-131/vip-131.ts @@ -9,7 +9,7 @@ const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; -const PSM_USDT = ""; +const PSM_USDT = "0x93dB3f46e1DC91c2b9D8Bc7443790bB4699c0E81"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); export const vip131 = () => { From f60c66cd897808a456f71f0c43eb5b259d8a6eb7 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 2 Aug 2023 15:12:41 +0300 Subject: [PATCH 07/13] refactor: change PSM address, include fee setting in VIP and add testing of both swaps --- simulations/vip-123/vip-123/simulations.ts | 2 +- simulations/vip-131/utils.ts | 70 ++ .../vip-131/vip-131-testnet/abi/PSM_ABI.json | 906 ++++++++++++++++++ .../abi/ResilientOracle_ABI.json | 1 + .../vip-131/vip-131-testnet/abi/USDT_ABI.json | 1 + .../vip-131/vip-131-testnet/simulations.ts | 39 +- vips/vip-131/vip-131-testnet.ts | 15 +- 7 files changed, 1027 insertions(+), 7 deletions(-) create mode 100644 simulations/vip-131/utils.ts create mode 100644 simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json create mode 100644 simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json create mode 100644 simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json diff --git a/simulations/vip-123/vip-123/simulations.ts b/simulations/vip-123/vip-123/simulations.ts index 322453ed9..6abe17f56 100644 --- a/simulations/vip-123/vip-123/simulations.ts +++ b/simulations/vip-123/vip-123/simulations.ts @@ -292,4 +292,4 @@ forking(28526142, () => { } }); }); -}); +}); \ No newline at end of file diff --git a/simulations/vip-131/utils.ts b/simulations/vip-131/utils.ts new file mode 100644 index 000000000..ccd355030 --- /dev/null +++ b/simulations/vip-131/utils.ts @@ -0,0 +1,70 @@ +import { expect } from "chai"; +import { BigNumber, Signer } from "ethers"; +import { parseUnits } from "ethers/lib/utils"; +import { ethers } from "hardhat"; + + +const BASIS_POINT_DIVISOR = BigNumber.from(10000); +const MANTISSA_ONE = parseUnits("1", 18); + + +export async function swapStableForVAIAndValidate( + psm: ethers.Contract, + stableToken: ethers.Contract, + stableTokenPrice: BigNumber, + tokenSigner: Signer, + tokenHolder: string, + VAI: ethers.Contract, + feeIn: BigNumber + ) { + const stableTokenAmount = parseUnits("1000", 18); + // calculate price of stableToken in USD, applying MIN(1$, oracle_price) thus capping stableToken maximum price to 1$ + const feeInTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? MANTISSA_ONE : stableTokenPrice; + const stableTokenAmountUSD = stableTokenAmount.mul(feeInTokenPrice).div(MANTISSA_ONE); + const fee = stableTokenAmountUSD.mul(feeIn).div(BASIS_POINT_DIVISOR); + const vaiToMint = stableTokenAmountUSD.sub(fee); + await stableToken.connect(tokenSigner).approve(psm.address, stableTokenAmount); + const vaiBalanceBefore = await VAI.balanceOf(tokenHolder); + const tx = await psm.connect(tokenSigner).swapStableForVAI(tokenHolder, stableTokenAmount); + const vaiBalanceAfter = await VAI.balanceOf(tokenHolder); + const vaiBalance = vaiBalanceAfter.sub(vaiBalanceBefore); + expect(vaiBalance).to.equal(vaiToMint); + await expect(tx).to.emit(psm, "StableForVAISwapped").withArgs(stableTokenAmount, vaiToMint, fee); + } + + export async function swapVAIForStableAndValidate( + psm: ethers.Contract, + stableTokenName: string, + stableTokenPrice: BigNumber, + VAI: ethers.Contract, + vaiSigner: Signer, + feeIn: BigNumber, + stableToken: ethers.Contract, + ) { + const tokenAmount = parseUnits("100", 18); // token amount to receive + // calculate price of stableToken in USD, applying MAX(1$, oracle_price) thus making stableToken minimum price to 1$ + const feeOutTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? stableTokenPrice : MANTISSA_ONE; + const tokenAmountUsd: BigNumber = tokenAmount.mul(feeOutTokenPrice).div(MANTISSA_ONE); // vai to burn + const fee = tokenAmountUsd.mul(feeIn).div(BASIS_POINT_DIVISOR); + formatConsoleLog(`${stableTokenName} Price: ` + stableTokenPrice.toString()); + await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd); + const vaiSignerAddress = await vaiSigner.getAddress(); + const tokenBalanceBefore = await stableToken.balanceOf(vaiSignerAddress); + const tx = await psm.connect(vaiSigner).swapVAIForStable(await vaiSigner.getAddress(), tokenAmount); + const tokenBalanceAfter = await stableToken.balanceOf(vaiSignerAddress); + const tokenBalance = tokenBalanceAfter.sub(tokenBalanceBefore); + expect(tokenBalance).to.equal(tokenAmount); + await expect(tx).to.emit(psm, "VAIForStableSwapped").withArgs(tokenAmountUsd, tokenAmount, fee); + } + +// **************************** +// ***** Helper Functions ***** +// **************************** + +function formatConsoleLog(message: string) { + const indentation = " ".repeat(10); // Adjust the number of spaces for indentation + // Format the message using ANSI escape codes + const formattedMessage = `\x1b[90m${message}\x1b[0m`; // Set gray color (90) and reset color (0) + console.log(`${indentation}${formattedMessage}`); +} + \ No newline at end of file diff --git a/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json b/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json new file mode 100644 index 000000000..ef2b7569b --- /dev/null +++ b/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json @@ -0,0 +1,906 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "AlreadyPaused", + "type": "error" + }, + { + "inputs": [], + "name": "AmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFee", + "type": "error" + }, + { + "inputs": [], + "name": "NotEnoughVAI", + "type": "error" + }, + { + "inputs": [], + "name": "NotPaused", + "type": "error" + }, + { + "inputs": [], + "name": "Paused", + "type": "error" + }, + { + "inputs": [], + "name": "TooManyDecimals", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintCapReached", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintedUnderflow", + "type": "error" + }, + { + "inputs": [], + "name": "VAITransferFail", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAmount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeIn", + "type": "uint256" + } + ], + "name": "FeeInChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeOut", + "type": "uint256" + } + ], + "name": "FeeOutChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "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": "admin", + "type": "address" + } + ], + "name": "PSMPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "PSMResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "stableIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "StableForVAISwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "vaiBurnt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stableOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiFee", + "type": "uint256" + } + ], + "name": "VAIForStableSwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCap", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCap", + "type": "uint256" + } + ], + "name": "VAIMintCapChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldTreasury", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTreasury", + "type": "address" + } + ], + "name": "VenusTreasuryChanged", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MANTISSA_ONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ONE_DOLLAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STABLE_TOKEN_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VAI", + "outputs": [ + { + "internalType": "contract IVAI", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeOut", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resume", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + } + ], + "name": "setFeeIn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + } + ], + "name": "setFeeOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "setVAIMintCap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + } + ], + "name": "setVenusTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMintCap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "venusTreasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } + ] \ No newline at end of file diff --git a/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json b/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json new file mode 100644 index 000000000..212d6aca5 --- /dev/null +++ b/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"address","name":"vBnbAddress","type":"address"},{"internalType":"address","name":"vaiAddress","type":"address"},{"internalType":"contract BoundValidatorInterface","name":"_boundValidator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"calledContract","type":"address"},{"internalType":"string","name":"methodSignature","type":"string"}],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAccessControlManager","type":"address"},{"indexed":false,"internalType":"address","name":"newAccessControlManager","type":"address"}],"name":"NewAccessControlManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"role","type":"uint256"},{"indexed":true,"internalType":"bool","name":"enable","type":"bool"}],"name":"OracleEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"uint256","name":"role","type":"uint256"}],"name":"OracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"mainOracle","type":"address"},{"indexed":true,"internalType":"address","name":"pivotOracle","type":"address"},{"indexed":false,"internalType":"address","name":"fallbackOracle","type":"address"}],"name":"TokenConfigAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"BNB_ADDR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVALID_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessControlManager","outputs":[{"internalType":"contract IAccessControlManagerV8","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boundValidator","outputs":[{"internalType":"contract BoundValidatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"enableOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"}],"name":"getOracle","outputs":[{"internalType":"address","name":"oracle","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getTokenConfig","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"getUnderlyingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"accessControlManager_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"accessControlManager_","type":"address"}],"name":"setAccessControlManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig","name":"tokenConfig","type":"tuple"}],"name":"setTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig[]","name":"tokenConfigs_","type":"tuple[]"}],"name":"setTokenConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"updateAssetPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"updatePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vBnb","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file diff --git a/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json b/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json new file mode 100644 index 000000000..b488f300f --- /dev/null +++ b/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json @@ -0,0 +1 @@ +[{"inputs":[{"internalType":"uint256","name":"_initialAmount","type":"uint256"},{"internalType":"string","name":"_tokenName","type":"string"},{"internalType":"uint8","name":"_decimalUnits","type":"uint8"},{"internalType":"string","name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"allocateTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file diff --git a/simulations/vip-131/vip-131-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts index b86aa3209..51ad8fafe 100644 --- a/simulations/vip-131/vip-131-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -1,14 +1,18 @@ import { expect } from "chai"; -import { Signer } from "ethers"; +import { BigNumber, Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip131Testnet } from "../../../vips/vip-131/vip-131-testnet"; +import { FEE_IN, FEE_OUT, vip131Testnet } from "../../../vips/vip-131/vip-131-testnet"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; +import PSM_ABI from "./abi/PSM_ABI.json"; +import USDT_ABI from "./abi/USDT_ABI.json"; +import ResilientOracle_ABI from "./abi/ResilientOracle_ABI.json"; +import { swapStableForVAIAndValidate, swapVAIForStableAndValidate } from "../utils"; const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; @@ -16,21 +20,36 @@ const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; -const PSM_USDT = "0x2822E0Ac03e64F7BA26e0aCb79EC0B6336e9CA2A"; +const PSM_USDT = "0xB21E69eef4Bc1D64903fa28D9b32491B1c0786F1"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); +const RESILIENT_ORACLE = "0x3cD69251D04A28d887Ac14cbe2E14c52F3D57823"; +const USDT = "0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c"; +const STABLE_TOKEN_HOLDER = "0xd9a851794184869fba26ae2417008cb09c9195f1"; +const VAI_HOLDER = "0xd24d881ff77a47188f40b2a0c36ecb6973b5f2a4"; -forking(30883314, () => { +forking(32091802, () => { const provider = ethers.provider; let vai: ethers.Contract; let vaiControllerProxy: ethers.Contract; let accessControlManager: ethers.Contract; + let resilientOracle: ethers.Contract; + let usdt: ethers.Contract; + let psm: ethers.Contract; let psmSigner: Signer; + let tokenHolder: Signer; + let vaiHolder: Signer; before(async () => { vai = new ethers.Contract(VAI, VAI_ABI, provider); vaiControllerProxy = new ethers.Contract(VAI_CONTROLLER_PROXY, VAI_CONTROLLER_ABI, provider); accessControlManager = new ethers.Contract(ACM, ACM_ABI, provider); + psm = new ethers.Contract(PSM_USDT, PSM_ABI, provider); + resilientOracle = new ethers.Contract(RESILIENT_ORACLE, ResilientOracle_ABI, provider); + usdt = new ethers.Contract(USDT, USDT_ABI, provider); + psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); + tokenHolder = await initMainnetUser(STABLE_TOKEN_HOLDER, ethers.utils.parseEther("1")); + vaiHolder = await initMainnetUser(VAI_HOLDER, ethers.utils.parseEther("1")); }); testVip("VIP-130 Add Peg Stability (USDT)", vip131Testnet()); @@ -72,5 +91,17 @@ forking(30883314, () => { const currentBaseRate = await vaiControllerProxy.baseRateMantissa(); expect(currentBaseRate).equals(BASE_RATE_MANTISSA); }); + it("Verify feeIn and feeOut",async () => { + expect(await psm.feeIn()).to.equal(FEE_IN); + expect(await psm.feeOut()).to.equal(FEE_OUT); + }) + it("Verify swapStableForVAI works", async () => { + const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); + swapStableForVAIAndValidate(psm,usdt,stableTokenPrice,tokenHolder,STABLE_TOKEN_HOLDER,vai,BigNumber.from(FEE_IN)); + }); + it("Verify swapVAIForStable works", async () => { + const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); + swapVAIForStableAndValidate(psm,stableTokenPrice,vai,vaiHolder,BigNumber.from(FEE_IN),usdt); + }); }); }); diff --git a/vips/vip-131/vip-131-testnet.ts b/vips/vip-131/vip-131-testnet.ts index 2d5d64304..f58d93887 100644 --- a/vips/vip-131/vip-131-testnet.ts +++ b/vips/vip-131/vip-131-testnet.ts @@ -3,13 +3,15 @@ import { parseUnits } from "ethers/lib/utils"; import { ProposalType } from "../../src/types"; import { makeProposal } from "../../src/utils"; +export const FEE_OUT = 100; // 10bps +export const FEE_IN = 0; const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; const VAI = "0x5fFbE5302BadED40941A403228E6AD03f93752d9"; const NORMAL_TIMELOCK = "0xce10739590001705F7FF231611ba4A48B2820327"; const FAST_TRACK_TIMELOCK = "0x3CFf21b7AF8390fE68799D58727d3b4C25a83cb6"; const CRITICAL_TIMELOCK = "0x23B893a7C45a5Eb8c8C062b9F32d0D2e43eD286D"; -const PSM_USDT = "0x2822E0Ac03e64F7BA26e0aCb79EC0B6336e9CA2A"; +const PSM_USDT = "0xB21E69eef4Bc1D64903fa28D9b32491B1c0786F1"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); export const vip131Testnet = () => { @@ -93,7 +95,16 @@ export const vip131Testnet = () => { signature: "giveCallPermission(address,string,address)", params: [PSM_USDT, "resume()", CRITICAL_TIMELOCK], }, - + { + target: PSM_USDT, + signature: "setFeeIn(uint256)", + params: [FEE_IN], + }, + { + target: PSM_USDT, + signature: "setFeeOut(uint256)", + params: [FEE_OUT], + }, { target: VAI_CONTROLLER_PROXY, signature: "setBaseRate(uint256)", From 1736016d2a4140cecf13e45e9181c78ecc9de4cf Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 2 Aug 2023 15:13:58 +0300 Subject: [PATCH 08/13] refactor: format code --- simulations/vip-123/vip-123/simulations.ts | 2 +- simulations/vip-131/utils.ts | 105 +- .../vip-131/vip-131-testnet/abi/PSM_ABI.json | 1810 ++++++++--------- .../abi/ResilientOracle_ABI.json | 302 ++- .../vip-131/vip-131-testnet/abi/USDT_ABI.json | 140 +- .../vip-131/vip-131-testnet/simulations.ts | 24 +- 6 files changed, 1413 insertions(+), 970 deletions(-) diff --git a/simulations/vip-123/vip-123/simulations.ts b/simulations/vip-123/vip-123/simulations.ts index 6abe17f56..322453ed9 100644 --- a/simulations/vip-123/vip-123/simulations.ts +++ b/simulations/vip-123/vip-123/simulations.ts @@ -292,4 +292,4 @@ forking(28526142, () => { } }); }); -}); \ No newline at end of file +}); diff --git a/simulations/vip-131/utils.ts b/simulations/vip-131/utils.ts index ccd355030..ea19d2100 100644 --- a/simulations/vip-131/utils.ts +++ b/simulations/vip-131/utils.ts @@ -3,68 +3,65 @@ import { BigNumber, Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; - const BASIS_POINT_DIVISOR = BigNumber.from(10000); const MANTISSA_ONE = parseUnits("1", 18); - export async function swapStableForVAIAndValidate( - psm: ethers.Contract, - stableToken: ethers.Contract, - stableTokenPrice: BigNumber, - tokenSigner: Signer, - tokenHolder: string, - VAI: ethers.Contract, - feeIn: BigNumber - ) { - const stableTokenAmount = parseUnits("1000", 18); - // calculate price of stableToken in USD, applying MIN(1$, oracle_price) thus capping stableToken maximum price to 1$ - const feeInTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? MANTISSA_ONE : stableTokenPrice; - const stableTokenAmountUSD = stableTokenAmount.mul(feeInTokenPrice).div(MANTISSA_ONE); - const fee = stableTokenAmountUSD.mul(feeIn).div(BASIS_POINT_DIVISOR); - const vaiToMint = stableTokenAmountUSD.sub(fee); - await stableToken.connect(tokenSigner).approve(psm.address, stableTokenAmount); - const vaiBalanceBefore = await VAI.balanceOf(tokenHolder); - const tx = await psm.connect(tokenSigner).swapStableForVAI(tokenHolder, stableTokenAmount); - const vaiBalanceAfter = await VAI.balanceOf(tokenHolder); - const vaiBalance = vaiBalanceAfter.sub(vaiBalanceBefore); - expect(vaiBalance).to.equal(vaiToMint); - await expect(tx).to.emit(psm, "StableForVAISwapped").withArgs(stableTokenAmount, vaiToMint, fee); - } - - export async function swapVAIForStableAndValidate( - psm: ethers.Contract, - stableTokenName: string, - stableTokenPrice: BigNumber, - VAI: ethers.Contract, - vaiSigner: Signer, - feeIn: BigNumber, - stableToken: ethers.Contract, - ) { - const tokenAmount = parseUnits("100", 18); // token amount to receive - // calculate price of stableToken in USD, applying MAX(1$, oracle_price) thus making stableToken minimum price to 1$ - const feeOutTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? stableTokenPrice : MANTISSA_ONE; - const tokenAmountUsd: BigNumber = tokenAmount.mul(feeOutTokenPrice).div(MANTISSA_ONE); // vai to burn - const fee = tokenAmountUsd.mul(feeIn).div(BASIS_POINT_DIVISOR); - formatConsoleLog(`${stableTokenName} Price: ` + stableTokenPrice.toString()); - await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd); - const vaiSignerAddress = await vaiSigner.getAddress(); - const tokenBalanceBefore = await stableToken.balanceOf(vaiSignerAddress); - const tx = await psm.connect(vaiSigner).swapVAIForStable(await vaiSigner.getAddress(), tokenAmount); - const tokenBalanceAfter = await stableToken.balanceOf(vaiSignerAddress); - const tokenBalance = tokenBalanceAfter.sub(tokenBalanceBefore); - expect(tokenBalance).to.equal(tokenAmount); - await expect(tx).to.emit(psm, "VAIForStableSwapped").withArgs(tokenAmountUsd, tokenAmount, fee); - } + psm: ethers.Contract, + stableToken: ethers.Contract, + stableTokenPrice: BigNumber, + tokenSigner: Signer, + tokenHolder: string, + VAI: ethers.Contract, + feeIn: BigNumber, +) { + const stableTokenAmount = parseUnits("1000", 18); + // calculate price of stableToken in USD, applying MIN(1$, oracle_price) thus capping stableToken maximum price to 1$ + const feeInTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? MANTISSA_ONE : stableTokenPrice; + const stableTokenAmountUSD = stableTokenAmount.mul(feeInTokenPrice).div(MANTISSA_ONE); + const fee = stableTokenAmountUSD.mul(feeIn).div(BASIS_POINT_DIVISOR); + const vaiToMint = stableTokenAmountUSD.sub(fee); + await stableToken.connect(tokenSigner).approve(psm.address, stableTokenAmount); + const vaiBalanceBefore = await VAI.balanceOf(tokenHolder); + const tx = await psm.connect(tokenSigner).swapStableForVAI(tokenHolder, stableTokenAmount); + const vaiBalanceAfter = await VAI.balanceOf(tokenHolder); + const vaiBalance = vaiBalanceAfter.sub(vaiBalanceBefore); + expect(vaiBalance).to.equal(vaiToMint); + await expect(tx).to.emit(psm, "StableForVAISwapped").withArgs(stableTokenAmount, vaiToMint, fee); +} + +export async function swapVAIForStableAndValidate( + psm: ethers.Contract, + stableTokenName: string, + stableTokenPrice: BigNumber, + VAI: ethers.Contract, + vaiSigner: Signer, + feeIn: BigNumber, + stableToken: ethers.Contract, +) { + const tokenAmount = parseUnits("100", 18); // token amount to receive + // calculate price of stableToken in USD, applying MAX(1$, oracle_price) thus making stableToken minimum price to 1$ + const feeOutTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? stableTokenPrice : MANTISSA_ONE; + const tokenAmountUsd: BigNumber = tokenAmount.mul(feeOutTokenPrice).div(MANTISSA_ONE); // vai to burn + const fee = tokenAmountUsd.mul(feeIn).div(BASIS_POINT_DIVISOR); + formatConsoleLog(`${stableTokenName} Price: ` + stableTokenPrice.toString()); + await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd); + const vaiSignerAddress = await vaiSigner.getAddress(); + const tokenBalanceBefore = await stableToken.balanceOf(vaiSignerAddress); + const tx = await psm.connect(vaiSigner).swapVAIForStable(await vaiSigner.getAddress(), tokenAmount); + const tokenBalanceAfter = await stableToken.balanceOf(vaiSignerAddress); + const tokenBalance = tokenBalanceAfter.sub(tokenBalanceBefore); + expect(tokenBalance).to.equal(tokenAmount); + await expect(tx).to.emit(psm, "VAIForStableSwapped").withArgs(tokenAmountUsd, tokenAmount, fee); +} // **************************** // ***** Helper Functions ***** // **************************** function formatConsoleLog(message: string) { - const indentation = " ".repeat(10); // Adjust the number of spaces for indentation - // Format the message using ANSI escape codes - const formattedMessage = `\x1b[90m${message}\x1b[0m`; // Set gray color (90) and reset color (0) - console.log(`${indentation}${formattedMessage}`); + const indentation = " ".repeat(10); // Adjust the number of spaces for indentation + // Format the message using ANSI escape codes + const formattedMessage = `\x1b[90m${message}\x1b[0m`; // Set gray color (90) and reset color (0) + console.log(`${indentation}${formattedMessage}`); } - \ No newline at end of file diff --git a/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json b/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json index ef2b7569b..7a11d5d6f 100644 --- a/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json +++ b/simulations/vip-131/vip-131-testnet/abi/PSM_ABI.json @@ -1,906 +1,906 @@ [ - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "previousAdmin", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "AdminChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "beacon", - "type": "address" - } - ], - "name": "BeaconUpgraded", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "implementation", - "type": "address" - } - ], - "name": "Upgraded", - "type": "event" - }, - { - "stateMutability": "payable", - "type": "fallback" - }, - { - "inputs": [], - "name": "admin", - "outputs": [ - { - "internalType": "address", - "name": "admin_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newAdmin", - "type": "address" - } - ], - "name": "changeAdmin", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "implementation", - "outputs": [ - { - "internalType": "address", - "name": "implementation_", - "type": "address" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - } - ], - "name": "upgradeTo", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newImplementation", - "type": "address" - }, - { - "internalType": "bytes", - "name": "data", - "type": "bytes" - } - ], - "name": "upgradeToAndCall", - "outputs": [], - "stateMutability": "payable", - "type": "function" - }, - { - "stateMutability": "payable", - "type": "receive" - }, - { - "inputs": [], - "name": "AlreadyPaused", - "type": "error" - }, - { - "inputs": [], - "name": "AmountTooSmall", - "type": "error" - }, - { - "inputs": [], - "name": "InvalidFee", - "type": "error" - }, - { - "inputs": [], - "name": "NotEnoughVAI", - "type": "error" - }, - { - "inputs": [], - "name": "NotPaused", - "type": "error" - }, - { - "inputs": [], - "name": "Paused", - "type": "error" - }, - { - "inputs": [], - "name": "TooManyDecimals", - "type": "error" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "sender", - "type": "address" - }, - { - "internalType": "address", - "name": "calledContract", - "type": "address" - }, - { - "internalType": "string", - "name": "methodSignature", - "type": "string" - } - ], - "name": "Unauthorized", - "type": "error" - }, - { - "inputs": [], - "name": "VAIMintCapReached", - "type": "error" - }, - { - "inputs": [], - "name": "VAIMintedUnderflow", - "type": "error" - }, - { - "inputs": [], - "name": "VAITransferFail", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAddress", - "type": "error" - }, - { - "inputs": [], - "name": "ZeroAmount", - "type": "error" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldFeeIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newFeeIn", - "type": "uint256" - } - ], - "name": "FeeInChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldFeeOut", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newFeeOut", - "type": "uint256" - } - ], - "name": "FeeOutChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint8", - "name": "version", - "type": "uint8" - } - ], - "name": "Initialized", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "address", - "name": "oldAccessControlManager", - "type": "address" - }, - { - "indexed": false, - "internalType": "address", - "name": "newAccessControlManager", - "type": "address" - } - ], - "name": "NewAccessControlManager", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "oldOracle", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOracle", - "type": "address" - } - ], - "name": "OracleChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "previousOwner", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "OwnershipTransferStarted", - "type": "event" - }, - { - "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": "admin", - "type": "address" - } - ], - "name": "PSMPaused", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "admin", - "type": "address" - } - ], - "name": "PSMResumed", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "stableIn", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "vaiOut", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "fee", - "type": "uint256" - } - ], - "name": "StableForVAISwapped", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "vaiBurnt", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "stableOut", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "vaiFee", - "type": "uint256" - } - ], - "name": "VAIForStableSwapped", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": false, - "internalType": "uint256", - "name": "oldCap", - "type": "uint256" - }, - { - "indexed": false, - "internalType": "uint256", - "name": "newCap", - "type": "uint256" - } - ], - "name": "VAIMintCapChanged", - "type": "event" - }, - { - "anonymous": false, - "inputs": [ - { - "indexed": true, - "internalType": "address", - "name": "oldTreasury", - "type": "address" - }, - { - "indexed": true, - "internalType": "address", - "name": "newTreasury", - "type": "address" - } - ], - "name": "VenusTreasuryChanged", - "type": "event" - }, - { - "inputs": [], - "name": "BASIS_POINTS_DIVISOR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "MANTISSA_ONE", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "ONE_DOLLAR", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "STABLE_TOKEN_ADDRESS", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "VAI", - "outputs": [ - { - "internalType": "contract IVAI", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "acceptOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "accessControlManager", - "outputs": [ - { - "internalType": "contract IAccessControlManagerV8", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "feeIn", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "feeOut", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - }, - { - "internalType": "address", - "name": "venusTreasury_", - "type": "address" - }, - { - "internalType": "address", - "name": "oracleAddress_", - "type": "address" - }, - { - "internalType": "uint256", - "name": "feeIn_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "feeOut_", - "type": "uint256" - }, - { - "internalType": "uint256", - "name": "vaiMintCap_", - "type": "uint256" - } - ], - "name": "initialize", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "isPaused", - "outputs": [ - { - "internalType": "bool", - "name": "", - "type": "bool" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "oracle", - "outputs": [ - { - "internalType": "contract ResilientOracleInterface", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "owner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "pause", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "pendingOwner", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "stableTknAmount", - "type": "uint256" - } - ], - "name": "previewSwapStableForVAI", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "stableTknAmount", - "type": "uint256" - } - ], - "name": "previewSwapVAIForStable", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "renounceOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "resume", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "accessControlManager_", - "type": "address" - } - ], - "name": "setAccessControlManager", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "feeIn_", - "type": "uint256" - } - ], - "name": "setFeeIn", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "feeOut_", - "type": "uint256" - } - ], - "name": "setFeeOut", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "oracleAddress_", - "type": "address" - } - ], - "name": "setOracle", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "uint256", - "name": "vaiMintCap_", - "type": "uint256" - } - ], - "name": "setVAIMintCap", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "venusTreasury_", - "type": "address" - } - ], - "name": "setVenusTreasury", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint256", - "name": "stableTknAmount", - "type": "uint256" - } - ], - "name": "swapStableForVAI", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "receiver", - "type": "address" - }, - { - "internalType": "uint256", - "name": "stableTknAmount", - "type": "uint256" - } - ], - "name": "swapVAIForStable", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "newOwner", - "type": "address" - } - ], - "name": "transferOwnership", - "outputs": [], - "stateMutability": "nonpayable", - "type": "function" - }, - { - "inputs": [], - "name": "vaiMintCap", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "vaiMinted", - "outputs": [ - { - "internalType": "uint256", - "name": "", - "type": "uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "venusTreasury", - "outputs": [ - { - "internalType": "address", - "name": "", - "type": "address" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "internalType": "address", - "name": "_logic", - "type": "address" - }, - { - "internalType": "address", - "name": "admin_", - "type": "address" - }, - { - "internalType": "bytes", - "name": "_data", - "type": "bytes" - } - ], - "stateMutability": "payable", - "type": "constructor" - } - ] \ No newline at end of file + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "AlreadyPaused", + "type": "error" + }, + { + "inputs": [], + "name": "AmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFee", + "type": "error" + }, + { + "inputs": [], + "name": "NotEnoughVAI", + "type": "error" + }, + { + "inputs": [], + "name": "NotPaused", + "type": "error" + }, + { + "inputs": [], + "name": "Paused", + "type": "error" + }, + { + "inputs": [], + "name": "TooManyDecimals", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintCapReached", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintedUnderflow", + "type": "error" + }, + { + "inputs": [], + "name": "VAITransferFail", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAmount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeIn", + "type": "uint256" + } + ], + "name": "FeeInChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeOut", + "type": "uint256" + } + ], + "name": "FeeOutChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "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": "admin", + "type": "address" + } + ], + "name": "PSMPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "PSMResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "stableIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "StableForVAISwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "vaiBurnt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stableOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiFee", + "type": "uint256" + } + ], + "name": "VAIForStableSwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCap", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCap", + "type": "uint256" + } + ], + "name": "VAIMintCapChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldTreasury", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTreasury", + "type": "address" + } + ], + "name": "VenusTreasuryChanged", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MANTISSA_ONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ONE_DOLLAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STABLE_TOKEN_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VAI", + "outputs": [ + { + "internalType": "contract IVAI", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeOut", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resume", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + } + ], + "name": "setFeeIn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + } + ], + "name": "setFeeOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "setVAIMintCap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + } + ], + "name": "setVenusTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMintCap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "venusTreasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } +] diff --git a/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json b/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json index 212d6aca5..29a91745a 100644 --- a/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json +++ b/simulations/vip-131/vip-131-testnet/abi/ResilientOracle_ABI.json @@ -1 +1,301 @@ -[{"inputs":[{"internalType":"address","name":"vBnbAddress","type":"address"},{"internalType":"address","name":"vaiAddress","type":"address"},{"internalType":"contract BoundValidatorInterface","name":"_boundValidator","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"calledContract","type":"address"},{"internalType":"string","name":"methodSignature","type":"string"}],"name":"Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldAccessControlManager","type":"address"},{"indexed":false,"internalType":"address","name":"newAccessControlManager","type":"address"}],"name":"NewAccessControlManager","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"role","type":"uint256"},{"indexed":true,"internalType":"bool","name":"enable","type":"bool"}],"name":"OracleEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"oracle","type":"address"},{"indexed":true,"internalType":"uint256","name":"role","type":"uint256"}],"name":"OracleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"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":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"mainOracle","type":"address"},{"indexed":true,"internalType":"address","name":"pivotOracle","type":"address"},{"indexed":false,"internalType":"address","name":"fallbackOracle","type":"address"}],"name":"TokenConfigAdded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"BNB_ADDR","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVALID_PRICE","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"accessControlManager","outputs":[{"internalType":"contract IAccessControlManagerV8","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"boundValidator","outputs":[{"internalType":"contract BoundValidatorInterface","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"},{"internalType":"bool","name":"enable","type":"bool"}],"name":"enableOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"}],"name":"getOracle","outputs":[{"internalType":"address","name":"oracle","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"getTokenConfig","outputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"getUnderlyingPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"accessControlManager_","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"accessControlManager_","type":"address"}],"name":"setAccessControlManager","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address","name":"oracle","type":"address"},{"internalType":"enum ResilientOracle.OracleRole","name":"role","type":"uint8"}],"name":"setOracle","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig","name":"tokenConfig","type":"tuple"}],"name":"setTokenConfig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"asset","type":"address"},{"internalType":"address[3]","name":"oracles","type":"address[3]"},{"internalType":"bool[3]","name":"enableFlagsForOracles","type":"bool[3]"}],"internalType":"struct ResilientOracle.TokenConfig[]","name":"tokenConfigs_","type":"tuple[]"}],"name":"setTokenConfigs","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"asset","type":"address"}],"name":"updateAssetPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vToken","type":"address"}],"name":"updatePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"vBnb","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vai","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}] \ No newline at end of file +[ + { + "inputs": [ + { "internalType": "address", "name": "vBnbAddress", "type": "address" }, + { "internalType": "address", "name": "vaiAddress", "type": "address" }, + { "internalType": "contract BoundValidatorInterface", "name": "_boundValidator", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "calledContract", "type": "address" }, + { "internalType": "string", "name": "methodSignature", "type": "string" } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldAccessControlManager", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newAccessControlManager", "type": "address" } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "role", "type": "uint256" }, + { "indexed": true, "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "OracleEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "oracle", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "role", "type": "uint256" } + ], + "name": "OracleSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "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": false, "internalType": "address", "name": "account", "type": "address" }], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "mainOracle", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "pivotOracle", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "fallbackOracle", "type": "address" } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "BNB_ADDR", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INVALID_PRICE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [{ "internalType": "contract IAccessControlManagerV8", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boundValidator", + "outputs": [{ "internalType": "contract BoundValidatorInterface", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" }, + { "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" } + ], + "name": "getOracle", + "outputs": [ + { "internalType": "address", "name": "oracle", "type": "address" }, + { "internalType": "bool", "name": "enabled", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "getPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "getTokenConfig", + "outputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "vToken", "type": "address" }], + "name": "getUnderlyingPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "accessControlManager_", "type": "address" }], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "accessControlManager_", "type": "address" }], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address", "name": "oracle", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", + "type": "tuple" + } + ], + "name": "setTokenConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", + "type": "tuple[]" + } + ], + "name": "setTokenConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "updateAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "vToken", "type": "address" }], + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vBnb", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vai", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json b/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json index b488f300f..fe8789439 100644 --- a/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json +++ b/simulations/vip-131/vip-131-testnet/abi/USDT_ABI.json @@ -1 +1,139 @@ -[{"inputs":[{"internalType":"uint256","name":"_initialAmount","type":"uint256"},{"internalType":"string","name":"_tokenName","type":"string"},{"internalType":"uint8","name":"_decimalUnits","type":"uint8"},{"internalType":"string","name":"_tokenSymbol","type":"string"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":false,"inputs":[{"internalType":"address","name":"_owner","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"allocateTo","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"_spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"src","type":"address"},{"internalType":"address","name":"dst","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"}] \ No newline at end of file +[ + { + "inputs": [ + { "internalType": "uint256", "name": "_initialAmount", "type": "uint256" }, + { "internalType": "string", "name": "_tokenName", "type": "string" }, + { "internalType": "uint8", "name": "_decimalUnits", "type": "uint8" }, + { "internalType": "string", "name": "_tokenSymbol", "type": "string" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "allocateTo", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "src", "type": "address" }, + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/simulations/vip-131/vip-131-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts index 51ad8fafe..24eec391c 100644 --- a/simulations/vip-131/vip-131-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -6,13 +6,13 @@ import { ethers } from "hardhat"; import { initMainnetUser } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; import { FEE_IN, FEE_OUT, vip131Testnet } from "../../../vips/vip-131/vip-131-testnet"; +import { swapStableForVAIAndValidate, swapVAIForStableAndValidate } from "../utils"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; -import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; -import VAI_ABI from "./abi/VAI_ABI.json"; import PSM_ABI from "./abi/PSM_ABI.json"; -import USDT_ABI from "./abi/USDT_ABI.json"; import ResilientOracle_ABI from "./abi/ResilientOracle_ABI.json"; -import { swapStableForVAIAndValidate, swapVAIForStableAndValidate } from "../utils"; +import USDT_ABI from "./abi/USDT_ABI.json"; +import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; +import VAI_ABI from "./abi/VAI_ABI.json"; const ACM = "0x45f8a08F534f34A97187626E05d4b6648Eeaa9AA"; const VAI_CONTROLLER_PROXY = "0xf70C3C6b749BbAb89C081737334E74C9aFD4BE16"; @@ -91,17 +91,25 @@ forking(32091802, () => { const currentBaseRate = await vaiControllerProxy.baseRateMantissa(); expect(currentBaseRate).equals(BASE_RATE_MANTISSA); }); - it("Verify feeIn and feeOut",async () => { + it("Verify feeIn and feeOut", async () => { expect(await psm.feeIn()).to.equal(FEE_IN); expect(await psm.feeOut()).to.equal(FEE_OUT); - }) + }); it("Verify swapStableForVAI works", async () => { const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); - swapStableForVAIAndValidate(psm,usdt,stableTokenPrice,tokenHolder,STABLE_TOKEN_HOLDER,vai,BigNumber.from(FEE_IN)); + swapStableForVAIAndValidate( + psm, + usdt, + stableTokenPrice, + tokenHolder, + STABLE_TOKEN_HOLDER, + vai, + BigNumber.from(FEE_IN), + ); }); it("Verify swapVAIForStable works", async () => { const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); - swapVAIForStableAndValidate(psm,stableTokenPrice,vai,vaiHolder,BigNumber.from(FEE_IN),usdt); + swapVAIForStableAndValidate(psm, stableTokenPrice, vai, vaiHolder, BigNumber.from(FEE_IN), usdt); }); }); }); From e9afc4d8759cfc0ed130dafc9648fe42a79ae2a0 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 2 Aug 2023 16:12:36 +0300 Subject: [PATCH 09/13] refactor: remove log funciton --- simulations/vip-131/utils.ts | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/simulations/vip-131/utils.ts b/simulations/vip-131/utils.ts index ea19d2100..5f9a8044e 100644 --- a/simulations/vip-131/utils.ts +++ b/simulations/vip-131/utils.ts @@ -32,7 +32,6 @@ export async function swapStableForVAIAndValidate( export async function swapVAIForStableAndValidate( psm: ethers.Contract, - stableTokenName: string, stableTokenPrice: BigNumber, VAI: ethers.Contract, vaiSigner: Signer, @@ -44,7 +43,6 @@ export async function swapVAIForStableAndValidate( const feeOutTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? stableTokenPrice : MANTISSA_ONE; const tokenAmountUsd: BigNumber = tokenAmount.mul(feeOutTokenPrice).div(MANTISSA_ONE); // vai to burn const fee = tokenAmountUsd.mul(feeIn).div(BASIS_POINT_DIVISOR); - formatConsoleLog(`${stableTokenName} Price: ` + stableTokenPrice.toString()); await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd); const vaiSignerAddress = await vaiSigner.getAddress(); const tokenBalanceBefore = await stableToken.balanceOf(vaiSignerAddress); @@ -54,14 +52,3 @@ export async function swapVAIForStableAndValidate( expect(tokenBalance).to.equal(tokenAmount); await expect(tx).to.emit(psm, "VAIForStableSwapped").withArgs(tokenAmountUsd, tokenAmount, fee); } - -// **************************** -// ***** Helper Functions ***** -// **************************** - -function formatConsoleLog(message: string) { - const indentation = " ".repeat(10); // Adjust the number of spaces for indentation - // Format the message using ANSI escape codes - const formattedMessage = `\x1b[90m${message}\x1b[0m`; // Set gray color (90) and reset color (0) - console.log(`${indentation}${formattedMessage}`); -} From b38f963dbe55155f3f3d00595f3ecd67f092d7a6 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 2 Aug 2023 17:24:49 +0300 Subject: [PATCH 10/13] refactor: fix testnet simulations and utils methods to handle dynamic values of stabletoken decimals --- simulations/vip-131/utils.ts | 21 ++++---- .../vip-131/vip-131-testnet/simulations.ts | 52 ++++++++++++++----- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/simulations/vip-131/utils.ts b/simulations/vip-131/utils.ts index 5f9a8044e..2fdfd7c50 100644 --- a/simulations/vip-131/utils.ts +++ b/simulations/vip-131/utils.ts @@ -3,9 +3,8 @@ import { BigNumber, Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; -const BASIS_POINT_DIVISOR = BigNumber.from(10000); const MANTISSA_ONE = parseUnits("1", 18); - +const BASIS_POINT_DIVISOR = BigNumber.from(10000); export async function swapStableForVAIAndValidate( psm: ethers.Contract, stableToken: ethers.Contract, @@ -14,10 +13,12 @@ export async function swapStableForVAIAndValidate( tokenHolder: string, VAI: ethers.Contract, feeIn: BigNumber, + tokenDecimals: number, + oneDollar: BigNumber, ) { - const stableTokenAmount = parseUnits("1000", 18); + const stableTokenAmount = parseUnits("1000", tokenDecimals); // calculate price of stableToken in USD, applying MIN(1$, oracle_price) thus capping stableToken maximum price to 1$ - const feeInTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? MANTISSA_ONE : stableTokenPrice; + const feeInTokenPrice = stableTokenPrice.gt(oneDollar) ? oneDollar : stableTokenPrice; const stableTokenAmountUSD = stableTokenAmount.mul(feeInTokenPrice).div(MANTISSA_ONE); const fee = stableTokenAmountUSD.mul(feeIn).div(BASIS_POINT_DIVISOR); const vaiToMint = stableTokenAmountUSD.sub(fee); @@ -35,15 +36,17 @@ export async function swapVAIForStableAndValidate( stableTokenPrice: BigNumber, VAI: ethers.Contract, vaiSigner: Signer, - feeIn: BigNumber, + feeOut: BigNumber, stableToken: ethers.Contract, + tokenDecimals: number, + oneDollar: BigNumber, ) { - const tokenAmount = parseUnits("100", 18); // token amount to receive + const tokenAmount = parseUnits("100", tokenDecimals); // token amount to receive // calculate price of stableToken in USD, applying MAX(1$, oracle_price) thus making stableToken minimum price to 1$ - const feeOutTokenPrice = stableTokenPrice.gt(MANTISSA_ONE) ? stableTokenPrice : MANTISSA_ONE; + const feeOutTokenPrice = stableTokenPrice.gt(oneDollar) ? stableTokenPrice : oneDollar; const tokenAmountUsd: BigNumber = tokenAmount.mul(feeOutTokenPrice).div(MANTISSA_ONE); // vai to burn - const fee = tokenAmountUsd.mul(feeIn).div(BASIS_POINT_DIVISOR); - await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd); + const fee = tokenAmountUsd.mul(feeOut).div(BASIS_POINT_DIVISOR); + await VAI.connect(vaiSigner).approve(psm.address, tokenAmountUsd.add(fee)); const vaiSignerAddress = await vaiSigner.getAddress(); const tokenBalanceBefore = await stableToken.balanceOf(vaiSignerAddress); const tx = await psm.connect(vaiSigner).swapVAIForStable(await vaiSigner.getAddress(), tokenAmount); diff --git a/simulations/vip-131/vip-131-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts index 24eec391c..31dcf92e6 100644 --- a/simulations/vip-131/vip-131-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -95,21 +95,45 @@ forking(32091802, () => { expect(await psm.feeIn()).to.equal(FEE_IN); expect(await psm.feeOut()).to.equal(FEE_OUT); }); - it("Verify swapStableForVAI works", async () => { - const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); - swapStableForVAIAndValidate( - psm, - usdt, - stableTokenPrice, - tokenHolder, - STABLE_TOKEN_HOLDER, - vai, - BigNumber.from(FEE_IN), - ); + it("Verify ONE_DOLLAR value", async () => { + const tokenDecimals = await usdt.decimals(); + const expectedValue = parseUnits("1", 36 - tokenDecimals); + expect(await psm.ONE_DOLLAR()).to.equal(expectedValue); }); - it("Verify swapVAIForStable works", async () => { - const stableTokenPrice: BigNumber = await resilientOracle.getPrice(USDT); - swapVAIForStableAndValidate(psm, stableTokenPrice, vai, vaiHolder, BigNumber.from(FEE_IN), usdt); + describe("Swaps test: ", () => { + let stableTokenPrice: BigNumber; + let oneDollar: BigNumber; + let tokenDecimals: number; + before(async () => { + stableTokenPrice = await resilientOracle.getPrice(USDT); + tokenDecimals = await usdt.decimals(); + oneDollar = await psm.ONE_DOLLAR(); + }); + it("Verify swapStableForVAI works", async () => { + await swapStableForVAIAndValidate( + psm, + usdt, + stableTokenPrice, + tokenHolder, + STABLE_TOKEN_HOLDER, + vai, + BigNumber.from(FEE_IN), + tokenDecimals, + oneDollar, + ); + }); + it("Verify swapVAIForStable works", async () => { + await swapVAIForStableAndValidate( + psm, + stableTokenPrice, + vai, + vaiHolder, + BigNumber.from(FEE_OUT), + usdt, + tokenDecimals, + oneDollar, + ); + }); }); }); }); From df48a0853c78c09d18785613d763119e6871b110 Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Wed, 2 Aug 2023 18:01:51 +0300 Subject: [PATCH 11/13] refactor: completed VIP + Simulation for mainnet --- simulations/vip-131/vip-131/abi/PSM_ABI.json | 906 ++++++++++++++++++ .../vip-131/abi/ResilientOracle_ABI.json | 301 ++++++ simulations/vip-131/vip-131/abi/USDT_ABI.json | 139 +++ simulations/vip-131/vip-131/simulations.ts | 84 +- vips/vip-131/vip-131.ts | 16 +- 5 files changed, 1438 insertions(+), 8 deletions(-) create mode 100644 simulations/vip-131/vip-131/abi/PSM_ABI.json create mode 100644 simulations/vip-131/vip-131/abi/ResilientOracle_ABI.json create mode 100644 simulations/vip-131/vip-131/abi/USDT_ABI.json diff --git a/simulations/vip-131/vip-131/abi/PSM_ABI.json b/simulations/vip-131/vip-131/abi/PSM_ABI.json new file mode 100644 index 000000000..7a11d5d6f --- /dev/null +++ b/simulations/vip-131/vip-131/abi/PSM_ABI.json @@ -0,0 +1,906 @@ +[ + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "previousAdmin", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "AdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "beacon", + "type": "address" + } + ], + "name": "BeaconUpgraded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "implementation", + "type": "address" + } + ], + "name": "Upgraded", + "type": "event" + }, + { + "stateMutability": "payable", + "type": "fallback" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "admin_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newAdmin", + "type": "address" + } + ], + "name": "changeAdmin", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "implementation", + "outputs": [ + { + "internalType": "address", + "name": "implementation_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + } + ], + "name": "upgradeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newImplementation", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "upgradeToAndCall", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + }, + { + "inputs": [], + "name": "AlreadyPaused", + "type": "error" + }, + { + "inputs": [], + "name": "AmountTooSmall", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidFee", + "type": "error" + }, + { + "inputs": [], + "name": "NotEnoughVAI", + "type": "error" + }, + { + "inputs": [], + "name": "NotPaused", + "type": "error" + }, + { + "inputs": [], + "name": "Paused", + "type": "error" + }, + { + "inputs": [], + "name": "TooManyDecimals", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "calledContract", + "type": "address" + }, + { + "internalType": "string", + "name": "methodSignature", + "type": "string" + } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintCapReached", + "type": "error" + }, + { + "inputs": [], + "name": "VAIMintedUnderflow", + "type": "error" + }, + { + "inputs": [], + "name": "VAITransferFail", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAmount", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeIn", + "type": "uint256" + } + ], + "name": "FeeInChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldFeeOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newFeeOut", + "type": "uint256" + } + ], + "name": "FeeOutChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldAccessControlManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newAccessControlManager", + "type": "address" + } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldOracle", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "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": "admin", + "type": "address" + } + ], + "name": "PSMPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "admin", + "type": "address" + } + ], + "name": "PSMResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "stableIn", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "StableForVAISwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "vaiBurnt", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "stableOut", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "vaiFee", + "type": "uint256" + } + ], + "name": "VAIForStableSwapped", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "oldCap", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newCap", + "type": "uint256" + } + ], + "name": "VAIMintCapChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "oldTreasury", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newTreasury", + "type": "address" + } + ], + "name": "VenusTreasuryChanged", + "type": "event" + }, + { + "inputs": [], + "name": "BASIS_POINTS_DIVISOR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MANTISSA_ONE", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ONE_DOLLAR", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "STABLE_TOKEN_ADDRESS", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "VAI", + "outputs": [ + { + "internalType": "contract IVAI", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManagerV8", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeIn", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeOut", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + }, + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + }, + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + }, + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "isPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract ResilientOracleInterface", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "previewSwapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "resume", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "accessControlManager_", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeIn_", + "type": "uint256" + } + ], + "name": "setFeeIn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "feeOut_", + "type": "uint256" + } + ], + "name": "setFeeOut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "oracleAddress_", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "vaiMintCap_", + "type": "uint256" + } + ], + "name": "setVAIMintCap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "venusTreasury_", + "type": "address" + } + ], + "name": "setVenusTreasury", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapStableForVAI", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "stableTknAmount", + "type": "uint256" + } + ], + "name": "swapVAIForStable", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMintCap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaiMinted", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "venusTreasury", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_logic", + "type": "address" + }, + { + "internalType": "address", + "name": "admin_", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "stateMutability": "payable", + "type": "constructor" + } +] diff --git a/simulations/vip-131/vip-131/abi/ResilientOracle_ABI.json b/simulations/vip-131/vip-131/abi/ResilientOracle_ABI.json new file mode 100644 index 000000000..29a91745a --- /dev/null +++ b/simulations/vip-131/vip-131/abi/ResilientOracle_ABI.json @@ -0,0 +1,301 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "vBnbAddress", "type": "address" }, + { "internalType": "address", "name": "vaiAddress", "type": "address" }, + { "internalType": "contract BoundValidatorInterface", "name": "_boundValidator", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "calledContract", "type": "address" }, + { "internalType": "string", "name": "methodSignature", "type": "string" } + ], + "name": "Unauthorized", + "type": "error" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "address", "name": "oldAccessControlManager", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "newAccessControlManager", "type": "address" } + ], + "name": "NewAccessControlManager", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "role", "type": "uint256" }, + { "indexed": true, "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "OracleEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "oracle", "type": "address" }, + { "indexed": true, "internalType": "uint256", "name": "role", "type": "uint256" } + ], + "name": "OracleSet", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "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": false, "internalType": "address", "name": "account", "type": "address" }], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "mainOracle", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "pivotOracle", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "fallbackOracle", "type": "address" } + ], + "name": "TokenConfigAdded", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "address", "name": "account", "type": "address" }], + "name": "Unpaused", + "type": "event" + }, + { + "inputs": [], + "name": "BNB_ADDR", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INVALID_PRICE", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "acceptOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [{ "internalType": "contract IAccessControlManagerV8", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "boundValidator", + "outputs": [{ "internalType": "contract BoundValidatorInterface", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" }, + { "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "enableOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" } + ], + "name": "getOracle", + "outputs": [ + { "internalType": "address", "name": "oracle", "type": "address" }, + { "internalType": "bool", "name": "enabled", "type": "bool" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "getPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "getTokenConfig", + "outputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "vToken", "type": "address" }], + "name": "getUnderlyingPrice", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "accessControlManager_", "type": "address" }], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "pause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "paused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "accessControlManager_", "type": "address" }], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address", "name": "oracle", "type": "address" }, + { "internalType": "enum ResilientOracle.OracleRole", "name": "role", "type": "uint8" } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig", + "name": "tokenConfig", + "type": "tuple" + } + ], + "name": "setTokenConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "asset", "type": "address" }, + { "internalType": "address[3]", "name": "oracles", "type": "address[3]" }, + { "internalType": "bool[3]", "name": "enableFlagsForOracles", "type": "bool[3]" } + ], + "internalType": "struct ResilientOracle.TokenConfig[]", + "name": "tokenConfigs_", + "type": "tuple[]" + } + ], + "name": "setTokenConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { "inputs": [], "name": "unpause", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "asset", "type": "address" }], + "name": "updateAssetPrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "vToken", "type": "address" }], + "name": "updatePrice", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vBnb", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vai", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + } +] diff --git a/simulations/vip-131/vip-131/abi/USDT_ABI.json b/simulations/vip-131/vip-131/abi/USDT_ABI.json new file mode 100644 index 000000000..fe8789439 --- /dev/null +++ b/simulations/vip-131/vip-131/abi/USDT_ABI.json @@ -0,0 +1,139 @@ +[ + { + "inputs": [ + { "internalType": "uint256", "name": "_initialAmount", "type": "uint256" }, + { "internalType": "string", "name": "_tokenName", "type": "string" }, + { "internalType": "uint8", "name": "_decimalUnits", "type": "uint8" }, + { "internalType": "string", "name": "_tokenSymbol", "type": "string" } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "owner", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "spender", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "from", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "Transfer", + "type": "event" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_owner", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" } + ], + "name": "allocateTo", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "_spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { "internalType": "address", "name": "src", "type": "address" }, + { "internalType": "address", "name": "dst", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/simulations/vip-131/vip-131/simulations.ts b/simulations/vip-131/vip-131/simulations.ts index b83ca5b0c..0656908fb 100644 --- a/simulations/vip-131/vip-131/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -1,12 +1,16 @@ import { expect } from "chai"; -import { Signer } from "ethers"; +import { BigNumber, Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; - -import { initMainnetUser } from "../../../src/utils"; +import { initMainnetUser, setMaxStalePeriodInChainlinkOracle } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; -import { vip131 } from "../../../vips/vip-131/vip-131"; +import { FEE_IN, vip131 } from "../../../vips/vip-131/vip-131"; +import { FEE_OUT } from "../../../vips/vip-131/vip-131"; +import { swapStableForVAIAndValidate, swapVAIForStableAndValidate } from "../utils"; import ACM_ABI from "./abi/IAccessControlManager_ABI.json"; +import PSM_ABI from "./abi/PSM_ABI.json"; +import ResilientOracle_ABI from "./abi/ResilientOracle_ABI.json"; +import USDT_ABI from "./abi/USDT_ABI.json"; import VAI_CONTROLLER_ABI from "./abi/VAIController_ABI.json"; import VAI_ABI from "./abi/VAI_ABI.json"; @@ -16,24 +20,46 @@ const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; -const PSM_USDT = "0x93dB3f46e1DC91c2b9D8Bc7443790bB4699c0E81"; +const PSM_USDT = "0xC138aa4E424D1A8539e8F38Af5a754a2B7c3Cc36"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); +const RESILIENT_ORACLE = "0x6592b5DE802159F3E74B2486b091D11a8256ab8A"; +const CHAINLINK_ORACLE = "0x1B2103441A0A108daD8848D8F5d790e4D402921F"; +const USDT = "0x55d398326f99059fF775485246999027B3197955"; +const USDT_PRICE_FEED = "0xb97ad0e74fa7d920791e90258a6e2085088b4320"; // Chainlink Oracle +const STABLE_TOKEN_HOLDER = "0x6a0b3611214d5001fa5efae91b7222a316c12b52"; +const VAI_HOLDER = "0x29aa70f8f3f2aa241b0ba9eaa744c97808d032c9"; -forking(29298113, () => { +forking(30501836, () => { const provider = ethers.provider; let vai: ethers.Contract; let vaiControllerProxy: ethers.Contract; let accessControlManager: ethers.Contract; + let resilientOracle: ethers.Contract; + let usdt: ethers.Contract; + let psm: ethers.Contract; let psmSigner: Signer; + let tokenHolder: Signer; + let vaiHolder: Signer; before(async () => { vai = new ethers.Contract(VAI, VAI_ABI, provider); vaiControllerProxy = new ethers.Contract(VAI_CONTROLLER_PROXY, VAI_CONTROLLER_ABI, provider); accessControlManager = new ethers.Contract(ACM, ACM_ABI, provider); + psm = new ethers.Contract(PSM_USDT, PSM_ABI, provider); + resilientOracle = new ethers.Contract(RESILIENT_ORACLE, ResilientOracle_ABI, provider); + usdt = new ethers.Contract(USDT, USDT_ABI, provider); + psmSigner = await initMainnetUser(PSM_USDT, ethers.utils.parseEther("1")); + tokenHolder = await initMainnetUser(STABLE_TOKEN_HOLDER, ethers.utils.parseEther("1")); + vaiHolder = await initMainnetUser(VAI_HOLDER, ethers.utils.parseEther("1")); + + await setMaxStalePeriodInChainlinkOracle(CHAINLINK_ORACLE, USDT, USDT_PRICE_FEED, NORMAL_TIMELOCK); }); - testVip("VIP-130 Add Peg Stability (USDT)", vip131()); + testVip("VIP-130 Add Peg Stability (USDT)", vip131(), { + proposer: "0xc444949e0054a23c44fc45789738bdf64aed2391", + supporter: "0x55A9f5374Af30E3045FB491f1da3C2E8a74d168D", + }); describe("Post-VIP behavior", async () => { it("Verify PSM_USDT is admin of VAI contract", async () => { const check = await vai.wards(PSM_USDT); @@ -72,5 +98,49 @@ forking(29298113, () => { const currentBaseRate = await vaiControllerProxy.baseRateMantissa(); expect(currentBaseRate).equals(BASE_RATE_MANTISSA); }); + it("Verify feeIn and feeOut", async () => { + expect(await psm.feeIn()).to.equal(FEE_IN); + expect(await psm.feeOut()).to.equal(FEE_OUT); + }); + it("Verify ONE_DOLLAR value", async () => { + const tokenDecimals = await usdt.decimals(); + const expectedValue = parseUnits("1", 36 - tokenDecimals); + expect(await psm.ONE_DOLLAR()).to.equal(expectedValue); + }); + describe("Swaps test: ", () => { + let stableTokenPrice: BigNumber; + let oneDollar: BigNumber; + let tokenDecimals: number; + before(async () => { + stableTokenPrice = await resilientOracle.getPrice(USDT); + tokenDecimals = await usdt.decimals(); + oneDollar = await psm.ONE_DOLLAR(); + }); + it("Verify swapStableForVAI works", async () => { + await swapStableForVAIAndValidate( + psm, + usdt, + stableTokenPrice, + tokenHolder, + STABLE_TOKEN_HOLDER, + vai, + BigNumber.from(FEE_IN), + tokenDecimals, + oneDollar, + ); + }); + it("Verify swapVAIForStable works", async () => { + await swapVAIForStableAndValidate( + psm, + stableTokenPrice, + vai, + vaiHolder, + BigNumber.from(FEE_OUT), + usdt, + tokenDecimals, + oneDollar, + ); + }); + }); }); }); diff --git a/vips/vip-131/vip-131.ts b/vips/vip-131/vip-131.ts index 4cd39fd40..daf91b20f 100644 --- a/vips/vip-131/vip-131.ts +++ b/vips/vip-131/vip-131.ts @@ -3,13 +3,15 @@ import { parseUnits } from "ethers/lib/utils"; import { ProposalType } from "../../src/types"; import { makeProposal } from "../../src/utils"; +export const FEE_OUT = 100; // 10bps +export const FEE_IN = 0; const ACM = "0x4788629ABc6cFCA10F9f969efdEAa1cF70c23555"; const VAI_CONTROLLER_PROXY = "0x004065D34C6b18cE4370ced1CeBDE94865DbFAFE"; const VAI = "0x4BD17003473389A42DAF6a0a729f6Fdb328BbBd7"; const NORMAL_TIMELOCK = "0x939bD8d64c0A9583A7Dcea9933f7b21697ab6396"; const FAST_TRACK_TIMELOCK = "0x555ba73dB1b006F3f2C7dB7126d6e4343aDBce02"; const CRITICAL_TIMELOCK = "0x213c446ec11e45b15a6E29C1C1b402B8897f606d"; -const PSM_USDT = "0x93dB3f46e1DC91c2b9D8Bc7443790bB4699c0E81"; +const PSM_USDT = "0xC138aa4E424D1A8539e8F38Af5a754a2B7c3Cc36"; const BASE_RATE_MANTISSA = parseUnits("2.72", 18); export const vip131 = () => { @@ -94,6 +96,18 @@ export const vip131 = () => { params: [PSM_USDT, "resume()", CRITICAL_TIMELOCK], }, + { + target: PSM_USDT, + signature: "setFeeIn(uint256)", + params: [FEE_IN], + }, + + { + target: PSM_USDT, + signature: "setFeeOut(uint256)", + params: [FEE_OUT], + }, + { target: VAI_CONTROLLER_PROXY, signature: "setBaseRate(uint256)", From f516b49f48d75ebffb5e65129dd995f93729572c Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Mon, 7 Aug 2023 11:54:17 +0300 Subject: [PATCH 12/13] refactor: address PR comments --- simulations/vip-131/vip-131-testnet/simulations.ts | 5 ++++- simulations/vip-131/vip-131/simulations.ts | 7 ++++++- vips/vip-131/vip-131-testnet.ts | 14 +++++++++++++- vips/vip-131/vip-131.ts | 14 +++++++++++++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/simulations/vip-131/vip-131-testnet/simulations.ts b/simulations/vip-131/vip-131-testnet/simulations.ts index 31dcf92e6..846abbd07 100644 --- a/simulations/vip-131/vip-131-testnet/simulations.ts +++ b/simulations/vip-131/vip-131-testnet/simulations.ts @@ -60,6 +60,9 @@ forking(32091802, () => { }); it("Verify access control setup", async () => { + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "pause()")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "resume()")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "pause()")).equals(true); expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "resume()")).equals(true); @@ -80,7 +83,7 @@ forking(32091802, () => { await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)"), ).equals(true); expect( - await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)"), + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setOracle(address)"), ).equals(true); expect( await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)"), diff --git a/simulations/vip-131/vip-131/simulations.ts b/simulations/vip-131/vip-131/simulations.ts index 0656908fb..fedb849f7 100644 --- a/simulations/vip-131/vip-131/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -67,6 +67,11 @@ forking(30501836, () => { }); it("Verify access control setup", async () => { + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "pause()")).equals(true); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "resume()")).equals( + true, + ); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "pause()")).equals(true); expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "resume()")).equals(true); @@ -87,7 +92,7 @@ forking(30501836, () => { await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVaiMintCap(uint256)"), ).equals(true); expect( - await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setComptroller(address)"), + await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setOracle(address)"), ).equals(true); expect( await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "setVenusTreasury(address)"), diff --git a/vips/vip-131/vip-131-testnet.ts b/vips/vip-131/vip-131-testnet.ts index f58d93887..06a06a533 100644 --- a/vips/vip-131/vip-131-testnet.ts +++ b/vips/vip-131/vip-131-testnet.ts @@ -63,7 +63,7 @@ export const vip131Testnet = () => { { target: ACM, signature: "giveCallPermission(address,string,address)", - params: [PSM_USDT, "setComptroller(address)", NORMAL_TIMELOCK], + params: [PSM_USDT, "setOracle(address)", NORMAL_TIMELOCK], }, { @@ -72,6 +72,12 @@ export const vip131Testnet = () => { params: [PSM_USDT, "setVenusTreasury(address)", NORMAL_TIMELOCK], }, + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", NORMAL_TIMELOCK], + }, + { target: ACM, signature: "giveCallPermission(address,string,address)", @@ -84,6 +90,12 @@ export const vip131Testnet = () => { params: [PSM_USDT, "pause()", CRITICAL_TIMELOCK], }, + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", NORMAL_TIMELOCK], + }, + { target: ACM, signature: "giveCallPermission(address,string,address)", diff --git a/vips/vip-131/vip-131.ts b/vips/vip-131/vip-131.ts index daf91b20f..045642ab0 100644 --- a/vips/vip-131/vip-131.ts +++ b/vips/vip-131/vip-131.ts @@ -63,7 +63,7 @@ export const vip131 = () => { { target: ACM, signature: "giveCallPermission(address,string,address)", - params: [PSM_USDT, "setComptroller(address)", NORMAL_TIMELOCK], + params: [PSM_USDT, "setOracle(address)", NORMAL_TIMELOCK], }, { @@ -72,6 +72,12 @@ export const vip131 = () => { params: [PSM_USDT, "setVenusTreasury(address)", NORMAL_TIMELOCK], }, + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "pause()", NORMAL_TIMELOCK], + }, + { target: ACM, signature: "giveCallPermission(address,string,address)", @@ -84,6 +90,12 @@ export const vip131 = () => { params: [PSM_USDT, "pause()", CRITICAL_TIMELOCK], }, + { + target: ACM, + signature: "giveCallPermission(address,string,address)", + params: [PSM_USDT, "resume()", NORMAL_TIMELOCK], + }, + { target: ACM, signature: "giveCallPermission(address,string,address)", From 5df1044518c9fb78a30eaf9edf26988213f8d04c Mon Sep 17 00:00:00 2001 From: 0xLucian <0xluciandev@gmail.com> Date: Mon, 7 Aug 2023 11:54:39 +0300 Subject: [PATCH 13/13] refactor: format code --- simulations/vip-131/vip-131/simulations.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/simulations/vip-131/vip-131/simulations.ts b/simulations/vip-131/vip-131/simulations.ts index fedb849f7..5d513cf84 100644 --- a/simulations/vip-131/vip-131/simulations.ts +++ b/simulations/vip-131/vip-131/simulations.ts @@ -2,6 +2,7 @@ import { expect } from "chai"; import { BigNumber, Signer } from "ethers"; import { parseUnits } from "ethers/lib/utils"; import { ethers } from "hardhat"; + import { initMainnetUser, setMaxStalePeriodInChainlinkOracle } from "../../../src/utils"; import { forking, testVip } from "../../../src/vip-framework"; import { FEE_IN, vip131 } from "../../../vips/vip-131/vip-131"; @@ -68,9 +69,7 @@ forking(30501836, () => { it("Verify access control setup", async () => { expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "pause()")).equals(true); - expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "resume()")).equals( - true, - ); + expect(await accessControlManager.connect(psmSigner).isAllowedToCall(NORMAL_TIMELOCK, "resume()")).equals(true); expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "pause()")).equals(true); expect(await accessControlManager.connect(psmSigner).isAllowedToCall(CRITICAL_TIMELOCK, "resume()")).equals(true);