Skip to content

Commit a4504e0

Browse files
USEONGEEclaude
andcommitted
refactor: barrel 모듈 경계 도입 — 6개 모듈 barrel + import 리다이렉트
Barrel 생성/정비: - exchanges/index.ts (신규) — interface, adapter, spot 타입 통합 - bot/index.ts (신규) — config, engine, presets, conditions - strategies/index.ts (신규) — 6개 전략 runner - dashboard/index.ts (신규) — server, ws-feeds - arb/index.ts (재생성) — sizing, utils, state, history-stats - signer/index.ts (재생성) — interface, local implementations Import 리다이렉트 (~43개 파일): - 모듈 외부의 deep import를 barrel import로 변경 - entry point(index.ts, mcp-server.ts)와 테스트는 예외 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f0df863 commit a4504e0

44 files changed

Lines changed: 136 additions & 69 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/arb/index.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
1-
export * from "./sizing.js";
2-
export * from "./utils.js";
3-
export * from "./state.js";
4-
export * from "./history-stats.js";
1+
// arb/ barrel — public API
2+
export { computeMatchedSize, computeSpotPerpMatchedSize, reconcileArbFills } from "./sizing.js";
3+
export {
4+
SETTLEMENT_SCHEDULES,
5+
getLastSettlement,
6+
getMinutesSinceSettlement,
7+
aggressiveSettleBoost,
8+
estimateFundingUntilSettlement,
9+
computeBasisRisk,
10+
formatNotifyMessage,
11+
sendNotification,
12+
notifyIfEnabled,
13+
} from "./utils.js";
14+
export type { SettleStrategy, BasisRisk, ArbNotifyEvent } from "./utils.js";
15+
export {
16+
setStateFilePath,
17+
resetStateFilePath,
18+
loadArbState,
19+
saveArbState,
20+
addPosition,
21+
removePosition,
22+
updatePosition,
23+
getPositions,
24+
createInitialState,
25+
} from "./state.js";
26+
export type { ArbPositionState, ArbDaemonState } from "./state.js";
27+
export { computeEnhancedStats } from "./history-stats.js";
28+
export type { ArbTradeForStats, ExchangePairPerf, TimeOfDayPerf, EnhancedHistoryStats } from "./history-stats.js";

src/arb/sizing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExchangeAdapter } from "../exchanges/interface.js";
1+
import type { ExchangeAdapter } from "../exchanges/index.js";
22

33
/**
44
* Calculate the exact same size for both legs of an arb position,

src/bot/conditions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExchangeAdapter } from "../exchanges/interface.js";
1+
import type { ExchangeAdapter } from "../exchanges/index.js";
22
import type { Condition } from "./config.js";
33

44
export interface MarketSnapshot {

src/bot/engine.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { ExchangeAdapter } from "../exchanges/interface.js";
1+
import type { ExchangeAdapter } from "../exchanges/index.js";
22
import type { BotConfig, GridStrategyParams, DCAStrategyParams, FundingArbStrategyParams } from "./config.js";
33
import { getMarketSnapshot, evaluateAllConditions, type MarketSnapshot } from "./conditions.js";
44
import { updateJobState } from "../jobs.js";

src/bot/index.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// bot/ barrel — public API
2+
export {
3+
loadBotConfig,
4+
quickGridConfig,
5+
quickDCAConfig,
6+
} from "./config.js";
7+
export type {
8+
ConditionType,
9+
Condition,
10+
RiskConfig,
11+
GridStrategyParams,
12+
DCAStrategyParams,
13+
FundingArbStrategyParams,
14+
StrategyParams,
15+
BotConfig,
16+
} from "./config.js";
17+
export { runBot } from "./engine.js";
18+
export type { BotLog } from "./engine.js";
19+
export { PRESETS, getPreset, getPresetsByStrategy } from "./presets.js";
20+
export type { Preset } from "./presets.js";
21+
export { evaluateCondition, evaluateAllConditions, getMarketSnapshot, calculateRSI } from "./conditions.js";
22+
export type { MarketSnapshot } from "./conditions.js";

src/commands/account.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import { Command } from "commander";
2-
import type { ExchangeAdapter, ExchangeBalance, ExchangePosition, ExchangeOrder } from "../exchanges/interface.js";
3-
import { PacificaAdapter } from "../exchanges/pacifica.js";
4-
import { HyperliquidAdapter } from "../exchanges/hyperliquid.js";
2+
import { PacificaAdapter, HyperliquidAdapter, type ExchangeAdapter, type ExchangeBalance, type ExchangePosition, type ExchangeOrder } from "../exchanges/index.js";
53
import { makeTable, formatUsd, formatPnl, printJson, jsonOk, jsonError, symbolMatch, withJsonErrors } from "../utils.js";
64
import chalk from "chalk";
75
import { assessRisk, type RiskLevel, type RiskViolation } from "../risk.js";

src/commands/agent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { createRequire } from "node:module";
33
import { printJson, jsonOk } from "../utils.js";
44
import { ERROR_CODES } from "../errors.js";
55
import chalk from "chalk";
6-
import type { ExchangeAdapter } from "../exchanges/interface.js";
6+
import type { ExchangeAdapter } from "../exchanges/index.js";
77

88
const _require = createRequire(import.meta.url);
99
const _pkg = _require("../../package.json") as { version: string };

src/commands/arb-auto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { Command } from "commander";
22
import chalk from "chalk";
33
import { formatUsd, printJson, jsonOk, makeTable } from "../utils.js";
4-
import type { ExchangeAdapter } from "../exchanges/interface.js";
4+
import type { ExchangeAdapter } from "../exchanges/index.js";
55
import { computeExecutableSize } from "../liquidity.js";
6-
import { computeMatchedSize, computeSpotPerpMatchedSize } from "../arb/sizing.js";
6+
import { computeMatchedSize, computeSpotPerpMatchedSize } from "../arb/index.js";
77
import { computeAnnualSpread, toHourlyRate } from "../funding.js";
88
import {
99
fetchPacificaPricesRaw, parsePacificaRaw,

src/commands/arb.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
getCompoundedAnnualReturn,
1616
getExchangeCompoundingHours,
1717
} from "../funding-history.js";
18-
import type { ExchangeAdapter } from "../exchanges/interface.js";
18+
import type { ExchangeAdapter } from "../exchanges/index.js";
1919
import {
2020
fetchPacificaPrices, fetchHyperliquidMeta,
2121
fetchLighterOrderBookDetails, fetchLighterFundingRates,

src/commands/arb/index.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Command } from "commander";
22
import chalk from "chalk";
33
import { makeTable, formatUsd, formatPnl, printJson, jsonOk } from "../../utils.js";
4-
import type { ExchangeAdapter, ExchangePosition } from "../../exchanges/interface.js";
4+
import { SPOT_PERP_TOKEN_MAP, type ExchangeAdapter, type ExchangePosition, type SpotBalance } from "../../exchanges/index.js";
55
import { readExecutionLog, logExecution, type ExecutionRecord } from "../../execution-log.js";
66
import { toHourlyRate, computeAnnualSpread } from "../../funding.js";
77
import {
@@ -11,8 +11,6 @@ import {
1111
import { computeBasisRisk } from "../../arb-utils.js";
1212
import { smartOrder } from "../../smart-order.js";
1313
import { removePosition as persistRemovePosition, getPositions as getArbStatePositions, loadArbState } from "../../arb-state.js";
14-
import { SPOT_PERP_TOKEN_MAP } from "../../exchanges/spot-interface.js";
15-
import type { SpotBalance } from "../../exchanges/spot-interface.js";
1614
import { fetchAllBalances, computeRebalancePlan } from "../../rebalance.js";
1715
import { EXCHANGE_TO_CHAIN, getBestQuote } from "../../bridge-engine.js";
1816
import { computeEnhancedStats, type ArbTradeForStats } from "../../arb-history-stats.js";

0 commit comments

Comments
 (0)