Skip to content

Commit 28443cc

Browse files
authored
Exclusive stake gyser (#258)
* updated deps * exclusive stake geyser * fixed incorrect check
1 parent 1afad52 commit 28443cc

File tree

5 files changed

+2465
-4
lines changed

5 files changed

+2465
-4
lines changed

contracts/ExclusiveGeyser.sol

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// SPDX-License-Identifier: GPL-3.0-only
2+
pragma solidity 0.7.6;
3+
pragma abicoder v2;
4+
5+
import {IUniversalVault} from "./UniversalVault.sol";
6+
import {Geyser} from "./Geyser.sol";
7+
8+
/// @title ExclusiveGeyser
9+
/// @notice A special extension of GeyserV2 which allows staking in,
10+
/// at most one distribution program in any given time, for a given staking token.
11+
/// @dev Security contact: [email protected]
12+
contract ExclusiveGeyser is Geyser {
13+
/// @inheritdoc Geyser
14+
function stake(
15+
address vault,
16+
uint256 amount,
17+
bytes calldata permission
18+
) public override {
19+
// verify that vault has NOT locked staking token in other programs
20+
_enforceExclusiveStake(IUniversalVault(vault));
21+
22+
// continue with regular stake
23+
super.stake(vault, amount, permission);
24+
}
25+
26+
function _enforceExclusiveStake(IUniversalVault vault) private view {
27+
address stakingToken = super.getGeyserData().stakingToken;
28+
uint256 lockCount = vault.getLockSetCount();
29+
for (uint256 i = 0; i < lockCount; i++) {
30+
IUniversalVault.LockData memory lock = vault.getLockAt(i);
31+
if(lock.token == stakingToken){
32+
require(lock.delegate == address(this), "ExclusiveGeyser: expected exclusive stake");
33+
}
34+
}
35+
}
36+
}

contracts/Geyser.sol

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ contract Geyser is IGeyser, Powered, OwnableUpgradeable {
317317

318318
/* geyser getters */
319319

320-
function getGeyserData() external view override returns (GeyserData memory geyser) {
320+
function getGeyserData() public view override returns (GeyserData memory geyser) {
321321
return _geyser;
322322
}
323323

@@ -788,7 +788,7 @@ contract Geyser is IGeyser, Powered, OwnableUpgradeable {
788788
address vault,
789789
uint256 amount,
790790
bytes calldata permission
791-
) external override onlyOnline {
791+
) public virtual override onlyOnline {
792792
// verify vault is valid
793793
require(isValidVault(vault), "Geyser: vault is not registered");
794794

frontend/.yarn/install-state.gz

2.27 MB
Binary file not shown.

0 commit comments

Comments
 (0)