@bananapus/suckers-v6 0.0.22 → 0.0.23
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/JBCeloSucker.sol +7 -6
- package/src/JBSucker.sol +17 -7
package/package.json
CHANGED
package/src/JBCeloSucker.sol
CHANGED
|
@@ -76,8 +76,8 @@ contract JBCeloSucker is JBOptimismSucker {
|
|
|
76
76
|
/// and adds native ETH to the project's balance.
|
|
77
77
|
/// @param token The terminal token to add to the project's balance.
|
|
78
78
|
/// @param amount The amount of terminal tokens to add to the project's balance.
|
|
79
|
-
/// @param
|
|
80
|
-
function _addToBalance(address token, uint256 amount, uint256
|
|
79
|
+
/// @param cachedProjectId The cached project ID to avoid redundant storage reads.
|
|
80
|
+
function _addToBalance(address token, uint256 amount, uint256 cachedProjectId) internal override {
|
|
81
81
|
if (token == address(WRAPPED_NATIVE)) {
|
|
82
82
|
// Check addable amount against WETH balance before unwrapping.
|
|
83
83
|
uint256 addableAmount = amountToAddToBalanceOf(token);
|
|
@@ -91,16 +91,17 @@ contract JBCeloSucker is JBOptimismSucker {
|
|
|
91
91
|
|
|
92
92
|
// Get the project's primary terminal for native token.
|
|
93
93
|
// slither-disable-next-line calls-loop
|
|
94
|
-
IJBTerminal terminal =
|
|
94
|
+
IJBTerminal terminal =
|
|
95
|
+
DIRECTORY.primaryTerminalOf({projectId: cachedProjectId, token: JBConstants.NATIVE_TOKEN});
|
|
95
96
|
|
|
96
97
|
if (address(terminal) == address(0)) {
|
|
97
|
-
revert JBSucker_NoTerminalForToken(
|
|
98
|
+
revert JBSucker_NoTerminalForToken(cachedProjectId, JBConstants.NATIVE_TOKEN);
|
|
98
99
|
}
|
|
99
100
|
|
|
100
101
|
// Add native ETH to the project's balance.
|
|
101
102
|
// slither-disable-next-line arbitrary-send-eth,calls-loop
|
|
102
103
|
terminal.addToBalanceOf{value: amount}({
|
|
103
|
-
projectId:
|
|
104
|
+
projectId: cachedProjectId,
|
|
104
105
|
token: JBConstants.NATIVE_TOKEN,
|
|
105
106
|
amount: amount,
|
|
106
107
|
shouldReturnHeldFees: false,
|
|
@@ -108,7 +109,7 @@ contract JBCeloSucker is JBOptimismSucker {
|
|
|
108
109
|
metadata: ""
|
|
109
110
|
});
|
|
110
111
|
} else {
|
|
111
|
-
super._addToBalance({token: token, amount: amount,
|
|
112
|
+
super._addToBalance({token: token, amount: amount, cachedProjectId: cachedProjectId});
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
package/src/JBSucker.sol
CHANGED
|
@@ -789,8 +789,8 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
789
789
|
/// @notice Adds funds to the projects balance.
|
|
790
790
|
/// @param token The terminal token to add to the project's balance.
|
|
791
791
|
/// @param amount The amount of terminal tokens to add to the project's balance.
|
|
792
|
-
/// @param
|
|
793
|
-
function _addToBalance(address token, uint256 amount, uint256
|
|
792
|
+
/// @param cachedProjectId The cached project ID to avoid redundant storage reads.
|
|
793
|
+
function _addToBalance(address token, uint256 amount, uint256 cachedProjectId) internal virtual {
|
|
794
794
|
// Make sure that the current `amountToAddToBalance` is greater than or equal to the amount being added.
|
|
795
795
|
uint256 addableAmount = amountToAddToBalanceOf(token);
|
|
796
796
|
if (amount > addableAmount) {
|
|
@@ -799,10 +799,10 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
799
799
|
|
|
800
800
|
// Get the project's primary terminal for the token.
|
|
801
801
|
// slither-disable-next-line calls-loop
|
|
802
|
-
IJBTerminal terminal = DIRECTORY.primaryTerminalOf({projectId:
|
|
802
|
+
IJBTerminal terminal = DIRECTORY.primaryTerminalOf({projectId: cachedProjectId, token: token});
|
|
803
803
|
|
|
804
804
|
// slither-disable-next-line incorrect-equality
|
|
805
|
-
if (address(terminal) == address(0)) revert JBSucker_NoTerminalForToken(
|
|
805
|
+
if (address(terminal) == address(0)) revert JBSucker_NoTerminalForToken(cachedProjectId, token);
|
|
806
806
|
|
|
807
807
|
// Perform the `addToBalance`.
|
|
808
808
|
if (token != JBConstants.NATIVE_TOKEN) {
|
|
@@ -813,7 +813,12 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
813
813
|
|
|
814
814
|
// slither-disable-next-line calls-loop
|
|
815
815
|
terminal.addToBalanceOf({
|
|
816
|
-
projectId:
|
|
816
|
+
projectId: cachedProjectId,
|
|
817
|
+
token: token,
|
|
818
|
+
amount: amount,
|
|
819
|
+
shouldReturnHeldFees: false,
|
|
820
|
+
memo: "",
|
|
821
|
+
metadata: ""
|
|
817
822
|
});
|
|
818
823
|
|
|
819
824
|
// Sanity check: make sure we transfer the full amount.
|
|
@@ -823,7 +828,12 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
823
828
|
// If the token is the native token, use `msg.value`.
|
|
824
829
|
// slither-disable-next-line arbitrary-send-eth,calls-loop
|
|
825
830
|
terminal.addToBalanceOf{value: amount}({
|
|
826
|
-
projectId:
|
|
831
|
+
projectId: cachedProjectId,
|
|
832
|
+
token: token,
|
|
833
|
+
amount: amount,
|
|
834
|
+
shouldReturnHeldFees: false,
|
|
835
|
+
memo: "",
|
|
836
|
+
metadata: ""
|
|
827
837
|
});
|
|
828
838
|
}
|
|
829
839
|
}
|
|
@@ -845,7 +855,7 @@ abstract contract JBSucker is ERC2771Context, JBPermissioned, Initializable, ERC
|
|
|
845
855
|
|
|
846
856
|
// Add the cashed out funds to the project's balance.
|
|
847
857
|
if (terminalTokenAmount != 0) {
|
|
848
|
-
_addToBalance({token: terminalToken, amount: terminalTokenAmount,
|
|
858
|
+
_addToBalance({token: terminalToken, amount: terminalTokenAmount, cachedProjectId: cachedProjectId});
|
|
849
859
|
}
|
|
850
860
|
|
|
851
861
|
// Cast the bytes32 beneficiary to an EVM address for the local mint.
|