@bananapus/suckers-v6 0.0.69 → 0.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/package.json +1 -1
- package/src/JBSucker.sol +9 -3
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ That means every bridge path has two trust surfaces:
|
|
|
64
64
|
- do not reason about suckers as if they were generic ERC-20 bridges
|
|
65
65
|
- root ordering and message delivery semantics matter as much as proof format
|
|
66
66
|
- token mapping is part of the economic invariant
|
|
67
|
+
- peer contexts are merged only when they share both currency and decimals; same-currency contexts with different decimals are kept separate and valued independently at read time, never summed across precisions
|
|
67
68
|
- emergency and deprecation paths are part of normal operational safety
|
|
68
69
|
|
|
69
70
|
## Where State Lives
|
package/package.json
CHANGED
package/src/JBSucker.sol
CHANGED
|
@@ -545,12 +545,18 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
545
545
|
_cachedCurrencyOf[contextToken] = contextCurrency;
|
|
546
546
|
}
|
|
547
547
|
|
|
548
|
-
// Accumulate into an existing
|
|
549
|
-
//
|
|
548
|
+
// Accumulate into an existing entry that matches on BOTH currency AND decimals, or append a new one.
|
|
549
|
+
// The decimals must match: `surplus`/`balance` are raw, un-valued token amounts, so two contexts that
|
|
550
|
+
// share a currency but carry different decimals (e.g. a 6-decimal and an 18-decimal representation of
|
|
551
|
+
// the same currency) are on different scales and CANNOT be summed directly — doing so would corrupt
|
|
552
|
+
// the
|
|
553
|
+
// aggregate. Keeping them as separate entries lets the read side (`remoteSurplusOf` -> `_valued`)
|
|
554
|
+
// decimal-adjust each one independently before summing. The context set is small (one entry per
|
|
555
|
+
// distinct local currency+decimals), so a linear scan is cheaper than a mapping.
|
|
550
556
|
uint256 numStored = _peerContexts.length;
|
|
551
557
|
bool merged;
|
|
552
558
|
for (uint256 j; j < numStored;) {
|
|
553
|
-
if (_peerContexts[j].currency == contextCurrency) {
|
|
559
|
+
if (_peerContexts[j].currency == contextCurrency && _peerContexts[j].decimals == ctx.decimals) {
|
|
554
560
|
_peerContexts[j].surplus = _saturatingAddU128(_peerContexts[j].surplus, ctx.surplus);
|
|
555
561
|
_peerContexts[j].balance = _saturatingAddU128(_peerContexts[j].balance, ctx.balance);
|
|
556
562
|
merged = true;
|