Skip to main content

PermissionManagerV2 Contract

Manages agent sessions and validates permissions.

Overview

PermissionManagerV2 provides:

  • O(1) session validation (gas efficient)
  • Chainlink oracle for USD price conversion
  • Daily and per-transaction spending limits
  • Automatic daily limit reset
  • Operation and protocol whitelisting

Functions

createSession

Create a new agent session.

function createSession(
address vault,
address agent,
uint256 expiresAt,
uint256 dailyLimitUSD,
uint256 perTxLimitUSD,
uint8 maxPositionSizePct,
uint16 maxSlippageBps,
uint8 maxLeverage,
bytes4[] calldata allowedOperations,
address[] calldata allowedProtocols
) external

validateOperation

Validate and record an operation (called by vault).

function validateOperation(
address vault,
address agent,
address target,
uint256 valueUSD,
bytes4 operation
) external returns (bool)

getSession

Get session details.

function getSession(
address vault,
address agent
) external view returns (AgentSession memory)

revokeSession

Revoke an agent's session.

function revokeSession(
address vault,
address agent
) external

Session Structure

struct AgentSession {
address agent;
uint256 expiresAt;
uint256 dailyLimitUSD;
uint256 perTxLimitUSD;
uint8 maxPositionSizePct;
uint16 maxSlippageBps;
uint8 maxLeverage;
bytes4[] allowedOperations;
address[] allowedProtocols;
uint256 dailySpentUSD;
uint256 lastResetTimestamp;
}

Custom Errors

error SessionExpired();
error OperationNotAllowed();
error ProtocolNotAllowed();
error PerTxLimitExceeded();
error DailyLimitExceeded();
error UnauthorizedAgent();