TreasuryAdapter
Inherits: ElaraBase, ITreasuryAdapter
Title: TreasuryAdapter Contract
Coordinates treasury operations for the Vault
Invariants:
Does NOT hold any funds - only coordinates operations
depositWallet receives incoming collateral tokens from mint operations
withdrawWallet holds collateral tokens for redemptions and must maintain sufficient liquidity
withdrawWallet must approve Vault for spending tokens
Vault calls this adapter to coordinate treasury operations State machine:
Contract operates in standard initialized state via {ElaraBase}
Wallet addresses are set at initialization and immutable thereafter Access model:
Transfer coordination functions are restricted to the configured vault address Upgradeability:
Uses {ElaraBase} for UUPS upgradeability pattern
Storage gap prevents layout collisions in future upgrades
Note: security-contact: [email protected]
State Variables
depositWallet
Address that receives stablecoin deposits from mint operations
All incoming collateral from mints is routed here
Set at initialization; immutable after initialization
Security: Critical for deposit routing
withdrawWallet
Address that provides stablecoins for redemption operations
Stores collateral tokens for instant redemptions; must maintain sufficient liquidity
withdrawWallet must approve Vault for spending tokens
Set at initialization; immutable after initialization
Security: Critical for redemption operations
vault
Reference to the Vault contract
Address of the Vault contract for yield distribution coordination
Can be set at initialization or updated via setVaultAddress
Security: Critical for yield distribution operations
__gap
Storage gap for future upgrades (EIP-1967)
Functions
initialize
Initializes the TreasuryAdapter with required dependencies
Sets up the base contract and wallet addresses Security:
Only callable during initialization via {initializer} modifier
Sets up the base contract via ElaraBase-__ElaraBase_init
Access control is managed by the {AccessManager} contract
Vault address can be zero during initialization and set later via setVaultAddress
Parameters
_accessManager
address
Address of the AccessManager contract
_depositWallet
address
Address that will receive deposits from mint operations
_withdrawWallet
address
Address that will provide collateral for redemptions
_vault
address
Address of the Vault contract (can be zero)
canTransferOut
Validates both balance and allowance of the withdraw wallet. Allowance is checked from withdrawWallet to msg.sender (the caller), so results are caller-relative — only the Vault (which holds the actual allowance from withdrawWallet) will get accurate results.
transferIn
Validates the transfer can proceed. Vault will execute the actual transfer using SafeERC20.
transferOut
Validates withdraw wallet has sufficient balance and allowance. Vault will execute the actual transfer.
getDepositWallet
Returns the wallet address set at initialization.
getWithdrawWallet
Returns the wallet address set at initialization.
setVaultAddress
Sets the vault address
Security:
Uses {restricted} modifier to allow only authorized callers (admin role)
Can be called after initialization to resolve circular dependency with Vault
Emits VaultAddressUpdated event
Parameters
_vault
address
New vault address
distributeYield
Security:
Uses {restricted} modifier to allow only authorized callers (treasury role)
Coordinates yield distribution by calling Vault.mintYieldToStaking
No tokens are transferred in this flow - Vault mints fresh elUSD
Events
TreasuryAdapterInitialized
Emitted when the contract is initialized
Parameters
accessManager
address
Address of the access manager
depositWallet
address
Address receiving incoming collateral from mints
withdrawWallet
address
Address providing collateral for redemptions
VaultAddressUpdated
Emitted when the vault address is updated
Parameters
oldVault
address
Previous vault address
newVault
address
New vault address
Last updated
Was this helpful?