Last commit before tests

Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
AlienTornadosaurusHex 2023-06-09 19:23:15 +00:00
parent 19f7d15c6f
commit a8e09194ec
3 changed files with 30 additions and 17 deletions

@ -45,10 +45,9 @@ contract CRVUSDInstancesProposal {
FeeOracleManager public constant feeOracleManager = FeeOracleManager public constant feeOracleManager =
FeeOracleManager(0x5f6c97C6AD7bdd0AE7E0Dd4ca33A4ED3fDabD4D7); FeeOracleManager(0x5f6c97C6AD7bdd0AE7E0Dd4ca33A4ED3fDabD4D7);
/* @dev This is the address of the Uniswap V3 Oracle which we will use for all of our traditional /* @dev This is the Uniswap V3 Oracle which we will use for all of our traditional instances, but it will
instances, but it will also help the Curve instances, the former must have been deployed with the address also help the Curve instances, the former must have been deployed with the address of this */
of this */ UniswapV3FeeOracle public immutable v3FeeOracle;
address public immutable deployedUniswapV3FeeOracleAddress;
/* @dev This is the CurveFeeOracle contract which will be deployed beforehand and which will be able to /* @dev This is the CurveFeeOracle contract which will be deployed beforehand and which will be able to
use multiple Curve pools as oracles, at once. */ use multiple Curve pools as oracles, at once. */
@ -58,7 +57,7 @@ contract CRVUSDInstancesProposal {
constructor(address _deployedCurveFeeOracleAddress, address _deployedUniswapV3FeeOracleAddress) public { constructor(address _deployedCurveFeeOracleAddress, address _deployedUniswapV3FeeOracleAddress) public {
curveFeeOracle = CurveFeeOracle(_deployedCurveFeeOracleAddress); curveFeeOracle = CurveFeeOracle(_deployedCurveFeeOracleAddress);
deployedUniswapV3FeeOracleAddress = _deployedUniswapV3FeeOracleAddress; v3FeeOracle = UniswapV3FeeOracle(_deployedUniswapV3FeeOracleAddress);
} }
/** /**
@ -75,7 +74,7 @@ contract CRVUSDInstancesProposal {
// Ok, first add the Uniswap V3 Oracle to the contract // Ok, first add the Uniswap V3 Oracle to the contract
curveFeeOracle.setUniswapV3FeeOracle(UniswapV3FeeOracle(deployedUniswapV3FeeOracleAddress)); curveFeeOracle.setUniswapV3FeeOracle(v3FeeOracle);
// Then, add necessary oracles for the CRVUSD price, to the CurveFeeOracle // Then, add necessary oracles for the CRVUSD price, to the CurveFeeOracle
@ -118,7 +117,7 @@ contract CRVUSDInstancesProposal {
* (...pool contracts as oracles) ===(`price_oracle`)===> CurveFeeOracle ===(`getFee()`)===> * (...pool contracts as oracles) ===(`price_oracle`)===> CurveFeeOracle ===(`getFee()`)===>
* FeeOracleManager ===(`instanceFeeWithUpdate`)===> RelayerRegistry * FeeOracleManager ===(`instanceFeeWithUpdate`)===> RelayerRegistry
*/ */
function _setCurveFeeChainedOracleForInstance(CurveFeeOracle feeOracle, ITornadoInstance _instance) function _setCurveFeeChainedOracleForInstance(CurveFeeOracle _feeOracle, ITornadoInstance _instance)
internal internal
{ {
// Add the oracles which are the USDC/CRVUSD stableswap and tricryptoUSDC pools // Add the oracles which are the USDC/CRVUSD stableswap and tricryptoUSDC pools
@ -143,10 +142,10 @@ contract CRVUSDInstancesProposal {
_coins[1] = 1; // ETHER _coins[1] = 1; // ETHER
// In order to receive the CRVUSD price, its price in USDC must be read out (the USDC price in crvUSD // In order to receive the CRVUSD price, its price in USDC must be read out (the USDC price in crvUSD
// is worthless because we do not have a common denominator then) and then the second price must be // is worthless because we do not have a common denominator in the oracle then) and then the second
// inverted to receive the accurate ETH/CRVUSD price, meaning ETH per CRVUSD, which will then be // price must be inverted to receive the accurate ETH/CRVUSD price, meaning ETH per CRVUSD, which will
// divided by ETH per TORN, and then (ETH/CRVUSD)/(ETH/TORN) = (ETH/CRVUSD)*(TORN/ETH) = (TORN/CRVUSD) // then be divided by ETH per TORN, and then (ETH/CRVUSD)/(ETH/TORN) = (ETH/CRVUSD)*(TORN/ETH) =
// which is the price that the oracle should be supplying // (TORN/CRVUSD) which is the price that the oracle should be supplying
bool[] memory _invert = new bool[](2); bool[] memory _invert = new bool[](2);
@ -155,7 +154,7 @@ contract CRVUSDInstancesProposal {
// (USDC/CRVUSD)*(ETH/USDC) = (ETH/CRVUSD) // (USDC/CRVUSD)*(ETH/USDC) = (ETH/CRVUSD)
feeOracle.modifyChainedOracleForInstance( _feeOracle.modifyChainedOracleForInstance(
_instance, _oracles, _selectors, _coins, _invert, "ETH/CRVUSD" _instance, _oracles, _selectors, _coins, _invert, "ETH/CRVUSD"
); );
} }

@ -37,6 +37,9 @@ contract InfrastructureUpgradeProposal {
/* @dev The address of the current InstanceRegistry proxy, this will also be upgraded */ /* @dev The address of the current InstanceRegistry proxy, this will also be upgraded */
address payable public constant instanceRegistryProxyAddress = 0xB20c66C4DE72433F3cE747b58B86830c459CA911; address payable public constant instanceRegistryProxyAddress = 0xB20c66C4DE72433F3cE747b58B86830c459CA911;
/* @dev The address of the current RelayerRegistry proxy, this won't be upgraded */
address payable public constant relayerRegistryProxyAddress = 0x58E8dCC13BE9780fC42E8723D8EaD4CF46943dF2;
/* @dev This is the Uniswap V3 Oracle which we will use for all of our traditional instances, but it will /* @dev This is the Uniswap V3 Oracle which we will use for all of our traditional instances, but it will
also help the CurveFeeOracle, the former must have been deployed witht the address of this */ also help the CurveFeeOracle, the former must have been deployed witht the address of this */
address public immutable deployedUniswapV3FeeOracleAddress; address public immutable deployedUniswapV3FeeOracleAddress;
@ -68,6 +71,15 @@ contract InfrastructureUpgradeProposal {
* @dev This function also executes further internal functions inlined below. * @dev This function also executes further internal functions inlined below.
*/ */
function executeProposal() external { function executeProposal() external {
// We need to prepare the new TornadoRouter contract by setting the instance registry and relayer
// registry addresses.
TornadoRouter router = TornadoRouter(deployedTornadoRouterAddress);
router.initialize(instanceRegistryProxyAddress, relayerRegistryProxyAddress);
// We also now need to upgrade the InstanceRegistry proxy and the FeeManager proxy
// Upgrade FeeManager (V1) Proxy to FeeOracleManager (V2) // Upgrade FeeManager (V1) Proxy to FeeOracleManager (V2)
AdminUpgradeableProxy(feeManagerProxyAddress).upgradeTo(deployedFeeOracleManagerImplementationAddress); AdminUpgradeableProxy(feeManagerProxyAddress).upgradeTo(deployedFeeOracleManagerImplementationAddress);
@ -97,9 +109,7 @@ contract InfrastructureUpgradeProposal {
// instances which isn't mutable for them, instead only determined for each. The new Tornado Router is // instances which isn't mutable for them, instead only determined for each. The new Tornado Router is
// also set. // also set.
InstanceRegistry(instanceRegistryProxyAddress).initialize( InstanceRegistry(instanceRegistryProxyAddress).initialize(_getAllInstances(), router);
_getAllInstances(), TornadoRouter(deployedTornadoRouterAddress)
);
// The Uniswap V3 Fee Oracle also needs global data like the old FeeManager (Uniswap V3 functionality // The Uniswap V3 Fee Oracle also needs global data like the old FeeManager (Uniswap V3 functionality
// has now been split out) did, the legacy data will be used and in this version also the minimum // has now been split out) did, the legacy data will be used and in this version also the minimum

@ -165,10 +165,14 @@ contract FeeOracleManager is FeeManagerLegacyStorage, Initializable {
// Now update if we do not respect the interval or we respect it and are in the interval // Now update if we do not respect the interval or we respect it and are in the interval
if (!_respectFeeUpdateInterval || (feeUpdateInterval < -feeData.lastUpdated + now)) { if (!_respectFeeUpdateInterval || (feeUpdateInterval < -feeData.lastUpdated + now)) {
IFeeOracle oracle = instanceFeeOracles[_instance];
// Check whether the instance is registered
require(address(oracle) != address(0), "FeeOracleManager: instance has no oracle");
// There must a be a fee set otherwise it's just 0 // There must a be a fee set otherwise it's just 0
if (feeData.feePercent != 0) { if (feeData.feePercent != 0) {
// This will revert if no contract is set feeData.feeAmount = oracle.getFee(
feeData.feeAmount = instanceFeeOracles[_instance].getFee(
torn, torn,
_instance, _instance,
instanceRegistry.getInstanceData(_instance), instanceRegistry.getInstanceData(_instance),