@across-protocol/contracts 5.0.10-alpha.4 → 5.0.10

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.
Files changed (70) hide show
  1. package/contracts/handlers/MulticallHandler.sol +7 -1
  2. package/contracts/libraries/SafeTransferERC20.sol +21 -0
  3. package/contracts/libraries/TronTransferLib.sol +42 -0
  4. package/contracts/periphery/SpokePoolPeriphery.sol +4 -0
  5. package/contracts/periphery/counterfactual/CounterfactualDepositSpokePool.sol +7 -3
  6. package/contracts/periphery/counterfactual/CounterfactualDepositSpokePoolTr.sol +36 -0
  7. package/contracts/periphery/counterfactual/WithdrawImplementation.sol +3 -6
  8. package/contracts/periphery/counterfactual/WithdrawImplementationTron.sol +22 -0
  9. package/contracts/sp1-helios/SP1AutoVerifier.sol +1 -1
  10. package/contracts/spoke-pools/SpokePool.sol +11 -6
  11. package/contracts/spoke-pools/Tron_SpokePool.sol +65 -0
  12. package/contracts/test/MockTronUSDT.sol +36 -0
  13. package/contracts/tron/TronCounterfactualImports.sol +4 -3
  14. package/contracts/tron/TronImports.sol +2 -2
  15. package/contracts/tron/TronPeripheryImports.sol +1 -1
  16. package/dist/broadcast/deployed-addresses.json +38 -48
  17. package/dist/evm/artifacts/AcrossMessageHandlerMock.sol/AcrossMessageHandlerMock.json +1 -1
  18. package/dist/evm/artifacts/AdminWithdrawManager.sol/AdminWithdrawManager.json +1 -1
  19. package/dist/evm/artifacts/Arbitrum_SpokePool.sol/Arbitrum_SpokePool.json +1 -1
  20. package/dist/evm/artifacts/Blast_SpokePool.sol/Blast_SpokePool.json +1 -1
  21. package/dist/evm/artifacts/Boba_SpokePool.sol/Boba_SpokePool.json +1 -1
  22. package/dist/evm/artifacts/Cher_SpokePool.sol/Cher_SpokePool.json +1 -1
  23. package/dist/evm/artifacts/CounterfactualDepositSpokePool.sol/CounterfactualDepositSpokePool.json +1 -1
  24. package/dist/evm/artifacts/CounterfactualDepositSpokePoolTr.sol/CounterfactualDepositSpokePoolTr.json +1 -0
  25. package/dist/evm/artifacts/DstOFTHandler.sol/DstOFTHandler.json +1 -1
  26. package/dist/evm/artifacts/Ethereum_SpokePool.sol/Ethereum_SpokePool.json +1 -1
  27. package/dist/evm/artifacts/HubPoolTestBase.sol/MockAddressWhitelist.json +1 -1
  28. package/dist/evm/artifacts/HubPoolTestBase.sol/MockFinder.json +1 -1
  29. package/dist/evm/artifacts/HubPoolTestBase.sol/MockIdentifierWhitelist.json +1 -1
  30. package/dist/evm/artifacts/HubPoolTestBase.sol/MockLpTokenFactory.json +1 -1
  31. package/dist/evm/artifacts/HubPoolTestBase.sol/MockOptimisticOracle.json +1 -1
  32. package/dist/evm/artifacts/HubPoolTestBase.sol/MockStore.json +1 -1
  33. package/dist/evm/artifacts/Ink_SpokePool.sol/Ink_SpokePool.json +1 -1
  34. package/dist/evm/artifacts/Lens_SpokePool.sol/Lens_SpokePool.json +1 -1
  35. package/dist/evm/artifacts/Linea_SpokePool.sol/Linea_SpokePool.json +1 -1
  36. package/dist/evm/artifacts/Lisk_SpokePool.sol/Lisk_SpokePool.json +1 -1
  37. package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockCrossDomainMessenger.json +1 -1
  38. package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockL1StandardBridge.json +1 -1
  39. package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockL2StandardBridge.json +1 -1
  40. package/dist/evm/artifacts/MockOptimism_SpokePool.sol/MockOptimism_SpokePool.json +1 -1
  41. package/dist/evm/artifacts/MockSpokePool.sol/MockSpokePool.json +1 -1
  42. package/dist/evm/artifacts/MockSpokePoolV2.sol/MockSpokePoolV2.json +1 -1
  43. package/dist/evm/artifacts/MockTronUSDT.sol/MockTronUSDT.json +1 -0
  44. package/dist/evm/artifacts/MulticallHandler.sol/MulticallHandler.json +1 -1
  45. package/dist/evm/artifacts/OP_SpokePool.sol/OP_SpokePool.json +1 -1
  46. package/dist/evm/artifacts/Optimism_SpokePool.sol/Optimism_SpokePool.json +1 -1
  47. package/dist/evm/artifacts/Ovm_SpokePool.sol/Ovm_SpokePool.json +1 -1
  48. package/dist/evm/artifacts/Ovm_WithdrawalHelper.sol/Ovm_WithdrawalHelper.json +1 -1
  49. package/dist/evm/artifacts/PermissionedMulticallHandler.sol/PermissionedMulticallHandler.json +1 -1
  50. package/dist/evm/artifacts/PolygonZkEVM_SpokePool.sol/PolygonZkEVM_SpokePool.json +1 -1
  51. package/dist/evm/artifacts/Polygon_SpokePool.sol/Polygon_SpokePool.json +1 -1
  52. package/dist/evm/artifacts/SP1AutoVerifier.sol/SP1AutoVerifier.json +1 -1
  53. package/dist/evm/artifacts/Scroll_SpokePool.sol/Scroll_SpokePool.json +1 -1
  54. package/dist/evm/artifacts/SpokePool.sol/SpokePool.json +1 -1
  55. package/dist/evm/artifacts/SpokePoolPeriphery.sol/SpokePoolPeriphery.json +1 -1
  56. package/dist/evm/artifacts/SpokePoolPeriphery.sol/SwapProxy.json +1 -1
  57. package/dist/evm/artifacts/SponsoredCCTPDstPeriphery.sol/SponsoredCCTPDstPeriphery.json +1 -1
  58. package/dist/evm/artifacts/SponsoredCCTPSrcPeriphery.sol/SponsoredCCTPSrcPeriphery.json +1 -1
  59. package/dist/evm/artifacts/SponsoredOFTSrcPeriphery.sol/SponsoredOFTSrcPeriphery.json +1 -1
  60. package/dist/evm/artifacts/TronTransferLib.sol/TronTransferLib.json +1 -0
  61. package/dist/evm/artifacts/Tron_SpokePool.sol/Tron_SpokePool.json +1 -0
  62. package/dist/evm/artifacts/Universal_SpokePool.sol/Universal_SpokePool.json +1 -1
  63. package/dist/evm/artifacts/WithdrawImplementation.sol/WithdrawImplementation.json +1 -1
  64. package/dist/evm/artifacts/WithdrawImplementationTron.sol/WithdrawImplementationTron.json +1 -0
  65. package/dist/evm/artifacts/WorldChain_SpokePool.sol/WorldChain_SpokePool.json +1 -1
  66. package/dist/evm/artifacts/ZkSync_SpokePool.sol/ZkSync_SpokePool.json +1 -1
  67. package/dist/evm/artifacts/eraVM_EIP7702.sol/SimpleContract.json +1 -1
  68. package/dist/evm/artifacts/eraVM_EIP7702.sol/SpokePoolEIP7702Test.json +1 -1
  69. package/dist/evm/artifacts/eraVM_EIP7702.sol/TestableMockSpokePool.json +1 -1
  70. package/package.json +3 -3
@@ -10,7 +10,13 @@ import "@openzeppelin/contracts-v4/security/ReentrancyGuard.sol";
10
10
  /**
11
11
  * @title Across Multicall contract that allows a user to specify a series of calls that should be made by the handler
12
12
  * via the message field in the deposit.
13
- * @dev This contract makes the calls blindly. The contract will send any remaining tokens The caller should ensure that the tokens received by the handler are completely consumed.
13
+ * @dev This contract makes the calls blindly. The caller should ensure that the tokens received by the handler are
14
+ * completely consumed; otherwise leftover balances will be sent to the fallbackRecipient (when one is provided)
15
+ * or remain on this contract.
16
+ *
17
+ * @dev This contract is a stateless utility with no per-user accounting or admin rescue. Tokens delivered to it
18
+ * are expected to be consumed in the same transaction; any balances left on the contract can be claimed by any
19
+ * caller.
14
20
  */
15
21
  contract MulticallHandler is AcrossMessageHandler, ReentrancyGuard {
16
22
  using SafeERC20 for IERC20;
@@ -0,0 +1,21 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
+ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
+
7
+ /**
8
+ * @notice Mixin exposing a virtual `_safeTransfer` hook. Default implementation uses
9
+ * OZ `SafeERC20.safeTransfer`. Inheritors may override to swap in alternative
10
+ * ERC20 transfer semantics.
11
+ */
12
+ abstract contract SafeTransferERC20 {
13
+ // This mixin is the only place in the codebase permitted to call `IERC20.safeTransfer`
14
+ // directly. Inheriting contracts restrict their own `using` directives to exclude
15
+ // `safeTransfer` so all transfer call sites are forced through this overridable hook.
16
+ using { SafeERC20.safeTransfer } for IERC20;
17
+
18
+ function _safeTransfer(address token, address to, uint256 amount) internal virtual {
19
+ IERC20(token).safeTransfer(to, amount);
20
+ }
21
+ }
@@ -0,0 +1,42 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
+
6
+ /**
7
+ * @notice Balance-delta ERC20 transfer for tokens whose `transfer` returns non-standard
8
+ * values. Specifically targets Tron USDT, which returns false even on success.
9
+ * @dev Two-error model: `_safeTransferBalanceCheck` reverts with `TronTransferCallReverted`
10
+ * if the underlying call reverts, or `TronTransferBalanceMismatch` if the call returns
11
+ * but the recipient's balance does not increase by exactly `amount`. `_balanceDeltaTransfer`
12
+ * is the bool-pair primitive both wrappers (revert / no-revert) share — callers needing a
13
+ * collapsed bool can AND the two flags. Assumes no fee-on-transfer.
14
+ *
15
+ * IERC20 and IERC20Upgradeable produce bytewise-identical calldata for
16
+ * `transfer(address,uint256)` and `balanceOf(address)`, so this library is safe to call
17
+ * from contracts using either OZ variant.
18
+ */
19
+ library TronTransferLib {
20
+ error TronTransferCallReverted();
21
+ error TronTransferBalanceMismatch();
22
+
23
+ /// @dev Returns (callOk, balanceOk). callOk=false means the low-level call reverted;
24
+ /// balanceOk=false means the call returned but balance did not change by exactly `amount`.
25
+ /// When callOk=false, balanceOk is also false (no balance check performed).
26
+ function _balanceDeltaTransfer(
27
+ address token,
28
+ address to,
29
+ uint256 amount
30
+ ) internal returns (bool callOk, bool balanceOk) {
31
+ uint256 pre = IERC20(token).balanceOf(to);
32
+ (callOk, ) = token.call(abi.encodeCall(IERC20.transfer, (to, amount)));
33
+ if (!callOk) return (false, false);
34
+ balanceOk = IERC20(token).balanceOf(to) == pre + amount;
35
+ }
36
+
37
+ function _safeTransferBalanceCheck(address token, address to, uint256 amount) internal {
38
+ (bool callOk, bool balanceOk) = _balanceDeltaTransfer(token, to, amount);
39
+ if (!callOk) revert TronTransferCallReverted();
40
+ if (!balanceOk) revert TronTransferBalanceMismatch();
41
+ }
42
+ }
@@ -21,6 +21,10 @@ import { AddressToBytes32 } from "../libraries/AddressConverters.sol";
21
21
  * @title SwapProxy
22
22
  * @notice A dedicated proxy contract that isolates swap execution to mitigate frontrunning vulnerabilities.
23
23
  * The SpokePoolPeriphery transfers tokens to this contract, which performs the swap and returns tokens back to the periphery.
24
+ *
25
+ * @dev This contract is a stateless utility with no per-user accounting or admin rescue. Tokens delivered to it
26
+ * are expected to be consumed in the same transaction; any balances left on the contract can be claimed by any
27
+ * caller.
24
28
  * @custom:security-contact bugs@across.to
25
29
  */
26
30
  contract SwapProxy is ReentrancyGuard {
@@ -8,6 +8,7 @@ import { EIP712 } from "@openzeppelin/contracts/utils/cryptography/EIP712.sol";
8
8
  import { V3SpokePoolInterface } from "../../interfaces/V3SpokePoolInterface.sol";
9
9
  import { ICounterfactualImplementation } from "../../interfaces/ICounterfactualImplementation.sol";
10
10
  import { NATIVE_ASSET, BPS_SCALAR } from "./CounterfactualConstants.sol";
11
+ import { SafeTransferERC20 } from "../../libraries/SafeTransferERC20.sol";
11
12
 
12
13
  /**
13
14
  * @notice Route parameters committed to in the merkle leaf.
@@ -51,8 +52,11 @@ struct SpokePoolSubmitterData {
51
52
  * cannot sign `speedUpV3Deposit` messages.
52
53
  * @custom:security-contact bugs@across.to
53
54
  */
54
- contract CounterfactualDepositSpokePool is ICounterfactualImplementation, EIP712 {
55
- using SafeERC20 for IERC20;
55
+ contract CounterfactualDepositSpokePool is ICounterfactualImplementation, EIP712, SafeTransferERC20 {
56
+ // Restrict the `using` attachment to `forceApprove` only. All `safeTransfer` calls must go
57
+ // through the `_safeTransfer` hook (inherited from `SafeTransferERC20`) so chain-specific
58
+ // variants can override transfer semantics in one place.
59
+ using { SafeERC20.forceApprove } for IERC20;
56
60
 
57
61
  uint256 internal constant EXCHANGE_RATE_SCALAR = 1e18;
58
62
 
@@ -152,7 +156,7 @@ contract CounterfactualDepositSpokePool is ICounterfactualImplementation, EIP712
152
156
  (bool success, ) = sd.executionFeeRecipient.call{ value: dp.executionFee }("");
153
157
  if (!success) revert NativeTransferFailed();
154
158
  } else {
155
- IERC20(inputToken).safeTransfer(sd.executionFeeRecipient, dp.executionFee);
159
+ _safeTransfer(inputToken, sd.executionFeeRecipient, dp.executionFee);
156
160
  }
157
161
  }
158
162
 
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { CounterfactualDepositSpokePool } from "./CounterfactualDepositSpokePool.sol";
5
+ import { TronTransferLib } from "../../libraries/TronTransferLib.sol";
6
+
7
+ /**
8
+ * @title CounterfactualDepositSpokePoolTr
9
+ * @notice Tron-specific variant of `CounterfactualDepositSpokePool` for chains where the
10
+ * input token may be Tron USDT (whose `transfer` returns false on success).
11
+ * @dev Inherits everything from the mainline implementation and overrides the
12
+ * `_safeTransfer` hook to use a balance-delta success check that tolerates
13
+ * Tron USDT's non-standard return value. `forceApprove` is unaffected — `approve`
14
+ * returns true correctly on Tron USDT.
15
+ *
16
+ * The EIP-712 domain name is inherited from the parent (`CounterfactualDepositSpokePool`).
17
+ * Cross-implementation signature replay is already prevented by the `verifyingContract`
18
+ * field of the EIP-712 domain: each clone's address is derived via CREATE2 from its
19
+ * implementation address, so a signature for a mainline clone does not verify against
20
+ * a Tron-variant clone.
21
+ * @custom:security-contact bugs@across.to
22
+ */
23
+ contract CounterfactualDepositSpokePoolTr is CounterfactualDepositSpokePool {
24
+ constructor(
25
+ address _spokePool,
26
+ address _signer,
27
+ address _wrappedNativeToken
28
+ ) CounterfactualDepositSpokePool(_spokePool, _signer, _wrappedNativeToken) {} // solhint-disable-line no-empty-blocks
29
+
30
+ /// @dev TRON OVERRIDE: was `IERC20(token).safeTransfer(to, amount)` in the parent.
31
+ /// `TronTransferLib._safeTransferBalanceCheck` uses a balance-delta success check so it
32
+ /// tolerates Tron USDT's non-standard `transfer` return value.
33
+ function _safeTransfer(address token, address to, uint256 amount) internal override {
34
+ TronTransferLib._safeTransferBalanceCheck(token, to, amount);
35
+ }
36
+ }
@@ -1,10 +1,9 @@
1
1
  // SPDX-License-Identifier: BUSL-1.1
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
5
- import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
6
4
  import { ICounterfactualImplementation } from "../../interfaces/ICounterfactualImplementation.sol";
7
5
  import { NATIVE_ASSET } from "./CounterfactualConstants.sol";
6
+ import { SafeTransferERC20 } from "../../libraries/SafeTransferERC20.sol";
8
7
 
9
8
  /**
10
9
  * @notice Withdrawal parameters committed to in the merkle leaf.
@@ -22,9 +21,7 @@ struct WithdrawParams {
22
21
  * @dev Called via delegatecall from the CounterfactualDeposit dispatcher. `address(this)` is the clone
23
22
  * and `msg.sender` is the original caller.
24
23
  */
25
- contract WithdrawImplementation is ICounterfactualImplementation {
26
- using SafeERC20 for IERC20;
27
-
24
+ contract WithdrawImplementation is ICounterfactualImplementation, SafeTransferERC20 {
28
25
  event Withdraw(address indexed token, address indexed to, uint256 amount);
29
26
 
30
27
  error Unauthorized();
@@ -46,7 +43,7 @@ contract WithdrawImplementation is ICounterfactualImplementation {
46
43
  (bool success, ) = to.call{ value: amount }("");
47
44
  if (!success) revert NativeTransferFailed();
48
45
  } else {
49
- IERC20(token).safeTransfer(to, amount);
46
+ _safeTransfer(token, to, amount);
50
47
  }
51
48
 
52
49
  emit Withdraw(token, to, amount);
@@ -0,0 +1,22 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { WithdrawImplementation } from "./WithdrawImplementation.sol";
5
+ import { TronTransferLib } from "../../libraries/TronTransferLib.sol";
6
+
7
+ /**
8
+ * @title WithdrawImplementationTron
9
+ * @notice Tron-specific variant of `WithdrawImplementation`. Inherits from the mainline
10
+ * contract and overrides the `_safeTransfer` hook to use a balance-delta
11
+ * success check that tolerates Tron USDT's non-standard `transfer` return value.
12
+ * Native-asset withdrawals are unchanged.
13
+ * @custom:security-contact bugs@across.to
14
+ */
15
+ contract WithdrawImplementationTron is WithdrawImplementation {
16
+ /// @dev TRON OVERRIDE: was `IERC20(token).safeTransfer(to, amount)` in the parent.
17
+ /// `TronTransferLib._safeTransferBalanceCheck` uses a balance-delta success check so it
18
+ /// tolerates Tron USDT's non-standard `transfer` return value.
19
+ function _safeTransfer(address token, address to, uint256 amount) internal override {
20
+ TronTransferLib._safeTransferBalanceCheck(token, to, amount);
21
+ }
22
+ }
@@ -4,7 +4,7 @@ pragma solidity ^0.8.25;
4
4
  import { ISP1Verifier } from "@sp1-contracts/src/ISP1Verifier.sol";
5
5
 
6
6
  /// @title SP1 Auto Verifier
7
- /// @notice A no-op verifier that accepts any proof. Useful for testing SP1Helios without real proofs.
7
+ /// @notice A no-op verifier that accepts any proof.
8
8
  contract SP1AutoVerifier is ISP1Verifier {
9
9
  // pure is intentionally stricter than the interface's view; Solidity allows this and it's correct for a no-op.
10
10
  function verifyProof(bytes32, bytes calldata, bytes calldata) external pure {}
@@ -11,6 +11,7 @@ import "../upgradeable/MultiCallerUpgradeable.sol";
11
11
  import "../upgradeable/EIP712CrossChainUpgradeable.sol";
12
12
  import "../upgradeable/AddressLibUpgradeable.sol";
13
13
  import "../libraries/AddressConverters.sol";
14
+ import { SafeTransferERC20 } from "../libraries/SafeTransferERC20.sol";
14
15
  import { IOFT, SendParam, MessagingFee } from "../interfaces/IOFT.sol";
15
16
  import { OFTTransportAdapter } from "../libraries/OFTTransportAdapter.sol";
16
17
 
@@ -39,9 +40,13 @@ abstract contract SpokePool is
39
40
  MultiCallerUpgradeable,
40
41
  EIP712CrossChainUpgradeable,
41
42
  IDestinationSettler,
42
- OFTTransportAdapter
43
+ OFTTransportAdapter,
44
+ SafeTransferERC20
43
45
  {
44
- using SafeERC20Upgradeable for IERC20Upgradeable;
46
+ // Restrict the `using` attachment to `safeTransferFrom` only. All `safeTransfer` calls must go
47
+ // through the `_safeTransfer` hook (inherited from `SafeTransferERC20`) so chain-specific
48
+ // variants can override transfer semantics in one place.
49
+ using { SafeERC20Upgradeable.safeTransferFrom } for IERC20Upgradeable;
45
50
  using AddressLibUpgradeable for address;
46
51
  using Bytes32ToAddress for bytes32;
47
52
  using AddressToBytes32 for address;
@@ -1241,7 +1246,7 @@ abstract contract SpokePool is
1241
1246
  uint256 refund = relayerRefund[l2TokenAddress.toAddress()][msg.sender];
1242
1247
  if (refund == 0) revert NoRelayerRefundToClaim();
1243
1248
  relayerRefund[l2TokenAddress.toAddress()][msg.sender] = 0;
1244
- IERC20Upgradeable(l2TokenAddress.toAddress()).safeTransfer(refundAddress.toAddress(), refund);
1249
+ _safeTransfer(l2TokenAddress.toAddress(), refundAddress.toAddress(), refund);
1245
1250
 
1246
1251
  emit ClaimedRelayerRefund(l2TokenAddress, refundAddress, refund, msg.sender);
1247
1252
  }
@@ -1429,7 +1434,7 @@ abstract contract SpokePool is
1429
1434
  // Re-implementation of OZ _callOptionalReturnBool to use private logic. Function executes a transfer and returns a
1430
1435
  // bool indicating if the external call was successful, rather than reverting. Original method:
1431
1436
  // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/28aed34dc5e025e61ea0390c18cac875bfde1a78/contracts/token/ERC20/utils/SafeERC20.sol#L188
1432
- function _noRevertTransfer(address token, address to, uint256 amount) internal returns (bool) {
1437
+ function _noRevertTransfer(address token, address to, uint256 amount) internal virtual returns (bool) {
1433
1438
  bool success;
1434
1439
  uint256 returnSize;
1435
1440
  uint256 returnValue;
@@ -1548,7 +1553,7 @@ abstract contract SpokePool is
1548
1553
  wrappedNativeToken.withdraw(amount);
1549
1554
  AddressLibUpgradeable.sendValue(to, amount);
1550
1555
  } else {
1551
- IERC20Upgradeable(address(wrappedNativeToken)).safeTransfer(to, amount);
1556
+ _safeTransfer(address(wrappedNativeToken), to, amount);
1552
1557
  }
1553
1558
  }
1554
1559
 
@@ -1662,7 +1667,7 @@ abstract contract SpokePool is
1662
1667
  } else {
1663
1668
  // Note: Similar to note above, send token directly from the contract to the user in the slow relay case.
1664
1669
  if (!isSlowFill) IERC20Upgradeable(outputToken).safeTransferFrom(msg.sender, recipientToSend, amountToSend);
1665
- else IERC20Upgradeable(outputToken).safeTransfer(recipientToSend, amountToSend);
1670
+ else _safeTransfer(outputToken, recipientToSend, amountToSend);
1666
1671
  }
1667
1672
 
1668
1673
  bytes memory updatedMessage = relayExecution.updatedMessage;
@@ -0,0 +1,65 @@
1
+ // SPDX-License-Identifier: BUSL-1.1
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { IERC20 } from "@openzeppelin/contracts-v4/token/ERC20/IERC20.sol";
5
+
6
+ import { Universal_SpokePool } from "./Universal_SpokePool.sol";
7
+ import { ITokenMessenger } from "../external/interfaces/CCTPInterfaces.sol";
8
+ import { TronTransferLib } from "../libraries/TronTransferLib.sol";
9
+
10
+ /**
11
+ * @notice Tron-specific SpokePool variant that handles non-standard ERC20 implementations.
12
+ * @dev Tron USDT's `transfer` always returns false on success, which breaks the return-value
13
+ * checks in `SafeERC20.safeTransfer` and `SpokePool._noRevertTransfer`. This variant
14
+ * overrides both base hooks (`_noRevertTransfer` and `_safeTransfer`) to delegate to
15
+ * `TronTransferLib`, which performs a balance-delta success check. `transferFrom` is
16
+ * correct on Tron USDT, so paths using `safeTransferFrom` are unchanged.
17
+ *
18
+ * Assumes Tether's `basisPointsRate` fee-on-transfer mechanism stays at zero. If it
19
+ * is ever activated, balance-delta will report failure on successful transfers and
20
+ * USDT routes on this contract will wedge until disabled operationally.
21
+ * @custom:security-contact bugs@across.to
22
+ */
23
+ contract Tron_SpokePool is Universal_SpokePool {
24
+ /// @custom:oz-upgrades-unsafe-allow constructor
25
+ constructor(
26
+ uint256 _adminUpdateBufferSeconds,
27
+ address _helios,
28
+ address _hubPoolStore,
29
+ address _wrappedNativeTokenAddress,
30
+ uint32 _depositQuoteTimeBuffer,
31
+ uint32 _fillDeadlineBuffer,
32
+ IERC20 _l2Usdc,
33
+ ITokenMessenger _cctpTokenMessenger,
34
+ uint32 _oftDstEid,
35
+ uint256 _oftFeeCap
36
+ )
37
+ Universal_SpokePool(
38
+ _adminUpdateBufferSeconds,
39
+ _helios,
40
+ _hubPoolStore,
41
+ _wrappedNativeTokenAddress,
42
+ _depositQuoteTimeBuffer,
43
+ _fillDeadlineBuffer,
44
+ _l2Usdc,
45
+ _cctpTokenMessenger,
46
+ _oftDstEid,
47
+ _oftFeeCap
48
+ )
49
+ {} // solhint-disable-line no-empty-blocks
50
+
51
+ /// @dev Replaces base implementation's return-value-based success detection with a
52
+ /// balance-delta check. Required because Tron USDT's `transfer` returns false
53
+ /// even on successful transfers.
54
+ function _noRevertTransfer(address token, address to, uint256 amount) internal override returns (bool) {
55
+ (bool callOk, bool balanceOk) = TronTransferLib._balanceDeltaTransfer(token, to, amount);
56
+ return callOk && balanceOk;
57
+ }
58
+
59
+ /// @dev Revert-on-failure variant; reverts with `TronTransferCallReverted` or
60
+ /// `TronTransferBalanceMismatch` so callers can distinguish failure modes.
61
+ /// Replaces the base `safeTransfer` call sites (claimRelayerRefund, slow-fill ERC20 path).
62
+ function _safeTransfer(address token, address to, uint256 amount) internal override {
63
+ TronTransferLib._safeTransferBalanceCheck(token, to, amount);
64
+ }
65
+ }
@@ -0,0 +1,36 @@
1
+ // SPDX-License-Identifier: Unlicense
2
+ pragma solidity ^0.8.0;
3
+
4
+ import { ERC20 } from "@openzeppelin/contracts-v4/token/ERC20/ERC20.sol";
5
+
6
+ /**
7
+ * @title MockTronUSDT
8
+ * @notice Test mock that mirrors the Tron USDT bug: `transfer` moves balances correctly
9
+ * but always returns `false` on success. `transferFrom` and `approve` return
10
+ * `true` correctly per the standard.
11
+ * @dev Set `blacklisted[addr]` to make transfers involving that address revert, simulating
12
+ * Tether's `notBlacklisted` modifier and the "actual failure" scenario.
13
+ */
14
+ contract MockTronUSDT is ERC20 {
15
+ mapping(address => bool) public blacklisted;
16
+
17
+ constructor() ERC20("Tron USDT", "USDT") {}
18
+
19
+ function mint(address to, uint256 amount) external {
20
+ _mint(to, amount);
21
+ }
22
+
23
+ function setBlacklisted(address account, bool isBlacklisted) external {
24
+ blacklisted[account] = isBlacklisted;
25
+ }
26
+
27
+ function decimals() public pure override returns (uint8) {
28
+ return 6;
29
+ }
30
+
31
+ function transfer(address to, uint256 amount) public override returns (bool) {
32
+ require(!blacklisted[msg.sender] && !blacklisted[to], "blacklisted");
33
+ _transfer(msg.sender, to, amount);
34
+ return false;
35
+ }
36
+ }
@@ -2,12 +2,13 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // Entry point for counterfactual contracts in the tron Foundry profile. These use OZ v4 and must
5
- // be in a separate file from SP1Helios/UniversalSpokePool (OZ v5) to avoid name collisions.
5
+ // be in a separate file from SP1Helios/Tron_SpokePool (OZ v5) to avoid name collisions.
6
6
  import "../periphery/counterfactual/AdminWithdrawManager.sol";
7
7
  import "../periphery/counterfactual/CounterfactualConstants.sol";
8
8
  import "../periphery/counterfactual/CounterfactualDeposit.sol";
9
9
  import "../periphery/counterfactual/CounterfactualDepositCCTP.sol";
10
10
  import "../periphery/counterfactual/CounterfactualDepositFactoryTron.sol";
11
11
  import "../periphery/counterfactual/CounterfactualDepositOFT.sol";
12
- import "../periphery/counterfactual/CounterfactualDepositSpokePool.sol";
13
- import "../periphery/counterfactual/WithdrawImplementation.sol";
12
+ import "../periphery/counterfactual/CounterfactualDepositSpokePoolTr.sol";
13
+ import "../libraries/TronTransferLib.sol";
14
+ import "../periphery/counterfactual/WithdrawImplementationTron.sol";
@@ -1,9 +1,9 @@
1
1
  // SPDX-License-Identifier: BUSL-1.1
2
2
  pragma solidity ^0.8.0;
3
3
 
4
- // Entry point for SP1Helios and UniversalSpokePool in the tron Foundry profile. These use OZ v5
4
+ // Entry point for SP1Helios and Tron_SpokePool in the tron Foundry profile. These use OZ v5
5
5
  // and must be in a separate file from counterfactual contracts (OZ v4) to avoid name collisions.
6
6
  import "../sp1-helios/SP1Helios.sol";
7
7
  import "../sp1-helios/SP1AutoVerifier.sol";
8
8
  import "@openzeppelin/contracts-v4/proxy/ERC1967/ERC1967Proxy.sol";
9
- import "../spoke-pools/Universal_SpokePool.sol";
9
+ import "../spoke-pools/Tron_SpokePool.sol";
@@ -2,5 +2,5 @@
2
2
  pragma solidity ^0.8.0;
3
3
 
4
4
  // Entry point for SpokePoolPeriphery and SwapProxy in the tron Foundry profile. These use OZ v4
5
- // and are kept in a separate file from SP1Helios/UniversalSpokePool (OZ v5) to avoid name collisions.
5
+ // and are kept in a separate file from SP1Helios/Tron_SpokePool (OZ v5) to avoid name collisions.
6
6
  import "../periphery/SpokePoolPeriphery.sol";
@@ -211,19 +211,19 @@
211
211
  "transaction_hash": "0xa2a7b2c6812fb8ae34539fb04cd5f2a9112da1c7f6ffce0ddcf1fee7e43acf48"
212
212
  },
213
213
  "PermissionedMulticallHandler": {
214
- "address": "0xDd52f8134f85f3979fbA24387Ce0CEC05937259E",
215
- "block_number": 25050834,
216
- "transaction_hash": "0xc7f656f7ae6a105c3cef94d67c488c14b2e44037af06dd3541d13e87305b8d53"
214
+ "address": "0x64a43393866DBA0044879979fAa7AD3d000622e9",
215
+ "block_number": 24021499,
216
+ "transaction_hash": "0x70b3edf99db66aac34338c3686cd708ddfc2b503c2f707f51ced67dc50e5022f"
217
217
  },
218
218
  "DonationBox_CCTP": {
219
- "address": "0x109Db572e719Fa363dC53Fbaf3617422159060c9",
220
- "block_number": 25050835,
221
- "transaction_hash": "0x0da10665bd5c3250388d5e07ae01004275fda9033d8eccfb94932623df6f667c"
219
+ "address": "0xc1A2465c0913438A51d0b6339169f8b944f00cD1",
220
+ "block_number": 24451558,
221
+ "transaction_hash": "0x2571a14def62200935cd4c90356b1f1415e6977e60380c7dbdd4b0f4915d12fa"
222
222
  },
223
223
  "SponsoredCCTPDstPeriphery": {
224
- "address": "0x214C19FBcdFb683F2c726B4BBAf24AB483bFaDf3",
225
- "block_number": 25050837,
226
- "transaction_hash": "0xd3a1f51d6917a22db3fafe940a9ce0b72986974eee1861c0706d46a49ba408e2"
224
+ "address": "0xDe589398a3FE1DCca80C12053A14811f3E4033f4",
225
+ "block_number": 24451558,
226
+ "transaction_hash": "0x60497293901970b1fc224cc51f134a171e5430ef6f30ff9a9084b7a0c852718a"
227
227
  },
228
228
  "SponsoredCCTPSrcPeriphery": {
229
229
  "address": "0x6769155b16F25D317819eFef011E0A50A48e83c5",
@@ -869,25 +869,20 @@
869
869
  "block_number": 32382094,
870
870
  "transaction_hash": "0x188d49f786ebe99a6dbeb7c845d525064431a1eb615d0bea275d8da8a32953b1"
871
871
  },
872
- "PermissionedMulticallHandler": {
873
- "address": "0xD7B719ed2b02Bfa0247600EDd6bd8Fb3957e95c8",
874
- "block_number": 33686717,
875
- "transaction_hash": "0x51bc99dd5ba78198246e16eee7b2f94dbe123720f05bffd1dd0862d5da8e2fb5"
876
- },
877
872
  "DonationBox_CCTP": {
878
- "address": "0xe3D0D1B6d3571EDC9657dB5076AC1Be5f0bBfE60",
879
- "block_number": 33686717,
880
- "transaction_hash": "0x38305e431db9c74a6f9fa2f6209c2086cc4b79f10ca3bfae773e4313914eaf28"
873
+ "address": "0xEd7422d44045781f4492Fa4b569063e5a1EB185b",
874
+ "block_number": 27222774,
875
+ "transaction_hash": "0x4eab452b9de97795c5d6644791e824359af36006ec521a7d1fb4c4283d247ff3"
881
876
  },
882
877
  "SponsoredCCTPDstPeriphery": {
883
- "address": "0x1CFE31eD57c2d2b4CB69c0298A1b586965b882d5",
884
- "block_number": 33686717,
885
- "transaction_hash": "0x5730f65ea3507b2daea9a0a143b3da717d7f2194e428993fb04fddfb714eb66e"
878
+ "address": "0x478D451e101bE484880a14cf3cCC293CD48E6140",
879
+ "block_number": 27222774,
880
+ "transaction_hash": "0x2b293a55b216b63afc96c148a0043b7522c4f6a847b9bc73112d03da3f1d2c6e"
886
881
  },
887
882
  "SponsoredCCTPSrcPeriphery": {
888
- "address": "0xF4E32c4aC479f0B007BC005Ec0F481A2C78Ba1B4",
889
- "block_number": 33685558,
890
- "transaction_hash": "0xef3bcc6d1bb0adc5a2b88c6dbe64a2492f72ac7d27a4aa6e42e5ace34df1f531"
883
+ "address": "0xc611D7c33d1C7915F13ef35f488EAee9D9DC3555",
884
+ "block_number": 27219602,
885
+ "transaction_hash": "0x13b2a5eee6960ab615fe83eaac7203a16878d039fa4a91cb9e1dfafc1bc56298"
891
886
  },
892
887
  "TransferProxy": {
893
888
  "address": "0x8b2C0BFaBD6DaD8cc700dde3F168D3c81CF0eEfF",
@@ -1197,20 +1192,15 @@
1197
1192
  "block_number": 43894633,
1198
1193
  "transaction_hash": "0x28b429aae286cfb5f09ce924514384b64203a62def3fbb61296a93e1bb3636eb"
1199
1194
  },
1200
- "PermissionedMulticallHandler": {
1201
- "address": "0xB6CAAfD8Ecf18385fFc7c020327E111a1D40A2D4",
1202
- "block_number": 44959757,
1203
- "transaction_hash": "0x0e3e581e4970cb3b9a193f8fddf7a63cbcc4c4f7b980139a6f685fbbfec1d459"
1204
- },
1205
1195
  "DonationBox_CCTP": {
1206
- "address": "0x3ff139d8d5519555aA13b0eBd357B0Ba810f06Df",
1207
- "block_number": 44959758,
1208
- "transaction_hash": "0x019b8a736e60768ec4410e4e38c8ae4385e23e72c0cdcc9f305269d1208948c5"
1196
+ "address": "0xC1d6B848553602BED3524B05B7EB68c20899d861",
1197
+ "block_number": 42941026,
1198
+ "transaction_hash": "0xe8250326847544f47a63a3b799e07e127d21dc62a1901722293ef1335bee17e4"
1209
1199
  },
1210
1200
  "SponsoredCCTPDstPeriphery": {
1211
- "address": "0x8dEDA155E446F5d90579C3DCe560e5b00e93F773",
1212
- "block_number": 44959760,
1213
- "transaction_hash": "0x052db9819150099889e890e641781eedcb3f7e016f87d72bea2984ce6554d350"
1201
+ "address": "0xd9DC78B969E9Efb1e54B625c33A21Aaf2509e6a1",
1202
+ "block_number": 42941286,
1203
+ "transaction_hash": "0x75e0619a67afe82f14b279e9b1896882a0b64513161f4d49cc80fd771e019df6"
1214
1204
  },
1215
1205
  "SponsoredCCTPSrcPeriphery": {
1216
1206
  "address": "0xa30968D3468316D957B9115EAad3C1c8E450116d",
@@ -1870,10 +1860,10 @@
1870
1860
  "block_number": 81269910,
1871
1861
  "transaction_hash": "ac7736e4912d3bd8e02b9dc26bd0ba6c0486b488b091141a8dde7f0c96be13f5"
1872
1862
  },
1873
- "CounterfactualDepositSpokePool": {
1874
- "address": "TN3K7Tk2jZMjdafcUQrkg8yw6BneQtXZ75",
1875
- "block_number": 81271437,
1876
- "transaction_hash": "d3a41d6aaf79a3a482c3824050ecd44457957b920893d92da222a2335eefdd09"
1863
+ "CounterfactualDepositSpokePoolTr": {
1864
+ "address": "TF3BzhGswEw4kEWnR5dzjCsZEj4cVzVtsG",
1865
+ "block_number": 82681402,
1866
+ "transaction_hash": "7c4a10b23d583e9290d43a3b2b8dca02cccf47b53b2f5932e6fa92ab72b6ba47"
1877
1867
  },
1878
1868
  "SP1AutoVerifier": {
1879
1869
  "address": "TUsGvWXwp8fhFfJD2Qj3qGUWUFqH4sjm84",
@@ -1881,24 +1871,24 @@
1881
1871
  "transaction_hash": "6bb786350fb65c85df414085b65caa22e5de47d59a241ec4b213aae2b41a9738"
1882
1872
  },
1883
1873
  "SP1Helios": {
1884
- "address": "TM7RW746BsRpoarBGZfwWVnVvhLNK6tBQx",
1885
- "block_number": 81266543,
1886
- "transaction_hash": "2a282124875b409051659cb86e82d2e6ae7eaa16df3d1a801b0936a2ffae81e9"
1874
+ "address": "TBQff32XdcRpknUY6iJVz2GkQe4aeB9eSm",
1875
+ "block_number": 82679886,
1876
+ "transaction_hash": "78ee3e484f44da394b990adcd3b43d422a343246ab7c7141b3385ee3aeac2f71"
1887
1877
  },
1888
1878
  "SpokePool": {
1889
- "address": "TDe6gRnHcqZnhn1H5UZQcJ29kmvadFKjb8",
1890
- "block_number": 81267900,
1891
- "transaction_hash": "916d12109b908916a5180dbaf032c577b758615e975ce909cdee696f066f5ac9"
1879
+ "address": "TTbCVPfUZmPhrB9sYC8GKgGBQQEdZovkmS",
1880
+ "block_number": 82680434,
1881
+ "transaction_hash": "74051a48b3f5f7b3bae081adab862e63689b93ee4e221473221f2a4206f5216c"
1892
1882
  },
1893
1883
  "SpokePoolPeriphery": {
1894
1884
  "address": "TN88jHbhTpRcKwS6f7fNmXFbGbeqJR1trZ",
1895
1885
  "block_number": 81812685,
1896
1886
  "transaction_hash": "9a708fb56c6b0bba4e87599f8b1309b479f144badc7a2130d4cd3554836e4481"
1897
1887
  },
1898
- "WithdrawImplementation": {
1899
- "address": "TJkwUDFPKXABkeu38v42sdwQS2VxgRweow",
1900
- "block_number": 81269861,
1901
- "transaction_hash": "226499b9a0e735991922ca744364017aa882df1b33ea23e44c80695181ed12d4"
1888
+ "WithdrawImplementationTron": {
1889
+ "address": "THPA5L2jxGE84FHMieds212WH3sRX5Hi9t",
1890
+ "block_number": 82681537,
1891
+ "transaction_hash": "5afe38b1baa3538f6692da873b1480b99dc30af81400948daf38fce8ac336d1d"
1902
1892
  }
1903
1893
  }
1904
1894
  },
@@ -1 +1 @@
1
- {"abi":[{"type":"function","name":"handleV3AcrossMessage","inputs":[{"name":"tokenSent","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"relayer","type":"address","internalType":"address"},{"name":"message","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"}],"bytecode":"0x60808060405234601557610154908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c633a5be8cb14610025575f80fd5b346100c05760803660031901126100c05761003e6100d8565b506100476100fb565b5060643567ffffffffffffffff81116100c057366023820112156100c057806004013567ffffffffffffffff81116100c457601f8101601f19908116603f0116830167ffffffffffffffff8111848210176100c45760405280835236602482840101116100c0575f928160246020940184830137010152005b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100c057565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036100c05756fea264697066735822122032b5cad3b224b740b9bbc0a4125dce4280d93cccf959dd369258d68703564b2164736f6c634300081e0033"}
1
+ {"abi":[{"type":"function","name":"handleV3AcrossMessage","inputs":[{"name":"tokenSent","type":"address","internalType":"address"},{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"relayer","type":"address","internalType":"address"},{"name":"message","type":"bytes","internalType":"bytes"}],"outputs":[],"stateMutability":"nonpayable"}],"bytecode":"0x60808060405234601557610154908161001a8239f35b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c633a5be8cb14610025575f80fd5b346100c05760803660031901126100c05761003e6100d8565b506100476100fb565b5060643567ffffffffffffffff81116100c057366023820112156100c057806004013567ffffffffffffffff81116100c457601f8101601f19908116603f0116830167ffffffffffffffff8111848210176100c45760405280835236602482840101116100c0575f928160246020940184830137010152005b5f80fd5b634e487b7160e01b5f52604160045260245ffd5b6004359073ffffffffffffffffffffffffffffffffffffffff821682036100c057565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036100c05756fea2646970667358221220ef8049b741ca8fdac486ace45efd7ddfebc0ae9d8ebd87ed9ddd5035543ecd1464736f6c634300081e0033"}