@@ -7,6 +7,10 @@ const toUFrgDenomination = (ample: string): BigNumber =>
7
7
8
8
const DECIMALS = 9
9
9
const INITIAL_SUPPLY = ethers . utils . parseUnits ( '50' , 6 + DECIMALS )
10
+ const MAX_UINT256 = ethers . BigNumber . from ( 2 ) . pow ( 256 ) . sub ( 1 )
11
+ const MAX_INT256 = ethers . BigNumber . from ( 2 ) . pow ( 255 ) . sub ( 1 )
12
+ const TOTAL_GONS = MAX_UINT256 . sub ( MAX_UINT256 . mod ( INITIAL_SUPPLY ) )
13
+
10
14
const transferAmount = toUFrgDenomination ( '10' )
11
15
const unitTokenAmount = toUFrgDenomination ( '1' )
12
16
@@ -51,10 +55,20 @@ describe('UFragments:Initialization', () => {
51
55
)
52
56
} )
53
57
58
+ it ( "should set the deployer's scaled balance" , async function ( ) {
59
+ expect ( await uFragments . scaledBalanceOf ( await deployer . getAddress ( ) ) ) . to . eq (
60
+ TOTAL_GONS ,
61
+ )
62
+ } )
63
+
54
64
it ( 'should set the totalSupply to 50M' , async function ( ) {
55
65
expect ( await uFragments . totalSupply ( ) ) . to . eq ( INITIAL_SUPPLY )
56
66
} )
57
67
68
+ it ( 'should set the scaledTotalSupply' , async function ( ) {
69
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
70
+ } )
71
+
58
72
it ( 'should set the owner' , async function ( ) {
59
73
expect ( await uFragments . owner ( ) ) . to . eq ( await deployer . getAddress ( ) )
60
74
} )
@@ -154,6 +168,22 @@ describe('UFragments:Rebase:Expansion', async () => {
154
168
await uFragments
155
169
. connect ( deployer )
156
170
. transfer ( await B . getAddress ( ) , toUFrgDenomination ( '250' ) )
171
+
172
+ expect ( await uFragments . totalSupply ( ) ) . to . eq ( INITIAL_SUPPLY )
173
+ expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
174
+ toUFrgDenomination ( '750' ) ,
175
+ )
176
+ expect ( await uFragments . balanceOf ( await B . getAddress ( ) ) ) . to . eq (
177
+ toUFrgDenomination ( '250' ) ,
178
+ )
179
+
180
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
181
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
182
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
183
+ )
184
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
185
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
186
+ )
157
187
} )
158
188
159
189
it ( 'should emit Rebase' , async function ( ) {
@@ -166,6 +196,10 @@ describe('UFragments:Rebase:Expansion', async () => {
166
196
expect ( await uFragments . totalSupply ( ) ) . to . eq ( initialSupply . add ( rebaseAmt ) )
167
197
} )
168
198
199
+ it ( 'should NOT CHANGE the scaledTotalSupply' , async function ( ) {
200
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
201
+ } )
202
+
169
203
it ( 'should increase individual balances' , async function ( ) {
170
204
expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
171
205
toUFrgDenomination ( '825' ) ,
@@ -175,6 +209,15 @@ describe('UFragments:Rebase:Expansion', async () => {
175
209
)
176
210
} )
177
211
212
+ it ( 'should NOT CHANGE the individual scaled balances' , async function ( ) {
213
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
214
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
215
+ )
216
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
217
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
218
+ )
219
+ } )
220
+
178
221
it ( 'should return the new supply' , async function ( ) {
179
222
const returnVal = await uFragments
180
223
. connect ( policy )
@@ -251,6 +294,22 @@ describe('UFragments:Rebase:NoChange', function () {
251
294
await uFragments
252
295
. connect ( deployer )
253
296
. transfer ( await B . getAddress ( ) , toUFrgDenomination ( '250' ) )
297
+
298
+ expect ( await uFragments . totalSupply ( ) ) . to . eq ( INITIAL_SUPPLY )
299
+ expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
300
+ toUFrgDenomination ( '750' ) ,
301
+ )
302
+ expect ( await uFragments . balanceOf ( await B . getAddress ( ) ) ) . to . eq (
303
+ toUFrgDenomination ( '250' ) ,
304
+ )
305
+
306
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
307
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
308
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
309
+ )
310
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
311
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
312
+ )
254
313
} )
255
314
256
315
it ( 'should emit Rebase' , async function ( ) {
@@ -263,6 +322,10 @@ describe('UFragments:Rebase:NoChange', function () {
263
322
expect ( await uFragments . totalSupply ( ) ) . to . eq ( initialSupply )
264
323
} )
265
324
325
+ it ( 'should NOT CHANGE the scaledTotalSupply' , async function ( ) {
326
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
327
+ } )
328
+
266
329
it ( 'should NOT CHANGE individual balances' , async function ( ) {
267
330
expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
268
331
toUFrgDenomination ( '750' ) ,
@@ -271,6 +334,15 @@ describe('UFragments:Rebase:NoChange', function () {
271
334
toUFrgDenomination ( '250' ) ,
272
335
)
273
336
} )
337
+
338
+ it ( 'should NOT CHANGE the individual scaled balances' , async function ( ) {
339
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
340
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
341
+ )
342
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
343
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
344
+ )
345
+ } )
274
346
} )
275
347
276
348
describe ( 'UFragments:Rebase:Contraction' , function ( ) {
@@ -292,6 +364,22 @@ describe('UFragments:Rebase:Contraction', function () {
292
364
await uFragments
293
365
. connect ( deployer )
294
366
. transfer ( await B . getAddress ( ) , toUFrgDenomination ( '250' ) )
367
+
368
+ expect ( await uFragments . totalSupply ( ) ) . to . eq ( INITIAL_SUPPLY )
369
+ expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
370
+ toUFrgDenomination ( '750' ) ,
371
+ )
372
+ expect ( await uFragments . balanceOf ( await B . getAddress ( ) ) ) . to . eq (
373
+ toUFrgDenomination ( '250' ) ,
374
+ )
375
+
376
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
377
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
378
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
379
+ )
380
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
381
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
382
+ )
295
383
} )
296
384
297
385
it ( 'should emit Rebase' , async function ( ) {
@@ -304,6 +392,10 @@ describe('UFragments:Rebase:Contraction', function () {
304
392
expect ( await uFragments . totalSupply ( ) ) . to . eq ( initialSupply . sub ( rebaseAmt ) )
305
393
} )
306
394
395
+ it ( 'should NOT. CHANGE the scaledTotalSupply' , async function ( ) {
396
+ expect ( await uFragments . scaledTotalSupply ( ) ) . to . eq ( TOTAL_GONS )
397
+ } )
398
+
307
399
it ( 'should decrease individual balances' , async function ( ) {
308
400
expect ( await uFragments . balanceOf ( await A . getAddress ( ) ) ) . to . eq (
309
401
toUFrgDenomination ( '675' ) ,
@@ -312,6 +404,15 @@ describe('UFragments:Rebase:Contraction', function () {
312
404
toUFrgDenomination ( '225' ) ,
313
405
)
314
406
} )
407
+
408
+ it ( 'should NOT CHANGE the individual scaled balances' , async function ( ) {
409
+ expect ( await uFragments . scaledBalanceOf ( await A . getAddress ( ) ) ) . to . eq (
410
+ '1736881338559742931353564775130318617799049769984608460591863250000000000' ,
411
+ )
412
+ expect ( await uFragments . scaledBalanceOf ( await B . getAddress ( ) ) ) . to . eq (
413
+ '578960446186580977117854925043439539266349923328202820197287750000000000' ,
414
+ )
415
+ } )
315
416
} )
316
417
317
418
describe ( 'UFragments:Transfer' , function ( ) {
0 commit comments