@@ -4,7 +4,6 @@ pragma solidity ^0.8.9;
4
4
import "../common/Decimal.sol " ;
5
5
import "./GasPriceConstants.sol " ;
6
6
import "./SFCBase.sol " ;
7
- import "./StakeTokenizer.sol " ;
8
7
import "./NodeDriver.sol " ;
9
8
10
9
contract SFCLib is SFCBase {
@@ -229,7 +228,6 @@ contract SFCLib is SFCBase {
229
228
230
229
require (amount > 0 , "zero amount " );
231
230
require (amount <= getUnlockedStake (delegator, toValidatorID), "not enough unlocked stake " );
232
- require (_checkAllowedToWithdraw (delegator, toValidatorID), "outstanding sFTM balance " );
233
231
234
232
require (getWithdrawalRequest[delegator][toValidatorID][wrID].amount == 0 , "wrID already exists " );
235
233
@@ -244,37 +242,6 @@ contract SFCLib is SFCBase {
244
242
emit Undelegated (delegator, toValidatorID, wrID, amount);
245
243
}
246
244
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
-
278
245
function isSlashed (uint256 validatorID ) public view returns (bool ) {
279
246
return getValidator[validatorID].status & CHEATER_MASK != 0 ;
280
247
}
@@ -298,7 +265,6 @@ contract SFCLib is SFCBase {
298
265
function _withdraw (address delegator , uint256 toValidatorID , uint256 wrID , address payable receiver ) private {
299
266
WithdrawalRequest memory request = getWithdrawalRequest[delegator][toValidatorID][wrID];
300
267
require (request.epoch != 0 , "request doesn't exist " );
301
- require (_checkAllowedToWithdraw (delegator, toValidatorID), "outstanding sFTM balance " );
302
268
303
269
uint256 requestTime = request.time;
304
270
uint256 requestEpoch = request.epoch;
@@ -455,7 +421,6 @@ contract SFCLib is SFCBase {
455
421
}
456
422
457
423
function _claimRewards (address delegator , uint256 toValidatorID ) internal returns (Rewards memory rewards ) {
458
- require (_checkAllowedToWithdraw (delegator, toValidatorID), "outstanding sFTM balance " );
459
424
_stashRewards (delegator, toValidatorID);
460
425
rewards = _rewardsStash[delegator][toValidatorID];
461
426
uint256 totalReward = rewards.unlockedReward + rewards.lockupBaseReward + rewards.lockupExtraReward;
@@ -522,13 +487,6 @@ contract SFCLib is SFCBase {
522
487
epochEndTime (epoch) <= getLockupInfo[delegator][toValidatorID].endTime;
523
488
}
524
489
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
-
532
490
function getUnlockedStake (address delegator , uint256 toValidatorID ) public view returns (uint256 ) {
533
491
if (! isLockedUp (delegator, toValidatorID)) {
534
492
return getStake[delegator][toValidatorID];
@@ -653,7 +611,6 @@ contract SFCLib is SFCBase {
653
611
require (amount > 0 , "zero amount " );
654
612
require (isLockedUp (delegator, toValidatorID), "not locked up " );
655
613
require (amount <= ld.lockedStake, "not enough locked stake " );
656
- require (_checkAllowedToWithdraw (delegator, toValidatorID), "outstanding sFTM balance " );
657
614
require (! _redirected (delegator), "redirected " );
658
615
659
616
_stashRewards (delegator, toValidatorID);
0 commit comments