> For the complete documentation index, see [llms.txt](https://rwapact.gitbook.io/whitepaper/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rwapact.gitbook.io/whitepaper/pact-execution/gas-optimization.md).

# Gas Optimization

## Gas Optimization

The final Pact stage evaluates execution efficiency, produces the decision, and records its context. KGR, the **Gas Router**, contributes the gas and route conditions used before a Trade Intent can be authorized.

KGR does not independently approve a trade. Gas optimization is one required input into the complete Pact decision.

### Gas conditions

KGR evaluates available execution conditions through the strategies defined by the protocol:

* Gas monitoring and delay windows
* Batch execution and route comparison
* L2 fallback

These strategies help determine whether gas conditions are acceptable or optimized for the proposed action. They do not replace the checks performed by KRO, KSO, or KPV.

### Authorization or rejection

The Pact authorizes a trade only when its required conditions are satisfied:

* Risk is below the configured threshold.
* The session is active and within scope.
* Policy allows the asset and amount.
* Gas conditions are acceptable or optimized.

In other words:

```
Can_Trade =
  risk below threshold
  AND session active and in scope
  AND policy allows asset and amount
  AND gas is acceptable or optimized
```

If any required condition fails, the Pact rejects the Trade Intent. The decision includes a reason code or clear rejection reason so the Agent and surrounding system can determine why execution was not authorized.

{% hint style="info" %}
**RWAPACT does not execute the trade.** It decides whether the trade may reach the Execution Layer.
{% endhint %}

### Attesting the decision

KAR, the **Attestation Registry**, records the Pact decision on-chain. Both approvals and rejections can produce an attested record.

The attestation context can include an attestation ID, Agent, session, asset, amount, risk score, policy version, gas route hash, approval or rejection reason, and timestamp. When applicable, it also includes the execution transaction hash.

This record creates an auditable trail of what the Pact evaluated and why it reached its decision. The attestation model supports ERC-8273 compatibility as defined by RWAPACT.

### The complete decision boundary

```
Intent → Risk → Session → Policy → Gas → Decision → Attestation → Execution only if authorized
```

The Pact is the decision boundary between autonomous intent and actual RWA execution.

***


---

# 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://rwapact.gitbook.io/whitepaper/pact-execution/gas-optimization.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.
