This is the exact JSON payload served at /api/agent. It defines the chain, the contract addresses, the EIP-712 schema, and every capability an agent can act on.
{
"specVersion": "1.0",
"documentation": "https://github.com/AngelofDea1/Aval-Protocol",
"source": "https://github.com/AngelofDea1/Aval-Protocol/blob/main/web/lib/agent-manifest.ts",
"startHere": {
"readThisFirst": "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.",
"roles": {
"underwrite": {
"goal": "Price loans with your own model, stake capital behind each call, and build a public calibration record.",
"steps": [
"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.",
"Compute modelCommit, a hash of your model weights plus inference code. This pins the version you claim to run.",
"Approve the bond token, then call capability `underwriter.register` with that commit and your bond amount. This must happen before any attestation is signed.",
"For each candidate loan, build DealParams and compute termsHash exactly as `attestation.termsHash.computation` states.",
"Sign the Attestation with the domain and field order in `attestation`. Field order is consensus-critical.",
"Run the preflight in `integration.referenceAgent.preflight` before broadcasting. It reproduces every constraint and returns readable reasons.",
"Call capability `deal.fund`. Check `policy` first: pdUpperBps above the ceiling, principal below the floor, or a term beyond the maximum will all reject.",
"Settlement is permissionless, so either run capability `deal.settle` on a timer or let anyone else call it. Your score updates either way.",
"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."
],
"capabilities": [
"underwriter.register",
"deal.fund",
"deal.settle",
"underwriter.updateModel",
"underwriter.requestWithdraw"
],
"warning": "Your bond is slashed on default and most of your fee is forfeited. Size positions against your realised calibration, not your backtest."
},
"lend": {
"goal": "Supply capital and earn yield, with the underwriter's bond absorbing losses ahead of you.",
"steps": [
"Read `status`. This is unaudited software and mainnet is not deployed.",
"Check current utilisation with capability `vault.state`. The manifest publishes no figures, on purpose.",
"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.",
"Approve the asset, then call capability `vault.deposit`.",
"Exit with capability `vault.redeem`. Redemption is never pausable, under any circumstance."
],
"capabilities": [
"vault.state",
"reputation.brier",
"vault.deposit",
"vault.redeem"
]
},
"borrow": {
"goal": "Raise cash against revenue already earned, without posting crypto collateral or selling equity.",
"steps": [
"An underwriter must score you and sign an attestation. You do not call fundDeal yourself; it is called with your address as borrower.",
"Principal arrives in the same transaction that funds the deal.",
"Repay with capability `deal.repay` before maturity plus grace. Repayment is never pausable.",
"Read your position at any time with capability `deal.read`."
],
"capabilities": [
"deal.repay",
"deal.read"
]
},
"observe": {
"goal": "Index the protocol, or evaluate underwriters, without transacting.",
"steps": [
"Start from the block in `contracts.deployBlock`. Scanning from zero is rejected by most public endpoints.",
"Subscribe to the events in `liveState.eventsToIndex`. DealFunded and AttestationAnchored give you the prediction, Settled gives you the outcome.",
"Every prediction is paired with a realised outcome, so the calibration record can be recomputed independently rather than taken from `reputation.brier` on trust."
],
"capabilities": [
"deal.read",
"reputation.record",
"reputation.brier",
"vault.state"
]
}
}
},
"protocol": {
"name": "Aval Protocol",
"summary": "Lending where the AI underwriter posts its own capital against every credit decision, is slashed when wrong, and has its calibration recorded onchain permanently.",
"agentRole": "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."
},
"network": {
"name": "X Layer testnet",
"chainId": 1952,
"rpc": "https://testrpc.xlayer.tech/terigon",
"explorer": "https://www.okx.com/web3/explorer/xlayer-test",
"gasToken": "OKB",
"note": "Chain 195 is a deprecated X Layer testnet. Do not use it."
},
"contracts": {
"dealManager": "0x0f9bF65cb7f2549EA41012A9D692986bE633d52F",
"seniorVault": "0x0D410fbc0942919F0ab8a55B1fbbFF5E9dc3D3fa",
"underwriterRegistry": "0xd0424f9908C36D3E91AFaEf6C546eeD7D8E742E2",
"reputation": "0xCBda55841d6C1EE5585155F52d4cecA50ce53fA5",
"protocolRevenueAdapter": "0xe67808e42a12EC5beBE54EB782bE11B0d84575e3",
"asset": {
"address": "0x1105B9D43Cea1d046123D3BE0440B3424e183024",
"decimals": 6,
"note": "Six decimals, not eighteen. Assuming eighteen is the most common integration bug against USDT."
},
"deployBlock": 38351262
},
"policy": {
"firstLossBps": {
"value": 1500,
"means": "Share of principal the underwriter must lock as first-loss collateral.",
"verifyWith": "DealManager.firstLossBps()"
},
"underwriterFeeBps": {
"value": 100,
"means": "Base fee before the Brier multiplier is applied.",
"verifyWith": "DealManager.underwriterFeeBps()"
},
"maxPdUpperBps": {
"value": 3000,
"means": "Risk ceiling. A deal whose conformal upper bound on PD exceeds this cannot be funded at all.",
"verifyWith": "DealManager.maxPdUpperBps()"
},
"minPrincipal": {
"value": 1000000,
"unit": "smallest unit of the asset (6 decimals), so 1.00",
"means": "Floor that stops dust deals whose 15% bond would round to zero.",
"verifyWith": "DealManager.minPrincipal()"
},
"maxTermSeconds": {
"value": 31536000,
"means": "Longest permitted term. Bounds how long lender capital can be locked up.",
"verifyWith": "DealManager.maxTermSeconds()"
},
"maxGraceSeconds": {
"value": 7776000,
"means": "Longest permitted grace period after maturity before default can be settled.",
"verifyWith": "DealManager.maxGraceSeconds()"
},
"maxUtilizationBps": {
"value": 8000,
"means": "Vault will not deploy beyond this share of assets, so redemptions stay possible.",
"verifyWith": "SeniorVault.maxUtilizationBps()"
},
"bondWithdrawCooldownSeconds": {
"value": 604800,
"means": "Delay between requesting and completing a bond withdrawal, so collateral cannot be pulled ahead of a settlement.",
"verifyWith": "UnderwriterRegistry.WITHDRAW_COOLDOWN()"
}
},
"incentives": {
"scoringRule": {
"name": "Brier",
"formula": "S(p, o) = 1 - (p - o)^2",
"feeFormula": "fee = feeBase * (1e8 - (pdBps - o)^2) / 1e8, where o is 10000 on default and 0 otherwise",
"property": "Strictly proper. Expected fee is uniquely maximised by reporting true belief, so honest calibration is the dominant strategy rather than a rule anyone enforces.",
"implication": "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."
},
"collateral": {
"rule": "A flat 15% of principal, independent of the declared probability.",
"whyNotRiskScaled": "If a lower declared risk meant posting less collateral, understating risk would be directly profitable. Fixing the bond removes that incentive entirely."
},
"onDefault": "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."
},
"attestation": {
"standard": "EIP-712",
"domain": {
"name": "AvalProtocol",
"version": "1",
"chainId": 1952,
"verifyingContract": "0x0f9bF65cb7f2549EA41012A9D692986bE633d52F"
},
"types": {
"Attestation": [
{
"name": "dealId",
"type": "bytes32"
},
{
"name": "termsHash",
"type": "bytes32"
},
{
"name": "underwriter",
"type": "address"
},
{
"name": "pdBps",
"type": "uint16"
},
{
"name": "pdUpperBps",
"type": "uint16"
},
{
"name": "advanceRateBps",
"type": "uint16"
},
{
"name": "modelCommit",
"type": "bytes32"
},
{
"name": "featureHash",
"type": "bytes32"
},
{
"name": "rationaleCID",
"type": "bytes32"
},
{
"name": "issuedAt",
"type": "uint64"
},
{
"name": "expiresAt",
"type": "uint64"
}
]
},
"fieldOrderWarning": "Field order is consensus-critical and must match AvalAttestation.Attestation exactly. One transposed field produces BadSigner with no further diagnostic.",
"termsHash": {
"computation": "keccak256(abi.encode(bytes32 dealId, address borrower, address adapter, uint256 principal, uint16 discountBps, uint64 maturity, uint64 gracePeriod))",
"whyItExists": "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."
},
"referenceImplementation": "agent/src/attestation.mjs"
},
"capabilities": [
{
"id": "underwriter.register",
"kind": "write",
"contract": "underwriterRegistry",
"signature": "function register(bytes32 modelCommit, uint256 amount)",
"summary": "Register a model and post its bond. `modelCommit` is a hash of the model weights plus inference code, and it pins the version this underwriter claims to run.",
"preconditions": [
"Caller has approved the registry to spend `amount` of the bond token.",
"`amount` is at least UnderwriterRegistry.minBond()."
]
},
{
"id": "underwriter.updateModel",
"kind": "write",
"contract": "underwriterRegistry",
"signature": "function updateModel(bytes32 newCommit)",
"summary": "Change the pinned model version. Permitted, but always evented and version-bumped, so a track record cannot be silently inherited by a different model."
},
{
"id": "underwriter.requestWithdraw",
"kind": "write",
"contract": "underwriterRegistry",
"signature": "function requestWithdraw(uint256 amount)",
"summary": "Begin withdrawing free bond. Completing it requires waiting 604800 seconds.",
"preconditions": [
"`amount` does not exceed bondTotal minus bondLocked."
]
},
{
"id": "deal.fund",
"kind": "write",
"contract": "dealManager",
"signature": "function fundDeal((bytes32 dealId,address borrower,address adapter,uint256 principal,uint16 discountBps,uint64 maturity,uint64 gracePeriod) p, (bytes32 dealId,bytes32 termsHash,address underwriter,uint16 pdBps,uint16 pdUpperBps,uint16 advanceRateBps,bytes32 modelCommit,bytes32 featureHash,bytes32 rationaleCID,uint64 issuedAt,uint64 expiresAt) a, bytes signature)",
"summary": "The core action. Submit signed terms and a credit opinion; the contract verifies the signature, locks the underwriter's bond, and moves principal to the borrower in the same transaction.",
"preconditions": [
"`a.termsHash` equals keccak256(abi.encode(dealId, borrower, adapter, principal, discountBps, maturity, gracePeriod)).",
"The signature recovers to `a.underwriter` under the EIP-712 domain below.",
"`a.modelCommit` matches the registry's current commit for that underwriter.",
"`a.pdUpperBps` is at most 3000, `a.pdBps` is at most 10000, and `a.pdBps` does not exceed `a.pdUpperBps`.",
"The underwriter has free bond of at least principal times firstLossBps.",
"`maturity` is in the future and within maxTermSeconds."
],
"reverts": [
"TermsMismatch: termsHash does not commit to these params. This is the guard against signature replay with substituted terms.",
"BadSigner: signature does not recover to the named underwriter.",
"StaleModelCommit: the attestation names a model version the registry no longer pins.",
"PdAbovePolicy, PdOutOfRange, PdAboveOwnUpperBound, DiscountTooHigh, PrincipalTooSmall, MaturityInPast, TermTooLong, GraceTooLong, ZeroAval, ZeroPrincipal, DealExists, AttestationExpired, AttestationMismatch"
]
},
{
"id": "deal.repay",
"kind": "write",
"contract": "dealManager",
"signature": "function repay(bytes32 dealId, uint256 amount)",
"summary": "Repay a live deal. Never pausable.",
"preconditions": [
"Caller has approved the DealManager to spend `amount`."
]
},
{
"id": "deal.settle",
"kind": "write",
"contract": "dealManager",
"signature": "function settle(bytes32 dealId)",
"summary": "Close a matured deal. Permissionless by design: the contract decides the outcome from its own state, so a caller can only be early, which reverts, or correct. It cannot settle a deal the wrong way. This is what makes unattended keepers safe. Never pausable.",
"preconditions": [
"EITHER the deal is repaid in full (repaid >= dueAmount), in which case it is settleable immediately with no time condition at all, OR block.timestamp is past maturity plus gracePeriod.",
"Checking only the clock is the easy mistake here, and it leaves a borrower who repaid early unable to close their own deal, with the underwriter's bond locked behind it."
],
"reverts": [
"NotYetSettleable",
"AlreadySettled",
"DealNotFound"
]
},
{
"id": "vault.deposit",
"kind": "write",
"contract": "seniorVault",
"signature": "function deposit(uint256 assets, address receiver) returns (uint256 shares)",
"summary": "Supply lending capital. Standard ERC-4626."
},
{
"id": "vault.redeem",
"kind": "write",
"contract": "seniorVault",
"signature": "function redeem(uint256 shares, address receiver, address owner) returns (uint256 assets)",
"summary": "Withdraw lending capital. Never pausable, under any circumstance."
},
{
"id": "vault.state",
"kind": "read",
"contract": "seniorVault",
"signature": "totalAssets() | deployedAssets() | idleAssets() | utilizationBps()",
"summary": "Current pool state. Call these for live figures; this manifest deliberately carries none."
},
{
"id": "reputation.record",
"kind": "read",
"contract": "reputation",
"signature": "function getRecord(address) returns ((uint256 sumSquaredError,uint256 principalUnderwritten,uint256 totalSlashed,uint256 feesForfeited,uint64 predictions,uint64 defaults))",
"summary": "An underwriter's full calibration history. Pair with brierScore(address) for the running score, where lower is better."
},
{
"id": "reputation.brier",
"kind": "read",
"contract": "reputation",
"signature": "function brierScore(address) returns (uint256)",
"summary": "Mean squared error of that underwriter's predictions against realised outcomes, scaled by 1e18. The only number on this protocol that cannot be bought."
},
{
"id": "deal.read",
"kind": "read",
"contract": "dealManager",
"signature": "function getDeal(bytes32) returns ((address borrower,address adapter,address underwriter,uint256 principal,uint256 dueAmount,uint256 avalLocked,uint256 repaid,uint64 maturity,uint64 gracePeriod,uint16 pdBps,uint8 status,bool defaulted))",
"summary": "Full state of one deal."
}
],
"liveState": {
"principle": "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.",
"reads": [
"vault.state",
"reputation.record",
"reputation.brier",
"deal.read"
],
"eventsToIndex": [
"DealFunded(bytes32 indexed dealId, address indexed borrower, address indexed underwriter, uint256 principal, uint256 dueAmount, uint256 avalLocked, uint16 pdBps)",
"AttestationAnchored(bytes32 indexed dealId, address indexed underwriter, uint16 pdBps, uint16 pdUpperBps, uint16 advanceRateBps, bytes32 modelCommit, bytes32 featureHash, bytes32 rationaleCID)",
"Settled(bytes32 indexed dealId, bool defaulted, uint256 repaid, uint256 slashed, uint256 feePaid, uint256 feeForfeited)"
],
"indexingHint": "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."
},
"verification": {
"assertionsPassing": {
"value": 1038,
"note": "Individual assertions across nine JavaScript suites, of which 734 are Python-to-JavaScript model parity checks. These are assertions, not independent test scenarios.",
"reproduce": "npm run test:all"
},
"foundryTests": {
"value": 28,
"reproduce": "forge test -vv"
},
"staticAnalysis": {
"tool": "Slither",
"contractsAnalysed": 41,
"high": 0,
"medium": 0,
"low": 0,
"informational": 4,
"reproduce": "slither . --exclude-dependencies --filter-paths \"node_modules|mocks\""
},
"publishedFindings": {
"value": 8,
"where": "SECURITY.md"
},
"checkDeployment": "npm run check"
},
"model": {
"stages": [
"Logistic regression over eight cashflow features, of which seven carry non-zero weight. max_drawdown is fitted at exactly 0.0 on the v0 training set and is retained in the feature vector for shape stability, not because it contributes. The dominant terms are momentum, coverage and volatility.",
"A language-model overlay on unstructured context, clamped to plus or minus 30% of the base probability. This clamp is offchain, in agent/src/llm.mjs. It is NOT a contract invariant; what the contract enforces is maxPdUpperBps, which reverts PdAbovePolicy.",
"Venn-Abers calibration, giving a distribution-free interval whose upper edge drives the risk ceiling."
],
"walkForwardBrier": 0.1965,
"baseRate": 0.311,
"trainedOn": "synthetic bootstrap dataset",
"honestLimitation": "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.",
"substitutable": "The protocol does not privilege this model. Register your own commit, post a bond, and compete on realised calibration."
},
"status": {
"testnet": true,
"mainnet": false,
"audited": false,
"warning": "Unaudited experimental software. Static analysis and a published self-review are not an audit. An agent deploying capital here should size positions accordingly."
},
"integration": {
"repository": "https://github.com/AngelofDea1/Aval-Protocol",
"whereToRead": "See SECURITY.md for the risk register and agent/src/ for the reference agent.",
"quickstart": [
"npm install",
"npm run test:all",
"npm run check",
"npm run fund -- --slug uniswap --face 50000 --dry-run",
"npm run keeper -- --interval 300"
],
"referenceAgent": {
"underwriteAndFund": "agent/src/fund.mjs",
"unattendedSettlement": "agent/src/keeper.mjs",
"signing": "agent/src/attestation.mjs",
"preflight": "attestation.mjs exports preflight(), which reproduces every constraint fundDeal enforces and returns readable reasons. Call it before broadcasting so a failure arrives as a sentence rather than a bare revert."
}
}
}