@@ -5,6 +5,7 @@ pragma solidity 0.8.26;
55import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol " ;
66import { UUPSUpgradeable } from "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol " ;
77import { AccessControlledUpgradeable } from "@synaps3/core/primitives/upgradeable/AccessControlledUpgradeable.sol " ;
8+ import { ReentrancyGuardTransientUpgradeable } from "@openzeppelin/contracts-upgradeable/utils/ReentrancyGuardTransientUpgradeable.sol " ;
89import { BalanceOperatorUpgradeable } from "@synaps3/core/primitives/upgradeable/BalanceOperatorUpgradeable.sol " ;
910
1011import { ITreasury } from "@synaps3/core/interfaces/economics/ITreasury.sol " ;
@@ -19,6 +20,7 @@ contract Treasury is
1920 Initializable ,
2021 UUPSUpgradeable ,
2122 AccessControlledUpgradeable ,
23+ ReentrancyGuardTransientUpgradeable ,
2224 BalanceOperatorUpgradeable ,
2325 ITreasury
2426{
@@ -41,6 +43,7 @@ contract Treasury is
4143 function initialize (address accessManager ) public initializer {
4244 __UUPSUpgradeable_init ();
4345 __BalanceOperator_init ();
46+ __ReentrancyGuardTransient_init ();
4447 __AccessControlled_init (accessManager);
4548 }
4649
@@ -52,18 +55,49 @@ contract Treasury is
5255 // function allocate(address pool, uint256 amount) restricted;
5356 // eg: proposal: deposit N fees to staking pool, deposit N fees to development pool, rewards, etc
5457
55- /// @notice Deposits a specified amount of currency into the treasury for a given recipient.
56- /// @param pool The address of the pool to credit with the deposit.
58+ /// @notice Deposits a specified amount of currency into the treasury for a given recipient (pool).
59+ /// @dev Only whitelisted accounts (via `restricted`) can interact with this method.
60+ /// This prevents arbitrary accounts from injecting funds into the treasury.
61+ /// @param pool The address of the pool credited with the deposit.
5762 /// @param amount The amount of currency to deposit.
58- /// @param currency The address of the ERC20 token to deposit.
63+ /// @param currency The address of the ERC20 token to deposit (use `address(0)` for native).
64+ /// @return The confirmed deposited amount.
5965 function deposit (
6066 address pool ,
6167 uint256 amount ,
6268 address currency
63- ) public override (BalanceOperatorUpgradeable) restricted returns (uint256 ) {
64- // restricted deposit to avoid invalid operations
65- // only allowed accounts can interact with this method
66- return super .deposit (pool, amount, currency);
69+ ) external whenNotPaused restricted returns (uint256 ) {
70+ return _deposit (pool, amount, currency);
71+ }
72+
73+ /// @notice Withdraws tokens from the treasury to a specified recipient.
74+ /// @dev Restricted to authorized accounts (via `restricted`).
75+ /// Ensures treasury funds are only withdrawn under governance-approved flows.
76+ /// @param recipient The address receiving the withdrawn tokens.
77+ /// @param amount The amount of tokens to withdraw.
78+ /// @param currency The token address for the withdrawal (use `address(0)` for native).
79+ /// @return The confirmed withdrawn amount.
80+ function withdraw (
81+ address recipient ,
82+ uint256 amount ,
83+ address currency
84+ ) external whenNotPaused restricted returns (uint256 ) {
85+ return _withdraw (recipient, amount, currency);
86+ }
87+
88+ /// @notice Transfers tokens internally in the treasury ledger from the caller to a recipient.
89+ /// @dev Restricted to authorized accounts (via `restricted`).
90+ /// Unlike `withdraw`, this does not move funds externally but shifts balances inside the ledger.
91+ /// @param recipient The address credited with the transfer.
92+ /// @param amount The amount to transfer.
93+ /// @param currency The token being transferred (use `address(0)` for native).
94+ /// @return The confirmed transferred amount.
95+ function transfer (
96+ address recipient ,
97+ uint256 amount ,
98+ address currency
99+ ) external whenNotPaused restricted returns (uint256 ) {
100+ return _transfer (recipient, amount, currency);
67101 }
68102
69103 /// @notice Collects accrued fees for a specified currency from an authorized fee collector. (visitable)
@@ -72,7 +106,7 @@ contract Treasury is
72106 /// Only the governor can execute this function, ensuring controlled fee collection.
73107 /// @param collector The address of an authorized fee collector.
74108 /// @param currency The address of the ERC20 token for which fees are being collected.
75- function collectFees (address collector , address currency ) external restricted nonReentrant {
109+ function collectFees (address collector , address currency ) external restricted whenNotPaused nonReentrant {
76110 // TODO update adding amount param on disburse call
77111 // IFeesCollector feesCollector = IFeesCollector(collector);
78112 // uint256 collected = feesCollector.disburse(currency);
0 commit comments