Skip to content

Commit 3e0b6bd

Browse files
committed
feat: require minimum stake to allocate zero tokens
1 parent b352e49 commit 3e0b6bd

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

contracts/staking/Staking.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,9 +1120,11 @@ contract Staking is StakingV2Storage, GraphUpgradeable, IStaking, Multicall {
11201120
// Needs to have free capacity not used for other purposes to allocate
11211121
require(getIndexerCapacity(_indexer) >= _tokens, "!capacity");
11221122
} else {
1123-
// Allocating zero-tokens still needs to have stake
1124-
// Minimum indexer stake is managed by stake/unstake
1125-
require(stakes[_indexer].tokensSecureStake() > 0, "!stake");
1123+
// Allocating zero-tokens still needs to comply with stake requirements
1124+
require(
1125+
stakes[_indexer].tokensSecureStake() >= minimumIndexerStake,
1126+
"!minimumIndexerStake"
1127+
);
11261128
}
11271129

11281130
// Creates an allocation

test/staking/allocation.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,9 @@ describe('Staking:Allocation', () => {
357357
await expect(tx).revertedWith('!capacity')
358358
})
359359

360-
it('reject allocate zero tokens if no tokens staked', async function () {
360+
it('reject allocate zero tokens if no minimum stake', async function () {
361361
const tx = allocate(toBN('0'))
362-
await expect(tx).revertedWith('!stake')
362+
await expect(tx).revertedWith('!minimumIndexerStake')
363363
})
364364

365365
context('> when staked', function () {

0 commit comments

Comments
 (0)