Skip to content

Commit

Permalink
Feat/general improvements (#308)
Browse files Browse the repository at this point in the history
* chore: update nft supply cap & fix supplyLogic contract size

Signed-off-by: GopherJ <[email protected]>

* feat(para-proxy): adds diamond loupe interfaces (#294)

* chore: update ape ir

Signed-off-by: GopherJ <[email protected]>

* feat: improve pool upgrade script

Signed-off-by: GopherJ <[email protected]>

* fix: configurator tests

Signed-off-by: GopherJ <[email protected]>

* chore: add libraries

Signed-off-by: GopherJ <[email protected]>

* chore: cleanup mintableLogic, apeStakingLogic deployment

Signed-off-by: GopherJ <[email protected]>

* chore: cleanup

Signed-off-by: GopherJ <[email protected]>

Signed-off-by: GopherJ <[email protected]>
Co-authored-by: Walid <[email protected]>
  • Loading branch information
0x8f701 and WalidOfNow authored Jan 2, 2023
1 parent 6e0dbb9 commit 8afdb27
Show file tree
Hide file tree
Showing 16 changed files with 425 additions and 336 deletions.
11 changes: 0 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -418,17 +418,6 @@ upgrade-ptoken: build
upgrade-debt-token: build
make TASK_NAME=upgrade:debt-token run-task

.PHONY: remove-pool-funcs
remove-pool-funcs: build
# e.g: emergency disable liquidation
FUNCS_TO_REMOVE=[0x3d7b66bf,0xd134142e] make TASK_NAME=upgrade:remove-pool-funcs run-task

.PHONY: add-pool-funcs
add-pool-funcs: build
# e.g: add liquidation back
FUNCS_TO_ADD=[0x3d7b66bf,0xd134142e] make TASK_NAME=upgrade:add-pool-funcs run-task


.PHONY: hardhat
hardhat:
npx hardhat node --hostname 0.0.0.0
Expand Down
5 changes: 0 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@
[![Medium](https://img.shields.io/badge/Medium-gray?logo=medium)](https://medium.com/@paraspace)
[![Discourse](https://img.shields.io/badge/Forum-gray?logo=discourse)](https://discourse.para.space)

[![Discord chat][discord-badge]][discord-url]

[discord-badge]: https://img.shields.io/discord/830972820846018600.svg?logo=discord&style=flat-square
[discord-url]: https://discord.com/invite/buKKx4dySW

This repository contains the core smart contracts for the Para-Space v1 Protocol.
For higher level contracts, see the [ paraspace-periphery](https://github.com/para-space/paraspace-periphery)
repository.
Expand Down
45 changes: 45 additions & 0 deletions contracts/interfaces/IParaProxyInterfaces.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/******************************************************************************\
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

// interfaces that are compatible with Diamond proxy loupe functions
interface IParaProxyInterfaces {
/// These functions are expected to be called frequently
/// by tools.

struct Implementation {
address implAddress;
bytes4[] functionSelectors;
}

/// @notice Gets all facet addresses and their four byte function selectors.
/// @return facets_ Implementation
function facets() external view returns (Implementation[] memory facets_);

/// @notice Gets all the function selectors supported by a specific facet.
/// @param _facet The facet address.
/// @return facetFunctionSelectors_
function facetFunctionSelectors(address _facet)
external
view
returns (bytes4[] memory facetFunctionSelectors_);

/// @notice Get all the facet addresses used by a diamond.
/// @return facetAddresses_
function facetAddresses()
external
view
returns (address[] memory facetAddresses_);

/// @notice Gets the facet that supports the given selector.
/// @dev If facet is not found return address(0).
/// @param _functionSelector The function selector.
/// @return facetAddress_ The facet address.
function facetAddress(bytes4 _functionSelector)
external
view
returns (address facetAddress_);
}
4 changes: 3 additions & 1 deletion contracts/interfaces/IPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity 0.8.10;
import {IPoolCore} from "./IPoolCore.sol";
import {IPoolMarketplace} from "./IPoolMarketplace.sol";
import {IPoolParameters} from "./IPoolParameters.sol";
import {IParaProxyInterfaces} from "./IParaProxyInterfaces.sol";
import "./IPoolApeStaking.sol";

/**
Expand All @@ -15,7 +16,8 @@ interface IPool is
IPoolCore,
IPoolMarketplace,
IPoolParameters,
IPoolApeStaking
IPoolApeStaking,
IParaProxyInterfaces
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/******************************************************************************\
* EIP-2535 Diamonds: https://eips.ethereum.org/EIPS/eip-2535
/******************************************************************************/

import {IParaProxyInterfaces} from "../../../interfaces/IParaProxyInterfaces.sol";
import {IERC165} from "../../../dependencies/openzeppelin/contracts/IERC165.sol";
import {ParaProxyLib} from "./lib/ParaProxyLib.sol";

// The EIP-2535 Diamond standard requires these functions.

contract ParaProxyInterfaces is IParaProxyInterfaces, IERC165 {
////////////////////////////////////////////////////////////////////
/// These functions are expected to be called frequently by tools.
// Facet == Implementtion

/// @notice Gets all facets and their selectors.
/// @return facets_ Implementation
function facets()
external
view
override
returns (Implementation[] memory facets_)
{
ParaProxyLib.ProxyStorage storage ds = ParaProxyLib.diamondStorage();
uint256 numFacets = ds.implementationAddresses.length;
facets_ = new Implementation[](numFacets);
for (uint256 i; i < numFacets; i++) {
address facetAddress_ = ds.implementationAddresses[i];
facets_[i].implAddress = facetAddress_;
facets_[i].functionSelectors = ds
.implementationFunctionSelectors[facetAddress_]
.functionSelectors;
}
}

/// @notice Gets all the function selectors provided by a facet.
/// @param _facet The facet address.
/// @return facetFunctionSelectors_
function facetFunctionSelectors(address _facet)
external
view
override
returns (bytes4[] memory facetFunctionSelectors_)
{
ParaProxyLib.ProxyStorage storage ds = ParaProxyLib.diamondStorage();
facetFunctionSelectors_ = ds
.implementationFunctionSelectors[_facet]
.functionSelectors;
}

/// @notice Get all the facet addresses used by a diamond.
/// @return facetAddresses_
function facetAddresses()
external
view
override
returns (address[] memory facetAddresses_)
{
ParaProxyLib.ProxyStorage storage ds = ParaProxyLib.diamondStorage();
facetAddresses_ = ds.implementationAddresses;
}

/// @notice Gets the facet that supports the given selector.
/// @dev If facet is not found return address(0).
/// @param _functionSelector The function selector.
/// @return facetAddress_ The facet address.
function facetAddress(bytes4 _functionSelector)
external
view
override
returns (address facetAddress_)
{
ParaProxyLib.ProxyStorage storage ds = ParaProxyLib.diamondStorage();
facetAddress_ = ds
.selectorToImplAndPosition[_functionSelector]
.implAddress;
}

// This implements ERC-165.
function supportsInterface(bytes4 _interfaceId)
external
view
override
returns (bool)
{
ParaProxyLib.ProxyStorage storage ds = ParaProxyLib.diamondStorage();

return (type(IParaProxyInterfaces).interfaceId == _interfaceId ||
ds.supportedInterfaces[_interfaceId]);
}
}
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const hardhatConfig: HardhatUserConfig = {
settings: {
optimizer: {
enabled: true,
runs: 4000,
runs: 2000,
},
evmVersion: "london",
},
Expand Down
Loading

0 comments on commit 8afdb27

Please sign in to comment.