openttt 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/README.md +52 -30
  2. package/dist/adaptive_switch.d.ts +22 -7
  3. package/dist/adaptive_switch.js +52 -15
  4. package/dist/auto_mint.d.ts +22 -7
  5. package/dist/auto_mint.js +107 -30
  6. package/dist/ct_log.d.ts +47 -0
  7. package/dist/ct_log.js +107 -0
  8. package/dist/dynamic_fee.d.ts +13 -2
  9. package/dist/dynamic_fee.js +62 -11
  10. package/dist/errors.d.ts +44 -25
  11. package/dist/errors.js +58 -42
  12. package/dist/evm_connector.d.ts +28 -1
  13. package/dist/evm_connector.js +124 -32
  14. package/dist/grg_api_client.d.ts +41 -0
  15. package/dist/grg_api_client.js +116 -0
  16. package/dist/http_client.d.ts +98 -0
  17. package/dist/http_client.js +252 -0
  18. package/dist/index.d.ts +5 -5
  19. package/dist/index.js +5 -5
  20. package/dist/logger.d.ts +36 -4
  21. package/dist/logger.js +70 -11
  22. package/dist/networks.d.ts +21 -0
  23. package/dist/networks.js +30 -4
  24. package/dist/pool_registry.d.ts +9 -0
  25. package/dist/pool_registry.js +37 -0
  26. package/dist/pot_signer.d.ts +15 -0
  27. package/dist/pot_signer.js +28 -0
  28. package/dist/protocol_fee.d.ts +42 -26
  29. package/dist/protocol_fee.js +77 -54
  30. package/dist/revenue_tiers.d.ts +36 -0
  31. package/dist/revenue_tiers.js +83 -0
  32. package/dist/signer.d.ts +1 -2
  33. package/dist/signer.js +72 -14
  34. package/dist/time_synthesis.d.ts +38 -0
  35. package/dist/time_synthesis.js +131 -21
  36. package/dist/trust_store.d.ts +49 -0
  37. package/dist/trust_store.js +89 -0
  38. package/dist/ttt_builder.d.ts +1 -1
  39. package/dist/ttt_builder.js +2 -2
  40. package/dist/ttt_client.d.ts +42 -29
  41. package/dist/ttt_client.js +117 -28
  42. package/dist/types.d.ts +46 -3
  43. package/dist/v4_hook.d.ts +10 -2
  44. package/dist/v4_hook.js +10 -2
  45. package/dist/x402_enforcer.d.ts +17 -2
  46. package/dist/x402_enforcer.js +27 -2
  47. package/package.json +6 -2
  48. package/dist/golay.d.ts +0 -6
  49. package/dist/golay.js +0 -166
  50. package/dist/grg_forward.d.ts +0 -11
  51. package/dist/grg_forward.js +0 -74
  52. package/dist/grg_inverse.d.ts +0 -7
  53. package/dist/grg_inverse.js +0 -100
  54. package/dist/grg_pipeline.d.ts +0 -13
  55. package/dist/grg_pipeline.js +0 -64
  56. package/dist/reed_solomon.d.ts +0 -12
  57. package/dist/reed_solomon.js +0 -179
  58. package/vendor/helm-crypto/golay.d.ts +0 -6
  59. package/vendor/helm-crypto/golay.js +0 -167
  60. package/vendor/helm-crypto/golay.js.map +0 -1
  61. package/vendor/helm-crypto/grg_forward.d.ts +0 -22
  62. package/vendor/helm-crypto/grg_forward.js +0 -89
  63. package/vendor/helm-crypto/grg_forward.js.map +0 -1
  64. package/vendor/helm-crypto/grg_inverse.d.ts +0 -16
  65. package/vendor/helm-crypto/grg_inverse.js +0 -118
  66. package/vendor/helm-crypto/grg_inverse.js.map +0 -1
  67. package/vendor/helm-crypto/grg_pipeline.d.ts +0 -13
  68. package/vendor/helm-crypto/grg_pipeline.js +0 -66
  69. package/vendor/helm-crypto/grg_pipeline.js.map +0 -1
  70. package/vendor/helm-crypto/index.d.ts +0 -5
  71. package/vendor/helm-crypto/index.js +0 -17
  72. package/vendor/helm-crypto/index.js.map +0 -1
  73. package/vendor/helm-crypto/logger.d.ts +0 -6
  74. package/vendor/helm-crypto/logger.js +0 -11
  75. package/vendor/helm-crypto/logger.js.map +0 -1
  76. package/vendor/helm-crypto/reed_solomon.d.ts +0 -37
  77. package/vendor/helm-crypto/reed_solomon.js +0 -210
  78. package/vendor/helm-crypto/reed_solomon.js.map +0 -1
package/README.md CHANGED
@@ -10,7 +10,9 @@ OpenTTT brings cryptographic time verification to blockchain transaction orderin
10
10
  [![License: BSL-1.1](https://img.shields.io/badge/License-BSL--1.1-blue.svg)](LICENSE)
11
11
  [![CI](https://github.com/Helm-Protocol/OpenTTT/actions/workflows/ci.yml/badge.svg)](https://github.com/Helm-Protocol/OpenTTT/actions/workflows/ci.yml)
12
12
  [![codecov](https://codecov.io/gh/Helm-Protocol/OpenTTT/branch/main/graph/badge.svg)](https://codecov.io/gh/Helm-Protocol/OpenTTT)
13
- [![Tests](https://img.shields.io/badge/tests-273%20passing%20%C2%B7%2029%20suites-brightgreen)]()
13
+ [![Tests](https://img.shields.io/badge/tests-386%20passing%20%C2%B7%2032%20suites-brightgreen)]()
14
+
15
+ > If this project is useful to you, please [star it on GitHub](https://github.com/Helm-Protocol/OpenTTT) — it helps others find it.
14
16
 
15
17
  ```
16
18
  npm install openttt
@@ -27,7 +29,7 @@ Current MEV protection relies on **trust**: builders promise fair ordering, prot
27
29
  | **Mechanism** | Social contract (request) | Physical verification (proof) |
28
30
  | **Enforcement** | Reputation, exclusion | Economic natural selection |
29
31
  | **Bad actors** | Must be identified and removed | Naturally unprofitable, self-selecting out |
30
- | **Time source** | Block timestamp (miner-controlled) | Multi-source NTP synthesis (NIST, KRISS, Google) |
32
+ | **Time source** | Block timestamp (miner-controlled) | Multi-source NTP synthesis (NIST, Google, Apple) |
31
33
 
32
34
  **The core insight**: Rollups generate precise timestamps and deliver them to builders with a receipt. The Adaptive GRG pipeline then verifies whether the builder respected that ordering:
33
35
 
@@ -40,7 +42,22 @@ No governance vote. No slashing committee. Cheating is simply bad business.
40
42
 
41
43
  ## Quick Start
42
44
 
43
- Three lines to start minting TimeTokens:
45
+ ### Try it in 30 seconds — No ETH, No Wallet
46
+
47
+ ```typescript
48
+ import { HttpOnlyClient } from "openttt";
49
+
50
+ const client = new HttpOnlyClient();
51
+ const pot = await client.generatePoT();
52
+ console.log(pot.timestamp, pot.confidence, pot.sources);
53
+
54
+ const valid = client.verifyPoT(pot);
55
+ console.log("Valid:", valid); // true
56
+ ```
57
+
58
+ No blockchain. No wallet. No gas fees. Just verified time from 4 independent HTTPS sources (NIST, Apple, Google, Cloudflare). Start here, upgrade to on-chain when ready.
59
+
60
+ ### On-Chain Mode (Full Power)
44
61
 
45
62
  ```typescript
46
63
  import { TTTClient } from "openttt";
@@ -49,9 +66,7 @@ const ttt = await TTTClient.forBase({ privateKey: process.env.OPERATOR_PK! });
49
66
  ttt.startAutoMint();
50
67
  ```
51
68
 
52
- That is it. The SDK connects to Base Mainnet, synthesizes time from three atomic clock sources, and begins minting Proof-of-Time tokens at your configured tier interval.
53
-
54
- > **Shorthand**: Pass `privateKey` directly as a string instead of the full `signer` config object. The verbose form `{ signer: { type: "privateKey", key: "0x..." } }` still works for when you need other signer types (Turnkey, KMS, Privy).
69
+ Connects to Base, synthesizes time from atomic clock sources, and mints Proof-of-Time tokens on-chain.
55
70
 
56
71
  ---
57
72
 
@@ -95,7 +110,7 @@ const ttt = await TTTClient.create({
95
110
  tier: "T1_block",
96
111
  contractAddress: "0x...",
97
112
  poolAddress: "0x...",
98
- timeSources: ["nist", "kriss", "google"],
113
+ timeSources: ["nist", "google", "cloudflare", "apple"],
99
114
  protocolFeeRate: 0.05,
100
115
  enableGracefulShutdown: true,
101
116
  });
@@ -246,8 +261,8 @@ const ttt = await TTTClient.create({
246
261
 
247
262
  | Method | Description |
248
263
  |---|---|
249
- | `GrgPipeline.processForward(data)` | Encode: Golomb compression -> Reed-Solomon erasure coding -> Golay verification |
250
- | `GrgPipeline.processInverse(shards, length)` | Decode: Golay verify -> Reed-Solomon reconstruct -> Golomb decompress |
264
+ | `GrgPipeline.processForward(data)` | Encode data through the multi-layer integrity pipeline, producing verifiable shards |
265
+ | `GrgPipeline.processInverse(shards, length)` | Decode shards back to original data with integrity verification |
251
266
 
252
267
  ### AdaptiveSwitch
253
268
 
@@ -264,37 +279,23 @@ const ttt = await TTTClient.create({
264
279
  ```
265
280
  TTTClient (entry point)
266
281
  |-- AutoMintEngine Periodic minting loop
267
- | |-- TimeSynthesis NTP multi-source median synthesis (NIST, KRISS, Google)
282
+ | |-- TimeSynthesis NTP multi-source median synthesis (NIST, Google, Apple)
268
283
  | |-- DynamicFeeEngine Oracle-based pricing
269
284
  | |-- EVMConnector On-chain mint/burn/events (ethers v6)
270
285
  | '-- ProtocolFee EIP-712 signed fee collection
271
286
  |-- AdaptiveSwitch TURBO/FULL mode state machine
272
- |-- GRG Pipeline Golomb + Reed-Solomon + Golay error correction
287
+ |-- GRG Pipeline Multi-layer data integrity (proprietary)
273
288
  |-- PoolRegistry Multi-pool statistics tracking
274
289
  '-- Signer Abstraction PrivateKey | Turnkey | Privy | KMS
275
290
  ```
276
291
 
277
- ### The GRG Pipeline
292
+ ### Data Integrity: GRG Pipeline
278
293
 
279
- GRG (Golomb-Reed-Golay) is the data integrity backbone of OpenTTT, analogous to how the TLS record protocol protects HTTP payloads.
294
+ GRG is a multi-layer data integrity pipeline that protects PoT payloads — analogous to how the TLS record protocol protects HTTP payloads. It provides compression, erasure coding, and error correction in a single pass.
280
295
 
281
- ```
282
- FORWARD (Encode)
283
- Raw Data --> Golomb-Rice Compression
284
- --> Reed-Solomon Erasure Coding
285
- --> Golay(24,12) Verification Codes
286
- --> Shards
287
-
288
- INVERSE (Decode)
289
- Shards --> Golay(24,12) Error Detection
290
- --> Reed-Solomon Reconstruction
291
- --> Golomb-Rice Decompression
292
- --> Raw Data
293
- ```
296
+ The pipeline produces verifiable shards that can be independently validated and reconstructed, ensuring PoT integrity even under partial data loss.
294
297
 
295
- **Golomb-Rice** compresses timestamp deltas efficiently (small integers compress well).
296
- **Reed-Solomon** adds erasure coding so data survives shard loss.
297
- **Golay(24,12)** detects and corrects up to 3-bit errors per 24-bit codeword.
298
+ > Implementation details are proprietary. See the [IETF Draft](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) for the abstract specification.
298
299
 
299
300
  ### Adaptive Mode Switching
300
301
 
@@ -311,7 +312,7 @@ This asymmetry is deliberate: it is hard to earn trust and easy to lose it.
311
312
  OpenTTT queries multiple atomic clock-synchronized NTP sources in parallel and produces a median-synthesized timestamp with confidence scoring:
312
313
 
313
314
  - **NIST** (time.nist.gov) -- US national standard
314
- - **KRISS** (time.kriss.re.kr) -- Korean national standard
315
+ - **Apple** (time.apple.com) -- Apple global time service
315
316
  - **Google** (time.google.com) -- Leap-smeared public NTP
316
317
 
317
318
  All readings must fall within a stratum-dependent tolerance of the synthesized median (10ms for stratum 1, 25ms for stratum 2, 50ms for stratum 3+), or the Proof of Time is rejected. Single-source operation triggers a degraded-confidence warning.
@@ -390,4 +391,25 @@ Copyright 2026 Helm Protocol.
390
391
 
391
392
  ---
392
393
 
394
+ ## Learn More
395
+
396
+ - [IETF Draft: draft-helmprotocol-tttps-00](https://datatracker.ietf.org/doc/draft-helmprotocol-tttps/) — TTTPS Protocol Specification
397
+ - [Yellow Paper](https://github.com/Helm-Protocol/OpenTTT/blob/main/YELLOW_PAPER.md) — Technical Deep Dive
398
+ - [MCP Server](https://github.com/Helm-Protocol/OpenTTT/tree/main/mcp) — AI Agent Integration (`@helm-protocol/ttt-mcp`)
399
+ - [Subgraph (The Graph)](https://api.studio.thegraph.com/query/1744392/openttt-base-sepolia/v0.2.0) — On-chain PoT Data
400
+ - [Base Sepolia Contracts](https://sepolia.basescan.org/address/0xde357135cA493e59680182CDE9E1c6A4dA400811) — TTT ERC-1155
401
+ - [Helm Protocol](https://github.com/Helm-Protocol) — GitHub Organization
402
+
393
403
  [GitHub](https://github.com/Helm-Protocol/OpenTTT) | Built by [Helm Protocol](https://github.com/Helm-Protocol)
404
+
405
+ ---
406
+
407
+ ## Contributing
408
+
409
+ Contributions are welcome. If you find a bug, have a feature request, or want to improve the documentation, please open an issue or submit a pull request on [GitHub](https://github.com/Helm-Protocol/OpenTTT).
410
+
411
+ - **Bug reports**: Open an issue with a minimal reproduction case.
412
+ - **Feature requests**: Open an issue describing the use case and expected behavior.
413
+ - **Pull requests**: Fork the repo, make your changes, ensure all tests pass (`npm test`), and open a PR against `main`.
414
+
415
+ For significant changes, please open an issue first to discuss the approach.
@@ -12,6 +12,8 @@ export interface Block {
12
12
  txs: string[];
13
13
  data: Uint8Array;
14
14
  }
15
+ /** Tier-based dynamic tolerance (ms) — auditor-requested upgrade */
16
+ export declare const TIER_TOLERANCE_MS: Record<string, number>;
15
17
  export declare class AdaptiveSwitch {
16
18
  private windowSize;
17
19
  private threshold;
@@ -22,23 +24,36 @@ export declare class AdaptiveSwitch {
22
24
  private consecutiveFailures;
23
25
  private turboEntryThreshold;
24
26
  private turboMaintainThreshold;
27
+ private tolerance;
28
+ constructor(options?: {
29
+ tolerance?: number;
30
+ });
25
31
  /**
26
- * TTT 핵심 메커니즘: 타임스탬프 순서 일치율에 따른 Turbo/Full 모드 전환
32
+ * Core TTT mechanism: switches between Turbo/Full mode based on timestamp ordering match rate.
27
33
  */
28
- verifyBlock(block: Block, tttRecord: TTTRecord): AdaptiveMode;
34
+ verifyBlock(block: Block, tttRecord: TTTRecord, chainId: number, poolAddress: string, tier?: string): AdaptiveMode;
29
35
  /**
30
- * 모드에 따른 수수료 할인율 반환
31
- * TURBO: 20% 할인 (수익 증가 유도)
32
- * FULL: 할인 없음
36
+ * Return fee discount rate based on current mode.
37
+ * TURBO: 20% discount (incentivizes profitability).
38
+ * FULL: No discount.
33
39
  */
34
40
  getFeeDiscount(): number;
35
41
  /**
36
- * 현재 모드 조회
42
+ * Get current adaptive mode.
37
43
  */
38
44
  getCurrentMode(): AdaptiveMode;
39
45
  /**
40
- * 테스트용: 이력 초기화
46
+ * Reset history (for testing).
41
47
  */
42
48
  reset(): void;
49
+ /**
50
+ * Serialize internal state to JSON for persistence across restarts.
51
+ * Allows operators to avoid re-learning over 20 blocks after a restart.
52
+ */
53
+ serialize(): string;
54
+ /**
55
+ * Reconstruct an AdaptiveSwitch from previously serialized JSON state.
56
+ */
57
+ static deserialize(json: string): AdaptiveSwitch;
43
58
  private compareTransactionOrder;
44
59
  }
@@ -2,15 +2,22 @@
2
2
  // sdk/src/adaptive_switch.ts — Adaptive Mode Switcher
3
3
  // Turbo (50ms) vs Full (127ms)
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.AdaptiveSwitch = exports.AdaptiveMode = void 0;
6
- const grg_inverse_1 = require("./grg_inverse");
5
+ exports.AdaptiveSwitch = exports.TIER_TOLERANCE_MS = exports.AdaptiveMode = void 0;
6
+ const helm_crypto_1 = require("../vendor/helm-crypto");
7
7
  const logger_1 = require("./logger");
8
8
  var AdaptiveMode;
9
9
  (function (AdaptiveMode) {
10
10
  AdaptiveMode["TURBO"] = "TURBO";
11
11
  AdaptiveMode["FULL"] = "FULL";
12
12
  })(AdaptiveMode || (exports.AdaptiveMode = AdaptiveMode = {}));
13
- const TOLERANCE = 100; // 100ms tolerance for KTSat sync
13
+ // const TOLERANCE = 100; // 100ms tolerance for KTSat sync (now configurable via constructor)
14
+ /** Tier-based dynamic tolerance (ms) — auditor-requested upgrade */
15
+ exports.TIER_TOLERANCE_MS = {
16
+ T0_epoch: 2000, // 6.4min tick → 2s tolerance
17
+ T1_block: 200, // 2s tick → 200ms
18
+ T2_slot: 500, // 12s tick → 500ms
19
+ T3_micro: 10, // 100ms tick → 10ms (10%)
20
+ };
14
21
  class AdaptiveSwitch {
15
22
  windowSize = 20; // B1-9: Updated from 10 to 20
16
23
  threshold = 0.9; // B1-9: Updated from 0.8 to 0.9
@@ -21,17 +28,22 @@ class AdaptiveSwitch {
21
28
  consecutiveFailures = 0; // P2-1: Track consecutive failures for exponential backoff
22
29
  turboEntryThreshold = 0.95; // P2-2: Hysteresis — stricter entry
23
30
  turboMaintainThreshold = 0.85; // P2-2: Hysteresis — relaxed maintenance
31
+ tolerance;
32
+ constructor(options) {
33
+ this.tolerance = options?.tolerance ?? 100;
34
+ }
24
35
  /**
25
- * TTT 핵심 메커니즘: 타임스탬프 순서 일치율에 따른 Turbo/Full 모드 전환
36
+ * Core TTT mechanism: switches between Turbo/Full mode based on timestamp ordering match rate.
26
37
  */
27
- verifyBlock(block, tttRecord) {
28
- // 1. 타임스탬프 순서 시간 일치 여부 확인
38
+ verifyBlock(block, tttRecord, chainId, poolAddress, tier) {
39
+ // 1. Check timestamp ordering and time match
29
40
  const orderMatch = this.compareTransactionOrder(block.txs, tttRecord.txOrder);
30
- const timeMatch = Math.abs(block.timestamp - tttRecord.time) < TOLERANCE;
41
+ const tolerance = tier ? (exports.TIER_TOLERANCE_MS[tier] ?? this.tolerance) : this.tolerance;
42
+ const timeMatch = Math.abs(block.timestamp - tttRecord.time) < tolerance;
31
43
  let sequenceOk = orderMatch && timeMatch;
32
44
  // B1-1: Do not skip GrgInverse.verify() in TURBO mode
33
45
  // We check integrity regardless of mode
34
- const integrityOk = grg_inverse_1.GrgInverse.verify(block.data, tttRecord.grgPayload);
46
+ const integrityOk = helm_crypto_1.GrgInverse.verify(block.data, tttRecord.grgPayload, chainId, poolAddress);
35
47
  if (!integrityOk) {
36
48
  logger_1.logger.error(`[AdaptiveSwitch] GRG integrity check FAILED`);
37
49
  sequenceOk = false; // Mark as false if integrity fails
@@ -42,7 +54,7 @@ class AdaptiveSwitch {
42
54
  this.penaltyCooldown = 20 * Math.pow(2, this.consecutiveFailures - 1); // 20, 40, 80, 160, 320
43
55
  }
44
56
  }
45
- // 2. 이력 업데이트 (Sliding Window)
57
+ // 2. Update history (Sliding Window)
46
58
  this.history.push(sequenceOk);
47
59
  if (this.history.length > this.windowSize) {
48
60
  this.history.shift();
@@ -50,7 +62,7 @@ class AdaptiveSwitch {
50
62
  if (this.penaltyCooldown > 0) {
51
63
  this.penaltyCooldown--;
52
64
  }
53
- // 3. 일치율 계산 모드 전환
65
+ // 3. Calculate match rate and switch mode
54
66
  const matchCount = this.history.filter(h => h).length;
55
67
  const matchRate = this.history.length > 0 ? matchCount / this.history.length : 0;
56
68
  // P2-2: Hysteresis — different thresholds for entering vs maintaining TURBO
@@ -73,21 +85,21 @@ class AdaptiveSwitch {
73
85
  return this.currentMode;
74
86
  }
75
87
  /**
76
- * 모드에 따른 수수료 할인율 반환
77
- * TURBO: 20% 할인 (수익 증가 유도)
78
- * FULL: 할인 없음
88
+ * Return fee discount rate based on current mode.
89
+ * TURBO: 20% discount (incentivizes profitability).
90
+ * FULL: No discount.
79
91
  */
80
92
  getFeeDiscount() {
81
93
  return this.currentMode === AdaptiveMode.TURBO ? 0.2 : 0.0;
82
94
  }
83
95
  /**
84
- * 현재 모드 조회
96
+ * Get current adaptive mode.
85
97
  */
86
98
  getCurrentMode() {
87
99
  return this.currentMode;
88
100
  }
89
101
  /**
90
- * 테스트용: 이력 초기화
102
+ * Reset history (for testing).
91
103
  */
92
104
  reset() {
93
105
  this.history = [];
@@ -95,6 +107,31 @@ class AdaptiveSwitch {
95
107
  this.penaltyCooldown = 0;
96
108
  this.consecutiveFailures = 0;
97
109
  }
110
+ /**
111
+ * Serialize internal state to JSON for persistence across restarts.
112
+ * Allows operators to avoid re-learning over 20 blocks after a restart.
113
+ */
114
+ serialize() {
115
+ return JSON.stringify({
116
+ history: this.history,
117
+ currentMode: this.currentMode,
118
+ consecutiveFailures: this.consecutiveFailures,
119
+ penaltyCooldown: this.penaltyCooldown,
120
+ tolerance: this.tolerance,
121
+ });
122
+ }
123
+ /**
124
+ * Reconstruct an AdaptiveSwitch from previously serialized JSON state.
125
+ */
126
+ static deserialize(json) {
127
+ const data = JSON.parse(json);
128
+ const instance = new AdaptiveSwitch({ tolerance: data.tolerance ?? 100 });
129
+ instance.history = data.history;
130
+ instance.currentMode = data.currentMode;
131
+ instance.consecutiveFailures = data.consecutiveFailures;
132
+ instance.penaltyCooldown = data.penaltyCooldown;
133
+ return instance;
134
+ }
98
135
  compareTransactionOrder(blockTxs, expectedOrder) {
99
136
  if (blockTxs.length !== expectedOrder.length)
100
137
  return false;
@@ -1,8 +1,9 @@
1
+ import { TimeSynthesis } from "./time_synthesis";
1
2
  import { EVMConnector } from "./evm_connector";
2
3
  import { AutoMintConfig, MintResult } from "./types";
3
4
  /**
4
- * AutoMintEngine - TTT 자동 민팅 엔진
5
- * 시간 합성, 동적 수수료 계산, EVM 민팅을 하나의 루프로 결합
5
+ * AutoMintEngine - Automatic TTT minting engine.
6
+ * Combines time synthesis, dynamic fee calculation, and EVM minting into a single loop.
6
7
  */
7
8
  export declare class AutoMintEngine {
8
9
  private config;
@@ -20,26 +21,40 @@ export declare class AutoMintEngine {
20
21
  private consecutiveFailures;
21
22
  private maxConsecutiveFailures;
22
23
  private potSigner;
24
+ /** Monotonic counter appended to tokenId hash to prevent collision when two mints share the same nanosecond timestamp. */
25
+ private mintNonce;
26
+ /** Fire the GRG >50ms performance warning at most once per engine session. */
27
+ private warnedGrgSlow;
23
28
  constructor(config: AutoMintConfig);
24
29
  getEvmConnector(): EVMConnector;
30
+ getTimeSynthesis(): TimeSynthesis;
25
31
  setOnMint(callback: (result: MintResult) => void): void;
26
32
  setOnFailure(callback: (error: Error) => void): void;
27
33
  setOnLatency(callback: (ms: number) => void): void;
28
34
  /**
29
- * 엔진 초기화 (RPC 연결 컨트랙트 설정)
35
+ * Initialize the engine (RPC connection and contract setup).
30
36
  */
31
37
  initialize(): Promise<void>;
32
38
  /**
33
- * 자동 민팅 루프 시작
39
+ * Start the automatic minting loop.
34
40
  */
35
41
  start(): void;
36
42
  /**
37
- * 자동 민팅 루프 정지
43
+ * Stop the automatic minting loop.
38
44
  */
39
45
  stop(): void;
40
46
  /**
41
- * 단일 민트 실행
42
- * 시간합성 tokenId 생성 EVM mint 호출 → 수수료 계산/차감
47
+ * Resume the minting loop after a circuit breaker trip.
48
+ * Resets the consecutive failure counter and restarts the loop.
49
+ */
50
+ resume(): void;
51
+ /**
52
+ * Sleep helper for retry backoff.
53
+ */
54
+ private sleep;
55
+ /**
56
+ * Execute a single mint tick.
57
+ * Time synthesis -> tokenId generation -> EVM mint call -> fee calculation/deduction.
43
58
  */
44
59
  mintTick(): Promise<void>;
45
60
  private signFeeMessage;