Description:
Multi-signature wallet contract requiring multiple confirmations for transaction execution.
Blockchain: Ethereum
Source Code: View Code On The Blockchain
Solidity Source Code:
{{
"language": "Solidity",
"sources": {
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
"
},
"@openzeppelin/contracts/security/Pausable.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}
"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
"
},
"contracts/LiquidityStakingRewards.sol": {
"content": "// SPDX-License-Identifier: MIT\r
pragma solidity ^0.8.27;\r
\r
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";\r
import "@openzeppelin/contracts/access/Ownable.sol";\r
import "@openzeppelin/contracts/security/Pausable.sol";\r
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";\r
\r
/**\r
* @title LiquidityStakingRewardsV4\r
* @notice Staking contract for Uniswap V4 liquidity providers\r
* @dev Provides 15% APR rewards for 3 months to liquidity providers\r
* \r
* Key Features:\r
* - Compatible with Uniswap V4 pool IDs\r
* - Works with native ETH and POL (not wrapped)\r
* - Earn 15% APR in BP tokens\r
* - 3-month reward program\r
* - Manual tracking of liquidity positions\r
* \r
* Architecture:\r
* - Uses standard OpenZeppelin contracts (non-upgradeable for simplicity)\r
* - Tracks liquidity by user address and pool ID\r
* - Comprehensive event logging\r
* - Owner-only admin functions\r
*/\r
contract LiquidityStakingRewardsV4 is Ownable, Pausable, ReentrancyGuard {\r
// ============================================\r
// STATE VARIABLES\r
// ============================================\r
\r
/// @notice BP token contract address\r
IERC20 public immutable bpToken;\r
\r
/// @notice Annual Percentage Rate (in basis points: 1500 = 15%)\r
uint256 public aprBasisPoints;\r
\r
/// @notice Program start timestamp\r
uint256 public programStartTime;\r
\r
/// @notice Program end timestamp (3 months = 90 days)\r
uint256 public programEndTime;\r
\r
/// @notice Total BP tokens allocated for rewards\r
uint256 public totalRewardsAllocated;\r
\r
/// @notice Total BP tokens already distributed\r
uint256 public totalRewardsDistributed;\r
\r
/// @notice Basis points denominator (10000 = 100%)\r
uint256 public constant BASIS_POINTS = 10000;\r
\r
/// @notice Seconds in a year (for APR calculation)\r
uint256 public constant SECONDS_PER_YEAR = 365 days;\r
\r
/// @notice Program duration (3 months)\r
uint256 public constant PROGRAM_DURATION = 90 days;\r
\r
// ============================================\r
// STAKING DATA STRUCTURES\r
// ============================================\r
\r
/**\r
* @notice Staking position information\r
* @param user Address of the liquidity provider\r
* @param poolId Uniswap V4 pool ID (bytes32)\r
* @param liquidityAmount Amount of liquidity provided (in USD value or tokens)\r
* @param stakedAt Timestamp when position was registered\r
* @param lastClaimAt Timestamp of last reward claim\r
* @param totalClaimed Total rewards claimed so far\r
* @param isActive Whether position is currently active\r
*/\r
struct StakingPosition {\r
address user;\r
bytes32 poolId;\r
uint256 liquidityAmount;\r
uint256 stakedAt;\r
uint256 lastClaimAt;\r
uint256 totalClaimed;\r
bool isActive;\r
}\r
\r
/// @notice Mapping from user address to pool ID to staking position\r
mapping(address => mapping(bytes32 => StakingPosition)) public stakingPositions;\r
\r
/// @notice Mapping from pool ID to total liquidity staked\r
mapping(bytes32 => uint256) public poolTotalLiquidity;\r
\r
/// @notice Array of supported pool IDs\r
bytes32[] public supportedPools;\r
\r
/// @notice Mapping to check if pool is supported\r
mapping(bytes32 => bool) public isPoolSupported;\r
\r
/// @notice Total liquidity currently staked across all pools\r
uint256 public totalLiquidityStaked;\r
\r
/// @notice Total number of active staking positions\r
uint256 public totalActivePositions;\r
\r
// ============================================\r
// EVENTS\r
// ============================================\r
\r
event PositionRegistered(\r
address indexed user,\r
bytes32 indexed poolId,\r
uint256 liquidityAmount,\r
uint256 timestamp\r
);\r
\r
event PositionUpdated(\r
address indexed user,\r
bytes32 indexed poolId,\r
uint256 newLiquidityAmount,\r
uint256 timestamp\r
);\r
\r
event PositionRemoved(\r
address indexed user,\r
bytes32 indexed poolId,\r
uint256 timestamp\r
);\r
\r
event RewardsClaimed(\r
address indexed user,\r
bytes32 indexed poolId,\r
uint256 rewardAmount,\r
uint256 timestamp\r
);\r
\r
event RewardsAllocated(\r
uint256 amount,\r
uint256 timestamp\r
);\r
\r
event ProgramExtended(\r
uint256 newEndTime,\r
uint256 timestamp\r
);\r
\r
event PoolAdded(\r
bytes32 indexed poolId,\r
uint256 timestamp\r
);\r
\r
event PoolRemoved(\r
bytes32 indexed poolId,\r
uint256 timestamp\r
);\r
\r
// ============================================\r
// ERRORS\r
// ============================================\r
\r
error ProgramNotStarted();\r
error ProgramEnded();\r
error PositionNotActive();\r
error PositionAlreadyExists();\r
error InsufficientRewards();\r
error InvalidLiquidity();\r
error PoolNotSupported();\r
error TransferFailed();\r
error InvalidPoolId();\r
\r
// ============================================\r
// CONSTRUCTOR\r
// ============================================\r
\r
/**\r
* @notice Initialize the staking contract\r
* @param _bpToken BP token contract address\r
* @param _aprBasisPoints APR in basis points (1500 = 15%)\r
* @param _poolIds Initial pool IDs to support\r
*/\r
constructor(\r
address _bpToken,\r
uint256 _aprBasisPoints,\r
bytes32[] memory _poolIds\r
) {\r
bpToken = IERC20(_bpToken);\r
aprBasisPoints = _aprBasisPoints;\r
\r
programStartTime = block.timestamp;\r
programEndTime = block.timestamp + PROGRAM_DURATION;\r
\r
// Add initial pools\r
for (uint256 i = 0; i < _poolIds.length; i++) {\r
_addPool(_poolIds[i]);\r
}\r
}\r
\r
// ============================================\r
// STAKING FUNCTIONS\r
// ============================================\r
\r
/**\r
* @notice Register a liquidity position\r
* @param poolId The Uniswap V4 pool ID\r
* @param liquidityAmount Amount of liquidity (in tokens or USD value)\r
* @dev User must provide proof of liquidity on Uniswap V4\r
*/\r
function registerPosition(bytes32 poolId, uint256 liquidityAmount) \r
external \r
whenNotPaused \r
nonReentrant \r
{\r
if (block.timestamp < programStartTime) revert ProgramNotStarted();\r
if (block.timestamp >= programEndTime) revert ProgramEnded();\r
if (!isPoolSupported[poolId]) revert PoolNotSupported();\r
if (liquidityAmount == 0) revert InvalidLiquidity();\r
\r
StakingPosition storage position = stakingPositions[msg.sender][poolId];\r
\r
if (position.isActive) revert PositionAlreadyExists();\r
\r
// Create new position\r
position.user = msg.sender;\r
position.poolId = poolId;\r
position.liquidityAmount = liquidityAmount;\r
position.stakedAt = block.timestamp;\r
position.lastClaimAt = block.timestamp;\r
position.totalClaimed = 0;\r
position.isActive = true;\r
\r
// Update totals\r
totalLiquidityStaked += liquidityAmount;\r
poolTotalLiquidity[poolId] += liquidityAmount;\r
totalActivePositions += 1;\r
\r
emit PositionRegistered(msg.sender, poolId, liquidityAmount, block.timestamp);\r
}\r
\r
/**\r
* @notice Update liquidity amount for existing position\r
* @param poolId The Uniswap V4 pool ID\r
* @param newLiquidityAmount New amount of liquidity\r
*/\r
function updatePosition(bytes32 poolId, uint256 newLiquidityAmount) \r
external \r
whenNotPaused \r
nonReentrant \r
{\r
StakingPosition storage position = stakingPositions[msg.sender][poolId];\r
\r
if (!position.isActive) revert PositionNotActive();\r
if (newLiquidityAmount == 0) revert InvalidLiquidity();\r
\r
// Claim pending rewards before update\r
uint256 pendingRewards = calculatePendingRewards(msg.sender, poolId);\r
if (pendingRewards > 0) {\r
_claimRewards(msg.sender, poolId, pendingRewards);\r
}\r
\r
// Update totals\r
totalLiquidityStaked = totalLiquidityStaked - position.liquidityAmount + newLiquidityAmount;\r
poolTotalLiquidity[poolId] = poolTotalLiquidity[poolId] - position.liquidityAmount + newLiquidityAmount;\r
\r
// Update position\r
position.liquidityAmount = newLiquidityAmount;\r
position.lastClaimAt = block.timestamp;\r
\r
emit PositionUpdated(msg.sender, poolId, newLiquidityAmount, block.timestamp);\r
}\r
\r
/**\r
* @notice Remove a liquidity position and claim final rewards\r
* @param poolId The Uniswap V4 pool ID\r
*/\r
function removePosition(bytes32 poolId) \r
external \r
nonReentrant \r
{\r
StakingPosition storage position = stakingPositions[msg.sender][poolId];\r
\r
if (!position.isActive) revert PositionNotActive();\r
\r
// Claim any pending rewards\r
uint256 pendingRewards = calculatePendingRewards(msg.sender, poolId);\r
if (pendingRewards > 0) {\r
_claimRewards(msg.sender, poolId, pendingRewards);\r
}\r
\r
// Update totals\r
totalLiquidityStaked -= position.liquidityAmount;\r
poolTotalLiquidity[poolId] -= position.liquidityAmount;\r
totalActivePositions -= 1;\r
\r
// Mark as inactive\r
position.isActive = false;\r
\r
emit PositionRemoved(msg.sender, poolId, block.timestamp);\r
}\r
\r
/**\r
* @notice Claim pending rewards without removing position\r
* @param poolId The Uniswap V4 pool ID\r
*/\r
function claimRewards(bytes32 poolId) \r
external \r
nonReentrant \r
{\r
StakingPosition storage position = stakingPositions[msg.sender][poolId];\r
\r
if (!position.isActive) revert PositionNotActive();\r
\r
uint256 pendingRewards = calculatePendingRewards(msg.sender, poolId);\r
if (pendingRewards == 0) return;\r
\r
_claimRewards(msg.sender, poolId, pendingRewards);\r
}\r
\r
/**\r
* @notice Internal function to process reward claims\r
* @param user User address\r
* @param poolId Pool ID\r
* @param rewardAmount Amount of rewards to claim\r
*/\r
function _claimRewards(address user, bytes32 poolId, uint256 rewardAmount) \r
internal \r
{\r
StakingPosition storage position = stakingPositions[user][poolId];\r
\r
// Check if enough rewards available\r
if (totalRewardsDistributed + rewardAmount > totalRewardsAllocated) {\r
revert InsufficientRewards();\r
}\r
\r
// Update position\r
position.lastClaimAt = block.timestamp;\r
position.totalClaimed += rewardAmount;\r
\r
// Update totals\r
totalRewardsDistributed += rewardAmount;\r
\r
// Transfer rewards\r
bool success = bpToken.transfer(user, rewardAmount);\r
if (!success) revert TransferFailed();\r
\r
emit RewardsClaimed(user, poolId, rewardAmount, block.timestamp);\r
}\r
\r
// ============================================\r
// VIEW FUNCTIONS\r
// ============================================\r
\r
/**\r
* @notice Calculate pending rewards for a position\r
* @param user User address\r
* @param poolId Pool ID\r
* @return Pending reward amount in BP tokens\r
*/\r
function calculatePendingRewards(address user, bytes32 poolId) \r
public \r
view \r
returns (uint256) \r
{\r
StakingPosition memory position = stakingPositions[user][poolId];\r
\r
if (!position.isActive) return 0;\r
\r
// Calculate time staked since last claim\r
uint256 timeStaked = block.timestamp - position.lastClaimAt;\r
\r
// Cap at program end time\r
if (block.timestamp > programEndTime) {\r
if (position.lastClaimAt >= programEndTime) {\r
return 0;\r
}\r
timeStaked = programEndTime - position.lastClaimAt;\r
}\r
\r
// Calculate rewards: (liquidity * APR * timeStaked) / (BASIS_POINTS * SECONDS_PER_YEAR)\r
uint256 rewards = (position.liquidityAmount * aprBasisPoints * timeStaked) \r
/ (BASIS_POINTS * SECONDS_PER_YEAR);\r
\r
return rewards;\r
}\r
\r
/**\r
* @notice Get staking position details\r
* @param user User address\r
* @param poolId Pool ID\r
* @return position Staking position struct\r
*/\r
function getStakingPosition(address user, bytes32 poolId) \r
external \r
view \r
returns (StakingPosition memory) \r
{\r
return stakingPositions[user][poolId];\r
}\r
\r
/**\r
* @notice Get all supported pool IDs\r
* @return Array of pool IDs\r
*/\r
function getSupportedPools() \r
external \r
view \r
returns (bytes32[] memory) \r
{\r
return supportedPools;\r
}\r
\r
/**\r
* @notice Check if program is currently active\r
* @return bool Whether program is active\r
*/\r
function isProgramActive() \r
external \r
view \r
returns (bool) \r
{\r
return block.timestamp >= programStartTime && block.timestamp < programEndTime;\r
}\r
\r
/**\r
* @notice Get remaining rewards available\r
* @return uint256 Remaining rewards in BP tokens\r
*/\r
function getRemainingRewards() \r
external \r
view \r
returns (uint256) \r
{\r
return totalRewardsAllocated - totalRewardsDistributed;\r
}\r
\r
/**\r
* @notice Get pool statistics\r
* @param poolId Pool ID\r
* @return totalLiquidity Total liquidity in pool\r
*/\r
function getPoolStats(bytes32 poolId) \r
external \r
view \r
returns (uint256 totalLiquidity) \r
{\r
return poolTotalLiquidity[poolId];\r
}\r
\r
// ============================================\r
// ADMIN FUNCTIONS\r
// ============================================\r
\r
/**\r
* @notice Allocate BP tokens for rewards\r
* @param amount Amount of BP tokens to allocate\r
* @dev Owner must transfer tokens to this contract first\r
*/\r
function allocateRewards(uint256 amount) \r
external \r
onlyOwner \r
{\r
totalRewardsAllocated += amount;\r
emit RewardsAllocated(amount, block.timestamp);\r
}\r
\r
/**\r
* @notice Add a new pool to support\r
* @param poolId Uniswap V4 pool ID\r
*/\r
function addPool(bytes32 poolId) \r
external \r
onlyOwner \r
{\r
_addPool(poolId);\r
}\r
\r
/**\r
* @notice Internal function to add pool\r
* @param poolId Pool ID to add\r
*/\r
function _addPool(bytes32 poolId) \r
internal \r
{\r
if (poolId == bytes32(0)) revert InvalidPoolId();\r
if (isPoolSupported[poolId]) return; // Already added\r
\r
supportedPools.push(poolId);\r
isPoolSupported[poolId] = true;\r
\r
emit PoolAdded(poolId, block.timestamp);\r
}\r
\r
/**\r
* @notice Remove a pool from supported list\r
* @param poolId Pool ID to remove\r
*/\r
function removePool(bytes32 poolId) \r
external \r
onlyOwner \r
{\r
if (!isPoolSupported[poolId]) revert PoolNotSupported();\r
\r
isPoolSupported[poolId] = false;\r
\r
// Remove from array (expensive but rarely used)\r
for (uint256 i = 0; i < supportedPools.length; i++) {\r
if (supportedPools[i] == poolId) {\r
supportedPools[i] = supportedPools[supportedPools.length - 1];\r
supportedPools.pop();\r
break;\r
}\r
}\r
\r
emit PoolRemoved(poolId, block.timestamp);\r
}\r
\r
/**\r
* @notice Extend the program duration\r
* @param additionalDays Number of days to extend\r
*/\r
function extendProgram(uint256 additionalDays) \r
external \r
onlyOwner \r
{\r
programEndTime += additionalDays * 1 days;\r
emit ProgramExtended(programEndTime, block.timestamp);\r
}\r
\r
/**\r
* @notice Update APR (only before program starts or after it ends)\r
* @param newAprBasisPoints New APR in basis points\r
*/\r
function updateAPR(uint256 newAprBasisPoints) \r
external \r
onlyOwner \r
{\r
require(\r
block.timestamp < programStartTime || block.timestamp >= programEndTime,\r
"Cannot update APR during active program"\r
);\r
aprBasisPoints = newAprBasisPoints;\r
}\r
\r
/**\r
* @notice Pause the contract (admin only)\r
*/\r
function pause() external onlyOwner {\r
_pause();\r
}\r
\r
/**\r
* @notice Unpause the contract (admin only)\r
*/\r
function unpause() external onlyOwner {\r
_unpause();\r
}\r
\r
/**\r
* @notice Withdraw excess rewards after program ends\r
* @param amount Amount to withdraw\r
*/\r
function withdrawExcessRewards(uint256 amount) \r
external \r
onlyOwner \r
{\r
require(block.timestamp >= programEndTime, "Program not ended");\r
\r
uint256 excess = totalRewardsAllocated - totalRewardsDistributed;\r
require(amount <= excess, "Amount exceeds excess");\r
\r
bool success = bpToken.transfer(owner(), amount);\r
if (!success) revert TransferFailed();\r
}\r
\r
/**\r
* @notice Emergency withdraw BP tokens (only after program ends)\r
* @param amount Amount to withdraw\r
*/\r
function emergencyWithdrawBP(uint256 amount) \r
external \r
onlyOwner \r
{\r
require(block.timestamp >= programEndTime, "Program not ended");\r
bool success = bpToken.transfer(owner(), amount);\r
if (!success) revert TransferFailed();\r
}\r
}\r
"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"viaIR": true,
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
}}
Submitted on: 2025-10-24 20:14:55
Comments
Log in to comment.
No comments yet.