> For the complete documentation index, see [llms.txt](https://docs.gage.cash/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.gage.cash/protocol/deal-lifecycle.md).

# Deal lifecycle and states

```mermaid
stateDiagram-v2
    [*] --> LISTED : list · collateral escrowed
    LISTED --> CANCELLED : cancel · borrower
    LISTED --> FUNDED : fund · lender pays the asking price
    FUNDED --> RECLAIMED : reclaim · borrower pays the cap
    FUNDED --> CLAIMED : claim · lender, after expiry + grace
```

## States as the app shows them

| Pill            | Sentence                                                                                     | On-chain state                                |
| --------------- | -------------------------------------------------------------------------------------------- | --------------------------------------------- |
| **LISTED**      | Open at its asking price until funded or cancelled                                           | LISTED                                        |
| **FUNDED**      | Running. The borrower may reclaim at any time                                                | FUNDED, before expiry                         |
| **RECLAIMABLE** | Expired. The borrower may still reclaim; the lender waits for grace to end                   | FUNDED, after expiry, before `expiry + grace` |
| **CLAIMABLE**   | Grace has ended. The lender may claim; the borrower may still reclaim until a claim executes | FUNDED, after `expiry + grace`                |
| **RECLAIMED**   | The borrower paid the cap and holds the collateral again                                     | RECLAIMED                                     |
| **CLAIMED**     | The lender holds the collateral                                                              | CLAIMED                                       |
| **CANCELLED**   | Taken off the market before funding                                                          | CANCELLED                                     |

Reclaimable and claimable are the same on-chain state read against the clock. Deadlines are exclusive: a deal is claimable once `now ≥ expiry + grace`.

## Transitions

| Call        | Who                   | Precondition                                                                                           | Effect                                                                                                                                          |
| ----------- | --------------------- | ------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------- |
| `list`      | Borrower              | Collateral passes the adapter's checks. New deals not paused. Cap, term and asking price within bounds | Collateral escrowed. Deal LISTED                                                                                                                |
| `cancel`    | Borrower              | Deal LISTED                                                                                            | Collateral credited back to the borrower. Deal CANCELLED                                                                                        |
| `fund`      | Lender                | Deal LISTED                                                                                            | Exactly the asking price pulled. Fee to the fee sink, remainder to the borrower's balance. `fundedAt = now`, `expiry = now + term`. Deal FUNDED |
| `reclaim`   | Borrower              | Deal FUNDED, not yet claimed                                                                           | Borrower pays exactly the cap, credited to the lender. Collateral credited to the borrower. Deal RECLAIMED                                      |
| `claim`     | Lender                | Deal FUNDED, `now ≥ expiry + grace`                                                                    | Collateral credited to the lender. Deal CLAIMED                                                                                                 |
| `withdraw…` | Anyone with a balance | Balance > 0                                                                                            | Pulls USDG, an ERC-20, or a position NFT owed to the caller                                                                                     |

Funding is atomic: escrow becomes the borrower's balance plus the fee, the state becomes FUNDED and the expiry is set, with no intermediate state observable.

## Offers

The vault also carries an offer flow (`bid`, `withdrawBid`, `accept`) in which a lender escrows a price below the cap and the borrower accepts one. It is dormant: the first version of the app lists at an asking price and funds in one step. Offers can be switched on later without a new vault. Under the hood, `fund` records an already-accepted offer so the accounting is one path.

## Grace

The grace window is a constructor parameter, at least 24 hours, 48 hours on mainnet. It is exclusive to the borrower. It is long against a 7-day term, but only the walk-away branch waits for it, and it is what stops a chain outage from costing a borrower their collateral.

## Early reclaim

Allowed at the full cap from the moment of funding. The lender is paid the same amount sooner. Rewards keep their original schedule.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.gage.cash/protocol/deal-lifecycle.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
