Skip to content
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

Mezo Allocator #326

Merged
merged 59 commits into from
Apr 10, 2024
Merged

Mezo Allocator #326

merged 59 commits into from
Apr 10, 2024

Conversation

dimpar
Copy link
Member

@dimpar dimpar commented Mar 20, 2024

Depends on #314

This PR adds the first tBTC Allocator with depositing functionality only that will work with Mezo L2. The gateway for tBTC allocation on Mezo is called Mezo Portal and this is where tBTC are allocated from Acre. As of now, 100% of assets will flow to Mezo Portal upon staking in Acre. In the future the % of allocation might change once other L2/DeFi are introduced.

Deposits are created as "rolling" deposits, meaning that the "old" Acre's deposit is drained and all the assets are moved to a newly created deposit. A new id is assigned and replaces the old one. The "old" deposit with zero balance is abandoned.

Mezo Allocator now serves as a "Dispatcher" contract in stBTC because there is only one Mezo Allocator. Once we have more allocators, then the Dispatcher contract will need to be implemented and switched with the current Mezo Allocator contract in stBTC. MezoAllocator will be included in Dispatcher's authorized list of allocators.

Mezo Allocator will route tBTC tokens between Acre x Mezo. Mezo
Allocator is the first pluggable contract to Acre system that will
handle staking tBTC on various L2s/DeFi.

Withdrawal part will be added in other commits.
@dimpar dimpar requested a review from nkuba March 20, 2024 21:07
@dimpar dimpar changed the base branch from main to fees March 20, 2024 21:08
@dimpar dimpar self-assigned this Mar 20, 2024
dimpar added 8 commits March 21, 2024 10:15
- Added mainnet and sepolia addresses in Jsons for Mezo Portal
- Added deployment script for Mezo Allocator contract. A fake random
  address is used for Mezo Portal when deploying on hardhat network.
  This is for testing purposes only.
At first Mezo Allocator will be Acre's dispatcher. Later on a proper
dispatcher will be implemented and switched with the Mezo Allocator.
Dispatcher in the current form will be replaced in the future. For now,
the role of the dispatcher contract will server the MezoAllocator
contract since we do not have any other L2s/DeFi partners yet. Once we
have it, it will be updated for the proper dispatcher that will include
MezoAllocator.
@dimpar dimpar marked this pull request as ready for review March 22, 2024 11:53
@dimpar dimpar mentioned this pull request Mar 25, 2024
@nkuba nkuba changed the title Mezo Allocator Mezo Allocator - deposit Mar 25, 2024
dimpar added 3 commits March 26, 2024 16:34
It might happen that we'll need a data structure to support information
like deposit creation and unclock time in case we shift from the zero
time locks.
- Made Slither and Solhing happier
- Renamed the tag name for Mezo Allocator
Base automatically changed from fees to main April 3, 2024 15:30
@nkuba nkuba added the 🔗 Solidity Solidity contracts label Apr 4, 2024
dimpar added 6 commits April 4, 2024 13:34
Here we change the deposit approach from tracking all the Mezo Deposits
to having only a single deposit that accumulates all deposited tBTC by
Acre into a single deposit. An "old" deposit is abondoned and balance is
zeroed. A "new" deposit is created with a new id and a new balance is
equal to the old balance + new requested amount.
dimpar added 6 commits April 9, 2024 15:47
We need to pull funds from Mezo Portal first before we can update the
balance. This is because if amount > then the balance, it should revert.
Otherwise, we'll get the underflow error.
@dimpar dimpar mentioned this pull request Apr 9, 2024
Copy link
Member

@pdyraga pdyraga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a high-level review. Left some non-blocking comments.

dimpar added 4 commits April 10, 2024 12:18
In case there will be a need of pulling all the funds from Mezo we add a
releaseDeposit function that can be called by the owner only.
Added NotMaintainer and NotStbtc to better understand the error if
occurs.
@nkuba nkuba enabled auto-merge April 10, 2024 13:23
@nkuba nkuba merged commit e94a4ff into main Apr 10, 2024
20 checks passed
@nkuba nkuba deleted the allocator branch April 10, 2024 13:23
nkuba added a commit that referenced this pull request Apr 10, 2024
Depends on #326

Mezo Allocator will serve as a first "dispatcher". We should remove the
current outdated version of the Dispatcher contract that will be
replaced by another contract in the future.
dimpar added a commit that referenced this pull request Apr 10, 2024
Depends on: #326

Make the MezoAllocator contract upgradable and deploy it as a
transparent proxy with Open Zeppelin upgrades plugin.
@thesis thesis deleted a comment from netlify bot Jul 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔗 Solidity Solidity contracts
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants