write.account.deposit
Build unsigned transactions to deposit ERC20 tokens or ERC721 NFTs as collateral into Arcadia Finance accounts, enabling asset management for leveraged liquidity positions.
Instructions
Build an unsigned transaction to deposit assets into an Arcadia account as collateral. Supports ERC20 tokens and ERC721 NFTs (LP positions). NOT needed before write.account.add_liquidity — that tool deposits from wallet atomically. Ensure the account is approved first (call read.wallet.allowances to check, then write.wallet.approve if needed). Account version is auto-detected on-chain (override with account_version if needed).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| account_address | Yes | Arcadia account address | |
| asset_addresses | Yes | Token contract addresses to deposit | |
| asset_amounts | Yes | Amounts in raw units/wei, one per asset | |
| asset_ids | No | Token IDs: 0 for ERC20, NFT token ID for ERC721 | |
| asset_types | No | V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721). | |
| account_version | No | Override account version (3 or 4). Auto-detected on-chain if omitted. | |
| chain_id | No | Chain ID: 8453 (Base) or 130 (Unichain) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | Yes | ||
| transaction | Yes | ||
| predicted_account_address | No |
Implementation Reference
- The handler function for 'write.account.deposit' that validates input, detects account version, constructs the transaction data using ABI, and returns the transaction object.
async (params) => { try { if (params.asset_addresses.length !== params.asset_amounts.length) { return { content: [ { type: "text" as const, text: "Error: asset_addresses and asset_amounts must have the same length.", }, ], isError: true, }; } const validChainId = validateChainId(params.chain_id); const validAccount = validateAddress(params.account_address, "account_address"); // Auto-detect account version on-chain, or use override let version = params.account_version ?? 0; if (!version) { const client = getPublicClient(validChainId, chains); version = Number( await client.readContract({ address: validAccount, abi: accountAbi, functionName: "ACCOUNT_VERSION", }), ); } const ids = (params.asset_ids ?? params.asset_addresses.map(() => 0)).map((n) => BigInt(n)); const amounts = params.asset_amounts.map((a) => BigInt(a)); const abi = getAccountAbi(version); const args: unknown[] = [params.asset_addresses as `0x${string}`[], ids, amounts]; if (version >= 4) { const assetTypes = params.asset_types ? params.asset_types.map((t) => BigInt(t)) : ids.map((id) => (id > 0n ? 2n : 1n)); // 0 → ERC20 (1), non-zero → ERC721 (2) args.push(assetTypes); } const data = appendDataSuffix( encodeFunctionData({ abi, functionName: "deposit", args, }), ); const result = { description: `Deposit assets into Arcadia account (V${version})`, transaction: { to: validAccount, data, value: "0", chainId: validChainId, }, }; return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], structuredContent: result, }; } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } }, - The input schema for the 'write.account.deposit' tool using zod for validation.
inputSchema: { account_address: z.string().describe("Arcadia account address"), asset_addresses: z.array(z.string()).describe("Token contract addresses to deposit"), asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"), asset_ids: z .array(z.number()) .optional() .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"), asset_types: z .array(z.number()) .optional() .describe( "V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721).", ), account_version: z .number() .optional() .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."), chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"), }, - src/tools/write/account/deposit.ts:11-126 (registration)Registration function for the 'write.account.deposit' tool.
export function registerDepositTool(server: McpServer, chains: Record<ChainId, ChainConfig>) { server.registerTool( "write.account.deposit", { annotations: { title: "Build Deposit Transaction", readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: false, }, outputSchema: SimpleTransactionOutput, description: "Build an unsigned transaction to deposit assets into an Arcadia account as collateral. Supports ERC20 tokens and ERC721 NFTs (LP positions). NOT needed before write.account.add_liquidity — that tool deposits from wallet atomically. Ensure the account is approved first (call read.wallet.allowances to check, then write.wallet.approve if needed). Account version is auto-detected on-chain (override with account_version if needed).", inputSchema: { account_address: z.string().describe("Arcadia account address"), asset_addresses: z.array(z.string()).describe("Token contract addresses to deposit"), asset_amounts: z.array(z.string()).describe("Amounts in raw units/wei, one per asset"), asset_ids: z .array(z.number()) .optional() .describe("Token IDs: 0 for ERC20, NFT token ID for ERC721"), asset_types: z .array(z.number()) .optional() .describe( "V4 only. Asset types per asset: 1=ERC20, 2=ERC721, 3=ERC1155. If omitted, inferred from asset_ids (non-zero → ERC721).", ), account_version: z .number() .optional() .describe("Override account version (3 or 4). Auto-detected on-chain if omitted."), chain_id: z.number().default(8453).describe("Chain ID: 8453 (Base) or 130 (Unichain)"), }, }, async (params) => { try { if (params.asset_addresses.length !== params.asset_amounts.length) { return { content: [ { type: "text" as const, text: "Error: asset_addresses and asset_amounts must have the same length.", }, ], isError: true, }; } const validChainId = validateChainId(params.chain_id); const validAccount = validateAddress(params.account_address, "account_address"); // Auto-detect account version on-chain, or use override let version = params.account_version ?? 0; if (!version) { const client = getPublicClient(validChainId, chains); version = Number( await client.readContract({ address: validAccount, abi: accountAbi, functionName: "ACCOUNT_VERSION", }), ); } const ids = (params.asset_ids ?? params.asset_addresses.map(() => 0)).map((n) => BigInt(n)); const amounts = params.asset_amounts.map((a) => BigInt(a)); const abi = getAccountAbi(version); const args: unknown[] = [params.asset_addresses as `0x${string}`[], ids, amounts]; if (version >= 4) { const assetTypes = params.asset_types ? params.asset_types.map((t) => BigInt(t)) : ids.map((id) => (id > 0n ? 2n : 1n)); // 0 → ERC20 (1), non-zero → ERC721 (2) args.push(assetTypes); } const data = appendDataSuffix( encodeFunctionData({ abi, functionName: "deposit", args, }), ); const result = { description: `Deposit assets into Arcadia account (V${version})`, transaction: { to: validAccount, data, value: "0", chainId: validChainId, }, }; return { content: [ { type: "text" as const, text: JSON.stringify(result, null, 2), }, ], structuredContent: result, }; } catch (err) { return { content: [ { type: "text" as const, text: `Error: ${err instanceof Error ? err.message : String(err)}`, }, ], isError: true, }; } }, );