diff --git a/AGENTS.md b/AGENTS.md index 9da77e7..3f61447 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **36-character-flower** (3095 symbols, 6119 relationships, 264 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **36-character-flower** (3365 symbols, 6609 relationships, 288 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. diff --git a/CLAUDE.md b/CLAUDE.md index 9da77e7..3f61447 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,7 +1,7 @@ # GitNexus — Code Intelligence -This project is indexed by GitNexus as **36-character-flower** (3095 symbols, 6119 relationships, 264 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. +This project is indexed by GitNexus as **36-character-flower** (3365 symbols, 6609 relationships, 288 execution flows). Use the GitNexus MCP tools to understand code, assess impact, and navigate safely. > If any GitNexus tool warns the index is stale, run `npx gitnexus analyze` in terminal first. diff --git a/src/hooks/use-withdraw-vm.ts b/src/hooks/use-withdraw-vm.ts index 9a73f1b..5a5e862 100644 --- a/src/hooks/use-withdraw-vm.ts +++ b/src/hooks/use-withdraw-vm.ts @@ -58,27 +58,39 @@ function getWithdrawDiamondBounds( function getQuickWithdrawAmounts(bounds: WithdrawDiamondBounds) { const { maximumDiamonds, minimumDiamonds } = bounds - const availableOptionCount = maximumDiamonds - minimumDiamonds + 1 + const roundingUnit = + 10 ** Math.max(0, Math.floor(Math.log10(maximumDiamonds)) - 1) + const roundedMinimumDiamonds = + Math.ceil(minimumDiamonds / roundingUnit) * roundingUnit + const roundedMaximumDiamonds = + Math.floor(maximumDiamonds / roundingUnit) * roundingUnit + + if (roundedMinimumDiamonds > roundedMaximumDiamonds) { + return [] + } + + const availableOptionCount = + (roundedMaximumDiamonds - roundedMinimumDiamonds) / roundingUnit + 1 if (availableOptionCount <= QUICK_WITHDRAW_OPTION_COUNT) { return Array.from( { length: availableOptionCount }, - (_, index) => minimumDiamonds + index, + (_, index) => roundedMinimumDiamonds + index * roundingUnit, ) } - const amounts = new Set([minimumDiamonds, maximumDiamonds]) - const span = maximumDiamonds - minimumDiamonds + const lastOptionIndex = availableOptionCount - 1 + const optionIndexes = new Set([0, lastOptionIndex]) for (let index = 1; index < QUICK_WITHDRAW_OPTION_COUNT - 1; index += 1) { - amounts.add( - Math.round( - minimumDiamonds + (span * index) / (QUICK_WITHDRAW_OPTION_COUNT - 1), - ), + optionIndexes.add( + Math.round((lastOptionIndex * index) / (QUICK_WITHDRAW_OPTION_COUNT - 1)), ) } - return [...amounts].sort((left, right) => left - right) + return [...optionIndexes] + .sort((left, right) => left - right) + .map((index) => roundedMinimumDiamonds + index * roundingUnit) } function getCurrencyExchangeRate(