@@ -364,8 +364,8 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
364
364
365
365
// Freeze token and nest
366
366
// Because of the use of floating-point representation(fraction * 16 ^ exponent), it may bring some precision
367
- // loss After assets are frozen according to tokenAmountPerEth * ethNum , the part with poor accuracy may be
368
- // lost when the assets are returned, It should be frozen according to decodeFloat(fraction, exponent) * ethNum
367
+ // loss After assets are frozen according to equivalent * scale , the part with poor accuracy may be
368
+ // lost when the assets are returned, It should be frozen according to decodeFloat(fraction, exponent) * scale
369
369
// However, considering that the loss is less than 1 / 10 ^ 14, the loss here is ignored, and the part of
370
370
// precision loss can be transferred out as system income in the future
371
371
mapping (address => UINT) storage balances = _accounts[accountIndex].balances;
@@ -441,7 +441,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
441
441
442
442
uint accountIndex = _addressIndex (msg .sender );
443
443
// Number of nest to be pledged
444
- // sheet.token0Scales + sheet.token1Scales is always two times to sheet.ethNum
444
+ // sheet.token0Scales + sheet.token1Scales is always two times to sheet.scale (a virtual variable)
445
445
uint needNest1k = (takeNum << 2 ) * uint (sheet.nestNum1k) / (uint (sheet.token0Scales) + uint (sheet.token1Scales));
446
446
447
447
// 4. Calculate the number of eth, token and nest needed, and freeze them
@@ -572,7 +572,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
572
572
uint accountIndex = 0 ;
573
573
uint reward = 0 ;
574
574
uint nestNum1k = 0 ;
575
- uint ethNum = 0 ;
575
+ uint token0Scales = 0 ;
576
576
577
577
// storage variable must given a value at declaring, this is useless
578
578
mapping (address => UINT) storage balances = _accounts[0 /*accountIndex*/ ].balances;
@@ -631,7 +631,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
631
631
}
632
632
633
633
nestNum1k += uint (sheet.nestNum1k);
634
- ethNum += uint (sheet.token0Scales);
634
+ token0Scales += uint (sheet.token0Scales);
635
635
tokenValue += _decodeFloat (sheet.priceFloat) * uint (sheet.token1Scales);
636
636
637
637
// Set sheet.miner to 0, express the sheet is closed
@@ -652,7 +652,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
652
652
}
653
653
654
654
// Unfreeze token0
655
- _unfreeze (balances, channel.token0, ethNum * uint (channel.unit), accountIndex);
655
+ _unfreeze (balances, channel.token0, token0Scales * uint (channel.unit), accountIndex);
656
656
657
657
// Unfreeze nest
658
658
_unfreeze (balances, NEST_TOKEN_ADDRESS, nestNum1k * 1000 ether, accountIndex);
@@ -792,7 +792,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
792
792
function _create (
793
793
PriceSheet[] storage sheets ,
794
794
uint accountIndex ,
795
- uint32 ethNum ,
795
+ uint32 scale ,
796
796
uint nestNum1k ,
797
797
uint level_shares ,
798
798
uint equivalent
@@ -801,9 +801,9 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
801
801
sheets.push (PriceSheet (
802
802
uint32 (accountIndex), // uint32 miner;
803
803
uint32 (block .number ), // uint32 height;
804
- ethNum , // uint32 remainScales;
805
- ethNum , // uint32 token0Scales;
806
- ethNum , // uint32 token1Scales;
804
+ scale , // uint32 remainScales;
805
+ scale , // uint32 token0Scales;
806
+ scale , // uint32 token1Scales;
807
807
uint24 (nestNum1k), // uint32 nestNum1k;
808
808
uint8 (level_shares >> 8 ), // uint8 level;
809
809
uint8 (level_shares & 0xFF ),
@@ -1067,7 +1067,7 @@ contract NestBatchMining is ChainConfig, NestFrequentlyUsed, INestBatchMining {
1067
1067
1068
1068
// Convert uint to uint96
1069
1069
function _toUInt96 (uint value ) internal pure returns (uint96 ) {
1070
- require (value < 0x1000000000000000000000000 );
1070
+ require (value < 0x1000000000000000000000000 , " NBM:can't convert to uint96 " );
1071
1071
return uint96 (value);
1072
1072
}
1073
1073
0 commit comments