From 26dda5c90e32b5c4e5ec8a1dad408a4de09b299a Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 31 Oct 2023 18:17:01 -0300 Subject: [PATCH 1/3] fix(GNS): use the correct token amount when curation or owner tax are zero --- contracts/discovery/GNS.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/discovery/GNS.sol b/contracts/discovery/GNS.sol index 9af60ba2f..4da091e59 100644 --- a/contracts/discovery/GNS.sol +++ b/contracts/discovery/GNS.sol @@ -732,7 +732,7 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { uint32 _curationTaxPercentage ) internal returns (uint256) { if (_curationTaxPercentage == 0 || ownerTaxPercentage == 0) { - return 0; + return _tokens; } // Tax on the total bonding curve funds From 4f3018c4858552a854e7799c6fa93db47140cc87 Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Tue, 31 Oct 2023 18:25:23 -0300 Subject: [PATCH 2/3] test: regression test for new versions with zero owner tax --- test/gns.test.ts | 5 +++++ test/l2/l2GNS.test.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/test/gns.test.ts b/test/gns.test.ts index 98199cd52..b729a5c08 100644 --- a/test/gns.test.ts +++ b/test/gns.test.ts @@ -420,6 +420,11 @@ describe('L1GNS', () => { await publishNewVersion(me, subgraph.id, newSubgraph1, gns, curation) }) + it('should publish a new version on an existing subgraph when owner tax is zero', async function () { + await gns.connect(governor.signer).setOwnerTaxPercentage(0) + await publishNewVersion(me, subgraph.id, newSubgraph1, gns, curation) + }) + it('should publish a new version on an existing subgraph with no current signal', async function () { const emptySignalSubgraph = await publishNewSubgraph(me, buildSubgraph(), gns) await publishNewVersion(me, emptySignalSubgraph.id, newSubgraph1, gns, curation) diff --git a/test/l2/l2GNS.test.ts b/test/l2/l2GNS.test.ts index 728decacf..996f355c7 100644 --- a/test/l2/l2GNS.test.ts +++ b/test/l2/l2GNS.test.ts @@ -165,6 +165,11 @@ describe('L2GNS', () => { await publishNewVersion(me, subgraph.id, newSubgraph1, gns, curation) }) + it('should publish a new version on an existing subgraph when owner tax is zero', async function () { + await gns.connect(governor.signer).setOwnerTaxPercentage(0) + await publishNewVersion(me, subgraph.id, newSubgraph1, gns, curation) + }) + it('should publish a new version on an existing subgraph with no current signal', async function () { const emptySignalSubgraph = await publishNewSubgraph(me, buildSubgraph(), gns) await publishNewVersion(me, emptySignalSubgraph.id, newSubgraph1, gns, curation) From 322658ed487c41db3a8dd33370c8392998b0671b Mon Sep 17 00:00:00 2001 From: Pablo Carranza Velez Date: Fri, 24 Nov 2023 13:59:23 -0300 Subject: [PATCH 3/3] fix: comment to clarify behavior --- contracts/discovery/GNS.sol | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contracts/discovery/GNS.sol b/contracts/discovery/GNS.sol index 4da091e59..68408279d 100644 --- a/contracts/discovery/GNS.sol +++ b/contracts/discovery/GNS.sol @@ -731,6 +731,11 @@ abstract contract GNS is GNSV3Storage, GraphUpgradeable, IGNS, Multicall { address _owner, uint32 _curationTaxPercentage ) internal returns (uint256) { + // If curation or owner tax are zero, we don't need to charge owner tax + // so the amount of tokens to signal will remain the same. + // Note if owner tax is zero but curation tax is nonzero, the curation tax + // will still be charged (in Curation or L2Curation) - this function just calculates + // the owner's additional tax. if (_curationTaxPercentage == 0 || ownerTaxPercentage == 0) { return _tokens; }