# Maker quickstart

Source: https://docs.hedgehood.io/earn-upfront/makers/quickstart

Seven steps from an allowlisted address to a bot quoting on Robinhood Chain testnet. The examples use the Python SDK;
the [TypeScript](https://github.com/0xHedgeHood/hedgehood-maker-ts) and
[Go](https://github.com/0xHedgeHood/hedgehood-maker-go) clients do the same things. The SDKs never sign or send a
transaction for you: they print unsigned ones that you review and send.

```bash
pip install hedgehood-maker
git clone https://github.com/0xHedgeHood/hedgehood-maker-py && cd hedgehood-maker-py   # for the examples
```

## 1. Get allowlisted

Send your **maker address** to [admin@hedgehood.io](mailto:admin@hedgehood.io): the account whose USDG pays premiums and which holds the longs. The
gateway refuses a login from any other address.

## 2. Delegate a hot signer

Keep the maker key cold. From the maker, call `RfqSettler.setSigner(hotKey, expiresAt)`; the hot key can then log in
and sign quotes for the maker until `expiresAt`. A quote only counts while `expiresAt > validUntil`, so rotate before
it expires; `setSigner(key, 0)` revokes one.

:::caution

A hot signer has the maker's full authority over its settler balance and its longs until it expires. Keep it
short-lived and keep the balance at what you mean to quote.

:::

## 3. Fund

Per quote, you choose how a premium is paid (the quote's `externalAccount`):

| Funding | `externalAccount` | Setup |
|---|---|---|
| Settler balance | `0x0` | `USDG.approve(settler, x)`, then `deposit(USDG, maker, x)`. Withdraw with `requestWithdraw`, then `withdraw` from 5 minutes to 1 day + 5 minutes later |
| Wallet by allowance | the paying wallet | `USDG.approve(settler, x)` from that wallet; if it is not the maker, it also calls `linkMaker(maker, true)` once |

## 4. Let the settler deliver your longs (to quote closes)

To quote early closes (side 1), the settler must be able to move your longs: `OptionsCore.setOperator(settler, true)`
from the maker. Skip this if you only buy.

## 5. Print and send the setup transactions

```bash
python examples/onboard.py --maker 0xYourMaker --signer 0xYourHotKey --signer-days 7 --deposit 1000 --sell --rpc
```

It prints each unsigned transaction (and a `cast send` line) plus, with `--rpc`, your current on-chain state: epoch,
signer, balances, allowances, operator. The Go CLI does the same with `hedgehood-maker tx …` and
`hedgehood-maker state`. Review each transaction and send it yourself.

## 6. Connect a bot

The smallest maker that works: it buys every open at 40 bps of the notional and declines the rest.

```python
import asyncio, os
from hedgehood_maker import MAKER_BUYS, RFQ, TESTNET, Decline, MakerClient
from hedgehood_maker.fees import notional

def price(rfq: RFQ):
    if rfq.side != MAKER_BUYS:
        return Decline("no_inventory")
    return notional(rfq.amount, rfq.series.strike) * 40 // 10_000   # premium in USDG raw, fee excluded

client = MakerClient(
    TESTNET.gateway_ws,
    os.environ["HEDGEHOOD_SIGNER_KEY"],          # the hot key from step 2
    price,
    maker="0xYourMaker",
    chain_id=TESTNET.chain_id, settler=TESTNET.settler,
    on_event=lambda f: print(f.type, f.raw),     # won, lost, fill, rejected, …
)
asyncio.run(client.run())
```

`MakerClient` logs in, calls your pricer within the window (it leaves 150 ms of margin and declines with `timeout` if
your pricer is slower), builds and signs the quote with a fresh nonce and your current epoch, checks it the way the
gateway will, and reconnects with backoff. `examples/simple_maker.py` adds Black-Scholes pricing, fee-aware premiums
and, with `--sell`, closes for longs you hold:

```bash
export HEDGEHOOD_SIGNER_KEY=...
python examples/simple_maker.py --maker 0xYourMaker --mode vol --vol 0.6 --spot TSLA=390 --edge 0.05 --sell
```

## 7. Test end to end

Request a quote yourself (any taker address works for a quote; a fill needs the taker's collateral):

```bash
curl -s https://testnet-rfq.hedgehood.io/v1/rfq -H 'content-type: application/json' -d \
  '{"underlying":"TSLA","expiry":<a listed 16:00 New York close>,"strike":"400000000","isPut":true,
    "side":0,"amount":"2000000000000000000","taker":"0xYourTestTaker"}'
```

Your bot should log the `rfq`, then `won` or `lost`. Then watch your scorecard:
`https://testnet-rfq.hedgehood.io/v1/makers`.

## Operating tips

- **Always answer.** Decline what you will not price; silence trips the breaker after 20 requests in a row.
- **Do not cancel a winner.** `increaseEpoch` or `invalidateNonces` after `won` is a fade; three in an hour pause you.
  To stop quoting, send `{"type":"pause"}` instead.
- **Keep the funds behind every outstanding quote.** A fill that reverts on funding fails the user the same way.
- **One connection per maker.** A new login replaces the old one.
- **Keep your clock on NTP.** `validUntil` is checked against chain time.

Next: [Settlement for makers](https://docs.hedgehood.io/earn-upfront/makers/settlement).
