The BootNode team has requested a grant of 16,800 USDC and 2,300 wNXM to build an alternative/replacement for the current ETH / Token swap mechanism currently used in Nexus Mutual that will enable swapping arbitrary ERC20 pairs using Gnosis Protocol (CowSwap) to avoid sandwich attacks and other forms of MEV.
The estimated timeline for this project would be 7 weeks of development and testing, with a gap period during the audit of the smart contracts.
The grant would be paid in two instalments:
- 8,400 USDC as soon as the proposal is approved
- 8,400 USDC and 2,300 wNXM once the code is delivered for review
Motivation
- If the protocol needs to make a relatively large claim payment/s in DAI then material amounts of ETH need to be swapped for DAI, at the moment the protocol would conduct this via Uniswap V2 only which doesn’t make use of the wider DEX liquidity.
- If the protocol wishes to swap assets for investments purposes, e.g. to sell stETH, then the same issues arise with the main difference being the time-sensitivity is likely much less than obtaining funds for claim payments.
- Existing asset swaps are quite highly exposed to MEV, in particular, sandwich attacks.
Project Description
The new implementation maintains the same security guarantees from the current design:
- transactions can only be initiated from whitelisted accounts,
- trades are only allowed in the correct price range using an onchain twap oracle,
- and within certain thresholds previously established through governance.
The new solution could co-exist with the current Uniswap implementation, incrementing the total liquidity that is available for swaps.
Scope assumptions and constraints:
- To reduce risk and scope, no changes will be made to the oracles that are currently in use by Nexus, this means the new implementation will not support new assets. The smart contract changes will focus on the CowSwapOperator and the required changes on the Pool contract to make it work.
- To facilitate and make possible the correct accounting of assets, token allowances, and flow of assets between the pool and the swap operator contract, this implementation will support 1 swap operation at a time. This swap operation could be canceled and replaced by new ones if desired.
- Both full and partial orders will be supported.
- The implementation will target version 2 of Nexus smart contracts and will not be ported back to v1.
Members can review the full text of the proposal on the forum: https://forum.nexusmutual.io/t/proposal-mev-protected-swaps/781