# LHYPE Builder Codes

### Product Overview

LoopedHYPE (LHYPE) is a yield‑optimizing protocol that loops staking positions on HYPE tokens. Integrators earn fees for every deposit bridged through their unique community code. Users deposit HYPE (native) or HYPE staking tokens (WHYPE, STHYPE, KHYPE) and receive LHYPE tokens that accrue yield over time.

Key benefits:

* **Maximized yield** via automated looping strategies
* **Revenue sharing** through `communityCode` attribution
* **Composable token** compatible with DeFi platforms<br>

If you plan to integrate LHYPE, get in touch with the Looping Collective team on Telegram [**@loopingcollective**](tg://resolve?domain=loopingcollective) to further discuss reward options.

### Contract Addresses

<table><thead><tr><th width="180.87109375">Contract</th><th width="263.078125">Address</th><th>Description</th></tr></thead><tbody><tr><td><strong>LHYPE (ERC-20)</strong></td><td><a href="https://hyperevmscan.io/address/0x5748ae796AE46A4F1348a1693de4b50560485562#code">0x5748ae796AE46A4F1348a1693de4b50560485562</a></td><td>The ERC20 token and the BoringVault contract that custodies the underlying HYPE and staking positions.</td></tr><tr><td><strong>Accountant</strong></td><td><a href="https://hyperevmscan.io/address/0xcE621a3CA6F72706678cFF0572ae8d15e5F001c3#code">0xcE621a3CA6F72706678cFF0572ae8d15e5F001c3</a></td><td>Returns current exchange rate for LHYPE ↔ HYPE derivatives</td></tr><tr><td><strong>Depositor</strong></td><td><a href="https://hyperevmscan.io/address/0x6e358dd1204c3fb1D24e569DF0899f48faBE5337#code">0x6e358dd1204c3fb1D24e569DF0899f48faBE5337</a></td><td>Entry point for all deposit operations</td></tr><tr><td><strong>Atomic Queue</strong></td><td><a href="https://hyperevmscan.io/address/0x228C44Bb4885C6633F4b6C83f14622f37D5112E5#code">0x228C44Bb4885C6633F4b6C83f14622f37D5112</a></td><td>Manages the withdrawal request queue</td></tr></tbody></table>

<table><thead><tr><th width="181.17578125">Contract</th><th width="261.54296875">Address</th><th>Description</th></tr></thead><tbody><tr><td><strong>WHYPE (ERC‑20)</strong></td><td><a href="https://hyperevmscan.io/address/0x5555555555555555555555555555555555555555#code">0x5555555555555555555555555555555555555555</a></td><td>Wrapped HYPE token</td></tr><tr><td><strong>STHYPE (ERC‑20)</strong></td><td><a href="https://hyperevmscan.io/address/0xfFaa4a3D97fE9107Cef8a3F48c069F577Ff76cC1#code">0xfFaa4a3D97fE9107Cef8a3F48c069F577Ff76cC1</a></td><td>Staked HYPE Liquid Staking Token</td></tr><tr><td><strong>KHYPE (ERC‑20)</strong></td><td><a href="https://hyperevmscan.io/address/0xfD739d4e423301CE9385c1fb8850539D657C296D#code">0xfD739d4e423301CE9385c1fb8850539D657C296D</a></td><td>Kinetica HYPE Liquid Staking Token</td></tr></tbody></table>

### Deposit Flow

#### Native HYPE Deposit

To accept native HYPE, call the `depositNative` function on the Depositor contract:

```typescript
const minimumMint = getQuote(AMOUNT, WHYPE)

const cc = encodeBytes(COMMUNITY_CODE ?? '')

const args = [AMOUNT, minimumMint, ADDRESS, cc]

const writeContractProps = {
    contractAddress: DEPOSIT_CONTRACT,
    accountAddress: ADDRESS,
    value: BigInt(depositAmount),
    abi: DEPOSIT_CONTRACT_ABI as Abi,
    functionName: 'depositNative',
    args,
    gasLimit: 215000n,
}
```

<table><thead><tr><th width="185.5546875">Parameter</th><th width="150.70703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>depositAmount</code></td><td><code>uint256</code></td><td>Amount of native HYPE to deposit</td></tr><tr><td><code>minimumMint</code></td><td><code>uint256</code></td><td>Minimum LHYPE shares to mint, reverts if minimumMint is too high (not enough slippage deduced from: depositAmount / rate)</td></tr><tr><td><code>to</code></td><td><code>address</code></td><td>Address to receive minted LHYPE</td></tr><tr><td><code>communityCode</code></td><td><code>bytes32</code></td><td>Byte‑encoded integrator code</td></tr></tbody></table>

#### ERC‑20 Deposits (WHYPE, STHYPE, KHYPE)

For wrapped or staked HYPE tokens, approve and then call `deposit`:

```typescript
LHYPE.approve(DEPOSIT_CONTRACT, AMOUNT);
```

```ts
const minimumMint = getQuote(AMOUNT, TOKEN_ADDRESS)

const cc = encodeBytes(COMMUNITY_CODE ?? '')

const args = [TOKEN_ADDRESS, AMOUNT, minimumMint, ADDRESS, cc]

const writeContractProps = {
    contractAddress: DEPOSIT_CONTRACT,
    accountAddress: ADDRESS,
    value: 0n,
    abi: DEPOSIT_CONTRACT_ABI,
    functionName: 'deposit',
    args,
    gasLimit: 300000n,
}
```

<table><thead><tr><th width="191.60546875">Parameter</th><th width="133.0703125">Type</th><th>Description</th></tr></thead><tbody><tr><td><code>depositAsset</code></td><td><code>address</code></td><td>ERC‑20 token to deposit (wHYPE | stHYPE | kHYPE)</td></tr><tr><td><code>depositAmount</code></td><td><code>uint256</code></td><td>Amount of token to deposit</td></tr><tr><td><code>minimumMint</code></td><td><code>uint256</code></td><td>Minimum LHYPE shares to mint, reverts if minimumMint is too high (not enough slippage deduced from: depositAmount / rate)</td></tr><tr><td><code>to</code></td><td><code>address</code></td><td>Address to receive minted LHYPE</td></tr><tr><td><code>communityCode</code></td><td><code>bytes32</code></td><td>Byte‑encoded integrator code</td></tr></tbody></table>

#### Minimum Mint Calculation

Compute the minimum number of LHYPE shares to mint, factoring in slippage.

If the calculated minimumMint is too high, the deposit call will fail.

```ts
const maxSlippage = 0.000001
const quote = new BigNumber(AMOUNT)
    .times(new BigNumber(1 - maxSlippage))
    .div(LHYPE_EXCHANGE_RATE)
```

* `LHYPE_EXCHANGE_RATE` is fetched via `Accountant.getRateInQuote(assetAddress)`.
* `maxSlippage` defines your worst acceptable deviation.

### Exchange Rate & Swap vs Mint

Before depositing, you may choose between swapping on a DEX or depositing natively:

```ts
const rate = accountant.getRateInQuote(WHYPE);
```

Decide based on:

1. **Order size** (large orders may incur DEX price impact)
2. **Market rate** vs **native rate** (if on-chain swap is cheaper)

### Withdrawal Flow

**Requesting a Withdrawal**

To request a withdrawal from LHYPE into HYPE derivatives (STHYPE or KHYPE), use the Atomic Queue:

```typescript
LHYPE.approve(ATOMIC_QUEUE_CONTRACT, AMOUNT);
```

```ts
const threeDays = 5 * DAY_IN_SECONDS
const deadline = Math.floor(Date.now() / 1000) + threeDays
const atomicPrice = new BigNumber(1 - MAX_SLIPPAGE).times(LHYPE_EXCHANGE_RATE)

const args = [
    LHYPE,
    STHYPE,
    [deadline, ATOMIC_PRICE, AMOUNT, false],
]

const writeContractProps: WriteContractProps = {
    contractAddress: ATOMIC_QUEUE_CONTRACT,
    accountAddress: ADDRESS,
    value: 0n,
    abi: ATOMIC_QUEUE_CONTRACT_ABI,
    functionName: 'updateAtomicRequest',
    args,
    gasLimit: 40000n,
}
```

| Parameter     | Type      | Description                                                                           |
| ------------- | --------- | ------------------------------------------------------------------------------------- |
| `offer`       | `address` | Asset to withdraw from (LHYPE)                                                        |
| `want`        | `address` | Desired asset (STHYPE or KHYPE)                                                       |
| `deadline`    | `uint64`  | Unix timestamp after which the request expires                                        |
| `atomicPrice` | `uint88`  | Solver price quote                                                                    |
| `offerAmount` | `uint96`  | Amount of LHYPE to redeem                                                             |
| `inSolve`     | `bool`    | Used during solves to prevent duplicate users, and to prevent redoing multiple checks |

* **Solver frequency**: \~10 min
* **Min. delay**: 0 days
* **Expiry period**: configurable by you (e.g. 5 days)

**Querying & Cancelling Requests**

* **Fetch pending/fulfilled/cancelled requests** using the Nucleus API:

```bash
GET https://backend.nucleusearn.io/v1/protocol/withdrawals
  ?chainId=999
  &vaultAddress=0x5748ae796AE46A4F1348a1693de4b50560485562
  &user=0xYourUserAddress
  &status=all
  &all=true
```

* **Cancel an existing request** by revoking LHYPE approval or submitting a new request (automatically cancels prior pending request).

### Data Endpoints

<table><thead><tr><th width="154.4609375">Metric</th><th width="362.328125">Endpoint</th><th>JSON Key</th></tr></thead><tbody><tr><td><strong>APY</strong></td><td><a href="https://app.loopingcollective.org/api/external/asset/lhype">https://app.loopingcollective.org/api/external/asset/lhype</a></td><td><code>reward_rate</code></td></tr><tr><td><strong>TVL</strong></td><td><a href="https://app.loopingcollective.org/api/external/asset/lhype">https://app.loopingcollective.org/api/external/asset/lhype</a></td><td><code>assets_under_management</code></td></tr><tr><td><strong>Strategy</strong></td><td><a href="https://backend.nucleusearn.io/v1/vaults/underlying_strategies?vault_address=0x5748ae796AE46A4F1348a1693de4b50560485562">https://backend.nucleusearn.io/v1/vaults/underlying_strategies?vault_address=0x5748ae796AE46A4F1348a1693de4b50560485562</a></td><td>various</td></tr><tr><td><strong>Exchange Rate</strong></td><td><a href="https://app.loopingcollective.org/api/external/asset/lhype">https://app.loopingcollective.org/api/external/asset/lhype</a></td><td><code>exchange_rate</code></td></tr></tbody></table>

***

### Support

If you need integration help, reach out on Telegram: [**@loopingcollective**](tg://resolve?domain=loopingcollective)
