Builder codes

A comprehensive guide for developers looking to integrate beHYPE staking and unstaking functionality into their applications.

Overview

beHYPE is a liquid staking token that represents staked HYPE tokens. Users can stake HYPE to receive beHYPE tokens, which continue to earn staking rewards while remaining liquid and transferable.

Contract Addresses

BeHYPE: 0xd8FC8F0b03eBA61F64D08B0bef69d80916E5DdA9
WithdrawManager: 0x9d0B0877b9f2204CF414Ca7862E4f03506822538
StakingCore: 0xCeaD893b162D38e714D82d06a7fe0b0dc3c38E0b
RoleRegistry: 0x90102473a816A01A9fB0809F2289438B2e294F76
BeHYPETimelock: 0xA24aF73EaDD17997EeEdbEd36672e996544D2DE4
L1Read: 0xb7467E0524Afba7006957701d1F06A59000d15A2

Minting (Staking)

Send a transaction to the StakingCore contract with the function signature stake(string communityCode). The communityCode is the validator name you want those tokens to be designated to. The amount minted will be the amount of HYPE included in the value of the transaction. If you do not have a specific validator to stake to, you can pass an empty string ("") for automatic distribution across validators.

This will mint beHYPE tokens to the caller's address.

function Stake() public {
    address user = address(0x1234);
    vm.deal(user, 10 ether);

    vm.startPrank(user); // using the private key of the user
    
    // Stake 10 HYPE to a specific validator
    stakingCore.stake{value: 10 ether}("validator_name");
    
    // Stake another 10 HYPE with automatic validator distribution
    stakingCore.stake{value: 10 ether}("");
}

Minting (Staking)

Send a transaction to the StakingCore contract with the function signature stake(string communityCode). The communityCode is the validator name you want those tokens to be designated to. The amount minted will be the amount of HYPE included in the value of the transaction. If you do not have a specific validator to stake to, you can pass an empty string ("") for automatic distribution across validators.

This will mint beHYPE tokens to the caller's address.

function Stake() public {
    address user = address(0x1234);
    vm.deal(user, 10 ether);

    vm.startPrank(user); // using the private key of the user
    
    // Stake 10 HYPE to a specific validator
    stakingCore.stake{value: 10 ether}("validator_name");
    
    // Stake another 10 HYPE with automatic validator distribution
    stakingCore.stake{value: 10 ether}("");
}

Burning (Unstaking)

Burning is a multistep process that depends on the amount of free (unstaked) tokens available in the protocol. There will typically always be a small float of the total supply unstaked to instantly fulfill burns, but for large amounts or high outflow volume, it becomes a two-step process.

Step 1: Approve the WithdrawManager contract with the amount of beHYPE tokens you want to unstake.

Step 2: Call withdraw(uint256 beHypeAmount, bool instant, uint256 minAmountOut) to burn beHypeAmount of tokens. The redeemed HYPE will be processed based on the instant parameter:

  • instant = false: Normal withdrawal (7-day processing, no fee)

  • instant = true: Instant withdrawal (0.5% fee applied)

The minAmountOut parameter provides slippage protection. This function returns a withdrawalId which will be used to claim the withdrawal once processed.

Step 3: For normal withdrawals, wait for processing time, then call claimWithdrawal(uint256 withdrawalId) to receive your HYPE tokens.

function Burn() public {
    uint256 decimals = 10 ** 18;
    address user = address(0x1234); // set up with a balance of 10 beHYPE
    vm.startPrank(user);
    
    // 1. Approve 10 beHYPE (18 decimals)
    behype.approve(withdrawManager, 10 * decimals); 

    // 2. Normal withdrawal (7-day processing, no fee)
    uint256 minAmountOut = 9.9 ether; // 1% slippage tolerance
    uint256 withdrawalId = withdrawManager.withdraw(10 * decimals, false, minAmountOut);
    
    // 3. Wait for processing time (7 days)
    // ...
    
    // 4. Claim the withdrawal
    withdrawManager.claimWithdrawal(withdrawalId);
    require(user.balance >= 9.9 ether, "user should have received HYPE");
}

Instant Redemption

For immediate access to HYPE, you can use instant redemption with a 0.5% fee:

function InstantBurn() public {
    uint256 decimals = 10 ** 18;
    address user = address(0x1234); // set up with a balance of 10 beHYPE
    vm.startPrank(user);
    
    // 1. Approve 10 beHYPE
    behype.approve(withdrawManager, 10 * decimals);
    
    // 2. Instant withdrawal (immediate, 0.5% fee)
    uint256 minAmountOut = 9.4 ether; // accounting for 0.5% fee + slippage
    withdrawManager.withdraw(10 * decimals, true, minAmountOut);
    
    // Tokens are received immediately
    require(user.balance >= 9.4 ether, "user should have received HYPE instantly");
}

API Endpoints

Base URL

https://api.hyperbeat.org/api/v1/behype/

Available Endpoints

  1. Get beHYPE Balance

    • GET /balance/{user_address}

    • Returns user's beHYPE balance

  2. Get Exchange Ratio Updates

    • GET /exchange-ratio-update

    • Returns latest exchange ratio between beHYPE and HYPE

  3. Get TVL Data

    • GET /tvl

    • Returns total value locked, exchange ratio, and price information

Function Signatures

StakingCore Contract

// Stake HYPE to receive beHYPE
function stake(string calldata communityCode) external payable;

WithdrawManager Contract

// Withdraw beHYPE for HYPE (returns withdrawal ID)
function withdraw(uint256 beHypeAmount, bool instant, uint256 minAmountOut) 
    external returns (uint256 withdrawalId);

// Claim completed withdrawal
function claimWithdrawal(uint256 withdrawalId) external;

BeHYPE Token Contract (ERC20)

// Standard ERC20 functions
function balanceOf(address account) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);

Support

For additional support or questions about beHYPE integration, ask us on discord or contact the development team.

Last updated