npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@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

Readme

LockDealNFT.InvestProvider

Build and Test codecov CodeFactor License

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

classDiagram

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.