-
Notifications
You must be signed in to change notification settings - Fork 148
/
CometProxyAdmin.sol
30 lines (26 loc) · 1.15 KB
/
CometProxyAdmin.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.8.15;
import "./vendor/proxy/transparent/ProxyAdmin.sol";
interface Deployable {
function deploy(address cometProxy) external returns (address);
}
contract CometProxyAdmin is ProxyAdmin {
/**
* @dev Deploy a new Comet and upgrade the implementation of the Comet proxy
* Requirements:
* - This contract must be the admin of `CometProxy`
*/
function deployAndUpgradeTo(Deployable configuratorProxy, TransparentUpgradeableProxy cometProxy) public virtual onlyOwner {
address newCometImpl = configuratorProxy.deploy(address(cometProxy));
upgrade(cometProxy, newCometImpl);
}
/**
* @dev Deploy a new Comet and upgrade the implementation of the Comet proxy, then call the function
* Requirements:
* - This contract must be the admin of `CometProxy`
*/
function deployUpgradeToAndCall(Deployable configuratorProxy, TransparentUpgradeableProxy cometProxy, bytes memory data) public virtual onlyOwner {
address newCometImpl = configuratorProxy.deploy(address(cometProxy));
upgradeAndCall(cometProxy, newCometImpl, data);
}
}