IProtocolAdapter
Title: IProtocolAdapter
Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)
Sidecar interface implemented by every Lattice protocol adapter alongside
IStrategy. Covers what IStrategy deliberately omits: sweeping pushed idle
funds into the protocol (deploy), claiming and forwarding rewards raw
(harvest), emergency exit, and pause/health introspection.
Adapters are stateless Diamond facets; all logic lives in their library + the
shared AdapterBaseLib. Errors are declared here (interface-owned) per Lattice
convention. Wide pragma so older-compiler consumers can import the ABI.
Functions
deploy
Sweeps the adapter's idle asset balance into the external protocol.
Required because the vault PUSHES funds via a bare ERC-20 transfer (no callback).
Reverts ProtocolAdapterNothingToDeploy if the idle balance is zero.
function deploy() external returns (uint256 deployed);Returns
| Name | Type | Description |
|---|---|---|
| deployed | uint256 | The amount swept into the protocol. |
harvest
Claims reward tokens from the protocol and forwards them RAW (no swap) to the configured recipient.
Safe against zero-claim and fee-on-transfer reward tokens; never reverts withdraw.
function harvest() external;emergencyWithdraw
Fully exits the protocol position and returns all recovered assets to the vault.
Intended for the emergency path; callable by an authorized guardian/admin even when the adapter is paused.
function emergencyWithdraw() external returns (uint256 recovered);Returns
| Name | Type | Description |
|---|---|---|
| recovered | uint256 | The amount returned to the vault. |
isPaused
Returns true when the adapter is paused or emergency-stopped, or the external
protocol reports the asset paused/frozen. When true, deploy() must be a no-op
path (revert), so a paused protocol cannot brick rebalance().
function isPaused() external view returns (bool);Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
healthFactor
Returns the current health factor (WAD, 1e18 == 1.0) of the adapter's position.
Supply-only adapters return type(uint256).max (no debt). Leverage adapters return
collateralValue * liquidationThreshold / debtValue.
function healthFactor() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
minHealthFactor
Returns the configured minimum health factor (WAD) the adapter must not breach.
function minHealthFactor() external view returns (uint256);Returns
| Name | Type | Description |
|---|---|---|
| <none> | uint256 |
rewardRecipient
Returns the address rewards are forwarded to.
function rewardRecipient() external view returns (address);Returns
| Name | Type | Description |
|---|---|---|
| <none> | address |
Events
Deployed
Emitted when idle funds are swept into the protocol.
event Deployed(address indexed asset, uint256 amount);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The underlying asset deployed. |
| amount | uint256 | The amount deployed. |
RewardsForwarded
Emitted when reward tokens are claimed and forwarded raw to the recipient.
event RewardsForwarded(address indexed rewardToken, address indexed recipient, uint256 amount);Parameters
| Name | Type | Description |
|---|---|---|
| rewardToken | address | The reward token forwarded. |
| recipient | address | The configured reward recipient. |
| amount | uint256 | The amount forwarded (post-transfer real delta). |
RewardRecipientSet
Emitted when the reward recipient is set or changed.
event RewardRecipientSet(address indexed recipient);Parameters
| Name | Type | Description |
|---|---|---|
| recipient | address |
OperatorSet
Emitted when the authorized operator (the only caller permitted to invoke the
deploy/withdraw/harvest trio) is set or changed.
event OperatorSet(address indexed operator);Parameters
| Name | Type | Description |
|---|---|---|
| operator | address |
EmergencyWithdrawn
Emitted when the adapter fully exits its position in an emergency.
event EmergencyWithdrawn(address indexed asset, address indexed toVault, uint256 recovered);Parameters
| Name | Type | Description |
|---|---|---|
| asset | address | The underlying asset recovered. |
| toVault | address | The vault the funds were returned to. |
| recovered | uint256 | The amount returned to the vault. |
Errors
ProtocolAdapterPaused
An operation requiring an active position was attempted while paused/stopped, or the external protocol reports paused/frozen.
error ProtocolAdapterPaused();ProtocolAdapterZeroAddress
A zero address was supplied where a non-zero address is required.
error ProtocolAdapterZeroAddress();ProtocolAdapterNothingToDeploy
deploy() was called with no idle balance to sweep.
error ProtocolAdapterNothingToDeploy();ProtocolAdapterHealthFactorBreached
A lever/delever/deploy op would push the position below the configured minimum health factor.
error ProtocolAdapterHealthFactorBreached(uint256 resulting, uint256 floor);Parameters
| Name | Type | Description |
|---|---|---|
| resulting | uint256 | The health factor (WAD) the op would produce. |
| floor | uint256 | The configured minimum health factor (WAD). |
ProtocolAdapterRewardForwardFailed
A reward token transfer to the recipient failed.
error ProtocolAdapterRewardForwardFailed(address rewardToken);Parameters
| Name | Type | Description |
|---|---|---|
| rewardToken | address |
ProtocolAdapterUnauthorized
Caller is not authorized for this operation.
error ProtocolAdapterUnauthorized(address caller);Parameters
| Name | Type | Description |
|---|---|---|
| caller | address |
ProtocolAdapterInvalidRecipient
withdraw was called with a recipient other than the adapter's stored vault.
The recipient of a recall is pinned to the vault the adapter was initialized with, so an
attacker who somehow reaches withdraw can never redirect the position to themselves.
error ProtocolAdapterInvalidRecipient(address to);Parameters
| Name | Type | Description |
|---|---|---|
| to | address |
ProtocolAdapterInvalidOraclePrice
The protocol's price oracle returned a non-positive (zero) asset price, which would make a valuation divide-by-zero or mis-state NAV. The valuation reverts rather than report a bogus figure.
error ProtocolAdapterInvalidOraclePrice();