Proposals can execute
Signed-off-by: AlienTornadosaurusHex <>
This commit is contained in:
parent
827e1d6991
commit
60be3e5936
@ -18,7 +18,7 @@ import { FeeOracleManager } from "../v2/FeeOracleManager.sol";
|
||||
|
||||
import { InstanceRegistry } from "../v2/InstanceRegistry.sol";
|
||||
|
||||
import { UniswapV3FeeOracle } from "../v2/UniswapV3FeeOracle.sol";
|
||||
import { UniswapV3FeeOracle, UniswapV3OracleHelper } from "../v2/UniswapV3FeeOracle.sol";
|
||||
|
||||
import { TornadoRouter } from "../v2/TornadoRouter.sol";
|
||||
|
||||
@ -113,9 +113,9 @@ contract InfrastructureUpgradeProposal {
|
||||
|
||||
// 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
|
||||
// observation cardinality for Uniswap V3 pools is set, it'll be a value that most pools can supply
|
||||
// and in general if it is too strict a proposal adding instances can also just set it to a lower
|
||||
// value, kind of gamey, but just to "enforce" some constraint or inform the user one exists
|
||||
// observation cardinality for Uniswap V3 pools is used, but we're only setting that after adding the
|
||||
// legacy cDAI pools which are in a kind of stupid liquidity condition, in any case there is a small
|
||||
// amount of funds in there so let's add them too
|
||||
|
||||
UniswapV3FeeOracle v3FeeOracle = UniswapV3FeeOracle(deployedUniswapV3FeeOracleAddress);
|
||||
|
||||
@ -123,7 +123,7 @@ contract InfrastructureUpgradeProposal {
|
||||
|
||||
v3FeeOracle.setGlobalTwapIntervalSeconds(5400); // Legacy value, still makes sense
|
||||
|
||||
v3FeeOracle.setGlobalMinObservationCardinality(10); // TODO: Check the value
|
||||
v3FeeOracle.setGlobalMinObservationCardinality(1); // Set it to minimum so cDAI passes
|
||||
|
||||
// Each of the instances are going to require a Uniswap Pool Fee to be set such that we actually know
|
||||
// what pools to lookup when querying for Oracle data. This data has also been read out from the
|
||||
@ -132,17 +132,18 @@ contract InfrastructureUpgradeProposal {
|
||||
// been recorded in the (first) legacy initialization above
|
||||
|
||||
_setAllInstancePoolFeesInOracle(v3FeeOracle);
|
||||
|
||||
v3FeeOracle.setGlobalMinObservationCardinality(10); // Now set the cardinality to a reasonable value
|
||||
}
|
||||
|
||||
function _setAllInstancePoolFeesInOracle(UniswapV3FeeOracle _v3FeeOracle) internal {
|
||||
ITornadoInstance[] memory instances = _getAllInstances();
|
||||
|
||||
IERC20 weth = IERC20(instances[0].token());
|
||||
IERC20 weth = IERC20(UniswapV3OracleHelper.WETH);
|
||||
IERC20 dai = IERC20(instances[4].token());
|
||||
IERC20 cdai = IERC20(instances[8].token());
|
||||
IERC20 usdc = IERC20(instances[12].token());
|
||||
IERC20 usdt = IERC20(instances[14].token());
|
||||
IERC20 wbtc = IERC20(instances[16].token());
|
||||
IERC20 usdt = IERC20(instances[12].token());
|
||||
IERC20 wbtc = IERC20(instances[14].token());
|
||||
|
||||
/* ETH instances */
|
||||
_v3FeeOracle.setPoolFeeForToken(weth, uint24(0x000));
|
||||
@ -162,10 +163,6 @@ contract InfrastructureUpgradeProposal {
|
||||
_v3FeeOracle.setPoolFeeForToken(cdai, uint24(0xbb8));
|
||||
_v3FeeOracle.setPoolFeeForToken(cdai, uint24(0xbb8));
|
||||
|
||||
/* USDC instances */
|
||||
_v3FeeOracle.setPoolFeeForToken(usdc, uint24(0x1f4));
|
||||
_v3FeeOracle.setPoolFeeForToken(usdc, uint24(0x1f4));
|
||||
|
||||
/* USDT instances */
|
||||
_v3FeeOracle.setPoolFeeForToken(usdt, uint24(0x1f4));
|
||||
_v3FeeOracle.setPoolFeeForToken(usdt, uint24(0x1f4));
|
||||
@ -177,7 +174,7 @@ contract InfrastructureUpgradeProposal {
|
||||
}
|
||||
|
||||
function _getAllInstances() internal pure returns (ITornadoInstance[] memory _addresses) {
|
||||
_addresses = new ITornadoInstance[](19);
|
||||
_addresses = new ITornadoInstance[](17);
|
||||
|
||||
/* ETH instances */
|
||||
_addresses[0] = ITornadoInstance(0x12D66f87A04A9E220743712cE6d9bB1B5616B8Fc);
|
||||
@ -197,22 +194,18 @@ contract InfrastructureUpgradeProposal {
|
||||
_addresses[10] = ITornadoInstance(0x2717c5e28cf931547B621a5dddb772Ab6A35B701);
|
||||
_addresses[11] = ITornadoInstance(0xD21be7248e0197Ee08E0c20D4a96DEBdaC3D20Af);
|
||||
|
||||
/* USDC instances */
|
||||
_addresses[12] = ITornadoInstance(0xd96f2B1c14Db8458374d9Aca76E26c3D18364307);
|
||||
_addresses[13] = ITornadoInstance(0x4736dCf1b7A3d580672CcE6E7c65cd5cc9cFBa9D);
|
||||
|
||||
/* USDT instances */
|
||||
_addresses[14] = ITornadoInstance(0x169AD27A470D064DEDE56a2D3ff727986b15D52B);
|
||||
_addresses[15] = ITornadoInstance(0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f);
|
||||
_addresses[12] = ITornadoInstance(0x169AD27A470D064DEDE56a2D3ff727986b15D52B);
|
||||
_addresses[13] = ITornadoInstance(0x0836222F2B2B24A3F36f98668Ed8F0B38D1a872f);
|
||||
|
||||
/* WBTC instances */
|
||||
_addresses[16] = ITornadoInstance(0x178169B423a011fff22B9e3F3abeA13414dDD0F1);
|
||||
_addresses[17] = ITornadoInstance(0x610B717796ad172B316836AC95a2ffad065CeaB4);
|
||||
_addresses[18] = ITornadoInstance(0xbB93e510BbCD0B7beb5A853875f9eC60275CF498);
|
||||
_addresses[14] = ITornadoInstance(0x178169B423a011fff22B9e3F3abeA13414dDD0F1);
|
||||
_addresses[15] = ITornadoInstance(0x610B717796ad172B316836AC95a2ffad065CeaB4);
|
||||
_addresses[16] = ITornadoInstance(0xbB93e510BbCD0B7beb5A853875f9eC60275CF498);
|
||||
}
|
||||
|
||||
function _getAllInstanceFeePercents() internal pure returns (uint256[] memory _percents) {
|
||||
_percents = new uint256[](19);
|
||||
_percents = new uint256[](17);
|
||||
|
||||
/* ETH instances */
|
||||
_percents[0] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
@ -229,20 +222,16 @@ contract InfrastructureUpgradeProposal {
|
||||
/* cDAI instances */
|
||||
_percents[8] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[9] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[10] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[11] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[12] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
|
||||
/* USDC instances */
|
||||
_percents[13] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[14] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
|
||||
/* USDT instances */
|
||||
_percents[15] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[16] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[12] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
_percents[13] = uint256(0x0000000000000000000000000000000000000000000000000000000000000000);
|
||||
|
||||
/* WBTC instances */
|
||||
_percents[17] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
_percents[18] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
_percents[19] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
_percents[14] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
_percents[15] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
_percents[16] = uint256(0x000000000000000000000000000000000000000000000000000000000000001e);
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,8 @@ contract FeeOracleManager is FeeManagerLegacyStorage, Initializable {
|
||||
function initialize(
|
||||
address _uniswapV3FeeOracle,
|
||||
address _instanceRegistryAddress,
|
||||
ITornadoInstance[] calldata _instances,
|
||||
uint256[] calldata _feePercents
|
||||
ITornadoInstance[] memory _instances,
|
||||
uint256[] memory _feePercents
|
||||
) external onlyGovernance initializer {
|
||||
// Get num of existing instances
|
||||
uint256 numInstances = _instances.length;
|
||||
|
@ -118,11 +118,12 @@ contract InstanceRegistry is InstanceRegistryLegacyStorage, EnsResolve, Initiali
|
||||
{
|
||||
uint256 numInstances = _instances.length;
|
||||
|
||||
// Router must be initialized before otherwise below will fail
|
||||
router = _router;
|
||||
|
||||
for (uint256 i = 0; i < numInstances; i++) {
|
||||
addInstance(_instances[i]);
|
||||
}
|
||||
|
||||
router = _router;
|
||||
}
|
||||
|
||||
function addInstance(ITornadoInstance _instance) public virtual onlyGovernance {
|
||||
|
@ -7,9 +7,11 @@ pragma experimental ABIEncoderV2;
|
||||
|
||||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
// Local imports
|
||||
// STD Imports
|
||||
|
||||
import { InfrastructureUpgradeProposal } from "src/proposals/InfrastructureUpgradeProposal.sol";
|
||||
import { console2 } from "forge-std/console2.sol";
|
||||
|
||||
// Local imports
|
||||
|
||||
import { UniswapV3FeeOracle } from "src/v2/UniswapV3FeeOracle.sol";
|
||||
|
||||
@ -21,19 +23,25 @@ import { FeeOracleManager } from "src/v2/FeeOracleManager.sol";
|
||||
|
||||
import { TornadoRouter } from "src/v2/TornadoRouter.sol";
|
||||
|
||||
import { InfrastructureUpgradeProposal } from "src/proposals/InfrastructureUpgradeProposal.sol";
|
||||
|
||||
import { CRVUSDInstancesProposal } from "src/proposals/CRVUSDInstancesProposal.sol";
|
||||
|
||||
// Test imports
|
||||
|
||||
import { TornadoProposalTest } from "./TornadoProposalTest.sol";
|
||||
import { TornadoProposalTest, ProposalState } from "./TornadoProposalTest.sol";
|
||||
|
||||
contract ProposalTests is TornadoProposalTest {
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ VARIABLES ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
IERC20 public constant TORN = IERC20(0x77777FeDdddFfC19Ff86DB637967013e6C6A116C);
|
||||
|
||||
InstanceRegistry implInstanceRegisty;
|
||||
CurveFeeOracle curveFeeOracle;
|
||||
|
||||
UniswapV3FeeOracle v3FeeOracle;
|
||||
|
||||
InstanceRegistry implInstanceRegisty;
|
||||
|
||||
FeeOracleManager feeOracleManager;
|
||||
|
||||
TornadoRouter router;
|
||||
@ -43,10 +51,18 @@ contract ProposalTests is TornadoProposalTest {
|
||||
function setUp() public override {
|
||||
super.setUp();
|
||||
|
||||
implInstanceRegisty = new InstanceRegistry(address(governance));
|
||||
vm.rollFork(17_438_199);
|
||||
|
||||
curveFeeOracle = new CurveFeeOracle(address(governance));
|
||||
|
||||
v3FeeOracle = new UniswapV3FeeOracle(address(governance));
|
||||
|
||||
vm.prank(address(governance));
|
||||
|
||||
curveFeeOracle.setUniswapV3FeeOracle(v3FeeOracle);
|
||||
|
||||
implInstanceRegisty = new InstanceRegistry(address(governance));
|
||||
|
||||
feeOracleManager = new FeeOracleManager(address(TORN), address(governance));
|
||||
|
||||
router = new TornadoRouter(address(governance));
|
||||
@ -72,4 +88,21 @@ contract ProposalTests is TornadoProposalTest {
|
||||
// Exec
|
||||
governance.execute(id);
|
||||
}
|
||||
|
||||
function test_crvusdInstancesProposalBasic() public {
|
||||
// First pass the former proposal
|
||||
test_infrastructureUpgradeProposalBasic();
|
||||
|
||||
// Then create the crvUSD proposal
|
||||
address proposal = address(new CRVUSDInstancesProposal(address(curveFeeOracle), address(v3FeeOracle)));
|
||||
|
||||
// Propose
|
||||
uint256 id = easyPropose(proposal);
|
||||
|
||||
// Wait
|
||||
waitUntilExecutable(id);
|
||||
|
||||
// Exec
|
||||
governance.execute(id);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
pragma solidity ^0.6.12;
|
||||
pragma experimental ABIEncoderV2;
|
||||
|
||||
import { IGovernance, Proposal } from "common/interfaces/IGovernance.sol";
|
||||
import { IGovernance, Proposal, ProposalState } from "common/interfaces/IGovernance.sol";
|
||||
|
||||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user