Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

aHYPESeat Contract Interface

Complete API reference for the SeatMarket contract.

Constructor

constructor(
    address hypeToken,
    uint256 _maxSeats,
    uint256 _minFeePerSecond,
    uint256 _maxFeePerSecond,
    address _feeRecipient,
    uint256 _burnBps
)
Parameters:
NameTypeDescription
hypeTokenaddressaHYPE token contract address
_maxSeatsuint256Maximum number of seats
_minFeePerSeconduint256Minimum fee rate (WAD per second)
_maxFeePerSeconduint256Maximum fee rate (WAD per second)
_feeRecipientaddressAddress to receive fees
_burnBpsuint256Basis points to burn (0-10000)

User Functions

purchaseSeat

Deposit collateral and occupy a seat.

function purchaseSeat(uint256 deposit) external nonReentrant
Parameters:
NameTypeDescription
deposituint256Amount of aHYPE to deposit
Requirements:
  • Caller must not already have a seat
  • deposit >= minDepositForSeat()
  • occupiedSeats < maxSeats
  • Caller must have approved contract for deposit amount
Behavior:
  • Transfers aHYPE from caller to contract
  • Creates new position with hasSeat = true
  • Snapshots current cumulativeFeePerSeat
  • Adds caller to seatHolders array

Emits: SeatPurchased(address indexed user, uint256 deposit)


addCollateral

Add more collateral to an existing position.

function addCollateral(uint256 amount) external nonReentrant
Parameters:
NameTypeDescription
amountuint256Amount of aHYPE to add
Requirements:
  • Caller must have a seat
  • Caller must have approved contract for amount
Behavior:
  • Transfers aHYPE from caller to contract
  • Increases position.collateral by amount

Emits: CollateralAdded(address indexed user, uint256 amount)


repayFees

Repay accrued fees to reduce debt.

function repayFees(uint256 amount) external nonReentrant
Parameters:
NameTypeDescription
amountuint256Amount to repay
Requirements:
  • Caller must have a seat
  • amount <= debtValueOf(caller)
  • Caller must have approved contract for amount
Behavior:
  • Accrues fees to current timestamp
  • Transfers aHYPE from caller to contract
  • Reduces settledDebt by repayment
  • Distributes repayment as fees (burn + recipient)
  • Updates fee index snapshot

Emits: FeesRepaid(address indexed user, uint256 amount)


withdrawCollateral

Withdraw excess collateral (must remain healthy).

function withdrawCollateral(uint256 amount) external nonReentrant
Parameters:
NameTypeDescription
amountuint256Amount of aHYPE to withdraw
Requirements:
  • Caller must have a seat
  • Position must remain healthy after withdrawal: collateral - amount >= debt
Behavior:
  • Accrues fees to current timestamp
  • Settles current debt
  • Reduces collateral by amount
  • Transfers aHYPE to caller

Emits: CollateralWithdrawn(address indexed user, uint256 amount)


exit

Voluntarily exit, settle debt, and receive remaining collateral.

function exit() external nonReentrant
Requirements:
  • Caller must have a seat
Behavior:
  • Accrues fees to current timestamp
  • Calculates final debt
  • If debt <= collateral:
    • Distributes debt as fees
    • Returns collateral - debt to user
  • If debt > collateral:
    • Distributes all collateral as fees
    • User receives nothing
  • Removes seat and clears position
  • Removes from seatHolders array

Emits: FeeDistributed(uint256 toRecipient, uint256 burned)


kick

Liquidate an unhealthy position.

function kick(address user) external nonReentrant
Parameters:
NameTypeDescription
useraddressAddress to liquidate
Requirements:
  • Target must have a seat
  • Target must be unhealthy: debt > collateral
Behavior:
  • Accrues fees to current timestamp
  • Seizes all collateral
  • Distributes collateral as fees (burn + recipient)
  • Removes seat and clears position
  • Removes from seatHolders array

Emits: SeatKicked(address indexed user, address indexed kicker, uint256 collateralSeized, uint256 debtValue)


View Functions

isActive

Check if user has a healthy seat (for API gating).

function isActive(address user) external view returns (bool)

Returns: true if user has a seat AND collateral >= debt

Use Case: Backend access control systems should call this to verify access.


isHealthy

Check if a position is healthy.

function isHealthy(address user) public view returns (bool)

Returns: true if collateral >= debt


debtValueOf

Get current debt including pending (unaccrued) fees.

function debtValueOf(address user) public view returns (uint256)

Returns: settledDebt + (cumulativeFeePerSeatView() - feeIndexSnapshot)


utilizationWad

Get current utilization rate.

function utilizationWad() public view returns (uint256)

Returns: (occupiedSeats * WAD) / maxSeats


feePerSecond

Get current fee rate per second.

function feePerSecond() public view returns (uint256)

Returns: minFeePerSecond + (maxFeePerSecond - minFeePerSecond) * utilization / WAD


feePerDay

Get current daily fee rate.

function feePerDay() external view returns (uint256)

Returns: feePerSecond() * 86400


feePerYear

Get current annual fee rate.

function feePerYear() external view returns (uint256)

Returns: feePerSecond() * 31536000


minDepositForSeat

Get minimum deposit required for a new seat.

function minDepositForSeat() public view returns (uint256)

Returns: Minimum collateral needed (typically 1 day of maximum fees)


getHealthySeats

Get array of all healthy seat holder addresses.

function getHealthySeats() external view returns (address[] memory)

Returns: Array of addresses with isActive(addr) == true

Note: May be gas-intensive for large seat counts. Use for off-chain queries.


cumulativeFeePerSeatView

Get cumulative fee index including pending accruals.

function cumulativeFeePerSeatView() public view returns (uint256)

Returns: cumulativeFeePerSeat + (feePerSecond() * timeSinceLastAccrual)


positions

Get position data for a user.

function positions(address user) external view returns (Position memory)
Returns:
struct Position {
    bool hasSeat;
    uint256 collateral;
    uint256 settledDebt;
    uint256 feeIndexSnapshot;
}

Admin Functions

setParams

Update market parameters.

function setParams(
    uint256 _maxSeats,
    uint256 _minFeePerSecond,
    uint256 _maxFeePerSecond,
    address _feeRecipient,
    uint256 _burnBps
) external onlyOwner
Parameters:
NameTypeDescription
_maxSeatsuint256New maximum seats
_minFeePerSeconduint256New minimum fee rate
_maxFeePerSeconduint256New maximum fee rate
_feeRecipientaddressNew fee recipient
_burnBpsuint256New burn rate (0-10000 BPS)
Requirements:
  • _maxSeats >= occupiedSeats
  • _minFeePerSecond <= _maxFeePerSecond
  • _burnBps <= 10000
  • _feeRecipient != address(0)

Emits: ParamsUpdated(uint256 maxSeats, uint256 minFeePerSecond, uint256 maxFeePerSecond, address feeRecipient, uint256 burnBps)


transferOwnership

Transfer contract ownership.

function transferOwnership(address newOwner) external onlyOwner
Parameters:
NameTypeDescription
newOwneraddressNew owner address
Requirements:
  • newOwner != address(0)

Error Conditions

ErrorCondition
AlreadyHasSeatUser already has a seat
NoSeatUser does not have a seat
MarketFullAll seats are occupied
InsufficientDepositDeposit below minimum
WouldBecomeUnhealthyAction would make position unhealthy
CannotKickHealthyTarget position is healthy
RepaymentExceedsDebtRepay amount exceeds current debt
InvalidParamsInvalid admin parameters