> ## Documentation Index
> Fetch the complete documentation index at: https://docs.b3os.org/llms.txt
> Use this file to discover all available pages before exploring further.

# DeFi and Market Actions

Use B3OS blockchain data, market, DeFi, futures, DEX, analytics, and token discovery actions.

B3OS includes a large blockchain data and DeFi action surface. These actions help workflows read token, market, protocol, position, DEX, futures, risk, and analytics data before deciding what to do next.

## Video Walkthroughs

**Auto-Deposit USDC Into Morpho's Top Vault on Arbitrum**

**Auto-Rebalance USDC Into Morpho's Highest-Yield Vault Every Week**

**Auto-Trade the NBA Underdog on Polymarket**

**More DeFi automations on YouTube**

See [aerodrome LP auto-claim](https://www.youtube.com/watch?v=wIcK3Vn7nyU), [Polymarket USDC funding from
  Morpho](https://www.youtube.com/watch?v=cx20ieUwN6k), and the full library on the [B3OS
  channel](https://www.youtube.com/@B3OS_AI).

## Action Families

| Family             | Examples                                                                               |
| ------------------ | -------------------------------------------------------------------------------------- |
| Token data         | Token lookup, metadata, price, decimals, discovery                                     |
| Market data        | CEX price, DEX price, futures, funding, market movement                                |
| DeFi               | Pools, yields, positions, protocol metrics, Morpho-style yield lookups                 |
| Analytics          | Dune, Coinglass, Coingecko, DexScreener, Codex, Chainalysis-style risk or data lookups |
| Prediction markets | Polymarket market and user activity                                                    |
| Onchain reads      | Balances, allowances, contract reads, transaction debugging                            |

## Read-Then-Decide Pattern

**Collect data**

Use market, token, position, or protocol read actions to gather context.
  **Normalize values**

Convert units, parse symbols, or select list min/max before branching.
  **Apply policy**

Check thresholds, risk flags, liquidity, slippage, or allowed markets.
  **Notify or execute**

Send a message, write an org database record, or call an onchain action.

## Example Decision Payload

```json
{
  "asset": "{{$props.asset}}",
  "price": "{{$nodes.fetchMarket.result.price}}",
  "threshold": "{{$props.alertThreshold}}",
  "shouldAlert": "{{$nodes.fetchMarket.result.price}} > {{$props.alertThreshold}}"
}
```

## Production Notes

| Concern           | Recommendation                                                           |
| ----------------- | ------------------------------------------------------------------------ |
| Rate limits       | Batch or cache where possible and avoid unnecessarily frequent schedules |
| Data freshness    | Include timestamps in notifications and downstream decisions             |
| Token decimals    | Normalize before comparisons and transfers                               |
| Provider variance | Handle missing fields and provider-specific error messages               |
| Trading actions   | Add policy branches before placing orders or moving funds                |

**Market data is not policy by itself**

Do not route a single unverified data point directly into a wallet action. Use thresholds, freshness checks, liquidity
  checks, and explicit branch logic.