Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
ddfdf0f
feat: Phase A — protocol-native DEX engine (Caldera Fusion)
0xZunia Feb 23, 2026
58067a4
feat: Phase B — batch auction solver and intent system
0xZunia Feb 23, 2026
8a928c7
feat: Phase C — order book, TWAP oracle, and dynamic fees
0xZunia Feb 23, 2026
e335f86
feat: Phase D — genesis deployment, node integration, REST API, and d…
0xZunia Feb 23, 2026
2cc5914
feat(dex): BST-20 token integration and LP token transfers (Phase E1)
0xZunia Feb 23, 2026
1dfda88
feat(dex): concentrated liquidity with tick math and position managem…
0xZunia Feb 23, 2026
2032dac
feat(dex): DKG threshold crypto and encrypted swap intents (Phase E3)
0xZunia Feb 23, 2026
6d7178c
feat(dex): solver network for competitive batch settlement (Phase E4)
0xZunia Feb 23, 2026
3423497
docs: update DEX documentation with Phase E features
0xZunia Feb 23, 2026
cde53d9
feat: DEX mainnet hardening, staking persistence, and production read…
0xZunia Feb 24, 2026
3ded2c6
fix(dex): allow withdrawals during pause, block batch auction when pa…
0xZunia Feb 24, 2026
2bfe23e
fix: address PR review findings (CR-2 through CR-10)
0xZunia Feb 24, 2026
2f648cd
fix(api): use per-pool linked list for /v1/dex/pools/{poolId}/orders …
0xZunia Feb 24, 2026
4a8dd8a
fix(api): adjust gas consumption tracking in contract call execution
0xZunia Feb 24, 2026
dd8074a
feat(sdk): add optional initialSupply to BST-20 constructor
0xZunia Feb 24, 2026
caab72d
fix(sdk): prevent BST-20 initial supply re-minting on contract calls
0xZunia Feb 24, 2026
7b3b89e
fix(sdk): add Context.IsDeploying to prevent constructor side-effects…
0xZunia Feb 24, 2026
d4f337f
feat(api): add GET /v1/dex/pools/{poolId}/lp/{address} LP balance end…
0xZunia Feb 24, 2026
d7be2a4
fix(dex): prevent BST-20 transfer failures from crashing validator co…
0xZunia Feb 25, 2026
7e4a7f7
fix(sdk): add camelCase selector aliases to contract dispatch
0xZunia Feb 25, 2026
c264e23
fix(vm): catch InvalidOperationException from unknown selectors in co…
0xZunia Feb 25, 2026
d31fe68
test: update tests to match error-return behavior for failed contract…
0xZunia Feb 25, 2026
2774b42
fix(dex): encode BST-20 Transfer calldata with BasaltWriter
0xZunia Feb 25, 2026
81e02e8
feat(dex): enable limit order matching in block builder
0xZunia Feb 25, 2026
327f1df
fix(dex): propagate order IDs through batch settlement so filled orde…
0xZunia Feb 25, 2026
e759ac7
fix(dex): remove spurious DEX→DEX self-transfer in limit order settle…
0xZunia Feb 25, 2026
63a40c1
fix(node): always use BuildBlockWithDex so limit orders match without…
0xZunia Feb 25, 2026
f0d9aba
feat(dex): add price-history endpoint and fix TWAP carry-forward for …
0xZunia Feb 26, 2026
903d1ea
fix(dex): run limit order matching and TWAP on canonical state during…
0xZunia Feb 27, 2026
e55234f
fix(dex): prevent filled buy orders from lingering with zero/dust amo…
0xZunia Feb 27, 2026
5f6b410
fix(mempool): evict transactions with insufficient balance during pru…
0xZunia Feb 27, 2026
2e555c9
fix(dex): standardize buy order Amount to token0 units
0xZunia Feb 27, 2026
638c99b
feat(deploy): add Caldera DEX routing to testnet infrastructure
0xZunia Mar 2, 2026
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
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ EXPOSE 5000 5001 30303
ENV ASPNETCORE_URLS=http://+:5000
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=true

# L19: Health check for container orchestrators (Docker Compose, Kubernetes)
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
CMD curl -sf http://localhost:5000/v1/health || exit 1

ENTRYPOINT ["dotnet", "Basalt.Node.dll"]
6 changes: 6 additions & 0 deletions deploy/testnet/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ http://basalt.foundation {
import security_headers
}

# ─── Caldera DEX (caldera.basalt.foundation) ─────────────────────
http://caldera.basalt.foundation {
reverse_proxy caldera:3000
import security_headers
}

# ─── Testnet (testnet.basalt.foundation or any other host) ─────────
:80 {
# REST API
Expand Down
2 changes: 1 addition & 1 deletion deploy/testnet/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@ volumes:

networks:
basalt-testnet:
driver: bridge
external: true
447 changes: 447 additions & 0 deletions docs/dex_design.md

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/api/Basalt.Api.GraphQL/GraphQLSetup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ public static IServiceCollection AddBasaltGraphQL(this IServiceCollection servic
.AddMutationType<Mutation>()
.AddMaxExecutionDepthRule(10)
// M-4: Limit query complexity to prevent expensive nested queries
.ModifyCostOptions(opt =>
{
opt.MaxFieldCost = 500;
opt.MaxTypeCost = 500;
opt.EnforceCostLimits = true;
})
.ModifyPagingOptions(opt => opt.MaxPageSize = 100)
.ModifyRequestOptions(opt =>
{
Expand Down
46 changes: 45 additions & 1 deletion src/api/Basalt.Api.Rest/MetricsEndpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace Basalt.Api.Rest;
/// <summary>
/// Prometheus-compatible /metrics endpoint for monitoring.
/// Exposes block height, TPS, mempool size, peer count, and timing metrics.
/// M13: Expanded with peer count, base fee, consensus view, finalization latency, DEX intent count.
/// </summary>
public static class MetricsEndpoint
{
Expand All @@ -20,6 +21,13 @@ public static class MetricsEndpoint
private static long _currentTpsTicks; // Store as ticks (long) for Interlocked
private static readonly Stopwatch Uptime = Stopwatch.StartNew();

// M13: Additional metrics
private static long _peerCount;
private static long _baseFee;
private static long _consensusView;
private static long _lastFinalizationLatencyMs;
private static long _dexIntentCount;

/// <summary>
/// Record a produced block for TPS calculation.
/// MEDIUM-6: All shared fields use Interlocked for thread safety.
Expand All @@ -43,6 +51,21 @@ public static void RecordBlock(int txCount, long timestampMs)
Interlocked.Exchange(ref _lastBlockTxCount, txCount);
}

/// <summary>M13: Record connected peer count.</summary>
public static void RecordPeerCount(int count) => Interlocked.Exchange(ref _peerCount, count);

/// <summary>M13: Record current base fee (Lo limb for Prometheus u64).</summary>
public static void RecordBaseFee(long baseFee) => Interlocked.Exchange(ref _baseFee, baseFee);

/// <summary>M13: Record current consensus view/block number.</summary>
public static void RecordConsensusView(long view) => Interlocked.Exchange(ref _consensusView, view);

/// <summary>M13: Record block finalization latency in milliseconds.</summary>
public static void RecordFinalizationLatency(long latencyMs) => Interlocked.Exchange(ref _lastFinalizationLatencyMs, latencyMs);

/// <summary>M13: Record DEX intent count in mempool.</summary>
public static void RecordDexIntentCount(int count) => Interlocked.Exchange(ref _dexIntentCount, count);

/// <summary>
/// Map the /metrics endpoint.
/// </summary>
Expand All @@ -53,7 +76,7 @@ public static void MapMetricsEndpoint(
{
IResult Handler()
{
var sb = new StringBuilder(2048);
var sb = new StringBuilder(4096);
var latest = chainManager.LatestBlock;
var blockHeight = latest?.Number ?? 0;
var mempoolSize = mempool.Count;
Expand Down Expand Up @@ -100,6 +123,27 @@ IResult Handler()
sb.AppendLine("# TYPE basalt_uptime_seconds gauge");
sb.Append("basalt_uptime_seconds ").AppendLine(Uptime.Elapsed.TotalSeconds.ToString("F0", CultureInfo.InvariantCulture));

// M13: Additional metrics
sb.AppendLine("# HELP basalt_peer_count Number of connected peers.");
sb.AppendLine("# TYPE basalt_peer_count gauge");
sb.Append("basalt_peer_count ").AppendLine(Interlocked.Read(ref _peerCount).ToString());

sb.AppendLine("# HELP basalt_base_fee Current base fee.");
sb.AppendLine("# TYPE basalt_base_fee gauge");
sb.Append("basalt_base_fee ").AppendLine(Interlocked.Read(ref _baseFee).ToString());

sb.AppendLine("# HELP basalt_consensus_view Current consensus view/block.");
sb.AppendLine("# TYPE basalt_consensus_view gauge");
sb.Append("basalt_consensus_view ").AppendLine(Interlocked.Read(ref _consensusView).ToString());

sb.AppendLine("# HELP basalt_finalization_latency_ms Last block finalization latency in milliseconds.");
sb.AppendLine("# TYPE basalt_finalization_latency_ms gauge");
sb.Append("basalt_finalization_latency_ms ").AppendLine(Interlocked.Read(ref _lastFinalizationLatencyMs).ToString());

sb.AppendLine("# HELP basalt_dex_intent_count Number of DEX intents in mempool.");
sb.AppendLine("# TYPE basalt_dex_intent_count gauge");
sb.Append("basalt_dex_intent_count ").AppendLine(Interlocked.Read(ref _dexIntentCount).ToString());

return Results.Text(sb.ToString(), "text/plain; version=0.0.4; charset=utf-8");
}

Expand Down
Loading