// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; /** * @title SOMA Lockdrop Contract. * @author SOMA.finance * @notice A fund raising contract for bootstrapping DEX liquidity pools. */ interface ILockdrop { /** * @notice Emitted when the {DelegationConfig} is updated. * @param poolId The pool ID. * @param prevLockDuration The previous lock duration. * @param newLockDuration The new lock duration. * @param sender The message sender that triggered the event. */ event LockDurationUpdated( bytes32 poolId, uint256 prevLockDuration, uint256 newLockDuration, address indexed sender ); /** * @notice Emitted when the {withdrawTo} address is updated. * @param prevTo The previous withdraw to address. * @param newTo The new withdraw to address. * @param sender The message sender that triggered the event. */ event WithdrawToUpdated(address prevTo, address newTo, address indexed sender); /** * @notice Emitted when a delegation is added to a pool. * @param poolId The pool ID. * @param amount The delegation amount denominated in the delegation asset. * @param lockDuration The lock duration. * @param sender The message sender that triggered the event. */ event DelegationAdded(bytes32 indexed poolId, uint256 amount, uint256 lockDuration, address indexed sender); /** * @notice Emitted when someone calls {moveDelegation}, transferring their delegation to a different pool. * @param fromPoolId The pool ID of the source pool. * @param toPoolId The pool ID of the destination pool. * @param amount The amount of the delegation asset to move. * @param sender TThe message sender that triggered the event. */ event DelegationMoved(bytes32 indexed fromPoolId, bytes32 indexed toPoolId, uint256 amount, address indexed sender); /** * @notice Emitted when the {DateConfig} is updated. * @param prevDateConfig The previous date configuration. * @param newDateConfig The new date configuration. * @param sender The message sender that triggered the event. */ event DatesUpdated(DateConfig prevDateConfig, DateConfig newDateConfig, address indexed sender); /** * @notice Emitted when the {Pool} is updated. * @param poolId The pool ID. * @param requiredPrivileges The new required privileges. * @param enabled Boolean indicating if the pool is enabled. * @param sender The message sender that triggered the event. */ event PoolUpdated(bytes32 indexed poolId, bytes32 requiredPrivileges, bool enabled, address indexed sender); /** * @notice Emitted when a delegation is removed from a pool. * @param poolId The pool ID. * @param amount The removed delegation amount denominated in the delegation asset. * @param sender The message sender that triggered the event. */ event DelegationRemoved(bytes32 indexed poolId, uint256 amount, address indexed sender); /** * @notice Date Configuration structure. * @param startDate The unix timestamp marking the start of the lockdrop. * @param removeDelegationEnd The unix timestamp marking the end of delegation removals. * @param endDate The unix timestamp marking the end of the lockdrop. */ struct DateConfig { uint48 startDate; uint48 removeDelegationEnd; uint48 endDate; } /** * @notice Pool structure. Each pool will bootstrap liquidity for an upcoming DEX pair. * E.g: sTSLA/USDC * @param enabled Boolean indicating if the pool is enabled. * @param requiredPrivileges The required privileges of the pool. * @param balances The mapping of user addresses to delegation balances. */ struct Pool { bool enabled; bytes32 requiredPrivileges; mapping(address => uint256) balances; } /** * @notice Returns the Lockdrop Global Admin Role. * @dev Equivalent to `keccak256('Lockdrop.GLOBAL_ADMIN_ROLE')`. */ function GLOBAL_ADMIN_ROLE() external pure returns (bytes32); /** * @notice Returns the Lockdrop Local Admin Role. * @dev Equivalent to `keccak256(abi.encodePacked(address(this), GLOBAL_ADMIN_ROLE))`. */ function LOCAL_ADMIN_ROLE() external view returns (bytes32); /** * @notice Returns the ID of the Lockdrop. */ function id() external view returns (uint256); /** * @notice The address of the Lockdrop's delegation asset. */ function asset() external view returns (address); /** * @notice The date configuration of the Lockdrop. */ function dateConfig() external view returns (DateConfig memory); /** * @notice The address where the delegated funds will be withdrawn to. */ function withdrawTo() external view returns (address); /** * @notice Initialize function for the Lockdrop contract. * @param _id The ID of the Lockdrop. * @param _asset The address of the delegation asset. * @param _withdrawTo The address that receives withdrawn assets. * @param _initDateConfig The initial date configuration. */ function initialize(uint256 _id, address _asset, address _withdrawTo, DateConfig calldata _initDateConfig) external; /** * @notice Updates the Lockdrop's date configuration. * @param newConfig The updated date configuration. * @custom:emits DatesUpdated * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE. */ function updateDateConfig(DateConfig calldata newConfig) external; /** * @notice Sets the `withdrawTo` address. * @param account The updated address to receive withdrawn funds. * @custom:emits WithdrawToUpdated * @custom:requirement The function caller must be the master. * @custom:requirement `account` must not be equal to address zero. */ function setWithdrawTo(address account) external; /** * @notice Returns the delegation balance of an account, given a pool ID. * @param poolId The pool ID to return the account's balance of. * @param account The account to return the balance of. * @return The delegation balance of `account` for the `poolId` pool. */ function balanceOf(bytes32 poolId, address account) external view returns (uint256); /** * @notice Returns the lock duration of an account for a pool. * @param poolId The poolId to return the user lock duration of. * @param account The account to return the pool lock duration of. * @return The lock duration. */ function lockDuration(bytes32 poolId, address account) external view returns (uint256); /** * @notice Returns a boolean indicating if a pool is enabled. * @param poolId The pool ID to check the enabled status of. * @return True if the pool is enabled, False if the pool is disabled. */ function enabled(bytes32 poolId) external view returns (bool); /** * @notice Returns the required privileges of the pool. These privileges are required in order to * delegate. * @param poolId The pool ID to check the enabled status of. * @custom:requirement The pool must be enabled. * @return The required privileges of the pool. */ function requiredPrivileges(bytes32 poolId) external view returns (bytes32); /** * @notice Updates the lockdrop pool parameters. * @param _poolId The ID of the pool to update. * @param _requiredPrivileges The updated required privileges of the pool. * @param _enabled The updated enabled or disabled state of the pool. * @custom:emits PoolUpdated * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE. */ function updatePool(bytes32 _poolId, bytes32 _requiredPrivileges, bool _enabled) external; /** * @notice Updates the delegation configuration of an account. * @param poolId The pool ID. * @param newLockDuration The new lock duration. * @custom:emits LockDurationUpdated * @custom:requirement The `poolId` pool must be enabled. * @custom:requirement The lockdrop must have started already. * @custom:requirement The lockdrop must not have ended yet. * @custom:requirement The contracts must not be paused. */ function updateLockDuration(bytes32 poolId, uint256 newLockDuration) external; /** * @notice Withdraws tokens from the Lockdrop contract to the `withdrawTo` address. * @param amount The amount of tokens to be withdrawn. * @custom:requirement The function caller must have the GLOBAL_ADMIN_ROLE or LOCAL_ADMIN_ROLE. */ function withdraw(uint256 amount) external; /** * @notice Moves the accounts' delegated tokens from one pool to another, and sets the `toPoolId` lock duration. * @param fromPoolId The ID of the pool that the delegation will be moved from. * @param toPoolId The ID of the pool that the delegation will be moved to. * @param amount The amount of tokens to be moved. * @param toPoolLockDuration The lock duration of the user for `toPoolId`. * @custom:emits DelegationMoved * @custom:requirement `fromPoolId` must not be equal to `toPoolId`. * @custom:requirement The lockdrop must have started already. * @custom:requirement The lockdrop must not have ended yet. * @custom:requirement `amount` must be greater than zero. * @custom:requirement The `fromPoolId` pool must be enabled. * @custom:requirement The `toPoolId` pool must be enabled. * @custom:requirement The delegation balance of the caller for the `fromPoolId` pool must be greater than * or equal to `amount`. * @custom:requirement The function caller must have the required privileges of the `fromPoolId` pool. * @custom:requirement The function caller must have the required privileges of the `toPoolId` pool. * @custom:requirement The contracts must not be paused. */ function moveDelegation(bytes32 fromPoolId, bytes32 toPoolId, uint256 amount, uint256 toPoolLockDuration) external; /** * @notice Removes the accounts' delegated tokens from the pool. * @param poolId The ID of the pool that the delegation will be removed from. * @param amount The amount of tokens to be removed. * @custom:emits DelegationRemoved * @custom:requirement The lockdrop must have started already. * @custom:requirement The block timestamp must be less than or equal to the remove delegation end timestamp. * @custom:requirement `amount` must be greater than zero. * @custom:requirement `amount` must be less than the balance of the asset. * @custom:requirement The `poolId` pool must be enabled. * @custom:requirement The delegation balance of the caller for the `poolId` pool must be greater than * or equal to `amount`. * @custom:requirement The function caller must have the required privileges of the `poolId` pool. * @custom:requirement The contracts must not be paused. */ function removeDelegation(bytes32 poolId, uint256 amount) external; /** * @notice Delegates tokens to the a specific pool. * @param poolId The ID of the pool to receive the delegation. * @param amount The amount of tokens to be delegated. * @param lockDuration_ The lock duration. * @custom:emits DelegationAdded * @custom:requirement `amount` must be greater than zero. * @custom:requirement The `poolId` pool must be enabled. * @custom:requirement The lockdrop must have started already. * @custom:requirement The lockdrop must not have ended yet. * @custom:requirement The function caller must have the `poolId` pool's required privileges. * @custom:requirement The contracts must not be paused. */ function delegate(bytes32 poolId, uint256 amount, uint256 lockDuration_) external; }