---
name: berry-press
description: Earn AI inference from token supply that is sitting idle on Base. Use this when a user or an agent wants unused tokens to earn something, wants to deposit a supported token into a one-sided Berry Press vault, wants to check or spend the inference balance a Press position has earned (through an OpenAI-compatible endpoint), or wants to withdraw and close a position. Press runs a one-sided Uniswap V4 position; its fees are swapped to USDC and 80% becomes the depositor's AI inference balance.
---

# Berry Press: agent skill

Berry Press turns idle token supply into AI inference. Every deposit gets a vault
of its own. Agents and people use the same contracts and the same API; there is
nothing agent-only.

Network: Base mainnet, chain id 8453.
Addresses: always read them from `GET /api/config`. The factory to deposit through
is the `depositFactory` field. Never save it in your code.

## Key ideas

- **Factory**: creates one vault per deposit. The creator starts it and pays the
  gas. Its address is `config.depositFactory`.
- **Vault**: holds one position and nothing else. It only ever holds its own
  creator's tokens and fees, so positions cannot affect each other.
- **Principal**: what the creator deposited, plus any quote asset it turned into.
  It belongs to the creator and all of it comes back on withdraw.
- **Fees**: the contract splits them. 80% is the creator's share and becomes their
  **AI inference balance**. 20% is protocol margin. Everything settles in USDC.
- **Inference wallet**: each creator has one of their own. Pressed USDC goes there
  and inference is paid from it. Nothing is shared between creators.

## Which tokens

Deposits are open. Before depositing, check `GET /api/config` for the enabled
tokens. For a single token, `supportedForDeposit` on
`GET /api/tokens/{address}/resolve` gives the final answer.

## Contracts (check these yourself, no API needed)

Factory (`config.depositFactory`):
- `createVault(token, amount) -> vault`: creates a vault and deposits into it.
  Approve `amount` of the token to the factory first. Unsupported tokens revert.
- `vaultsOf(creator) -> address[]`: every vault a creator owns.

Vault (one per position):
- `press(minUsdcOut)`: operator or creator. Collects the fees, swaps them to USDC
  and splits them. The money can only go to the creator and the protocol.
- `withdraw()`: creator only. Settles fees and returns the principal. Needs no
  off-chain service, so it works even when the API and operator are down.
- `position() -> (token, amount, open)`, `pendingFees() -> uint256`, `creator()`.

## API

Base URL: `https://api.berryfi.net`

Call `GET /api/config` first for current addresses. This file names addresses
by field, never by value, because the config endpoint is the only source to trust.

No login needed:
- `GET /api/config`: chain id, current addresses, `depositFactory`, supportedTokens.
- `GET /api/creators/{address}/balance`: credited, spent and remaining (USDC, 6 decimals).
- `GET /api/creators/{address}/inference-wallet`: the creator's inference wallet.
- `GET /api/tokens/{address}/resolve`: market data, pool settings, supportedForDeposit.

Spending inference (sign with the wallet, no API key):
- Sign `berry-inference:{your_address_lowercase}:{timestamp_ms}`. It is valid for 5 minutes.
- `POST /api/inference/chat` with the headers `x-berry-address`, `x-berry-timestamp`
  and `x-berry-sig`, and an OpenAI-style body. The cost comes from your own USDC.

## Step by step

1. `GET /api/config` for `depositFactory`, the quote asset and supportedTokens.
2. Approve the token to `depositFactory`.
3. Call `createVault(token, amount)` to open your vault.
4. Fees build up and are pressed on-chain. The creator's share arrives as
   inference balance in the creator's own wallet.
5. To spend, sign the inference message and `POST /api/inference/chat`.
6. Call `withdraw()` whenever you want your principal back.

## Spending for someone else (optional)

An agent can spend a creator's balance without owning the position. The creator
signs `berry-delegate:{creator}:{agent}:{expiresAtMs}` once and sends it to
`POST /api/delegations`. The agent then signs its own inference message and adds
the header `x-berry-on-behalf-of: 0xCreatorAddress`. This only covers spending.
Withdrawing always needs the creator's own wallet.
