@bananapus/core-v6 0.0.62 → 0.0.63
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/package.json +1 -1
- package/src/JBMultiTerminal.sol +18 -4
- package/src/JBTerminalStore.sol +17 -4
package/package.json
CHANGED
package/src/JBMultiTerminal.sol
CHANGED
|
@@ -626,7 +626,11 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
626
626
|
}
|
|
627
627
|
|
|
628
628
|
// Transfer the balance minus the fee to the new terminal.
|
|
629
|
-
uint256 migrationAmount
|
|
629
|
+
uint256 migrationAmount;
|
|
630
|
+
// `_takeFeeFrom` calculated `feeAmount` from `balance`, so it cannot exceed `balance`.
|
|
631
|
+
unchecked {
|
|
632
|
+
migrationAmount = balance - feeAmount;
|
|
633
|
+
}
|
|
630
634
|
|
|
631
635
|
_externalAddToBalance({
|
|
632
636
|
terminal: to, projectId: projectId, token: token, amount: migrationAmount, metadata: bytes("")
|
|
@@ -690,7 +694,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
690
694
|
|
|
691
695
|
// Set the beneficiary token count.
|
|
692
696
|
if (beneficiaryBalanceAfter > beneficiaryBalanceBefore) {
|
|
693
|
-
|
|
697
|
+
// Guarded by the comparison above.
|
|
698
|
+
unchecked {
|
|
699
|
+
beneficiaryTokenCount = beneficiaryBalanceAfter - beneficiaryBalanceBefore;
|
|
700
|
+
}
|
|
694
701
|
}
|
|
695
702
|
|
|
696
703
|
// The token count for the beneficiary must be greater than or equal to the specified minimum.
|
|
@@ -737,7 +744,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
737
744
|
// reverting.
|
|
738
745
|
// A `FeeReverted` event is emitted so the forgiveness is observable off-chain.
|
|
739
746
|
delete _heldFeesOf[projectId][token][currentIndex];
|
|
740
|
-
|
|
747
|
+
// `currentIndex` was proven to be within the held-fee array.
|
|
748
|
+
unchecked {
|
|
749
|
+
_nextHeldFeeIndexOf[projectId][token] = currentIndex + 1;
|
|
750
|
+
}
|
|
741
751
|
|
|
742
752
|
// Restore the originating fee-paying call's referral project for the duration of this fee's processing
|
|
743
753
|
// so the credit in `_processFee` attributes to the right (chain, project) pair. No save needed:
|
|
@@ -1879,6 +1889,10 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1879
1889
|
});
|
|
1880
1890
|
|
|
1881
1891
|
_recordAddedBalanceFor({projectId: projectId, token: token, amount: amount});
|
|
1892
|
+
// The store balance was credited first; this mirrors that bounded increase for fee recovery.
|
|
1893
|
+
unchecked {
|
|
1894
|
+
_feeFreeSurplusOf[projectId][token] += amount;
|
|
1895
|
+
}
|
|
1882
1896
|
}
|
|
1883
1897
|
}
|
|
1884
1898
|
|
|
@@ -1887,7 +1901,7 @@ contract JBMultiTerminal is JBPermissioned, ERC2771Context, IJBMultiTerminal {
|
|
|
1887
1901
|
/// @param token The token to record the added balance for.
|
|
1888
1902
|
/// @param amount The amount of the token to record, as a fixed point number with the same number of decimals as
|
|
1889
1903
|
/// this terminal.
|
|
1890
|
-
function _recordAddedBalanceFor(uint256 projectId, address token, uint256 amount)
|
|
1904
|
+
function _recordAddedBalanceFor(uint256 projectId, address token, uint256 amount) private {
|
|
1891
1905
|
STORE.recordAddedBalanceFor({projectId: projectId, token: token, amount: amount});
|
|
1892
1906
|
}
|
|
1893
1907
|
|
package/src/JBTerminalStore.sol
CHANGED
|
@@ -43,6 +43,7 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
43
43
|
error JBTerminalStore_AccountingContextDecimalsMismatch(
|
|
44
44
|
address token, uint256 providedDecimals, uint256 expectedDecimals
|
|
45
45
|
);
|
|
46
|
+
error JBTerminalStore_AccountingContextDecimalsOutOfRange(address token, uint256 decimals);
|
|
46
47
|
error JBTerminalStore_AddingAccountingContextNotAllowed(uint256 projectId, uint256 rulesetId, address terminal);
|
|
47
48
|
error JBTerminalStore_InadequateControllerAllowance(uint256 amount, uint256 allowance);
|
|
48
49
|
|
|
@@ -212,6 +213,12 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
212
213
|
revert JBTerminalStore_AccountingContextAlreadySet({token: context.token});
|
|
213
214
|
}
|
|
214
215
|
|
|
216
|
+
if (context.decimals > 36) {
|
|
217
|
+
revert JBTerminalStore_AccountingContextDecimalsOutOfRange({
|
|
218
|
+
token: context.token, decimals: context.decimals
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
215
222
|
// Keep track of a flag indicating if we know the provided decimals are incorrect.
|
|
216
223
|
bool knownInvalidDecimals;
|
|
217
224
|
uint256 expectedDecimals;
|
|
@@ -222,16 +229,22 @@ contract JBTerminalStore is IJBTerminalStore {
|
|
|
222
229
|
expectedDecimals = 18;
|
|
223
230
|
} else if (context.token != JBConstants.NATIVE_TOKEN && context.token.code.length > 0) {
|
|
224
231
|
try IERC20Metadata(context.token).decimals() returns (uint8 decimals) {
|
|
225
|
-
|
|
226
|
-
knownInvalidDecimals = true;
|
|
227
|
-
expectedDecimals = decimals;
|
|
228
|
-
}
|
|
232
|
+
expectedDecimals = decimals;
|
|
229
233
|
} catch {
|
|
230
234
|
// The token didn't support `decimals`.
|
|
231
235
|
// @dev Non-standard ERC20s that revert on `decimals()` will bypass decimal validation.
|
|
232
236
|
// The caller is responsible for providing the correct decimals for such tokens.
|
|
233
237
|
knownInvalidDecimals = false;
|
|
238
|
+
expectedDecimals = context.decimals;
|
|
234
239
|
}
|
|
240
|
+
|
|
241
|
+
if (expectedDecimals > 36) {
|
|
242
|
+
revert JBTerminalStore_AccountingContextDecimalsOutOfRange({
|
|
243
|
+
token: context.token, decimals: expectedDecimals
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
if (context.decimals != expectedDecimals) knownInvalidDecimals = true;
|
|
235
248
|
}
|
|
236
249
|
|
|
237
250
|
// Make sure the decimals are correct.
|