Skip to content

Commit

Permalink
Merge final 3.4.0 into fuzz (#1135)
Browse files Browse the repository at this point in the history
Co-authored-by: Taylor Brent <[email protected]>
Co-authored-by: brr <[email protected]>
Co-authored-by: Akshat Mittal <[email protected]>
Co-authored-by: pmckelvy1 <[email protected]>
Co-authored-by: omahs <[email protected]>
Co-authored-by: Julian M. Rodriguez <[email protected]>
Co-authored-by: celest <[email protected]>
  • Loading branch information
8 people authored May 6, 2024
1 parent 2878398 commit 21ab9c1
Show file tree
Hide file tree
Showing 86 changed files with 7,009 additions and 993 deletions.
3,238 changes: 3,238 additions & 0 deletions .openzeppelin/mainnet.json

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion common/blockchain-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useEnv } from '#/utils/env'
import { BigNumber } from 'ethers'
import { HardhatRuntimeEnvironment } from 'hardhat/types'

// getChainId: Returns current chain Id
export const getChainId = async (hre: HardhatRuntimeEnvironment) => {
export const getChainId = async (hre: HardhatRuntimeEnvironment): Promise<string> => {
let _chainId
try {
_chainId = await hre.network.provider.send('eth_chainId')
Expand All @@ -17,6 +18,20 @@ export const getChainId = async (hre: HardhatRuntimeEnvironment) => {
if (_chainId.startsWith('0x')) {
_chainId = BigNumber.from(_chainId).toString()
}

if (useEnv('FORK') && _chainId === '31337') {
switch (useEnv('FORK_NETWORK').toLowerCase()) {
case 'mainnet':
_chainId = '1'
break;
case 'base':
_chainId = '8453'
break;
case 'arbitrum':
_chainId = '42161'
break;
}
}
return _chainId
}

Expand Down
16 changes: 15 additions & 1 deletion common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ export interface ITokens {
RSR?: string
CRV?: string
CVX?: string
SDT?: string
USDCPLUS?: string
ETHPLUS?: string
ankrETH?: string
frxETH?: string
Expand All @@ -65,6 +67,7 @@ export interface ITokens {
wstETH?: string
rETH?: string
cUSDCv3?: string
wcUSDCv3?: string
cUSDbCv3?: string
ONDO?: string
sFRAX?: string
Expand Down Expand Up @@ -103,6 +106,8 @@ export interface ITokens {
Re7WETH?: string
}

export type ITokensKeys = Array<keyof ITokens>;

export interface IFeeds {
stETHETH?: string
stETHUSD?: string
Expand All @@ -125,11 +130,12 @@ export interface IPools {
crveUSDFRAXBP?: string
crvTriCrypto?: string
crvMIM3Pool?: string
sdUSDCUSDCPlus?: string
}

interface INetworkConfig {
name: string
tokens: ITokens
tokens: ITokens & IPools
chainlinkFeeds: ITokens & ICurrencies & IFeeds
AAVE_LENDING_POOL?: string
AAVE_INCENTIVES?: string
Expand Down Expand Up @@ -202,6 +208,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
RSR: '0x320623b8E4fF03373931769A31Fc52A4E78B5d70',
CRV: '0xD533a949740bb3306d119CC777fa900bA034cd52',
CVX: '0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B',
SDT: '0x73968b9a57c6E53d41345FD57a6E6ae27d6CDB2F',
USDCPLUS: '0xFc0B1EEf20e4c68B3DCF36c4537Cfa7Ce46CA70b',
ETHPLUS: '0xE72B141DF173b999AE7c1aDcbF60Cc9833Ce56a8',
ankrETH: '0xE95A203B1a91a908F9B9CE46459d101078c2c3cb',
frxETH: '0x5E8422345238F34275888049021821E8E08CAa1f',
Expand All @@ -210,6 +218,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
wstETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
rETH: '0xae78736Cd615f374D3085123A210448E74Fc6393',
cUSDCv3: '0xc3d688B66703497DAA19211EEdff47f25384cdc3',
wcUSDCv3: '0xfBD1a538f5707C0D67a16ca4e3Fc711B80BD931A',
ONDO: '0xfAbA6f8e4a5E8Ab82F62fe7C39859FA577269BE3',
sFRAX: '0xA663B02CF0a4b149d2aD41910CB81e23e1c41c32',
sDAI: '0x83f20f44975d03b1b09e64809b757c47f942beea',
Expand All @@ -231,6 +240,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
steakPYUSD: '0xbEEF02e5E13584ab96848af90261f0C8Ee04722a',
bbUSDT: '0x2C25f6C25770fFEC5959D34B94Bf898865e5D6b1',
Re7WETH: '0x78Fc2c2eD1A4cDb5402365934aE5648aDAd094d0',
sdUSDCUSDCPlus: '0x9bbF31E99F30c38a5003952206C31EEa77540BeF',
},
chainlinkFeeds: {
RSR: '0x759bBC1be8F90eE6457C44abc7d443842a976d02',
Expand Down Expand Up @@ -327,6 +337,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
wstETH: '0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0',
rETH: '0xae78736Cd615f374D3085123A210448E74Fc6393',
cUSDCv3: '0xc3d688B66703497DAA19211EEdff47f25384cdc3',
wcUSDCv3: '0xfBD1a538f5707C0D67a16ca4e3Fc711B80BD931A',
ONDO: '0xfAbA6f8e4a5E8Ab82F62fe7C39859FA577269BE3',
sDAI: '0x83f20f44975d03b1b09e64809b757c47f942beea',
cbETH: '0xBe9895146f7AF43049ca1c1AE358B0541Ea49704',
Expand Down Expand Up @@ -477,6 +488,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
cbETH: '0x2ae3f1ec7f1f5012cfeab0185bfc7aa3cf0dec22',
cUSDbCv3: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
cUSDCv3: '0xb125E6687d4313864e53df431d5425969c15Eb2F',
wcUSDCv3: '0xA694f7177C6c839C951C74C797283B35D0A486c8',
aBasUSDC: '0x4e65fE4DbA92790696d040ac24Aa414708F5c0AB',
saBasUSDC: '0x184460704886f9F2A7F3A0c2887680867954dC6E', // our wrapper
aWETHv3: '0xD4a0e0b9149BCee3C920d2E00b5dE09138fd8bb7',
Expand Down Expand Up @@ -674,6 +686,8 @@ export const MIN_THROTTLE_AMT_RATE = BigNumber.from(10).pow(18)
export const MAX_THROTTLE_AMT_RATE = BigNumber.from(10).pow(48)
export const MAX_THROTTLE_PCT_RATE = BigNumber.from(10).pow(18)
export const GNOSIS_MAX_TOKENS = BigNumber.from(7).mul(BigNumber.from(10).pow(28))
export const MAX_BASKET_SIZE = 100
export const MAX_BACKUP_SIZE = 64

// Timestamps
export const MAX_ORACLE_TIMEOUT = BigNumber.from(2).pow(48).sub(1).sub(300)
Expand Down
3 changes: 1 addition & 2 deletions contracts/facade/facets/ActFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";
import "../../plugins/trading/DutchTrade.sol";
import "../../plugins/trading/GnosisTrade.sol";
import "../../interfaces/IActFacet.sol";
import "../../interfaces/IBackingManager.sol";

/**
Expand All @@ -17,7 +16,7 @@ import "../../interfaces/IBackingManager.sol";
* @custom:static-call - Use ethers callStatic() to get result after update; do not execute
*/
// slither-disable-start
contract ActFacet is IActFacet, Multicall {
contract ActFacet is Multicall {
using Address for address;
using SafeERC20 for IERC20;
using FixLib for uint192;
Expand Down
13 changes: 9 additions & 4 deletions contracts/facade/facets/ReadFacet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../../plugins/trading/DutchTrade.sol";
import "../../interfaces/IAsset.sol";
import "../../interfaces/IAssetRegistry.sol";
import "../../interfaces/IReadFacet.sol";
import "../../interfaces/IRToken.sol";
import "../../interfaces/IStRSR.sol";
import "../../libraries/Fixed.sol";
Expand All @@ -22,7 +21,7 @@ import "./MaxIssuableFacet.sol";
* @custom:static-call - Use ethers callStatic() to get result after update; do not execute
*/
// slither-disable-start
contract ReadFacet is MaxIssuableFacet {
contract ReadFacet {
using FixLib for uint192;

// === Static Calls ===
Expand Down Expand Up @@ -247,14 +246,20 @@ contract ReadFacet is MaxIssuableFacet {

// === Views ===

struct Pending {
uint256 index;
uint256 availableAt;
uint256 amount;
}

/// @param draftEra {draftEra} The draft era to query unstakings for
/// @param account The account for the query
/// @return unstakings {qRSR} All the pending StRSR unstakings for an account, in RSR
function pendingUnstakings(
RTokenP1 rToken,
uint256 draftEra,
address account
) external view returns (IReadFacet.Pending[] memory unstakings) {
) external view returns (Pending[] memory unstakings) {
StRSRP1 stRSR = StRSRP1(address(rToken.main().stRSR()));
uint256 left = stRSR.firstRemainingDraft(draftEra, account);
uint256 right = stRSR.draftQueueLen(draftEra, account);
Expand All @@ -271,7 +276,7 @@ contract ReadFacet is MaxIssuableFacet {
}

// {qRSR} = {qDrafts} / {qDrafts/qRSR}
unstakings[i] = IReadFacet.Pending(i + left, availableAt, diff.div(draftRate));
unstakings[i] = Pending(i + left, availableAt, diff.div(draftRate));
}
}

Expand Down
7 changes: 4 additions & 3 deletions contracts/interfaces/IFacade.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// SPDX-License-Identifier: BlueOak-1.0.0
pragma solidity 0.8.19;

import "./IActFacet.sol";
import "./IReadFacet.sol";
import "../facade/facets/ActFacet.sol";
import "../facade/facets/ReadFacet.sol";
import "../facade/facets/MaxIssuableFacet.sol";

interface IFacade {
event SelectorSaved(address indexed facet, bytes4 indexed selector);
Expand All @@ -14,6 +15,6 @@ interface IFacade {
}

// solhint-disable-next-line no-empty-blocks
interface TestIFacade is IFacade, IActFacet, IReadFacet {
abstract contract TestIFacade is IFacade, ActFacet, MaxIssuableFacet, ReadFacet {

}
2 changes: 1 addition & 1 deletion contracts/p1/StRSR.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "./mixins/Component.sol";

// solhint-disable max-states-count

/*
/**
* @title StRSRP1
* @notice StRSR is an ERC20 token contract that allows people to stake their RSR as
* over-collateralization behind an RToken. As compensation stakers receive a share of revenues
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ contract CurveAppreciatingRTokenFiatCollateral is CurveStableCollateral {

// Check RToken status
try pairedBasketHandler.isReady() returns (bool isReady) {
if (!isReady) {
markStatus(CollateralStatus.IFFY);
} else if (low == 0 || _anyDepeggedInPool() || _anyDepeggedOutsidePool()) {
if (!isReady || low == 0 || _anyDepeggedInPool() || _anyDepeggedOutsidePool()) {
// If the price is below the default-threshold price, default eventually
// uint192(+/-) is the same as Fix.plus/minus
markStatus(CollateralStatus.IFFY);
Expand Down
Loading

0 comments on commit 21ab9c1

Please sign in to comment.