@bananapus/router-terminal-v6 0.0.4 → 0.0.5
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/JBRouterTerminal.sol +19 -0
package/package.json
CHANGED
package/src/JBRouterTerminal.sol
CHANGED
|
@@ -575,6 +575,7 @@ contract JBRouterTerminal is
|
|
|
575
575
|
bool hasFallback;
|
|
576
576
|
|
|
577
577
|
for (uint256 i; i < terminals.length; i++) {
|
|
578
|
+
// slither-disable-next-line calls-loop
|
|
578
579
|
JBAccountingContext[] memory contexts = terminals[i].accountingContextsOf(projectId);
|
|
579
580
|
|
|
580
581
|
for (uint256 j; j < contexts.length; j++) {
|
|
@@ -611,9 +612,11 @@ contract JBRouterTerminal is
|
|
|
611
612
|
function _bestPoolLiquidity(address tokenA, address tokenB) internal view returns (uint128 bestLiquidity) {
|
|
612
613
|
// Search V3.
|
|
613
614
|
for (uint256 i; i < 4; i++) {
|
|
615
|
+
// slither-disable-next-line calls-loop
|
|
614
616
|
address poolAddr = FACTORY.getPool(tokenA, tokenB, _FEE_TIERS[i]);
|
|
615
617
|
if (poolAddr == address(0)) continue;
|
|
616
618
|
|
|
619
|
+
// slither-disable-next-line calls-loop
|
|
617
620
|
uint128 liquidity = IUniswapV3Pool(poolAddr).liquidity();
|
|
618
621
|
if (liquidity > bestLiquidity) bestLiquidity = liquidity;
|
|
619
622
|
}
|
|
@@ -811,11 +814,13 @@ contract JBRouterTerminal is
|
|
|
811
814
|
function _settleV4(Currency currency, uint256 amount) internal {
|
|
812
815
|
if (Currency.unwrap(currency) == address(0)) {
|
|
813
816
|
// Native ETH: contract already holds raw ETH.
|
|
817
|
+
// slither-disable-next-line unused-return
|
|
814
818
|
POOL_MANAGER.settle{value: amount}();
|
|
815
819
|
} else {
|
|
816
820
|
// ERC20: sync then transfer then settle.
|
|
817
821
|
POOL_MANAGER.sync(currency);
|
|
818
822
|
IERC20(Currency.unwrap(currency)).safeTransfer(address(POOL_MANAGER), amount);
|
|
823
|
+
// slither-disable-next-line unused-return
|
|
819
824
|
POOL_MANAGER.settle();
|
|
820
825
|
}
|
|
821
826
|
}
|
|
@@ -935,6 +940,7 @@ contract JBRouterTerminal is
|
|
|
935
940
|
returns (uint256 minAmountOut)
|
|
936
941
|
{
|
|
937
942
|
PoolId id = key.toId();
|
|
943
|
+
// slither-disable-next-line unused-return
|
|
938
944
|
(, int24 tick,,) = POOL_MANAGER.getSlot0(id);
|
|
939
945
|
uint128 liquidity = POOL_MANAGER.getLiquidity(id);
|
|
940
946
|
|
|
@@ -976,10 +982,12 @@ contract JBRouterTerminal is
|
|
|
976
982
|
|
|
977
983
|
// Search V3.
|
|
978
984
|
for (uint256 i; i < 4; i++) {
|
|
985
|
+
// slither-disable-next-line calls-loop
|
|
979
986
|
address poolAddr = FACTORY.getPool(normalizedTokenIn, normalizedTokenOut, _FEE_TIERS[i]);
|
|
980
987
|
|
|
981
988
|
if (poolAddr == address(0)) continue;
|
|
982
989
|
|
|
990
|
+
// slither-disable-next-line calls-loop
|
|
983
991
|
uint128 poolLiquidity = IUniswapV3Pool(poolAddr).liquidity();
|
|
984
992
|
|
|
985
993
|
if (poolLiquidity > bestLiquidity) {
|
|
@@ -1035,9 +1043,11 @@ contract JBRouterTerminal is
|
|
|
1035
1043
|
hooks: IHooks(address(0))
|
|
1036
1044
|
});
|
|
1037
1045
|
|
|
1046
|
+
// slither-disable-next-line unused-return,calls-loop
|
|
1038
1047
|
(uint160 sqrtPriceX96,,,) = POOL_MANAGER.getSlot0(key.toId());
|
|
1039
1048
|
if (sqrtPriceX96 == 0) continue;
|
|
1040
1049
|
|
|
1050
|
+
// slither-disable-next-line calls-loop
|
|
1041
1051
|
uint128 poolLiquidity = POOL_MANAGER.getLiquidity(key.toId());
|
|
1042
1052
|
if (poolLiquidity > currentBestLiquidity) {
|
|
1043
1053
|
currentBestLiquidity = poolLiquidity;
|
|
@@ -1099,6 +1109,7 @@ contract JBRouterTerminal is
|
|
|
1099
1109
|
while (true) {
|
|
1100
1110
|
// Skip the destination check on the first iteration if we have a credit override.
|
|
1101
1111
|
if (sourceProjectIdOverride == 0) {
|
|
1112
|
+
// slither-disable-next-line calls-loop
|
|
1102
1113
|
destTerminal = DIRECTORY.primaryTerminalOf({projectId: destProjectId, token: token});
|
|
1103
1114
|
if (address(destTerminal) != address(0)) {
|
|
1104
1115
|
return (destTerminal, token, amount);
|
|
@@ -1106,6 +1117,7 @@ contract JBRouterTerminal is
|
|
|
1106
1117
|
}
|
|
1107
1118
|
|
|
1108
1119
|
// Use the override if provided, otherwise look up the project ID from the token.
|
|
1120
|
+
// slither-disable-next-line calls-loop
|
|
1109
1121
|
uint256 sourceProjectId =
|
|
1110
1122
|
sourceProjectIdOverride != 0 ? sourceProjectIdOverride : TOKENS.projectIdOf(IJBToken(token));
|
|
1111
1123
|
|
|
@@ -1119,6 +1131,7 @@ contract JBRouterTerminal is
|
|
|
1119
1131
|
_findCashOutPath({sourceProjectId: sourceProjectId, destProjectId: destProjectId});
|
|
1120
1132
|
|
|
1121
1133
|
// Cash out the source project's tokens.
|
|
1134
|
+
// slither-disable-next-line calls-loop
|
|
1122
1135
|
amount = cashOutTerminal.cashOutTokensOf({
|
|
1123
1136
|
holder: address(this),
|
|
1124
1137
|
projectId: sourceProjectId,
|
|
@@ -1155,11 +1168,13 @@ contract JBRouterTerminal is
|
|
|
1155
1168
|
address baseFallbackToken;
|
|
1156
1169
|
IJBCashOutTerminal baseFallbackTerminal;
|
|
1157
1170
|
|
|
1171
|
+
// slither-disable-next-line calls-loop
|
|
1158
1172
|
IJBTerminal[] memory terminals = DIRECTORY.terminalsOf(sourceProjectId);
|
|
1159
1173
|
|
|
1160
1174
|
for (uint256 i; i < terminals.length; i++) {
|
|
1161
1175
|
// Check if this terminal supports the IJBCashOutTerminal interface.
|
|
1162
1176
|
{
|
|
1177
|
+
// slither-disable-next-line calls-loop
|
|
1163
1178
|
try IERC165(address(terminals[i])).supportsInterface(type(IJBCashOutTerminal).interfaceId) returns (
|
|
1164
1179
|
bool supported
|
|
1165
1180
|
) {
|
|
@@ -1170,6 +1185,7 @@ contract JBRouterTerminal is
|
|
|
1170
1185
|
}
|
|
1171
1186
|
|
|
1172
1187
|
IJBCashOutTerminal terminal = IJBCashOutTerminal(address(terminals[i]));
|
|
1188
|
+
// slither-disable-next-line calls-loop
|
|
1173
1189
|
JBAccountingContext[] memory contexts = terminals[i].accountingContextsOf(sourceProjectId);
|
|
1174
1190
|
|
|
1175
1191
|
for (uint256 j; j < contexts.length; j++) {
|
|
@@ -1177,6 +1193,7 @@ contract JBRouterTerminal is
|
|
|
1177
1193
|
|
|
1178
1194
|
// Priority 1: Does the destination project directly accept this token?
|
|
1179
1195
|
{
|
|
1196
|
+
// slither-disable-next-line calls-loop
|
|
1180
1197
|
IJBTerminal destTerminal =
|
|
1181
1198
|
DIRECTORY.primaryTerminalOf({projectId: destProjectId, token: contextToken});
|
|
1182
1199
|
if (address(destTerminal) != address(0)) {
|
|
@@ -1186,6 +1203,7 @@ contract JBRouterTerminal is
|
|
|
1186
1203
|
|
|
1187
1204
|
// Priority 2: Is this a JB project token (so we can recurse)?
|
|
1188
1205
|
if (address(fallbackTerminal) == address(0) && contextToken != JBConstants.NATIVE_TOKEN) {
|
|
1206
|
+
// slither-disable-next-line calls-loop
|
|
1189
1207
|
if (TOKENS.projectIdOf(IJBToken(contextToken)) != 0) {
|
|
1190
1208
|
fallbackToken = contextToken;
|
|
1191
1209
|
fallbackTerminal = terminal;
|
|
@@ -1258,6 +1276,7 @@ contract JBRouterTerminal is
|
|
|
1258
1276
|
sigDeadline: allowance.sigDeadline
|
|
1259
1277
|
});
|
|
1260
1278
|
|
|
1279
|
+
// slither-disable-next-line reentrancy-events
|
|
1261
1280
|
try PERMIT2.permit({owner: _msgSender(), permitSingle: permitSingle, signature: allowance.signature}) {}
|
|
1262
1281
|
catch (bytes memory reason) {
|
|
1263
1282
|
emit Permit2AllowanceFailed(token, _msgSender(), reason);
|