This document proposes one specific solution to provide support for tokens with arbitrary fractional decimal places within the Zeitgeist protocol. Before continuing reading this propoal, having a look at the [research document](https://hackmd.io/@lZVVinJVS6WI4IpRgmbsLA/SydXnflKh) is recommended. # Selected solution The solution to [adjust the fixed point math functionality](https://hackmd.io/mP5QzxVzSDmPZdXiFjTuNw?both#Solution-1-Update-fixed-point-math) to be capable to handle all constellations of fractional decimal places in arithmetic operations has the benefit that it provides the most accurate results in any case if done properly, however the effort involved with implementing that especially in regards to ensuring that no security flaws have been added is not neglectable. Changing the very core of the protocol, the arithmetic foundation, should only be done when absolutely mandatory as introduced bugs have a major impact on many levels of the protocol. An external audit in that case is highly recommended. In addition to that, the effort caused to consumers of the protocol to handle all the different fractional places is an ongoing cost that just increases over the course of time. On the other hand, the solution that [enforces a fixed number of fractional decimal places](https://hackmd.io/mP5QzxVzSDmPZdXiFjTuNw?both#Solution-2-Align-fractional-decimal-places) for any token comes with the benefit that it only requires adjustment when the tokens enter or leave the chain. All the other existing functionality is not touched by that and the protocol can continue to operate as it is. As the effects of the change do not affect other parts of the protocol, the danger to introduce new security issues and the effort to adjust existing code are comparatively low. Consumers of the protocol can simply assume one single representation for any token and utilize a fixed implementation for any token, thus keeping the entrance barrier to handle different tokens comparateively low. One drawback of this solution is that it results in lost tokens when tokens that have more decimal fractional places as the native token enter the chain. However, as the [research document](https://hackmd.io/mP5QzxVzSDmPZdXiFjTuNw?both#Evaluation) shows, the lost tokens can be considered as dust as the real value is so low that it is practically irrelevant. Given the reduced implementation effort, reduced likeihood to introduce new bugs and the convenience for consumers to interact with the protocol in regards to different tokens, the solution that enforces a fixed number of fractional decimal places is preferred. # Conceptual overview During XCM reserve asset transfers the [`AssetTransactor` type within the XCM configuration](https://github.com/zeitgeistpm/zeitgeist/blob/00262ca7e8e6f6c6f5f55e8924dcf2abda66a34c/runtime/zeitgeist/src/xcm_config/config.rs#L65-L66) deals with deposits and withdrawals. The `AssetTransactor` is configured to use a specific instance of the [`MultiCurrencyAdapter` provided by ORML](https://github.com/open-web3-stack/open-runtime-module-library/blob/28a2e6f0df9540d91db4018c7ecebb8bfc217a2a/xcm-support/src/currency_adapter.rs#L105-L125). To align the fractional decimal places, it is necessary to implement a wrapper around `MultiCurrencyAdapter` that executes the alignment before calling the [implementation provided by ORML](https://github.com/open-web3-stack/open-runtime-module-library/blob/28a2e6f0df9540d91db4018c7ecebb8bfc217a2a/xcm-support/src/currency_adapter.rs#L127-L202). In addition to that, a migration must ensure that all existing foreign token balances are aligned to the common base. As Zeitgeist currently only uses foreign assets that have the same base as the native token ZTG, no migration is necessary.