-
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.
feat(StakeManager): add capabilities to register vaults
This commit introduces changes related to vault registrations in the stake manager. The stake manager needs to keep track of the vaults a users creates so it can aggregate accumulated MP across vaults for any given user. The `StakeVault` now comes with a `register()` function which needs to be called to register itself with the stake manager. `StakeManager` has a new `onlyRegisteredVault` modifier that ensures only registered vaults can actually `stake` and `unstake`. Closes #70
- Loading branch information
Showing
7 changed files
with
189 additions
and
71 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
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 |
---|---|---|
|
@@ -5,14 +5,15 @@ pragma solidity ^0.8.26; | |
import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol"; | ||
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||
import { IStakeManager } from "./interfaces/IStakeManager.sol"; | ||
import { IStakeVault } from "./interfaces/IStakeVault.sol"; | ||
|
||
/** | ||
* @title StakeVault | ||
* @author Ricardo Guilherme Schmidt <[email protected]> | ||
* @notice A contract to secure user stakes and manage staking with IStakeManager. | ||
* @dev This contract is owned by the user and allows staking, unstaking, and withdrawing tokens. | ||
*/ | ||
contract StakeVault is Ownable { | ||
contract StakeVault is IStakeVault, Ownable { | ||
error StakeVault__NoEnoughAvailableBalance(); | ||
error StakeVault__InvalidDestinationAddress(); | ||
error StakeVault__UpdateNotAvailable(); | ||
|
@@ -24,7 +25,7 @@ contract StakeVault is Ownable { | |
//if is needed that STAKING_TOKEN to be a variable, StakeManager should be changed to check codehash and | ||
//StakeVault(msg.sender).STAKING_TOKEN() | ||
IERC20 public immutable STAKING_TOKEN; | ||
IStakeManager private stakeManager; | ||
IStakeManager public stakeManager; | ||
|
||
/** | ||
* @dev Emitted when tokens are staked. | ||
|
@@ -52,6 +53,20 @@ contract StakeVault is Ownable { | |
stakeManager = _stakeManager; | ||
} | ||
|
||
/** | ||
* @notice Registers the vault with the stake manager. | ||
*/ | ||
function register() public { | ||
stakeManager.registerVault(); | ||
} | ||
|
||
/** | ||
* @notice Returns the address of the current owner. | ||
*/ | ||
function owner() public view override(Ownable, IStakeVault) returns (address) { | ||
return super.owner(); | ||
} | ||
|
||
/** | ||
* @notice Stake tokens for a specified time. | ||
* @param _amount The amount of tokens to stake. | ||
|
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
Oops, something went wrong.