Polkassembly Logo

Create Pencil IconCreate
Chat with KlaraComing Soon
OpenGov
View All Discussion

Treasury Proposal by Centrifuge: On-Chain Automated Treasury Management (with TWAMM)

usermustermeiszer
2 years ago

Proponent: 12wWLUd5qMzLFGqBsMnHLVFeTuYJwuo5ygMAxuSywrBX1XSF

Date: 2023.03.30

Requested DOT: $495,000 ~ TBD DOT

Contact: William Freudenberger (william@k-f.co)


The ongoing discussion about automated market makers (AMMs) in the Statemint roadmap is mainly focused on improving the user and custodian experience by allowing small atomic swaps natively and making Statemint a central hub for asset deposits. This addresses important pain points by enabling transaction fees to be paid in non-native tokens and facilitating interaction with the entire asset variety of the ecosystem without requiring to run custom nodes or infrastructure.

However, we believe that one aspect has been overlooked: the slow swaps of large volumes, which can be easily front-run or sandwiched. This is particularly relevant in the context of trades proposed through governance for use cases such as

  1. Paying out treasury grants, bounties or even salaries in less volatile currencies (ie. stablecoins).
  2. Enabling parachains to build a DOT reserve which can be used to acquire a parachain lease, pay XCM fees, or increase availability cores during times of high demand (once supported).
  3. Governance deciding to invest part of the treasury into a token to diversify their treasury

What we need is the opposite of what a traditional AMM provides: atomic swaps with immediate execution, even in relatively illiquid assets. A governance vote is unable to time the market and is highly predictable. Therefore, executing such a transaction as a market order on an AMM is problematic, as it will be guaranteed to be front-run. A better solution is to "dollar-cost-average" over a long period of time making it harder for price manipulation to affect the purchase.

At Centrifuge, we have researched distinct approaches of how to achieve hard-to-front-run slower transactions. In our opinion, the most elegant solution is TWAMM (Time Weighted Automated Market Maker. We are of the firm conviction that the implementation of this model represents the most efficacious approach for executing token swaps in the context of slower and passive procedures, such as governance.

TWAMM (Time Weighted Automated Market Maker) eliminates front-running vulnerabilities of traditional AMMs when executing large orders, especially in the context of passive procedures, such as governance. The proposed solution will be executed as a seamless extension to pallet-asset-conversion, thereby enhancing its capabilities as an embedded AMM.

The deliverables of the proposal contain the TWAMM-pallet, associated runtime APIs, associated research for further optimizing and extending the pallet, a security audit of the pallet and a frontend.

The full proposal can be found here.

Comments (2)

2 years ago

$150/hr for frontend developer? What seriously? Where are these geniuses coming from that charge this exorbitant amount? $200/hr for substrate developers. Centrifuge team exploiting the treasury just because of the existing reputation?

2 years ago

Hello Team,

Thank you for submitting this proposal for review/discussion by the Community.
A few comments:

What we need is the opposite of what a traditional AMM provides: atomic swaps with immediate execution, even in relatively illiquid assets. A governance vote is unable to time the market and is highly predictable. Therefore, executing such a transaction as a market order on an AMM is problematic, as it will be guaranteed to be front-run. A better solution is to “dollar-cost-average” over a long period of time making it harder for price manipulation to affect the purchase.

Q: Can you please clarify whether you are seeking to provide a completely different alternative to the proposed Statemine/t DEX or adding extra functionalities for this future DEX?

This innovative solution offers an elegant means of executing large orders even in relatively illiquid markets. It is particularly well-suited for slow automated processes, such as governance-controlled treasury operations, that can effectively implement a dollar-cost averaging strategy over extended periods.

Q: Will this solution be available for integration by other existing parachain/DEXes? If so, how will you spread the word about your solution within the Polkadot ecosystem to expand the reach of your TWAMM?

Technically, the goal would be to make this work for a single Substrate chain that includes the asset-conversion and twamm pallets. Ideally we can make this work using XCM for retrieving asset data, but alternatively we look to making this work directly on orml-tokens and/or assets. If possible, this would use the same design system as the Staking Dashboard.

Q: Which timelines are you looking at for the completion of the milestones in this proposal, given that the Common-good DEX is not deployed yet?

Milestone 3 - Security Audit Security audit from SR Labs Budget: 120,000$

Q: The PAL bounty has been proposed by a collective of parachain teams to finance part of the audits conducted on Polkadot ecosystem protocols. Would you consider applying for this bounty to cover the cost of your audit when the time comes for your solution to be audited?

The grant is proposed to the Polkadot Treasury and as such, if granted, will be paid in DOT.
At the time of writing the total grant amount of $494,500 results in a total grant amount of 80,999 DOT, based on EMA7 March 30th, 2023 (source: Subscan).

S: Please consider breaking down the above budgeted milestones into separate Treasury proposals with their own costs and reporting requirements, so that the community can have the opportunity to track and review the proposal's progress in the medium term.

2 years ago

Hi Anaelle,

Thank you for your questions regarding our treasury proposal. We have been in close contact with Parity regarding the development of TWAMM and have received positive feedback so far. Our recent collaboration on the development of a Multi Asset Treasury (e.g. Substrate #13602, Substrate #13608) has highlighted the necessity of having a non-attackable long-term tokenswap mechanism like TWAMM (e.g. see the draft for Multi Asset Treasury).

Q: Can you please clarify whether you are seeking to provide a completely different alternative to the proposed Statemine/t DEX or adding extra functionalities for this future DEX?

As outlined in the proposal deliverable breakdown,, we are not planning to build an alternative DEX. Instead, TWAMM will be a feature on top of the Statemine/t DEX, whose logic was renamed to pallet-asset-conversion (Substrate PR #12984) as a result of discussions on the Polkadot forum. While pallet-asset-conversion will remain independent of our TWAMM pallets, TWAMM expects an embedded AMM interface via the pallet's Config trait, which will be based on pallet-asset-conversion, making it easy for any chain implementing pallet-asset-conversion to add TWAMM to their runtime with minimal overhead.

Q: Will this solution be available for integration by other existing parachain/DEXes? If so, how will you spread the word about your solution within the Polkadot ecosystem to expand the reach of your TWAMM?

In addition to the simple integration statement above, parachains will also have the option to plug in their custom DEX as the embedded AMM of TWAMM instead of pallet-asset-conversion.

We hope to discuss this further in the next iteration of Polkadot Decoded or Sub0, and we also plan to showcase it in Substrate Seminar. Furthermore, we will share this information with the parachain teams we have regular conversations with and meet in upcoming ecosystem events, as we believe it would be valuable for the community.

Q: Which timelines are you looking at for the completion of the milestones in this proposal, given that the Common-good DEX is not deployed yet?

Although our design is somewhat dependent on pallet-asset-conversion, we can still develop TWAMM before pallet-asset-conversion is completed, as we can base it on an abstract interface for the embedded AMM. In the event that breaking changes are introduced to pallet-asset-conversion API, we will need to apply those changes to our embedded AMM interface as well. However, we do not anticipate any issues in this regard, as to our knowledge, pallet-asset-conversion is already undergoing audits by SRLabs.

We are planning to start the development in Q2 and complete it by the beginning of Q4 2023.

Q: The PAL bounty has been proposed by a collective of parachain teams to finance part of the audits conducted on Polkadot ecosystem protocols. Would you consider applying for this bounty to cover the cost of your audit when the time comes for your solution to be audited?

To our knowledge, the PAL is intended for general parachain audits and may not cover specific shared functionality audits like TWAMM. Moreover, k-factory (the core team building Centrifuge) has already discussed a pre-commitment with SRLabs, which gives us certainty over the timeline of the audit process.

S: Please consider breaking down the above budgeted milestones into separate Treasury proposals with their own costs and reporting requirements, so that the community can have the opportunity to track and review the proposal's progress in the medium term.

We appreciate your input and your desire to track and review our proposal's progress. We understand that breaking down the budgeted milestones into separate Treasury proposals with their own costs and reporting requirements can provide more transparency to the community. However, we would like to highlight that this approach may add additional overhead and administrative burden on our team, potentially affecting our ability to focus on delivering the actual project outcomes.

We also want to assure you that Centrifuge has a proven track record of delivering on previous grant proposals in the past. We are committed to transparency and accountability, and we will continue to provide regular updates on our progress throughout the medium term. We value your support and feedback, and we will take your suggestion into consideration while ensuring that we can effectively execute our proposal and deliver the intended outcomes. Thank you for your understanding.

PleaseLogin to comment

Help Center

Report an Issue
Feedback
Terms and Conditions
Github

Our Services

Docs
Terms of Website
Privacy Policy

A House of Commons Initiative.

Polka Labs Private Limited 2025

All rights reserved.

Terms and ConditionsTerms of Website
Privacy Policy