Funding & Withdrawals
Use the Execution API for deposit addresses, balances, sync, and withdrawals
Funding endpoints require a signed-in user session. Start with Authentication before calling the execution routes below.
AGG exposes execution endpoints for deposit addresses, balance sync, withdrawals, positions, and orders so partners can build funding and account views on top of the same user session.
AGG's omni-chain funding flow lets users deposit on supported chains without choosing a destination venue account up front. After funds arrive, AGG tracks managed balances and automatically rebalances across managed accounts as needed for execution, eliminating the need for users to split deposits manually across venues or addresses.
How it works
Sign in via SIWE, SIWS, Google, or any supported provider.
Call GET /execution/deposit-addresses to get the user's wallet addresses and supported chains.
Returns 202 while the addresses are being prepared — poll until 200.
The user sends USDC to a supported deposit address on the chain they prefer.
Call GET /execution/balances to see per-chain cash balances plus current venue positions.
Use POST /execution/sync-balances to force an on-chain sync if needed. For paginated activity,
use GET /execution/positions and GET /execution/orders.
Use the same execution surface for withdrawals, positions, orders, and any account-level funding UI in your app.
import { createAggClient } from "@agg-build/sdk";
type DepositAddressesResponse =
| {
ready: true;
evmAddress: string;
svmAddress: string;
supportedChains: Array<{
chainId: number;
name: string;
tokens: Array<{
symbol: string;
address: string;
decimals: number;
}>;
}>;
}
| { ready: false };
const client = createAggClient({
baseUrl: "https://api.agg.market",
appId: "your-app-id",
});
// After user authenticates...
// 1. Get deposit addresses (poll until ready)
async function getDepositInfo() {
while (true) {
const res = await client.request<DepositAddressesResponse>(
"/execution/deposit-addresses",
);
if (res.ready) {
return {
evmAddress: res.evmAddress, // Send USDC here on any EVM chain
svmAddress: res.svmAddress, // Send USDC here on Solana
chains: res.supportedChains, // Available chains + token addresses
};
}
// Deposit addresses are still being prepared — wait and retry
await new Promise((r) => setTimeout(r, 2000));
}
}
const deposit = await getDepositInfo();
console.log("EVM deposit address:", deposit.evmAddress);
console.log("Solana deposit address:", deposit.svmAddress);
console.log("Supported chains:", deposit.chains.map((c) => c.name));
// 2. Check balances
const balances = await client.getManagedBalances();
// balances.cash — per-chain token balances
// balances.positions — per-venue position balances
// 3. Force balance sync (after deposit)
await client.request<Record<string, never>>("/execution/sync-balances", {
method: "POST",
body: JSON.stringify({}),
});Withdrawals
Withdraw USDC to any external address.
type WithdrawResponse = {
sources: Array<{
chainId: number;
amountRaw: string;
txHash?: string;
}>;
};
const result = await client.request<WithdrawResponse>("/execution/withdraw", {
method: "POST",
body: JSON.stringify({
amountRaw: "50000000", // 50 USDC (6 decimals)
tokenSymbol: "USDC",
destinationAddress: "0x...", // External wallet address
destinationChainId: 137, // Optional preferred destination chain
}),
});
// result.sources — which chains the funds came from
for (const source of result.sources) {
console.log(`${source.amountRaw} from chain ${source.chainId}`);
if (source.txHash) console.log(` tx: ${source.txHash}`);
}
Supported chains
The supportedChains array in the deposit response tells you exactly which chains and tokens
are available. Common chains include:
| Chain | Use |
|---|---|
| Polygon (137) | Polymarket trading |
| Arbitrum (42161) | Low-fee deposits |
| Ethereum (1) | High-value deposits |
| Solana | Solana-native venues |
Related execution endpoints
GET /execution/balancesfor managed cash balances and venue position balances.GET /execution/positionsfor paginated open positions grouped by matched market.GET /execution/ordersfor paginated execution activity.
Deposit detection
Deposits appear automatically after on-chain confirmation. There is no separate partner-side
confirmation step before the balance becomes visible in GET /execution/balances.
For faster UI feedback after a deposit, call POST /execution/sync-balances to trigger an
immediate on-chain balance refresh.
Keep a target-chain balance funded
Use Managed Balance Refills when a user wants AGG to maintain a USDC minimum on a selected chain after trading.