Skip to content

Commit 8fcdeaa

Browse files
author
Mike-CZ
committed
Remove StakeTokenizer
1 parent c4b7d33 commit 8fcdeaa

File tree

6 files changed

+0
-118
lines changed

6 files changed

+0
-118
lines changed

contracts/sfc/SFC.sol

-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,6 @@ contract SFC is SFCBase, Version {
102102
getEpochSnapshot[sealedEpoch].endTime = _now();
103103
}
104104

105-
function updateStakeTokenizerAddress(address addr) external onlyOwner {
106-
stakeTokenizerAddress = addr;
107-
}
108-
109105
function updateLibAddress(address v) external onlyOwner {
110106
libAddress = v;
111107
}

contracts/sfc/SFCI.sol

-4
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,6 @@ interface SFCI {
101101

102102
function slashingRefundRatio(uint256) external view returns (uint256);
103103

104-
function stakeTokenizerAddress() external view returns (address);
105-
106104
function stashedRewardsUntilEpoch(address, uint256) external view returns (uint256);
107105

108106
function totalActiveStake() external view returns (uint256);
@@ -171,8 +169,6 @@ interface SFCI {
171169

172170
function updateSlashingRefundRatio(uint256 validatorID, uint256 refundRatio) external;
173171

174-
function updateStakeTokenizerAddress(address addr) external;
175-
176172
function updateTreasuryAddress(address v) external;
177173

178174
function burnFTM(uint256 amount) external;

contracts/sfc/SFCLib.sol

-43
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pragma solidity ^0.8.9;
44
import "../common/Decimal.sol";
55
import "./GasPriceConstants.sol";
66
import "./SFCBase.sol";
7-
import "./StakeTokenizer.sol";
87
import "./NodeDriver.sol";
98

109
contract SFCLib is SFCBase {
@@ -229,7 +228,6 @@ contract SFCLib is SFCBase {
229228

230229
require(amount > 0, "zero amount");
231230
require(amount <= getUnlockedStake(delegator, toValidatorID), "not enough unlocked stake");
232-
require(_checkAllowedToWithdraw(delegator, toValidatorID), "outstanding sFTM balance");
233231

234232
require(getWithdrawalRequest[delegator][toValidatorID][wrID].amount == 0, "wrID already exists");
235233

@@ -244,37 +242,6 @@ contract SFCLib is SFCBase {
244242
emit Undelegated(delegator, toValidatorID, wrID, amount);
245243
}
246244

247-
// liquidateSFTM is used for finalization of last fMint positions with outstanding sFTM balances
248-
// it allows to undelegate without the unboding period, and also to unlock stake without a penalty.
249-
// Such a simplification, which might be dangerous generally, is okay here because there's only a small amount
250-
// of leftover sFTM
251-
function liquidateSFTM(address delegator, uint256 toValidatorID, uint256 amount) external {
252-
require(msg.sender == sftmFinalizer, "not sFTM finalizer");
253-
_stashRewards(delegator, toValidatorID);
254-
255-
require(amount > 0, "zero amount");
256-
StakeTokenizer(stakeTokenizerAddress).redeemSFTMFor(msg.sender, delegator, toValidatorID, amount);
257-
require(amount <= getStake[delegator][toValidatorID], "not enough stake");
258-
uint256 unlockedStake = getUnlockedStake(delegator, toValidatorID);
259-
if (amount > unlockedStake) {
260-
LockedDelegation storage ld = getLockupInfo[delegator][toValidatorID];
261-
ld.lockedStake = ld.lockedStake - amount - unlockedStake;
262-
emit UnlockedStake(delegator, toValidatorID, amount - unlockedStake, 0);
263-
}
264-
265-
_rawUndelegate(delegator, toValidatorID, amount, false, true, false);
266-
267-
_syncValidator(toValidatorID, false);
268-
269-
emit Undelegated(delegator, toValidatorID, 0xffffffffff, amount);
270-
271-
// It's important that we transfer after erasing (protection against Re-Entrancy)
272-
(bool sent, ) = msg.sender.call{value: amount}("");
273-
require(sent, "Failed to send FTM");
274-
275-
emit Withdrawn(delegator, toValidatorID, 0xffffffffff, amount);
276-
}
277-
278245
function isSlashed(uint256 validatorID) public view returns (bool) {
279246
return getValidator[validatorID].status & CHEATER_MASK != 0;
280247
}
@@ -298,7 +265,6 @@ contract SFCLib is SFCBase {
298265
function _withdraw(address delegator, uint256 toValidatorID, uint256 wrID, address payable receiver) private {
299266
WithdrawalRequest memory request = getWithdrawalRequest[delegator][toValidatorID][wrID];
300267
require(request.epoch != 0, "request doesn't exist");
301-
require(_checkAllowedToWithdraw(delegator, toValidatorID), "outstanding sFTM balance");
302268

303269
uint256 requestTime = request.time;
304270
uint256 requestEpoch = request.epoch;
@@ -455,7 +421,6 @@ contract SFCLib is SFCBase {
455421
}
456422

457423
function _claimRewards(address delegator, uint256 toValidatorID) internal returns (Rewards memory rewards) {
458-
require(_checkAllowedToWithdraw(delegator, toValidatorID), "outstanding sFTM balance");
459424
_stashRewards(delegator, toValidatorID);
460425
rewards = _rewardsStash[delegator][toValidatorID];
461426
uint256 totalReward = rewards.unlockedReward + rewards.lockupBaseReward + rewards.lockupExtraReward;
@@ -522,13 +487,6 @@ contract SFCLib is SFCBase {
522487
epochEndTime(epoch) <= getLockupInfo[delegator][toValidatorID].endTime;
523488
}
524489

525-
function _checkAllowedToWithdraw(address delegator, uint256 toValidatorID) internal view returns (bool) {
526-
if (stakeTokenizerAddress == address(0)) {
527-
return true;
528-
}
529-
return StakeTokenizer(stakeTokenizerAddress).allowedToWithdrawStake(delegator, toValidatorID);
530-
}
531-
532490
function getUnlockedStake(address delegator, uint256 toValidatorID) public view returns (uint256) {
533491
if (!isLockedUp(delegator, toValidatorID)) {
534492
return getStake[delegator][toValidatorID];
@@ -653,7 +611,6 @@ contract SFCLib is SFCBase {
653611
require(amount > 0, "zero amount");
654612
require(isLockedUp(delegator, toValidatorID), "not locked up");
655613
require(amount <= ld.lockedStake, "not enough locked stake");
656-
require(_checkAllowedToWithdraw(delegator, toValidatorID), "outstanding sFTM balance");
657614
require(!_redirected(delegator), "redirected");
658615

659616
_stashRewards(delegator, toValidatorID);

contracts/sfc/SFCState.sol

-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ contract SFCState is Initializable, Ownable {
8888

8989
mapping(uint256 => uint256) public slashingRefundRatio; // validator ID -> (slashing refund ratio)
9090

91-
address public stakeTokenizerAddress;
92-
9391
uint256 private erased3;
9492
uint256 private erased4;
9593
uint256 public minGasPrice;

contracts/sfc/StakeTokenizer.sol

-61
This file was deleted.

contracts/test/UnitTestSFC.sol

-4
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,6 @@ interface SFCUnitTestI {
177177

178178
function slashingRefundRatio(uint256) external view returns (uint256);
179179

180-
function stakeTokenizerAddress() external view returns (address);
181-
182180
function stashedRewardsUntilEpoch(address, uint256) external view returns (uint256);
183181

184182
function targetGasPowerPerSecond() external view returns (uint256);
@@ -251,8 +249,6 @@ interface SFCUnitTestI {
251249

252250
function updateSlashingRefundRatio(uint256 validatorID, uint256 refundRatio) external;
253251

254-
function updateStakeTokenizerAddress(address addr) external;
255-
256252
function updateTreasuryAddress(address v) external;
257253

258254
function burnFTM(uint256 amount) external;

0 commit comments

Comments
 (0)