Skip to content

Commit 6a80950

Browse files
Merge pull request #111 from The-Poolz/issue-110
add v3.1 contracts interfaces
2 parents f590dae + 2becbe6 commit 6a80950

File tree

4 files changed

+132
-3
lines changed

4 files changed

+132
-3
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import "./ISimpleProvider.sol";
5+
6+
/// @title IDispenserProvider
7+
/// @dev Interface for the Dispenser provider, responsible for dispensing tokens from a pool
8+
/// and interacting with simple providers for NFT handling.
9+
interface IDispenserProvider is ISimpleProvider {
10+
/// @notice Dispenses tokens from the pool to the specified user.
11+
/// @dev Validates the provider, checks the signature, and processes the dispensation logic for the given pool.
12+
/// @param poolId The unique identifier for the pool.
13+
/// @param validUntil The timestamp until which the dispense is valid.
14+
/// @param owner The address of the owner requesting to dispense tokens.
15+
/// @param data The array of Builder structs containing provider and parameters data.
16+
/// @param signature The cryptographic signature verifying the validity of the transaction.
17+
function dispenseLock(
18+
uint256 poolId,
19+
uint256 validUntil,
20+
address owner,
21+
Builder[] calldata data,
22+
bytes calldata signature
23+
) external;
24+
25+
/// @dev Represents the data required to handle a token dispensation.
26+
/// @param simpleProvider The provider that handles the token dispensation logic.
27+
/// @param params Additional parameters required for dispensing the tokens.
28+
struct Builder {
29+
ISimpleProvider simpleProvider;
30+
uint256[] params;
31+
}
32+
33+
/// @notice Emitted when tokens are dispensed from the pool to a user.
34+
/// @param poolId The unique identifier for the pool.
35+
/// @param user The address of the user receiving the tokens.
36+
/// @param amountTaken The amount of tokens dispensed from the pool.
37+
/// @param leftAmount The remaining amount of tokens in the pool after dispensation.
38+
event TokensDispensed(uint256 poolId, address user, uint256 amountTaken, uint256 leftAmount);
39+
40+
error CallerNotApproved(address caller, address owner, uint256 poolId);
41+
error InvalidTime(uint256 currentTime, uint256 validUntil);
42+
error InvalidSignature(uint256 poolId, address owner);
43+
error TokensAlreadyTaken(uint256 poolId, address owner);
44+
error AmountMustBeGreaterThanZero();
45+
error NotEnoughTokensInPool(uint256 requestedAmount, uint256 availableAmount);
46+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.0;
3+
4+
import "./IProvider.sol";
5+
6+
/**
7+
* @title IInvestProvider
8+
* @dev Interface for managing investment pools, including investment actions and pool creation.
9+
* It extends the IProvider interface and defines additional functionality specific to investment pools.
10+
*/
11+
interface IInvestProvider is IProvider {
12+
/**
13+
* @notice Allows an address to invest in a specific IDO (Initial DEX Offering) pool.
14+
* @dev The function is used to transfer a specified amount of tokens into the pool.
15+
* @param poolId The ID of the pool where the investment will occur.
16+
* @param amount The amount of tokens to be invested in the pool.
17+
*/
18+
function invest(uint256 poolId, uint256 amount, uint256 validUntil, bytes calldata signature) external;
19+
20+
/**
21+
* @notice Creates a new investment pool.
22+
* @dev This function is used to create a new pool with the specified parameters, copying the settings of an existing source pool.
23+
* It will initialize the new pool with the given details and return its poolId.
24+
* @param poolAmount The maximum amount of tokens that can be invested in the pool.
25+
* @param investSigner The address of the signer for investments.
26+
* @param dispenserSigner The address of the signer for dispenses.
27+
* @param sourcePoolId The ID of the source pool to copy settings from.
28+
* @return poolId The ID of the newly created pool.
29+
*/
30+
function createNewPool(
31+
uint256 poolAmount,
32+
address investSigner,
33+
address dispenserSigner,
34+
uint256 sourcePoolId
35+
) external returns (uint256 poolId);
36+
37+
/**
38+
* @notice Creates a new investment pool.
39+
* @dev This function is used to create a new pool with the specified parameters, copying the settings of an existing source pool.
40+
* It will initialize the new pool with the given details and return its poolId.
41+
* @param poolAmount The maximum amount of tokens that can be invested in the pool.
42+
* @param sourcePoolId The ID of the source pool to copy settings from.
43+
* @return poolId The ID of the newly created pool.
44+
*/
45+
function createNewPool(uint256 poolAmount, uint256 sourcePoolId) external returns (uint256 poolId);
46+
47+
/**
48+
* @dev Struct that represents an IDO pool, which contains the pool's configuration and the remaining investment amount.
49+
*/
50+
struct Pool {
51+
uint256 maxAmount; // The maximum amount of tokens that can be invested in the pool
52+
uint256 leftAmount; // The amount of tokens left to invest in the pool
53+
}
54+
55+
/**
56+
* @notice Emitted when a user successfully invests in a pool.
57+
* @param poolId The ID of the pool where the investment was made.
58+
* @param user The address of the user who made the investment.
59+
* @param amount The amount of tokens that were invested.
60+
*/
61+
event Invested(uint256 indexed poolId, address indexed user, uint256 amount);
62+
63+
/**
64+
* @notice Emitted when a new pool is created.
65+
* @param poolId The ID of the newly created pool.
66+
* @param owner The address of the user who created the pool.
67+
* @param poolAmount The maximum amount of tokens that can be invested in the pool.
68+
*/
69+
event NewPoolCreated(uint256 indexed poolId, address indexed owner, uint256 poolAmount);
70+
71+
error InvalidLockDealNFT();
72+
error InvalidProvider();
73+
error InvalidPoolId();
74+
error OnlyLockDealNFT();
75+
error NoZeroAddress();
76+
error InvalidParams();
77+
error NoZeroAmount();
78+
error ExceededLeftAmount();
79+
error InvalidParamsLength(uint256 paramsLength, uint256 minLength);
80+
error InvalidSignature(uint256 poolId, address owner);
81+
error InvalidTime(uint256 currentTime, uint256 validUntil);
82+
error InvalidSourcePoolId(uint256 sourcePoolId);
83+
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@poolzfinance/poolz-helper-v2",
3-
"version": "3.0.0",
3+
"version": "3.0.2",
44
"description": "A single source of truth of helper contracts used by Poolz.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

0 commit comments

Comments
 (0)