-
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
9 changed files
with
247 additions
and
110 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 { IStakeManagerProxy } from "./interfaces/IStakeManagerProxy.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__NotEnoughAvailableBalance(); | ||
error StakeVault__InvalidDestinationAddress(); | ||
error StakeVault__UpdateNotAvailable(); | ||
|
@@ -26,7 +27,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; | ||
IStakeManagerProxy private stakeManager; | ||
IStakeManagerProxy public stakeManager; | ||
address public stakeManagerImplementationAddress; | ||
|
||
/** | ||
|
@@ -71,6 +72,20 @@ contract StakeVault is Ownable { | |
stakeManagerImplementationAddress = stakeManagerAddress; | ||
} | ||
|
||
/** | ||
* @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
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,10 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.26; | ||
|
||
import { IStakeManagerProxy } from "./IStakeManagerProxy.sol"; | ||
|
||
interface IStakeVault { | ||
function owner() external view returns (address); | ||
function stakeManager() external view returns (IStakeManagerProxy); | ||
function register() external; | ||
} |
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