Files
pumpfun-bonkfun-bot_github/.cursor/rules/idl.mdc
T
2025-07-15 14:33:17 +00:00

90 lines
2.3 KiB
Plaintext

---
description: Program interface definitions for on-chain contract interactions. Apply when working with smart contract integration or program data structures.
globs: idl/*.json
alwaysApply: true
---
# Interface Definition Guide
## Overview
The IDL (Interface Definition Language) files define the structure and interface of on-chain Solana programs. These definitions enable the bot to interact with smart contracts, serialize/deserialize data, and interpret on-chain events correctly.
## Core IDL Files
### Pump Fun IDL
@idl/pump_fun_idl.json contains the core protocol definitions:
- Main pump.fun protocol instruction schemas
- Account structures and data layouts
- Token creation and management instructions
- Event definitions and discriminators
### Pump Swap IDL
@idl/pump_swap_idl.json defines the swap interface:
- Token swap instruction formats
- Liquidity management operations
- Price calculation functions
- Fee structure definitions
### Raydium AMM IDL
@idl/raydium_amm_idl.json provides integration with Raydium:
- AMM pool interface definitions
- Liquidity provider instructions
- Market making operations
- Price discovery mechanisms
## Working with IDLs
IDL files are used throughout the codebase for:
```python
# Example: Using IDLs for instruction building
with open("idl/pump_fun_idl.json", "r") as f:
pump_idl = json.load(f)
# Extract instruction discriminator
discriminator = bytes(pump_idl["instructions"][0]["discriminator"])
```
## IDL Structure
Each IDL file follows this structure:
```json
{
"address": "Program address on chain",
"metadata": {
"name": "Program name",
"version": "Version number"
},
"instructions": [
{
"name": "instructionName",
"discriminator": [byte array],
"accounts": [...],
"args": [...]
}
],
"accounts": [...],
"events": [...]
}
```
## IDL Usage
| Component | Usage |
|-----------|-------|
| Instructions | Building transaction instructions |
| Discriminators | Identifying program events in logs |
| Accounts | Parsing account data |
| Events | Interpreting program-emitted events |
## Related Files
- @idl/pump_fun_idl.json: Main pump.fun protocol definition
- @idl/pump_swap_idl.json: Swap functionality interface
- @idl/raydium_amm_idl.json: Raydium AMM integration