From d5c1cd2f691afb84b6f4eac4200efde84572796c Mon Sep 17 00:00:00 2001 From: Narayan Prusty Date: Thu, 22 Aug 2024 15:34:30 +0400 Subject: [PATCH] fix: added conversion config --- multisig/proposals/ethereum/vip-055/index.ts | 39 ++ .../ethereum/vip-055/abi/PrimeConverter.json | 587 ++++++++++++++++++ .../ethereum/vip-055/abi/erc20.json | 295 +++++++++ .../simulations/ethereum/vip-055/index.ts | 40 ++ 4 files changed, 961 insertions(+) create mode 100644 multisig/simulations/ethereum/vip-055/abi/PrimeConverter.json create mode 100644 multisig/simulations/ethereum/vip-055/abi/erc20.json diff --git a/multisig/proposals/ethereum/vip-055/index.ts b/multisig/proposals/ethereum/vip-055/index.ts index b22e7c799..18fba0512 100644 --- a/multisig/proposals/ethereum/vip-055/index.ts +++ b/multisig/proposals/ethereum/vip-055/index.ts @@ -14,6 +14,18 @@ export const vweETHs = "0xEF26C64bC06A8dE4CA5D31f119835f9A1d9433b9"; export const LIQUID_STAKED_COMPTROLLER = "0xF522cd0360EF8c2FF48B648d53EA1717Ec0F3Ac3"; export const VTOKEN_RECEIVER = "0x86fBaEB3D6b5247F420590D303a6ffC9cd523790"; const { ethereum } = NETWORK_ADDRESSES; +export const USDT_PRIME_CONVERTER = "0x4f55cb0a24D5542a3478B0E284259A6B850B06BD"; +export const USDC_PRIME_CONVERTER = "0xcEB9503f10B781E30213c0b320bCf3b3cE54216E"; +export const WBTC_PRIME_CONVERTER = "0xDcCDE673Cd8988745dA384A7083B0bd22085dEA0"; +export const WETH_PRIME_CONVERTER = "0xb8fD67f215117FADeF06447Af31590309750529D"; +export const XVS_VAULT_CONVERTER = "0x1FD30e761C3296fE36D9067b1e398FD97B4C0407"; +export const BaseAssets = [ + "0xdAC17F958D2ee523a2206206994597C13D831ec7", // USDT USDTTokenConverter BaseAsset + "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC USDCTokenConverter BaseAsset + "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599", // WBTC WBTCTokenConverter BaseAsset + "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH WETHTokenConverter BaseAsset + "0xd3CC9d8f3689B83c91b7B59cAB4946B063EB894A", // XVS XVSTokenConverter BaseAsset +]; export const vip055 = () => { return makeProposal([ @@ -62,6 +74,33 @@ export const vip055 = () => { signature: "setActionsPaused(address[],uint8[],bool)", params: [[vweETHs], [2], true], }, + + // Conversion config + { + target: USDT_PRIME_CONVERTER, + signature: "setConversionConfigs(address,address[],(uint256,uint8)[])", + params: [BaseAssets[0], [weETHs], [[0, 1]]], + }, + { + target: USDC_PRIME_CONVERTER, + signature: "setConversionConfigs(address,address[],(uint256,uint8)[])", + params: [BaseAssets[1], [weETHs], [[0, 1]]], + }, + { + target: WBTC_PRIME_CONVERTER, + signature: "setConversionConfigs(address,address[],(uint256,uint8)[])", + params: [BaseAssets[2], [weETHs], [[0, 1]]], + }, + { + target: WETH_PRIME_CONVERTER, + signature: "setConversionConfigs(address,address[],(uint256,uint8)[])", + params: [BaseAssets[3], [weETHs], [[0, 1]]], + }, + { + target: XVS_VAULT_CONVERTER, + signature: "setConversionConfigs(address,address[],(uint256,uint8)[])", + params: [BaseAssets[4], [weETHs], [[0, 1]]], + }, ]); }; diff --git a/multisig/simulations/ethereum/vip-055/abi/PrimeConverter.json b/multisig/simulations/ethereum/vip-055/abi/PrimeConverter.json new file mode 100644 index 000000000..cb4a3fc03 --- /dev/null +++ b/multisig/simulations/ethereum/vip-055/abi/PrimeConverter.json @@ -0,0 +1,587 @@ +[ + { "inputs": [], "stateMutability": "nonpayable", "type": "constructor" }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMaxMantissa", "type": "uint256" } + ], + "name": "AmountInHigherThanMax", + "type": "error" + }, + { "inputs": [], "name": "AmountInMismatched", "type": "error" }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMinMantissa", "type": "uint256" } + ], + "name": "AmountOutLowerThanMinRequired", + "type": "error" + }, + { "inputs": [], "name": "AmountOutMismatched", "type": "error" }, + { "inputs": [], "name": "ConversionConfigNotEnabled", "type": "error" }, + { "inputs": [], "name": "ConversionEnabledOnlyForPrivateConversions", "type": "error" }, + { "inputs": [], "name": "ConversionTokensActive", "type": "error" }, + { "inputs": [], "name": "ConversionTokensPaused", "type": "error" }, + { "inputs": [], "name": "DeflationaryTokenNotSupported", "type": "error" }, + { + "inputs": [ + { "internalType": "uint256", "name": "incentive", "type": "uint256" }, + { "internalType": "uint256", "name": "maxIncentive", "type": "uint256" } + ], + "name": "IncentiveTooHigh", + "type": "error" + }, + { "inputs": [], "name": "InputLengthMisMatch", "type": "error" }, + { "inputs": [], "name": "InsufficientInputAmount", "type": "error" }, + { "inputs": [], "name": "InsufficientOutputAmount", "type": "error" }, + { "inputs": [], "name": "InsufficientPoolLiquidity", "type": "error" }, + { "inputs": [], "name": "InvalidConverterNetwork", "type": "error" }, + { "inputs": [], "name": "InvalidMinimumAmountToConvert", "type": "error" }, + { "inputs": [], "name": "InvalidToAddress", "type": "error" }, + { "inputs": [], "name": "InvalidTokenConfigAddresses", "type": "error" }, + { "inputs": [], "name": "NonZeroIncentiveForPrivateConversion", "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": "ZeroAddressNotAllowed", "type": "error" }, + { "inputs": [], "name": "ZeroValueNotAllowed", "type": "error" }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "receiver", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "comptroller", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "asset", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "AssetTransferredToDestination", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "oldBaseAsset", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "newBaseAsset", "type": "address" } + ], + "name": "BaseAssetUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "oldIncentive", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newIncentive", "type": "uint256" }, + { + "indexed": false, + "internalType": "enum IAbstractTokenConverter.ConversionAccessibility", + "name": "oldAccess", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "enum IAbstractTokenConverter.ConversionAccessibility", + "name": "newAccess", + "type": "uint8" + } + ], + "name": "ConversionConfigUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], + "name": "ConversionPaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": true, "internalType": "address", "name": "sender", "type": "address" }], + "name": "ConversionResumed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "receiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "name": "ConvertedExactTokens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "receiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "name": "ConvertedExactTokensSupportingFeeOnTransferTokens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "receiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "name": "ConvertedForExactTokens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "receiver", "type": "address" }, + { "indexed": false, "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "name": "ConvertedForExactTokensSupportingFeeOnTransferTokens", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "oldConverterNetwork", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "converterNetwork", "type": "address" } + ], + "name": "ConverterNetworkAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "oldDestinationAddress", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "destinationAddress", "type": "address" } + ], + "name": "DestinationAddressUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [{ "indexed": false, "internalType": "uint8", "name": "version", "type": "uint8" }], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": false, "internalType": "uint256", "name": "oldMinAmountToConvert", "type": "uint256" }, + { "indexed": false, "internalType": "uint256", "name": "newMinAmountToConvert", "type": "uint256" } + ], + "name": "MinAmountToConvertUpdated", + "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": "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": "contract ResilientOracle", "name": "oldPriceOracle", "type": "address" }, + { "indexed": true, "internalType": "contract ResilientOracle", "name": "priceOracle", "type": "address" } + ], + "name": "PriceOracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "address", "name": "token", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "to", "type": "address" }, + { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "SweepToken", + "type": "event" + }, + { + "inputs": [], + "name": "MAX_INCENTIVE", + "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": [{ "internalType": "address", "name": "tokenAddress", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "tokenBalance", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseAsset", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "conversionConfigurations", + "outputs": [ + { "internalType": "uint256", "name": "incentive", "type": "uint256" }, + { + "internalType": "enum IAbstractTokenConverter.ConversionAccessibility", + "name": "conversionAccess", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "conversionPaused", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMinMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "convertExactTokens", + "outputs": [ + { "internalType": "uint256", "name": "actualAmountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "actualAmountOut", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMinMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "convertExactTokensSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "actualAmountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "actualAmountOut", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMaxMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "convertForExactTokens", + "outputs": [ + { "internalType": "uint256", "name": "actualAmountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "actualAmountOut", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMaxMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" } + ], + "name": "convertForExactTokensSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "actualAmountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "actualAmountOut", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "converterNetwork", + "outputs": [{ "internalType": "contract IConverterNetwork", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "destinationAddress", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" } + ], + "name": "getAmountIn", + "outputs": [ + { "internalType": "uint256", "name": "amountConvertedMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" } + ], + "name": "getAmountOut", + "outputs": [ + { "internalType": "uint256", "name": "amountConvertedMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" } + ], + "name": "getUpdatedAmountIn", + "outputs": [ + { "internalType": "uint256", "name": "amountConvertedMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountInMantissa", "type": "uint256" }, + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" } + ], + "name": "getUpdatedAmountOut", + "outputs": [ + { "internalType": "uint256", "name": "amountConvertedMantissa", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMantissa", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "accessControlManager_", "type": "address" }, + { "internalType": "contract ResilientOracle", "name": "priceOracle_", "type": "address" }, + { "internalType": "address", "name": "destinationAddress_", "type": "address" }, + { "internalType": "address", "name": "baseAsset_", "type": "address" }, + { "internalType": "uint256", "name": "minAmountToConvert_", "type": "uint256" } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "minAmountToConvert", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "pauseConversion", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "priceOracle", + "outputs": [{ "internalType": "contract ResilientOracle", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { "inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { "inputs": [], "name": "resumeConversion", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, + { + "inputs": [{ "internalType": "address", "name": "accessControlManager_", "type": "address" }], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "baseAsset_", "type": "address" }], + "name": "setBaseAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address", "name": "tokenAddressOut", "type": "address" }, + { + "components": [ + { "internalType": "uint256", "name": "incentive", "type": "uint256" }, + { + "internalType": "enum IAbstractTokenConverter.ConversionAccessibility", + "name": "conversionAccess", + "type": "uint8" + } + ], + "internalType": "struct IAbstractTokenConverter.ConversionConfig", + "name": "conversionConfig", + "type": "tuple" + } + ], + "name": "setConversionConfig", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddressIn", "type": "address" }, + { "internalType": "address[]", "name": "tokenAddressesOut", "type": "address[]" }, + { + "components": [ + { "internalType": "uint256", "name": "incentive", "type": "uint256" }, + { + "internalType": "enum IAbstractTokenConverter.ConversionAccessibility", + "name": "conversionAccess", + "type": "uint8" + } + ], + "internalType": "struct IAbstractTokenConverter.ConversionConfig[]", + "name": "conversionConfigs", + "type": "tuple[]" + } + ], + "name": "setConversionConfigs", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "contract IConverterNetwork", "name": "converterNetwork_", "type": "address" }], + "name": "setConverterNetwork", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "destinationAddress_", "type": "address" }], + "name": "setDestination", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "uint256", "name": "minAmountToConvert_", "type": "uint256" }], + "name": "setMinAmountToConvert", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "contract ResilientOracle", "name": "priceOracle_", "type": "address" }], + "name": "setPriceOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenAddress", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "comptroller", "type": "address" }, + { "internalType": "address", "name": "asset", "type": "address" } + ], + "name": "updateAssetsState", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/multisig/simulations/ethereum/vip-055/abi/erc20.json b/multisig/simulations/ethereum/vip-055/abi/erc20.json new file mode 100644 index 000000000..19f45adca --- /dev/null +++ b/multisig/simulations/ethereum/vip-055/abi/erc20.json @@ -0,0 +1,295 @@ +[ + { + "inputs": [ + { "internalType": "string", "name": "name_", "type": "string" }, + { "internalType": "string", "name": "symbol_", "type": "string" } + ], + "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": false, "internalType": "address", "name": "userAddress", "type": "address" }, + { "indexed": false, "internalType": "address payable", "name": "relayerAddress", "type": "address" }, + { "indexed": false, "internalType": "bytes", "name": "functionSignature", "type": "bytes" } + ], + "name": "MetaTransactionExecuted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "previousAdminRole", "type": "bytes32" }, + { "indexed": true, "internalType": "bytes32", "name": "newAdminRole", "type": "bytes32" } + ], + "name": "RoleAdminChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleGranted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { "indexed": true, "internalType": "bytes32", "name": "role", "type": "bytes32" }, + { "indexed": true, "internalType": "address", "name": "account", "type": "address" }, + { "indexed": true, "internalType": "address", "name": "sender", "type": "address" } + ], + "name": "RoleRevoked", + "type": "event" + }, + { + "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" + }, + { + "inputs": [], + "name": "DEFAULT_ADMIN_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "ERC712_VERSION", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PREDICATE_ROLE", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "subtractedValue", "type": "uint256" } + ], + "name": "decreaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "userAddress", "type": "address" }, + { "internalType": "bytes", "name": "functionSignature", "type": "bytes" }, + { "internalType": "bytes32", "name": "sigR", "type": "bytes32" }, + { "internalType": "bytes32", "name": "sigS", "type": "bytes32" }, + { "internalType": "uint8", "name": "sigV", "type": "uint8" } + ], + "name": "executeMetaTransaction", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "getChainId", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "getDomainSeperator", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], + "name": "getNonce", + "outputs": [{ "internalType": "uint256", "name": "nonce", "type": "uint256" }], + "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": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "getRoleMember", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes32", "name": "role", "type": "bytes32" }], + "name": "getRoleMemberCount", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "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": "spender", "type": "address" }, + { "internalType": "uint256", "name": "addedValue", "type": "uint256" } + ], + "name": "increaseAllowance", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "user", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "mint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "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": "bytes32", "name": "role", "type": "bytes32" }, + { "internalType": "address", "name": "account", "type": "address" } + ], + "name": "revokeRole", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "sender", "type": "address" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/multisig/simulations/ethereum/vip-055/index.ts b/multisig/simulations/ethereum/vip-055/index.ts index 74766b4a1..2eafa4317 100644 --- a/multisig/simulations/ethereum/vip-055/index.ts +++ b/multisig/simulations/ethereum/vip-055/index.ts @@ -17,22 +17,37 @@ import { vip055, vweETHs, weETHs, + BaseAssets, + USDT_PRIME_CONVERTER } from "../../../proposals/ethereum/vip-055"; import POOL_REGISTRY_ABI from "./abi/PoolRegistry.json"; import RESILIENT_ORACLE_ABI from "./abi/ResilientOracle.json"; import COMPTROLLER_ABI from "./abi/comptroller.json"; import VTOKEN_ABI from "./abi/vToken.json"; +import ERC20_ABI from "./abi/erc20.json"; +import PRIME_CONVERTER_ABI from "./abi/PrimeConverter.json"; const { ethereum } = NETWORK_ADDRESSES; const PROTOCOL_SHARE_RESERVE = "0x8c8c8530464f7D95552A11eC31Adbd4dC4AC4d3E"; +const USDT_USER = "0xF977814e90dA44bFA03b6295A0616a897441aceC"; +const weETHs_USER = "0x9e8f10574ACc2c62C6e5d19500CEd39163Da37A9"; forking(20583543, async () => { let resilientOracle: Contract; let poolRegistry: Contract; let vweETHsContract: Contract; let comptroller: Contract; + let usdt: Contract; + let usdtPrimeConverter: Contract; + let weETHsContract: Contract; before(async () => { + await impersonateAccount(USDT_USER); + await impersonateAccount(weETHs_USER); + await impersonateAccount(ethereum.GUARDIAN); + await setBalance(USDT_USER, parseUnits("1000", 18)); + await setBalance(weETHs_USER, parseUnits("1000", 18)); + await impersonateAccount(ethereum.NORMAL_TIMELOCK); await setBalance(ethereum.NORMAL_TIMELOCK, parseUnits("1000", 18)); @@ -40,6 +55,9 @@ forking(20583543, async () => { poolRegistry = await ethers.getContractAt(POOL_REGISTRY_ABI, ethereum.POOL_REGISTRY); vweETHsContract = await ethers.getContractAt(VTOKEN_ABI, vweETHs); comptroller = await ethers.getContractAt(COMPTROLLER_ABI, LIQUID_STAKED_COMPTROLLER); + usdt = await ethers.getContractAt(ERC20_ABI, BaseAssets[0], await ethers.provider.getSigner(USDT_USER)); + usdtPrimeConverter = await ethers.getContractAt(PRIME_CONVERTER_ABI, USDT_PRIME_CONVERTER); + weETHsContract = await ethers.getContractAt(ERC20_ABI, weETHs, await ethers.provider.getSigner(weETHs_USER)); }); describe("Pre-VIP behavior", () => { @@ -131,5 +149,27 @@ forking(20583543, async () => { it("borrow paused", async () => { expect(await comptroller.actionPaused(vweETHs, 2)).to.be.true; }); + + it("weETHs conversion", async () => { + const usdtAmount = parseUnits("10", 6); + await usdt.transfer(ethereum.GUARDIAN, usdtAmount); + await usdt.connect(await ethers.getSigner(ethereum.GUARDIAN)).approve(usdtPrimeConverter.address, usdtAmount); + + const weETHsAmount = parseUnits("0.001", 18); + await weETHsContract.transfer(usdtPrimeConverter.address, weETHsAmount); + + const usdtBalanceBefore = await usdt.balanceOf(ethereum.GUARDIAN); + const weETHsBalanceBefore = await weETHsContract.balanceOf(ethereum.GUARDIAN); + + await usdtPrimeConverter + .connect(await ethers.getSigner(ethereum.GUARDIAN)) + .convertForExactTokens(usdtAmount, weETHsAmount, usdt.address, weETHsContract.address, ethereum.GUARDIAN); + + const usdtBalanceAfter = await usdt.balanceOf(ethereum.GUARDIAN); + const weETHsBalanceAfter = await weETHsContract.balanceOf(ethereum.GUARDIAN); + + expect(usdtBalanceBefore.sub(usdtBalanceAfter)).to.be.equal(parseUnits("2.638021", 6)); + expect(weETHsBalanceAfter.sub(weETHsBalanceBefore)).to.be.equal(weETHsAmount); + }); }); });