Skip to main content

Python adapter for the ARS-Solana Profile. Subclass the ARS SettlementLayer ABC against the Telaro Anchor program.

Project description

telaro-ars

Python adapter for the ARS-Solana Profile. Implements the Agentic Risk Standard SettlementLayer and CollateralVault abstract base classes against the Telaro Anchor program on Solana.

The TypeScript reference implementation is @telaro/ars-solana on npm. This package mirrors the same surface for Python ARS consumers.

Install

pip install telaro-ars

Requires Python 3.10+ and brings in solders for Pubkey / Instruction primitives.

What you get

File Role
abc.py SettlementLayer / CollateralVault ABCs, mirrored from t54 upstream
events.py Principal-track event types (JobOpened, UnderwritingDecided, ...)
state.py replay() / apply_event(). Pure, no chain. Mirrors src/state.ts byte for byte.
binding.py *_intent describes the on-chain call; build_view_bond_ix encodes it for v0.1
settlement.py TelaroSettlement concrete impl + TELARO_SETTLEMENT_MAP
constants.py Program id, bond floor, leverage cap

10-second look

from telaro_ars import (
    JobOpened, UnderwritingStarted, UnderwritingDecided,
    PrincipalReleased, EvidenceSubmitted, Closed,
    replay,
)

log = [
    JobOpened(
        job_id="job-1", at=1,
        agent="AgentPubkey...", requestor="DAppPubkey...",
        exposure_atomic=1_000_000_000,
    ),
    UnderwritingStarted(job_id="job-1", at=2),
    UnderwritingDecided(job_id="job-1", at=3, passed=True),
    PrincipalReleased(job_id="job-1", at=4, amount_atomic=1_000_000_000),
    EvidenceSubmitted(
        job_id="job-1", at=5, action_hash="0xabc", outcome="success",
    ),
    Closed(job_id="job-1", at=6, resolution="no_dispute"),
]

job = replay(log)
print(job.state)            # "CLOSED"
print(job.released_atomic)  # 1_000_000_000

replay is pure: same log in, same Job out.

Subclassing the SettlementLayer

from telaro_ars import (
    SettlementLayer,
    LockCollateralParams,
    PROGRAM_ID_DEVNET,
    build_view_bond_ix,
)
from solders.pubkey import Pubkey

# Subclass the upstream ABC and get a Telaro-backed implementation.
# lock_collateral builds a real view_bond instruction.
class MySettlement(SettlementLayer):
    async def lock_collateral(self, job_id, agent_id, amount):
        return build_view_bond_ix(
            LockCollateralParams(
                job_id=job_id,
                agent=Pubkey.from_string(agent_id),
                min_bond_atomic=amount,
                min_score=700,
            )
        )
    # ... other methods

Or use the bundled concrete class:

from telaro_ars import TelaroSettlement

s = TelaroSettlement()
intent = await s.lock_collateral(
    job_id="job-1",
    agent_id="4Nd1mYJgC7DsB3v9pkM9CRZxoUTfXn1kbm1zFM5hZRgM",
    amount=1_000_000_000,
)
# -> InstructionIntent(method="view_bond", ..., args={...})

v0.2 scope

All five in-scope SettlementLayer methods (principal track) ship with fully-encoded Instruction builders that produce a valid Solana solders.instruction.Instruction against the Telaro Anchor program:

ABC method Builder
lock_collateral build_view_bond_ix
slash_collateral build_resolve_claim_ix
unlock_collateral build_withdraw_bond_ix
pay_premium build_process_pool_yield_ix
release_principal build_request_credit_ix

PDAs (bond vault, deposit vault, credit line, pool config, pool vault, pool mint authority) are derived in-package against the seeds pinned in SPEC.md §3; the Python side and the TypeScript reference produce identical addresses for the same inputs.

The three fee-track methods (lock_fee, release_fee, refund_fee) remain out of scope per SPEC.md §1 and §10 (deferred).

Conformance with the TypeScript reference

The apply_event transition table here is line-for-line equivalent to applyEvent in src/state.ts. The mapping table in settlement.py (TELARO_SETTLEMENT_MAP) is the same one pinned in src/settlement.ts. The discriminator for view_bond matches the on-chain Anchor program by construction (sha256('global:view_bond')[:8]).

A conformance-test corpus that exercises both sides lives in tests/test_state.py here and tests/state.test.ts in the npm package.

License

MIT. See LICENSE in the parent repo.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

telaro_ars-0.4.0.tar.gz (26.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

telaro_ars-0.4.0-py3-none-any.whl (26.7 kB view details)

Uploaded Python 3

File details

Details for the file telaro_ars-0.4.0.tar.gz.

File metadata

  • Download URL: telaro_ars-0.4.0.tar.gz
  • Upload date:
  • Size: 26.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for telaro_ars-0.4.0.tar.gz
Algorithm Hash digest
SHA256 23dcca94fe2ddf0a8872e4e117fdd1002c3f88f245d29cba095d9606c481289c
MD5 1190438b060846c58ad3e26afe0a29dc
BLAKE2b-256 169e69acfd0080c803235af372daf9817997ab8d1a737183e51078bb3c2869c8

See more details on using hashes here.

File details

Details for the file telaro_ars-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: telaro_ars-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 26.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for telaro_ars-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 afa15d8e6a7980d43d94c7e66c74107cd363187f0b60a1fc9c6788dde07ba4b0
MD5 89f436e5994ee183b77d964797373e33
BLAKE2b-256 e6b14a675ae67564b791d1c15897f33b5efe68144bba7fc56c6d8f94465bc7ec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page