sla-escrow-api 0.2.9

SLA-Escrow: Service Level Agreement Enforcer for AI Agents
Documentation
# sla-escrow-api

**Rust types, instruction codecs, PDA helpers, and `EscrowSdk` builders** for the SLA-Escrow Solana program.

[Crates.io](https://crates.io/crates/sla-escrow-api) · Apache-2.0

## Role

- **`declare_id!`** — Must match the deployed program (rebuild clients after ID changes).
- **`instruction`** — Binary layouts for every opcode (`FundPayment`, `ConfirmOracle`, `UpdateConfig`, …).
- **`state`**`Bank`, `Config`, `Escrow`, `Payment` (`Payment` includes `oracle_authority_set_at`, `resolution_hash`, timing snapshots, etc.).
- **`sdk::EscrowSdk`** — Instruction builders aligned with the on-chain account order.
- **`event`** — Log-friendly event structs (e.g. `PaymentOracleConfirmedEvent` includes `resolution_hash`).
- **`consts`** — Fee caps, timing validation bounds, seeds, optional precomputed PDAs for integrators.

## Participants

- **Buyer** — Funds the payment.  
- **Seller** — Fulfills and submits `delivery_hash`.  
- **Oracle**`payment.oracle_authority`; signs `ConfirmOracle` with `delivery_hash`, optional **`resolution_hash`**, and resolution/reason.  
- **Bank authority** — Admin path: init, open escrow, withdraw fees, pause, update config, authority rotation, etc.

## SDK examples

### Gross quote (fees + oracle tip)

```rust
use sla_escrow_api::sdk::EscrowSdk;

let desired_net = 1_000_000u64; // e.g. 1 USDC (6 decimals)
let gross = EscrowSdk::calculate_gross_quote(
    desired_net,
    100,    // protocol fee_bps
    10_000, // min protocol fee raw
    50,     // oracle_fee_bps
);
```

### Fund payment (SPL)

```rust
use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::fund_payment(
    buyer,
    Some(buyer_ata),
    seller,
    mint,
    amount_raw,
    86_400,
    "payment-uid",
    sla_hash,
    oracle_authority,
);
```

Use `buyer_tokens: None` and `mint: Pubkey::default()` for **native SOL** (see `fund_payment` rustdoc).

### Confirm oracle (with attestation hash)

```rust
use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::confirm_oracle(
    oracle_authority,
    mint,
    "payment-uid",
    delivery_hash,
    resolution_hash, // [0u8; 32] if unused
    1,               // approved
    0,               // resolution_reason
);
```

### Update global config (admin)

```rust
use sla_escrow_api::sdk::EscrowSdk;

let ix = EscrowSdk::update_config(
    admin,
    closure_delay_seconds,
    refund_cooldown_seconds,
    delivery_cutoff_seconds,
);
```

Newly funded payments snapshot these values; existing payments keep their stored copies.

## License

Apache License, Version 2.0.