Skip to content

pallet-treasury: Asset Category#10381

Closed
Doordashcon wants to merge 23 commits into
paritytech:masterfrom
Doordashcon:TPS
Closed

pallet-treasury: Asset Category#10381
Doordashcon wants to merge 23 commits into
paritytech:masterfrom
Doordashcon:TPS

Conversation

@Doordashcon

@Doordashcon Doordashcon commented Nov 21, 2025

Copy link
Copy Markdown
Contributor

resolves #7961

Indroduction

This PR enables the treasury request payment from a category of assets (i.e. USD* stablecoins) instead of just a specific asset_kind, distributing the amount across available assets within that category on payout. Extending SpendAsset to support category based requests, configuring PaymentState to handle multiple payment executions on payout, introducing AssetCategoryManager for defining category membership and performing balance checks and maintaining backward compatibility for single asset spend requests and payout.

TODO

  • Runtime implementation of AssetCategoryManager
  • Payment optimization strategies(i.e. percentage payouts across available assets)
  • Documentation
  • Migration
  • XCM?

@Doordashcon
Doordashcon marked this pull request as ready for review January 26, 2026 09:08
@Doordashcon
Doordashcon requested a review from a team as a code owner January 26, 2026 09:08
@dhirajs0 dhirajs0 added the T1-FRAME This PR/Issue is related to core FRAME, the framework. label Mar 24, 2026
@dhirajs0

Copy link
Copy Markdown
Contributor

/fmt

@dhirajs0 dhirajs0 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I have left some comments.

Comment on lines +496 to +515

LowBalance,

EmptyAssetCategory,

InvalidPaymentState,

ExecutionRateLimit,

TooManyFailedPayments,

AssetNotFound,

ConversionFailed,

ArithmeticOverflow,

ConversionRateMismatch,

InvalidConversionRate,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add doc comments to each error variant

}
}

Err(Error::<T, I>::LowBalance.into())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the balance check at creation time is overly restrictive and contradicts the partial payment design.

Comment on lines +178 to +190
pub enum PaymentState<AssetKind, Balance, Id> {
/// Pending claim.
Pending,
/// Payment attempted with a payment identifier.
Attempted { id: Id },
/// Payment failed.
Failed,
/// Payment attempted with payment identifiers for each payment execution
Attempted {
executions: BoundedVec<PaymentExecution<AssetKind, Balance, Id>, ConstU32<32>>,
remaining_amount: Balance,
},
/// Record of all failed payments to retry
Failed(BoundedVec<PaymentExecution<AssetKind, Balance, Id>, ConstU32<32>>),
/// Attempt incomplete payment balance from spend
Partial(Balance),
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is breaking storage change and require migration.

Failed,
/// Payment attempted with payment identifiers for each payment execution
Attempted {
executions: BoundedVec<PaymentExecution<AssetKind, Balance, Id>, ConstU32<32>>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConstU32<32> please make the limit configurable, so runtimes should be able to choose them.

Comment on lines +495 to +496
BoundedVec<u8, ConstU32<32>>, // Category name
BoundedVec<T::AssetId, ConstU32<32>>, // Assets in this category

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic numbers: I thing it would be good to make them configurable

}

#[test]
fn category_payout_partial_fulfillment() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical with fn category_payout_distributes_across_assets()


let diff_percent = multiplied_diff.checked_div(max).unwrap_or(0);

if diff_percent > 5 {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic number: making it configurable would be better.

@dhirajs0
dhirajs0 requested a review from muharem March 24, 2026 12:25
@muharem

muharem commented Mar 31, 2026

Copy link
Copy Markdown
Contributor

@Doordashcon are you planing to continue the work on this? we can provide more support. can you please open a separate PR for the ordered payouts.

@Doordashcon

Doordashcon commented Mar 31, 2026

Copy link
Copy Markdown
Contributor Author

Yes!

@muharem In the process of deprecating this GitHub account after all currently open PRs have been handled, I will push ordered payouts using @jessechejieh. Thanks

@Doordashcon Doordashcon changed the title Improve Treasury Payout of Stables pallet-treasury: Asset Category Apr 9, 2026
@Doordashcon

Copy link
Copy Markdown
Contributor Author

Closing in favor of #12687

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T1-FRAME This PR/Issue is related to core FRAME, the framework.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve Treasury payout of stables

5 participants