Skip to content

Commit

Permalink
feat: cbETH Deployment (#195)
Browse files Browse the repository at this point in the history
* adding cbETH oracle

* checking deployment scripts

* deploying contracts

* remove flattened

* change README to add new reference
  • Loading branch information
sogipec authored Jan 31, 2023
1 parent 0c7e088 commit 253e376
Show file tree
Hide file tree
Showing 22 changed files with 8,944 additions and 18 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Angle is a decentralized stablecoin protocol, designed to be both over-collatera

The protocol is made of different modules, each with their own set of smart contracts. This repo contains the Borrowing module smart contracts.

Smart contracts used to for yield-bearing tokens as collateral assets in the Borrowing module are in a different repository that you can find [here](https://github.com/AngleProtocol/borrow-lpTokens-contracts).

Documentation to understand Angle Protocol's Borrowing Module is available [here](https://docs.angle.money).

Developers documentation to understand how these smart contracts work together is available [here](https://developers.angle.money/borrowing-module-contracts/architecture-overview).
Expand All @@ -27,7 +29,7 @@ Other Angle-related smart contracts can be found in the following repositories:
- [Angle Core module contracts](https://github.com/AngleProtocol/angle-core)
- [Angle Strategies](https://github.com/AngleProtocol/angle-strategies)
- [Angle Router contracts](https://github.com/AngleProtocol/angle-router)
- [Angle Algorithmic Market Operations](https://github.com/AngleProtocol/angle-amo)
- [Angle Direct Deposit Modules (or Algorithmic market operations)](https://github.com/AngleProtocol/angle-amo)

Otherwise, for more info about the protocol, check out [this portal](https://linktr.ee/angleprotocol) of resources.

Expand Down
2 changes: 1 addition & 1 deletion contracts/oracle/BaseOracleChainlinkMultiTwoFeeds.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ abstract contract BaseOracleChainlinkMultiTwoFeeds is BaseOracleChainlinkMulti {
}

/// @inheritdoc IOracle
function read() external view override returns (uint256 quoteAmount) {
function read() external view virtual override returns (uint256 quoteAmount) {
quoteAmount = _getQuoteAmount();
AggregatorV3Interface[] memory _circuitChainlink = circuitChainlink();
uint8[2] memory circuitChainIsMultiplied = [1, 0];
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: GPL-3.0

pragma solidity ^0.8.12;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

import "../../BaseOracleChainlinkMultiTwoFeeds.sol";

/// @title OracleCBETHEURChainlink
/// @author Angle Labs, Inc.
/// @notice Gives the price of cbETH in Euro in base 18
contract OracleCBETHEURChainlink is BaseOracleChainlinkMultiTwoFeeds {
string public constant DESCRIPTION = "cbETH/EUR Oracle";

constructor(uint32 _stalePeriod, address _treasury) BaseOracleChainlinkMultiTwoFeeds(_stalePeriod, _treasury) {}

/// @inheritdoc IOracle
function circuitChainlink() public pure override returns (AggregatorV3Interface[] memory) {
AggregatorV3Interface[] memory _circuitChainlink = new AggregatorV3Interface[](3);
// Oracle cbETH/ETH
_circuitChainlink[0] = AggregatorV3Interface(0xF017fcB346A1885194689bA23Eff2fE6fA5C483b);
// Oracle ETH/USD
_circuitChainlink[1] = AggregatorV3Interface(0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419);
// Oracle EUR/USD
_circuitChainlink[2] = AggregatorV3Interface(0xb49f677943BC038e9857d61E7d053CaA2C1734C1);
return _circuitChainlink;
}

/// @inheritdoc BaseOracleChainlinkMultiTwoFeeds
function read() external view virtual override returns (uint256 quoteAmount) {
quoteAmount = _getQuoteAmount();
AggregatorV3Interface[] memory _circuitChainlink = circuitChainlink();
uint8[3] memory circuitChainIsMultiplied = [1, 1, 0];
uint8[3] memory chainlinkDecimals = [18, 8, 8];
uint256 circuitLength = _circuitChainlink.length;
for (uint256 i; i < circuitLength; ++i) {
quoteAmount = _readChainlinkFeed(
quoteAmount,
_circuitChainlink[i],
circuitChainIsMultiplied[i],
chainlinkDecimals[i]
);
}
}
}
2 changes: 1 addition & 1 deletion contracts/vaultManager/VaultManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ contract VaultManager is VaultManagerPermit, IVaultManagerFunctions {
BASE_PARAMS *
liquidationDiscount) /
(surcharge * targetHealthFactor * liquidationDiscount - (BASE_PARAMS**2) * collateralFactor);
// Need to check for the dustas liquidating should not leave a dusty amount in the vault
// Need to check for the dust as liquidating should not leave a dusty amount in the vault
uint256 dustParameter = dustLiquidation;
if (currentDebt * BASE_PARAMS <= maxAmountToRepay * surcharge + dustParameter * BASE_PARAMS) {
// If liquidating to the target threshold would leave a dusty amount: the liquidator can repay all.
Expand Down
13 changes: 7 additions & 6 deletions deploy/4_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,21 @@ const argv = yargs.env('').boolean('ci').parseSync();
const func: DeployFunction = async ({ deployments, web3, ethers, network }) => {
const { deploy } = deployments;
const { deployer } = await ethers.getNamedSigners();
const treasury = (await deployments.get('Treasury')).address;
// const treasury = (await deployments.get('Treasury')).address;
const treasury = '0x8667DBEBf68B0BFa6Db54f550f41Be16c4067d60';

const chainName = network.name.charAt(0).toUpperCase() + network.name.substring(1);

if (!network.live || network.config.chainId === ChainId.MAINNET) {
console.log('Now deploying the Oracle LUSD/EUR');
await deploy('Oracle_LUSD_EUR', {
contract: 'OracleLUSDEURChainlink',
console.log('Now deploying the Oracle CBETH/EUR');
await deploy('Oracle_CBETH_EUR', {
contract: 'OracleCBETHEURChainlink',
from: deployer.address,
args: [3600 * 48, treasury],
log: !argv.ci,
});
const oracle = (await deployments.get('Oracle_LUSD_EUR')).address;
console.log(`Successfully deployed Oracle LUSD/EUR at the address ${oracle}`);
const oracle = (await deployments.get('Oracle_CBETH_EUR')).address;
console.log(`Successfully deployed Oracle CBETH/EUR at the address ${oracle}`);
console.log('');
} else {
await deploy('Oracle_AVAX_EUR', {
Expand Down
3 changes: 2 additions & 1 deletion deploy/6_vaultManagerProxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
const treasuryAddress = (await ethers.getContract('Treasury')).address;
const treasury = new Contract(treasuryAddress, Treasury__factory.abi, deployer);

const implementation = (await ethers.getContract('VaultManager_Implementation')).address;
const implementation = (await ethers.getContract('VaultManager_V2_0_Implementation')).address;
const callData = new ethers.Contract(
implementation,
VaultManager__factory.createInterface(),
Expand All @@ -71,6 +71,7 @@ const func: DeployFunction = async ({ deployments, ethers, network }) => {
]);

// await deployProxy(name, implementation, proxyAdminAddress, callData);

await deploy(name, {
contract: 'TransparentUpgradeableProxy',
from: deployer.address,
Expand Down
2 changes: 1 addition & 1 deletion deploy/networks/mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"oneInchRouter": "0x1111111254eeb25477b68fb85ed929f73a960582",
"angleRouter": "0xBB755240596530be0c1DE5DFD77ec6398471561d",
"dust": "0",
"vaultsList": ["LUSD"]
"vaultsList": ["cbETH"]
}
Loading

0 comments on commit 253e376

Please sign in to comment.