Bug: BSC deposit button blocked at exact minimum amount (off-by-one) #101
Labels
No labels
agent:implement
agent:ready
backend
bug
cannot-reproduce
confirmed
desktop
docs
documentation
duplicate
enhancement
feature
frontend
good first issue
help wanted
high-risk
in-review
invalid
mobile
needs-triage
P0-critical
P1-high
P2-medium
P3-low
qa
QA
question
ready
report
responsive
security
security-escalate
smart-contract
solana
tablet
test-pass
ux
wallet-issue
wallet:keplr
wallet:metamask
wallet:station
wallet:walletconnect
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-bridge-monorepo#101
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Mainnet v0.1.82 (
b9c6d54)Token: testa (tokena-cb) on BSC
MIN displayed: 1.005
Amount entered: 1.005025
Bridge fee: 0.5%
YOU WILL RECEIVE: 1.00 TESTA
Current behavior: Bridge button is blocked/disabled when entering the minimum amount (1.005025). Cannot submit deposit.
Works when: Amount is increased above the minimum. Transfers complete normally at higher amounts.
Expected behavior: Bridge button should be enabled at the displayed minimum amount. If 1.005 is the minimum, entering 1.005 or 1.005025 should be accepted.
Likely cause: Division or off-by-one bug in the minimum amount calculation. The post-fee amount may be compared against the minimum instead of the pre-fee amount, or rounding causes the check to fail at the boundary.
Acceptance criteria:
@PlasticDigits Still reproducing on build v0.1.82 -
f227b6f(frontend bundle main-CvcBOh67), 4/20 mainnet.Reproducing scenario (MIN off-by-one on BSC -> Terra):
Comparison (BSC -> opBNB works):
The MIN preset math is the same pattern (gross = min + fee buffer). BSC -> opBNB passes, BSC -> Terra blocks. Looks like the off-by-one is Terra-destination specific, possibly related to Terra's 6-decimal rounding vs 18-decimal source. The 1.00 net might be evaluated as exactly equal to min rather than >= min after decimal normalization.
Recent transfers today show the BSC -> Terra path itself works fine at amounts above MIN (see nonce 48: 1.99 testa BSC -> Terra, just completed). Issue is strictly at the MIN boundary on Terra destinations.
Leaving open.
mentioned in issue #111
mentioned in commit
dae31d3fc3Fixed on main in
dae31d3: MIN gross now targets the same destination minimum as validation (removed +1 base-unit skew). MIN label uses full token precision (formatAmountForNumberInput) so compact rounding cannot suggest an amount that still fails isBelowMin. Regression test added for 50 bps / 1e6 min net (1.005025 gross).What we changed
The bridge form had two boundary bugs:
Skewed minimum gross — MIN was computed with
effectiveMinInSrc + 1n, so the UI required slightly more net thanisBelowMin(which only checksnet >= effectiveMinInSrc). That disagreed with the on-chain minimum and the “exact MIN” expectation.Misleading MIN label — The label used
formatCompact(4 significant figures), so e.g. 1.005025 appeared as 1.005. Typing what the label showed could yield net below the real minimum, so the deposit button stayed disabled.Fix (merged to
main, commitdae31d3):minGrossForMinNet(effectiveMinInSrc, bridgeFeeBps)— aligned with validation.formatAmountForNumberInput(..., amountDecimals, amountDecimals)— full token precision so the shown MIN matches what you can enter.1_005_025).This applies to all routes that use
TransferForm(EVM / Terra / Solana as source), not only BSC → Terra Classic.@brouie Could you verify on the next deploy (or locally against
main) that the bridge button enables at the displayed MIN and that entering that amount still shows the expected “you will receive” at the destination minimum? We are leaving this issue open until you confirm. Thanks!@PlasticDigits Partial fix on build v0.1.82 -
dae31d3(frontend bundle main-CSMgjCa4), 4/20 mainnet.What's fixed:
What's still broken:
Expected:
MIN preset should fill the exact full-precision value from the label so clicking MIN gives an immediately valid amount.
Leaving open. The label fix is good; preset fill just needs to match label precision.
mentioned in commit
3cd46b3b71Follow-up: MIN preset vs full-precision label (partial fix after
dae31d3)Cause:
formatAmountForNumberInputdefaultsdisplayDecimalstomin(tokenDecimals, 6)when the third argument is omitted. The MIN label already passed(amountDecimals, amountDecimals)for full precision, but the MIN button calledformatAmountForNumberInput(minSendGrossInSrc, amountDecimals)with only two arguments—so the field was filled with at most 6 decimal places (e.g.1.005025) while the enforceable gross requires full source precision (e.g.1.005025125628140703on 18 dp).Fix:
handleMinnow passes the third argument:formatAmountForNumberInput(minSendGrossInSrc, amountDecimals, amountDecimals), matchingdisplayMinLabel.Commit:
3cd46b3onmainTest: Regression in
format.test.tsdocuments default 6-dp cap vs explicit full decimals.Leaving this issue open for verification on deploy (MIN click should enable the bridge button at the same value as the MIN label).
Update (follow-up commits on
main)MIN preset vs label (
3cd46b3)The MIN button now calls
formatAmountForNumberInput(minSendGrossInSrc, amountDecimals, amountDecimals)so the filled amount matches the full-precision MIN label. Previously the third argument was omitted, soformatAmountForNumberInputcapped display at 6 decimals while high-decimal source tokens need the full string to pass validation.Solana dest limits (
2a127e6)Related frontend hardening: Solana destination routes now resolve the TokenMapping PDA for
useTokenDetails(EVM→Solana, Terra→Solana) and surface mappingdestTokenDecimalsso min/max and unit conversion use the correct SPL decimals when the destination is Solana.Repo hygiene
Branches were already only
main; no extra branches to remove locally or onorigin.Leaving this issue open until you can confirm on a deploy that MIN enables the bridge at the displayed minimum without manual entry.
@PlasticDigits Fix verified on v0.1.82 -
2a127e6(mainnet).Route: opBNB -> BSC, token testa (18 decimals)
Behavior confirmed:
formatAmountForNumberInput fix in
3cd46b3resolves the truncation that was capping display at 6 decimals. Closing.