@poolzfinance/invest-provider
v1.0.1
Published
[![Build and Test](https://github.com/The-Poolz/LockDealNFT.InvestProvider/actions/workflows/node.js.yml/badge.svg)](https://github.com/The-Poolz/LockDealNFT.InvestProvider/actions/workflows/node.js.yml) [![codecov](https://codecov.io/gh/The-Poolz/LockDe
Downloads
76
Keywords
Readme
LockDealNFT.InvestProvider
InvestProvider is a contract enabling the creation and management of Investment Pools (IDO Pools). It allows users to invest in pools by contributing tokens, such as stablecoins, in exchange for tokens issued by the IDO project. The contract manages pool creation, investments, and enforces compliance with defined limits while tracking available tokens.
Navigation
Installation
Install the packages:
npm i
Compile contracts:
npx hardhat compile
Run tests:
npx hardhat test
Run coverage:
npx hardhat coverage
Deploy:
npx truffle dashboard
npx hardhat run ./scripts/deploy.ts --network truffleDashboard
Overview
InvestProvider facilitates the creation and management of investment pools, enabling users to join various token pools. It integrates with the LockDealNFT contract to mint and transfer tokens based on users' investments.
Key Features
- Create Investment Pools: Configure pools with parameters such as maximum investment limits, pool owners, and investment signers.
- Join Investment Pools: Users can invest in the pools with specific amounts and terms.
- Advanced Authorization: Uses signature-based authorization to ensure secure and valid investment operations.
- Integration with LockDealNFT: Leverages NFT tokenization for flexible and transparent investment management.
InvestProvider Diagram
Create IDO Pool
There are two functions available for creating Investment Pools (IDO Pools) in the InvestProvider contract. Both functions allow the creation of a new pool with a configurable amount, but they differ in how they handle the investment and dispenser signers.
1. createNewPool (with signers)
This function creates a new pool and requires specifying both the investment signer and dispenser signer addresses. These signers are responsible for verifying investments and handling token dispensations.
/**
* @notice Creates a new investment pool and registers it.
* @param poolAmount The amount to allocate to the pool.
* @param investSigner The address of the signer for investments.
* @param dispenserSigner The address of the signer for dispenses.
* @param sourcePoolId The ID of the source pool to clone settings from.
* @return poolId The ID of the newly created pool.
* @dev Emits the `NewPoolCreated` event upon successful creation.
*/
function createNewPool(
uint256 poolAmount,
address investSigner,
address dispenserSigner,
uint256 sourcePoolId
) external;
This function is suitable for scenarios where specific signers for investments and dispensing are required.
2. createNewPool (without explicit signers)
This variant creates a new pool, but the investment signer and dispenser signer default to the sender's address (i.e., the account calling the function). It also allows cloning settings from an existing pool.
/**
* @notice Creates a new investment pool and registers it.
* @param poolAmount The amount to allocate to the pool.
* @param sourcePoolId The ID of the source pool to clone settings from.
* @return poolId The ID of the newly created pool.
* @dev Emits the `NewPoolCreated` event upon successful creation.
*/
function createNewPool(
uint256 poolAmount,
uint256 sourcePoolId
) external;
In this case, both the investment signer and dispenser signer default to the caller’s address (msg.sender). This is useful for simpler cases where the same address is responsible for managing both investments and token dispensations.
Summary of Differences
| Function | Signer Parameters | Purpose |
| --------------------------------------------------- | ----------------------------------------------------------- | ----------------------------------------------------------- |
| createNewPool(uint256, address, address, uint256)
| Requires explicit signers for investments and dispensations | Full control over signers for customized pool management |
| createNewPool(uint256, uint256)
| Uses msg.sender
for both signers | Simpler pool creation where the caller manages both actions |
Join Pool
The invest function enables users to participate in investment pools by contributing tokens. It processes contributions and updates the pool's state. Before participating in an investment pool, users must approve the contract to spend the required amount of the ERC20 token they intend to invest.
/**
* @notice Allows a user to invest in an IDO pool.
* @param poolId The ID of the pool.
* @param amount The amount to invest.
* @param validUntil The timestamp until the signature is valid.
* @param signature The cryptographic signature validating the investment.
* @dev Emits the `Invested` event upon success.
*/
function invest(
uint256 poolId,
uint256 amount,
uint256 validUntil,
bytes calldata signature
) external;
event Invested(
uint256 indexed poolId,
address indexed user,
uint256 amount
);
Emitted when a user successfully invests in a pool.
- poolId: The pool's ID.
- user: Address of the investor.
- amount: Tokens invested
Pool data
InvestProvider contract provides a convenient way to monitor the details of investment pools, including the maximum amount of tokens that can be invested and the remaining tokens available for investment. This is achieved using the poolIdToPool
view function.
function poolIdToPool(uint256 investPoolId) external view returns (Pool data);
struct Pool {
uint256 maxAmount; // The maximum amount of tokens that can be invested in the pool
uint256 leftAmount; // The amount of tokens left to invest in the pool
}
This function allows users to retrieve information about a specific pool by its poolId.
License
The-Poolz Contracts is released under the MIT License.