> For the complete documentation index, see [llms.txt](https://docs.peach.ag/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/rwa-calendar-and-fee-curve.md).

# RWA Calendar and Fee Curve

RWA pools adjust their autonomous base fee to a configured market calendar. A session label changes the fee policy; **CLOSED is not a trading pause**. Trading still depends on liquidity, valid configuration and the separate Hook pause state.

### Sessions and fee shape

| Session   | Base behavior                                                                                                                      |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| OPEN      | An opening peak descends toward openFloor over descentWindow. An opening after a fully closed local date can use a different peak. |
| OVERNIGHT | Uses overnightFloor, subject to an overlapping closing envelope.                                                                   |
| CLOSED    | Uses closedFloor, subject to an overlapping closing envelope. The closed rate is not inherently the highest rate.                  |

The closing envelope and session base combine using **max**, not addition. Then the directional premium, ordinary keeper/cap rules and optional Mid-block policy apply. For production quoting, prefer the on-chain policy reads over duplicating calendar logic.

### One worked curve

Example configuration: floors 100 / 300 / 700 pips, spikeMult=3, closedSpike=1200, descentWindow=600 seconds, closeFloor=800, closeBefore=600 and closeAfter=300. No directional premium or keeper is applied here.

| Point in time                            | Base fee (pips) | Percent |
| ---------------------------------------- | --------------- | ------- |
| Normal Tuesday opening                   | 900             | 0.09%   |
| Tuesday, 5 minutes after opening         | 500             | 0.05%   |
| Tuesday, 10 minutes after opening        | 100             | 0.01%   |
| Monday opening after fully closed Sunday | 1200            | 0.12%   |
| Monday, 5 minutes after opening          | 650             | 0.065%  |
| 5 minutes before close                   | 450             | 0.045%  |
| At close                                 | 800             | 0.08%   |
| Friday, first 5 minutes after close      | 800             | 0.08%   |
| Friday, exactly 5 minutes after close    | 700             | 0.07%   |

Fees do not guarantee executable liquidity while the underlying market is closed. The token issuer defines any asset rights or redemption process; the pool calendar does not establish them.

### Exact calendar and curve reference

The Hook's immutable `marketCalendar` computes `poolFeeAt(poolId, block.timestamp)`. Its public calendar getters are also forwarded through RwaRamp. For most integrations, sample `autonomousFee` and refresh rather than maintaining a second production calendar implementation. The following rules specify an exact local reproduction when needed.

### Local time, day classification and overrides

`DstMode`: AUTO=0, FIXED\_EST=1, FIXED\_EDT=2. EST subtracts 18,000 seconds from UTC; EDT subtracts 14,400. AUTO uses EDT from **00:00 UTC on the second Sunday of March**, inclusive, until **00:00 UTC on the first Sunday of November**, exclusive. This matches the source and differs from a standard US/Eastern 02:00 wall-clock transition. Setting a fixed mode is authorized only if its offset agrees with AUTO at the setting transaction's time; once set, evaluation uses that fixed mode.

Reject timestamps smaller than the selected offset (`InvalidTimestamp`); zero is not shorthand for now. Compute local day index and second of day from `timestamp - offset`, using Gregorian dates and Sunday=0 weekdays.

Default session hours are 09:30:00 (34200) to 16:00:00 (57600) in that local time. Configured hours are per pool. An early-close override replaces close only if `open < early <= close` and `early - open >= 10800`. Recheck this at evaluation time: a later hours change can make an old override stale and ignored.

A date is `fullyClosed` if marked FORCE\_CLOSED, or is a weekend or a holiday, unless FORCE\_OPEN overrides it. The monthly override is a uint64 with two bits per local day: `(packed >> (2*(day-1))) & 3`, NONE=0, FORCE\_CLOSED=1, FORCE\_OPEN=2; 3 is invalid. Friday's post-close classification is separate:

```
if (weekday == Friday and second >= close) or fullyClosed(date): CLOSED
else if open <= second < close: OPEN
else: OVERNIGHT
```

Consequently FORCE\_OPEN removes full-day weekend/holiday closure but does not remove the Friday post-close rule. FORCE\_CLOSED affects that entire local date. Only the pinned built-in holiday table for 2026–2030 is consulted; outside those years there is no built-in holiday match. Weekends and explicit overrides continue to apply. Do not infer new holidays or automatic half days from an external calendar. The exact built-in dates are listed below.

| Year | Month-day entries                                                    |
| ---- | -------------------------------------------------------------------- |
| 2026 | 01-01, 01-19, 02-16, 04-03, 05-25, 06-19, 07-03, 09-07, 11-26, 12-25 |
| 2027 | 01-01, 01-18, 02-15, 03-26, 05-31, 06-18, 07-05, 09-06, 11-25, 12-24 |
| 2028 | 01-17, 02-21, 04-14, 05-29, 06-19, 07-04, 09-04, 11-23, 12-25        |
| 2029 | 01-01, 01-15, 02-19, 03-30, 05-28, 06-19, 07-04, 09-03, 11-22, 12-25 |
| 2030 | 01-01, 01-21, 02-18, 04-19, 05-27, 06-19, 07-04, 09-02, 11-28, 12-25 |

### Curve fields and exact operation order

`FloorConfig = (openFloor, overnightFloor, closedFloor, spikeMult, closedSpike, descentWindow, closeFloor, closeBefore, closeAfter)`.

For valid nonnegative elapsed times, define:

```
descending(peak, floorValue, elapsed, window):
    if window == 0 or elapsed >= window or peak <= floorValue: return floorValue
    return floorValue + floor((peak-floorValue)*(window-elapsed)/window)

ascending(floorValue, peak, elapsed, window):
    if window == 0 or elapsed >= window or peak <= floorValue: return peak
    return floorValue + floor((peak-floorValue)*elapsed/window)
```

First choose the session base:

```
CLOSED:     base = closedFloor
OVERNIGHT:  base = overnightFloor
OPEN:
    peak = closedSpike if previous local date is fullyClosed
           else overnightFloor * spikeMult
    base = descending(peak, openFloor, second-open, descentWindow)
```

Then apply the independent closing envelope on a date that is not fully closed, provided `closeFloor != 0` and `second >= open`:

```
w = min(closeBefore, close-open)
ramp = 0
if w != 0 and close-w <= second <= close:
    ramp = openFloor if closeFloor <= openFloor
           else ascending(openFloor, closeFloor, second-(close-w), w)
else if close <= second < close+closeAfter:
    ramp = closeFloor
base = max(base, ramp)
```

The ramp and opening curve may overlap; use **max**, not sum or replacement. Friday after close is CLOSED but its closing hold can still dominate `closedFloor`. The instant `second == close` belongs to the ramp if it has a nonzero window; the hold's upper endpoint is exclusive. At `second == close + closeAfter`, the hold no longer applies. At the end of the opening descent window, the opening curve equals `openFloor`.

After this calendar base, add the directional premium and apply [ordinary cap/keeper resolution](https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/fees-and-keeper-policy), followed by [Mid-block policy](https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/mid-block-policy-and-observations). Do not cap the raw curve before adding the directional premium, and do not reject a valid high raw peak.

Configuration constraints relevant to interpreting data: the three session floors are at least 100 and no greater than the pool cap; `spikeMult <= 20`; descent/close windows are at most 6 hours. If descentWindow=0, spikeMult and closedSpike must both be zero. Otherwise both opening peak choices must exceed openFloor. A nonzero closeFloor lies between openFloor and cap and requires at least one nonzero close window. Authorized writes validate these relationships; readers should not silently fabricate defaults for missing configuration.

### SDK integration

Use the client from [Quickstart](https://docs.peach.ag/documentation/arc/adaptive-pools/quickstart) with a registered `rwa-ramp` pool. These examples follow SDK `1.0.1`, `main@b5fc5ba`; browsing needs no wallet.

```typescript
import type { MarketClient } from "@masterpeach/market-sdk";
import type { Hex } from "viem";

export async function readRwaFees(
  client: MarketClient, poolId: Hex, zeroForOne: boolean,
) {
  const pool = await client.getPool(poolId);
  if (pool.data.hookKind !== "rwa-ramp") throw new Error("Select an RwaRamp pool");
  const [session, fees] = await Promise.all([
    client.getSession(poolId, pool.block),
    client.getFeeBreakdown(poolId, zeroForOne, pool.block),
  ]);
  return { block: pool.block, session: session.data, fees: fees.data };
}

export async function previewRwaCurve(
  client: MarketClient, poolId: Hex, zeroForOne: boolean,
  timestamps: readonly bigint[],
) {
  const current = await readRwaFees(client, poolId, zeroForOne);
  const points = [];
  for (const timestamp of timestamps)
    points.push(await client.previewFeeAt(poolId, zeroForOne, timestamp, current.block));
  return { block: current.block, points };
}
```

Reuse the returned `block` for related reads. `getFeeBreakdown` and `previewFeeAt` require the configured RampReader; `getCurrentFees` reads both directions without a Reader. Sessions are `"open"`, `"overnight"`, `"closed"`; non-RWA session reads return `null`. `closed` is a fee period, not a trading pause. `zeroForOne=true` means currency0 → currency1; derive buy/sell with `getMarketSwapDirection` and explicit base/quote assets.

Use Unix **seconds** as `bigint`; `0n` is literal zero, not now. For example, `BigInt(Date.parse("2026-10-23T13:30:00Z") / 1000)` denotes an explicit UTC instant. A single session preview is `getSession(poolId, { ...block, timestamp })`. Let the contract evaluate DST, holidays and overrides.

For charts, `baseFeePips` is the raw calendar curve (`bigint`); `cappedAutonomousFeePips` adds premium and cap, while `finalFeePips` also resolves the temporary override (both `number`). `100 pips = 0.01%`; do not mix pips with claim/distribution bps.

Every curve point uses the selected block's configuration. It does not restore historical configuration or guarantee future execution fees. The frontend owns sampling density and refresh; keep RPC concurrency bounded and surface unavailable data rather than zero fees. `getCurrentFees` and `finalFeePips` exclude the one-block Mid-block surcharge: obtain a fresh `quoteSwap` for trading and keep the user's minimum output/maximum input and deadline.

Calendar administration uses permission-aware `getManagementAuthorization` / `prepareManagement` direct, schedule and execute flows through RwaRamp. Relevant actions are `setRwaPoolConfig`, `setSessionHours`, `setDayOverrides`, `setDstMode`, `setEarlyClose`. The mainnet preset has management disabled; enabling it requires independent review and an authorized wallet. `marketDaysInMonth` / `packMarketDayOverrides` validate/encode dates rather than calculate curves; monthly overrides replace the full month, at most ten dates, and empty `days` clears it.

Source: [SDK fee/session API](https://git.techpilots.org/web/peach/peach-ts-sdk/-/blob/b5fc5bacdbee2364128044a4afe793682fa323f4/packages/market/src/actions/fees.ts).


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.peach.ag/documentation/arc/adaptive-pools/core-features/rwa-calendar-and-fee-curve.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
