Repository navigation
feat: v4 direct minter #3
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
Open
DhairyaSethi
wants to merge
11
commits into
main
Choose a base branch
from
feat/v4-minter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+419
−19
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
7d0d92c
feat: add v4
DhairyaSethi 2e16ea8
feat: implement v4 direct minter
DhairyaSethi 56d6b8e
chore: lint
DhairyaSethi 7a17e10
fix: docs and consistency w v4 style
DhairyaSethi 0f1d927
chore: bump aave-v4 to main and aave-helpers
DhairyaSethi c7aa1e1
chore: remove unused import
DhairyaSethi cbf0ec4
feat: add DeployV4Core using address book addresses
DhairyaSethi f249c2a
test: fork mainnet core hub and fuzz transferExcessToTreasury
DhairyaSethi 59a28a1
ci: use aave-dao github workflows
DhairyaSethi 2d4f784
docs: remove redundant @return natspec
DhairyaSethi a25c346
chore: use aave-v4 from address book dependency
DhairyaSethi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule aave-helpers
updated
123 files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| import { | ||
| UpgradeableOwnableWithGuardian | ||
| } from "solidity-utils/contracts/access-control/UpgradeableOwnableWithGuardian.sol"; | ||
| import {Initializable} from "openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol"; | ||
| import {IHub} from "aave-v4/hub/interfaces/IHub.sol"; | ||
| import {IGhoDirectMinterV4} from "src/interfaces/IGhoDirectMinterV4.sol"; | ||
| import {IGhoToken} from "src/interfaces/IGhoToken.sol"; | ||
|
|
||
| /// @title GhoDirectMinterV4 | ||
| /// @author Aave Labs | ||
| /// @notice A GHO facilitator that injects (mints) and removes (burns) GHO from an Aave V4 Hub. | ||
| /// @dev The GhoDirectMinterV4 is expected to be registered as a spoke on the Hub with infinite addCap. | ||
| contract GhoDirectMinterV4 is Initializable, UpgradeableOwnableWithGuardian, IGhoDirectMinterV4 { | ||
| IGhoToken internal immutable GHO; | ||
| IHub internal immutable HUB; | ||
| uint256 internal immutable ASSET_ID; | ||
|
|
||
| /// @dev Constructor. | ||
| /// @param hub_ The address of the Aave v4 Hub. | ||
| /// @param gho_ The address of the GHO token. | ||
| constructor(address hub_, address gho_) { | ||
| _disableInitializers(); | ||
| HUB = IHub(hub_); | ||
| ASSET_ID = HUB.getAssetId(gho_); // reverts on invalid `underlying` | ||
| GHO = IGhoToken(gho_); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function initialize(address owner, address council) external virtual initializer { | ||
| __Ownable_With_Guardian_init(owner, council); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function mintAndSupply(uint256 amount) external onlyOwnerOrGuardian { | ||
| GHO.mint(address(HUB), amount); | ||
| HUB.add(ASSET_ID, amount); // this spoke is given infinite cap | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function withdrawAndBurn(uint256 amount) external onlyOwnerOrGuardian { | ||
| HUB.remove(ASSET_ID, amount, address(this)); | ||
| GHO.burn(amount); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function transferExcessToTreasury() external { | ||
| (, uint256 level) = GHO.getFacilitatorBucket(address(this)); | ||
| uint256 balance = HUB.getSpokeAddedAssets(ASSET_ID, address(this)); | ||
| uint256 excess = balance - level; | ||
| // underestimate excess shares to ensure the facilitator remains at or above bucket level | ||
| uint256 excessShares = HUB.previewAddByAssets(ASSET_ID, excess); | ||
| if (excessShares > 0) { | ||
| HUB.payFeeShares(ASSET_ID, excessShares); | ||
| } | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function hub() external view returns (address) { | ||
| return address(HUB); | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function assetId() external view returns (uint256) { | ||
| return ASSET_ID; | ||
| } | ||
|
|
||
| /// @inheritdoc IGhoDirectMinterV4 | ||
| function gho() external view returns (address) { | ||
| return address(GHO); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
| pragma solidity ^0.8.0; | ||
|
|
||
| /// @title IGhoDirectMinterV4 | ||
| /// @author Aave Labs | ||
| /// @notice Interface for the GhoDirectMinter, a GHO facilitator that injects (mints) and removes (burns) GHO from an Aave V4 Hub. | ||
| /// @dev The GhoDirectMinter is expected to be registered as a spoke on the Hub with infinite addCap. | ||
| interface IGhoDirectMinterV4 { | ||
| /// @notice Initializes the contract. | ||
| /// @param owner The address of the owner. | ||
| /// @param council The address of the guardian council. | ||
| function initialize(address owner, address council) external; | ||
|
|
||
| /// @notice Mints GHO and adds it as liquidity to the Hub. | ||
| /// @dev Only callable by the owner or guardian. | ||
| /// @param amount The amount of GHO to mint and supply. | ||
| function mintAndSupply(uint256 amount) external; | ||
|
|
||
| /// @notice Removes GHO liquidity from the Hub and burns it. | ||
| /// @dev Only callable by the owner or guardian. | ||
| /// @param amount The amount of GHO to withdraw and burn. | ||
| function withdrawAndBurn(uint256 amount) external; | ||
|
|
||
| /// @notice Transfers excess GHO interest (added shares above facilitator bucket level) to the fee receiver. | ||
| /// @dev Callable by anyone. | ||
| /// @dev Due to rounding in the share conversion, the amount transferred may be slightly less than the true excess. | ||
| function transferExcessToTreasury() external; | ||
|
|
||
| /// @notice Returns the address of the Aave v4 Hub. | ||
| function hub() external view returns (address); | ||
|
|
||
| /// @notice Returns the asset identifier for GHO in the Hub. | ||
| function assetId() external view returns (uint256); | ||
|
|
||
| /// @notice Returns the address of the GHO token. | ||
| function gho() external view returns (address); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we think about having this more flexible so it can mint GHO to multiple hubs if needed?
Is that unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
while that's possible, I think we'd need to do like AIP to grant access to each, rather than allowing the same owner/guardian to supply into multiple hubs, so would need to add more granular access controls on a per-hub basis perhaps
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no i dont think we should mix facilitator capacities also