Policy
Simulate policy rules, write receipts, attest policy hashes, check invariants, and query policy via CPI.
Pre-alpha — not production ready
@aura-protocol/sdk-ts targets Solana devnet only. APIs may change without notice. Do not use for real funds until a stable release and audit are published.
simulatePolicy
Run the full policy evaluation against a treasury without committing any state changes. Useful for pre-flight checks and UI previews.
// Build only
const instruction = await client.simulatePolicyInstruction(
accounts: SimulatePolicyAccounts,
args: SimulatePolicyArgs,
);
// Build + send
await client.simulatePolicy(payer, accounts, args);interface SimulatePolicyAccounts {
payer: PublicKey; // funds the simulation result account
treasury: PublicKey;
operatorRole?: PublicKey | null; // required if caller is a delegated operator
simulationResult: PublicKey; // PDA: derivePolicySimulationAddress(treasury, simulationId)
systemProgram: PublicKey;
}import { derivePolicySimulationAddress } from '@aura-protocol/sdk-ts';
import BN from 'bn.js';
const simulationId = new BN(1);
const [simulationResult] = derivePolicySimulationAddress(treasury, simulationId);
await client.simulatePolicy(
payer,
{
payer: payer.publicKey,
treasury,
operatorRole: null,
simulationResult,
systemProgram: SystemProgram.programId,
},
{
simulationId,
amountUsd: new BN(500),
targetChain: 2,
txType: 0,
protocolId: null,
recipientOrContract: '0xdeadbeef...',
counterpartyRiskScore: null,
quoteAgeSecs: null,
expectedOutputUsd: null,
actualOutputUsd: null,
currentTimestamp: new BN(Math.floor(Date.now() / 1000)),
},
);writePolicyReceipt
Store an immutable snapshot of the policy decision for the current pending proposal. Links the receipt to an optional attestation.
// Build only
const instruction = await client.writePolicyReceiptInstruction(
accounts: WritePolicyReceiptAccounts,
args: WritePolicyReceiptArgs,
);
// Build + send
await client.writePolicyReceipt(payer, accounts, args);interface WritePolicyReceiptAccounts {
payer: PublicKey;
treasury: PublicKey;
receipt: PublicKey; // PDA: derivePolicyReceiptAddress(treasury, proposalId)
attestation?: PublicKey | null; // optional — link to an existing attestation
systemProgram: PublicKey;
}applyPolicyPreset
Apply a named policy preset to the treasury, replacing the current PolicyConfig with a predefined configuration.
// Build only
const instruction = await client.applyPolicyPresetInstruction(
accounts: OwnerTreasuryAccounts,
args: ApplyPolicyPresetArgs,
);
// Build + send
await client.applyPolicyPreset(owner, accounts, args);await client.applyPolicyPreset(
owner,
{ owner: owner.publicKey, treasury },
{
presetKind: 0, // preset index — see on-chain PolicyPresetKind enum
timestamp: new BN(Math.floor(Date.now() / 1000)),
},
);attestPolicy
Sign and store a hash of the current policy configuration. Used to prove that a specific policy was in effect at a given time.
// Build only
const instruction = await client.attestPolicyInstruction(
accounts: AttestPolicyAccounts,
args: AttestPolicyArgs,
);
// Build + send — payer and attester may be different signers
await client.attestPolicy(payer, attester, accounts, args);interface AttestPolicyAccounts {
payer: PublicKey; // funds the attestation account
attester: PublicKey; // signs the policy hash — must be a signer
treasury: PublicKey;
attestation: PublicKey; // PDA: derivePolicyAttestationAddress(treasury, attester, policyVersion)
systemProgram: PublicKey;
}import { derivePolicyAttestationAddress } from '@aura-protocol/sdk-ts';
import BN from 'bn.js';
const account = await client.getTreasuryAccount(treasury);
const policyVersion = account.currentPolicyVersion;
const [attestation] = derivePolicyAttestationAddress(
treasury,
attester.publicKey,
policyVersion,
);
await client.attestPolicy(
payer,
attester,
{ payer: payer.publicKey, attester: attester.publicKey, treasury, attestation, systemProgram: SystemProgram.programId },
{ policyVersion, timestamp: new BN(Math.floor(Date.now() / 1000)) },
);checkInvariants
Run a set of on-chain invariant checks against the treasury and store the result. Useful for monitoring and auditing.
// Build only
const instruction = await client.checkInvariantsInstruction(
accounts: CheckInvariantsAccounts,
args: CheckInvariantsArgs,
);
// Build + send
await client.checkInvariants(payer, accounts, args);interface CheckInvariantsAccounts {
payer: PublicKey;
treasury: PublicKey;
report: PublicKey; // PDA: deriveInvariantReportAddress(treasury, reportId)
systemProgram: PublicKey;
}import { deriveInvariantReportAddress } from '@aura-protocol/sdk-ts';
import BN from 'bn.js';
const reportId = new BN(1);
const [report] = deriveInvariantReportAddress(treasury, reportId);
await client.checkInvariants(
payer,
{ payer: payer.publicKey, treasury, report, systemProgram: SystemProgram.programId },
{ reportId, timestamp: new BN(Math.floor(Date.now() / 1000)) },
);checkPolicyCpi
Allow an external program to query AURA policy for a treasury via CPI. The result is stored in a PDA that the calling program can read.
// Build only
const instruction = await client.checkPolicyCpiInstruction(
accounts: CheckPolicyCpiAccounts,
args: CheckPolicyCpiArgs,
);
// Build + send
await client.checkPolicyCpi(feePayer, accounts, args);interface CheckPolicyCpiAccounts {
caller: PublicKey; // the calling integration account
treasury: PublicKey;
feePayer: PublicKey; // funds the result account — must be a signer
result: PublicKey; // PDA storing the policy check result
systemProgram: PublicKey;
}