@@ -324,9 +324,7 @@ contract BancorFormula {
324
324
uint256 _amount
325
325
) public view returns (uint256 ) {
326
326
// validate input
327
- require (
328
- _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2
329
- );
327
+ require (_supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 );
330
328
331
329
// special case for 0 amount
332
330
if (_amount == 0 ) return 0 ;
@@ -364,11 +362,7 @@ contract BancorFormula {
364
362
) public view returns (uint256 ) {
365
363
// validate input
366
364
require (
367
- _supply > 0 &&
368
- _reserveBalance > 0 &&
369
- _totalRatio > 1 &&
370
- _totalRatio <= MAX_RATIO * 2 &&
371
- _amount <= _supply
365
+ _supply > 0 && _reserveBalance > 0 && _totalRatio > 1 && _totalRatio <= MAX_RATIO * 2 && _amount <= _supply
372
366
);
373
367
374
368
// special case for 0 amount
@@ -407,12 +401,7 @@ contract BancorFormula {
407
401
* This functions assumes that "_expN < 2 ^ 256 / log(MAX_NUM - 1)", otherwise the multiplication should be replaced with a "safeMul".
408
402
* Since we rely on unsigned-integer arithmetic and "base < 1" ==> "log(base) < 0", this function does not support "_baseN < _baseD".
409
403
*/
410
- function power (
411
- uint256 _baseN ,
412
- uint256 _baseD ,
413
- uint32 _expN ,
414
- uint32 _expD
415
- ) internal view returns (uint256 , uint8 ) {
404
+ function power (uint256 _baseN , uint256 _baseD , uint32 _expN , uint32 _expD ) internal view returns (uint256 , uint8 ) {
416
405
require (_baseN < MAX_NUM);
417
406
418
407
uint256 baseLog;
@@ -428,10 +417,7 @@ contract BancorFormula {
428
417
return (optimalExp (baseLogTimesExp), MAX_PRECISION);
429
418
} else {
430
419
uint8 precision = findPositionInMaxExpArray (baseLogTimesExp);
431
- return (
432
- generalExp (baseLogTimesExp >> (MAX_PRECISION - precision), precision),
433
- precision
434
- );
420
+ return (generalExp (baseLogTimesExp >> (MAX_PRECISION - precision), precision), precision);
435
421
}
436
422
}
437
423
@@ -642,37 +628,21 @@ contract BancorFormula {
642
628
643
629
z = y = x - FIXED_1;
644
630
w = (y * y) / FIXED_1;
645
- res +=
646
- (z * (0x100000000000000000000000000000000 - y)) /
647
- 0x100000000000000000000000000000000 ;
631
+ res += (z * (0x100000000000000000000000000000000 - y)) / 0x100000000000000000000000000000000 ;
648
632
z = (z * w) / FIXED_1; // add y^01 / 01 - y^02 / 02
649
- res +=
650
- (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) /
651
- 0x200000000000000000000000000000000 ;
633
+ res += (z * (0x0aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa - y)) / 0x200000000000000000000000000000000 ;
652
634
z = (z * w) / FIXED_1; // add y^03 / 03 - y^04 / 04
653
- res +=
654
- (z * (0x099999999999999999999999999999999 - y)) /
655
- 0x300000000000000000000000000000000 ;
635
+ res += (z * (0x099999999999999999999999999999999 - y)) / 0x300000000000000000000000000000000 ;
656
636
z = (z * w) / FIXED_1; // add y^05 / 05 - y^06 / 06
657
- res +=
658
- (z * (0x092492492492492492492492492492492 - y)) /
659
- 0x400000000000000000000000000000000 ;
637
+ res += (z * (0x092492492492492492492492492492492 - y)) / 0x400000000000000000000000000000000 ;
660
638
z = (z * w) / FIXED_1; // add y^07 / 07 - y^08 / 08
661
- res +=
662
- (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) /
663
- 0x500000000000000000000000000000000 ;
639
+ res += (z * (0x08e38e38e38e38e38e38e38e38e38e38e - y)) / 0x500000000000000000000000000000000 ;
664
640
z = (z * w) / FIXED_1; // add y^09 / 09 - y^10 / 10
665
- res +=
666
- (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) /
667
- 0x600000000000000000000000000000000 ;
641
+ res += (z * (0x08ba2e8ba2e8ba2e8ba2e8ba2e8ba2e8b - y)) / 0x600000000000000000000000000000000 ;
668
642
z = (z * w) / FIXED_1; // add y^11 / 11 - y^12 / 12
669
- res +=
670
- (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) /
671
- 0x700000000000000000000000000000000 ;
643
+ res += (z * (0x089d89d89d89d89d89d89d89d89d89d89 - y)) / 0x700000000000000000000000000000000 ;
672
644
z = (z * w) / FIXED_1; // add y^13 / 13 - y^14 / 14
673
- res +=
674
- (z * (0x088888888888888888888888888888888 - y)) /
675
- 0x800000000000000000000000000000000 ; // add y^15 / 15 - y^16 / 16
645
+ res += (z * (0x088888888888888888888888888888888 - y)) / 0x800000000000000000000000000000000 ; // add y^15 / 15 - y^16 / 16
676
646
677
647
return res;
678
648
}
0 commit comments