Skip to content

Commit e692371

Browse files
committed
✨ add claimYield fct
1 parent ee965d7 commit e692371

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/treasury/TreasuryV1.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ contract TreasuryV1 is StorageV1 {
4242
error SyncIntervalNotMet();
4343
error WeightsNotValid();
4444
error YieldIntervalNotMet();
45+
error YieldTooLow();
4546

4647
/* //////////////////////////////////////////////////////////////
4748
EVENTS
@@ -74,6 +75,25 @@ contract TreasuryV1 is StorageV1 {
7475
YIELD LOCKERS LOGIC
7576
////////////////////////////////////////////////////////////// */
7677

78+
/**
79+
* @notice Claims an amount of yield from the treasury.
80+
* @param amount The amount of yield to claim.
81+
* @param receiver The address receiving the yield.
82+
* @dev If amount provided is equal to type(uint256).max, it will claim the full available yield balance.
83+
*/
84+
function claimYield(uint256 amount, address receiver) external onlyOwner {
85+
if (amount > availableYield) revert YieldTooLow();
86+
87+
if (amount == type(uint256).max) {
88+
uint256 availableYield_ = availableYield;
89+
availableYield = 0;
90+
IERC20(EURE).safeTransfer(receiver, availableYield_);
91+
} else {
92+
availableYield -= amount;
93+
IERC20(EURE).safeTransfer(receiver, amount);
94+
}
95+
}
96+
7797
/**
7898
* @notice Synchronizes all yield lockers by adjusting balances based on weights and idle ratio.
7999
*/

0 commit comments

Comments
 (0)