@@ -176,9 +176,7 @@ describe('GNS', () => {
176
176
subgraphToPublish = subgraph0 , // Defaults to subgraph created in before()
177
177
) => {
178
178
// Before stats for the old vSignal curve
179
- const tokensBeforeVSigOldCuration = await getTokensAndVSig ( subgraph0 . subgraphDeploymentID )
180
- const tokensBeforeOldCuration = tokensBeforeVSigOldCuration [ 0 ]
181
- const vSigBeforeOldCuration = tokensBeforeVSigOldCuration [ 1 ]
179
+ const ownerFee = await gns . ownerFeePercentage ( )
182
180
183
181
// Before stats for the name curve
184
182
const poolBefore = await gns . nameSignals ( graphAccount , subgraphNumber )
@@ -190,11 +188,10 @@ describe('GNS', () => {
190
188
subgraphNumber ,
191
189
nSigBefore ,
192
190
)
193
- const vSignalBurnEstimate = nSignalToTokensResult [ 0 ]
194
191
const tokensReceivedEstimate = nSignalToTokensResult [ 1 ]
195
192
196
193
// since in upgrade, owner must refund fees, we need to actually add this back in
197
- const feesToAddBackEstimate = nSignalToTokensResult [ 2 ]
194
+ const feesToAddBackEstimate = nSignalToTokensResult [ 2 ] . div ( toBN ( 100 / ownerFee ) )
198
195
const upgradeTokenReturn = tokensReceivedEstimate . add ( feesToAddBackEstimate )
199
196
200
197
// Get the value for new vSignal that should be created on the new curve
@@ -228,12 +225,12 @@ describe('GNS', () => {
228
225
subgraphToPublish . subgraphDeploymentID ,
229
226
)
230
227
231
- // Check curation vSignal old was lowered and tokens too
228
+ // Check curation vSignal old are set to zero
232
229
const tokensVSigOldCuration = await getTokensAndVSig ( subgraph0 . subgraphDeploymentID )
233
230
const tokensAfterOldCuration = tokensVSigOldCuration [ 0 ]
234
231
const vSigAfterOldCuration = tokensVSigOldCuration [ 1 ]
235
- expect ( tokensAfterOldCuration ) . eq ( tokensBeforeOldCuration . sub ( upgradeTokenReturn ) )
236
- expect ( vSigAfterOldCuration ) . eq ( vSigBeforeOldCuration . sub ( vSignalBurnEstimate ) )
232
+ expect ( tokensAfterOldCuration ) . eq ( 0 )
233
+ expect ( vSigAfterOldCuration ) . eq ( 0 )
237
234
238
235
// Check the vSignal of the new curation curve, amd tokens
239
236
const tokensVSigNewCuration = await getTokensAndVSig ( subgraphToPublish . subgraphDeploymentID )
@@ -260,15 +257,18 @@ describe('GNS', () => {
260
257
subgraphNumber0 : number ,
261
258
) => {
262
259
const curationBefore = await getTokensAndVSig ( subgraph0 . subgraphDeploymentID )
260
+ const ownerFee = await gns . ownerFeePercentage ( )
263
261
// We can use the whole amount, since in this test suite all vSignal is used to be staked on nSignal
264
262
const tokensBefore = curationBefore [ 0 ]
265
263
const ownerBalanceBefore = await grt . balanceOf ( account . address )
264
+ const expectedWithdrawalFee = tokensBefore . div ( toBN ( 1000000 / withdrawalPercentage ) )
265
+ const expectedOwnerFee = expectedWithdrawalFee . div ( toBN ( 100 / ownerFee ) )
266
266
267
267
const tx = gns . connect ( account . signer ) . deprecateSubgraph ( graphAccount , subgraphNumber0 )
268
268
await expect ( tx ) . emit ( gns , 'SubgraphDeprecated' ) . withArgs ( subgraph0 . graphAccount . address , 0 )
269
269
await expect ( tx )
270
270
. emit ( gns , 'NameSignalDisabled' )
271
- . withArgs ( graphAccount , subgraphNumber0 , tokensBefore )
271
+ . withArgs ( graphAccount , subgraphNumber0 , tokensBefore . sub ( expectedOwnerFee ) )
272
272
273
273
const deploymentID = await gns . subgraphs ( subgraph0 . graphAccount . address , 0 )
274
274
expect ( ethers . constants . HashZero ) . eq ( deploymentID )
@@ -279,11 +279,11 @@ describe('GNS', () => {
279
279
expect ( poolVSignalAfter . eq ( toBN ( '0' ) ) )
280
280
// Check that the owner balance decreased by the withdrawal fee
281
281
const ownerBalanceAfter = await grt . balanceOf ( account . address )
282
- expect ( ownerBalanceBefore . sub ( tokensBefore . div ( toBN ( 1000000 / withdrawalPercentage ) ) ) ) . eq (
283
- ownerBalanceAfter ,
284
- )
282
+ expect ( ownerBalanceBefore . sub ( expectedOwnerFee ) . eq ( ownerBalanceAfter ) )
285
283
// Should be equal since owner pays withdrawal fees
286
- expect ( poolAfter . withdrawableGRT ) . eq ( tokensBefore )
284
+ expect ( poolAfter . withdrawableGRT ) . eq (
285
+ tokensBefore . sub ( expectedWithdrawalFee ) . add ( expectedOwnerFee ) ,
286
+ )
287
287
// Check that deprecated is true
288
288
expect ( poolAfter . disabled ) . eq ( true )
289
289
// Check balance of gns increase by withdrawalFees from owner being added
@@ -901,21 +901,21 @@ describe('GNS', () => {
901
901
// we compare 1:1 ratio. Its implied that vSignal is 1 as well (1:1:1)
902
902
expect ( tokensToDeposit ) . eq ( nSignalCreated )
903
903
}
904
- describe ( 'setDeprecateFeePercentage ' , function ( ) {
904
+ describe ( 'setOwnerFeePercentage ' , function ( ) {
905
905
const newValue = 10
906
- it ( 'should set `minimumVSignalStake `' , async function ( ) {
906
+ it ( 'should set `ownerFeePercentage `' , async function ( ) {
907
907
// Can set if allowed
908
- await gns . connect ( governor . signer ) . setDeprecateFeePercentage ( newValue )
909
- expect ( await gns . deprecateFeePercentage ( ) ) . eq ( newValue )
908
+ await gns . connect ( governor . signer ) . setOwnerFeePercentage ( newValue )
909
+ expect ( await gns . ownerFeePercentage ( ) ) . eq ( newValue )
910
910
} )
911
911
912
- it ( 'reject set `minimumVSignalStake ` if out of bounds' , async function ( ) {
913
- const tx = gns . connect ( governor . signer ) . setDeprecateFeePercentage ( 101 )
914
- await expect ( tx ) . revertedWith ( 'Deprecate fee must be 100 or less' )
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
915
} )
916
916
917
- it ( 'reject set `minimumVSignalStake ` if not allowed' , async function ( ) {
918
- const tx = gns . connect ( me . signer ) . setDeprecateFeePercentage ( newValue )
917
+ it ( 'reject set `ownerFeePercentage ` if not allowed' , async function ( ) {
918
+ const tx = gns . connect ( me . signer ) . setOwnerFeePercentage ( newValue )
919
919
await expect ( tx ) . revertedWith ( 'Caller must be Controller governor' )
920
920
} )
921
921
} )
0 commit comments