> For the complete documentation index, see [llms.txt](https://docs.bounce.tech/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bounce.tech/technical/integration-guide.md).

# Integration Guide

Below is a high level guide on how to integrate with the Bounce Tech Protocol. It covers useful tools and frameworks, and some general details on primary functions.

#### Tools & Links

* [Bounce Tech npm Package](https://github.com/bounce-tech/bounce-npm) (useful for TypeScript based integrations)
* [Bounce Tech Data API](https://api.bounce.tech/docs) (useful for querying Bounce Tech data and PnL)
* [Bounce Tech WebSocket API](https://ws.bounce.tech/docs) (useful for subscribing to the live price feed)
* [Bounce Tech Smart Contracts](https://github.com/bounce-tech/bounce-smart-contracts) (useful for understanding code in more detail)

#### Useful Contract Views

* `factory.lts()` query the contract addresses for all Leveraged Tokens
* `leveragedToken.targetAsset()` the target asset of the leveraged token, e.g. BTC, HYPE
* `leveragedToken.targetLeverage()` the taget leverage of the leveraged token, e.g. 2, 5
* `leveragedToken.isLong()` the direction of the leveraged token, `true` for long and `false` for short
* `leveragedToken.exchangeRate()` the exchange rate from one leveraged token to one USDC. So `usdcValue = ltAmount * exchangeRate` . Essentially a live oracle that updates every block for the value of a leveraged token.
* `leveragedToken.totalAssets()` the total amount of USDC in the leveraged token, including USDC used as margin on Hyperliquid and idle USDC in the leveraged token. Essentially the TVL of the leveraged token.
* `leveragedToken.baseAssetBalance()` the amount of idle USDC in the leveraged token. Essentially `usdc.balanceOf(leveragedTokenAddress)`.

#### Mint and Redeem Flow

The primary function for minting is `mint(address to_, uint256 baseAmount_, uint256 minOut_)`. `to` is what address you want the leveraged tokens sent to, usually this will be yourself. `baseAmount` is the amount of USDC you want to mint with. And `minOut` is the minimum amount of leveraged tokens you want to receive (to protect against slippage). This function is on the Leveraged Token contract, so you will first need to identify what leveraged token you want to mint. And before minting you will need to approve the Leveraged Token to spend your USDC.

There are two redeem flows. The atomic redeem flow, and the async redeem flow. The atomic redeem flow can be used when the amount of USDC you are redeeming is less than or equal to the amount of available USDC in the Leveraged Token contract. To get the amount of USDC in the contract you can call `usdc.balanceOf(leveragedTokenAddress)` or `leveragedToken.baseAssetBalance()` (which is just a wrapper for the same thing).

To atomic redeem, you can call `redeem(address to_, uint256 ltAmount_, uint256 minBaseAmount_)`. This will return your USDC to you within the transaction and is fully atomic.&#x20;

For async redemptions, you can call `prepareRedeem(uint256 ltAmount_)` which will take your Leveraged Token balance atomically. But you will be sent your USDC around 10 seconds later. If this complicates your integration, you can instead opt to always use the atomic redeem, and can break redeems down into smaller steps. Each time an atomic redeem is done, the idle balance of funds in the Leveraged Token contract is replenished, so you can do another atomic redemption shortly after.

#### Leveraged Token Helper

The Leveraged Token Helper is a contract that sits outside of the core protocol. It exposes some useful views that allow for querying data about the leveraged tokens more conveniently and quickly. This may be useful for your integration to find the available leveraged tokens and to assist with basic accounting logic. Using the Leveraged Token Helper views, combined with the Mint and Redeem flow above, should provide the core toolkit for most integrations.

{% hint style="info" %}
The Leveraged Token Helper is only lightly audited, and considered outside of the scope of the core protocol. Use it at your own risk and verify functionality is what you expect.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.bounce.tech/technical/integration-guide.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
