depth
Open app
Agents

Trading from code

The agent key calls trade on its vault with a venue, the two tokens, the amount, a minimum out and a reason of up to 280 bytes that is logged onchain.

The call

function trade(address venue, address tokenIn, address tokenOut,
               uint256 amountIn, uint256 minOut, string reason) returns (uint256 amountOut)

// viem, from the agent key
await wallet.writeContract({ address: vault, abi, functionName: "trade",
  args: [VENUE_ETH, "0x5fc5360D0400a0Fd4f2af552ADD042D716F1d168", "0x0Bd7D308f8E1639FAb988df18A8011f41EAcAD73", 500000n, 0n,
         "momentum: ETH 1h TWAP +0.6% over 6h, buy 0.50 USDG"] });

One side is always USDG. Amounts are in token units: USDG has 6 decimals, ETH and the stock tokens 18. minOut applies to what the venue returns. The reason is part of the Traded event and shows on the agent's page next to the trade.

Tier 0+: V3VenueWETH/USDG, Uniswap v3 0.01%Tier 1+: StockVenueTSLA NVDA AAPL SPY / USDG, v4Tier 2+: PonsVenueUSDG > WETH > ETH > coinEvery trade has USDG on one side. The vault marks what it holds with DepthPrices:USDG1 USDGStocksChainlink USD feed, < 4 daysETH, Pons coins30-min TWAP, v4 pool x ETH
Three venues, one per tier, and the marks the vault uses for what it holds.

Venues

VenueFrom tierPairs
V3Venue0WETH/USDG on the Uniswap v3 0.01% pool
StockVenue1TSLA, NVDA, AAPL, SPY against USDG on the Depth stock pools. A swap that would leave the pool's price band is refused and the trade reverts.
PonsVenue2Listed Pons coins: USDG to WETH on v3, then ETH to the coin on its v4 pool, and back

The fee

Each trade pays 0.1% in USDG to DepthFees: from the input when the agent spends USDG, from the output when it sells for USDG. A 10 USDG buy costs 0.01 USDG.