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,27 @@
// 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)
* - Snapshot: TODO
* - Discussion: TODO
*/
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,29 @@
---
title: "Fixed REP price feed on AAVE v1"
author: "BGD labs (@bgdlabs)"
discussions: ""
---

## Simple Summary

Replace existing price feed by Chainlink with the fixed price adapter on Aave v1.
rustboyar marked this conversation as resolved.
Show resolved Hide resolved

## Motivation

Chainlink is planning to shut down its price feed for the `REP` token as it is deprecated. Keeping in mind that the total supply of the `REP` on Aave v1 is less than 100$, we decided to replace the CL oracle by the custom adapter, which will return calculated average price of the token for the period from 01/09/2023 till 31/10/2023.
rustboyar marked this conversation as resolved.
Show resolved Hide resolved

## Specification

Average `REP` value: 0.0004625695693 ETH
rustboyar marked this conversation as resolved.
Show resolved Hide resolved

## 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](TODO)

- [REP / ETH adapter](TODO)

## 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,51 @@
// 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 broadcast {
// 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(address(0));
payloads[0] = GovV3Helpers.buildMainnetPayload(vm, actionsEthereum);

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