Skip to main content
GET
/
market
/
{marketAddress}
/
usdToTokens
Calculate USD to tokens conversion
curl --request GET \
  --url https://mainnet.base.org/market/{marketAddress}/usdToTokens
{
  "tokensIn": 123,
  "tokensOut": 123,
  "protocolFeeAmount": 123,
  "creatorFeeAmount": 123
}
This is a smart contract view function. The curl example shown is for illustration. To call this function, use web3 libraries (ethers.js, viem, web3.py) or JSON-RPC directly.

Path Parameters

marketAddress
string
required

Address of the market contract

Query Parameters

amountIn
integer
required

USD amount to convert

Required range: x >= 1
buyBased
boolean
required

True if buying Based, false if buying Cringe

Response

200 - application/json

Conversion calculated successfully

tokensIn
integer

Tokens deposited to AMM

tokensOut
integer

Tokens received from AMM

protocolFeeAmount
integer

Protocol fee amount

creatorFeeAmount
integer

Creator fee amount

I