-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init * sphereX integration * changed to onlyOwner * refactored * added migration contract & made method external * added integration & bugfixes * rm debug lines * fixed govPoolMigration * rm param name * rm import * added protected public beacon proxy * impl tiny improvements
- Loading branch information
Showing
15 changed files
with
313 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@spherex-xyz/contracts/src/SphereXProtectedBase.sol"; | ||
|
||
contract GovPoolMigration { | ||
address internal immutable DEPLOYER; | ||
|
||
constructor() { | ||
DEPLOYER = msg.sender; | ||
} | ||
|
||
modifier onlyDeployer() { | ||
_onlyDeployer(); | ||
_; | ||
} | ||
|
||
function acceptSphereXAdmins(address[] calldata sphereXProxies) external onlyDeployer { | ||
for (uint256 i = 0; i < sphereXProxies.length; ++i) { | ||
SphereXProtectedBase(sphereXProxies[i]).acceptSphereXAdminRole(); | ||
} | ||
} | ||
|
||
function _onlyDeployer() internal { | ||
require(msg.sender == DEPLOYER, "Gov: caller is not a deployer"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@spherex-xyz/contracts/src/SphereXProxyStorage.sol"; | ||
import "@spherex-xyz/contracts/src/ProtectedProxies/ISphereXBeacon.sol"; | ||
|
||
import "@solarity/solidity-lib/contracts-registry/pools/proxy/ProxyBeacon.sol"; | ||
|
||
contract PoolBeacon is ISphereXBeacon, SphereXProxyBase, ProxyBeacon { | ||
constructor( | ||
address sphereXAdmin, | ||
address sphereXOperator, | ||
address sphereXEngine | ||
) SphereXProxyBase(sphereXAdmin, sphereXOperator, sphereXEngine) {} | ||
|
||
function protectedImplementation( | ||
bytes4 selector | ||
) external view returns (address, address, bool) { | ||
return (implementation(), sphereXEngine(), isProtectedFuncSig(selector)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@openzeppelin/contracts/proxy/beacon/IBeacon.sol"; | ||
|
||
import "@spherex-xyz/contracts/src/ProtectedProxies/ProtectedBeaconProxy.sol"; | ||
|
||
contract ProtectedPublicBeaconProxy is ProtectedBeaconProxy { | ||
constructor(address beacon, bytes memory data) ProtectedBeaconProxy(beacon, data) {} | ||
|
||
function implementation() external view returns (address) { | ||
return IBeacon(_getBeacon()).implementation(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.20; | ||
|
||
import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; | ||
|
||
import "@spherex-xyz/contracts/src/SphereXProtectedProxy.sol"; | ||
|
||
contract ProtectedTransparentProxy is SphereXProtectedProxy, TransparentUpgradeableProxy { | ||
constructor( | ||
address sphereXAdmin, | ||
address sphereXOperator, | ||
address sphereXEngine, | ||
address implementation, | ||
address proxyAdmin, | ||
bytes memory data | ||
) | ||
SphereXProtectedProxy(sphereXAdmin, sphereXOperator, sphereXEngine) | ||
TransparentUpgradeableProxy(implementation, proxyAdmin, data) | ||
{} | ||
|
||
function _fallback() internal virtual override(Proxy, TransparentUpgradeableProxy) { | ||
TransparentUpgradeableProxy._fallback(); | ||
} | ||
|
||
function _delegate( | ||
address implementation | ||
) internal virtual override(Proxy, SphereXProtectedProxy) { | ||
SphereXProtectedProxy._delegate(implementation); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
const Proxy = artifacts.require("ERC1967Proxy"); | ||
const ContractsRegistry = artifacts.require("ContractsRegistry"); | ||
const PoolRegistry = artifacts.require("PoolRegistry"); | ||
const SphereXProtectedBase = artifacts.require("ProtectedTransparentProxy"); | ||
const GovPool = artifacts.require("GovPool"); | ||
const GovPoolMigration = artifacts.require("GovPoolMigration"); | ||
|
||
module.exports = async (deployer, logger) => { | ||
const contractsRegistry = await ContractsRegistry.at((await Proxy.deployed()).address); | ||
|
||
const poolRegistry = await PoolRegistry.at(await contractsRegistry.getPoolRegistryContract()); | ||
|
||
const proxies = [ | ||
["PoolRegistry", poolRegistry.address], | ||
["UserRegistry", await contractsRegistry.getUserRegistryContract()], | ||
["PoolFactory", await contractsRegistry.getPoolFactoryContract()], | ||
["DexeExpertNft", await contractsRegistry.getDexeExpertNftContract()], | ||
["PriceFeed", await contractsRegistry.getPriceFeedContract()], | ||
["CoreProperties", await contractsRegistry.getCorePropertiesContract()], | ||
["GovPool", await poolRegistry.getProxyBeacon(await poolRegistry.GOV_POOL_NAME())], | ||
["GovSettings", await poolRegistry.getProxyBeacon(await poolRegistry.SETTINGS_NAME())], | ||
["GovValidators", await poolRegistry.getProxyBeacon(await poolRegistry.VALIDATORS_NAME())], | ||
["GovUserKeeper", await poolRegistry.getProxyBeacon(await poolRegistry.USER_KEEPER_NAME())], | ||
["DistributionProposal", await poolRegistry.getProxyBeacon(await poolRegistry.DISTRIBUTION_PROPOSAL_NAME())], | ||
["TokenSaleProposal", await poolRegistry.getProxyBeacon(await poolRegistry.TOKEN_SALE_PROPOSAL_NAME())], | ||
["ExpertNft", await poolRegistry.getProxyBeacon(await poolRegistry.EXPERT_NFT_NAME())], | ||
["NftMultiplier", await poolRegistry.getProxyBeacon(await poolRegistry.NFT_MULTIPLIER_NAME())], | ||
["LinearPower", await poolRegistry.getProxyBeacon(await poolRegistry.LINEAR_POWER_NAME())], | ||
["PolynomialPower", await poolRegistry.getProxyBeacon(await poolRegistry.POLYNOMIAL_POWER_NAME())], | ||
]; | ||
|
||
logger.logContracts(...proxies); | ||
|
||
const govPoolImplementation = await poolRegistry.getImplementation(await poolRegistry.GOV_POOL_NAME()); | ||
const govPoolMigration = (await deployer.deploy(GovPoolMigration)).address; | ||
|
||
logger.logTransaction( | ||
await poolRegistry.setNewImplementations([await poolRegistry.GOV_POOL_NAME()], [govPoolMigration]), | ||
"Setting a default GovPool implementation" | ||
); | ||
|
||
for (const [contractName, proxy] of proxies) { | ||
logger.logTransaction( | ||
await (await SphereXProtectedBase.at(proxy)).transferSphereXAdminRole(deployer.dexeDaoAddress), | ||
`Transferring a SphereX admin role for the ${contractName} proxy` | ||
); | ||
} | ||
|
||
logger.logTransaction( | ||
await (await GovPoolMigration.at(deployer.dexeDaoAddress)).acceptSphereXAdmins(proxies.map((e) => e[1])), | ||
"Accepting SphereX admin roles" | ||
); | ||
|
||
logger.logTransaction( | ||
await poolRegistry.setNewImplementations([await poolRegistry.GOV_POOL_NAME()], [govPoolImplementation]), | ||
"Setting a default GovPool implementation" | ||
); | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.