It’s been a while since the first discussions around treasury rebalancing and the opportunity for the DXdao to trade tokens arose. The last few weeks we’ve been working on an integration between DAOstack & Gnosis Protocol that enables the DXdao and potentially any other DAO to facilitate token trades on Gnosis Protocol in a fully trustless way. We’ve just finalised the audit process and I want to shortly provide an overview of the implementation and lay out a roadmap for the first trade.
Why do we need a relayer?
While most of us are used to trade tokens on different AMMs with our personal wallets, a trade from a DAO brings its own challenges that require some specialized design in order to ensure expected trading results. To summarize, the challenges faced by trading tokens as DXdao:
Timing - To ratify a proposal typically takes 8 days & it’s impossible to predict market prices 1 week prior to execution. While we potentially could create (multiple) limit orders, they could quickly become out of sync with a fast moving market.
Transparency - orders are fully transparent, any arbitrageurs or front-running bots will have ample time to plan ahead.
With the relayer we’re using on-chain price oracles that observe prices from AMMs, such as Swapr, Uniswap or any other Uniswap-style AMM, over a given period right after the proposal has been ratified by the DAO and places an order on GP based on the calculated average price from the oracle observations.
Example Trading Walkthrough
Let’s say we decide to trade 500 ETH from the DXdao treasury to DAI, the process would look like this:
A proposal to transfer 500 ETH to the GP Relayer using a regular Funding & Voting Power proposal is being created.
A GP trading proposal is created using the Multicall Scheme on Alchemy. The potential parameters could look like this:
- TokenIn: ETH
- TokenOut: DAI
- TokenInAmount: 500 ETH
- MinAmountOut: 300,000 DAI
- PriceTolerance: 0.5%
- MinReserve: 10,000 ETH
- Deadline: 14 days
- PriceOracle: Uniswap
Note: Separating the token transfer & order creation in two separate proposals is an additional security mechansism we decided to go for now – we’ve prioritised security over UX. We will continue to research about new solutions for Multicall that will allow us to move funds directly.
Right after the proposal has been ratified and executed by the DAO, an on-chain oracle will be established that measures the price on the defined PriceOracle for two times in a span over 120 seconds. The price will only be recorded if the ETH reserve, in our case the ETH/DAI pool on Uniswap is higher than 10,000 ETH.
As soon as the on-chain observation has been finalised a trade on Gnosis Protocol will be placed with 500 ETH in and an amountOut = (averagePrice * expectedToken) - priceTolerance. The price tolerance is a way to add additional slippage tolerance to make sure the trade is executed faster by expecting a certain price movement right after the observation.
Once the trade has been placed & matched on GP, anybody can trigger a transaction to release the DAI from Gnosis Protocol and send them back to the DXdao treasury, there’s no need for an additional proposal.
Additional functionality that we might want to use in specific scenarios:
- If the deadline is reached anybody can withdraw the GP order and send the inputTokens back to the DXdao treasury
- Any ETH or ERC20 token sitting in the relayer can be sent back to the DXdao treasury by using a proposal.
The most recent release can be found here:
The audit & post-audit report can be found here:
There are some technical tasks to be delivered in the coming days, we’ll be working on. Additionally I propose to run a first test trade on Mainnet to confirm everything is working as expected – a trade size around $10k might be reasonable?
|Task||Timeline / Finalisation|
|xDAI deployment (Oracle whitelist: Honeyswap)||Dec 20th|
|Mainnet deployment (Oracle whitelist: Uniswap, Swapr)||Dec 20th|
|Multicall Scheme Deployment||Dec 20th|
|Find consensus on test trade||Dec 25th|
|Security Bot Integration||Dec 25th|
|Multicall Installation Proposal||Jan 7th|
|Execute test trade (2 proposals)||Jan 14th|
|Twitter & blog post to cover first (DX)dao trade?||Jan 14th|
The status can be tracked in the project board: https://github.com/nicoelzer/gnosis-protocol-relayer/projects/2