Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions .github/workflows/contracts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,52 @@ on:
paths:
- "contracts/**"
- ".github/workflows/contracts.yaml"
- "flake.nix"
- "flake.lock"

permissions:
contents: read

# Nix is installed via nix-quick-install-action; the shared `data-cartel-public`
# Cachix (cachix-action) and the per-runner nix store (cache-nix-action) are
# warmed before any `nix` build, and built paths are pushed back to Cachix. This
# replaces the DeterminateSystems installer + FlakeHub cache, whose hosted cache
# requires FlakeHub authentication. cachix-action is continue-on-error so a fork
# PR (no CACHIX_AUTH_TOKEN) skips the data-cartel-public cache and still builds
# against cache.nixos.org without failing the job.

jobs:
pipeline:
runs-on: ubuntu-latest
timeout-minutes: 45
env:
NIXPKGS_ALLOW_UNFREE: 1
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
persist-credentials: false

- uses: nixbuild/nix-quick-install-action@2c9db80fb984ceb1bcaa77cdda3fdf8cfba92035 # v34
with:
nix_version: "2.31.2"
nix_conf: |
accept-flake-config = true
fallback = true
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
keep-env-derivations = true
keep-outputs = true

- uses: cachix/cachix-action@ad2ddac53f961de1989924296a1f236fcfbaa4fc # v15
continue-on-error: true
with:
name: data-cartel-public
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- uses: DeterminateSystems/nix-installer-action@main
- uses: DeterminateSystems/flakehub-cache-action@main
- uses: DeterminateSystems/flake-checker-action@main
- uses: nix-community/cache-nix-action@7df957e333c1e5da7721f60227dbba6d06080569 # v7
with:
primary-key: nix-${{ runner.os }}-contracts-${{ hashFiles('**/*.nix', '**/flake.lock') }}
restore-prefixes-first-match: nix-${{ runner.os }}-contracts-
gc-max-store-size-linux: 5G

- name: Nix Flake check
run: nix flake check --impure --accept-flake-config --show-trace
Expand All @@ -33,4 +67,4 @@ jobs:
run: |
nix develop \
--impure --accept-flake-config --show-trace \
--command /bin/bash -c 'cd contracts && sui move test'
--command /bin/bash -c 'cd contracts/units && sui move test && cd ../conformance && sui move test && cd .. && sui move test'
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

# generated by but.nix on shell entry
.claude/skills/gitbutler
.cursor/skills/gitbutler
.cursor/cli.json
**/.cursor/skills/gitbutler
**/.cursor/cli.json

backend/testcandledata/target/
node_modules/
.worktrees/
.cursor/skills/gitbutler
12 changes: 6 additions & 6 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ early perpetual-specific margin and liquidation work; the generic instrument
architecture is specified in
[ADR 02](adrs/02-composable-instrument-standard.md).

| Directory | Contents | Standards |
| ------------ | ------------------------------------------------------------------------ | ------------------------------------------ |
| `contracts/` | Sui Move package `strike`: margin accounts, orderbook, pool, oracle | [contracts/AGENTS.md](contracts/AGENTS.md) |
| `backend/` | Rust crate `strikefi`: Rocket on Shuttle, sqlx, sui-sdk (indexing/cache) | [backend/AGENTS.md](backend/AGENTS.md) |
| `frontend/` | Vite + React + TypeScript dApp using @mysten/dapp-kit | [frontend/AGENTS.md](frontend/AGENTS.md) |
| `docs/` | Protocol math and design notes | — |
| Directory | Contents | Standards |
| ------------ | ------------------------------------------------------------------- | ------------------------------------------ |
| `contracts/` | Sui Move package `nth`: margin accounts, orderbook, pool, oracle | [contracts/AGENTS.md](contracts/AGENTS.md) |
| `backend/` | Rust crate `nth`: Rocket on Shuttle, sqlx, sui-sdk (indexing/cache) | [backend/AGENTS.md](backend/AGENTS.md) |
| `frontend/` | Vite + React + TypeScript dApp using @mysten/dapp-kit | [frontend/AGENTS.md](frontend/AGENTS.md) |
| `docs/` | Protocol math and design notes | — |

## Development Environment

Expand Down
4 changes: 2 additions & 2 deletions adrs/01-orderbook-insertion-sort.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

## Context

`strike::orderbook` stores each book side as a `vector<Order>` inside the shared
`nth::orderbook` stores each book side as a `vector<Order>` inside the shared
`Pool` object, sorted best-price-first (bids descending, asks ascending). The
matching engine consumes from index 0, cancellation and liquidation remove in
place — all order-preserving. The only operation that disturbs sortedness is
Expand Down Expand Up @@ -88,7 +88,7 @@ comparators would make the sort unstable at equal prices.
- The non-strict comparators are load-bearing: "optimizing" `ge`/`le` to
`gt`/`lt` breaks FIFO fairness without failing the sort itself. The
time-priority test guards this.
- Sorting stays private to `strike::orderbook`; no other module observes or
- Sorting stays private to `nth::orderbook`; no other module observes or
maintains book order.
- Revisit (superseding this record) when a side regularly holds hundreds of
orders, the book must outgrow a single object, or matching must skip price
Expand Down
10 changes: 5 additions & 5 deletions backend/AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# AGENTS.md — Backend

Standards for the `strikefi` Rust crate. Repo-wide rules (dev shell, GitButler,
Standards for the `nth` Rust crate. Repo-wide rules (dev shell, GitButler,
commit style) live in the root [AGENTS.md](../AGENTS.md).

## What This Is
Expand Down Expand Up @@ -56,10 +56,10 @@ all be clean before every commit. A broken commit on master deploys.
`.map_err(|e| ...to_string())`. `anyhow` is tolerable only at the binary's top
level, never inside logic you want to test.
- **Newtypes over primitives.** Values coming from or going to the chain (object
IDs, order ids, prices, sizes, USDC amounts) get newtypes mirroring
`strike::units` — a bare `u64` price and a bare `u64` size must not be
interchangeable here either. Same scaling rules apply: on-chain values are
fixed-point with 10^6 scaling; document the unit on every field.
IDs, order ids, prices, sizes, USDC amounts) get newtypes mirroring `units::*`
— a bare `u64` price and a bare `u64` size must not be interchangeable here
either. Same scaling rules apply: on-chain values are fixed-point with 10^6
scaling; document the unit on every field.
- **No boolean blindness.** Order side is an enum (`Side::Bid | Side::Ask`), not
`is_bid: bool`, except at the serialization boundary where the on-chain event
layout dictates the shape.
Expand Down
26 changes: 13 additions & 13 deletions backend/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion backend/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "strikefi"
name = "nth"
version = "0.1.0"
edition = "2021"

Expand Down
3 changes: 2 additions & 1 deletion contracts/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build/*
**/build/
**/.cursor/
.cursor/skills/gitbutler
Loading
Loading