@@ -112,6 +112,8 @@ interface IStakingRouter {
112
112
external
113
113
view
114
114
returns (uint256 );
115
+
116
+ function TOTAL_BASIS_POINTS () external view returns (uint256 );
115
117
}
116
118
117
119
interface IWithdrawalQueue {
@@ -673,7 +675,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
673
675
* Depends on the bunker state and protocol's pause state
674
676
*/
675
677
function canDeposit () public view returns (bool ) {
676
- return ! IWithdrawalQueue ( getLidoLocator (). withdrawalQueue () ).isBunkerModeActive () && ! isStopped ();
678
+ return ! _withdrawalQueue ( ).isBunkerModeActive () && ! isStopped ();
677
679
}
678
680
679
681
/**
@@ -682,7 +684,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
682
684
*/
683
685
function getDepositableEther () public view returns (uint256 ) {
684
686
uint256 bufferedEther = _getBufferedEther ();
685
- uint256 withdrawalReserve = IWithdrawalQueue ( getLidoLocator (). withdrawalQueue () ).unfinalizedStETH ();
687
+ uint256 withdrawalReserve = _withdrawalQueue ( ).unfinalizedStETH ();
686
688
return bufferedEther > withdrawalReserve ? bufferedEther - withdrawalReserve : 0 ;
687
689
}
688
690
@@ -698,7 +700,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
698
700
require (msg .sender == locator.depositSecurityModule (), "APP_AUTH_DSM_FAILED " );
699
701
require (canDeposit (), "CAN_NOT_DEPOSIT " );
700
702
701
- IStakingRouter stakingRouter = IStakingRouter (locator. stakingRouter () );
703
+ IStakingRouter stakingRouter = _stakingRouter ( );
702
704
uint256 depositsCount = Math256.min (
703
705
_maxDepositsCount,
704
706
stakingRouter.getStakingModuleMaxDepositsCount (_stakingModuleId, getDepositableEther ())
@@ -730,7 +732,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
730
732
* @dev DEPRECATED: use StakingRouter.getWithdrawalCredentials() instead
731
733
*/
732
734
function getWithdrawalCredentials () external view returns (bytes32 ) {
733
- return IStakingRouter ( getLidoLocator (). stakingRouter () ).getWithdrawalCredentials ();
735
+ return _stakingRouter ( ).getWithdrawalCredentials ();
734
736
}
735
737
736
738
/**
@@ -746,7 +748,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
746
748
* @dev DEPRECATED: use LidoLocator.treasury()
747
749
*/
748
750
function getTreasury () external view returns (address ) {
749
- return getLidoLocator (). treasury ();
751
+ return _treasury ();
750
752
}
751
753
752
754
/**
@@ -757,11 +759,11 @@ contract Lido is Versioned, StETHPermit, AragonApp {
757
759
* inaccurate because the actual value is truncated here to 1e4 precision.
758
760
*/
759
761
function getFee () external view returns (uint16 totalFee ) {
760
- totalFee = IStakingRouter ( getLidoLocator (). stakingRouter () ).getTotalFeeE4Precision ();
762
+ totalFee = _stakingRouter ( ).getTotalFeeE4Precision ();
761
763
}
762
764
763
765
/**
764
- * @notice Returns current fee distribution
766
+ * @notice Returns current fee distribution, values relative to the total fee (getFee())
765
767
* @dev DEPRECATED: Now fees information is stored in StakingRouter and
766
768
* with higher precision. Use StakingRouter.getStakingFeeAggregateDistribution() instead.
767
769
* @return treasuryFeeBasisPoints return treasury fee in TOTAL_BASIS_POINTS (10000 is 100% fee) precision
@@ -780,9 +782,15 @@ contract Lido is Versioned, StETHPermit, AragonApp {
780
782
uint16 operatorsFeeBasisPoints
781
783
)
782
784
{
783
- insuranceFeeBasisPoints = 0 ; // explicitly set to zero
784
- (treasuryFeeBasisPoints, operatorsFeeBasisPoints) = IStakingRouter (getLidoLocator ().stakingRouter ())
785
+ IStakingRouter stakingRouter = _stakingRouter ();
786
+ uint256 totalBasisPoints = stakingRouter.TOTAL_BASIS_POINTS ();
787
+ uint256 totalFee = stakingRouter.getTotalFeeE4Precision ();
788
+ (uint256 treasuryFeeBasisPointsAbs , uint256 operatorsFeeBasisPointsAbs ) = stakingRouter
785
789
.getStakingFeeAggregateDistributionE4Precision ();
790
+
791
+ insuranceFeeBasisPoints = 0 ; // explicitly set to zero
792
+ treasuryFeeBasisPoints = uint16 ((treasuryFeeBasisPointsAbs * totalBasisPoints) / totalFee);
793
+ operatorsFeeBasisPoints = uint16 ((operatorsFeeBasisPointsAbs * totalBasisPoints) / totalFee);
786
794
}
787
795
788
796
/*
@@ -970,7 +978,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
970
978
StakingRewardsDistribution memory ret ,
971
979
IStakingRouter router
972
980
) {
973
- router = IStakingRouter ( getLidoLocator (). stakingRouter () );
981
+ router = _stakingRouter ( );
974
982
975
983
(
976
984
ret.recipients,
@@ -1075,7 +1083,7 @@ contract Lido is Versioned, StETHPermit, AragonApp {
1075
1083
}
1076
1084
1077
1085
function _transferTreasuryRewards (uint256 treasuryReward ) internal {
1078
- address treasury = getLidoLocator (). treasury ();
1086
+ address treasury = _treasury ();
1079
1087
_transferShares (address (this ), treasury, treasuryReward);
1080
1088
_emitTransferAfterMintingShares (treasury, treasuryReward);
1081
1089
}
@@ -1371,4 +1379,16 @@ contract Lido is Versioned, StETHPermit, AragonApp {
1371
1379
ret.postTokenRebaseReceiver
1372
1380
) = getLidoLocator ().oracleReportComponentsForLido ();
1373
1381
}
1382
+
1383
+ function _stakingRouter () internal view returns (IStakingRouter) {
1384
+ return IStakingRouter (getLidoLocator ().stakingRouter ());
1385
+ }
1386
+
1387
+ function _withdrawalQueue () internal view returns (IWithdrawalQueue) {
1388
+ return IWithdrawalQueue (getLidoLocator ().withdrawalQueue ());
1389
+ }
1390
+
1391
+ function _treasury () internal view returns (address ) {
1392
+ return getLidoLocator ().treasury ();
1393
+ }
1374
1394
}
0 commit comments