@@ -9,7 +9,7 @@ use frame_support::{
9
9
pallet_prelude:: DispatchResult ,
10
10
traits:: {
11
11
Currency , EnsureOrigin , ExistenceRequirement , ExistenceRequirement :: KeepAlive , Get ,
12
- LockableCurrency , WithdrawReasons ,
12
+ LockableCurrency , OnUnbalanced , WithdrawReasons ,
13
13
} ,
14
14
transactional,
15
15
weights:: Pays ,
@@ -51,7 +51,7 @@ pub mod pallet {
51
51
use frame_support:: {
52
52
dispatch:: DispatchResultWithPostInfo ,
53
53
log,
54
- traits:: { Currency , Get , LockIdentifier , LockableCurrency } ,
54
+ traits:: { Currency , Get , LockIdentifier , LockableCurrency , OnUnbalanced } ,
55
55
} ;
56
56
use frame_system:: pallet_prelude:: * ;
57
57
use sp_core:: H256 ;
@@ -64,6 +64,8 @@ pub mod pallet {
64
64
65
65
pub type BalanceOf < T > =
66
66
<<T as Config >:: Currency as Currency < <T as system:: Config >:: AccountId > >:: Balance ;
67
+ pub type NegativeImbalanceOf < T > =
68
+ <<T as Config >:: Currency as Currency < <T as system:: Config >:: AccountId > >:: NegativeImbalance ;
67
69
68
70
pub const GRID_LOCK_ID : LockIdentifier = * b"gridlock" ;
69
71
@@ -165,6 +167,8 @@ pub mod pallet {
165
167
{
166
168
type Event : From < Event < Self > > + IsType < <Self as frame_system:: Config >:: Event > ;
167
169
type Currency : LockableCurrency < Self :: AccountId > ;
170
+ /// Handler for the unbalanced decrement when slashing (burning collateral)
171
+ type Burn : OnUnbalanced < NegativeImbalanceOf < Self > > ;
168
172
type StakingPoolAccount : Get < Self :: AccountId > ;
169
173
type BillingFrequency : Get < u64 > ;
170
174
type DistributionFrequency : Get < u16 > ;
@@ -1297,11 +1301,18 @@ impl<T: Config> Pallet<T> {
1297
1301
- existential_deposit_requirement;
1298
1302
}
1299
1303
1300
- <T as Config >:: Currency :: slash ( & twin. account_id , amount_to_burn) ;
1304
+ let to_burn = T :: Currency :: withdraw (
1305
+ & twin. account_id ,
1306
+ amount_to_burn,
1307
+ WithdrawReasons :: FEE ,
1308
+ ExistenceRequirement :: KeepAlive ,
1309
+ ) ?;
1310
+ T :: Burn :: on_unbalanced ( to_burn) ;
1301
1311
Self :: deposit_event ( Event :: TokensBurned {
1302
1312
contract_id : contract. contract_id ,
1303
1313
amount : amount_to_burn,
1304
1314
} ) ;
1315
+
1305
1316
Ok ( ( ) . into ( ) )
1306
1317
}
1307
1318
0 commit comments