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
| Package | What it is |
|---|---|
@hyr0-xyz/client-js | Low-level client generated from the IDLs: instruction builders, account decoders and codecs. |
@hyr0-xyz/program | Higher-level vault, policy and fee helpers built on the generated client. |
@hyr0-xyz/react | React 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:
vaultandparent_vaultmanager: the trader's walletchallenge_idstarting_equitystatus:Pending,Active,Passed,FailedorCancelledcreated_atandstatus_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,FailedandCancelledare final.set_challenge_statusrefuses to change them.- Only a
Pendingchallenge 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.