@@ -298,6 +298,11 @@ pub mod pallet {
298298 from : AssetAmount < T :: AssetId > ,
299299 to : AssetAmount < T :: AssetId > ,
300300 } ,
301+ /// A pending asset could not be converted; skipped, not blocking.
302+ ConversionFailed {
303+ asset_id : T :: AssetId ,
304+ reason : DispatchError ,
305+ } ,
301306 /// Rewards claimed.
302307 Claimed {
303308 who : T :: AccountId ,
@@ -482,20 +487,18 @@ pub mod pallet {
482487 let who = ensure_signed ( origin) ?;
483488 for ( asset_id, _) in PendingConversions :: < T > :: iter ( ) {
484489 let asset_balance = T :: Currency :: balance ( asset_id. clone ( ) , & Self :: pot_account_id ( ) ) ;
485- let r = T :: Convert :: convert (
490+ // Best-effort, like `on_idle`: skip an un-convertible slice rather than revert the
491+ // whole claim. Funds stay in the pot and re-queue on the next fee.
492+ if let Err ( reason) = T :: Convert :: convert (
486493 Self :: pot_account_id ( ) ,
487494 asset_id. clone ( ) ,
488495 T :: RewardAsset :: get ( ) ,
489496 asset_balance,
490- ) ;
491- if let Err ( error) = r {
492- // We allow these errors to continue claiming as the current amount of asset that needed to be converted
493- // has very low impact on the rewards.
494- if error != Error :: < T > :: ConversionMinTradingAmountNotReached . into ( )
495- && error != Error :: < T > :: ConversionZeroAmountReceived . into ( )
496- {
497- return Err ( error) ;
498- }
497+ ) {
498+ Self :: deposit_event ( Event :: ConversionFailed {
499+ asset_id : asset_id. clone ( ) ,
500+ reason,
501+ } ) ;
499502 }
500503 PendingConversions :: < T > :: remove ( asset_id) ;
501504 }
@@ -623,12 +626,17 @@ pub mod pallet {
623626 for asset_id in PendingConversions :: < T > :: iter_keys ( ) . take ( max_converts as usize ) {
624627 let asset_balance = T :: Currency :: balance ( asset_id. clone ( ) , & Self :: pot_account_id ( ) ) ;
625628 // remove the asset_id from PendingConversions even when the conversion fails
626- let _ = T :: Convert :: convert (
629+ if let Err ( reason ) = T :: Convert :: convert (
627630 Self :: pot_account_id ( ) ,
628631 asset_id. clone ( ) ,
629632 T :: RewardAsset :: get ( ) ,
630633 asset_balance,
631- ) ;
634+ ) {
635+ Self :: deposit_event ( Event :: ConversionFailed {
636+ asset_id : asset_id. clone ( ) ,
637+ reason,
638+ } ) ;
639+ }
632640 PendingConversions :: < T > :: remove ( asset_id) ;
633641 actual_converts += 1 ;
634642 }
0 commit comments