[BIP-875] Implement EZKL Dynamic Fee Control for Balancer Pools

PR with Payload

Summary

Over the past 3 months the EZKL team has led an effort to implement dynamic pool fees that are adjusted according to a machine learning strategy to optimize fee revenue. After many iterations, the Balancer and EZKL team are confident that the current dynamic fee model results in 10-30% greater performance than reference pools of a typical static swap fee, resulting in more fees earned, better welfare for LP’s, and more protocol revenue.

Unlike many dynamic fee implementations, this model uses off-chain bots to periodically update the fee on the pool. These bots are themselves run in a zk-circuit, with a corresponding on-chain verifier such that their underlying logic and algorithm cannot be swapped out or maliciously tampered with. The bots can ingest both offchain and on-chain data. Off-chain data is attested to using a TEE network to mitigate the risk of data manipulation. In short, this means both the methodology and data are enforced through verifiable cryptographic means.

This proposal seeks to give EZKL permission for fee control through our newly developed Fee Helper contract which allows us to easily reconfigure fee control roles without needing to go through governance.


Listed below are some of the pools that were tested in production

Base WETH/USDC weighted pool

EZKL: https://balancer.fi/pools/base/v3/0x2c5800ba1fb2a2958c01739731788269ed9548f8

Fees 30d: $273.54

0.3% Static reference: https://balancer.fi/pools/base/v3/0x984f78ad333a474b2c54aa5bd393a565de2a027d

Fees 30d: $183.42

Difference: 49%

Mainnet AAVE/WETH ECLP

EZKL: https://balancer.fi/pools/ethereum/v3/0x12216142f02663d7a3f3016ac4bbbaa1d0b05db8

Fees 30d: $54.26

0.3% Reference: https://balancer.fi/pools/ethereum/v3/0x9c9859af553cf953fd016d47c51d798487dafc7d

Fees 30d: $47.77

Difference: 13.5%

Base AAVE/WETH Weighted

EZKL: https://balancer.fi/pools/base/v3/0xae0443a7e934c97cd5838935f519ac8090243030

Fees 30d: $12.65

0.3% Static reference: https://balancer.fi/pools/base/v3/0xe03fd3e33a88fbf26808522fffaa3b17bdf599dd

Fees 30d: $11.93

Difference: 6%

In return for providing this dynamic fee control, EZKL will receive 5% of the protocol fees derived from the pools of which they control fees for. This will be set up through a redirect during the periodic fee collection process run by the maxis. Initially this will only be for the mainnet AAVE/wstETH mainnet pool, but newly deployed pools may be included. The EZKL multisig to which this fee cut will be delivered to is:

0xB7aadD330A64088A85e500874DCDcFB7F253fEB4

It is virtually impossible to absolutely measure increased performance without a direct reference pool, so we will begin with a 3 month test period for this initiative and attempt to collect and analyze data to our best ability. If data looks promising, we will consider expanding to more volatile token pairs.

The Maxi Omni Multisig 0x9ff471F9f98F42E5151C7855fD1b5aa906b1AF7e will be the manager for the fee helper contract.

Risks:

The worst case scenario is a pool with an improperly set pool fee. In our months of testing thus far we have not seen any outlier scenarios (i.e. pool fee set to a miniscule amount or such a high fee it bricks trades) but we have active monitoring to step in and correct if anything should occur. We also can easily suspend fee control at any time through the fee helper contract.

Specifications:

Governance will grant the roles for:

Mainnet:

The following roles will be granted to the v2 fee helper contract at 0x8A8B9f35765899B3a0291700141470D79EA2eA88


“setSwapFeePercentage(uint256)”: “0x78e9adfe5f05d7114a59d0870d78971192f871f57bb36e2aff2edbe75d425844” [v2 weighted pool v2]
“setSwapFeePercentage(uint256)”: “0xd8638fc873fb8c5c0e67c437099a19eb0546fb439dab8babff44196f11d44831” [v2 weighted pool v3]
“setSwapFeePercentage(uint256)”: “0xa5547190e3d59f2bfeb4174ca3454b2f2acaeed644bc7ad7018014516f73f2bd” [v2 weighted pool v4]

The following roles will be granted to the v3 fee helper contract at 0xc00fF743B73346c9a4C40509e0550FfC18e5426d


“setStaticSwapFeePercentage(address,uint256)”: “0x535f82655cb6a856d1452d97dc8e7b3393044c974f85cfcdd2c1d304c08ce34c” [v3 swap fees]

Base

The following roles will be granted to the v2 fee helper contract at 0xd22eecBB495380Ef52b1CCeF1cA594979885D484

“setSwapFeePercentage(uint256)”: “0x82082fa8e750c32535c8828ada82d6f47fd7ec82740773fc3bb3f7eb88a11717” [v2 weighted pool v4]

The following roles will be granted to the v3 fee helper contract at 0xFc00536A0fd292c284deeF6af8F644d8373d9cad

“setStaticSwapFeePercentage(address,uint256)”: “0x535f82655cb6a856d1452d97dc8e7b3393044c974f85cfcdd2c1d304c08ce34c” [v3 setSwapFee]

The Maxi Omni multisig will call to the EZKL fee controller at 0xB7aadD330A64088A85e500874DCDcFB7F253fEB4 on the deployed fee helper at 0x8A8B9f35765899B3a0291700141470D79EA2eA88 using the following parameters

initialManager: 0xB7aadD330A64088A85e500874DCDcFB7F253fEB4

newPools: [0x3de27EFa2F1AA663Ae5D458857e731c129069F29]

In case of the maxis findings something wrong, they can immediately call destroyPoolSet on the fee controller.

5 Likes

Hey all, Dante from EZKL here.

We’re developing a stack for ZK-Machine Learning: https://github.com/zkonduit/ezkl, which makes it easy for anyone to turn a statistical or machine learning model into an equivalent ZK-circuit. The library has been audited and battle-tested in production across many settings.

We’ve long held the thesis that our stack could be immensely impactful in DeFi: https://blog.ezkl.xyz/post/defi3dot0/. Many quantitative and statistical models are simply too complex to implement directly in smart contracts. By deploying them as ZK circuits, you can prove their execution off-chain and then verify that execution in a smart contract, essentially extending the trusted bounds of the EVM.

Balancer, as one of the more forward-looking and fast-moving ecosystems, has been the first to embrace this approach, and the results have been impressive. We’re really grateful for the trust and faith the team has placed in us.

We also want to thank the QuantAMM team, well known in these circles, for their help developing the models that underpin these dynamic fee updates. They’re an exceptional quantitative team, and it’s been great working with them on this.

3 Likes

Edit by Maxis:

  • Assign BIP ID
  • add payload
1 Like

Thanks for pushing this!

Just one comment to complement the first post from a technical standpoint. The fee helpers come pre-wired with the maxi omni multisig as the owner. The owner of the contract can create allowlists with an initial manager. For this application, allowlists with EZKL-managed pools will be created with a manager that belongs to EZKL. This manager account can then set the swap fee percentage only in the allowlisted set of pools.

EZKL can then appoint a new manager on their own, which has the same rights. The maxi omni can always add and remove pools from the allowlist, delete the allowlist, and create new allowlists (potentially for other partners that require this feature).

Last but not least, the contract is pre-wired to spare governance permissions during setup, but governance can always remove maxi omni as the owner of the contract via a permissioned function call (that is not callable by the contract owner of course, giving governance full control over it).

2 Likes

https://snapshot.box/#/s:balancer.eth/proposal/0x45c9b459504d3d21b0128a7286ca848a855af99805c9866897483c7a959f9b1a

1 Like