Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
75e9f55
feat: Simple contract to mint fee shares
CheyenneAtapour Feb 17, 2026
9ec1d11
chore: Cleanup
CheyenneAtapour Feb 17, 2026
4dc1448
feat: Make contract usable with all hubs
CheyenneAtapour Feb 17, 2026
0f6dab4
fix: Pr comments
CheyenneAtapour Feb 17, 2026
4f0492e
fix: test comment
CheyenneAtapour Feb 17, 2026
d9bfd8d
fix: Address pr comments
CheyenneAtapour Feb 25, 2026
cf0e864
Merge remote-tracking branch 'origin/main' into feat/fee-minter
CheyenneAtapour Feb 25, 2026
ba91946
fix: address pr comments
CheyenneAtapour Feb 26, 2026
729a05f
feat: Integrate with chainlink automation
CheyenneAtapour Feb 26, 2026
89d75b4
fix: test suite
CheyenneAtapour Feb 27, 2026
521c61c
chore: cleanup
CheyenneAtapour Feb 27, 2026
3a54457
fix: Cleanup natspec
CheyenneAtapour Feb 28, 2026
05bcd6c
fix: typo
CheyenneAtapour Mar 4, 2026
aba7d8c
Merge remote-tracking branch 'origin/main' into feat/fee-minter
CheyenneAtapour Mar 10, 2026
55f3330
Merge remote-tracking branch 'origin/main' into feat/fee-minter
CheyenneAtapour Mar 12, 2026
60d2395
Merge remote-tracking branch 'origin/main' into feat/fee-minter
CheyenneAtapour Mar 25, 2026
01fc11f
merge in main
CheyenneAtapour Mar 28, 2026
d6c0ac0
fix: Address pr comments
CheyenneAtapour Mar 28, 2026
9a0ce16
fix: Address pr comments
CheyenneAtapour Mar 28, 2026
36d151c
fix: Some pr comments
CheyenneAtapour Apr 9, 2026
976361e
Merge remote-tracking branch 'origin/main' into feat/fee-minter
CheyenneAtapour Apr 9, 2026
e0244e0
merge in main
CheyenneAtapour Apr 9, 2026
6e155aa
fix: Remaining pr comments
CheyenneAtapour Apr 9, 2026
39c7c5a
feat: Remove time component from fee minter
CheyenneAtapour Apr 9, 2026
56fbaf0
fix: Remove extraneous functions
CheyenneAtapour Apr 9, 2026
7bb20ec
fix : address pr comments & cleanup
Kogaroshi Apr 15, 2026
55f1f82
fix : renaming
Kogaroshi Apr 15, 2026
c0c322d
feat : add FeeSharesMinter to deploy engine
Kogaroshi Apr 15, 2026
8bb19cc
fix: address fee minter comments (#1299)
yan-man Apr 16, 2026
98c4cc4
fix: address comments
avniculae May 21, 2026
c85cb6f
feat: migrate FeeSharesMinter to CRE
avniculae May 22, 2026
9010c1f
feat: add FeeSharesMinter support in config engine
avniculae May 22, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions src/hub/FeeSharesMinterBase.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// SPDX-License-Identifier: UNLICENSED
// Copyright (c) 2025 Aave Labs
pragma solidity ^0.8.0;

import {Ownable} from 'src/dependencies/openzeppelin/Ownable.sol';
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated
import {Ownable2Step} from 'src/dependencies/openzeppelin/Ownable2Step.sol';
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated
import {Rescuable} from 'src/utils/Rescuable.sol';
import {IHub} from 'src/hub/interfaces/IHub.sol';

/// @title FeeSharesMinterBase
/// @author Aave Labs
/// @notice Contract to mint fee shares on the Hub when specific conditions are met.
contract FeeSharesMinterBase is Ownable2Step, Rescuable {
struct MintConfig {
uint256 minTimeInterval;
uint16 minUnrealizedFeePercent; // 1e4 = 100% (basis points)
}

uint256 public constant MAX_BPS = 1e4;
uint256 public constant MAX_TIME_INTERVAL = 365 days;

mapping(address => mapping(uint256 => MintConfig)) internal _configs;
mapping(address => mapping(uint256 => uint256)) public lastMintTime;

event ConfigUpdated(address indexed hub, uint256 indexed assetId, MintConfig config);

error ConditionsNotMet();
error InvalidConfig();
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated

/// @dev Constructor.
/// @param owner The owner of the contract.
constructor(address owner) Ownable(owner) {}

/// @notice Sets the automation configuration for a specific asset.
/// @param hub The address of the hub.
/// @param assetId The identifier of the asset.
/// @param config The new configuration.
function setConfig(address hub, uint256 assetId, MintConfig memory config) external onlyOwner {
require(
config.minUnrealizedFeePercent <= MAX_BPS && config.minTimeInterval <= MAX_TIME_INTERVAL,
InvalidConfig()
);
_configs[hub][assetId] = config;
emit ConfigUpdated(hub, assetId, config);
}

/// @notice Executes the fee minting if conditions are met.
/// @param hub The address of the hub.
/// @param assetId The identifier of the asset.
function execute(address hub, uint256 assetId) external {
require(_checkExecute(hub, assetId), ConditionsNotMet());

lastMintTime[hub][assetId] = block.timestamp;
IHub(hub).mintFeeShares(assetId);
}

/// @notice Returns the automation configuration for a specific asset.
/// @param hub The address of the hub.
/// @param assetId The identifier of the asset.
/// @return The configuration struct.
function getConfig(address hub, uint256 assetId) external view returns (MintConfig memory) {
return _configs[hub][assetId];
}

/// @notice Checks if the conditions to mint fee shares are met.
/// @param hub The address of the hub.
/// @param assetId The identifier of the asset.
/// @return True if conditions are met, false otherwise.
function checkExecute(address hub, uint256 assetId) external view returns (bool) {
return _checkExecute(hub, assetId);
}

/// @dev Internal function to check execution conditions.
/// @param hub The address of the hub.
/// @param assetId The identifier of the asset.
/// @return True if conditions are met, false otherwise.
function _checkExecute(address hub, uint256 assetId) internal view virtual returns (bool) {
MintConfig memory config = _configs[hub][assetId];

// Check mint interval
if (block.timestamp - lastMintTime[hub][assetId] < config.minTimeInterval) {
return false;
}

IHub hubContract = IHub(hub);
uint256 accruedFees = hubContract.getAssetAccruedFees(assetId);

uint256 totalAddedAssets = hubContract.getAddedAssets(assetId);
if (totalAddedAssets == 0) return false;
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated

// Check if accruedFees / totalAddedAssets >= minUnrealizedFeePercent (in bps)
if ((accruedFees * MAX_BPS) / totalAddedAssets < config.minUnrealizedFeePercent) {
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated
return false;
}

// Ensure at least 1 fee share is minted
uint256 expectedShares = hubContract.previewAddByAssets(assetId, accruedFees);
if (expectedShares == 0) {
return false;
}

return true;
Comment thread
DhairyaSethi marked this conversation as resolved.
Outdated
}

/// @inheritdoc Rescuable
function _rescueGuardian() internal view override returns (address) {
return owner();
}
}
Loading
Loading