> 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/invariants.md).

# Security invariants

Each of these is a property or invariant test in the contract suite. They are the promises the rest of this documentation rests on.

## Vault layer

| #   | Invariant                                                                                                                                                                       |
| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| I1  | Escrowed collateral is credited out only by `reclaim` to the borrower, `claim` to the lender, or `cancel` to the borrower. No other path exists.                                |
| I2  | No owner or admin function can move collateral or USDG belonging to a user, change a live deal's cap, term, expiry or parties, or alter the grace window for an existing deal.  |
| I3  | Pausing affects only listing and funding. Cancel, reclaim, claim and withdraw can never be paused.                                                                              |
| I4  | 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.                   |
| I5  | Solvency: the vault's USDG balance is at least the sum of open escrows plus the sum of USDG balances, at all times.                                                             |
| I6  | `reclaim` requires exactly the cap and credits exactly the cap to the lender.                                                                                                   |
| I7  | `claim` reverts before `expiry + grace`. `reclaim` reverts after a successful `claim`. Both can never succeed for the same deal.                                                |
| I8  | A funding or offer above the cap, below the asking price, past its expiry, or on a non-LISTED deal is rejected.                                                                 |
| I9  | The position adapter rejects wrong NFT contracts, unlisted pools, flagged hooks, zero or sub-minimum liquidity, out-of-range positions when required, and subscribed positions. |
| I10 | All external token paths are reentrancy-guarded. The vault accepts an NFT only from the PositionManager and only during an in-flight listing.                                   |
| I11 | No price is read on-chain except the current tick for the in-range check at deposit. No oracle dependency exists anywhere in the deal path.                                     |
| I12 | Code is immutable. Parameters are bounded at compile time: fee, grace, terms.                                                                                                   |

## Token layer

| #  | Invariant                                                                                                                                                                   |
| -- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| T1 | sGAGE total supply only ever decreases. It is minted once and burned by Buyback, by floor sweeps and at the end of emissions.                                               |
| T2 | The emissions contract can send sGAGE only to the reward contracts, cumulative emission never exceeds the schedule, and nothing leaves it after week 52 except to the burn. |
| T3 | Locked sGAGE unlocks only by the curve. No function, owner or otherwise, releases it early or slows it.                                                                     |
| T4 | A deal's reward is at most the rate times the fee paid, and a zero-fee deal earns zero.                                                                                     |
| T5 | The pool hook never reverts and never changes the result of a swap or a liquidity change. It only records. No token-layer contract ever holds a user's position NFT.        |
| T6 | Buyback only buys and burns. It never sells GAGE or sGAGE and never exceeds the impact bound.                                                                               |
| T7 | The creator-fee splitter can send only to the floor and the operations wallet, in the fixed split.                                                                          |
| T8 | The reinvest router ends every transaction holding nothing, and the position it mints is owned by the caller.                                                               |

## How they are tested

Unit and fuzz tests against test tokens that can pause, blocklist and charge transfer fees. Invariant tests run with a handler that exercises every external function and ghost totals for every balance, and fail on any revert the handler did not predict. Fork tests run against the live chain state. The suite runs on every commit.


---

# 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/invariants.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.
