otc-rfq 0.1.1

High-performance OTC Request-for-Quote engine supporting DeFi protocols and TradFi venues via FIX 4.4
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# =============================================================================
# Makefile for OTC RFQ Engine
# High-performance OTC Request-for-Quote engine
# =============================================================================

# Detect current branch
CURRENT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)

# Project name for packaging
PROJECT_NAME := otc-rfq

# =============================================================================
# Default target
# =============================================================================
.PHONY: all
all: fmt lint test build

# =============================================================================
# ๐Ÿ”ง Build & Run
# =============================================================================

.PHONY: build
build:
	@echo "๐Ÿ”จ Building debug version..."
	cargo build

.PHONY: release
release:
	@echo "๐Ÿš€ Building release version..."
	cargo build --release

.PHONY: run
run:
	@echo "โ–ถ๏ธ  Running application..."
	cargo run

.PHONY: run-release
run-release:
	@echo "โ–ถ๏ธ  Running application (release mode)..."
	cargo run --release

.PHONY: clean
clean:
	@echo "๐Ÿงน Cleaning build artifacts..."
	cargo clean

# =============================================================================
# ๐Ÿงช Test & Quality
# =============================================================================

.PHONY: test
test:
	@echo "๐Ÿงช Running all tests..."
	RUST_LOG=warn cargo test --all-features

.PHONY: test-lib
test-lib:
	@echo "๐Ÿงช Running library tests..."
	RUST_LOG=warn cargo test --lib

.PHONY: test-integration
test-integration:
	@echo "๐Ÿงช Running integration tests..."
	RUST_LOG=warn cargo test --test '*'

.PHONY: test-doc
test-doc:
	@echo "๐Ÿงช Running documentation tests..."
	cargo test --doc

.PHONY: fmt
fmt:
	@echo "โœจ Formatting code..."
	cargo +stable fmt --all

.PHONY: fmt-check
fmt-check:
	@echo "๐Ÿ” Checking code formatting..."
	cargo +stable fmt --all --check

.PHONY: lint
lint:
	@echo "๐Ÿ” Running clippy lints..."
	cargo clippy --all-targets --all-features -- -D warnings

.PHONY: lint-fix
lint-fix:
	@echo "๐Ÿ”ง Auto-fixing lint issues..."
	cargo clippy --fix --all-targets --all-features --allow-dirty --allow-staged -- -D warnings

.PHONY: fix
fix:
	@echo "๐Ÿ”ง Applying cargo fix suggestions..."
	cargo fix --allow-staged --allow-dirty

.PHONY: check
check: fmt-check lint test
	@echo "โœ… All checks passed!"

.PHONY: pre-push
pre-push: fix fmt lint-fix test doc
	@echo "โœ… All pre-push checks passed!"

# =============================================================================
# ๐Ÿ“ฆ Packaging & Docs
# =============================================================================

.PHONY: doc
doc:
	@echo "๐Ÿ“š Generating documentation..."
	cargo doc --no-deps --document-private-items

.PHONY: doc-open
doc-open:
	@echo "๐Ÿ“š Opening documentation in browser..."
	cargo doc --no-deps --open

.PHONY: doc-check
doc-check:
	@echo "๐Ÿ” Checking for missing documentation..."
	cargo clippy -- -W missing-docs

.PHONY: create-doc
create-doc:
	@echo "๐Ÿ“ Generating internal documentation..."
	@mkdir -p doc
	cargo doc --no-deps --document-private-items
	@echo "Documentation generated in target/doc/"

.PHONY: readme
readme:
	@echo "๐Ÿ“ Regenerating README..."
	@command -v cargo-readme > /dev/null || cargo install cargo-readme
	cargo readme > README.md.new
	@echo "New README generated as README.md.new"

.PHONY: publish
publish:
	@echo "๐Ÿ“ฆ Publishing to crates.io..."
	cargo publish --dry-run
	@echo "Dry run complete. Run 'cargo publish' to actually publish."

.PHONY: package
package:
	@echo "๐Ÿ“ฆ Creating package..."
	cargo package --list

# =============================================================================
# ๐Ÿ“ˆ Coverage & Benchmarks
# =============================================================================

.PHONY: coverage
coverage:
	@echo "๐Ÿ“Š Generating code coverage report (XML)..."
	@command -v cargo-tarpaulin > /dev/null || cargo install cargo-tarpaulin
	@mkdir -p coverage
	RUST_LOG=warn cargo tarpaulin --verbose --all-features --timeout 120 --out Xml --output-dir coverage

.PHONY: coverage-html
coverage-html:
	@echo "๐Ÿ“Š Generating HTML coverage report..."
	@command -v cargo-tarpaulin > /dev/null || cargo install cargo-tarpaulin
	@mkdir -p coverage
	RUST_LOG=warn cargo tarpaulin --all-features --timeout 120 --out Html --output-dir coverage

.PHONY: open-coverage
open-coverage:
	@echo "๐Ÿ“Š Opening coverage report..."
	open coverage/tarpaulin-report.html

.PHONY: check-cargo-criterion
check-cargo-criterion:
	@command -v cargo-criterion > /dev/null || cargo install cargo-criterion

.PHONY: bench
bench: check-cargo-criterion
	@echo "โšก Running benchmarks..."
	cargo criterion --output-format=quiet

.PHONY: bench-show
bench-show:
	@echo "๐Ÿ“Š Opening benchmark report..."
	open target/criterion/report/index.html

.PHONY: bench-save
bench-save:
	@echo "๐Ÿ’พ Saving benchmark baseline..."
	cargo criterion --save-baseline main

.PHONY: bench-compare
bench-compare:
	@echo "๐Ÿ“Š Comparing benchmarks against baseline..."
	cargo criterion --baseline main

.PHONY: bench-json
bench-json: check-cargo-criterion
	@echo "๐Ÿ“Š Running benchmarks (JSON output)..."
	cargo criterion --message-format=json

.PHONY: bench-clean
bench-clean:
	@echo "๐Ÿงน Cleaning benchmark data..."
	rm -rf target/criterion

# =============================================================================
# ๐Ÿ—„๏ธ Database
# =============================================================================

.PHONY: migrate
migrate:
	@echo "๐Ÿ—„๏ธ  Running database migrations..."
	sqlx migrate run

.PHONY: migrate-new
migrate-new:
	@echo "๐Ÿ—„๏ธ  Creating new migration..."
	@read -p "Migration name: " name; \
	sqlx migrate add $$name

.PHONY: migrate-revert
migrate-revert:
	@echo "๐Ÿ—„๏ธ  Reverting last migration..."
	sqlx migrate revert

.PHONY: db-reset
db-reset:
	@echo "๐Ÿ—„๏ธ  Resetting database..."
	sqlx database drop -y || true
	sqlx database create
	sqlx migrate run

# =============================================================================
# ๐Ÿณ Docker
# =============================================================================

.PHONY: docker-up
docker-up:
	@echo "๐Ÿณ Starting Docker services..."
	docker-compose up -d postgres redis

.PHONY: docker-down
docker-down:
	@echo "๐Ÿณ Stopping Docker services..."
	docker-compose down

.PHONY: docker-logs
docker-logs:
	@echo "๐Ÿณ Showing Docker logs..."
	docker-compose logs -f

.PHONY: docker-build
docker-build:
	@echo "๐Ÿณ Building Docker image..."
	docker build -t $(PROJECT_NAME):latest .

.PHONY: docker-run
docker-run:
	@echo "๐Ÿณ Running Docker container..."
	docker run -p 50051:50051 -p 8080:8080 $(PROJECT_NAME):latest

# =============================================================================
# ๐Ÿงน Git & Workflow Helpers
# =============================================================================

.PHONY: git-log
git-log:
	@if [ "$(CURRENT_BRANCH)" = "HEAD" ]; then \
		echo "You are in a detached HEAD state. Please check out a branch."; \
		exit 1; \
	fi; \
	echo "๐Ÿ“‹ Showing git log for branch $(CURRENT_BRANCH) against main:"; \
	git log main..$(CURRENT_BRANCH) --pretty=full

.PHONY: check-spanish
check-spanish:
	@echo "๐Ÿ” Checking for Spanish words in code..."
	@rg -n --pcre2 -e '^\s*(//|///|//!|#|/\*|\*).*?[รกรฉรญรณรบรร‰รร“รšรฑร‘ยฟยก]' \
		--glob '!target/*' \
		--glob '!**/*.png' \
		. && (echo "โŒ Spanish comments found"; exit 1) || echo "โœ… No Spanish comments found"

.PHONY: zip
zip:
	@echo "๐Ÿ“ฆ Creating project zip..."
	@mkdir -p dist
	zip -r dist/$(PROJECT_NAME)-$(shell date +%Y%m%d).zip . \
		-x "target/*" \
		-x ".git/*" \
		-x "*.DS_Store" \
		-x "coverage/*" \
		-x "dist/*"
	@echo "โœ… Created dist/$(PROJECT_NAME)-$(shell date +%Y%m%d).zip"

.PHONY: tree
tree:
	@echo "๐ŸŒณ Project structure:"
	@tree -I 'target|.git|node_modules|coverage|dist' -L 3

.PHONY: loc
loc:
	@echo "๐Ÿ“Š Lines of code:"
	@tokei --exclude target --exclude .git

.PHONY: deps
deps:
	@echo "๐Ÿ“ฆ Dependency tree:"
	cargo tree --depth 1

.PHONY: outdated
outdated:
	@echo "๐Ÿ“ฆ Checking for outdated dependencies..."
	@command -v cargo-outdated > /dev/null || cargo install cargo-outdated
	cargo outdated

.PHONY: audit
audit:
	@echo "๐Ÿ”’ Security audit..."
	@command -v cargo-audit > /dev/null || cargo install cargo-audit
	cargo audit

# =============================================================================
# ๐Ÿค– GitHub Actions (via act)
# =============================================================================

.PHONY: workflow-build
workflow-build:
	@echo "๐Ÿค– Simulating build workflow..."
	DOCKER_HOST="$${DOCKER_HOST}" act push --job build \
		-P ubuntu-latest=catthehacker/ubuntu:latest

.PHONY: workflow-lint
workflow-lint:
	@echo "๐Ÿค– Simulating lint workflow..."
	DOCKER_HOST="$${DOCKER_HOST}" act push --job lint

.PHONY: workflow-test
workflow-test:
	@echo "๐Ÿค– Simulating test workflow..."
	DOCKER_HOST="$${DOCKER_HOST}" act push --job test

.PHONY: workflow-coverage
workflow-coverage:
	@echo "๐Ÿค– Simulating coverage workflow..."
	DOCKER_HOST="$${DOCKER_HOST}" act push --job coverage

.PHONY: workflow
workflow: workflow-build workflow-lint workflow-test
	@echo "โœ… All workflows completed!"

# =============================================================================
# ๐Ÿš€ Release
# =============================================================================

.PHONY: version
version:
	@echo "๐Ÿ“‹ Current version:"
	@grep '^version' Cargo.toml | head -1

.PHONY: tag
tag:
	@echo "๐Ÿท๏ธ  Creating git tag..."
	@version=$$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/'); \
	git tag -a "v$$version" -m "Release v$$version"; \
	echo "Created tag v$$version"

# =============================================================================
# โ“ Help
# =============================================================================

.PHONY: help
help:
	@echo ""
	@echo "โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—"
	@echo "โ•‘              OTC RFQ Engine - Development Commands                    โ•‘"
	@echo "โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
	@echo ""
	@echo "๐Ÿ”ง Build & Run:"
	@echo "  make build           Compile the project (debug)"
	@echo "  make release         Build in release mode"
	@echo "  make run             Run the main binary"
	@echo "  make run-release     Run in release mode"
	@echo "  make clean           Clean build artifacts"
	@echo ""
	@echo "๐Ÿงช Test & Quality:"
	@echo "  make test            Run all tests"
	@echo "  make test-lib        Run library tests only"
	@echo "  make test-integration Run integration tests"
	@echo "  make fmt             Format code"
	@echo "  make fmt-check       Check formatting without applying"
	@echo "  make lint            Run clippy with warnings as errors"
	@echo "  make lint-fix        Auto-fix lint issues"
	@echo "  make fix             Auto-fix Rust compiler suggestions"
	@echo "  make check           Run fmt-check + lint + test"
	@echo "  make pre-push        Run all pre-push checks"
	@echo ""
	@echo "๐Ÿ“ฆ Packaging & Docs:"
	@echo "  make doc             Generate documentation"
	@echo "  make doc-open        Build and open Rust documentation"
	@echo "  make doc-check       Check for missing docs via clippy"
	@echo "  make create-doc      Generate internal docs"
	@echo "  make readme          Regenerate README using cargo-readme"
	@echo "  make publish         Prepare and publish crate to crates.io"
	@echo ""
	@echo "๐Ÿ“ˆ Coverage & Benchmarks:"
	@echo "  make coverage        Generate code coverage report (XML)"
	@echo "  make coverage-html   Generate HTML coverage report"
	@echo "  make open-coverage   Open HTML report"
	@echo "  make bench           Run benchmarks using Criterion"
	@echo "  make bench-show      Open benchmark report"
	@echo "  make bench-save      Save benchmark history snapshot"
	@echo "  make bench-compare   Compare benchmark runs"
	@echo "  make bench-json      Output benchmarks in JSON"
	@echo "  make bench-clean     Remove benchmark data"
	@echo ""
	@echo "๐Ÿ—„๏ธ  Database:"
	@echo "  make migrate         Run database migrations"
	@echo "  make migrate-new     Create a new migration"
	@echo "  make migrate-revert  Revert last migration"
	@echo "  make db-reset        Reset database (drop, create, migrate)"
	@echo ""
	@echo "๐Ÿณ Docker:"
	@echo "  make docker-up       Start Docker services"
	@echo "  make docker-down     Stop Docker services"
	@echo "  make docker-logs     Show Docker logs"
	@echo "  make docker-build    Build Docker image"
	@echo "  make docker-run      Run Docker container"
	@echo ""
	@echo "๐Ÿงน Git & Workflow Helpers:"
	@echo "  make git-log         Show commits on current branch vs main"
	@echo "  make check-spanish   Check for Spanish words in code"
	@echo "  make zip             Create zip without target/ and temp files"
	@echo "  make tree            Visualize project tree"
	@echo "  make loc             Count lines of code"
	@echo "  make deps            Show dependency tree"
	@echo "  make outdated        Check for outdated dependencies"
	@echo "  make audit           Run security audit"
	@echo ""
	@echo "๐Ÿค– GitHub Actions (via act):"
	@echo "  make workflow-build  Simulate build workflow"
	@echo "  make workflow-lint   Simulate lint workflow"
	@echo "  make workflow-test   Simulate test workflow"
	@echo "  make workflow-coverage Simulate coverage workflow"
	@echo "  make workflow        Run all workflows"
	@echo ""
	@echo "๐Ÿš€ Release:"
	@echo "  make version         Show current version"
	@echo "  make tag             Create git tag from Cargo.toml version"
	@echo ""