Skip to main content

sra-riskgate

Deterministic pre-filter for stablecoin transactions. It runs fast rule checks (peg-deviation bounds in both directions, a single-transfer ceiling, and payload validation) before you send a transaction to the SRA-RiskGate-4B model.

This package does not run the model and does not perform sanctions screening.

pip install sra-riskgate
from sra_riskgate import RulePreFilter, TransactionPayload

gate = RulePreFilter(max_amount=50_000, depeg_hold_pct=1.0, depeg_reject_pct=5.0)
verdict = gate.inspect(TransactionPayload(
    chain_id=1, token="USDC",
    sender="0x" + "a" * 40, recipient="0x" + "b" * 40,
    amount=5000.0, peg_deviation_pct=-1.5,
))
print(verdict.decision.value, verdict.flags, verdict.required_actions)
# hold ['MODERATE_DEPEG'] ['manual_review']
Rule Decision
Peg deviation NaN / infinite reject
abs(peg deviation) >= depeg_reject_pct reject
abs(peg deviation) >= depeg_hold_pct hold
amount > max_amount hold
otherwise approve

Changelog

0.3.5: AgentKit integration rewritten: real ActionProvider with @create_action; sends USDC as an ERC-20 transfer (0.3.3 sent ETH; 0.3.4 was not accepted by AgentKit); chain read from the wallet; reverted transactions reported as failures; optional peg_feed; solana pinned so the [agentkit] extra imports.

0.3.1: Unknown constructor arguments now raise TypeError instead of being silently ignored. Legacy max_allowed_deviation_pct maps to the hold threshold again (as in 0.1.x). Non-finite thresholds are rejected. License and author metadata restored.

0.3.0: Depeg checks use abs() (catches upward depegs). Thresholds validated.

License: Apache-2.0

Coinbase AgentKit integration

pip install "sra-riskgate[agentkit]"
from coinbase_agentkit import AgentKit, AgentKitConfig, CdpEvmWalletProvider, CdpEvmWalletProviderConfig
from sra_riskgate.integrations.agentkit import RiskGateActionProvider

wallet = CdpEvmWalletProvider(CdpEvmWalletProviderConfig(network_id="base-sepolia"))
agentkit = AgentKit(AgentKitConfig(
    wallet_provider=wallet,
    # Register ONLY the risk-gated provider for payments. Adding AgentKit's
    # wallet or ERC-20 providers gives the agent ungated transfer actions.
    action_providers=[RiskGateActionProvider(max_amount=1000.0, peg_feed=my_usdc_peg_feed)],
))

The agent gets one action, risk_gated_usdc_transfer. It sends USDC (ERC-20, never the native token) on Ethereum, Base, and Base Sepolia, and only after the pre-filter approves. Depeg checks need a peg_feed(chain_id) -> deviation %; without one they're reported as disabled. A reverted transaction is reported as FAILED, never as sent.

Metadata

Release files for sra-riskgate 0.3.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sra-riskgate 0.3.5
File Size Uploaded
sra_riskgate-0.3.5.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sra-riskgate 0.3.5
File Interpreter ABI Platform
sra_riskgate-0.3.5-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / sra_riskgate-0.3.5.tar.gz

Download URL sra_riskgate-0.3.5.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
e166e132da8e8f798ad2c7eab753a2498be6f77fa855c45475820acdd8563b9f
BLAKE2b-256 checksum
How to use checksums
25b85a8be8b13d77538b15deefd5a854150b3dd0d11d0327657b1ca9e66fa319
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release files / sra_riskgate-0.3.5-py3-none-any.whl

Download URL sra_riskgate-0.3.5-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
57e77362ad1e4e0df213b0ecca7c211103ec352656a16a9204723c4af94d6cf3
BLAKE2b-256 checksum
How to use checksums
ca3c54bec569591058be4c63ff56cf52e493fb8dae52fec1f203f6590f4c823b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.6

Release history Release notifications | RSS feed

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.0

2 release files

This release

0.3.5 This release

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page