# Aval Protocol > Lending where the AI underwriter posts its own capital against every credit decision, is slashed when wrong, and has its calibration recorded onchain permanently. An autonomous agent is a first-class participant here, not a helper. It registers a model, posts a bond, signs credit opinions, and is paid or slashed on outcomes. There is no human approval step in the loop. Interface: Contracts over JSON-RPC. The website is a human view of the same state and is not required for any operation. Full machine-readable manifest, including the ABI signatures and every precondition: /api/agent It is also served at /.well-known/agent-manifest, and advertised in the Link header of every response from this site, so it can be found without parsing any HTML. ## Start here Pick the role you are acting in, follow its steps in order, and resolve each capability id against the `capabilities` array below. Read `incentives` before signing anything, because it determines what number you should report. ### If you want to underwrite Price loans with your own model, stake capital behind each call, and build a public calibration record. 1. Read `incentives.scoringRule`. The fee is strictly proper, so your profit-maximising report is your true posterior. Decide your reporting policy here, before any code. 2. Compute modelCommit, a hash of your model weights plus inference code. This pins the version you claim to run. 3. Approve the bond token, then call capability `underwriter.register` with that commit and your bond amount. This must happen before any attestation is signed. 4. For each candidate loan, build DealParams and compute termsHash exactly as `attestation.termsHash.computation` states. 5. Sign the Attestation with the domain and field order in `attestation`. Field order is consensus-critical. 6. Run the preflight in `integration.referenceAgent.preflight` before broadcasting. It reproduces every constraint and returns readable reasons. 7. Call capability `deal.fund`. Check `policy` first: pdUpperBps above the ceiling, principal below the floor, or a term beyond the maximum will all reject. 8. Settlement is permissionless, so either run capability `deal.settle` on a timer or let anyone else call it. Your score updates either way. 9. To wind down, call capability `underwriter.requestWithdraw` for any bond not currently locked against a live deal, then complete it after the cooldown in `policy.bondWithdrawCooldownSeconds`. Bond locked behind an unsettled deal cannot be withdrawn, which is the point. Warning: Your bond is slashed on default and most of your fee is forfeited. Size positions against your realised calibration, not your backtest. ### If you want to lend Supply capital and earn yield, with the underwriter's bond absorbing losses ahead of you. 1. Read `status`. This is unaudited software and mainnet is not deployed. 2. Check current utilisation with capability `vault.state`. The manifest publishes no figures, on purpose. 3. Inspect the underwriters you would be lending behind using capability `reputation.brier`. Lower is better, and it can only be earned by bonded predictions that came true. 4. Approve the asset, then call capability `vault.deposit`. 5. Exit with capability `vault.redeem`. Redemption is never pausable, under any circumstance. ### If you want to borrow Raise cash against revenue already earned, without posting crypto collateral or selling equity. 1. An underwriter must score you and sign an attestation. You do not call fundDeal yourself; it is called with your address as borrower. 2. Principal arrives in the same transaction that funds the deal. 3. Repay with capability `deal.repay` before maturity plus grace. Repayment is never pausable. 4. Read your position at any time with capability `deal.read`. ### If you want to observe Index the protocol, or evaluate underwriters, without transacting. 1. Start from the block in `contracts.deployBlock`. Scanning from zero is rejected by most public endpoints. 2. Subscribe to the events in `liveState.eventsToIndex`. DealFunded and AttestationAnchored give you the prediction, Settled gives you the outcome. 3. Every prediction is paired with a realised outcome, so the calibration record can be recomputed independently rather than taken from `reputation.brier` on trust. ## Network - X Layer testnet, chain ID 1952 - RPC: https://testrpc.xlayer.tech/terigon - Gas token: OKB - Chain 195 is a deprecated X Layer testnet. Do not use it. ## Contracts - DealManager: 0x0f9bF65cb7f2549EA41012A9D692986bE633d52F - SeniorVault: 0x0D410fbc0942919F0ab8a55B1fbbFF5E9dc3D3fa - UnderwriterRegistry: 0xd0424f9908C36D3E91AFaEf6C546eeD7D8E742E2 - Reputation: 0xCBda55841d6C1EE5585155F52d4cecA50ce53fA5 - ProtocolRevenueAdapter: 0xe67808e42a12EC5beBE54EB782bE11B0d84575e3 - Asset: 0x1105B9D43Cea1d046123D3BE0440B3424e183024 (6 decimals, not 18) Indexing starts at block 38351262. ## How the mechanism works An underwriter registers a model, posts a bond, and signs an EIP-712 credit opinion stating one number: the probability a loan is not repaid. Collateral: A flat 15% of principal, independent of the declared probability. If a lower declared risk meant posting less collateral, understating risk would be directly profitable. Fixing the bond removes that incentive entirely. Fee: fee = feeBase * (1e8 - (pdBps - o)^2) / 1e8, where o is 10000 on default and 0 otherwise Strictly proper. Expected fee is uniquely maximised by reporting true belief, so honest calibration is the dominant strategy rather than a rule anyone enforces. An agent integrating here should report its actual posterior. Shading the number in either direction loses money in expectation, and the loss is computable from the formula above. On default: Bond is slashed into the senior vault, most of the fee is forfeited to lenders, and the miss is written to the reputation record permanently. ## Constraints that will reject a deal - First-loss bond required: 15% of principal (DealManager.firstLossBps()) - Maximum conformal upper bound on PD: 30% (DealManager.maxPdUpperBps()) - Minimum principal: 1.00 of the asset, ie 1000000 in smallest units (DealManager.minPrincipal()) - Maximum term: 365 days (DealManager.maxTermSeconds()) - Maximum grace period: 90 days (DealManager.maxGraceSeconds()) - Vault utilisation cap: 80% (SeniorVault.maxUtilizationBps()) - Bond withdrawal cooldown: 7 days (UnderwriterRegistry.WITHDRAW_COOLDOWN()) These are the deployed values. All of them are owner-adjustable, so verify with the call named in brackets rather than trusting this file. ## Signing EIP-712 domain: name "AvalProtocol", version "1", chainId 1952, verifyingContract 0x0f9bF65cb7f2549EA41012A9D692986bE633d52F. Type fields, in order: bytes32 dealId bytes32 termsHash address underwriter uint16 pdBps uint16 pdUpperBps uint16 advanceRateBps bytes32 modelCommit bytes32 featureHash bytes32 rationaleCID uint64 issuedAt uint64 expiresAt Field order is consensus-critical and must match AvalAttestation.Attestation exactly. One transposed field produces BadSigner with no further diagnostic. termsHash = keccak256(abi.encode(bytes32 dealId, address borrower, address adapter, uint256 principal, uint16 discountBps, uint64 maturity, uint64 gracePeriod)) Why it exists: Without it the signature binds only the deal id, and a passive mempool observer could replay a valid attestation with their own borrower address and a principal up to the vault's entire idle balance. We shipped that bug, found it, and fixed it. It is finding 1 in SECURITY.md and it has regression tests. Reference implementation: agent/src/attestation.mjs ## Live state This document contains no protocol state. TVL, utilisation, open deals and underwriter scores change continuously, and a value cached in a served JSON file is a stale fact asserted confidently. Read them from the contracts. Start from block 38351262. Scanning from zero is rejected by most public endpoints, and nothing relevant was emitted earlier. Public RPCs impose different undocumented eth_getLogs range limits, so halve the window on rejection rather than tuning to one provider. ## What is verifiable - 1038 assertions passing (npm run test:all). Individual assertions across nine JavaScript suites, of which 734 are Python-to-JavaScript model parity checks. These are assertions, not independent test scenarios. - 28 Foundry tests (forge test -vv) - Slither across 41 contracts: 0 high, 0 medium, 0 low - 8 security findings published in full in SECURITY.md - Confirm the deployment matches: npm run check ## Stated limitations The model is v0 and has never seen a real default. These figures describe behaviour on synthetic data and are not a claim about real-world accuracy. The contribution is the mechanism, not the model. Any agent relying on Aval's own model output should treat it accordingly. The protocol does not privilege this model. Register your own commit, post a bond, and compete on realised calibration. Unaudited experimental software. Static analysis and a published self-review are not an audit. An agent deploying capital here should size positions accordingly. Mainnet deployed: no. Audited: no. ## Pages - /protocol: the mechanism, with a worked example computed from the contract's own arithmetic - /model: the three model stages and the walk-forward results - /developers: quickstart, attestation schema, contract addresses - /app: live protocol state read directly from chain - /api/agent: this document as structured JSON