Skip to content

Commit

Permalink
Merge pull request #177 from dexe-network/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Arvolear authored Nov 7, 2023
2 parents 48d8d24 + ca4725e commit f4186c5
Show file tree
Hide file tree
Showing 372 changed files with 54,218 additions and 40,930 deletions.
12 changes: 12 additions & 0 deletions .docs/gen-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

rm -rf generated-markups

npm run generate-markups

echo "Markups have been generated. Moving..."

mkdir -p docs
rsync -av --delete generated-markups/contracts/interfaces/ docs

rm -r generated-markups
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ coverage
# Typechain generated files
generated-types
generated-markups

# Hardhat migrate files
.storage.json
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run lint-fix && git add -u
npm run lint-fix && npm run generate-docs && git add -u
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# DEXE DAO
86 changes: 73 additions & 13 deletions contracts/core/ContractsRegistry.sol
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
pragma solidity ^0.8.20;

import "@openzeppelin/contracts/proxy/utils/UUPSUpgradeable.sol";

import "@dlsl/dev-modules/contracts-registry/presets/OwnableContractsRegistry.sol";
import "@solarity/solidity-lib/contracts-registry/presets/MultiOwnableContractsRegistry.sol";

import "@spherex-xyz/engine-contracts/src/SphereXEngine.sol";

import "../interfaces/core/IContractsRegistry.sol";

contract ContractsRegistry is IContractsRegistry, OwnableContractsRegistry, UUPSUpgradeable {
import "../proxy/ProtectedTransparentProxy.sol";

contract ContractsRegistry is IContractsRegistry, MultiOwnableContractsRegistry, UUPSUpgradeable {
string public constant USER_REGISTRY_NAME = "USER_REGISTRY";

string public constant POOL_FACTORY_NAME = "POOL_FACTORY";
Expand All @@ -16,17 +20,44 @@ contract ContractsRegistry is IContractsRegistry, OwnableContractsRegistry, UUPS
string public constant DEXE_NAME = "DEXE";
string public constant USD_NAME = "USD";
string public constant BABT_NAME = "BABT";
string public constant DEXE_EXPERT_NFT_NAME = "DEXE_EXPERT_NFT";

string public constant PRICE_FEED_NAME = "PRICE_FEED";
string public constant UNISWAP_V2_ROUTER_NAME = "UNISWAP_V2_ROUTER";
string public constant UNISWAP_V2_FACTORY_NAME = "UNISWAP_V2_FACTORY";

string public constant INSURANCE_NAME = "INSURANCE";
string public constant TREASURY_NAME = "TREASURY";
string public constant DIVIDENDS_NAME = "DIVIDENDS";

string public constant CORE_PROPERTIES_NAME = "CORE_PROPERTIES";

string public constant SPHEREX_ENGINE_NAME = "SPHEREX_ENGINE";
string public constant POOL_SPHEREX_ENGINE_NAME = "POOL_SPHEREX_ENGINE";

function toggleSphereXEngine(bool on) external onlyOwner {
address sphereXEngine = on ? getSphereXEngineContract() : address(0);

_setSphereXEngine(USER_REGISTRY_NAME, sphereXEngine);
_setSphereXEngine(POOL_FACTORY_NAME, sphereXEngine);
_setSphereXEngine(POOL_REGISTRY_NAME, sphereXEngine);
_setSphereXEngine(DEXE_EXPERT_NFT_NAME, sphereXEngine);
_setSphereXEngine(PRICE_FEED_NAME, sphereXEngine);
_setSphereXEngine(CORE_PROPERTIES_NAME, sphereXEngine);
}

function protectContractFunctions(
string calldata contractName,
bytes4[] calldata selectors
) external onlyOwner {
SphereXProxyBase(getContract(contractName)).addProtectedFuncSigs(selectors);
}

function unprotectContractFunctions(
string calldata contractName,
bytes4[] calldata selectors
) external onlyOwner {
SphereXProxyBase(getContract(contractName)).removeProtectedFuncSigs(selectors);
}

function getUserRegistryContract() external view override returns (address) {
return getContract(USER_REGISTRY_NAME);
}
Expand Down Expand Up @@ -59,18 +90,10 @@ contract ContractsRegistry is IContractsRegistry, OwnableContractsRegistry, UUPS
return getContract(UNISWAP_V2_FACTORY_NAME);
}

function getInsuranceContract() external view override returns (address) {
return getContract(INSURANCE_NAME);
}

function getTreasuryContract() external view override returns (address) {
return getContract(TREASURY_NAME);
}

function getDividendsContract() external view override returns (address) {
return getContract(DIVIDENDS_NAME);
}

function getCorePropertiesContract() external view override returns (address) {
return getContract(CORE_PROPERTIES_NAME);
}
Expand All @@ -79,5 +102,42 @@ contract ContractsRegistry is IContractsRegistry, OwnableContractsRegistry, UUPS
return getContract(BABT_NAME);
}

function getDexeExpertNftContract() external view override returns (address) {
return getContract(DEXE_EXPERT_NFT_NAME);
}

function getPoolSphereXEngineContract() external view override returns (address) {
return getContract(POOL_SPHEREX_ENGINE_NAME);
}

function getSphereXEngineContract() public view override returns (address) {
return getContract(SPHEREX_ENGINE_NAME);
}

function _setSphereXEngine(string memory contractName, address sphereXEngine) internal {
ProtectedTransparentProxy(payable(getContract(contractName))).changeSphereXEngine(
sphereXEngine
);
}

function _deployProxy(
address contractAddress,
address admin,
bytes memory data
) internal override returns (address proxy) {
proxy = address(
new ProtectedTransparentProxy(
msg.sender,
address(this),
address(0),
contractAddress,
admin,
data
)
);

ISphereXEngine(getSphereXEngineContract()).addAllowedSenderOnChain(proxy);
}

function _authorizeUpgrade(address newImplementation) internal override onlyOwner {}
}
Loading

0 comments on commit f4186c5

Please sign in to comment.