Context: I'm creating a pallet with a simple DEX (decentralised exchange) functionality. I need to perform some arithmetic operations on balances for liquidity pools.

Problem: How can I convert from asset balance to currency balance? I am aware of the BalanceConversion trait and its BalanceToAssetBalance impelementation, but it only converts the other way (which also need, btw). Could an asset balance -> currency balance conversion be implemented in a similar way without modifying the assets pallet?

1 Answer 1


It turned out I didn't actually need this kind of conversion which BalanceToAssetBalance offers. It's based on the ratio between the fungible’s minimum balance and the minimum asset balance, which was not relevant in my use case. So I ended up simply using the Convert trait (which, btw is required by BalanceToAssetBalance). Here's how I implemented it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.