# wHLP Builder Codes

### Product Overview

**wHLP** is a tokenized wrapper of HyperLiquidity Provider (HLP). Users mint wHLP and earn HLP trading fees while keeping full DeFi composability on HyperEVM. Integrators earn fees for every deposit attributed to their unique `communityCode`. For CommunityCode flow, **deposits are in USDT0**.<br>

If you plan to integrate wHLP, 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>wHLP (ERC-20)</strong></td><td><a href="https://hyperevmscan.io/address/0x1359b05241cA5076c9F59605214f4F84114c0dE8">0x1359b05241cA5076c9F59605214f4F84114c0dE8</a></td><td>The ERC20 token and the BoringVault contract that that accrues HLP yield</td></tr><tr><td><strong>Accountant</strong></td><td><a href="https://hyperevmscan.io/address/0x470bd109A24f608590d85fc1f5a4B6e625E8bDfF">0x470bd109A24f608590d85fc1f5a4B6e625E8bDfF</a></td><td>Returns current exchange rate for wHLP ↔ USDT0 derivatives</td></tr><tr><td><strong>Depositor</strong></td><td><a href="https://hyperevmscan.io/address/0x340C9f6159ABc2bdfCC0E2b9Fe91D739006b41c1">0x340C9f6159ABc2bdfCC0E2b9Fe91D739006b41c1</a></td><td>Entry point for <strong>community-code</strong> deposits</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>USDT0 (ERC‑20)</strong></td><td><a href="https://hyperevmscan.io/token/0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb">0xb8ce59fc3717ada4c02eadf9682a9e934f625ebb</a></td><td>Hyper USD token</td></tr></tbody></table>

### Deposit Flow

#### ERC‑20 Deposits (USDT0)

The **CommunityCodeDepositor** exposes a single `deposit` function. The **accepted** deposit asset for this flow is **USDT0**.

```typescript
USDT0.approve(COMMUNITY_CODE_DEPOSITOR, 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: <estimate>
}
```

<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 (USDT0)</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 wHLP 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 wHLP</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 wHLP 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(WHLP_EXCHANGE_RATE)
```

* `WHLP_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(USDTO);
```

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 redeem wHLP back to **USDT0**, submit/modify a request via the **Atomic Queue** (UCP). Solvers process requests periodically.

```typescript
WHLP.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(WHLP_EXCHANGE_RATE)

const args = [
    WHLP,
    USDT0,
    [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: <estimate>
}
```

| Parameter     | Type      | Description                                                                           |
| ------------- | --------- | ------------------------------------------------------------------------------------- |
| `offer`       | `address` | Asset to withdraw from (wHLP)                                                         |
| `want`        | `address` | Desired asset (USDT0)                                                                 |
| `deadline`    | `uint64`  | Unix timestamp after which the request expires                                        |
| `atomicPrice` | `uint88`  | Solver price quote                                                                    |
| `offerAmount` | `uint96`  | Amount of wHLP 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=0x1359b05241cA5076c9F59605214f4F84114c0dE8
  &user=0xYourUserAddress
  &status=all
  &all=true
```

* **Cancel an existing request** by revoking wHLP 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/whlp">https://app.loopingcollective.org/api/external/asset/whlp</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/whlp">https://app.loopingcollective.org/api/external/asset/whlp</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=0x1359b05241cA5076c9F59605214f4F84114c0dE8">https://backend.nucleusearn.io/v1/vaults/underlying_strategies?vault_address=0x1359b05241cA5076c9F59605214f4F84114c0dE8</a></td><td>various</td></tr><tr><td><strong>Exchange Rate</strong></td><td><a href="https://app.loopingcollective.org/api/external/asset/whlp">https://app.loopingcollective.org/api/external/asset/whlp</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)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.loopingcollective.org/get-started/whlp-builder-codes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
