Skip to content

Commit d6f7789

Browse files
committed
Fix GNS ownerFee PR #331 fixes
1 parent 5216c17 commit d6f7789

File tree

2 files changed

+25
-26
lines changed

2 files changed

+25
-26
lines changed

contracts/discovery/GNS.sol

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ contract GNS is Managed {
339339
delete subgraphs[_graphAccount][_subgraphNumber];
340340
emit SubgraphDeprecated(_graphAccount, _subgraphNumber);
341341

342-
_disableNameSignal(_graphAccount, _subgraphNumber, subgraphDeploymentID);
342+
_disableNameSignal(_graphAccount, _subgraphNumber);
343343
}
344344

345345
/**
@@ -396,14 +396,13 @@ contract GNS is Managed {
396396
namePool.vSignal = namePool.vSignal.sub(vSignalOld);
397397
// Update name signals deployment ID to match the subgraphs deployment ID
398398
namePool.subgraphDeploymentID = _newSubgraphDeploymentID;
399-
400399
// nSignal stays constant, but vSignal can change here
401-
uint256 vSignalNew = curation.mint(namePool.subgraphDeploymentID, (tokens + ownerFee));
402-
namePool.vSignal = vSignalNew;
400+
namePool.vSignal = curation.mint(namePool.subgraphDeploymentID, (tokens + ownerFee));
401+
403402
emit NameSignalUpgrade(
404403
_graphAccount,
405404
_subgraphNumber,
406-
vSignalNew,
405+
namePool.vSignal,
407406
tokens + ownerFee,
408407
_newSubgraphDeploymentID
409408
);
@@ -457,23 +456,20 @@ contract GNS is Managed {
457456
* contract holds the GRT from burning the vSignal, which all curators can withdraw manually.
458457
* @param _graphAccount Account that is deprecating their name curation
459458
* @param _subgraphNumber Subgraph number
460-
* @param _subgraphDeploymentID Subgraph deployment ID of the deprecating subgraph
461459
*/
462460
function _disableNameSignal(
463461
address _graphAccount,
464-
uint256 _subgraphNumber,
465-
bytes32 _subgraphDeploymentID
462+
uint256 _subgraphNumber
466463
) private {
467464
NameCurationPool storage namePool = nameSignals[_graphAccount][_subgraphNumber];
468-
uint256 vSignal = namePool.vSignal;
469-
namePool.vSignal = 0;
470465
// If no nSignal, then no need to burn vSignal
471466
if (namePool.nSignal != 0) {
472467
(uint256 tokens, , uint256 ownerFee) = _burnVSignal(
473468
_graphAccount,
474469
namePool.subgraphDeploymentID,
475-
vSignal
470+
namePool.vSignal
476471
);
472+
namePool.vSignal = 0;
477473
namePool.withdrawableGRT = tokens + ownerFee;
478474
}
479475
// Set the NameCurationPool fields to make it disabled
@@ -580,7 +576,7 @@ contract GNS is Managed {
580576
)
581577
{
582578
(uint256 tokens, uint256 withdrawalFees) = curation().burn(_subgraphDeploymentID, _vSignal);
583-
uint256 ownerFee = _ownerFee(withdrawalFees, _graphAccount);
579+
uint256 ownerFee = _chargeOwnerFee(withdrawalFees, _graphAccount);
584580
return (tokens, withdrawalFees, ownerFee);
585581
}
586582

@@ -590,7 +586,7 @@ contract GNS is Managed {
590586
* @param _withdrawalFees Total withdrawal fee for changing subgraphs
591587
* @return Amount the owner must pay by transferring GRT to the GNS
592588
*/
593-
function _ownerFee(uint256 _withdrawalFees, address _owner) private returns (uint256) {
589+
function _chargeOwnerFee(uint256 _withdrawalFees, address _owner) private returns (uint256) {
594590
if (ownerFeePercentage == 0) {
595591
return 0;
596592
}

test/gns.test.ts

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -901,22 +901,25 @@ describe('GNS', () => {
901901
// we compare 1:1 ratio. Its implied that vSignal is 1 as well (1:1:1)
902902
expect(tokensToDeposit).eq(nSignalCreated)
903903
}
904-
describe('setOwnerFeePercentage', function () {
905-
const newValue = 10
906-
it('should set `ownerFeePercentage`', async function () {
907-
// Can set if allowed
908-
await gns.connect(governor.signer).setOwnerFeePercentage(newValue)
909-
expect(await gns.ownerFeePercentage()).eq(newValue)
910904
})
911905

912-
it('reject set `ownerFeePercentage` if out of bounds', async function () {
913-
const tx = gns.connect(governor.signer).setOwnerFeePercentage(101)
914-
await expect(tx).revertedWith('Owner fee must be 100 or less')
915-
})
906+
describe('setOwnerFeePercentage', function () {
907+
const newValue = 10
908+
it('should set `ownerFeePercentage`', async function () {
909+
// Can set if allowed
910+
await gns.connect(governor.signer).setOwnerFeePercentage(newValue)
911+
expect(await gns.ownerFeePercentage()).eq(newValue)
912+
})
916913

917-
it('reject set `ownerFeePercentage` if not allowed', async function () {
918-
const tx = gns.connect(me.signer).setOwnerFeePercentage(newValue)
919-
await expect(tx).revertedWith('Caller must be Controller governor')
914+
it('reject set `ownerFeePercentage` if out of bounds', async function () {
915+
const tx = gns.connect(governor.signer).setOwnerFeePercentage(101)
916+
await expect(tx).revertedWith('Owner fee must be 100 or less')
917+
})
918+
919+
it('reject set `ownerFeePercentage` if not allowed', async function () {
920+
const tx = gns.connect(me.signer).setOwnerFeePercentage(newValue)
921+
await expect(tx).revertedWith('Caller must be Controller governor')
922+
})
920923
})
921924
})
922925
})

0 commit comments

Comments
 (0)