Skip to content

Commit

Permalink
Update public API of MaticX contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Sep 17, 2024
1 parent b1e3e48 commit 799ead4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 28 deletions.
30 changes: 9 additions & 21 deletions contracts/MaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down
5 changes: 0 additions & 5 deletions contracts/interfaces/IMaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/MaticX.forking.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ describe("MaticX (Forking)", function () {
}

const totalPooledStakeTokens =
await maticX.getTotalPooledStakeTokens();
await maticX.getTotalStakeAcrossAllValidators();
expect(totalPooledStakeTokens).to.equal(
totalStakeAmount.mul(2)
);
Expand Down Expand Up @@ -1079,7 +1079,7 @@ describe("MaticX (Forking)", function () {
}

const totalPooledStakeTokens =
await maticX.getTotalPooledStakeTokens();
await maticX.getTotalStakeAcrossAllValidators();
expect(totalPooledStakeTokens).to.equal(
totalStakeAmount.mul(2)
);
Expand Down

0 comments on commit 799ead4

Please sign in to comment.