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

Implement Public Allocator #1

Merged
merged 171 commits into from
Feb 20, 2024
Merged

Implement Public Allocator #1

merged 171 commits into from
Feb 20, 2024

Conversation

adhusson
Copy link
Contributor

@adhusson adhusson commented Feb 6, 2024

Summary

tldr
Main function is reallocateTo(Withdrawal[] calldata withdrawals, MarketParams calldata supplyMarketParams), it is callable by anyone. withdrawals is a list of (market,amount) pairs. The function will try to withdraw the given amount from each market and then deposit the total withdrawn to depositMarketParams, subject to admin-settable constraints.

Max flows
Each market has a max inflow (maxIn) and a max outflow (maxOut). For every call to reallocateTo:

  • The markets in withdrawals increase their maxIn and decrease their maxOut by the amount withdrawn.
  • The market depositMarketParams increases its maxOut and decreases its maxIn by the total withdrawn.

The owner can configure the max inflows/outflows.

Supply caps
Each market has a supply cap that works like MetaMorpho's supply caps. The owner can configure the caps.

Fee
The PublicAllocator has a fee (payable in ETH). The owner can configure the fee. The owner must call transferFee to take the accumulated fees out of the PublicAllocator.

Checks
The PublicAllocator will make the following checks when reallocateTo is called:

  • No market's maxIn or maxOut is exceeded.
  • No market's supply cap is exceeded.
  • The fee has been paid.

@adhusson adhusson marked this pull request as ready for review February 9, 2024 08:47
src/PublicAllocator.sol Outdated Show resolved Hide resolved
src/PublicAllocator.sol Outdated Show resolved Hide resolved
src/PublicAllocator.sol Outdated Show resolved Hide resolved
src/PublicAllocator.sol Outdated Show resolved Hide resolved
@adhusson adhusson changed the title feat: allocator with min/max flows and ETH fee feat: allocator with min/max flows, subcaps and ETH fee Feb 12, 2024
MathisGD
MathisGD previously approved these changes Feb 20, 2024
MerlinEgalite
MerlinEgalite previously approved these changes Feb 20, 2024
Jean-Grimal
Jean-Grimal previously approved these changes Feb 20, 2024
QGarchery
QGarchery previously approved these changes Feb 20, 2024
src/interfaces/IPublicAllocator.sol Outdated Show resolved Hide resolved
src/interfaces/IPublicAllocator.sol Outdated Show resolved Hide resolved
Co-authored-by: Quentin Garchery <QGarchery@users.noreply.github.com>
Signed-off-by: MathisGD <74971347+MathisGD@users.noreply.github.com>
@MathisGD MathisGD dismissed stale reviews from QGarchery, Jean-Grimal, MerlinEgalite, and themself via 14f4eb8 February 20, 2024 14:53
@MathisGD MathisGD merged commit 1cdcee8 into main Feb 20, 2024
2 checks passed
@MathisGD MathisGD deleted the feat/flows-and-eth-fee branch February 20, 2024 15:20
@adhusson adhusson mentioned this pull request Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants