Skip to content

Commit

Permalink
Merge pull request #45 from soramitsu/revert-42-feature/code_document…
Browse files Browse the repository at this point in the history
…ation

Revert "[Documentation] include NatSpec comments for factory and interfaces"
  • Loading branch information
SergeyPoslavskiy authored Jul 10, 2024
2 parents 3376fae + 3ca1e6a commit 1e33dc8
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 370 deletions.
72 changes: 2 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,2 @@

# StakePad Staking Pool

This repository contains the smart contracts and tests for an ERC20 Lockup Staking Pool.

## Setup

### Installation

Install the required dependencies by running:

```
npm install
```

### Environment Variables

Before running the project, you need to set up the environment variables. Create a `.env` file in the root directory of the project and add the following variables:

```
AMOY_API_KEY="Your_Amoy_API_Key"
PRIVATE_KEY="0xYour_Wallet_Private_Key"
```

To get your AMOY API key, please refer to the [AMOY Documentation](https://docs.polygonscan.com/getting-started/viewing-api-usage-statistics#creating-an-api-key).

## Running Tests

To run all unit tests, use the following command:

```
npx hardhat test
```

Make sure you have provided the necessary environment variables in the `.env` file before running the tests.

## Deployment

Before deploying the smart contracts, ensure you have set up all required parameters in your `.env` file as described above.

### Deploying the Contracts

To deploy the ERC20 Lockup Staking Pool smart contracts, run the following command:

```
npx hardhat run scripts/deployStakingPool.ts --network `network`
```

Replace `network` with the desired network name. The network should be configured in your `hardhat.config.ts` file under the `networks` section. Please refer to the [Hardhat Networks Configuration](https://hardhat.org/hardhat-runner/docs/config#networks-configuration) guide for more information.

Currently, the following networks are already configured:

- hardhat (default)


Example for deploying to the default hardhat network:

```bash
npx hardhat ignition deploy ignition\modules\factories.ts -network 'your_netwrok'
```

## Documentation

This repository contains the specifications and audit reports for the ERC20 Lockup Staking Pool smart contracts. For more detailed information, please refer to the [Documentation](./docs/README.md).

## Support

If you have any questions or need further assistance, feel free to open an issue on the repository or contact the maintainers.

Happy coding!
# stakepad-contracts
Designing a Better World Through Decentralized Technologies
30 changes: 3 additions & 27 deletions contracts/factories/ERC20LockUpFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

/// @title ERC20LockUpStakingFactory
/// @notice A smart contract for deploying ERC20 LockUp staking pools.
/// @dev This contract uses Ownable for ownership and ILockUpFactory for factory functionality.
/// @author Ayooluwa Akindeko, Soramitsu team
contract ERC20LockUpStakingFactory is Ownable, ILockUpFactory {
using SafeERC20 for IERC20;

/// @notice Array to store addresses of deployed staking pools.
address[] public stakingPools;

/// @notice Array to store requests for staking pools.
LockUpRequest[] public requests;

/// @notice Mapping to store pool address by request ID.
mapping(uint256 id => address pool) public poolById;

/// @notice Constructor sets the owner of the contract.
constructor() Ownable(msg.sender) {}

/// @notice Deploys a new LockUp staking pool.
/// @param id ID of the request to be deployed.
/// @return newPoolAddress Address of the newly deployed staking pool.
/// @notice Function allows users to deploy the LockUp staking pool with specified parameters
function deploy(uint256 id) public returns (address newPoolAddress) {
if (requests.length <= id) revert InvalidId();
LockUpRequest memory req = requests[id];
Expand Down Expand Up @@ -75,9 +66,6 @@ contract ERC20LockUpStakingFactory is Ownable, ILockUpFactory {
emit StakingPoolDeployed(newPoolAddress, id);
}

/// @notice Requests deployment of a new LockUp staking pool.
/// @param ipfsHash IPFS hash of the request data.
/// @param data Deployment data for the staking pool.
function requestDeployment(
bytes32 ipfsHash,
DeploymentData calldata data
Expand All @@ -102,30 +90,22 @@ contract ERC20LockUpStakingFactory is Ownable, ILockUpFactory {
);
}

/// @notice Approves a deployment request.
/// @param id ID of the request to be approved.
function approveRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
if (req.info.requestStatus != Status.CREATED)
revert InvalidRequestStatus();
if (req.info.requestStatus != Status.CREATED) revert InvalidRequestStatus();
req.info.requestStatus = Status.APPROVED;
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Denies a deployment request.
/// @param id ID of the request to be denied.
function denyRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
if (req.info.requestStatus != Status.CREATED)
revert InvalidRequestStatus();
if (req.info.requestStatus != Status.CREATED) revert InvalidRequestStatus();
req.info.requestStatus = Status.DENIED;
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Cancels a deployment request.
/// @param id ID of the request to be canceled.
function cancelRequest(uint256 id) external {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
Expand All @@ -138,14 +118,10 @@ contract ERC20LockUpStakingFactory is Ownable, ILockUpFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Returns all deployment requests.
/// @return reqs Array of all LockUp requests.
function getRequests() external view returns (LockUpRequest[] memory reqs) {
reqs = requests;
}

/// @notice Returns all deployed staking pools.
/// @return pools Array of all staking pool addresses.
function getPools() external view returns (address[] memory pools) {
pools = stakingPools;
}
Expand Down
26 changes: 2 additions & 24 deletions contracts/factories/ERC20PenaltyFeeFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,18 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

/// @title ERC20PenaltyFeeStakingFactory
/// @notice A smart contract for deploying ERC20 staking pools with penalty fees.
/// @dev This contract uses Ownable for ownership and IPenaltyFeeFactory for factory functionality.
/// @author Ayooluwa Akindeko, Soramitsu team
contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
using SafeERC20 for IERC20;

/// @notice Array to store addresses of deployed staking pools.
address[] public stakingPools;

/// @notice Array to store requests for staking pools.
PenaltyFeeRequest[] public requests;

/// @notice Mapping to store pool address by request ID.
mapping(uint256 id => address pool) public poolById;

/// @notice Constructor sets the owner of the contract.
constructor() Ownable(msg.sender) {}

/// @notice Deploys a new PenaltyFee staking pool.
/// @param id ID of the request to be deployed.
/// @return newPoolAddress Address of the newly deployed staking pool.
function deploy(uint256 id) public returns (address newPoolAddress) {
/// @notice Function allows users to deploy the penaltyFee staking pool with specified parameters
function deploy(uint256 id) public returns (address newPoolAddress) {
if (requests.length < id) revert InvalidId();
PenaltyFeeRequest memory req = requests[id];
if (req.info.requestStatus != Status.APPROVED) revert InvalidRequestStatus();
Expand Down Expand Up @@ -74,9 +65,6 @@ contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
emit StakingPoolDeployed(newPoolAddress, id);
}

/// @notice Requests deployment of a new PenaltyFee staking pool.
/// @param ipfsHash IPFS hash of the request data.
/// @param data Deployment data for the staking pool.
function requestDeployment(bytes32 ipfsHash, DeploymentData calldata data) external {
if (data.stakeToken == address(0) || data.rewardToken == address(0))
revert InvalidTokenAddress();
Expand All @@ -98,8 +86,6 @@ contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
);
}

/// @notice Approves a deployment request.
/// @param id ID of the request to be approved.
function approveRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
PenaltyFeeRequest storage req = requests[id];
Expand All @@ -108,8 +94,6 @@ contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Denies a deployment request.
/// @param id ID of the request to be denied.
function denyRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
PenaltyFeeRequest storage req = requests[id];
Expand All @@ -118,8 +102,6 @@ contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Cancels a deployment request.
/// @param id ID of the request to be canceled.
function cancelRequest(uint256 id) external {
if (requests.length <= id) revert InvalidId();
PenaltyFeeRequest storage req = requests[id];
Expand All @@ -132,14 +114,10 @@ contract ERC20PenaltyFeeStakingFactory is Ownable, IPenaltyFeeFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Returns all deployment requests.
/// @return reqs Array of all PenaltyFee requests.
function getRequests() external view returns (PenaltyFeeRequest[] memory reqs) {
reqs = requests;
}

/// @notice Returns all deployed staking pools.
/// @return pools Array of all staking pool addresses.
function getPools() external view returns (address[] memory pools) {
pools = stakingPools;
}
Expand Down
24 changes: 1 addition & 23 deletions contracts/factories/ERC721LockUpFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,17 @@ import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol

/// @title ERC721LockUpStakingFactory
/// @notice A smart contract for deploying ERC721 LockUp staking pools.
/// @dev This contract uses Ownable for ownership and ILockUpFactory for factory functionality.
/// @author Ayooluwa Akindeko, Soramitsu team
contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
using SafeERC20 for IERC20;

/// @notice Array to store addresses of deployed staking pools.
address[] public stakingPools;

/// @notice Array to store requests for staking pools.
LockUpRequest[] public requests;

/// @notice Mapping to store pool address by request ID.
mapping(uint256 id => address pool) public poolById;

/// @notice Constructor sets the owner of the contract.
constructor() Ownable(msg.sender) {}

/// @notice Function allows users to deploy the LockUp staking pool with specified parameters.
/// @param id ID of the request to be deployed.
/// @return newPoolAddress Address of the newly deployed staking pool.
/// @notice Function allows users to deploy the LockUp staking pool with specified parameters
function deploy(uint256 id) public returns (address newPoolAddress) {
if (requests.length < id) revert InvalidId();
LockUpRequest memory req = requests[id];
Expand Down Expand Up @@ -75,9 +66,6 @@ contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
emit StakingPoolDeployed(newPoolAddress, id);
}

/// @notice Requests deployment of a new LockUp staking pool.
/// @param ipfsHash IPFS hash of the request data.
/// @param data Deployment data for the staking pool.
function requestDeployment(
bytes32 ipfsHash,
DeploymentData calldata data
Expand All @@ -102,8 +90,6 @@ contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
);
}

/// @notice Approves a deployment request.
/// @param id ID of the request to be approved.
function approveRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
Expand All @@ -113,8 +99,6 @@ contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Denies a deployment request.
/// @param id ID of the request to be denied.
function denyRequest(uint256 id) external onlyOwner {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
Expand All @@ -124,8 +108,6 @@ contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Cancels a deployment request.
/// @param id ID of the request to be canceled.
function cancelRequest(uint256 id) external {
if (requests.length <= id) revert InvalidId();
LockUpRequest storage req = requests[id];
Expand All @@ -138,14 +120,10 @@ contract ERC721LockUpStakingFactory is Ownable, ILockUpFactory {
emit RequestStatusChanged(id, req.info.requestStatus);
}

/// @notice Returns all deployment requests.
/// @return reqs Array of all LockUp requests.
function getRequests() external view returns (LockUpRequest[] memory reqs) {
reqs = requests;
}

/// @notice Returns all deployed staking pools.
/// @return pools Array of all staking pool addresses.
function getPools() external view returns (address[] memory pools) {
pools = stakingPools;
}
Expand Down
Loading

0 comments on commit 1e33dc8

Please sign in to comment.