> ## Documentation Index
> Fetch the complete documentation index at: https://docs.kas.fun/llms.txt
> Use this file to discover all available pages before exploring further.

# BondingCurve

> BondingCurve contract ABI reference

## Contract Info

| Property | Value |
| - | - |
| **Address** | Read from `MemeFactory.bondingCurve()` (see [Addresses](https://docs.kas.fun/contracts/addresses.md) for MemeFactory address) |
| **Network** | Kasplex (see [Addresses](https://docs.kas.fun/contracts/addresses.md) for chain details) |

> [!TIP]
>
> All calculation functions are `pure` — they don't read or modify state. You can call them off-chain for gas-free price quotes.

## Functions

### calculateBuyReturnWithParams

Calculate how many tokens you get for a given KAS amount.

```solidity theme={null}
function calculateBuyReturnWithParams(
    uint256 kasIn,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 tokensOut)
```

| Parameter | Type | Description |
| - | - | - |
| `kasIn` | uint256 | KAS amount to spend (wei) |
| `tokenReserves` | uint256 | Current token reserves from `getTokenInfo()` |
| `kasReserves` | uint256 | Current KAS reserves from `getTokenInfo()` |
| `vToken` | uint256 | Virtual token from `getTokenParamVersion()` |
| `vKas` | uint256 | Virtual KAS from `getTokenParamVersion()` |

***

### calculateSellReturnWithParams

Calculate how much KAS you get for selling tokens.

```solidity theme={null}
function calculateSellReturnWithParams(
    uint256 tokensIn,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 kasOut)
```

| Parameter | Type | Description |
| - | - | - |
| `tokensIn` | uint256 | Token amount to sell (wei) |
| `tokenReserves` | uint256 | Current token reserves from `getTokenInfo()` |
| `kasReserves` | uint256 | Current KAS reserves from `getTokenInfo()` |
| `vToken` | uint256 | Virtual token from `getTokenParamVersion()` |
| `vKas` | uint256 | Virtual KAS from `getTokenParamVersion()` |

***

### calculateBuyCostWithParams

Calculate how much KAS you need to get a desired amount of tokens.

```solidity theme={null}
function calculateBuyCostWithParams(
    uint256 tokensOut,
    uint256 tokenReserves,
    uint256 kasReserves,
    uint256 vToken,
    uint256 vKas
) external pure returns (uint256 kasIn)
```

| Parameter | Type | Description |
| - | - | - |
| `tokensOut` | uint256 | Desired token amount (wei) |
| `tokenReserves` | uint256 | Current token reserves from `getTokenInfo()` |
| `kasReserves` | uint256 | Current KAS reserves from `getTokenInfo()` |
| `vToken` | uint256 | Virtual token from `getTokenParamVersion()` |
| `vKas` | uint256 | Virtual KAS from `getTokenParamVersion()` |

***

### getCurrentPrice

Get the current spot price.

```solidity theme={null}
function getCurrentPrice(
    uint256 tokenReserves,
    uint256 kasReserves
) external view returns (uint256 price)
```

***

### virtualToken / virtualKas

```solidity theme={null}
function virtualToken() external view returns (uint256)
function virtualKas() external view returns (uint256)
```

Default virtual reserves configured in the BondingCurve contract. Note: individual tokens may use different values via `getTokenParamVersion()`.

***

### curveType

```solidity theme={null}
function curveType() external view returns (uint256)
```

Returns the curve type identifier.

***

## Full ABI (JSON)

> [accordion] BondingCurve ABI JSON
>
> ```json theme={null}
> [
>   {
>     "inputs": [{"internalType": "uint256", "name": "kasIn", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
>     "name": "calculateBuyReturnWithParams",
>     "outputs": [{"internalType": "uint256", "name": "tokensOut", "type": "uint256"}],
>     "stateMutability": "pure",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "uint256", "name": "tokensOut", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
>     "name": "calculateBuyCostWithParams",
>     "outputs": [{"internalType": "uint256", "name": "kasIn", "type": "uint256"}],
>     "stateMutability": "pure",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "uint256", "name": "tokensIn", "type": "uint256"}, {"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}, {"internalType": "uint256", "name": "vToken", "type": "uint256"}, {"internalType": "uint256", "name": "vKas", "type": "uint256"}],
>     "name": "calculateSellReturnWithParams",
>     "outputs": [{"internalType": "uint256", "name": "kasOut", "type": "uint256"}],
>     "stateMutability": "pure",
>     "type": "function"
>   },
>   {
>     "inputs": [{"internalType": "uint256", "name": "tokenReserves", "type": "uint256"}, {"internalType": "uint256", "name": "kasReserves", "type": "uint256"}],
>     "name": "getCurrentPrice",
>     "outputs": [{"internalType": "uint256", "name": "price", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "virtualToken",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "virtualKas",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   },
>   {
>     "inputs": [],
>     "name": "curveType",
>     "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}],
>     "stateMutability": "view",
>     "type": "function"
>   }
> ]
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.