Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: robots migration #312

Merged
merged 10 commits into from
May 27, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
## Reserve changes

### Reserves altered

#### LINK ([0xf97f4df75117a78c1A5a0DBb814Af92458539FB4](https://arbiscan.io/address/0xf97f4df75117a78c1A5a0DBb814Af92458539FB4))

| description | value before | value after |
| --- | --- | --- |
| liquidityIndex | 1.004 | 1.004 |
| variableBorrowIndex | 1.03 | 1.03 |
| currentLiquidityRate | 0.002 % | 0.002 % |
| currentVariableBorrowRate | 0.202 % | 0.202 % |


## Raw diff

```json
{
"reserves": {
"0xf97f4df75117a78c1A5a0DBb814Af92458539FB4": {
"currentLiquidityRate": {
"from": "20985901007959518447306",
"to": "20986891757668837645354"
},
"currentVariableBorrowRate": {
"from": "2020047490198880263355387",
"to": "2020095173113288571012529"
},
"liquidityIndex": {
"from": "1003748460436427781600991452",
"to": "1003748460849222735985294419"
},
"variableBorrowIndex": {
"from": "1030014561085096814904145780",
"to": "1030014601859425605006587904"
}
}
}
}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Raw diff

```json
{}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {IAaveCLRobotOperator} from './interfaces/IAaveCLRobotOperator.sol';

/**
* @title Migrate Robots to Chainlink Automation v2
* @author BGD Labs (@bgdlabs)
* @notice This payload should be executed before the payload for registering new robots.
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/36
*/
contract AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422 is IProposalGenericExecutor {
address public constant OLD_ROBOT_OPERATOR = 0x7A9ff54A6eE4a21223036890bB8c4ea2D62c686b;
uint256 public constant OLD_EXECUTION_CHAIN_ROBOT_ID =
42967470609923359998605990815360926273002411113492386351801017384824248835129;
uint256 public constant OLD_VOTING_CHAIN_ROBOT_ID =
23105234861606727783784560473737793446534476931507704105643023042466416318991;

function execute() external {
// cancel previous robots
IAaveCLRobotOperator(OLD_ROBOT_OPERATOR).cancel(OLD_EXECUTION_CHAIN_ROBOT_ID);
IAaveCLRobotOperator(OLD_ROBOT_OPERATOR).cancel(OLD_VOTING_CHAIN_ROBOT_ID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV2Avalanche} from 'aave-address-book/AaveV2Avalanche.sol';
import {ProtocolV2TestBase} from 'aave-helpers/ProtocolV2TestBase.sol';
import {AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422} from './AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422.sol';

/**
* @dev Test for AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422
* command: make test-contract filter=AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422
*/
contract AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422_Test is ProtocolV2TestBase {
AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422 internal proposal;
event KeeperCancelled(uint256 indexed id, address indexed upkeep);

address public constant OLD_EXECUTION_CHAIN_ROBOT_ADDRESS =
0x7B74938583Eb03e06042fcB651046BaF0bf15644;
address public constant OLD_VOTING_CHAIN_ROBOT_ADDRESS =
0x10E49034306EaA663646773C04b7B67E81eD0D52;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('avalanche'), 44528432);
proposal = new AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422();
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV2Avalanche_MigrateRobotsToChainlinkAutomationV2_20240422',
AaveV2Avalanche.POOL,
address(proposal)
);
}

function test_keepersCancelled() public {
vm.expectEmit();
emit KeeperCancelled(
proposal.OLD_EXECUTION_CHAIN_ROBOT_ID(),
OLD_EXECUTION_CHAIN_ROBOT_ADDRESS
);

vm.expectEmit();
emit KeeperCancelled(proposal.OLD_VOTING_CHAIN_ROBOT_ID(), OLD_VOTING_CHAIN_ROBOT_ADDRESS);

executePayload(vm, address(proposal));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {IAaveCLRobotOperator} from './interfaces/IAaveCLRobotOperator.sol';

/**
* @title Migrate Robots to Chainlink Automation v2
* @author BGD Labs (@bgdlabs)
* @notice This payload should be executed before the payload for registering new robots.
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/36
*/
contract AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422 is IProposalGenericExecutor {
address public constant OLD_ROBOT_OPERATOR = 0x4e8984D11A47Ff89CD67c7651eCaB6C00a74B4A9;
uint256 public constant OLD_EXECUTION_CHAIN_ROBOT_ID =
82990232394810788826748981965753730350133859818029683929136401112559915179430;
uint256 public constant OLD_VOTING_CHAIN_ROBOT_ID =
5475326125853957331243818268970211605617607736278808003229011576358255850220;

function execute() external {
// cancel previous robots
IAaveCLRobotOperator(OLD_ROBOT_OPERATOR).cancel(OLD_EXECUTION_CHAIN_ROBOT_ID);
IAaveCLRobotOperator(OLD_ROBOT_OPERATOR).cancel(OLD_VOTING_CHAIN_ROBOT_ID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV2Polygon} from 'aave-address-book/AaveV2Polygon.sol';
import {ProtocolV2TestBase} from 'aave-helpers/ProtocolV2TestBase.sol';
import {AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422} from './AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422.sol';

/**
* @dev Test for AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422
* command: make test-contract filter=AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422
*/
contract AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422_Test is ProtocolV2TestBase {
AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422 internal proposal;
event KeeperCancelled(uint256 indexed id, address indexed upkeep);

address public constant OLD_EXECUTION_CHAIN_ROBOT_ADDRESS =
0x249396a890F89D47F89326d7EE116b1d374Fb3A9;
address public constant OLD_VOTING_CHAIN_ROBOT_ADDRESS =
0xbe7998712402B6A63975515A532Ce503437998b7;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('polygon'), 56113527);
proposal = new AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422();
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV2Polygon_MigrateRobotsToChainlinkAutomationV2_20240422',
AaveV2Polygon.POOL,
address(proposal)
);
}

function test_keepersCancelled() public {
vm.expectEmit();
emit KeeperCancelled(
proposal.OLD_EXECUTION_CHAIN_ROBOT_ID(),
OLD_EXECUTION_CHAIN_ROBOT_ADDRESS
);

vm.expectEmit();
emit KeeperCancelled(proposal.OLD_VOTING_CHAIN_ROBOT_ID(), OLD_VOTING_CHAIN_ROBOT_ADDRESS);

executePayload(vm, address(proposal));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Arbitrum, AaveV3ArbitrumAssets} from 'aave-address-book/AaveV3Arbitrum.sol';
import {IAaveCLRobotOperator} from './interfaces/IAaveCLRobotOperator.sol';
import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {IERC20} from 'solidity-utils/contracts/oz-common/interfaces/IERC20.sol';
import {SafeERC20} from 'solidity-utils/contracts/oz-common/SafeERC20.sol';
import {SafeCast} from 'solidity-utils/contracts/oz-common/SafeCast.sol';

/**
* @title Migrate Robots to Chainlink Automation v2
* @author BGD Labs (@bgdlabs)
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/36
*/
contract AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422 is IProposalGenericExecutor {
using SafeERC20 for IERC20;
using SafeCast for uint256;

address public constant OLD_ROBOT_OPERATOR = 0xb0A73671C97BAC9Ba899CD1a23604Fd2278cD02A;
uint256 public constant OLD_EXECUTION_CHAIN_ROBOT_ID =
78329451080216164099529400539433108989111820950862041749656351555695961643082;

address public constant ROBOT_OPERATOR = 0xaa944aD95e51CB83C1f35FAEEDfC7d2c31B0BB4d;
address public constant EXECUTION_CHAIN_ROBOT_ADDRESS =
0x64093fe5f8Cf62aFb4377cf7EF4373537fe9155B;
address public constant STATIC_A_TOKEN_ROBOT_ADDRESS = 0x0451f67bA61966C346daBAbB50a30Cc6A9A67C69;

uint256 public constant STATIC_A_TOKEN_ROBOT_LINK_AMOUNT = 35 ether;
uint256 public constant EXECUTION_CHAIN_ROBOT_LINK_AMOUNT = 45 ether;

function execute() external {
// cancel previous robot
IAaveCLRobotOperator(OLD_ROBOT_OPERATOR).cancel(OLD_EXECUTION_CHAIN_ROBOT_ID);

AaveV3Arbitrum.COLLECTOR.transfer(
AaveV3ArbitrumAssets.LINK_A_TOKEN,
address(this),
EXECUTION_CHAIN_ROBOT_LINK_AMOUNT + STATIC_A_TOKEN_ROBOT_LINK_AMOUNT
);
AaveV3Arbitrum.POOL.withdraw(
AaveV3ArbitrumAssets.LINK_UNDERLYING,
type(uint256).max,
address(this)
);

uint256 linkBalance = IERC20(AaveV3ArbitrumAssets.LINK_UNDERLYING).balanceOf(address(this));
IERC20(AaveV3ArbitrumAssets.LINK_UNDERLYING).forceApprove(ROBOT_OPERATOR, linkBalance);

// register new robot
IAaveCLRobotOperator(ROBOT_OPERATOR).register(
'Execution Chain Robot',
EXECUTION_CHAIN_ROBOT_ADDRESS,
'',
5_000_000,
EXECUTION_CHAIN_ROBOT_LINK_AMOUNT.toUint96(),
0,
''
);
IAaveCLRobotOperator(ROBOT_OPERATOR).register(
'StaticAToken Rewards Robot',
STATIC_A_TOKEN_ROBOT_ADDRESS,
'',
1_000_000,
IERC20(AaveV3ArbitrumAssets.LINK_UNDERLYING).balanceOf(address(this)).toUint96(),
0,
''
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV3Arbitrum} from 'aave-address-book/AaveV3Arbitrum.sol';
import {ProtocolV3TestBase} from 'aave-helpers/ProtocolV3TestBase.sol';
import {AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422} from './AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422.sol';
import {ArbSys} from './interfaces/ArbSys.sol';

/**
* @dev Test for AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422
* command: make test-contract filter=AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422
*/
contract AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422_Test is ProtocolV3TestBase {
AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422 internal proposal;
address public constant ARB_SYS = 0x0000000000000000000000000000000000000064;

event KeeperRegistered(uint256 indexed id, address indexed upkeep, uint96 indexed amount);
event KeeperCancelled(uint256 indexed id, address indexed upkeep);

function setUp() public {
uint256 blockNumber = 213434099;
vm.createSelectFork(vm.rpcUrl('arbitrum'), blockNumber);
proposal = new AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422();

// https://github.com/foundry-rs/foundry/issues/5085
vm.mockCall(
ARB_SYS,
abi.encodeWithSelector(ArbSys.arbBlockNumber.selector),
abi.encode(blockNumber)
);
vm.mockCall(
ARB_SYS,
abi.encodeWithSelector(ArbSys.arbBlockHash.selector, blockNumber - 1),
abi.encode(0xbe6f5dfa9ce3324bd677f5195ecd8d1a258cbf3800f24621d0e0d2724224704f)
);
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_defaultProposalExecution() public {
defaultTest(
'AaveV3Arbitrum_MigrateRobotsToChainlinkAutomationV2_20240422',
AaveV3Arbitrum.POOL,
address(proposal)
);
}

function test_oldKeeperCancelledAndNewRegistered() public {
// validate robots cancelled
vm.expectEmit();
emit KeeperCancelled(
proposal.OLD_EXECUTION_CHAIN_ROBOT_ID(),
proposal.EXECUTION_CHAIN_ROBOT_ADDRESS()
);

// validate robots registered
vm.expectEmit(false, true, true, true);
emit KeeperRegistered(
uint256(0),
proposal.EXECUTION_CHAIN_ROBOT_ADDRESS(),
uint96(proposal.EXECUTION_CHAIN_ROBOT_LINK_AMOUNT())
);
vm.expectEmit(false, true, true, true);
emit KeeperRegistered(
uint256(0),
proposal.STATIC_A_TOKEN_ROBOT_ADDRESS(),
uint96(proposal.STATIC_A_TOKEN_ROBOT_LINK_AMOUNT())
);

executePayload(vm, address(proposal));
}
}
Loading
Loading