Skip to content

Commit

Permalink
Merge branch 'feature/codeDocumentation' of https://github.com/sorami…
Browse files Browse the repository at this point in the history
…tsu/stakepad-contracts into feature/codeDocumentation
  • Loading branch information
ayodeko committed Jul 26, 2024
2 parents 05ebc22 + ac8156f commit 41c3055
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contracts/factories/ERC20LockUpFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ contract ERC20LockUpStakingFactory is GenericFactory, ILockUpFactory {
uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) *
data.rewardPerSecond;
ERC20LockUpPool(newPoolAddress).transferOwnership(deployer);
// Transfer reward tokens from the owner to the contract
// Transfer reward tokens from the owner to the deployed pool contract
// slither-disable-next-line arbitrary-send-erc20
IERC20(data.rewardToken).safeTransferFrom(
deployer,
Expand Down
4 changes: 2 additions & 2 deletions contracts/factories/ERC20PenaltyFeeFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
ERC20LockUpFactory
ERC20PenaltyFeeFactory
SPDX-License-Identifier: MIT
*/

Expand Down Expand Up @@ -52,7 +52,7 @@ contract ERC20PenaltyFeeStakingFactory is GenericFactory, IPenaltyFeeFactory {
uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) *
data.rewardPerSecond;
ERC20PenaltyFeePool(newPoolAddress).transferOwnership(deployer);
// Transfer reward tokens from the owner to the contract
// Transfer reward tokens from the owner to the deployed pool contract
// slither-disable-next-line arbitrary-send-erc20
IERC20(data.rewardToken).safeTransferFrom(
deployer,
Expand Down
4 changes: 2 additions & 2 deletions contracts/factories/ERC721LockUpFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
ERC20LockUpFactory
ERC721LockUpFactory
SPDX-License-Identifier: MIT
*/

Expand Down Expand Up @@ -52,7 +52,7 @@ contract ERC721LockUpStakingFactory is GenericFactory, ILockUpFactory {
uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) *
data.rewardPerSecond;
ERC721LockUpPool(newPoolAddress).transferOwnership(deployer);
// Transfer reward tokens from the owner to the contract
// Transfer reward tokens from the owner to the deployed pool contract
// slither-disable-next-line arbitrary-send-erc20
IERC20(data.rewardToken).safeTransferFrom(
deployer,
Expand Down
4 changes: 2 additions & 2 deletions contracts/factories/ERC721PenaltyFeeFactory.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
ERC20LockUpFactory
ERC721PenaltyFeeFactory
SPDX-License-Identifier: MIT
*/

Expand Down Expand Up @@ -49,7 +49,7 @@ contract ERC721PenaltyFeeStakingFactory is GenericFactory, IPenaltyFeeFactory {
uint256 rewardAmount = (data.poolEndTime - data.poolStartTime) *
data.rewardPerSecond;
ERC721PenaltyFeePool(newPoolAddress).transferOwnership(deployer);
// Transfer reward tokens from the owner to the contract
// Transfer reward tokens from the owner to the deployed pool contract
// slither-disable-next-line arbitrary-send-erc20
IERC20(data.rewardToken).safeTransferFrom(
deployer,
Expand Down
2 changes: 1 addition & 1 deletion contracts/factories/GenericFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ abstract contract GenericFactory is Ownable, IGenericFactory {
requestManager = managerContract;
}

/// @notice Function allows admins to replace RequestManager contract's address in case of repdeployment
/// @notice Function allows admins to replace RequestManager contract's address in case of redeployment
/// @param newManagerContract Address of the new RequestManager contract
function updateManagerContract(
address newManagerContract
Expand Down
16 changes: 16 additions & 0 deletions contracts/interfaces/IRequestManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,32 @@ interface IRequestManager {
bytes stakingData;
}

/**
* @notice Information about a staking pool request.
* @param requestStatus Current status of the request.
* @param data See {RequestPayload} above.
*/
struct Request {
Status requestStatus;
RequestPayload data;
}

/// @notice Thrown when an invalid ID is used.
error InvalidId();

/// @notice Thrown when the request status is invalid.
error InvalidRequestStatus();

/// @notice Thrown when the caller is not authorized.
error InvalidDeployer();

/// @notice Thrown when the IPFS hash is zero.
error IpfsZeroHash();

/// @notice Thrown when the token address is invalid.
error InvalidAddress();

/// @notice Thrown when the {stakingData} payload param is empty.
error EmptyPayload();
error UnregisteredFactory();
error AlreadyRegisteredFactory();
Expand Down
18 changes: 17 additions & 1 deletion contracts/mocks/ERC20MockToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@ pragma solidity 0.8.25;
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/// @title ERC20MockToken
/// @notice A mock ERC20 token for testing purposes, with minting and burning capabilities controlled by the owner.
/// @dev Extends the OpenZeppelin ERC20 and Ownable contracts.
contract ERC20MockToken is ERC20, Ownable {
/// @dev Custom decimal places for the mock token.
uint8 private immutable _decimals;


/// @notice Constructor to initialize the mock token with a name, symbol, and decimals.
/// @param name The name of the token.
/// @param symbol The symbol of the token.
/// @param decimals_ The number of decimal places for the token.
constructor(
string memory name,
string memory symbol,
Expand All @@ -15,14 +23,22 @@ contract ERC20MockToken is ERC20, Ownable {
_decimals = decimals_;
}

/// @notice Mints new tokens to the specified account.
/// @param account The address of the account to mint tokens to.
/// @param amount The amount of tokens to mint.
function mint(address account, uint256 amount) external onlyOwner {
_mint(account, amount);
}

/// @notice Burns tokens from the specified account.
/// @param account The address of the account to burn tokens from.
/// @param amount The amount of tokens to burn.
function burn(address account, uint256 amount) external onlyOwner {
_burn(account, amount);
}

/// @notice Returns the number of decimals.
/// @return The number of decimals.
function decimals() public view override returns (uint8) {
return _decimals;
}
Expand Down
11 changes: 10 additions & 1 deletion contracts/mocks/ERC721MockToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,23 @@ pragma solidity 0.8.25;
import {ERC721} from "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/// @title ERC721MockToken
/// @notice A mock ERC721 token for testing purposes, with minting capabilities controlled by the owner.
/// @dev Extends the OpenZeppelin ERC721 and Ownable contracts.
contract ERC721MockToken is ERC721, Ownable {
/// @dev Counter for tracking the next token ID to be minted.
uint256 private _nextTokenId;


/// @notice Constructor to initialize the mock token with a name and symbol.
/// @param name The name of the token.
/// @param symbol The symbol of the token.
constructor(
string memory name,
string memory symbol
) ERC721(name, symbol) Ownable(msg.sender) {}

/// @notice Mints a new token to the specified address.
/// @param to The address to mint the token to.
function safeMint(address to) public onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
Expand Down

0 comments on commit 41c3055

Please sign in to comment.