🌳
Bonsai Docs
  • Introduction
    • Bonsai
    • What is Smart Media?
  • Platform
    • No-code creator studio
    • Guide: Create a post
  • Smart Media
    • Framework for builders
  • Building Smart Media
    • ElizaOS server setup
    • Bonsai Client
    • Templates
  • Guide: Create a Template
  • Client Integrations
    • Showing whether a post is Smart Media
    • Linking to Bonsai for remixes
    • Creating a smart media post
  • Actions
    • Reward Swap
  • Launchpad
    • Overview
    • Getting Started
    • Launchpad Contract
    • Vesting ERC20 Contract
    • Hooks
    • API
      • Tokens
      • Token Balances
      • Buy / Sell Quotes
      • Link your token to a Lens Post & Account
  • ElizaOS
    • plugin-bonsai-launchpad
    • client-lens
Powered by GitBook
On this page
  • Buy quote
  • Sell quote
  1. Launchpad
  2. API

Buy / Sell Quotes

PreviousToken BalancesNextLink your token to a Lens Post & Account

Last updated 2 months ago

We use the term clubs and tokens interchangeably. We will migrate to using tokens in the future.

Queries Lens Chain tokens by default. Include query param chain=base for Base tokens.

Buy quote

If a user wishes to buy $100 (USDC) of a given token, the client can use this API to show the amountOut of tokens the user will receive.

GET

Param
Type
Required
Description

clubId

string

true

club.clubId

tokenAddress

0x${string}

true

club.tokenAddress

senderAddress

0x${string}

true

sender account

amountIn

string

true

USDC amount to spend (in decimals)

clientAddress

0x${string}

false

the client to receive a fee

referralAddress

0x${string}

false

the referrer to receive a fee

recipientAddress

0x${string}

false

the recipient of tokens (if not the senderAddress)

{
    "to": "0xb43a85C7369FA6535abCbBB9Da71f8eDCE067E03",
    "amountOut": "5240243000000000000000000",
    "maxAmountIn": "105000000",
    "rawData": {
        "to": "0xb43a85C7369FA6535abCbBB9Da71f8eDCE067E03",
        "data": "0x5753ae9a00000000000000000000000000000000000000000000000000000000000000d20000000000000000000000000000000000000000000455aa246a56acbeec00000000000000000000000000000000000000000000000000000000000006422c40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
        "chainId": 8453,
        "type": "eip1559",
        "maxPriorityFeePerGas": "1000000",
        "maxFeePerGas": "3579090",
        "gasLimit": "116616"
    }
}

The response object contains the following params

Param
Description

to

The BonsaiLaunchpad contract address to send the buy transaction to

amountOut

The amount of tokens (in wei) the user will receive

maxAmountIn

The maximum amount of USDC the user will spend (with 5% slippage)

rawData

Prepared transaction data to send to the BonsaiLaunchpad This param will be null if the transaction would revert, which means the senderAddress either has no funds or has not approved the swap beforehand.

Sell quote

If a user wishes to sell their tokens, the client can use this API to show the amountOut of tokens the user will receive.

Param
Type
Required
Description

clubId

string

true

club.clubId

senderAddress

0x${string}

true

sender account

amountIn

string

true

token amount to spend (in decimals)

clientAddress

0x${string}

false

the client to receive a fee

{
    "to": "0xb43a85C7369FA6535abCbBB9Da71f8eDCE067E03",
    "amountOut": "137561667",
    "minAmountOut": "130683583",
    "rawData": {
        "to": "0xb43a85C7369FA6535abCbBB9Da71f8eDCE067E03",
        "data": "0x7ed2479500000000000000000000000000000000000000000000000000000000000000d2000000000000000000000000000000000000000000067a9ec8d0fc5b9bbdd6000000000000000000000000000000000000000000000000000000000007ca12bf0000000000000000000000000000000000000000000000000000000000000000",
        "chainId": 8453,
        "type": "eip1559",
        "maxPriorityFeePerGas": "1000000",
        "maxFeePerGas": "3536005",
        "gasLimit": "110881"
    }
}

The response object contains the following params

Param
Description

to

The BonsaiLaunchpad contract address to send the sell transaction to

amountOut

The amount of USDC (in wei) the user will receive

minAmountOut

The minimum amount of USDC the user will receive (with 5% slippage)

rawData

Prepared transaction data to send to the BonsaiLaunchpad This param will be null if the transaction would revert, which means the senderAddress either has no tokens or has not approved the swap beforehand.

GET

ℹ️
ℹ️
https://app.onbons.ai/api/clubs/get-quote-buy?clubId=210&tokenAddress=0x9d8a5f45778825e58361afef815bd8eb90e9b5fc&amountIn=100&senderAddress={sender}
https://app.onbons.ai/api/clubs/get-quote-sell?clubId=210&amountIn=7832612.684504591&senderAddress={sender}