Skip to content

Commit

Permalink
feat: added metis, optimism and scroll. Fixed compilation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
sendra committed Mar 6, 2024
1 parent 5f897ac commit 3aef4ce
Show file tree
Hide file tree
Showing 12 changed files with 298 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ contract AaveV3Arbitrum_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericE
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Arbitrum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ contract AaveV3BNB_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericExecut
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3BNB.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ contract AaveV3Base_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericExecu
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Base.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Base.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ contract AaveV3Base_ADIAndBridgeAdaptersUpdate_20240305_Test is ProtocolV3TestBa

function setUp() public {
ccc = GovernanceV3Base.CROSS_CHAIN_CONTROLLER;
proxyAdmin = MiscBASE.PROXY_ADMIN;
proxyAdmin = MiscBase.PROXY_ADMIN;

vm.createSelectFork(vm.rpcUrl('base'), 11420130);
proposal = new AaveV3Base_ADIAndBridgeAdaptersUpdate_20240305();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ contract AaveV3Gnosis_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericExe
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Ethereum.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
ICrossChainReceiver(GovernanceV3Gnosis.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.
import {ChainIds} from 'aave-helpers/ChainIds.sol';
import {MiscMetis} from 'aave-address-book/MiscMetis.sol';
import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol';
import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol';
import {ICrossChainReceiver} from 'aave-address-book/common/ICrossChainController.sol';

/**
* @title aDI and bridge adapters update
Expand All @@ -16,10 +16,68 @@ import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/commo
* - Discussion: TODO
*/
contract AaveV3Metis_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericExecutor {
address public constant ADAPTER_TO_REMOVE = 0x746c675dAB49Bcd5BB9Dc85161f2d7Eb435009bf;
address public constant NEW_ADAPTER = address(0); // TODO: change for real address when deployed
address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = address(0); // TODO: change for real address when deployed

function execute() external {
// custom code goes here
// Update CrossChainController implementation
ProxyAdmin(MiscMetis.PROXY_ADMIN).upgradeAndCall(
TransparentUpgradeableProxy(payable(GovernanceV3Metis.CROSS_CHAIN_CONTROLLER)),
NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION,
abi.encodeWithSignature('initializeRevision()')
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Metis.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Metis.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}

function _getReceiverBridgeAdaptersToRemove()
internal
pure
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory)
{
uint256[] memory receiverChainIds = new uint256[](1);
receiverChainIds[0] = ChainIds.MAINNET;

ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]
memory receiverAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](
1
);

receiverAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: ADAPTER_TO_REMOVE,
chainIds: receiverChainIds
});

return receiverAdaptersToRemove;
}

function _getReceiverBridgeAdaptersToAllow()
internal
pure
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory)
{
uint256[] memory receiverChainIds = new uint256[](1);
receiverChainIds[0] = ChainIds.MAINNET;

ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]
memory receiverAdaptersToAllow = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](
1
);

receiverAdaptersToAllow[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: NEW_ADAPTER,
chainIds: receiverChainIds
});

return receiverAdaptersToAllow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AaveV3Metis} from 'aave-address-book/AaveV3Metis.sol';
import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Metis_ADIAndBridgeAdaptersUpdate_20240305} from './AaveV3Metis_ADIAndBridgeAdaptersUpdate_20240305.sol';
import {MiscMetis} from 'aave-address-book/MiscMetis.sol';
import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Avalanche.sol';
import {GovernanceV3Metis} from 'aave-address-book/GovernanceV3Metis.sol';
import './BaseTest.sol';

/**
Expand All @@ -27,10 +27,40 @@ contract AaveV3Metis_ADIAndBridgeAdaptersUpdate_20240305_Test is ProtocolV3TestB
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV3Metis_ADIAndBridgeAdaptersUpdate_20240305',
AaveV3Metis.POOL,
address(proposal)
);
_testImplementationAddress(proposal.NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), false);
_testCurrentReceiversAreAllowed();
_testAllReceiversAreRepresented();

executePayload(vm, address(proposal));

_testImplementationAddress(proposal.NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), true);
_testAfterReceiversAreAllowed();
_testAllReceiversAreRepresentedAfter();
}

function _testAllReceiversAreRepresented() internal {
address[] memory adapters = new address[](1);
adapters[0] = proposal.ADAPTER_TO_REMOVE();

_testReceiverAdaptersByChain(ChainIds.MAINNET, adapters);
}

function _testAllReceiversAreRepresentedAfter() internal {
address[] memory adapters = new address[](1);
adapters[0] = proposal.NEW_ADAPTER();

_testReceiverAdaptersByChain(ChainIds.MAINNET, adapters);
}

function _testCurrentReceiversAreAllowed() internal {
_testReceiverAdapterAllowed(proposal.ADAPTER_TO_REMOVE(), ChainIds.MAINNET, true);
}

function _testAfterReceiversAreAllowed() internal {
// check that old bridges are no longer allowed
_testReceiverAdapterAllowed(proposal.ADAPTER_TO_REMOVE(), ChainIds.MAINNET, false);

// check that new bridges are allowed
_testReceiverAdapterAllowed(proposal.NEW_ADAPTER(), ChainIds.MAINNET, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {TransparentUpgradeableProxy} from 'solidity-utils/contracts/transparent-
import {ProxyAdmin} from 'solidity-utils/contracts/transparent-proxy/ProxyAdmin.sol';
import {ChainIds} from 'aave-helpers/ChainIds.sol';
import {MiscOptimism} from 'aave-address-book/MiscOptimism.sol';
import {ICrossChainReceiver, ICrossChainForwarder} from 'aave-address-book/common/ICrossChainController.sol';
import {ICrossChainReceiver} from 'aave-address-book/common/ICrossChainController.sol';
import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol';

/**
Expand All @@ -16,10 +16,68 @@ import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol';
* - Discussion: TODO
*/
contract AaveV3Optimism_ADIAndBridgeAdaptersUpdate_20240305 is IProposalGenericExecutor {
address public constant ADAPTER_TO_REMOVE = 0x81d32B36380e6266e1BDd490eAC56cdB300afBe0;
address public constant NEW_ADAPTER = address(0); // TODO: change for real address when deployed
address public constant NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION = address(0); // TODO: change for real address when deployed

function execute() external {
// custom code goes here
// Update CrossChainController implementation
ProxyAdmin(MiscOptimism.PROXY_ADMIN).upgradeAndCall(
TransparentUpgradeableProxy(payable(GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER)),
NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION,
abi.encodeWithSignature('initializeRevision()')
);

// remove old Receiver bridge adapter
ICrossChainReceiver(GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER).disallowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToRemove()
);

// add receiver adapters
ICrossChainReceiver(GovernanceV3Optimism.CROSS_CHAIN_CONTROLLER).allowReceiverBridgeAdapters(
_getReceiverBridgeAdaptersToAllow()
);
}

function _getReceiverBridgeAdaptersToRemove()
internal
pure
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory)
{
uint256[] memory receiverChainIds = new uint256[](1);
receiverChainIds[0] = ChainIds.MAINNET;

ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]
memory receiverAdaptersToRemove = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](
1
);

receiverAdaptersToRemove[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: ADAPTER_TO_REMOVE,
chainIds: receiverChainIds
});

return receiverAdaptersToRemove;
}

function _getReceiverBridgeAdaptersToAllow()
internal
pure
returns (ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[] memory)
{
uint256[] memory receiverChainIds = new uint256[](1);
receiverChainIds[0] = ChainIds.MAINNET;

ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[]
memory receiverAdaptersToAllow = new ICrossChainReceiver.ReceiverBridgeAdapterConfigInput[](
1
);

receiverAdaptersToAllow[0] = ICrossChainReceiver.ReceiverBridgeAdapterConfigInput({
bridgeAdapter: NEW_ADAPTER,
chainIds: receiverChainIds
});

return receiverAdaptersToAllow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AaveV3Optimism} from 'aave-address-book/AaveV3Optimism.sol';
import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Optimism_ADIAndBridgeAdaptersUpdate_20240305} from './AaveV3Optimism_ADIAndBridgeAdaptersUpdate_20240305.sol';
import {MiscOptimism} from 'aave-address-book/MiscOptimism.sol';
import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Avalanche.sol';
import {GovernanceV3Optimism} from 'aave-address-book/GovernanceV3Optimism.sol';
import './BaseTest.sol';

/**
Expand All @@ -27,10 +27,40 @@ contract AaveV3Optimism_ADIAndBridgeAdaptersUpdate_20240305_Test is ProtocolV3Te
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV3Optimism_ADIAndBridgeAdaptersUpdate_20240305',
AaveV3Optimism.POOL,
address(proposal)
);
_testImplementationAddress(proposal.NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), false);
_testCurrentReceiversAreAllowed();
_testAllReceiversAreRepresented();

executePayload(vm, address(proposal));

_testImplementationAddress(proposal.NEW_CROSS_CHAIN_CONTROLLER_IMPLEMENTATION(), true);
_testAfterReceiversAreAllowed();
_testAllReceiversAreRepresentedAfter();
}

function _testAllReceiversAreRepresented() internal {
address[] memory adapters = new address[](1);
adapters[0] = proposal.ADAPTER_TO_REMOVE();

_testReceiverAdaptersByChain(ChainIds.MAINNET, adapters);
}

function _testAllReceiversAreRepresentedAfter() internal {
address[] memory adapters = new address[](1);
adapters[0] = proposal.NEW_ADAPTER();

_testReceiverAdaptersByChain(ChainIds.MAINNET, adapters);
}

function _testCurrentReceiversAreAllowed() internal {
_testReceiverAdapterAllowed(proposal.ADAPTER_TO_REMOVE(), ChainIds.MAINNET, true);
}

function _testAfterReceiversAreAllowed() internal {
// check that old bridges are no longer allowed
_testReceiverAdapterAllowed(proposal.ADAPTER_TO_REMOVE(), ChainIds.MAINNET, false);

// check that new bridges are allowed
_testReceiverAdapterAllowed(proposal.NEW_ADAPTER(), ChainIds.MAINNET, true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {AaveV3Polygon} from 'aave-address-book/AaveV3Polygon.sol';
import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Polygon_ADIAndBridgeAdaptersUpdate_20240305} from './AaveV3Polygon_ADIAndBridgeAdaptersUpdate_20240305.sol';
import {MiscPolygon} from 'aave-address-book/MiscPolygon.sol';
import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Avalanche.sol';
import {GovernanceV3Polygon} from 'aave-address-book/GovernanceV3Polygon.sol';
import './BaseTest.sol';

/**
Expand Down
Loading

0 comments on commit 3aef4ce

Please sign in to comment.