@@ -23,6 +23,9 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
23
23
24
24
uint256 private constant MAX_UINT256 = 2 ** 256 - 1 ;
25
25
26
+ // 100% in parts per million
27
+ uint32 private constant MAX_PPM = 1000000 ;
28
+
26
29
// Equates to Connector weight on bancor formula to be CW = 1
27
30
uint32 private constant defaultReserveRatio = 1000000 ;
28
31
@@ -157,7 +160,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
157
160
erc1056Registry = IEthereumDIDRegistry (_didRegistry);
158
161
159
162
// Settings
160
- _setOwnerTaxPercentage (50 );
163
+ _setOwnerTaxPercentage (500000 );
161
164
}
162
165
163
166
/**
@@ -182,7 +185,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
182
185
* @param _ownerTaxPercentage Owner tax percentage
183
186
*/
184
187
function _setOwnerTaxPercentage (uint32 _ownerTaxPercentage ) private {
185
- require (_ownerTaxPercentage <= 100 , "Owner tax must be 100 or less " );
188
+ require (_ownerTaxPercentage <= MAX_PPM , "Owner tax must be MAX_PPM or less " );
186
189
ownerTaxPercentage = _ownerTaxPercentage;
187
190
emit ParameterUpdated ("ownerTaxPercentage " );
188
191
}
@@ -366,23 +369,20 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
366
369
// Burn all version signal in the name pool for tokens
367
370
uint256 tokens = curation.burn (namePool.subgraphDeploymentID, namePool.vSignal, 0 );
368
371
369
- // Take the owner cut of the curation tax
370
- (, uint256 curationTax ) = curation.tokensToSignal (namePool.subgraphDeploymentID, tokens);
371
- uint256 ownerTax = _chargeOwnerTax (curationTax, _graphAccount);
372
+ // Take the owner cut of the curation tax, add it to the total
373
+ uint32 curationTaxPercentage = curation.getCurationTaxPercentage ();
374
+
375
+ uint256 tokensWithTax = _chargeOwnerTax (tokens, _graphAccount, curationTaxPercentage);
372
376
373
377
// Update pool: constant nSignal, vSignal can change
374
378
namePool.subgraphDeploymentID = _newSubgraphDeploymentID;
375
- (namePool.vSignal, ) = curation.mint (
376
- namePool.subgraphDeploymentID,
377
- tokens.add (ownerTax), // Cover part of the tax by the owner
378
- 0
379
- );
379
+ (namePool.vSignal, ) = curation.mint (namePool.subgraphDeploymentID, tokensWithTax, 0 );
380
380
381
381
emit NameSignalUpgrade (
382
382
_graphAccount,
383
383
_subgraphNumber,
384
384
namePool.vSignal,
385
- tokens. add (ownerTax) ,
385
+ tokensWithTax ,
386
386
_newSubgraphDeploymentID
387
387
);
388
388
}
@@ -533,23 +533,35 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
533
533
534
534
/**
535
535
* @dev Calculate tax that owner will have to cover for upgrading or deprecating.
536
- * @param _curationTax Total curation tax for changing subgraphs
536
+ * @param _tokens Tokens that were received from deprecating the old subgraph
537
537
* @param _owner Subgraph owner
538
- * @return Amount the owner must pay by transferring GRT to the GNS
539
- */
540
- function _chargeOwnerTax (uint256 _curationTax , address _owner ) private returns (uint256 ) {
541
- if (_curationTax == 0 || ownerTaxPercentage == 0 ) {
538
+ * @param _curationTaxPercentage Tax percentage on curation deposits from Curation contract
539
+ * @return Total tokens that will be sent to curation, _tokens + ownerTax
540
+ */
541
+ function _chargeOwnerTax (
542
+ uint256 _tokens ,
543
+ address _owner ,
544
+ uint32 _curationTaxPercentage
545
+ ) private returns (uint256 ) {
546
+ if (_curationTaxPercentage == 0 || ownerTaxPercentage == 0 ) {
542
547
return 0 ;
543
548
}
544
549
545
- uint256 ownerTax = _curationTax.mul (ownerTaxPercentage).div (100 );
550
+ // calculate tax on current tokens
551
+ uint256 topUpTax = _tokens.mul (_curationTaxPercentage).div (MAX_PPM);
552
+ // take full tax, and multiply it by owner percentage to
553
+ // find the amount owner needs to add
554
+ uint256 ownerTax = topUpTax.mul (ownerTaxPercentage).div (MAX_PPM);
546
555
547
556
// Get the owner of the subgraph to reimburse the curation tax
548
557
require (
549
558
graphToken ().transferFrom (_owner, address (this ), ownerTax),
550
559
"GNS: Error reimbursing curation tax "
551
560
);
552
- return ownerTax;
561
+
562
+ // new amount is the total tokens before plus the owner tax
563
+ uint256 totalSentToCuration = _tokens.add (ownerTax);
564
+ return totalSentToCuration;
553
565
}
554
566
555
567
/**
@@ -565,8 +577,8 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
565
577
uint256 _tokensIn
566
578
)
567
579
public
568
- override
569
580
view
581
+ override
570
582
returns (
571
583
uint256 ,
572
584
uint256 ,
@@ -593,7 +605,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
593
605
address _graphAccount ,
594
606
uint256 _subgraphNumber ,
595
607
uint256 _nSignalIn
596
- ) public override view returns (uint256 , uint256 ) {
608
+ ) public view override returns (uint256 , uint256 ) {
597
609
NameCurationPool storage namePool = nameSignals[_graphAccount][_subgraphNumber];
598
610
uint256 vSignal = nSignalToVSignal (_graphAccount, _subgraphNumber, _nSignalIn);
599
611
uint256 tokensOut = curation ().signalToTokens (namePool.subgraphDeploymentID, vSignal);
@@ -611,7 +623,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
611
623
address _graphAccount ,
612
624
uint256 _subgraphNumber ,
613
625
uint256 _vSignalIn
614
- ) public override view returns (uint256 ) {
626
+ ) public view override returns (uint256 ) {
615
627
NameCurationPool storage namePool = nameSignals[_graphAccount][_subgraphNumber];
616
628
617
629
// Handle initialization by using 1:1 version to name signal
@@ -639,7 +651,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
639
651
address _graphAccount ,
640
652
uint256 _subgraphNumber ,
641
653
uint256 _nSignalIn
642
- ) public override view returns (uint256 ) {
654
+ ) public view override returns (uint256 ) {
643
655
NameCurationPool storage namePool = nameSignals[_graphAccount][_subgraphNumber];
644
656
return
645
657
BancorFormula (bondingCurve).calculateSaleReturn (
@@ -661,7 +673,7 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
661
673
address _graphAccount ,
662
674
uint256 _subgraphNumber ,
663
675
address _curator
664
- ) public override view returns (uint256 ) {
676
+ ) public view override returns (uint256 ) {
665
677
return nameSignals[_graphAccount][_subgraphNumber].curatorNSignal[_curator];
666
678
}
667
679
@@ -673,8 +685,8 @@ contract GNS is GNSV1Storage, GraphUpgradeable, IGNS {
673
685
*/
674
686
function isPublished (address _graphAccount , uint256 _subgraphNumber )
675
687
public
676
- override
677
688
view
689
+ override
678
690
returns (bool )
679
691
{
680
692
return subgraphs[_graphAccount][_subgraphNumber] != 0 ;
0 commit comments