Documentation
adapter-interface

Asset Adapter Interface

IAssetAdapter is the uniform interface between the Lending Pool and each collateral asset. Every adapter is responsible for:

  • Valuation via an asset-specific oracle.
  • Custody of the underlying RWA tokens.
  • Position identification (opaque bytes encoding, decoded only by the adapter).

Interface

interface IAssetAdapter {
    // Valuation
    function getAssetValue(address user, bytes calldata data) external view returns (uint256);
    function getWithdrawValue(address user, bytes calldata data) external view returns (uint256);
    function getTotalAssetValue(address user) external view returns (uint256);
 
    // Position management (LendingPool-only)
    function deposit(address user, bytes calldata data) external;
    function withdraw(address user, bytes calldata data) external;
    function transferAsset(address from, bytes calldata data, address to) external;
 
    // Position identification
    function getPositionKey(bytes calldata data) external pure returns (bytes32);
    function getPositionKeys(address user) external view returns (bytes32[] memory);
 
    // Validation
    function validate(address user, bytes calldata data) external view;
    function validateLiquidationData(address user, bytes calldata data) external view returns (bool);
 
    // Asset info
    function getAssetToken() external view returns (address);
    function getAssetType() external view returns (string memory);
    function supportsPartialWithdraw() external view returns (bool);
 
    // Oracle management (owner-only)
    function setPriceOracle(address _oracle) external;
}

Data encoding convention

Asset classdata encoding
ERC-20abi.encode(uint256 amount)
ERC-721abi.encode(uint256 tokenId) (not used in V1)
ERC-1155abi.encode(uint256 tokenId, uint256 amount) (not used in V1)

The adapter decodes data in every function. getPositionKey(data) computes the storage key used by the Lending Pool for the position.

Risk parameters (per adapter)

Each adapter exposes its own immutable risk parameters:

ParameterTypeMeaning
MAX_LTVuint256Borrow threshold in basis points.
LIQUIDATION_THRESHOLDuint256LLTV in basis points (HF denominator scaler).
LIQUIDATION_BONUSuint256Bonus seized during liquidation, basis points.
ORACLE_STALENESS_MAXuint256Max time since last oracle update, seconds.

Oracle integration contract

Design Review #4: each adapter has a single oracle today. This is a concentrated trust assumption. We recommend requiring a secondary oracle (or NAV attestation from a second issuer signing key) before mainnet.

At minimum, every adapter MUST:

  1. Check oracle.lastUpdate() + ORACLE_STALENESS_MAX > block.timestamp on every user-facing entry.
  2. Reject price == 0 explicitly.
  3. Optionally reject out-of-bound price moves (e.g., > 30% in < 1h) as a circuit breaker.

Adding a new adapter

Contact the Agama team.