@ar-agents/treasury 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nazareno Clemente
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # @ar-agents/treasury
2
+
3
+ The treasury + fiscal rail for an Argentine **Sociedad Automatizada**: the moat half of the crypto/fiat bridge. An autonomous society earns in crypto (USDC on Base) but must pay AFIP/ARCA in pesos. This package closes that loop.
4
+
5
+ ## What it does
6
+
7
+ - **Balances + tax buffer** — track USDC + ARS; size the peso buffer for upcoming AFIP obligations (`requiredArsBuffer`, `nextObligation`).
8
+ - **Just-in-time conversion** — convert only enough USDC to ARS to cover the buffer, net of spread, never over-converting (`planConversion`, `fundTaxBuffer`).
9
+ - **Ganancias cedular accounting** — tax on the gain of each disposal: 5% (ARS) or 15% (foreign); crypto is IVA-exempt; holding + own-wallet transfers are not taxable (`cedularTax`).
10
+ - **Monotributo** — the verified 2026 category table (A–K, eff. 2026-02-01) + `monotributoCuota` / `categoryForAnnualIncome`.
11
+ - **Honest settlement model** — `settlementPlan` describes how an obligation actually gets paid. In jun-2026 there is **no fully-autonomous official channel**, so `canAutoExecute` is always `false`: débito automático is *passive* (one-time human enrolment, then it runs and the agent only keeps the CVU funded); VEP / Mercado Pago need a human each time. The rail funds + instructs; it does not pay.
12
+ - **MantecaOffRampAdapter** — the real USDC→ARS payout to a CVU, done by a **registered PSAV** (Manteca). We integrate one; we do not become one (CNV RG 1058/2025). An `InMemoryOffRampAdapter` ships for tests/dev.
13
+ - **AI SDK tools** — `@ar-agents/treasury/tools` exports `treasuryTools()`: 8 Vercel AI SDK 6 tools (5 pure + 3 PSAV-backed) that drop into an `Experimental_Agent`.
14
+
15
+ ## Entry points
16
+
17
+ - `@ar-agents/treasury` — pure core + `MantecaOffRampAdapter` + AFIP fiscal logic. **No `ai`/`zod` deps.**
18
+ - `@ar-agents/treasury/tools` — the AI SDK tool wrappers (needs the `ai` + `zod` peers).
19
+
20
+ ## Design
21
+
22
+ Pure, deterministic functions (clock + fx injected, never read) so the brain is fully unit-tested. Irreversible moves (`convert`, payments) MUST be gated by the agent's `requireConfirmation` (RFC-001) and written to the signed audit log by the caller. We orchestrate on top of a registered PSAV; we never custody the conversion ourselves.
23
+
24
+ ## Going live with Manteca
25
+
26
+ `MantecaOffRampAdapter` is a thin client over Manteca's documented v2 API. The **request contract is pinned exactly** (paths, `md-api-key` header, the ramp-off body) and unit-tested against mocked HTTP. Manteca onboarding is sales-gated (no self-serve keys), so it is **not yet integration-tested live**. To go to production, confirm three config items against a sandbox account, then run for real:
27
+
28
+ 1. `baseUrl` — defaults to `https://api.manteca.dev` (the public docs host is `developers.manteca.dev`; the live API host ships with your credentials).
29
+ 2. `ticker` — defaults to `USDC_ARS`.
30
+ 3. The price-response JSON shape and the synthetic status enum — both are parsed defensively + normalized here; verify against a sandbox call.
31
+
32
+ Ripio B2B (a registered PSAV with a documented sandbox) is the planned second adapter behind the same `OffRampAdapter` interface.
33
+
34
+ ## Status
35
+
36
+ `0.2.0` — core + Manteca off-ramp adapter + AFIP fiscal layer (monotributo + settlement) + 8 AI SDK tools, **52 tests**. Wired into the generated society (select the `treasury` pieza). Live PSAV integration is pending a Manteca business account; the Ripio adapter is the next increment. Full design + sourcing: [`../../TREASURY-FISCAL-RAIL.md`](../../TREASURY-FISCAL-RAIL.md).