From 799ead4fd7d4fc1ea90798bd32e62e6b4b4039b6 Mon Sep 17 00:00:00 2001 From: Sergey <2901744+evercoinx@users.noreply.github.com.> Date: Tue, 17 Sep 2024 19:07:51 +0200 Subject: [PATCH] Update public API of MaticX contract --- contracts/MaticX.sol | 30 +++++++++--------------------- contracts/interfaces/IMaticX.sol | 5 ----- test/MaticX.forking.spec.ts | 4 ++-- 3 files changed, 11 insertions(+), 28 deletions(-) diff --git a/contracts/MaticX.sol b/contracts/MaticX.sol index fc8289c1..502f1d73 100644 --- a/contracts/MaticX.sol +++ b/contracts/MaticX.sol @@ -379,8 +379,8 @@ contract MaticX is emit ClaimWithdrawal(_to, _idx, amountToClaim); } - /// @notice Withdraws Matic rewards from a given validator. This method is - /// deprecated. + /// @notice Withdraws Matic rewards from a given validator. + /// @custom:deprecated /// @param _validatorId - Validator id to withdraw Matic rewards function withdrawRewards( uint256 _validatorId @@ -489,7 +489,7 @@ contract MaticX is : IValidatorShare(validatorShare).buyVoucher(amountStaked, 0); uint256 totalShares = totalSupply(); - uint256 totalPooledStakeTokens = getTotalPooledStakeTokens(); + uint256 totalPooledStakeTokens = getTotalStakeAcrossAllValidators(); IFxStateRootTunnel(fxStateRootTunnel).sendMessageToChild( abi.encode(totalShares, totalPooledStakeTokens) @@ -554,7 +554,7 @@ contract MaticX is } /// @notice Converts an arbitrary amount of MaticX shares to stake tokens. - /// This method is deprecated. + /// @custom:deprecated /// @param _balance - Balance in MaticX /// @return Balance in stake tokens /// @return Total shares @@ -576,7 +576,7 @@ contract MaticX is uint256 totalShares = totalSupply(); totalShares = totalShares == 0 ? 1 : totalShares; - uint256 totalPooledStakeTokens = getTotalPooledStakeTokens(); + uint256 totalPooledStakeTokens = getTotalStakeAcrossAllValidators(); totalPooledStakeTokens = totalPooledStakeTokens == 0 ? 1 : totalPooledStakeTokens; @@ -599,7 +599,7 @@ contract MaticX is } /// @notice Converts an arbritrary amount of stake tokens to MaticX shares. - // This method is deprecated. + /// @custom:deprecated /// @param _balance - Balance in a stake token /// @return Balance in MaticX /// @return Total shares @@ -621,7 +621,7 @@ contract MaticX is uint256 totalShares = totalSupply(); totalShares = totalShares == 0 ? 1 : totalShares; - uint256 totalPooledStakeTokens = getTotalPooledStakeTokens(); + uint256 totalPooledStakeTokens = getTotalStakeAcrossAllValidators(); totalPooledStakeTokens = totalPooledStakeTokens == 0 ? 1 : totalPooledStakeTokens; @@ -734,25 +734,13 @@ contract MaticX is return totalStake; } - /// @notice Returns total pooled stake tokens from all registered - /// validators. This method is deprecated. + /// @notice Returns total pooled stake tokens from all registered validators. + /// @custom:deprecated /// @return Total pooled stake tokens function getTotalPooledMatic() external view override returns (uint256) { return getTotalStakeAcrossAllValidators(); } - /// @notice Returns total pooled stake tokens from all registered - /// validators. - /// @return Total pooled stake tokens - function getTotalPooledStakeTokens() - public - view - override - returns (uint256) - { - return getTotalStakeAcrossAllValidators(); - } - /// @notice Returns the total stake of this contract for the given validator /// share. /// @param _validatorShare - Address of the validator share diff --git a/contracts/interfaces/IMaticX.sol b/contracts/interfaces/IMaticX.sol index 3a828efd..26212d24 100644 --- a/contracts/interfaces/IMaticX.sol +++ b/contracts/interfaces/IMaticX.sol @@ -241,11 +241,6 @@ interface IMaticX is IERC20Upgradeable { /// @return Total pooled stake tokens function getTotalPooledMatic() external view returns (uint256); - /// @notice Returns total pooled stake tokens from all registered - /// validators. - /// @return Total pooled stake tokens - function getTotalPooledStakeTokens() external view returns (uint256); - /// @notice Returns the total stake of this contract for the given validator /// share. /// @param _validatorShare - Address of the validator share diff --git a/test/MaticX.forking.spec.ts b/test/MaticX.forking.spec.ts index 4a70cf8b..0a5f2011 100644 --- a/test/MaticX.forking.spec.ts +++ b/test/MaticX.forking.spec.ts @@ -891,7 +891,7 @@ describe("MaticX (Forking)", function () { } const totalPooledStakeTokens = - await maticX.getTotalPooledStakeTokens(); + await maticX.getTotalStakeAcrossAllValidators(); expect(totalPooledStakeTokens).to.equal( totalStakeAmount.mul(2) ); @@ -1079,7 +1079,7 @@ describe("MaticX (Forking)", function () { } const totalPooledStakeTokens = - await maticX.getTotalPooledStakeTokens(); + await maticX.getTotalStakeAcrossAllValidators(); expect(totalPooledStakeTokens).to.equal( totalStakeAmount.mul(2) );