Index / Trading days
pattern · MIT · last updated 2026-08-27
Trading days
Revert beforeSwap outside NY weekday cash hours (9:30–16:00 ET, fixed UTC-5).
First-party rewrite inspired by horsefacts trading-days (MIT). beforeSwap reverts on weekends or outside the cash session. First open swap of the day emits DingDingDing. Simplified vs the original: no holiday/DST libraries — weekday + hour gate only. 14 permission fields, OpenZeppelin BaseHook. Listing is not an audit. Forge tests under test/TradingDays.t.sol.
Permission bits
These bits must match the deployed address. Confirm on-chain before you route.
beforeSwap
Solidity
Excerpt from contracts/TradingDays.sol. Copy the full file to implement this. Not an audit.
function getHookPermissions() public pure override returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: false,
afterInitialize: false,
beforeAddLiquidity: false,
afterAddLiquidity: false,
beforeRemoveLiquidity: false,
afterRemoveLiquidity: false,
beforeSwap: true,
afterSwap: false,
beforeDonate: false,
afterDonate: false,
beforeSwapReturnDelta: false,
afterSwapReturnDelta: false,
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}Spec
| Kind | pattern |
|---|---|
| Status | experimental |
| License | MIT |
| Source | https://github.com/CryptoGnome/v4hooks |
| Categories | RWACompliance |
| Properties | Vanilla swap |
| Chains | Ethereum |
| Docs | https://github.com/horsefacts/trading-days |
FAQ
Can I paste this into production? The snippet is an excerpt. Use the full file at the source URL, match flags to the address, and treat this page as a map, not a guarantee.
How do I build this safely? Start with secure v4 hooks and the OpenZeppelin hooks guide.