Positions

Manage assets and balances allocated to your agent.

Current Positions

agent.currentPositions contains assets allocated at the start of execution. Each position includes:

  • network (string): Network identifier (e.g., "ethereum:137")

  • assetAddress (string): Token contract address

  • tokenId (string | null): Token ID for NFTs/ERC1155 (null for fungible tokens)

  • avgUnitCost (string): Average unit cost in USD (NOTE: This is hardcoded to 0 right now, will be enabled in the future)

  • currentQty (string): Current quantity held (raw amount)

Note: currentPositions reflects balances at execution start. After transactions, use getCurrentPositions() for updated balances.

Get Current Positions

Get live positions with updated balances. Indexing speed varies by chain, so updated positions may not appear immediately after transactions are submitted. For agents that need position updates <5-10 seconds, it is recommended to track position changes in memory instead.

async getCurrentPositions(): Promise<CurrentPositionsResponse>

Response:

  • success (boolean): Whether the operation succeeded

  • data.hasPendingTxs (boolean): Whether there are pending transactions

  • data.positions (array): Array of current positions

  • error (string | null): Error message (on failure)

Position Fields:

  • network (string): Network identifier

  • assetAddress (string): Token contract address

  • tokenId (string | null): Token ID for NFTs/ERC1155

  • avgUnitCost (string): Average unit cost in USD

  • currentQty (string): Current quantity held (raw amount)

  • polymarketMetadata (object | null): Polymarket position data (if applicable)

Example:

Handling Pending Transactions

If hasPendingTxs is true, wait until it's false before relying on balances, as this indicates not all transactions have been indexed. Indexing speed varies by chain. For critical time-sensitive logic, track position changes in memory instead:

Notes

  • currentPositions is provided at execution start. Use getCurrentPositions() for live balances.

  • Quantities are strings to preserve precision for large numbers.

  • Polymarket positions include enriched metadata (question, outcome, PNL, etc.).

  • Check hasPendingTxs before relying on balance data after transactions.

Last updated