--- name: replicats version: 1.0.1 description: AI-powered crypto trading agents. Deploy autonomous trading strategies on Base network. homepage: https://app.replicats.ai metadata: {"moltbot":{"emoji":"🐱","category":"defi","api_base":"https://api.replicats.ai/api"},"openclaw":{"emoji":"🐱","homepage":"https://app.replicats.ai","requires":{"env":["REPLICATS_FID"]}}} --- # Replicats AI-powered autonomous trading agents on Base network. Deploy, monitor, and manage crypto trading strategies. **Base URL:** `https://api.replicats.ai/api` ## What is Replicats? Replicats provides AI trading agents that autonomously execute crypto trading strategies. You can: - Deploy funds to AI trading agents - Monitor your portfolio performance - View trade history and forecasts - Withdraw your funds anytime --- ## Authentication for AI Agents Replicats supports automatic authentication for AI agents via Farcaster ID (FID). > **Critical Learning:** FIDs are not free. Registration requires an on-chain Optimism transaction (ETH for storage rent) and binding an Ed25519 signer. Ensure your environment has a funded Optimism EVM wallet, or use Neynar/Syndicate to provision one programmatically. ### Step 1: Get your tokens ```bash curl -X POST https://api.replicats.ai/api/auth/agent \ -H "Content-Type: application/json" \ -d '{"fid": YOUR_FARCASTER_ID}' ``` Response: ```json { "access_token": "eyJhbGciOiJIUzI1NiIs...", "refresh_token": "eyJhbGciOiJIUzI1NiIs...", "token": "eyJhbGciOiJIUzI1NiIs...", "user": { "id": "uuid", "external_id": "12345", "access_level": "AGENT", "wallets": {}, ... } } ``` ### Step 2: Use the access_token in all requests ```bash curl https://api.replicats.ai/api/agents \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ -H "x-auth-method: agent" ``` **Important:** Always include `x-auth-method: agent` on every request. Endpoints like `/api/me` will return 401 or "Invalid authentication token format" without it. ### Step 3: Refresh your token when expired ```bash curl -X POST https://api.replicats.ai/api/auth/agent/refresh \ -H "Content-Type: application/json" \ -d '{"refresh_token": "YOUR_REFRESH_TOKEN"}' ``` Response: ```json { "access_token": "new_access_token...", "refresh_token": "new_refresh_token..." } ``` ### Token Duration - **Access token**: valid for **1 hour** - **Refresh token**: valid for **30 days** - When access token expires, use refresh token to get new tokens - Store both tokens securely between sessions --- ## User Profile ### Get your profile ```bash curl https://api.replicats.ai/api/me \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Response: ```json { "id": "uuid", "email": null, "wallets": {}, "wallets_addresses": [ { "id": "wallet-uuid", "wallet_address": "0xYourWalletAddress", "wallet_origin": "agent" } ], "external_id": "12345", "access_level": "AGENT", "whitelist": true, ... } ``` The `wallets_addresses` field contains all wallets linked to your account. Note that creating a strategy will automatically provision a `crossmint` custodial wallet linked to your user profile. --- ## Wallet Registration Before creating a strategy, register your **local agent wallet address** (must be on Base network): ```bash curl -X POST https://api.replicats.ai/api/wallet/register \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{ "wallet_address": "0xYourWalletAddress" }' ``` Response: ```json { "wallet_id": "uuid", "wallet_address": "0xYourWalletAddress", "user_id": "uuid" } ``` This wallet will become the **vault owner** when you create a strategy. You need the private key for this wallet to sign deposit and withdraw transactions on-chain. Make sure it is funded with both **Base ETH** (for gas) and **Base USDC** (for deposit). > **Security Disclaimer:** The agent's wallet private key is managed entirely by the agent itself. Replicats does **not** store, manage, or have access to the agent's private key. The security of the wallet — including key storage, rotation, and access control — is the sole responsibility of the agent operator. If the private key is compromised, funds in the vault may be at risk. Use hardware wallets, secure enclaves, or trusted key management solutions whenever possible. --- ## AI Agents ### List available agents ```bash curl https://api.replicats.ai/api/agents \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Response: ```json [ { "id": "uuid", "name": "Agent Alpha", "owner": "replicats", "description": "Conservative DeFi yield strategy", "configurations": {} } ] ``` This endpoint also returns each agent's current `market_context` (narrative about current market conditions) and `reasoning` (per-token positioning rationale). Parse these to understand why an agent is allocating the portfolio as it is. ### Get forecasting data ```bash curl "https://api.replicats.ai/api/forecasting?redis_key=forecast" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Response: ```json { "updated_at": "2025-01-28T12:00:00Z", "historical": [ {"date": "2025-01-27", "value": 100.5} ], "forecast": [ {"date": "2025-01-29", "value": 102.3, "lower": 98.0, "upper": 106.5, "day_ahead": 1} ] } ``` --- ## Strategies ### List your strategies ```bash curl https://api.replicats.ai/api/strategy/list \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Response: ```json [ { "id": "uuid", "description": "My trading strategy", "status": "active", "wallet_id": "uuid", "wallet_address": "0x...", "vault_address": "0x...", "agent_id": "uuid", "configuration_key": "default" } ] ``` > **Critical Learning — Vault Address Delay:** Smart contract deployment is asynchronous. Immediately after `POST /strategy/create`, `vault_address` will likely be `null` or `"None"`. Poll this endpoint until a valid `0x...` address appears before attempting to approve or deposit funds. ### Create a strategy ```bash curl -X POST https://api.replicats.ai/api/strategy/create \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{ "agent_id": "AGENT_UUID", "wallet_address": "0xYourWalletAddress", "description": "My new strategy" }' ``` ### Pause a strategy ```bash curl -X PUT "https://api.replicats.ai/api/pause?agent_strategy_id=STRATEGY_UUID" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` ### Get vault info ```bash curl "https://api.replicats.ai/api/vault?agent_strategy_id=STRATEGY_UUID" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` ### Deactivate a strategy ```bash curl -X POST https://api.replicats.ai/api/new-deactivate \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{"agent_strategy_id": "STRATEGY_UUID"}' ``` --- ## Transactions ### List transactions ```bash curl "https://api.replicats.ai/api/transactions?page=1&page_size=20" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Query parameters: - `transaction_id` - Filter by specific transaction - `wallet_id` - Filter by wallet - `page` - Page number (default: 1) - `page_size` - Items per page ### Get a specific transaction ```bash curl https://api.replicats.ai/api/transaction/TRANSACTION_UUID \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` --- ## Orders ### List orders for a wallet ```bash curl "https://api.replicats.ai/api/orders/WALLET_UUID?page=1&page_size=20" \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` --- ## Deposits & Withdrawals ### Prerequisites To deposit and withdraw, your agent needs: - **A wallet with a private key** on Base network (the wallet used in `POST /strategy/create`) - **ETH** on Base for gas fees (~0.0001 ETH per transaction) - **USDC** on Base for deposits The wallet you pass as `wallet_address` when creating a strategy becomes the **vault owner**. Only the owner can call `deposit()` and `withdrawUSDC()` on the vault contract. ### Deposit Flow (3 steps) > **Critical Learning — Approval Sequencing:** Do not parallelize `approve` and `deposit` for the same token, or execute them back-to-back without waiting. Always await the `approve` transaction receipt and insert a short delay (3–5 seconds) before broadcasting the `deposit` transaction. If the node hasn't synced the updated allowance state, the deposit will revert with `ERC20: transfer amount exceeds allowance`. **Step 1: Approve USDC spending** The vault needs permission to transfer your USDC. Call `approve()` on the USDC contract. ```bash # Using cast (foundry) cast send 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \ "approve(address,uint256)" \ VAULT_ADDRESS \ AMOUNT_IN_USDC_UNITS \ --rpc-url https://mainnet.base.org \ --private-key YOUR_PRIVATE_KEY ``` ```bash # Function: approve(address spender, uint256 amount) # Selector: 0x095ea7b3 # USDC has 6 decimals, so 100 USDC = 100000000 ``` **Step 2: Deposit USDC into the vault** Call `deposit()` on the vault contract. Only accepts USDC. ```bash # Using cast (foundry) cast send VAULT_ADDRESS \ "deposit(address,uint256)" \ 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \ AMOUNT_IN_USDC_UNITS \ --rpc-url https://mainnet.base.org \ --private-key YOUR_PRIVATE_KEY ``` ```bash # Function: deposit(address token, uint256 amount) # Selector: 0x47e7ef24 # token must be USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 # USDC has 6 decimals: 100 USDC = 100000000 ``` **Step 3: Register the deposit via API** After the on-chain deposit confirms, register it so the platform tracks it: ```bash curl -X POST https://api.replicats.ai/api/deposit \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{ "wallet_id": "WALLET_UUID", "transaction_hash": "0xYourDepositTxHash" }' ``` > **Note:** `wallet_id` is the Crossmint custodial wallet ID from `GET /strategy/list` — **not** your local agent wallet ID from the initial registration. ### Withdraw Flow (4 steps) Withdrawing is a multi-step process because the vault may hold multiple tokens that need to be swapped back to USDC first. **Step 1: Initiate withdrawal (API)** This triggers the server to swap all vault tokens back to USDC via the agent wallet (Crossmint). ```bash curl -X POST https://api.replicats.ai/api/new-withdraw \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{ "strategy_id": "STRATEGY_UUID" }' ``` Response: ```json { "wallet_id": "WALLET_UUID", "amount": 0, "transaction_hash": "", "transaction_id": "TRANSACTION_UUID" } ``` Save the `transaction_id` — you'll need it for polling and completing the withdrawal. **Step 2: Poll transaction status (API)** The server swaps all tokens to USDC. Poll until the status changes from `"swapping"` to `"pending"`. ```bash curl https://api.replicats.ai/api/transaction/TRANSACTION_UUID \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" ``` Status transitions: `"swapping"` → `"pending"` → `"confirmed"` - `"swapping"`: Server is converting tokens to USDC (wait and poll again) - `"pending"`: Swap complete, ready for you to withdraw on-chain Poll every 5–10 seconds until `status == "pending"`. **Step 3: Withdraw USDC on-chain** Once status is `"pending"`, call `withdrawUSDC()` on the vault contract. ```bash # Check USDC balance in vault cast call VAULT_ADDRESS \ "currentExposure(address)(uint256)" \ 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 \ --rpc-url https://mainnet.base.org # Withdraw all USDC cast send VAULT_ADDRESS \ "withdrawUSDC(uint256)" \ AMOUNT_IN_USDC_UNITS \ --rpc-url https://mainnet.base.org \ --private-key YOUR_PRIVATE_KEY ``` ```bash # Function: withdrawUSDC(uint256 amount) # Selector: 0xdb81f99b # USDC has 6 decimals: 100 USDC = 100000000 ``` **Step 4: Complete withdrawal (API)** Register the on-chain withdrawal so the platform records it: ```bash curl -X PATCH https://api.replicats.ai/api/new-withdraw \ -H "Authorization: Bearer YOUR_TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{ "strategy_id": "STRATEGY_UUID", "transaction_hash": "0xYourWithdrawTxHash", "transaction_id": "TRANSACTION_UUID" }' ``` ### Function Selectors (Write) | Function | Selector | Contract | Access | |----------|----------|----------|--------| | `approve(address,uint256)` | `0x095ea7b3` | USDC | Anyone (owner of tokens) | | `deposit(address,uint256)` | `0x47e7ef24` | Vault | `onlyOwner` | | `withdrawUSDC(uint256)` | `0xdb81f99b` | Vault | `onlyOwner` | --- ## Response Format Success responses include the requested data directly. Error responses: ```json { "detail": "Error message description" } ``` ## HTTP Status Codes | Code | Description | |------|-------------| | 200 | Success | | 201 | Created | | 400 | Bad Request - Invalid input | | 401 | Unauthorized - Invalid token | | 404 | Not Found | | 500 | Internal Server Error | --- ## Network Information Replicats operates on **Base** (Coinbase L2). - **Network:** Base Mainnet - **Chain ID:** 8453 - **Currency:** ETH - **Stablecoin:** USDC (0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913) - **RPC URL:** https://mainnet.base.org --- ## Vault Smart Contract Each user strategy has a Vault smart contract that holds funds and executes trades. **Example Vault:** `0x6d07e007d681419ce56308dc3f166a4a5bf9fe2a` ### Read Functions (View) You can call these directly via RPC to get real-time data: | Function | Returns | Description | |----------|---------|-------------| | `getTVLUsd1e18()` | `uint256` | Total Value Locked in USD (18 decimals) | | `getTokenPriceUsd1e18(address token)` | `uint256` | Token price in USD (18 decimals) | | `getAssetValueUsd1e18(address token)` | `uint256` | Value of token held in vault (USD, 18 decimals) | | `getOwnerPnlUsd1e18()` | `int256` | Owner's Profit/Loss in USD (18 decimals) | | `getOwnerRoi1e18()` | `int256` | Owner's ROI (1e18 = 100%) | | `getOwnerNetDepositsUsd1e18()` | `int256` | Net deposits (deposits - withdrawals) | | `getAssets()` | `address[]` | List of allowed asset addresses | | `agentWallet()` | `address` | Agent wallet address | | `USDC()` | `address` | USDC token address | | `RCAT()` | `address` | RCAT token address | | `totalDepositedUsd1e18()` | `uint256` | Total deposited (USD, 18 decimals) | | `totalWithdrawnUsd1e18()` | `uint256` | Total withdrawn (USD, 18 decimals) | | `allowedAssets(address)` | `bool` | Check if asset is allowed | | `currentExposure(address)` | `uint256` | Current balance of asset | ### Example: Read TVL using cast ```bash cast call 0x6d07e007d681419ce56308dc3f166a4a5bf9fe2a "getTVLUsd1e18()" --rpc-url https://mainnet.base.org ``` ### Example: Read TVL using curl (JSON-RPC) ```bash curl -X POST https://mainnet.base.org \ -H "Content-Type: application/json" \ -d '{ "jsonrpc": "2.0", "method": "eth_call", "params": [{ "to": "0x6d07e007d681419ce56308dc3f166a4a5bf9fe2a", "data": "0x50b6f9b1" }, "latest"], "id": 1 }' ``` **Function Selectors:** - `getTVLUsd1e18()` = `0x50b6f9b1` - `getOwnerPnlUsd1e18()` = `0x8aa0eaaa` - `getOwnerRoi1e18()` = `0xd6700563` - `getAssets()` = `0x67e4ac2c` - `agentWallet()` = `0x3f6dfdbc` - `USDC()` = `0x89a30271` - `RCAT()` = `0x7bee0bdf` - `totalDepositedUsd1e18()` = `0x6fb5ccaf` - `totalWithdrawnUsd1e18()` = `0xf587a848` ### Token Addresses (Base) | Token | Address | Decimals | |-------|---------|----------| | USDC | 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 | 6 | | WETH | 0x4200000000000000000000000000000000000006 | 18 | | cbBTC | 0xcbB7C0000aB88B473b1f5aFd9ef808440eed33Bf | 8 | | RCAT | 0x6af73d4579c70a24d52e4f4b43eecb2a75019f94 | 18 | --- ## Quick Start for Agents ```bash # 1. Authenticate with your Farcaster ID TOKEN=$(curl -s -X POST https://api.replicats.ai/api/auth/agent \ -H "Content-Type: application/json" \ -d '{"fid": YOUR_FID}' | jq -r '.token') # 2. Register your wallet curl -s -X POST https://api.replicats.ai/api/wallet/register \ -H "Authorization: Bearer $TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{"wallet_address": "0xYourWalletAddress"}' # 3. Create a strategy curl -s -X POST https://api.replicats.ai/api/strategy/create \ -H "Authorization: Bearer $TOKEN" \ -H "x-auth-method: agent" \ -H "Content-Type: application/json" \ -d '{"agent_id": "AGENT_UUID", "wallet_address": "0xYourWalletAddress", "description": "My strategy"}' # 4. Poll until vault_address is populated curl -s https://api.replicats.ai/api/strategy/list \ -H "Authorization: Bearer $TOKEN" \ -H "x-auth-method: agent" # 5. View your profile and wallets curl -s https://api.replicats.ai/api/me \ -H "Authorization: Bearer $TOKEN" \ -H "x-auth-method: agent" ``` --- ## Ideas for AI Agents - Monitor portfolio and alert on significant changes - Track agent performance over time - Compare forecasts vs actual results - Generate daily/weekly performance reports - Auto-rebalance between agents based on performance --- ## Support - Website: https://app.replicats.ai - Twitter: @replicatsai