refactor(common-ts): restructure utils into domain-based modules#329
Merged
ChesterSim merged 18 commits intomasterfrom Mar 26, 2026
Merged
refactor(common-ts): restructure utils into domain-based modules#329ChesterSim merged 18 commits intomasterfrom
ChesterSim merged 18 commits intomasterfrom
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add missing functions: getLpSharesAmountForQuote, getQuoteValueForLpShares, roundToStepSizeIfLargeEnough, POTENTIAL_PROFIT_DEFAULT_STATE - Fix function placements: roundToDecimal, getPctCompletion, aprFromApy to numbers.ts - Fix featureFlags.ts filename (was incorrectly hyphenated) - Add HighLeverageOptions type to orders/flags.ts - Add all deprecation facade files (COMMON_MATH, EQUALITY_CHECKS, etc.) - Add typesVersions fallback for moduleResolution: "node" consumers - Add types conditions to all subpath exports - Remove duplicate exports in barrel (MultiplexWebSocket, WalletConnectionState) - Document shared cache infrastructure (uiStringCache) - Add TypeScript moduleResolution risk to Risks section Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Already removed by user prior to spec finalization. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
16-task plan covering: domain module creation (core, math, strings, enum, validation, token, trading, markets, orders, positions, accounts), deprecation facades, barrel rewrites, package.json exports, and verification. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tils/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…bility Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…d files Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
….json Enables targeted imports like '@drift-labs/common/utils/math'. Includes typesVersions fallback for moduleResolution: "node" consumers. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Point MarketId.ts and UIMarket.ts directly at utils/enum instead of the utils barrel, breaking the cycle: types/ → utils/ → core/equality → types/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Merge duplicate imports from trading/size in _deprecated/trading-utils.ts - Use top-level BN import instead of inline import() in trading/pnl.ts - Remove unnecessary export of private updateUserAccount in accounts/init.ts - Consistent export style for timedPromise in core/async.ts Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
utils/index.tsgod file andcommon-ui-utils/into 11 domain-based modules undersrc/utils/(math, strings, enum, validation, token, trading, markets, orders, positions, accounts, core)package.jsonso consumers can import from@drift-labs/common/utils/math,@drift-labs/common/utils/trading, etc.chunks,getTokenAddress,getTokenAccount(had two copies each)src/_deprecated/—COMMON_UI_UTILS,COMMON_UTILS,TRADING_UTILS,MARKET_UTILS,ORDER_COMMON_UTILS,USER_UTILS,COMMON_MATH,EQUALITY_CHECKSall still worktypesVersionsfallback for consumers usingmoduleResolution: "node"New import paths
Test plan
src/madge --circularreports 0 circular dependenciestscbuild produces correctlib/output with all subpath targetsCOMMON_UI_UTILS, etc.) match original shapes🤖 Generated with Claude Code