Developers

Technical notes for developers who want to read Hyro Protocol data or build against the programs. For the overview, start with Architecture.

Stack

  • Solana programs in Rust, built with Anchor 0.31.1.
  • TypeScript clients generated from the program IDLs with Codama.
  • The source code is the reference. Where this page and the code disagree, the code wins.

SDK packages

PackageWhat it is
@hyr0-xyz/client-jsLow-level client generated from the IDLs: instruction builders, account decoders and codecs.
@hyr0-xyz/programHigher-level vault, policy and fee helpers built on the generated client.
@hyr0-xyz/reactReact hooks on top of @hyr0-xyz/program.

Challenge accounts

policy_challenges stores two account types.

ChallengeConfig is the policy state of the parent vault. It holds the parent vault, the challenge admin key and a counter of registered challenges.

Challenge is the policy state of one challenge vault. It holds:

  • vault and parent_vault
  • manager: the trader's wallet
  • challenge_id
  • starting_equity
  • status: Pending, Active, Passed, Failed or Cancelled
  • created_at and status_updated_at

The current balance is not copied into the Challenge account. It lives on the challenge vault itself, in the core program.

Instructions: initialize_config, update_config_admin, register_challenge, set_challenge_status, close_challenge, validate, plus account migration instructions.

Rules worth knowing:

  • Balance reports are accepted only while the status is Active.
  • Passed, Failed and Cancelled are final. set_challenge_status refuses to change them.
  • Only a Pending challenge can be closed. A finished challenge record stays on chain permanently, so its address cannot be reused.
  • The challenge admin and the oracle are separate keys. The admin manages the lifecycle. The oracle, set on the parent vault, reports balances.

The policy interface

Every policy program exposes one validate instruction. The core program calls it before a sensitive action, passing the operation type and an amount (interface version 2). The operations are:

Creation, Execution, UseFunds, ReturnFunds, Report, RequestWithdrawal, ProcessWithdrawals, RequestDeposit, ProcessDeposits, ApproveDeposit, RejectDeposit, ApproveWithdrawal, RejectWithdrawal, IssueChildVault, ClaimFees, AccrueFees.

For each operation the core passes a fixed list of accounts, including the policy's state account and the signer. Each policy decides for itself who is authorized. The shared account check only confirms the accounts are present. It does not check who signed, so every policy must do that itself.

Policy state lives at a program-derived address with seeds [vault] under the policy program.

Proposed transactions

The core program supports a propose-then-execute flow for vaults that need it. create_tx stores a proposed instruction and asks the policy (Creation). execute_tx asks the policy again (Execution) and then runs the instruction, signed by the vault. cancel_tx closes an unexecuted proposal. Challenge vaults refuse both steps.

Addresses and seeds

  • Vaults: ["vault", seed]. Child vaults: ["child", parent, seed].
  • Devnet program addresses are listed in What's on Solana. Mainnet addresses will be published at launch.

Local development

The repository includes a local test validator setup that loads the programs, and a test suite for the programs. The audit recommended expanding the tests for authorization, fee accounting, balance accounting, state transitions and migrations.