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

Replace REP price feed on Aave v1 #13

Merged
merged 12 commits into from
Nov 3, 2023
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IProposalGenericExecutor} from 'aave-helpers/interfaces/IProposalGenericExecutor.sol';
import {IAaveOracle} from 'aave-address-book/AaveV2.sol';

/**
* @title Fixed REP price feed on AAVE v1
* @author BGD labs (@bgdlabs)
* - Discussion: https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/2
*/
contract AaveV1Ethereum_FixedREPPriceFeed_20231031 is IProposalGenericExecutor {
address public constant REP = 0x1985365e9f78359a9B6AD760e32412f4a445E862;
address public constant REP_ADAPTER = 0xc7751400F809cdB0C167F87985083C558a0610F7;
address public constant AAVE_V1_ORACLE = 0x76B47460d7F7c5222cFb6b6A75615ab10895DDe4;

function execute() external {
address[] memory assets = new address[](1);
address[] memory sources = new address[](1);

assets[0] = REP;
sources[0] = REP_ADAPTER;

IAaveOracle(AAVE_V1_ORACLE).setAssetSources(assets, sources);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {AaveV2Ethereum} from 'aave-address-book/AaveV2Ethereum.sol';

import 'forge-std/Test.sol';
import {CommonTestBase} from 'aave-helpers/CommonTestBase.sol';
import {IAaveOracle} from 'aave-address-book/AaveV2.sol';
import {AaveV1Ethereum_FixedREPPriceFeed_20231031} from './AaveV1Ethereum_FixedREPPriceFeed_20231031.sol';

/**
* @dev Test for AaveV1Ethereum_FixedREPPriceFeed_20231031
* command: make test-contract filter=AaveV1Ethereum_FixedREPPriceFeed_20231031
*/
contract AaveV1Ethereum_FixedREPPriceFeed_20231031_Test is CommonTestBase {
AaveV1Ethereum_FixedREPPriceFeed_20231031 internal proposal;

address public constant REP = 0x1985365e9f78359a9B6AD760e32412f4a445E862;
address public constant REP_ADAPTER = 0xc7751400F809cdB0C167F87985083C558a0610F7;
address public constant AAVE_V1_ORACLE = 0x76B47460d7F7c5222cFb6b6A75615ab10895DDe4;

function setUp() public {
vm.createSelectFork(vm.rpcUrl('mainnet'), 18470486);
proposal = new AaveV1Ethereum_FixedREPPriceFeed_20231031();
}

/**
* @dev executes the generic test suite including e2e and config snapshots
*/
function test_proposalExecution() public {
executePayload(vm, address(proposal));

IAaveOracle oracle = IAaveOracle(AAVE_V1_ORACLE);
address newSource = oracle.getSourceOfAsset(REP);
assertEq(newSource, REP_ADAPTER);

assertEq(oracle.getAssetPrice(REP), 462569569300000);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
title: "Fixed REP price feed on AAVE v1"
author: "BGD labs (@bgdlabs)"
discussions: "https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/2"
---

## Simple Summary

Replace existing REP/ETH price feed by Chainlink on Aave v1 Ethereum with a fixed price adapter.

## Motivation

The REP asset listed on Aave 1 Ethereum is a legacy one, that long time ago has suffered a token migration.
With a total supply of this legacy `REP` on Aave v1 of less than $100, Chainlink is looking to shut down the REP/ETH price feed, but this can only be done if Aave stops using it.
Consequently, giving the size of the asset and that factually is off-boarded (frozen), we propose to replace the Chainlink price feed by an ad-hoc one that will return a constant value: the average price of the token for the period from 01/09/2023 till 31/10/2023.

## Specification

Average `REP` price to use: 0.0004625695693 ETH

- call `IAaveOracle(AAVE_V1_ORACLE).setAssetSources([0x1985365e9f78359a9B6AD760e32412f4a445E862], [0xc7751400F809cdB0C167F87985083C558a0610F7])` to replace the price feed of the `REP` on Aave v1 Pool.

## References

- Implementation: [AaveV1Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231031_AaveV2Ethereum_FixedREPPriceFeed/AaveV2Ethereum_FixedREPPriceFeedOnAAVEV1_20231031.sol)
- Tests: [AaveV1Ethereum](https://github.com/bgd-labs/aave-proposals-v3/blob/main/src/20231031_AaveV2Ethereum_FixedREPPriceFeedOnAAVEV1/AaveV1Ethereum_FixedREPPriceFeed_20231031.t)
- [Discussion](https://governance.aave.com/t/bgd-technical-maintenance-proposals/15274/2)

- [REP token](https://etherscan.io/address/0x1985365e9f78359a9B6AD760e32412f4a445E862)
- [REP / ETH adapter](https://github.com/bgd-labs/cl-synchronicity-price-adapter/blob/main/src/contracts/RepFixedPriceAdapter.sol)

## Copyright

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {GovV3Helpers, IPayloadsControllerCore, PayloadsControllerUtils} from 'aave-helpers/GovV3Helpers.sol';
import {EthereumScript} from 'aave-helpers/ScriptUtils.sol';
import {AaveV1Ethereum_FixedREPPriceFeed_20231031} from './AaveV1Ethereum_FixedREPPriceFeed_20231031.sol';

/**
* @dev Deploy Ethereum
* command: make deploy-ledger contract=src/20231031_AaveV1Ethereum_FixedREPPriceFeed/FixedREPPriceFeedOnAAVEV1_20231031.s.sol:DeployEthereum chain=mainnet
*/
contract DeployEthereum is EthereumScript {
function run() external broadcast {
// deploy payloads
AaveV1Ethereum_FixedREPPriceFeed_20231031 payload0 = new AaveV1Ethereum_FixedREPPriceFeed_20231031();

// compose action
IPayloadsControllerCore.ExecutionAction[]
memory actions = new IPayloadsControllerCore.ExecutionAction[](1);
actions[0] = GovV3Helpers.buildAction(address(payload0));

// register action at payloadsController
GovV3Helpers.createPayload(actions);
}
}

/**
* @dev Create Proposal
* command: make deploy-ledger contract=src/20231031_AaveV1Ethereum_FixedREPPriceFeed/FixedREPPriceFeedOnAAVEV1_20231031.s.sol:CreateProposal chain=mainnet
*/
contract CreateProposal is EthereumScript {
function run() external {
// create payloads
PayloadsControllerUtils.Payload[] memory payloads = new PayloadsControllerUtils.Payload[](1);

// compose actions for validation
IPayloadsControllerCore.ExecutionAction[]
memory actionsEthereum = new IPayloadsControllerCore.ExecutionAction[](1);
actionsEthereum[0] = GovV3Helpers.buildAction(0xBdD1458A6d399C88D4509275e4463485C6c86Ef3);
payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum);

// create proposal
vm.startBroadcast();
GovV3Helpers.createProposal2_5(
payloads,
GovV3Helpers.ipfsHashFile(
vm,
'src/20231031_AaveV1Ethereum_FixedREPPriceFeed/FixedREPPriceFeedOnAAVEV1_20231031.s.sol'
)
);
}
}