# abis

Copy-paste ABI fragments for the three main contracts. These match the verified source on Kubscan — compatible with `ethers`, `viem`, `web3.js`, `wagmi`, etc.

## Factory (V4.5)

```javascript
const FACTORY_ABI = [
  // View
  "function NAME() view returns (string)",
  "function totalTokens() view returns (uint256)",
  "function treasury() view returns (address)",
  "function treasuryFeePpm() view returns (uint256)",
  "function creatorFeePpm() view returns (uint256)",
  "function CREATE_COST() view returns (uint256)",
  "function MAX_FEE_PPM() view returns (uint256)",
  "function paused() view returns (bool)",
  "function owner() view returns (address)",
  "function getTokens(uint256 offset, uint256 limit) view returns (tuple(address token, address market, address creator, string name, string symbol, uint256 totalSupply, uint256 createdAt)[])",
  "function getTokenInfo(address token) view returns (tuple(address token, address market, address creator, string name, string symbol, uint256 totalSupply, uint256 createdAt))",
  "function getAmmPool(address token) view returns (address)",
  // Write
  "function createToken(string name, string symbol, string imageUrl) payable returns (address tokenAddr, address marketAddr)",
  // Events
  "event TokenCreated(address indexed token, address indexed market, address indexed creator, string name, string symbol, uint256 totalSupply, uint256 timestamp)",
];
```

## BondingCurveMarket (V4.5)

```javascript
const BONDING_CURVE_ABI = [
  // State
  "function token() view returns (address)",
  "function treasury() view returns (address)",
  "function creator() view returns (address)",
  "function treasuryFeePpm() view returns (uint256)",
  "function creatorFeePpm() view returns (uint256)",
  "function kubRaised() view returns (uint256)",
  "function tokensSold() view returns (uint256)",
  "function graduated() view returns (bool)",
  "function ammPool() view returns (address)",
  "function totalFeeCollected() view returns (uint256)",
  // View helpers
  "function currentPricePerToken() view returns (uint256)",
  "function getTokensOut(uint256 kubIn) view returns (uint256)",
  "function getKubOut(uint256 tokenIn) view returns (uint256)",
  "function graduationProgress() view returns (uint256)",
  "function bondingTokensRemaining() view returns (uint256)",
  // Write
  "function buyToken(uint256 minTokensOut) payable",
  "function sellToken(uint256 tokenAmountIn, uint256 minKubOut)",
  // Events
  "event TokensBought(address indexed buyer, uint256 kubIn, uint256 tokensOut, uint256 fee, uint256 newKubRaised, uint256 price)",
  "event TokensSold(address indexed seller, uint256 tokensIn, uint256 kubOut, uint256 fee, uint256 newKubRaised, uint256 price)",
  "event Graduated(address indexed market, address indexed token, address indexed ammPool, uint256 kubRaised, uint256 treasuryFee, uint256 creatorReward)",
  "event BuyRefunded(address indexed buyer, uint256 kubIn, uint256 actualUsed, uint256 refunded)",
];
```

## DurianAMM (V4.5, post-graduation)

```javascript
const AMM_ABI = [
  // State
  "function market() view returns (address)",
  "function token() view returns (address)",
  "function treasury() view returns (address)",
  "function creator() view returns (address)",
  "function reserveKub() view returns (uint256)",
  "function reserveToken() view returns (uint256)",
  "function totalFeeCollected() view returns (uint256)",
  "function initialized() view returns (bool)",
  "function initializedAtBlock() view returns (uint256)",
  // Fee constants (hardcoded — cannot change)
  "function TREASURY_FEE_PPM() view returns (uint256)", // 3000 (0.30%)
  "function LP_FEE_PPM() view returns (uint256)",       // 1000 (0.10%)
  "function TOTAL_FEE_PPM() view returns (uint256)",    // 4000 (0.40%)
  "function COOLDOWN_BLOCKS() view returns (uint256)",  // 10
  // View helpers
  "function currentPrice() view returns (uint256)",
  "function getTokensOut(uint256 kubIn) view returns (uint256)",
  "function getKubOut(uint256 tokenIn) view returns (uint256)",
  "function isCooldownActive() view returns (bool)",
  "function cooldownBlocksLeft() view returns (uint256)",
  // Write
  "function swapKubForToken(uint256 minTokensOut) payable",
  "function swapTokenForKub(uint256 tokenAmountIn, uint256 minKubOut)",
  // Events
  "event Swapped(address indexed trader, bool indexed kubForToken, uint256 amountIn, uint256 amountOut, uint256 fee, uint256 newReserveKub, uint256 newReserveToken)",
  "event Initialized(uint256 reserveKub, uint256 reserveToken)",
];
```

## DurianToken (ERC-20)

Standard ERC-20 plus 3 public getters:

```javascript
const TOKEN_ABI = [
  // Standard ERC-20
  "function name() view returns (string)",
  "function symbol() view returns (string)",
  "function decimals() view returns (uint8)",
  "function totalSupply() view returns (uint256)",
  "function balanceOf(address) view returns (uint256)",
  "function allowance(address owner, address spender) view returns (uint256)",
  "function approve(address spender, uint256 amount) returns (bool)",
  "function transfer(address to, uint256 amount) returns (bool)",
  "function transferFrom(address from, address to, uint256 amount) returns (bool)",
  "event Transfer(address indexed from, address indexed to, uint256 value)",
  "event Approval(address indexed owner, address indexed spender, uint256 value)",
  // Durian extras
  "function market() view returns (address)",
  "function creator() view returns (address)",
  "function imageUrl() view returns (string)",
  "function TOTAL_SUPPLY() view returns (uint256)",
];
```

## Network constants

```javascript
const KUB_MAINNET = {
  chainId: 96,
  rpcUrl: "https://rpc.bitkubchain.io",
  explorer: "https://www.kubscan.com",
  currency: "KUB",
};

const FACTORY_ADDRESSES = {
  mainV45:     "0xdf4f3dB298A9aDe853191F58b4b2a322D47EC005",
  testV25:     "0xa1000BB39f36a630F1AB1b245B25Ca75a6744Aa5",
  legacyV42:   "0xeadEc9dA89F97Ae6215362EBA4B33F3F1d1775b2",
  legacyD242:  "0x96D0117DE988C20f4E4D4B27b46351D760b99D97",
};
```

## Downloadable JSON ABIs

Full JSON ABIs (for tools like Foundry, Hardhat, cast) are available via Kubscan:

* [Factory V4.5 ABI](https://www.kubscan.com/address/0xdf4f3dB298A9aDe853191F58b4b2a322D47EC005#code) → Contract ABI tab
* [Factory-D V2.5 ABI](https://www.kubscan.com/address/0xa1000BB39f36a630F1AB1b245B25Ca75a6744Aa5#code)

Or pull programmatically from Kubscan's API (standard Etherscan-compatible).


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://durianandfun.gitbook.io/durianfun/durian-launchpad/integration/abis.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
