Skip to content

Commit

Permalink
Merge branch '4.0.0' into usds-plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
julianmrodri committed Nov 4, 2024
2 parents 1c02192 + abbbb9f commit 2339fbe
Show file tree
Hide file tree
Showing 68 changed files with 2,615 additions and 1,429 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- run: yarn install --immutable
- run: yarn devchain &
env:
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet
- run: yarn deploy:run --network localhost
env:
Expand Down Expand Up @@ -82,7 +82,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet
PROTO_IMPL: 1
FORK: 1
Expand All @@ -109,7 +109,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet
PROTO_IMPL: 1
FORK: 1
Expand All @@ -136,7 +136,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet
PROTO_IMPL: 1
FORK: 1
Expand All @@ -159,11 +159,11 @@ jobs:
restore-keys: |
hardhat-network-fork-${{ runner.os }}-
hardhat-network-fork-
- run: yarn hardhat test ./test/plugins/individual-collateral/{cbeth,aave-v3,compoundv3,stargate,lido}/*.test.ts
- run: yarn hardhat test ./test/plugins/individual-collateral/{cbeth,aave-v3,compoundv3,stargate,lido,meta-morpho}/*.test.ts
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
BASE_RPC_URL: https://base-mainnet.infura.io/v3/${{ secrets.INFURA_BASE_KEY }}
BASE_RPC_URL: https://base-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_BASE_KEY }}
FORK_NETWORK: base
FORK_BLOCK: 4446300
FORK: 1
Expand Down Expand Up @@ -262,7 +262,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet

integration-tests:
Expand All @@ -289,7 +289,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet

monitor-tests:
Expand All @@ -314,7 +314,7 @@ jobs:
env:
NODE_OPTIONS: '--max-old-space-size=32768'
TS_NODE_SKIP_IGNORE: true
MAINNET_RPC_URL: https://eth-mainnet.alchemyapi.io/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
MAINNET_RPC_URL: https://eth-mainnet.g.alchemy.com/v2/${{ secrets.ALCHEMY_MAINNET_KEY }}
FORK_NETWORK: mainnet
FORK: 1
PROTO_IMPL: 1
Expand Down
7 changes: 7 additions & 0 deletions common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface ITokens {
cUSDCv3?: string
wcUSDCv3?: string
cUSDbCv3?: string
cUSDTv3?: string
ONDO?: string
sFRAX?: string
sDAI?: string
Expand Down Expand Up @@ -105,6 +106,7 @@ export interface ITokens {
bbUSDT?: string
steakPYUSD?: string
Re7WETH?: string
meUSD?: string

pxETH?: string
apxETH?: string
Expand Down Expand Up @@ -237,6 +239,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
apxETH: '0x9Ba021B0a9b958B5E75cE9f6dff97C7eE52cb3E6',
cUSDCv3: '0xc3d688B66703497DAA19211EEdff47f25384cdc3',
wcUSDCv3: '0x27F2f159Fe990Ba83D57f39Fd69661764BEbf37a',
cUSDTv3: '0x3Afdc9BCA9213A35503b077a6072F3D0d5AB0840',
ONDO: '0xfAbA6f8e4a5E8Ab82F62fe7C39859FA577269BE3',
sFRAX: '0xA663B02CF0a4b149d2aD41910CB81e23e1c41c32',
sDAI: '0x83f20f44975d03b1b09e64809b757c47f942beea',
Expand Down Expand Up @@ -521,6 +524,8 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
sUSDbC: '0x4c80e24119cfb836cdf0a6b53dc23f04f7e652ca',
wstETH: '0xc1CBa3fCea344f92D9239c08C0568f6F2F0ee452',
STG: '0xE3B53AF74a4BF62Ae5511055290838050bf764Df',
eUSD: '0xCfA3Ef56d303AE4fAabA0592388F19d7C3399FB4',
meUSD: '0xbb819D845b573B5D7C538F5b85057160cfb5f313',
},
chainlinkFeeds: {
DAI: '0x591e79239a7d679378ec8c847e5038150364c78f', // 0.3%, 24hr
Expand All @@ -537,6 +542,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
stETHETH: '0xf586d0728a47229e747d824a939000Cf21dEF5A0', // 0.5%, 24h
ETHUSD: '0x71041dddad3595F9CEd3DcCFBe3D1F4b0a16Bb70', // 0.15%, 20min
wstETHstETH: '0xB88BAc61a4Ca37C43a3725912B1f472c9A5bc061', // 0.5%, 24h
eUSD: '0x9b2C948dbA5952A1f5Ab6fA16101c1392b8da1ab', // 0.5%, 24h
},
GNOSIS_EASY_AUCTION: '0xb1875Feaeea32Bbb02DE83D81772e07E37A40f02', // mock
COMET_REWARDS: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
Expand All @@ -560,6 +566,7 @@ export const networkConfig: { [key: string]: INetworkConfig } = {
USDC: '0xaf88d065e77c8cc2239327c5edb3a432268e5831',
USDT: '0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9',
cUSDCv3: '0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf',
cUSDTv3: '0xd98Be00b5D27fc98112BdE293e487f8D4cA57d07',
WETH: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',
WBTC: '0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f',
aArbUSDCn: '0x724dc807b04555b71ed48a6896b6f41593b8c637', // aArbUSDCn wraps USDC!
Expand Down
33 changes: 33 additions & 0 deletions common/registries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
interface IRegistries {
roleRegistry: string
versionRegistry: string
assetPluginRegistry: string
daoFeeRegistry: string
}

interface IRegistryControl {
owner: string
feeRecipient: string
}

export interface RegistryChainRecord {
registries: IRegistries
registryControl: IRegistryControl
}

export const registryConfig: Record<string, RegistryChainRecord> = {
'1': {
registryControl: {
owner: '0x0000000000000000000000000000000000000123',
feeRecipient: '0x0000000000000000000000000000000000000123',
},
registries: {
roleRegistry: '',
versionRegistry: '',
assetPluginRegistry: '',
daoFeeRegistry: '',
},
},
}

registryConfig['31337'] = registryConfig['1']
2 changes: 0 additions & 2 deletions contracts/facade/DeployerRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import "../interfaces/IDeployerRegistry.sol";
* @dev Does not allow overwriting without deregistration
*/
contract DeployerRegistry is IDeployerRegistry, Ownable {
string public constant ENS = "reserveprotocol.eth";

mapping(string => IDeployer) public deployments;

IDeployer public override latestDeployment;
Expand Down
4 changes: 2 additions & 2 deletions contracts/facade/FacadeMonitor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import "../interfaces/IRToken.sol";
import "../libraries/Fixed.sol";
import "../p1/RToken.sol";
import "../plugins/assets/compoundv2/DEPRECATED_CTokenWrapper.sol";
import "../plugins/assets/compoundv3/ICusdcV3Wrapper.sol";
import "../plugins/assets/compoundv3/ICFiatV3Wrapper.sol";
import "../plugins/assets/stargate/StargateRewardableWrapper.sol";
import { StaticATokenV3LM } from "../plugins/assets/aave-v3/vendor/StaticATokenV3LM.sol";
import "../plugins/assets/morpho-aave/MorphoAaveV2TokenisedDeposit.sol";
Expand Down Expand Up @@ -174,7 +174,7 @@ contract FacadeMonitor is Initializable, OwnableUpgradeable, UUPSUpgradeable, IF
backingBalance = (cTokenBal * exchangeRate) / 1e18;
availableLiquidity = underlying.balanceOf(address(cToken));
} else if (collType == CollPluginType.COMPOUND_V3) {
ICusdcV3Wrapper cTokenV3Wrapper = ICusdcV3Wrapper(address(erc20));
ICFiatV3Wrapper cTokenV3Wrapper = ICFiatV3Wrapper(address(erc20));
CometInterface cTokenV3 = CometInterface(address(cTokenV3Wrapper.underlyingComet()));
IERC20 underlying = IERC20(cTokenV3.baseToken());

Expand Down
13 changes: 8 additions & 5 deletions contracts/facade/FacadeWrite.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pragma solidity 0.8.19;

import "../interfaces/IFacadeWrite.sol";
import "../interfaces/IDeployer.sol";
import "./lib/FacadeWriteLib.sol";

/**
Expand All @@ -21,10 +22,11 @@ contract FacadeWrite is IFacadeWrite {
}

/// Step 1
function deployRToken(ConfigurationParams calldata config, SetupParams calldata setup)
external
returns (address)
{
function deployRToken(
ConfigurationParams calldata config,
SetupParams calldata setup,
IDeployer.Registries calldata registries
) external returns (address) {
// Perform validations
require(setup.primaryBasket.length != 0, "no collateral");
require(setup.primaryBasket.length == setup.weights.length, "invalid length");
Expand All @@ -51,7 +53,8 @@ contract FacadeWrite is IFacadeWrite {
config.symbol,
config.mandate,
address(this), // set as owner
config.params
config.params,
registries
)
);

Expand Down
26 changes: 12 additions & 14 deletions contracts/interfaces/IDeployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ import "./IStRSR.sol";
import "./ITrade.sol";
import "./IVersioned.sol";

import "../registry/VersionRegistry.sol";
import "../registry/AssetPluginRegistry.sol";
import "../registry/DAOFeeRegistry.sol";

/**
* @title DeploymentParams
* @notice The set of protocol params needed to configure a new system deployment.
Expand Down Expand Up @@ -92,21 +96,27 @@ interface IDeployer is IVersioned {
/// @param rTokenAsset The address of the RTokenAsset
event RTokenAssetCreated(IRToken indexed rToken, IAsset rTokenAsset);

//
struct Registries {
VersionRegistry versionRegistry;
AssetPluginRegistry assetPluginRegistry;
DAOFeeRegistry daoFeeRegistry;
}

/// Deploys an instance of the entire system
/// @param name The name of the RToken to deploy
/// @param symbol The symbol of the RToken to deploy
/// @param mandate An IPFS link or direct string; describes what the RToken _should be_
/// @param owner The address that should own the entire system, hopefully a governance contract
/// @param params Deployment params
/// @param registries Registries list; can be 0 to unset
/// @return The address of the newly deployed Main instance.
function deploy(
string calldata name,
string calldata symbol,
string calldata mandate,
address owner,
DeploymentParams calldata params
DeploymentParams calldata params,
Registries calldata registries
) external returns (address);

/// Deploys a new RTokenAsset instance. Not needed during normal deployment flow
Expand All @@ -115,15 +125,3 @@ interface IDeployer is IVersioned {

function implementations() external view returns (Implementations memory);
}

interface TestIDeployer is IDeployer {
/// A top-level ENS domain that should always point to the latest Deployer instance
// solhint-disable-next-line func-name-mixedcase
function ENS() external view returns (string memory);

function rsr() external view returns (IERC20Metadata);

function rsrAsset() external view returns (IAsset);

function implementations() external view returns (Implementations memory);
}
8 changes: 5 additions & 3 deletions contracts/interfaces/IFacadeWrite.sol
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@ interface IFacadeWrite {
);

/// Deploys an instance of an RToken
function deployRToken(ConfigurationParams calldata config, SetupParams calldata setup)
external
returns (address);
function deployRToken(
ConfigurationParams calldata config,
SetupParams calldata setup,
IDeployer.Registries calldata registries
) external returns (address);

/// Sets up governance for an RToken
function setupGovernance(
Expand Down
5 changes: 2 additions & 3 deletions contracts/p0/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import "../mixins/Versioned.sol";
* @notice The factory contract that deploys the entire P0 system.
*/
contract DeployerP0 is IDeployer, Versioned {
string public constant ENS = "reserveprotocol.eth";

IERC20Metadata public immutable rsr;
IGnosis public immutable gnosis;
IAsset public immutable rsrAsset;
Expand Down Expand Up @@ -61,7 +59,8 @@ contract DeployerP0 is IDeployer, Versioned {
string memory symbol,
string calldata mandate,
address owner,
DeploymentParams memory params
DeploymentParams memory params,
Registries calldata // ignored
) external returns (address) {
require(owner != address(0) && owner != address(this), "invalid owner");

Expand Down
17 changes: 14 additions & 3 deletions contracts/p1/Deployer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ import "../plugins/trading/GnosisTrade.sol";
contract DeployerP1 is IDeployer, Versioned {
using Clones for address;

string public constant ENS = "reserveprotocol.eth";

IERC20Metadata public immutable rsr;
IAsset public immutable rsrAsset;

Expand Down Expand Up @@ -106,7 +104,8 @@ contract DeployerP1 is IDeployer, Versioned {
string memory symbol,
string calldata mandate,
address owner,
DeploymentParams memory params
DeploymentParams memory params,
Registries calldata registries
) external returns (address) {
require(owner != address(0) && owner != address(this), "invalid owner");

Expand Down Expand Up @@ -251,11 +250,23 @@ contract DeployerP1 is IDeployer, Versioned {
// Init Asset Registry
components.assetRegistry.init(main, assets);

// Assign DAO Registries
if (address(registries.versionRegistry) != address(0)) {
main.setVersionRegistry(registries.versionRegistry);
}
if (address(registries.assetPluginRegistry) != address(0)) {
main.setAssetPluginRegistry(registries.assetPluginRegistry);
}
if (address(registries.daoFeeRegistry) != address(0)) {
main.setDAOFeeRegistry(registries.daoFeeRegistry);
}

// Transfer Ownership
main.grantRole(OWNER, owner);
main.renounceRole(OWNER, address(this));

emit RTokenCreated(main, components.rToken, components.stRSR, owner, version());

return (address(components.rToken));
}

Expand Down
Loading

0 comments on commit 2339fbe

Please sign in to comment.