-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add mean bridge #320
base: master
Are you sure you want to change the base?
Conversation
Hi, I have added a couple of comments and questions to different parts of the PR. Legend: [i] = info (used for comment or lower severity issues), [?] = question, [!] = issue (loss of user funds).
Let me know if you have any questions 😄 |
@LHerskind wow! That was a really fast review! I'll try to go one by one Specs
Let me get back to you on that. I was under the impression that when a user initiated the withdraw, then it would do so for all the users on the batch
Well, that's a really good question. Just so that I understand it correctly, can the gas limit be updated at a later stage?
Done! Tests
Let me know if the changes are ok or if I can change something else
Nice, didn't know that existed (first time with Foundry). Done! Code
Wow, good catch! Fixed it 😄
Glad you liked it 😄
Done!
Done!
Decided to go with an
Not sure what you mean with the fact that we don't mention Ethereum. But I added some information to the spec regarding immutability. Please let me know if that's enough
Done!
My bad 😅
I was not trying to modify the reference, just forgot to use the return value. But I did a little refactor, let me know if you like it better |
Yes, that batch will be closed at once. But if it cannot be done from within the convert, then it would require an L1 transaction. Someone needs to execute the L1 transaction, and if there is no incentive to do that, then it is most likely one of the users in the batch doing it which leaks information.
The same bridge can be listed with multiple gas limits and new can be added over time. Was mainly to hear if you would want to have multiple different so frontends need to figure out which one based on type of call, or going for the higher gas ones where users on average then would pay a bit more gas but it is easy to handle for people building frontends because they don't need to handle it.
Fine with me that you use the EnumerableSet, was just curious.
My bad on clarity. I was looking at your docs for the Smart Contract Registry where it just don't mention that it is also the addresses on Ethereum 😄 Will look at the code in a moment. The CI is not running, I'm not fully sure why, might be fixed with a rebase though, should be running.
|
I see. I'm curious about your experience with the current Uniswap DCA bridge. I see that there is a fixed fee. How big is it? Is it enough so that third parties execute the
We are going to be building our own FE at aztec.mean.finance. After we are done with the measurements, we can see what the initial gas limit should be, but it's nice to know that it can be updated
Oh, you are right. Just updated it. It's the same address across all chains |
To be honest the current Uniswap DCA bridge don't work particularly well with the fee, fee is too small for searchers to be executing it "often". Also have not won interest from many searchers because profit is tiny and need to do a bit of extra logic to see if it makes sense etc. Generalized frontrunners will frontrun finalises if profitable though, just not look for it themselves 😅
Cool cool. It can be a good idea to have a couple of options for different flows. For the ERC4626 the bridge is listed 3 times, with 300, 400 and 500K gas. With the more general bridges gas are not as consistent, so it is nice to have something to pick between. |
Thank you for the diagram @LHerskind , it definitely adds a ton of value. Just added it to the bridge spec, and also added the comments you asked for 😄 Based on the experience you've described with the Uniswap DCA bridge, we are currently discussing with the rest of the Mean team potential approaches to solve the finalise issue |
Cool, thanks 👍 Let me know if you need input or have questions related to it 😄. Since this might impact the code, will wait a bit before planning the audit, ok? |
Yeah, 100%. Let's wait a little bit before we set it up |
Hey @LHerskind ! The idea would be to make the bridge synchronous, similarly to the ERC4626 bridge. Users would deposit into Mean, and they would get a virtual asset in response. From what I understood, virtual assets simply have the id of the interaction nonce, so we could always return a fixed amount that would be automatically distributed along all users on the same batch. By doing this, we would have the following benefits:
Changes necessary:
And I guess that’s it. What do you think? Do you see it possible? |
Hi, sorry for the slow response. Yes, modelling a synchronous bridge using the Virtual assets should be possible. Your second benefit might not be a full benefit, you also run into have a more difficult time finding other people to batch with. If someone have already exited, you have a pretty small set of users that you could batch together with. But agree on 1 and 3 being clear benefits. For changes, yes you would probably need to do some accounting. Practically, your bridge was already holding funds in the form of the mean position before as well, so don't see the big difference there. Deposits and withdrawals should be happening with different ordering of the assets, so you should be able to use the ids to distinguish between the two flows. |
Hey @LHerskind ! Sorry for the delay. Just pushed the changes to implement the approach we discussed. I also updated the diagram, tests and spec. Please let me know if there is something else I can do from my side |
Description
We are adding a new Aztec bridge that adds support for DCAing with Mean Finance. This bridge supports:
Subsidies
In our case, we will subsidize a combination of:
For example, we will subsidize
(DAI => ETH, 7 swaps, daily)
or(USDC => AAVE, 10 swaps, weekly)
Now, it's important to understand that
(DAI => ETH, 7 swaps, daily)
is different from(ETH => DAI, 7 swaps, daily)
We are doing this because if we considered them the same, then they would share the same subsidy funds. If that happened, then depending on what positions were created, we could be subsidizing
DAI => ETH
twice before doing it forETH => DAI
Another important detail is that since we are using the from/to token, we can subsidize "DAI with yield on Euler" without subsidizing "DAI" (and viceversa)
Note: the bridge has an owner that can set and modify subsidies
Checklist:
forge coverage --match-contract MyContract
returns 100% line coverage.Technical details
Wrappers Registry
This bridge supports the yield-while-DCAing feature. Since we can't pass the 4626 wrapper's address as part of the convert function, we introduced the concept of the Wrappers Registry. The idea is to have a registry that would allow us to map
id => address
. Since the id is smaller (uint16) than an address, we can pass it as part of theauxData
Anyone will be able to register tokens to the registry, since we can easily make sure that there is no wrong-doing
Flow
This is how we expect the data to be passed to the bridge:
inputAssetA
will represent the token that the user will deposit (for example DAI)outputAssetA
will represent the token that the user will withdraw (for example ETH)outputAssetB
will be the same as output_inputAssetA
(to support withdrawing unswapped funds)auxData
will encode:AuxData
The
auxData
field is 64bits long: