I want to make a stable coin on substrate based chain, what I want to know is that can I do it with the assets pallet
, as I can't find any function that peg it with any other collateral, if it is possible can someone point me towards the right documentation. Or is it only possible through ink smart contract
, it would be really helpful, if someone has already done this and can share their contract with me.
-
2You can start with having a look to aUSD stable coin on Acala parachain.– IkerJul 12, 2022 at 7:39
-
@Iker thanks for the link but i don't want to add stable coin in my blockchain code as done in acala for now, is there a way to that via smart contract or assets pallet.– Shubham GuptaJul 12, 2022 at 9:49
-
2This is definitely not a trivial question, I would suggest that you take some time to check how different projects have been implementing their peg system. There are a lot of meat under the hood of such a project.– Alejandro MartínezJul 12, 2022 at 10:01
1 Answer
This is no trivial undertaking. A good resource to learn about the different types of stable coins is https://101blockchains.com/types-of-stablecoins.
For crypto-backed stablecoins and algorithmic stablecoins you can easily find open source implementations and whitepapers. For those systems it's especially important that their development happens out in the open, for anybody to find issues with. Otherwise you might end up going live with a system that hasn't been peer reviewed beforehand and issues might be exploited immediately.
For crypto-backed stablecoins there is e.g. MakerDAO's Multi Collateral DAI implementation in Solidity. You can find the paper on it here and the repository points to some documentation as well.
You will see that this is a complex system though, requiring much more than the what-might-seem core logic of pegging to another currency (e.g. a governance system for upgrading the system is required as well).
In Polkadot, Acala is a stablecoin for which you can find their whitepaper here and an implementation in Rust here.
At the moment there is no ink! stablecoin implementation that I am aware of. If you're serious about this undertaking (be it just as an exercise to learn more about how stablecoins work) the best starting points would be to either
- …understand how Acala works and try to port that code to ink!. Since the Acala implementation is already in Rust this will easen the work or
- …port a MakerDAO implementation to ink!. You could e.g. restrict yourself to SAI, which has a simpler implementation than MCD.