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.

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.

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.

circle-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.

Last updated