@@ -173,6 +173,7 @@ describe('GNS', () => {
173
173
const namePoolBefore = await gns . nameSignals ( graphAccount , subgraphNumber )
174
174
175
175
// Check what selling all nSignal, which == selling all vSignal, should return for tokens
176
+ // NOTE - no tax on burning on nSignal
176
177
const { 1 : tokensReceivedEstimate } = await gns . nSignalToTokens (
177
178
graphAccount ,
178
179
subgraphNumber ,
@@ -182,24 +183,34 @@ describe('GNS', () => {
182
183
// Deposit 100, 5 is taxed, 95 GRT in curve
183
184
// Upgrade - calculate 5% tax on 95 --> 4.75 GRT
184
185
// Multiple by ownerPercentage --> 50% * 4.75 = 2.375 GRT
185
- // Owner adds 2.375 to the amount, we deposit 97.375 GRT into the curve
186
- // In the end there will be 92.5 GRT left after the taxation of
187
- // the upgrade
186
+ // Owner adds 2.375 to 90.25, we deposit 92.625 GRT into the curve
187
+ // Divide this by 0.95 to get exactly 97.5 total tokens to be deposited
188
188
189
189
// nSignalToTokens returns the amount of tokens with tax removed
190
190
// already. So we must add in the tokens removed
191
191
const MAX_PPM = 1000000
192
- const ownerFullTax = tokensReceivedEstimate . mul ( curationTaxPercentage ) . div ( MAX_PPM )
192
+ const taxOnOriginal = tokensReceivedEstimate . mul ( curationTaxPercentage ) . div ( MAX_PPM )
193
+ const totalWithoutOwnerTax = tokensReceivedEstimate . sub ( taxOnOriginal )
194
+ const ownerTax = taxOnOriginal . mul ( ownerTaxPercentage ) . div ( MAX_PPM )
193
195
194
- const ownerTax = ownerFullTax . mul ( ownerTaxPercentage ) . div ( MAX_PPM )
195
- const upgradeTokenReturn = tokensReceivedEstimate . add ( ownerTax )
196
+ const totalWithOwnerTax = totalWithoutOwnerTax . add ( ownerTax )
197
+
198
+ const totalAdjustedUp = totalWithOwnerTax . mul ( MAX_PPM ) . div ( MAX_PPM - curationTaxPercentage )
196
199
197
200
// Re-estimate amount of signal to get considering the owner tax paid by the owner
198
201
const { 0 : newVSignalEstimate , 1 : newCurationTaxEstimate } = await curation . tokensToSignal (
199
202
subgraphToPublish . subgraphDeploymentID ,
200
- upgradeTokenReturn ,
203
+ totalAdjustedUp ,
201
204
)
202
205
206
+ console . log ( 'taxOnOriginal: ' , taxOnOriginal . toString ( ) )
207
+ console . log ( 'totalWithoutOwnerTax: ' , totalWithoutOwnerTax . toString ( ) )
208
+ console . log ( 'ownerTax: ' , ownerTax . toString ( ) )
209
+ console . log ( 'totalWithOwnerTax: ' , totalWithOwnerTax . toString ( ) )
210
+ console . log ( 'total adj up: ' , totalAdjustedUp . toString ( ) )
211
+
212
+ console . log ( 'total adj up: ' , totalAdjustedUp . toString ( ) )
213
+
203
214
const tx = gns
204
215
. connect ( account . signer )
205
216
. publishNewVersion (
@@ -221,7 +232,7 @@ describe('GNS', () => {
221
232
graphAccount ,
222
233
subgraphNumber ,
223
234
newVSignalEstimate ,
224
- upgradeTokenReturn ,
235
+ totalAdjustedUp ,
225
236
subgraphToPublish . subgraphDeploymentID ,
226
237
)
227
238
@@ -236,7 +247,7 @@ describe('GNS', () => {
236
247
const [ tokensAfterNewCurve , vSignalAfterNewCurve ] = await getTokensAndVSignal (
237
248
subgraphToPublish . subgraphDeploymentID ,
238
249
)
239
- expect ( tokensAfterNewCurve ) . eq ( upgradeTokenReturn . sub ( newCurationTaxEstimate ) )
250
+ expect ( tokensAfterNewCurve ) . eq ( totalAdjustedUp . sub ( newCurationTaxEstimate ) )
240
251
expect ( vSignalAfterNewCurve ) . eq ( newVSignalEstimate )
241
252
242
253
// Check the nSignal pool
0 commit comments