DocsCurrent Page

Anchor IDL Reference


Key accounts and instructions from the DexBotics Anchor program.


Config Account


rust
#[account]
pub struct Config {
    pub authority: Pubkey,
    pub treasury: Pubkey,
    pub fee_bps: u16,
    pub oracle_quorum: u8,
    pub oracle_allowlist: Vec<Pubkey>,
}

The Config account stores global parameters for the protocol including the guardian authority, treasury address, fee basis points, oracle quorum requirements, and the list of allowed oracle nodes.


Task Account


rust
#[account]
pub struct Task {
    pub creator: Pubkey,
    pub task_id: u64,
    pub price_lamports: u64,
    pub collateral_lamports: u64,
    pub deadline_unix: i64,
    pub requirements_hash: [u8; 32],
    pub state: u8, // 0 Open, 1 Assigned, 2 Delivered, 3 Disputed, 4 Settled
    pub assignee_robot: Pubkey,
    pub oracle_quorum: u8,
    pub accepted_oracle_votes: u8,
    pub fee_bps_snapshot: u16,
}

Votes Account


rust
#[account]
pub struct Votes {
    pub task: Pubkey,
    pub proof_hash: [u8; 32],
    pub voters: Vec<Pubkey>,
}

The Votes account tracks oracle attestations for a specific task, including the proof hash and list of oracles that have voted.


Initialize Config


rust
pub fn init_config(
    ctx: Context<InitConfig>,
    fee_bps: u16,
    oracle_quorum: u8,
) -> Result<()>

Accounts:
  • config - Config PDA to initialize
  • treasury - Treasury account for fees
  • authority - Guardian authority (signer)
  • system_program - System program

Description: Initializes the global config account with fee parameters and oracle quorum requirements.

Create Task Instruction


rust
pub fn create_task(
    ctx: Context<CreateTask>,
    price_lamports: u64,
    collateral_lamports: u64,
    deadline_unix: i64,
    requirements_hash: [u8; 32],
) -> Result<()>

Accounts:
  • config - Config account (read-only)
  • task - Task account to initialize
  • escrow_vault - Escrow PDA to hold task payment
  • creator - Task creator (signer)
  • system_program - System program

Description: Creates a new task with escrow, collateral requirements, and deadline.

Accept Task Instruction


rust
pub fn accept_task(
    ctx: Context<AcceptTask>,
    robot_nft: Pubkey,
) -> Result<()>

Accounts:
  • config - Config account
  • task - Task account to update
  • collateral_vault - Collateral PDA to hold robot collateral
  • robot_operator - Robot operator wallet (signer)
  • system_program - System program

Description: Robot operator accepts a task by providing the required collateral. The robot NFT is recorded and the task state changes to Assigned.

Submit Proof Instruction


rust
pub fn submit_proof(
    ctx: Context<SubmitProof>,
    proof_hash: [u8; 32],
) -> Result<()>

Accounts:
  • task - Task account to update
  • votes - Votes PDA to initialize
  • assignee_robot - Assigned robot operator (signer)
  • system_program - System program

Description: The assigned robot submits a proof hash after completing the task. This initializes the voting process for oracles.

Oracle Attest Instruction


rust
pub fn oracle_attest(
    ctx: Context<OracleAttest>,
    verdict: bool, // true = approve, false = reject
) -> Result<()>

Accounts:
  • config - Config account (read-only)
  • task - Task account
  • votes - Votes account
  • escrow_vault - Escrow vault PDA
  • collateral_vault - Collateral vault PDA
  • treasury - Treasury account
  • assignee_robot - Robot operator
  • oracle - Oracle node (signer)
  • system_program - System program

Description: Allowed oracle nodes vote on task completion. Once quorum is reached, funds are automatically settled based on the verdict.

Cancel Task Instruction


rust
pub fn cancel_task(
    ctx: Context<CancelTask>,
) -> Result<()>

Accounts:
  • task - Task account
  • escrow_vault - Escrow vault PDA
  • collateral_vault - Collateral vault PDA
  • creator - Task creator
  • assignee_robot - Robot operator (if assigned)
  • signer - Cancellation initiator (signer)
  • system_program - System program

Description: Cancels a task after the deadline has passed without completion. Refunds are issued to the creator and robot operator based on task state.

Update Config Instruction


rust
pub fn update_config(
    ctx: Context<UpdateConfig>,
    fee_bps: Option<u16>,
    oracle_quorum: Option<u8>,
) -> Result<()>

Accounts:
  • config - Config account to update
  • authority - Guardian authority (signer)

Description: Updates global config parameters. Only the guardian authority can execute this instruction.

Allow Oracle Instruction


rust
pub fn allow_oracle(
    ctx: Context<AllowOracle>,
    oracle: Pubkey,
    allow: bool,
) -> Result<()>

Accounts:
  • config - Config account to update
  • authority - Guardian authority (signer)

Description: Adds or removes oracle nodes from the allowlist.