#substrate #pallet #balance

no-std pallet-asset-rate

Whitelist non-native assets for treasury spending and provide conversion to native balance

15 major breaking releases

new 18.1.0 Mar 27, 2025
17.0.0 Sep 26, 2024
16.0.0 Jul 18, 2024
15.0.0 Jul 12, 2024
0.0.0 Oct 16, 2023

#14 in #balance

Download history 27428/week @ 2024-12-04 23961/week @ 2024-12-11 19342/week @ 2024-12-18 7185/week @ 2024-12-25 19191/week @ 2025-01-01 24394/week @ 2025-01-08 34596/week @ 2025-01-15 30372/week @ 2025-01-22 27285/week @ 2025-01-29 29201/week @ 2025-02-05 40188/week @ 2025-02-12 25880/week @ 2025-02-19 5718/week @ 2025-02-26 4781/week @ 2025-03-05 5499/week @ 2025-03-12 4152/week @ 2025-03-19

21,881 downloads per month
Used in 71 crates (5 directly)

Apache-2.0

3MB
46K SLoC

Release

Polkadot SDK Stable 2412


lib.rs:

Asset Rate Pallet

Overview

The AssetRate pallet provides means of setting conversion rates for some asset to native balance.

The supported dispatchable functions are documented in the Call enum.

Terminology

  • Asset balance: The balance type of an arbitrary asset. The network might only know about the identifier of the asset and nothing more.
  • Native balance: The balance type of the network's native currency.

Goals

The asset-rate system in Substrate is designed to make the following possible:

  • Providing a soft conversion for the balance of supported assets to a default asset class.
  • Updating existing conversion rates.

Interface

Permissioned Functions

  • create: Creates a new asset conversion rate.
  • remove: Removes an existing asset conversion rate.
  • update: Overwrites an existing assert conversion rate.

Please refer to the Call enum and its associated variants for documentation on each function.

Assumptions

  • Conversion rates are only used as estimates, and are not designed to be precise or closely tracking real world values.
  • All conversion rates reflect the ration of some asset to native, e.g. native = asset * rate.

Dependencies

~20–34MB
~583K SLoC