-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: pallet asset-rate #13608
feat: pallet asset-rate #13608
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need create/upgrade/remove? wouldn't an update with Optional param be enough?
That could suffice. IMO though, it should be preferred to have better granularity, especially since adding an asset to this pallet's storage can be considered whitelisting them as payout currencies. Assume the Moreover, in the current design the |
Why the treasury should rely on the oracle pallet to determine an asset is supported? If treasury wants a whitelist, it should implement a whitelist in the treasury. The oracle pallet could be for example used for fee payment, ED amount calculation etc. But if this is the design that this pallet will tightly coupled with treasury, that maybe fine. Is there a design of how all the pallets interact with each other? Another thing is, any reason why this needs to be treasury-oracle pallet instead of just a generic oracle pallet? One thing I don't like on how those issues are approached is that I don't see a high level design. I don't see a detailed spec. There is no way for me (and the community) to review them and provide feedbacks. This is Substrate that the pallets are supposed to be generalized and reusable. Currently I need to read the code to guess what you are trying to achieve and as a result I have a lot of questions. Presumably there are a lot of internal discussion and docs but I don't see them so they don't exist for me. @joepetrowski @bkchr can we improve the process here by requiring someone to write some tech spec of all the new pallets before start coding them? |
@tonyalaribe is writing up a design of how these work together. But the main reason that this is a Treasury-Oracle is that it's really limited to some specific information related to Treasury logic. I would not be opposed to putting this directly in Treasury, in the context that the Treasury logic exists in one place but its assets exist in many. However for a single-asset, single-location Treasury, this would be pointless, so it also makes sense as an extension. |
I shared a potential plan here: paritytech/polkadot-sdk#98 |
@tonyalaribe Please review, thank you! |
I renamed the pallet from An open discussion point is the potential splitting of whitelisting an asset to a separate pallet such that this pallet truly just serves as a convertor without whitelisting implications. IMO such splitting would be unnecessary as I think it's feasible to assume giving an asset a conversion to native balance relates to whitelisting is as payout currency. In the end, that logic is dependent on the final design of the Multi-Asset Treasury and out of scope of this PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this to together @wischli. Other than the updates to documentation and how the pallet is portrayed, everything else looks great to me.
bot rebase |
Rebased |
bot merge |
* poc * fix: remove AssetIdParameter * tests: add * docs: add pallet description * feat: add benches * refactor: UnknownAssetId * fix: normalize mock cfg * fix: benchmarks * chore: add weights * refactor: remove storage getter * chore: apply suggestions from code review * docs: add native balance to calls * chore: apply suggestions from code review * chore: apply ConversionFromAssetBalance * tests: update balance mock * chore: apply suggestions from code review * ci: set publish to false * docs: fix missing rustdoc --------- Co-authored-by: parity-processbot <>
Description
Adds a simple
oracleasset-rate
pallet which provides means of setting conversion rates for assets to native. These conversion rates are planned to be used to Treasury. Please note that these conversion rates should not be used for the actual payment but just to determine the{Small, Medium, Big} Spender
status/track for users which desire to be paid in anything but the native currency. Moreover, it could also be used to softly assert aSpendingPeriods
budget has not been exceeded, if that will eventually be necessary for a Multi Asset Treasury.CUD is enabled via three (potentially) separate origins. The
UpdateOrigin
could be a DEX which sends an update everyN
blocks. It was discussed whether{Create, Remove}Origin
s could be merged. However, I believe we should provide the most flexible granularity and keep all three origins. Consider separate Gov2 track thresholds for adding and removing an asset rate as one argument. In the end, even ifCreateOrigin
andRemoveOrigin
are exactly the same, it's one more line of configuration in the particular runtime.How is this pallet supposed to be used?
This pallet provides an implementation of
ConversionFromAssetBalance
which can be plugged into the more generic treasury pallet as an associated type. This enables mappingX
amount of balance for an asset toY
amount of native balance. The creation of treasury proposals in Gov2 will always happen on the governance chain (e.g. relay for now, common good in the future). Since such chain does not need to understand multi assets, there needs to be a mechanism to map such balances to the native balance.TODO
BalanceConversion
, e.g.