@@ -12,9 +12,9 @@ use crate::pallet::{
1212} ;
1313use crate :: staking_epoch:: { mint_funds, mint_into_treasury} ;
1414use crate :: {
15- BalanceOf , Config , DepositOnHold , DomainBlockNumberFor , DomainHashingFor , Event ,
16- ExecutionReceiptOf , HoldIdentifier , InvalidBundleAuthors , NominatorId , OperatorEpochSharePrice ,
17- OperatorHighestSlot , Pallet , ReceiptHashFor , SlashedReason ,
15+ BalanceOf , Config , DepositOnHold , DeregisteredOperators , DomainBlockNumberFor ,
16+ DomainHashingFor , Event , ExecutionReceiptOf , HoldIdentifier , InvalidBundleAuthors , NominatorId ,
17+ OperatorEpochSharePrice , OperatorHighestSlot , Pallet , ReceiptHashFor , SlashedReason ,
1818} ;
1919use frame_support:: traits:: fungible:: { Inspect , MutateHold } ;
2020use frame_support:: traits:: tokens:: { Fortitude , Precision , Preservation } ;
@@ -698,6 +698,10 @@ pub(crate) fn do_deregister_operator<T: Config>(
698698 operator. update_status ( OperatorStatus :: Deregistered ( operator_deregister_info) ) ;
699699
700700 stake_summary. next_operators . remove ( & operator_id) ;
701+
702+ DeregisteredOperators :: < T > :: mutate ( operator. current_domain_id , |operators| {
703+ operators. insert ( operator_id)
704+ } ) ;
701705 Ok ( ( ) )
702706 } ,
703707 )
@@ -1131,36 +1135,35 @@ pub(crate) fn do_unlock_nominator<T: Config>(
11311135 let mut deposit = Deposits :: < T > :: take ( operator_id, nominator_id. clone ( ) )
11321136 . ok_or ( Error :: UnknownNominator ) ?;
11331137
1134- // convert any deposits from the previous epoch to shares
1135- match do_convert_previous_epoch_deposits :: < T > (
1138+ // convert any deposits from the previous epoch to shares.
1139+ // share prices will always be present because
1140+ // - if there are any deposits before operator de-registered, we ensure to create a
1141+ // share price for them at the time of epoch transition.
1142+ // - if the operator got rewarded after the being de-registered and due to nomination tax
1143+ // operator self deposits said tax amount, we calculate share price at the time of epoch transition.
1144+ do_convert_previous_epoch_deposits :: < T > (
11361145 operator_id,
11371146 & mut deposit,
11381147 current_domain_epoch_index,
1139- ) {
1140- // Share price may be missing if there is deposit happen in the same epoch as de-register
1141- Ok ( ( ) ) | Err ( Error :: MissingOperatorEpochSharePrice ) => { }
1142- Err ( err) => return Err ( err) ,
1143- }
1148+ ) ?;
11441149
11451150 // if there are any withdrawals from this operator, account for them
11461151 // if the withdrawals has share price noted, then convert them to AI3
1147- // if no share price, then it must be intitated in the epoch before operator de-registered,
1148- // so get the shares as is and include them in the total staked shares.
11491152 let (
11501153 amount_ready_to_withdraw,
11511154 total_storage_fee_withdrawal,
11521155 shares_withdrew_in_current_epoch,
11531156 ) = Withdrawals :: < T > :: take ( operator_id, nominator_id. clone ( ) )
11541157 . map ( |mut withdrawal| {
1155- match do_convert_previous_epoch_withdrawal :: < T > (
1158+ // convert any withdrawals from the previous epoch to stake.
1159+ // share prices will always be present because
1160+ // - if there are any withdrawals before operator de-registered, we ensure to create a
1161+ // share price for them at the time of epoch transition.
1162+ do_convert_previous_epoch_withdrawal :: < T > (
11561163 operator_id,
11571164 & mut withdrawal,
11581165 current_domain_epoch_index,
1159- ) {
1160- // Share price may be missing if there is withdrawal happen in the same epoch as de-register
1161- Ok ( ( ) ) | Err ( Error :: MissingOperatorEpochSharePrice ) => { }
1162- Err ( err) => return Err ( err) ,
1163- }
1166+ ) ?;
11641167 Ok ( (
11651168 withdrawal. total_withdrawal_amount ,
11661169 withdrawal. total_storage_fee_withdrawal ,
0 commit comments