-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
42 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.24; | ||
|
||
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol"; | ||
import {PoolId} from "@uniswap/v4-core/src/types/PoolId.sol"; | ||
|
||
contract ClvrStake { | ||
|
||
uint256 public constant STAKE_AMOUNT = 1 ether; | ||
|
||
mapping(PoolId => mapping(address => bool)) public stakedSchedulers; // per pool addresses that can schedule swaps | ||
|
||
modifier onlyStakedScheduler(PoolKey calldata key) { | ||
require(isStakedScheduler(key, msg.sender), "Only staked schedulers can call this function"); | ||
_; | ||
} | ||
|
||
constructor() {} | ||
|
||
function stake(PoolKey calldata key, address scheduler) payable public { | ||
require(msg.value == STAKE_AMOUNT, "Must stake 1 ETH to stake"); | ||
stakedSchedulers[key.toId()][scheduler] = true; | ||
} | ||
|
||
function unstake(PoolKey calldata key, address scheduler) external onlyStakedScheduler(key) { | ||
stakedSchedulers[key.toId()][scheduler] = false; | ||
payable(msg.sender).transfer(STAKE_AMOUNT); | ||
} | ||
|
||
function isStakedScheduler(PoolKey calldata key, address scheduler) internal view returns (bool) { | ||
return stakedSchedulers[key.toId()][scheduler]; | ||
} | ||
} |