Skip to content

Commit

Permalink
update interfaces, dispenser and invest providers
Browse files Browse the repository at this point in the history
  • Loading branch information
YouStillAlive committed Dec 5, 2024
1 parent 55f6102 commit 2becbe6
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 118 deletions.
25 changes: 25 additions & 0 deletions contracts/interfaces/IDispenserProvider.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ pragma solidity ^0.8.0;

import "./ISimpleProvider.sol";

/// @title IDispenserProvider
/// @dev Interface for the Dispenser provider, responsible for dispensing tokens from a pool
/// and interacting with simple providers for NFT handling.
interface IDispenserProvider is ISimpleProvider {
/// @notice Dispenses tokens from the pool to the specified user.
/// @dev Validates the provider, checks the signature, and processes the dispensation logic for the given pool.
/// @param poolId The unique identifier for the pool.
/// @param validUntil The timestamp until which the dispense is valid.
/// @param owner The address of the owner requesting to dispense tokens.
/// @param data The array of Builder structs containing provider and parameters data.
/// @param signature The cryptographic signature verifying the validity of the transaction.
function dispenseLock(
uint256 poolId,
uint256 validUntil,
Expand All @@ -12,10 +22,25 @@ interface IDispenserProvider is ISimpleProvider {
bytes calldata signature
) external;

/// @dev Represents the data required to handle a token dispensation.
/// @param simpleProvider The provider that handles the token dispensation logic.
/// @param params Additional parameters required for dispensing the tokens.
struct Builder {
ISimpleProvider simpleProvider;
uint256[] params;
}

/// @notice Emitted when tokens are dispensed from the pool to a user.
/// @param poolId The unique identifier for the pool.
/// @param user The address of the user receiving the tokens.
/// @param amountTaken The amount of tokens dispensed from the pool.
/// @param leftAmount The remaining amount of tokens in the pool after dispensation.
event TokensDispensed(uint256 poolId, address user, uint256 amountTaken, uint256 leftAmount);

error CallerNotApproved(address caller, address owner, uint256 poolId);
error InvalidTime(uint256 currentTime, uint256 validUntil);
error InvalidSignature(uint256 poolId, address owner);
error TokensAlreadyTaken(uint256 poolId, address owner);
error AmountMustBeGreaterThanZero();
error NotEnoughTokensInPool(uint256 requestedAmount, uint256 availableAmount);
}
81 changes: 59 additions & 22 deletions contracts/interfaces/IInvestProvider.sol
Original file line number Diff line number Diff line change
@@ -1,46 +1,83 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IInvestedProvider.sol";
import "./IProvider.sol";

/**
* @title IInvestProvider
* @dev Interface for managing investment pools, including investment actions and pool creation.
* It extends the IProvider interface and defines additional functionality specific to investment pools.
*/
interface IInvestProvider is IProvider {
/// @notice Invest in a IDO pool
/// @param poolId - the ID of the pool
/// @param amount - the amount of tokens to invest
function invest(uint256 poolId, uint256 amount, bytes calldata data) external;
/**
* @notice Allows an address to invest in a specific IDO (Initial DEX Offering) pool.
* @dev The function is used to transfer a specified amount of tokens into the pool.
* @param poolId The ID of the pool where the investment will occur.
* @param amount The amount of tokens to be invested in the pool.
*/
function invest(uint256 poolId, uint256 amount, uint256 validUntil, bytes calldata signature) external;

/**
* @notice Creates a new investment pool.
* @dev This function is used to create a new pool with the specified parameters, copying the settings of an existing source pool.
* It will initialize the new pool with the given details and return its poolId.
* @param poolAmount The maximum amount of tokens that can be invested in 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 copy settings from.
* @return poolId The ID of the newly created pool.
*/
function createNewPool(
Pool calldata pool,
bytes calldata data,
uint256 poolAmount,
address investSigner,
address dispenserSigner,
uint256 sourcePoolId
) external returns (uint256 poolId);

struct IDO {
Pool pool;
uint256 leftAmount;
}
/**
* @notice Creates a new investment pool.
* @dev This function is used to create a new pool with the specified parameters, copying the settings of an existing source pool.
* It will initialize the new pool with the given details and return its poolId.
* @param poolAmount The maximum amount of tokens that can be invested in the pool.
* @param sourcePoolId The ID of the source pool to copy settings from.
* @return poolId The ID of the newly created pool.
*/
function createNewPool(uint256 poolAmount, uint256 sourcePoolId) external returns (uint256 poolId);

/**
* @dev Struct that represents an IDO pool, which contains the pool's configuration and the remaining investment amount.
*/
struct Pool {
uint256 maxAmount;
uint256 whiteListId;
IInvestedProvider investedProvider;
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
}

event Invested(
uint256 indexed poolId,
address indexed user,
uint256 amount
);
event NewPoolCreated(uint256 indexed poolId, IDO pool);
/**
* @notice Emitted when a user successfully invests in a pool.
* @param poolId The ID of the pool where the investment was made.
* @param user The address of the user who made the investment.
* @param amount The amount of tokens that were invested.
*/
event Invested(uint256 indexed poolId, address indexed user, uint256 amount);

/**
* @notice Emitted when a new pool is created.
* @param poolId The ID of the newly created pool.
* @param owner The address of the user who created the pool.
* @param poolAmount The maximum amount of tokens that can be invested in the pool.
*/
event NewPoolCreated(uint256 indexed poolId, address indexed owner, uint256 poolAmount);

error InvalidLockDealNFT();
error InvalidInvestedProvider();
error InvalidProvider();
error InvalidPoolId();
error OnlyLockDealNFT();
error NoZeroAddress();
error InvalidParams();
error NoZeroAmount();
error ExceededLeftAmount();
/// @dev Error thrown when the length of parameters is invalid
error InvalidParamsLength(uint256 paramsLength, uint256 minLength);
error InvalidSignature(uint256 poolId, address owner);
error InvalidTime(uint256 currentTime, uint256 validUntil);
error InvalidSourcePoolId(uint256 sourcePoolId);
}
14 changes: 0 additions & 14 deletions contracts/interfaces/IInvestedProvider.sol

This file was deleted.

58 changes: 0 additions & 58 deletions contracts/interfaces/IWhiteListRouter.sol

This file was deleted.

21 changes: 0 additions & 21 deletions contracts/interfaces/IWhiteListV2.sol

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@poolzfinance/poolz-helper-v2",
"version": "3.0.0",
"version": "3.0.2",
"description": "A single source of truth of helper contracts used by Poolz.",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down

0 comments on commit 2becbe6

Please sign in to comment.