#assets #conversion #balance #native #substrate #pallet #rate

no-std pallet-asset-rate

Whitelist non-native assets for treasury spending and provide conversion to native balance (polkadot v1.10.0)

8 major breaking releases

11.0.0 Apr 8, 2024
10.0.0 Mar 18, 2024
9.0.0 Feb 26, 2024
8.0.0 Feb 13, 2024
0.0.0 Oct 16, 2023

#413 in Magic Beans

Download history 736/week @ 2024-01-02 820/week @ 2024-01-09 355/week @ 2024-01-16 484/week @ 2024-01-23 355/week @ 2024-01-30 353/week @ 2024-02-06 893/week @ 2024-02-13 1231/week @ 2024-02-20 969/week @ 2024-02-27 520/week @ 2024-03-05 692/week @ 2024-03-12 1097/week @ 2024-03-19 930/week @ 2024-03-26 882/week @ 2024-04-02 887/week @ 2024-04-09 732/week @ 2024-04-16

3,694 downloads per month
Used in 50 crates (4 directly)

Apache-2.0

2MB
42K SLoC

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

~17–32MB
~535K SLoC