Skip to content

Commit

Permalink
Exclusive stake gyser (#258)
Browse files Browse the repository at this point in the history
* updated deps

* exclusive stake geyser

* fixed incorrect check
  • Loading branch information
aalavandhan authored Dec 13, 2024
1 parent 1afad52 commit 28443cc
Show file tree
Hide file tree
Showing 5 changed files with 2,465 additions and 4 deletions.
36 changes: 36 additions & 0 deletions contracts/ExclusiveGeyser.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.7.6;
pragma abicoder v2;

import {IUniversalVault} from "./UniversalVault.sol";
import {Geyser} from "./Geyser.sol";

/// @title ExclusiveGeyser
/// @notice A special extension of GeyserV2 which allows staking in,
/// at most one distribution program in any given time, for a given staking token.
/// @dev Security contact: [email protected]
contract ExclusiveGeyser is Geyser {
/// @inheritdoc Geyser
function stake(
address vault,
uint256 amount,
bytes calldata permission
) public override {
// verify that vault has NOT locked staking token in other programs
_enforceExclusiveStake(IUniversalVault(vault));

// continue with regular stake
super.stake(vault, amount, permission);
}

function _enforceExclusiveStake(IUniversalVault vault) private view {
address stakingToken = super.getGeyserData().stakingToken;
uint256 lockCount = vault.getLockSetCount();
for (uint256 i = 0; i < lockCount; i++) {
IUniversalVault.LockData memory lock = vault.getLockAt(i);
if(lock.token == stakingToken){
require(lock.delegate == address(this), "ExclusiveGeyser: expected exclusive stake");
}
}
}
}
4 changes: 2 additions & 2 deletions contracts/Geyser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ contract Geyser is IGeyser, Powered, OwnableUpgradeable {

/* geyser getters */

function getGeyserData() external view override returns (GeyserData memory geyser) {
function getGeyserData() public view override returns (GeyserData memory geyser) {
return _geyser;
}

Expand Down Expand Up @@ -788,7 +788,7 @@ contract Geyser is IGeyser, Powered, OwnableUpgradeable {
address vault,
uint256 amount,
bytes calldata permission
) external override onlyOnline {
) public virtual override onlyOnline {
// verify vault is valid
require(isValidVault(vault), "Geyser: vault is not registered");

Expand Down
Binary file added frontend/.yarn/install-state.gz
Binary file not shown.
Loading

0 comments on commit 28443cc

Please sign in to comment.