@across-protocol/contracts 5.0.26 → 5.0.27
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 +4 -0
- package/contracts/chain-adapters/CrossDomainEnabled.sol +1 -1
- package/contracts/external/interfaces/IAcrossV5Executor.sol +14 -0
- package/contracts/external/interfaces/IAcrossV5ExecutorAdapter.sol +14 -0
- package/contracts/external/interfaces/IGateway.sol +25 -0
- package/contracts/interfaces/ICounterfactualBeacon.sol +25 -16
- package/contracts/interfaces/ICounterfactualBeaconBase.sol +30 -0
- package/contracts/interfaces/ICounterfactualDeposit.sol +30 -0
- package/contracts/interfaces/ICounterfactualDepositFactory.sol +33 -54
- package/contracts/interfaces/SpokePoolPeripheryInterface.sol +16 -4
- package/contracts/interfaces/V5SpokePoolInterface.sol +71 -0
- package/contracts/libraries/HyperCoreLib.sol +114 -30
- package/contracts/libraries/PeripherySigningLib.sol +56 -0
- package/contracts/libraries/SafeTransferERC20.sol +4 -0
- package/contracts/periphery/SpokePoolPeriphery.sol +81 -19
- package/contracts/periphery/Tron_SpokePoolPeriphery.sol +52 -0
- package/contracts/periphery/counterfactual/AdminWithdrawManager.sol +12 -4
- package/contracts/periphery/counterfactual/CounterfactualBeacon.sol +28 -1
- package/contracts/periphery/counterfactual/CounterfactualBeaconBase.sol +11 -11
- package/contracts/periphery/counterfactual/CounterfactualDeposit.sol +6 -16
- package/contracts/periphery/counterfactual/CounterfactualDepositCCTP.sol +9 -5
- package/contracts/periphery/counterfactual/CounterfactualDepositFactory.sol +3 -5
- package/contracts/periphery/counterfactual/CounterfactualDepositOFT.sol +6 -3
- package/contracts/periphery/counterfactual/CounterfactualDepositSpokePool.sol +24 -8
- package/contracts/periphery/counterfactual/CounterfactualDepositVanillaCCTP.sol +28 -12
- package/contracts/periphery/counterfactual/CounterfactualImplementationBase.sol +8 -7
- package/contracts/periphery/counterfactual/CounterfactualNonces.sol +52 -0
- package/contracts/periphery/mintburn/HyperCoreFlowExecutor.sol +7 -1
- package/contracts/periphery/mintburn/SwapHandler.sol +8 -7
- package/contracts/spoke-pools/Arbitrum_SpokePool.sol +10 -2
- package/contracts/spoke-pools/Cher_SpokePool.sol +4 -2
- package/contracts/spoke-pools/Ethereum_SpokePool.sol +4 -2
- package/contracts/spoke-pools/Lens_SpokePool.sol +7 -2
- package/contracts/spoke-pools/Linea_SpokePool.sol +4 -2
- package/contracts/spoke-pools/Lisk_SpokePool.sol +4 -2
- package/contracts/spoke-pools/OP_SpokePool.sol +4 -2
- package/contracts/spoke-pools/Ovm_SpokePool.sol +7 -5
- package/contracts/spoke-pools/Polygon_SpokePool.sol +10 -2
- package/contracts/spoke-pools/SpokePool.sol +181 -25
- package/contracts/spoke-pools/Tron_SpokePool.sol +4 -2
- package/contracts/spoke-pools/Universal_SpokePool.sol +10 -2
- package/contracts/spoke-pools/ZkSync_SpokePool.sol +7 -2
- package/contracts/test/MockGateway.sol +33 -0
- package/contracts/test/MockSpokePool.sol +4 -1
- package/contracts/test/MockSpokePoolV2.sol +1 -1
- package/contracts/tron/TronCounterfactualImports.sol +2 -0
- package/contracts/tron/TronPeripheryImports.sol +5 -2
- package/dist/broadcast/deployed-addresses.json +606 -447
- package/dist/evm/artifacts/AcrossConfigStore.sol/AcrossConfigStore.json +1 -1
- package/dist/evm/artifacts/AcrossEventEmitter.sol/AcrossEventEmitter.json +1 -1
- package/dist/evm/artifacts/AcrossMerkleDistributor.sol/AcrossMerkleDistributor.json +1 -1
- package/dist/evm/artifacts/AcrossMessageHandlerMock.sol/AcrossMessageHandlerMock.json +1 -1
- package/dist/evm/artifacts/AdapterStore.sol/AdapterStore.json +1 -1
- package/dist/evm/artifacts/AdapterStore.sol/MessengerTypes.json +1 -1
- package/dist/evm/artifacts/Address.sol/Address.json +1 -1
- package/dist/evm/artifacts/AddressConverters.sol/Bytes32ToAddress.json +1 -1
- package/dist/evm/artifacts/AdminRelayTokensAdapter.sol/AdminRelayTokensAdapter.json +1 -1
- package/dist/evm/artifacts/AdminWithdrawManager.sol/AdminWithdrawManager.json +1 -1
- package/dist/evm/artifacts/ArbitrumMocks.sol/ArbitrumMockErc20GatewayRouter.json +1 -1
- package/dist/evm/artifacts/ArbitrumMocks.sol/Inbox.json +1 -1
- package/dist/evm/artifacts/ArbitrumMocks.sol/L2GatewayRouter.json +1 -1
- package/dist/evm/artifacts/Arbitrum_Adapter.sol/Arbitrum_Adapter.json +1 -1
- package/dist/evm/artifacts/Arbitrum_CustomGasToken_Adapter.sol/Arbitrum_CustomGasToken_Adapter.json +1 -1
- package/dist/evm/artifacts/Arbitrum_Forwarder.sol/Arbitrum_Forwarder.json +1 -1
- package/dist/evm/artifacts/Arbitrum_RescueAdapter.sol/Arbitrum_RescueAdapter.json +1 -1
- package/dist/evm/artifacts/Arbitrum_SendTokensAdapter.sol/Arbitrum_SendTokensAdapter.json +1 -1
- package/dist/evm/artifacts/Arbitrum_SpokePool.sol/Arbitrum_SpokePool.json +1 -1
- package/dist/evm/artifacts/Arbitrum_WithdrawalHelper.sol/Arbitrum_WithdrawalHelper.json +1 -1
- package/dist/evm/artifacts/Base_Adapter.sol/Base_Adapter.json +1 -1
- package/dist/evm/artifacts/BeaconProxy.sol/BeaconProxy.json +1 -1
- package/dist/evm/artifacts/BondToken.sol/BondToken.json +1 -1
- package/dist/evm/artifacts/BytesLib.sol/BytesLib.json +1 -1
- package/dist/evm/artifacts/Cher_SpokePool.sol/Cher_SpokePool.json +1 -1
- package/dist/evm/artifacts/CircleCCTPAdapter.sol/CircleDomainIds.json +1 -1
- package/dist/evm/artifacts/Constants.sol/Constants.json +1 -1
- package/dist/evm/artifacts/Constants.sol/OptimisticOracleConstraints.json +1 -1
- package/dist/evm/artifacts/Constants.sol/OracleInterfaces.json +1 -1
- package/dist/evm/artifacts/CoreExecution.sol/CoreExecution.json +1 -1
- package/dist/evm/artifacts/CoreSimulatorLib.sol/HypeSystemContract.json +1 -1
- package/dist/evm/artifacts/CoreState.sol/CoreState.json +1 -1
- package/dist/evm/artifacts/CoreView.sol/CoreView.json +1 -1
- package/dist/evm/artifacts/CoreWriterLib.sol/CoreWriterLib.json +1 -1
- package/dist/evm/artifacts/CoreWriterSim.sol/CoreWriterSim.json +1 -1
- package/dist/evm/artifacts/CounterfactualBeacon.sol/CounterfactualBeacon.json +1 -1
- package/dist/evm/artifacts/CounterfactualBeaconBase.sol/CounterfactualBeaconBase.json +1 -1
- package/dist/evm/artifacts/CounterfactualBeaconBootstrap.sol/CounterfactualBeaconBootstrap.json +1 -1
- package/dist/evm/artifacts/CounterfactualConfig.sol/CounterfactualConfig.json +1 -1
- package/dist/evm/artifacts/CounterfactualDeposit.sol/CounterfactualDeposit.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositCCTP.sol/CounterfactualDepositCCTP.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositFactory.sol/CounterfactualDepositFactory.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositFactoryTron.sol/CounterfactualDepositFactoryTron.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositOFT.sol/CounterfactualDepositOFT.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositSpokePool.sol/CounterfactualDepositSpokePool.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositSpokePoolTr.sol/CounterfactualDepositSpokePoolTr.json +1 -1
- package/dist/evm/artifacts/CounterfactualDepositVanillaCCTP.sol/CounterfactualDepositVanillaCCTP.json +1 -1
- package/dist/evm/artifacts/CounterfactualNonces.sol/CounterfactualNonces.json +1 -0
- package/dist/evm/artifacts/Create2.sol/Create2.json +1 -1
- package/dist/evm/artifacts/CrossDomainEnabled.sol/CrossDomainEnabled.json +1 -1
- package/dist/evm/artifacts/DeployedAddresses.sol/DeployedAddresses.json +1 -1
- package/dist/evm/artifacts/DeploymentUtils.sol/DeploymentUtils.json +1 -1
- package/dist/evm/artifacts/DoctorWho_Adapter.sol/DoctorWho_Adapter.json +1 -1
- package/dist/evm/artifacts/DonationBox.sol/DonationBox.json +1 -1
- package/dist/evm/artifacts/DstOFTHandler.sol/DstOFTHandler.json +1 -1
- package/dist/evm/artifacts/ECDSA.sol/ECDSA.json +1 -1
- package/dist/evm/artifacts/ERC1155.sol/ERC1155.json +1 -1
- package/dist/evm/artifacts/ERC1967Proxy.sol/ERC1967Proxy.json +1 -1
- package/dist/evm/artifacts/ERC1967Utils.sol/ERC1967Utils.json +1 -1
- package/dist/evm/artifacts/ERC20.sol/ERC20.json +1 -1
- package/dist/evm/artifacts/Errors.sol/Errors.json +1 -1
- package/dist/evm/artifacts/Ethereum_Adapter.sol/Ethereum_Adapter.json +1 -1
- package/dist/evm/artifacts/Ethereum_RescueAdapter.sol/Ethereum_RescueAdapter.json +1 -1
- package/dist/evm/artifacts/Ethereum_SpokePool.sol/Ethereum_SpokePool.json +1 -1
- package/dist/evm/artifacts/ExpandedERC20.sol/ExpandedERC20.json +1 -1
- package/dist/evm/artifacts/ExpandedERC20WithBlacklist.sol/ExpandedERC20WithBlacklist.json +1 -1
- package/dist/evm/artifacts/HLConstants.sol/HLConstants.json +1 -1
- package/dist/evm/artifacts/HLConversions.sol/HLConversions.json +1 -1
- package/dist/evm/artifacts/HubPool.sol/HubPool.json +1 -1
- package/dist/evm/artifacts/HubPoolStore.sol/HubPoolStore.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/HubPoolTestBase.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockAddressWhitelist.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockFinder.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockIdentifierWhitelist.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockLpTokenFactory.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockOptimisticOracle.json +1 -1
- package/dist/evm/artifacts/HubPoolTestBase.sol/MockStore.json +1 -1
- package/dist/evm/artifacts/HyperCore.sol/HyperCore.json +1 -1
- package/dist/evm/artifacts/HyperCoreFlowExecutor.sol/HyperCoreFlowExecutor.json +1 -1
- package/dist/evm/artifacts/HyperCoreLib.sol/HyperCoreLib.json +1 -1
- package/dist/evm/artifacts/HyperliquidDepositHandler.sol/HyperliquidDepositHandler.json +1 -1
- package/dist/evm/artifacts/IAcrossV5Executor.sol/IAcrossV5Executor.json +1 -0
- package/dist/evm/artifacts/IAcrossV5ExecutorAdapter.sol/IAcrossV5ExecutorAdapter.json +1 -0
- package/dist/evm/artifacts/ICounterfactualBeacon.sol/ICounterfactualBeacon.json +1 -1
- package/dist/evm/artifacts/ICounterfactualBeaconBase.sol/ICounterfactualBeaconBase.json +1 -0
- package/dist/evm/artifacts/ICounterfactualDeposit.sol/ICounterfactualDeposit.json +1 -1
- package/dist/evm/artifacts/ICounterfactualDepositFactory.sol/ICounterfactualDepositFactory.json +1 -1
- package/dist/evm/artifacts/IGateway.sol/IGateway.json +1 -0
- package/dist/evm/artifacts/Lens_SpokePool.sol/Lens_SpokePool.json +1 -1
- package/dist/evm/artifacts/LibVariable.sol/LibVariable.json +1 -1
- package/dist/evm/artifacts/LineaMocks.sol/MockL2MessageService.json +1 -1
- package/dist/evm/artifacts/LineaMocks.sol/MockL2TokenBridge.json +1 -1
- package/dist/evm/artifacts/Linea_Adapter.sol/Linea_Adapter.json +1 -1
- package/dist/evm/artifacts/Linea_SpokePool.sol/Linea_SpokePool.json +1 -1
- package/dist/evm/artifacts/Lisk_Adapter.sol/Lisk_Adapter.json +1 -1
- package/dist/evm/artifacts/Lisk_SpokePool.sol/Lisk_SpokePool.json +1 -1
- package/dist/evm/artifacts/Lockable.sol/Lockable.json +1 -1
- package/dist/evm/artifacts/LpTokenFactory.sol/LpTokenFactory.json +1 -1
- package/dist/evm/artifacts/Merkle.sol/Merkle.json +1 -1
- package/dist/evm/artifacts/MerkleDistributor.sol/MerkleDistributor.json +1 -1
- package/dist/evm/artifacts/MerkleLibTest.sol/MerkleLibTest.json +1 -1
- package/dist/evm/artifacts/MerkleProof.sol/MerkleProof.json +1 -1
- package/dist/evm/artifacts/MinimalLZOptions.sol/MinimalLZOptions.json +1 -1
- package/dist/evm/artifacts/MintableERC1155.sol/MintableERC1155.json +1 -1
- package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockCrossDomainMessenger.json +1 -1
- package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockL1StandardBridge.json +1 -1
- package/dist/evm/artifacts/MockBedrockStandardBridge.sol/MockBedrockL2StandardBridge.json +1 -1
- package/dist/evm/artifacts/MockCCTP.sol/MockCCTPMessageTransmitter.json +1 -1
- package/dist/evm/artifacts/MockCCTP.sol/MockCCTPMessenger.json +1 -1
- package/dist/evm/artifacts/MockCCTP.sol/MockCCTPMessengerV2.json +1 -1
- package/dist/evm/artifacts/MockCCTP.sol/MockCCTPMinter.json +1 -1
- package/dist/evm/artifacts/MockCaller.sol/MockCaller.json +1 -1
- package/dist/evm/artifacts/MockERC1271.sol/MockERC1271.json +1 -1
- package/dist/evm/artifacts/MockERC20.sol/MintableERC20.json +1 -1
- package/dist/evm/artifacts/MockERC20.sol/MockERC20.json +1 -1
- package/dist/evm/artifacts/MockEndpoint.sol/MockEndpoint.json +1 -1
- package/dist/evm/artifacts/MockGateway.sol/MockGateway.json +1 -0
- package/dist/evm/artifacts/MockHubPool.sol/MockHubPool.json +1 -1
- package/dist/evm/artifacts/MockOFTMessenger.sol/MockOFTMessenger.json +1 -1
- package/dist/evm/artifacts/MockPermit2.sol/MockPermit2.json +1 -1
- package/dist/evm/artifacts/MockPermit2.sol/Permit2EIP712.json +1 -1
- package/dist/evm/artifacts/MockPermit2.sol/SignatureVerification.json +1 -1
- package/dist/evm/artifacts/MockSpokePool.sol/MockSpokePool.json +1 -1
- package/dist/evm/artifacts/MockSpokePoolV2.sol/MockSpokePoolV2.json +1 -1
- package/dist/evm/artifacts/MockTronUSDT.sol/MockTronUSDT.json +1 -1
- package/dist/evm/artifacts/MockZkStackBridgeHub.sol/MockBridgeHub.json +1 -1
- package/dist/evm/artifacts/Mock_Adapter.sol/Mock_Adapter.json +1 -1
- package/dist/evm/artifacts/Mock_Adapter.sol/Mock_Bridge.json +1 -1
- package/dist/evm/artifacts/Mode_Adapter.sol/Mode_Adapter.json +1 -1
- package/dist/evm/artifacts/MultiCaller.sol/MultiCaller.json +1 -1
- package/dist/evm/artifacts/MultiCallerUpgradeable.sol/MultiCallerUpgradeable.json +1 -1
- package/dist/evm/artifacts/Multicall3.sol/Multicall3.json +1 -1
- package/dist/evm/artifacts/MulticallHandler.sol/MulticallHandler.json +1 -1
- package/dist/evm/artifacts/OFTTransportAdapter.sol/OFTTransportAdapter.json +1 -1
- package/dist/evm/artifacts/OFTTransportAdapterWithStore.sol/OFTTransportAdapterWithStore.json +1 -1
- package/dist/evm/artifacts/OP_Adapter.sol/OP_Adapter.json +1 -1
- package/dist/evm/artifacts/OP_SpokePool.sol/OP_SpokePool.json +1 -1
- package/dist/evm/artifacts/Ovm_Forwarder.sol/Ovm_Forwarder.json +1 -1
- package/dist/evm/artifacts/Ovm_SpokePool.sol/Ovm_SpokePool.json +1 -1
- package/dist/evm/artifacts/Ovm_WithdrawalHelper.sol/Ovm_WithdrawalHelper.json +1 -1
- package/dist/evm/artifacts/PeripherySigningLib.sol/PeripherySigningLib.json +1 -1
- package/dist/evm/artifacts/PermissionedMulticallHandler.sol/PermissionedMulticallHandler.json +1 -1
- package/dist/evm/artifacts/PolygonERC20Test.sol/PolygonERC20Test.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/DepositManagerMock.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/FxStateSenderMock.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/PolygonERC20Mock.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/PolygonERC20PredicateMock.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/PolygonRegistryMock.json +1 -1
- package/dist/evm/artifacts/PolygonMocks.sol/RootChainManagerMock.json +1 -1
- package/dist/evm/artifacts/PolygonTokenBridger.sol/PolygonTokenBridger.json +1 -1
- package/dist/evm/artifacts/Polygon_Adapter.sol/Polygon_Adapter.json +1 -1
- package/dist/evm/artifacts/Polygon_SpokePool.sol/Polygon_SpokePool.json +1 -1
- package/dist/evm/artifacts/PrecompileLib.sol/PrecompileLib.json +1 -1
- package/dist/evm/artifacts/PrecompileSim.sol/PrecompileSim.json +1 -1
- package/dist/evm/artifacts/ProxyAdmin.sol/ProxyAdmin.json +1 -1
- package/dist/evm/artifacts/Router_Adapter.sol/Router_Adapter.json +1 -1
- package/dist/evm/artifacts/SP1AutoVerifier.sol/SP1AutoVerifier.json +1 -1
- package/dist/evm/artifacts/SP1Helios.sol/SP1Helios.json +1 -1
- package/dist/evm/artifacts/SP1MockVerifier.sol/SP1MockVerifier.json +1 -1
- package/dist/evm/artifacts/SafeCast.sol/SafeCast.json +1 -1
- package/dist/evm/artifacts/SafeERC20.sol/SafeERC20.json +1 -1
- package/dist/evm/artifacts/ShortStrings.sol/ShortStrings.json +1 -1
- package/dist/evm/artifacts/Solana_Adapter.sol/Solana_Adapter.json +1 -1
- package/dist/evm/artifacts/SpokePool.sol/SpokePool.json +1 -1
- package/dist/evm/artifacts/SpokePoolPeriphery.sol/SpokePoolPeriphery.json +1 -1
- package/dist/evm/artifacts/SpokePoolPeriphery.sol/SwapProxy.json +1 -1
- package/dist/evm/artifacts/SpokePoolVerifier.sol/SpokePoolVerifier.json +1 -1
- package/dist/evm/artifacts/SponsoredCCTPDstPeriphery.sol/SponsoredCCTPDstPeriphery.json +1 -1
- package/dist/evm/artifacts/SponsoredCCTPSrcPeriphery.sol/SponsoredCCTPSrcPeriphery.json +1 -1
- package/dist/evm/artifacts/SponsoredOFTSrcPeriphery.sol/SponsoredOFTSrcPeriphery.json +1 -1
- package/dist/evm/artifacts/StdConfig.sol/StdConfig.json +1 -1
- package/dist/evm/artifacts/Strings.sol/Strings.json +1 -1
- package/dist/evm/artifacts/SwapHandler.sol/SwapHandler.json +1 -1
- package/dist/evm/artifacts/Timer.sol/Timer.json +1 -1
- package/dist/evm/artifacts/TransferProxy.sol/TransferProxy.json +1 -1
- package/dist/evm/artifacts/TransparentUpgradeableProxy.sol/TransparentUpgradeableProxy.json +1 -1
- package/dist/evm/artifacts/TronMulticallHandler.sol/TronMulticallHandler.json +1 -1
- package/dist/evm/artifacts/TronTransferLib.sol/TronTransferLib.json +1 -1
- package/dist/evm/artifacts/Tron_SpokePool.sol/Tron_SpokePool.json +1 -1
- package/dist/evm/artifacts/Tron_SpokePoolPeriphery.sol/Tron_SpokePoolPeriphery.json +1 -0
- package/dist/evm/artifacts/Tron_SpokePoolPeriphery.sol/Tron_SwapProxy.json +1 -0
- package/dist/evm/artifacts/Universal_Adapter.sol/Universal_Adapter.json +1 -1
- package/dist/evm/artifacts/Universal_SpokePool.sol/Universal_SpokePool.json +1 -1
- package/dist/evm/artifacts/UpgradeableBeacon.sol/UpgradeableBeacon.json +1 -1
- package/dist/evm/artifacts/V5SpokePoolInterface.sol/V5SpokePoolInterface.json +1 -0
- package/dist/evm/artifacts/WETH9.sol/WETH9.json +1 -1
- package/dist/evm/artifacts/WithdrawImplementation.sol/WithdrawImplementation.json +1 -1
- package/dist/evm/artifacts/WithdrawImplementationTron.sol/WithdrawImplementationTron.json +1 -1
- package/dist/evm/artifacts/ZkStack_Adapter.sol/ZkStack_Adapter.json +1 -1
- package/dist/evm/artifacts/ZkStack_CustomGasToken_Adapter.sol/ZkStack_CustomGasToken_Adapter.json +1 -1
- package/dist/evm/artifacts/ZkSyncMocks.sol/MockL2Eth.json +1 -1
- package/dist/evm/artifacts/ZkSyncMocks.sol/MockZkBridge.json +1 -1
- package/dist/evm/artifacts/ZkSync_SpokePool.sol/ZkSync_SpokePool.json +1 -1
- package/dist/evm/artifacts/Zora_Adapter.sol/Zora_Adapter.json +1 -1
- package/dist/evm/artifacts/eraVM_EIP7702.sol/SimpleContract.json +1 -1
- package/dist/evm/artifacts/eraVM_EIP7702.sol/SpokePoolEIP7702Test.json +1 -1
- package/dist/evm/artifacts/eraVM_EIP7702.sol/TestableMockSpokePool.json +1 -1
- package/dist/src/consts.d.ts +2 -0
- package/dist/src/consts.js +18 -47
- package/dist/src/svm/assets/idl/svm_spoke.json +9 -4
- package/dist/src/svm/assets/svm_spoke.d.ts +9 -4
- package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.d.ts +3 -1
- package/dist/src/svm/clients/SvmSpoke/errors/svmSpoke.js +4 -1
- package/dist/src/types/svm.d.ts +44 -0
- package/dist/target/types/svm_spoke.d.ts +9 -4
- package/package.json +12 -6
- package/contracts/chain-adapters/Blast_Adapter.sol +0 -127
- package/contracts/chain-adapters/Blast_RescueAdapter.sol +0 -47
- package/contracts/chain-adapters/Boba_Adapter.sol +0 -78
- package/contracts/chain-adapters/Optimism_Adapter.sol +0 -118
- package/contracts/chain-adapters/PolygonZkEVM_Adapter.sol +0 -75
- package/contracts/chain-adapters/Scroll_Adapter.sol +0 -144
- package/contracts/external/interfaces/IPolygonZkEVMBridge.sol +0 -40
- package/contracts/hub-pool/Blast_DaiRetriever.sol +0 -59
- package/contracts/hub-pool/PermissionSplitterProxy.sol +0 -128
- package/contracts/spoke-pools/Blast_SpokePool.sol +0 -161
- package/contracts/spoke-pools/Boba_SpokePool.sol +0 -45
- package/contracts/spoke-pools/Ink_SpokePool.sol +0 -72
- package/contracts/spoke-pools/Optimism_SpokePool.sol +0 -66
- package/contracts/spoke-pools/PolygonZkEVM_SpokePool.sol +0 -217
- package/contracts/spoke-pools/Scroll_SpokePool.sol +0 -153
- package/contracts/spoke-pools/WorldChain_SpokePool.sol +0 -72
- package/contracts/test/MockBlastUsdYieldManager.sol +0 -20
- package/contracts/test/MockOptimism_SpokePool.sol +0 -22
- package/contracts/test/PolygonZkEVMMocks.sol +0 -72
- package/contracts/test/ScrollMocks.sol +0 -109
- package/dist/evm/artifacts/Blast_Adapter.sol/Blast_Adapter.json +0 -1
- package/dist/evm/artifacts/Blast_Adapter.sol/IL1ERC20Bridge.json +0 -1
- package/dist/evm/artifacts/Blast_DaiRetriever.sol/Blast_DaiRetriever.json +0 -1
- package/dist/evm/artifacts/Blast_DaiRetriever.sol/USDYieldManager.json +0 -1
- package/dist/evm/artifacts/Blast_RescueAdapter.sol/Blast_RescueAdapter.json +0 -1
- package/dist/evm/artifacts/Blast_SpokePool.sol/Blast_SpokePool.json +0 -1
- package/dist/evm/artifacts/Blast_SpokePool.sol/IBlast.json +0 -1
- package/dist/evm/artifacts/Blast_SpokePool.sol/IERC20Rebasing.json +0 -1
- package/dist/evm/artifacts/Blast_SpokePool.sol/IUSDBL2Bridge.json +0 -1
- package/dist/evm/artifacts/Boba_Adapter.sol/Boba_Adapter.json +0 -1
- package/dist/evm/artifacts/Boba_SpokePool.sol/Boba_SpokePool.json +0 -1
- package/dist/evm/artifacts/IL1ERC20Gateway.sol/IL1ERC20Gateway.json +0 -1
- package/dist/evm/artifacts/IL1ETHGateway.sol/IL1ETHGateway.json +0 -1
- package/dist/evm/artifacts/IL1GatewayRouter.sol/IL1GatewayRouter.json +0 -1
- package/dist/evm/artifacts/IL1ScrollMessenger.sol/IL1ScrollMessenger.json +0 -1
- package/dist/evm/artifacts/IL2ERC20Gateway.sol/IL2ERC20Gateway.json +0 -1
- package/dist/evm/artifacts/IL2ETHGateway.sol/IL2ETHGateway.json +0 -1
- package/dist/evm/artifacts/IL2GasPriceOracle.sol/IL2GasPriceOracle.json +0 -1
- package/dist/evm/artifacts/IL2GatewayRouter.sol/IL2GatewayRouter.json +0 -1
- package/dist/evm/artifacts/IPolygonZkEVMBridge.sol/IPolygonZkEVMBridge.json +0 -1
- package/dist/evm/artifacts/IScrollMessenger.sol/IScrollMessenger.json +0 -1
- package/dist/evm/artifacts/Ink_SpokePool.sol/Ink_SpokePool.json +0 -1
- package/dist/evm/artifacts/MockBlastUsdYieldManager.sol/MockBlastUsdYieldManager.json +0 -1
- package/dist/evm/artifacts/MockOptimism_SpokePool.sol/MockOptimism_SpokePool.json +0 -1
- package/dist/evm/artifacts/Optimism_Adapter.sol/Optimism_Adapter.json +0 -1
- package/dist/evm/artifacts/Optimism_Adapter.sol/SynthetixBridgeToOptimism.json +0 -1
- package/dist/evm/artifacts/Optimism_SpokePool.sol/Optimism_SpokePool.json +0 -1
- package/dist/evm/artifacts/Optimism_SpokePool.sol/SynthetixBridgeToBase.json +0 -1
- package/dist/evm/artifacts/PermissionSplitterProxy.sol/PermissionSplitterProxy.json +0 -1
- package/dist/evm/artifacts/PolygonZkEVMMocks.sol/MockPolygonZkEVMBridge.json +0 -1
- package/dist/evm/artifacts/PolygonZkEVM_Adapter.sol/PolygonZkEVM_Adapter.json +0 -1
- package/dist/evm/artifacts/PolygonZkEVM_SpokePool.sol/IBridgeMessageReceiver.json +0 -1
- package/dist/evm/artifacts/PolygonZkEVM_SpokePool.sol/PolygonZkEVM_SpokePool.json +0 -1
- package/dist/evm/artifacts/ScrollMocks.sol/MockScrollL2GatewayRouter.json +0 -1
- package/dist/evm/artifacts/ScrollMocks.sol/MockScrollMessenger.json +0 -1
- package/dist/evm/artifacts/Scroll_Adapter.sol/Scroll_Adapter.json +0 -1
- package/dist/evm/artifacts/Scroll_SpokePool.sol/IL2GatewayRouterExtended.json +0 -1
- package/dist/evm/artifacts/Scroll_SpokePool.sol/Scroll_SpokePool.json +0 -1
- package/dist/evm/artifacts/WorldChain_SpokePool.sol/WorldChain_SpokePool.json +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
pragma solidity ^0.8.0;
|
|
3
3
|
|
|
4
|
-
import { IERC20 } from "@openzeppelin/contracts
|
|
5
|
-
import { SafeERC20 } from "@openzeppelin/contracts
|
|
6
|
-
import { SafeCast } from "@openzeppelin/contracts
|
|
4
|
+
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
|
|
5
|
+
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
|
|
6
|
+
import { SafeCast } from "@openzeppelin/contracts/utils/math/SafeCast.sol";
|
|
7
7
|
import { ICoreDepositWallet } from "../external/interfaces/ICoreDepositWallet.sol";
|
|
8
8
|
|
|
9
9
|
interface ICoreWriter {
|
|
@@ -53,10 +53,23 @@ library HyperCoreLib {
|
|
|
53
53
|
address public constant TOKEN_INFO_PRECOMPILE_ADDRESS = 0x000000000000000000000000000000000000080C;
|
|
54
54
|
address public constant CORE_WRITER_PRECOMPILE_ADDRESS = 0x3333333333333333333333333333333333333333;
|
|
55
55
|
|
|
56
|
-
// USDC
|
|
56
|
+
// USDC. Circle's CoreDepositWallet is deployed at a different address on mainnet and testnet.
|
|
57
57
|
address public constant USDC_CORE_DEPOSIT_WALLET_ADDRESS = 0x6B9E773128f453f5c2C60935Ee2DE2CBc5390A24;
|
|
58
|
+
address public constant USDC_CORE_DEPOSIT_WALLET_ADDRESS_TESTNET = 0x0B80659a4076E9E93C7DbE0f10675A16a3e5C206;
|
|
58
59
|
uint64 public constant USDC_CORE_INDEX = 0;
|
|
59
60
|
|
|
61
|
+
// Native HYPE. Unlike every other token, HYPE bridges through a fixed system address rather than one
|
|
62
|
+
// derived from its Core index, and that index differs between mainnet and testnet.
|
|
63
|
+
address public constant HYPE_SYSTEM_ADDRESS = 0x2222222222222222222222222222222222222222;
|
|
64
|
+
uint32 public constant HYPE_CORE_INDEX = 150;
|
|
65
|
+
uint32 public constant HYPE_CORE_INDEX_TESTNET = 1105;
|
|
66
|
+
// HYPE has 18 decimals on HyperEVM and 8 on HyperCore, so only EVM amounts aligned to 1e10 wei are representable
|
|
67
|
+
int8 public constant HYPE_DECIMAL_DIFF = 10;
|
|
68
|
+
|
|
69
|
+
// HyperEVM chain ids. The precompiles and CoreWriter below only exist on these chains.
|
|
70
|
+
uint256 public constant HYPEREVM_CHAIN_ID = 999;
|
|
71
|
+
uint256 public constant HYPEREVM_TESTNET_CHAIN_ID = 998;
|
|
72
|
+
|
|
60
73
|
// CoreWriter action headers
|
|
61
74
|
bytes4 public constant LIMIT_ORDER_HEADER = 0x01000001; // version=1, action=1
|
|
62
75
|
bytes4 public constant SPOT_SEND_HEADER = 0x01000006; // version=1, action=6
|
|
@@ -75,7 +88,9 @@ library HyperCoreLib {
|
|
|
75
88
|
error TokenInfoPrecompileCallFailed();
|
|
76
89
|
error SpotPxPrecompileCallFailed();
|
|
77
90
|
error InsufficientAmountForAccountActivation();
|
|
78
|
-
error
|
|
91
|
+
error TokenNotBridgeable(uint64 erc20CoreIndex);
|
|
92
|
+
error NativeTransferFailed();
|
|
93
|
+
error UnsupportedChain();
|
|
79
94
|
|
|
80
95
|
/**
|
|
81
96
|
* @notice Transfer `amountEVM` from HyperEVM to `to` on HyperCore.
|
|
@@ -106,18 +121,15 @@ library HyperCoreLib {
|
|
|
106
121
|
if (_amountEVMToSend != 0) {
|
|
107
122
|
if (erc20CoreIndex == USDC_CORE_INDEX) {
|
|
108
123
|
// USDC flow takes care of account creation fee for us, we don't need to reduce `_amountEVMToSend`
|
|
109
|
-
|
|
124
|
+
ICoreDepositWallet depositWallet = usdcCoreDepositWallet();
|
|
125
|
+
IERC20(erc20EVMAddress).forceApprove(address(depositWallet), _amountEVMToSend);
|
|
110
126
|
if (to == address(this)) {
|
|
111
|
-
|
|
127
|
+
depositWallet.deposit(_amountEVMToSend, destinationDex);
|
|
112
128
|
} else {
|
|
113
|
-
|
|
114
|
-
to,
|
|
115
|
-
_amountEVMToSend,
|
|
116
|
-
destinationDex
|
|
117
|
-
);
|
|
129
|
+
depositWallet.depositFor(to, _amountEVMToSend, destinationDex);
|
|
118
130
|
}
|
|
119
131
|
} else {
|
|
120
|
-
IERC20(erc20EVMAddress).safeTransfer(
|
|
132
|
+
IERC20(erc20EVMAddress).safeTransfer(toSystemAddress(erc20CoreIndex), _amountEVMToSend);
|
|
121
133
|
// Transfer the tokens from this contract on HyperCore to the `to` address on HyperCore
|
|
122
134
|
if (to != address(this) || destinationDex != CORE_SPOT_DEX_ID) {
|
|
123
135
|
transferERC20CoreToCore(
|
|
@@ -192,6 +204,25 @@ library HyperCoreLib {
|
|
|
192
204
|
);
|
|
193
205
|
}
|
|
194
206
|
|
|
207
|
+
/**
|
|
208
|
+
* @notice Bridges up to `amountEVM` of native HYPE from this address on HyperEVM to this address on HyperCore.
|
|
209
|
+
* @dev A native transfer to the HYPE system address credits the sender's spot HYPE on Core. Core only credits
|
|
210
|
+
* whole multiples of 1e10 wei and silently drops the remainder, so, like the ERC20 path, this rounds the
|
|
211
|
+
* amount down before sending and leaves the dust in the calling contract. Sends nothing if the aligned
|
|
212
|
+
* amount is zero.
|
|
213
|
+
* @param amountEVM The maximum amount of native HYPE to transfer, in EVM wei.
|
|
214
|
+
* @return amountEVMSent The amount actually sent on HyperEVM, in wei
|
|
215
|
+
* @return amountCoreToReceive The amount credited on Core, in Core units
|
|
216
|
+
*/
|
|
217
|
+
function transferNativeEVMToSelfOnSpot(
|
|
218
|
+
uint256 amountEVM
|
|
219
|
+
) internal returns (uint256 amountEVMSent, uint64 amountCoreToReceive) {
|
|
220
|
+
(amountEVMSent, amountCoreToReceive) = maximumEVMSendAmountToAmounts(amountEVM, HYPE_DECIMAL_DIFF);
|
|
221
|
+
if (amountEVMSent == 0) return (0, 0);
|
|
222
|
+
(bool success, ) = HYPE_SYSTEM_ADDRESS.call{ value: amountEVMSent }("");
|
|
223
|
+
if (!success) revert NativeTransferFailed();
|
|
224
|
+
}
|
|
225
|
+
|
|
195
226
|
/**
|
|
196
227
|
* @notice Transfers tokens from this contract on HyperCore to the `to` address on HyperCore on the Spot DEX.
|
|
197
228
|
* @param erc20CoreIndex The HyperCore index id of the token
|
|
@@ -245,10 +276,11 @@ library HyperCoreLib {
|
|
|
245
276
|
uint256 amountEVM
|
|
246
277
|
) internal {
|
|
247
278
|
if (erc20CoreIndex == USDC_CORE_INDEX) {
|
|
248
|
-
|
|
249
|
-
|
|
279
|
+
ICoreDepositWallet depositWallet = usdcCoreDepositWallet();
|
|
280
|
+
IERC20(erc20EVMAddress).forceApprove(address(depositWallet), amountEVM);
|
|
281
|
+
depositWallet.depositFor(user, amountEVM, CORE_SPOT_DEX_ID);
|
|
250
282
|
} else {
|
|
251
|
-
IERC20(erc20EVMAddress).safeTransfer(
|
|
283
|
+
IERC20(erc20EVMAddress).safeTransfer(toSystemAddress(erc20CoreIndex), amountEVM);
|
|
252
284
|
// Transfer 1 wei to user on HyperCore to activate account
|
|
253
285
|
transferERC20CoreToCore(erc20CoreIndex, user, 1, CORE_SPOT_DEX_ID, CORE_SPOT_DEX_ID);
|
|
254
286
|
}
|
|
@@ -353,6 +385,40 @@ library HyperCoreLib {
|
|
|
353
385
|
return _tokenInfo;
|
|
354
386
|
}
|
|
355
387
|
|
|
388
|
+
/**
|
|
389
|
+
* @notice Whether the current chain is HyperEVM (mainnet or testnet), and therefore whether the HyperCore
|
|
390
|
+
* precompiles and CoreWriter this library reads and writes actually exist.
|
|
391
|
+
* @return True on HyperEVM mainnet or testnet, false otherwise
|
|
392
|
+
*/
|
|
393
|
+
function isHyperEVMChain() internal view returns (bool) {
|
|
394
|
+
return block.chainid == HYPEREVM_CHAIN_ID || block.chainid == HYPEREVM_TESTNET_CHAIN_ID;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
/**
|
|
398
|
+
* @notice The Core index of native HYPE on the current chain.
|
|
399
|
+
* @dev Differs between mainnet and testnet, so it cannot be a plain constant at the call site. Reverts off
|
|
400
|
+
* HyperEVM rather than defaulting, since the index has no meaning there.
|
|
401
|
+
* @return The HyperCore index id of native HYPE
|
|
402
|
+
*/
|
|
403
|
+
function hypeCoreIndex() internal view returns (uint32) {
|
|
404
|
+
if (block.chainid == HYPEREVM_CHAIN_ID) return HYPE_CORE_INDEX;
|
|
405
|
+
if (block.chainid == HYPEREVM_TESTNET_CHAIN_ID) return HYPE_CORE_INDEX_TESTNET;
|
|
406
|
+
revert UnsupportedChain();
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* @notice Circle's USDC CoreDepositWallet on the current chain.
|
|
411
|
+
* @dev Differs between mainnet and testnet; the mainnet address has no code on testnet, so using it there
|
|
412
|
+
* would revert every USDC bridge and account activation. Reverts off HyperEVM rather than defaulting.
|
|
413
|
+
* @return The CoreDepositWallet to approve and deposit USDC through
|
|
414
|
+
*/
|
|
415
|
+
function usdcCoreDepositWallet() internal view returns (ICoreDepositWallet) {
|
|
416
|
+
if (block.chainid == HYPEREVM_CHAIN_ID) return ICoreDepositWallet(USDC_CORE_DEPOSIT_WALLET_ADDRESS);
|
|
417
|
+
if (block.chainid == HYPEREVM_TESTNET_CHAIN_ID)
|
|
418
|
+
return ICoreDepositWallet(USDC_CORE_DEPOSIT_WALLET_ADDRESS_TESTNET);
|
|
419
|
+
revert UnsupportedChain();
|
|
420
|
+
}
|
|
421
|
+
|
|
356
422
|
/**
|
|
357
423
|
* @notice Checks if an amount is safe to bridge from HyperEVM to HyperCore
|
|
358
424
|
* @dev Verifies that the asset bridge has sufficient balance to cover the amount plus a buffer
|
|
@@ -366,29 +432,47 @@ library HyperCoreLib {
|
|
|
366
432
|
uint64 coreAmount,
|
|
367
433
|
uint64 coreBufferAmount
|
|
368
434
|
) internal view returns (bool) {
|
|
369
|
-
|
|
370
|
-
|
|
435
|
+
// A predicate answers rather than reverts: an unbridgeable token is simply not safe to bridge, so the fill
|
|
436
|
+
// path keeps its HyperEVM fallback instead of failing.
|
|
437
|
+
(address systemAddress, bool bridgeable) = tryToSystemAddress(erc20CoreIndex);
|
|
438
|
+
if (!bridgeable) return false;
|
|
371
439
|
|
|
372
440
|
// Return true if currentBridgeBalance >= coreAmount + coreBufferAmount
|
|
373
|
-
return
|
|
441
|
+
return spotBalance(systemAddress, erc20CoreIndex) >= coreAmount + coreBufferAmount;
|
|
374
442
|
}
|
|
375
443
|
|
|
376
444
|
/**
|
|
377
|
-
* @notice
|
|
445
|
+
* @notice Resolves a core index id to its system address, the bridge account shared by both chains. On HyperEVM,
|
|
446
|
+
* a transfer to it credits the sender's spot balance on HyperCore; on HyperCore, a spot send to it
|
|
447
|
+
* credits the sender's balance on HyperEVM.
|
|
448
|
+
* @dev Reverts if the token is not bridgeable, since a send to such an address would strand the funds. For a
|
|
449
|
+
* non-reverting answer, use `tryToSystemAddress`.
|
|
378
450
|
* @param erc20CoreIndex The core token index id to convert
|
|
379
|
-
* @return
|
|
451
|
+
* @return The token's system address, valid as a destination on either chain
|
|
380
452
|
*/
|
|
381
|
-
function
|
|
382
|
-
|
|
453
|
+
function toSystemAddress(uint64 erc20CoreIndex) internal view returns (address) {
|
|
454
|
+
(address systemAddress, bool bridgeable) = tryToSystemAddress(erc20CoreIndex);
|
|
455
|
+
if (!bridgeable) revert TokenNotBridgeable(erc20CoreIndex);
|
|
456
|
+
return systemAddress;
|
|
383
457
|
}
|
|
384
458
|
|
|
385
459
|
/**
|
|
386
|
-
* @notice
|
|
387
|
-
* @
|
|
388
|
-
*
|
|
460
|
+
* @notice `toSystemAddress` that reports bridgeability instead of reverting on it.
|
|
461
|
+
* @dev Native HYPE uses a fixed system address and is always bridgeable; every other token derives one from
|
|
462
|
+
* its Core index and is bridgeable only if linked to a HyperEVM contract. Still reverts if the tokenInfo
|
|
463
|
+
* precompile call itself fails, like every other precompile read in this library.
|
|
464
|
+
* @param erc20CoreIndex The core token index id to convert
|
|
465
|
+
* @return systemAddress The token's system address, valid as a destination on either chain
|
|
466
|
+
* @return bridgeable False if a send to `systemAddress` would not be credited on the other side
|
|
389
467
|
*/
|
|
390
|
-
function
|
|
391
|
-
|
|
468
|
+
function tryToSystemAddress(uint64 erc20CoreIndex) internal view returns (address systemAddress, bool bridgeable) {
|
|
469
|
+
// A uint64 above the uint32 domain can never equal the uint32 HYPE index, so no range check is needed
|
|
470
|
+
if (erc20CoreIndex == hypeCoreIndex()) return (HYPE_SYSTEM_ADDRESS, true);
|
|
471
|
+
systemAddress = address(uint160(BASE_ASSET_BRIDGE_ADDRESS_UINT256 + erc20CoreIndex));
|
|
472
|
+
// Only linked tokens convert between Core and EVM (docs: "HyperCore <> HyperEVM transfers"), and
|
|
473
|
+
// linkage resolves via tokenInfo, declared `tokenInfo(uint32)` in canonical L1Read.sol — an id
|
|
474
|
+
// beyond that domain (spotBalance's uint64 also carries encoded outcome asset ids) can't be resolved.
|
|
475
|
+
bridgeable = erc20CoreIndex <= type(uint32).max && tokenInfo(uint32(erc20CoreIndex)).evmContract != address(0);
|
|
392
476
|
}
|
|
393
477
|
|
|
394
478
|
/**
|
|
@@ -416,7 +500,7 @@ library HyperCoreLib {
|
|
|
416
500
|
// Scale down, rounding UP to avoid shortfall on Core
|
|
417
501
|
uint256 scaleDivisor = 10 ** uint8(-decimalDiff);
|
|
418
502
|
amountEVMToSend = (uint256(minimumCoreReceiveAmount) + scaleDivisor - 1) / scaleDivisor; // ceil division
|
|
419
|
-
amountCoreToReceive =
|
|
503
|
+
amountCoreToReceive = SafeCast.toUint64(amountEVMToSend * scaleDivisor);
|
|
420
504
|
}
|
|
421
505
|
}
|
|
422
506
|
|
|
@@ -461,7 +545,7 @@ library HyperCoreLib {
|
|
|
461
545
|
if (decimalsFrom == decimalsTo) {
|
|
462
546
|
return amountDecimalsFrom;
|
|
463
547
|
} else if (decimalsFrom < decimalsTo) {
|
|
464
|
-
return
|
|
548
|
+
return SafeCast.toUint64(amountDecimalsFrom * 10 ** (decimalsTo - decimalsFrom));
|
|
465
549
|
} else {
|
|
466
550
|
// round down
|
|
467
551
|
return uint64(amountDecimalsFrom / 10 ** (decimalsFrom - decimalsTo));
|
|
@@ -9,6 +9,10 @@ library PeripherySigningLib {
|
|
|
9
9
|
"BaseDepositData(address inputToken,bytes32 outputToken,uint256 outputAmount,address depositor,bytes32 recipient,uint256 destinationChainId,bytes32 exclusiveRelayer,uint32 quoteTimestamp,uint32 fillDeadline,uint32 exclusivityParameter,bytes message)";
|
|
10
10
|
string internal constant EIP712_DEPOSIT_DATA_TYPE =
|
|
11
11
|
"DepositData(Fees submissionFees,BaseDepositData baseDepositData,uint256 inputAmount,address spokePool,uint256 nonce)";
|
|
12
|
+
string internal constant EIP712_SIGNED_DEPOSIT_DATA_TYPE =
|
|
13
|
+
"SignedDepositData(DepositData depositData,uint256 deadline)";
|
|
14
|
+
string internal constant EIP712_SIGNED_SWAP_AND_DEPOSIT_DATA_TYPE =
|
|
15
|
+
"SignedSwapAndDepositData(SwapAndDepositData swapAndDepositData,uint256 deadline)";
|
|
12
16
|
string internal constant EIP712_SWAP_AND_DEPOSIT_DATA_TYPE =
|
|
13
17
|
"SwapAndDepositData(Fees submissionFees,BaseDepositData depositData,address swapToken,address exchange,uint8 transferType,uint256 swapTokenAmount,uint256 minExpectedInputTokenAmount,bytes routerCalldata,bool enableProportionalAdjustment,address spokePool,uint256 nonce)";
|
|
14
18
|
|
|
@@ -18,6 +22,24 @@ library PeripherySigningLib {
|
|
|
18
22
|
keccak256(abi.encodePacked(EIP712_BASE_DEPOSIT_DATA_TYPE));
|
|
19
23
|
bytes32 internal constant EIP712_DEPOSIT_DATA_TYPEHASH =
|
|
20
24
|
keccak256(abi.encodePacked(EIP712_DEPOSIT_DATA_TYPE, EIP712_BASE_DEPOSIT_DATA_TYPE, EIP712_FEES_TYPE));
|
|
25
|
+
bytes32 internal constant EIP712_SIGNED_DEPOSIT_DATA_TYPEHASH =
|
|
26
|
+
keccak256(
|
|
27
|
+
abi.encodePacked(
|
|
28
|
+
EIP712_SIGNED_DEPOSIT_DATA_TYPE,
|
|
29
|
+
EIP712_BASE_DEPOSIT_DATA_TYPE,
|
|
30
|
+
EIP712_DEPOSIT_DATA_TYPE,
|
|
31
|
+
EIP712_FEES_TYPE
|
|
32
|
+
)
|
|
33
|
+
);
|
|
34
|
+
bytes32 internal constant EIP712_SIGNED_SWAP_AND_DEPOSIT_DATA_TYPEHASH =
|
|
35
|
+
keccak256(
|
|
36
|
+
abi.encodePacked(
|
|
37
|
+
EIP712_SIGNED_SWAP_AND_DEPOSIT_DATA_TYPE,
|
|
38
|
+
EIP712_BASE_DEPOSIT_DATA_TYPE,
|
|
39
|
+
EIP712_FEES_TYPE,
|
|
40
|
+
EIP712_SWAP_AND_DEPOSIT_DATA_TYPE
|
|
41
|
+
)
|
|
42
|
+
);
|
|
21
43
|
bytes32 internal constant EIP712_SWAP_AND_DEPOSIT_DATA_TYPEHASH =
|
|
22
44
|
keccak256(abi.encodePacked(EIP712_SWAP_AND_DEPOSIT_DATA_TYPE, EIP712_BASE_DEPOSIT_DATA_TYPE, EIP712_FEES_TYPE));
|
|
23
45
|
|
|
@@ -128,6 +150,40 @@ library PeripherySigningLib {
|
|
|
128
150
|
);
|
|
129
151
|
}
|
|
130
152
|
|
|
153
|
+
/**
|
|
154
|
+
* @notice Hashes a DepositData together with the deadline the signer authorized it until.
|
|
155
|
+
* @dev The permit entrypoints verify this rather than the bare DepositData hash, so the deadline cannot be
|
|
156
|
+
* swapped out by the submitter. Permit2 and ERC-3009 bind their own deadline alongside the witness the same
|
|
157
|
+
* way, so their entrypoints keep using the bare hash.
|
|
158
|
+
* @param depositData Input struct whose values are hashed.
|
|
159
|
+
* @param deadline Timestamp after which the signature is no longer redeemable.
|
|
160
|
+
*/
|
|
161
|
+
function hashSignedDepositData(
|
|
162
|
+
SpokePoolPeripheryInterface.DepositData calldata depositData,
|
|
163
|
+
uint256 deadline
|
|
164
|
+
) internal pure returns (bytes32) {
|
|
165
|
+
return keccak256(abi.encode(EIP712_SIGNED_DEPOSIT_DATA_TYPEHASH, hashDepositData(depositData), deadline));
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* @notice Hashes a SwapAndDepositData together with the deadline the signer authorized it until.
|
|
170
|
+
* @param swapAndDepositData Input struct whose values are hashed.
|
|
171
|
+
* @param deadline Timestamp after which the signature is no longer redeemable.
|
|
172
|
+
*/
|
|
173
|
+
function hashSignedSwapAndDepositData(
|
|
174
|
+
SpokePoolPeripheryInterface.SwapAndDepositData calldata swapAndDepositData,
|
|
175
|
+
uint256 deadline
|
|
176
|
+
) internal pure returns (bytes32) {
|
|
177
|
+
return
|
|
178
|
+
keccak256(
|
|
179
|
+
abi.encode(
|
|
180
|
+
EIP712_SIGNED_SWAP_AND_DEPOSIT_DATA_TYPEHASH,
|
|
181
|
+
hashSwapAndDepositData(swapAndDepositData),
|
|
182
|
+
deadline
|
|
183
|
+
)
|
|
184
|
+
);
|
|
185
|
+
}
|
|
186
|
+
|
|
131
187
|
/**
|
|
132
188
|
* @notice Reads an input bytes, and, assuming it is a signature for a 32-byte hash, returns the v, r, and s values.
|
|
133
189
|
* @param _signature The input signature to deserialize.
|
|
@@ -8,6 +8,10 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.s
|
|
|
8
8
|
* @notice Mixin exposing a virtual `_safeTransfer` hook. Default implementation uses
|
|
9
9
|
* OZ `SafeERC20.safeTransfer`. Inheritors may override to swap in alternative
|
|
10
10
|
* ERC20 transfer semantics.
|
|
11
|
+
* @dev Intentionally uses OZ v5, even in inheritors that otherwise use OZ v4: a transfer failing
|
|
12
|
+
* the return-value check reverts with the v5 custom error `SafeERC20FailedOperation(address)`,
|
|
13
|
+
* not the v4 string "SafeERC20: ERC20 operation did not succeed". (A transfer that itself
|
|
14
|
+
* reverts bubbles the token's revert data, as in v4.)
|
|
11
15
|
*/
|
|
12
16
|
abstract contract SafeTransferERC20 {
|
|
13
17
|
// This mixin is the only place in the codebase permitted to call `IERC20.safeTransfer`
|
|
@@ -16,6 +16,7 @@ import { IPermit2 } from "../external/interfaces/IPermit2.sol";
|
|
|
16
16
|
import { PeripherySigningLib } from "../libraries/PeripherySigningLib.sol";
|
|
17
17
|
import { SpokePoolPeripheryInterface } from "../interfaces/SpokePoolPeripheryInterface.sol";
|
|
18
18
|
import { AddressToBytes32 } from "../libraries/AddressConverters.sol";
|
|
19
|
+
import { SafeTransferERC20 } from "../libraries/SafeTransferERC20.sol";
|
|
19
20
|
import { ERC6492SignatureHandler } from "./ERC6492SignatureHandler.sol";
|
|
20
21
|
|
|
21
22
|
/**
|
|
@@ -28,8 +29,10 @@ import { ERC6492SignatureHandler } from "./ERC6492SignatureHandler.sol";
|
|
|
28
29
|
* caller.
|
|
29
30
|
* @custom:security-contact bugs@across.to
|
|
30
31
|
*/
|
|
31
|
-
contract SwapProxy is ReentrancyGuard {
|
|
32
|
-
using
|
|
32
|
+
contract SwapProxy is ReentrancyGuard, SafeTransferERC20 {
|
|
33
|
+
// `using` is restricted to `forceApprove`; `safeTransfer` goes through the `_safeTransfer` hook so
|
|
34
|
+
// chain-specific variants (Tron) can override transfer semantics in one place.
|
|
35
|
+
using { SafeERC20.forceApprove } for IERC20;
|
|
33
36
|
using Address for address;
|
|
34
37
|
|
|
35
38
|
// Canonical Permit2 contract address
|
|
@@ -90,7 +93,7 @@ contract SwapProxy is ReentrancyGuard {
|
|
|
90
93
|
if (transferType == SpokePoolPeripheryInterface.TransferType.Approval) {
|
|
91
94
|
IERC20(inputToken).forceApprove(exchange, inputAmount);
|
|
92
95
|
} else if (transferType == SpokePoolPeripheryInterface.TransferType.Transfer) {
|
|
93
|
-
|
|
96
|
+
_safeTransfer(inputToken, exchange, inputAmount);
|
|
94
97
|
} else if (transferType == SpokePoolPeripheryInterface.TransferType.Permit2Approval) {
|
|
95
98
|
IERC20(inputToken).forceApprove(address(permit2), inputAmount);
|
|
96
99
|
expectingPermit2Callback = true;
|
|
@@ -121,7 +124,7 @@ contract SwapProxy is ReentrancyGuard {
|
|
|
121
124
|
uint256 outputBalance = IERC20(outputToken).balanceOf(address(this));
|
|
122
125
|
|
|
123
126
|
// Transfer all output tokens back to the periphery
|
|
124
|
-
|
|
127
|
+
_safeTransfer(outputToken, msg.sender, outputBalance);
|
|
125
128
|
|
|
126
129
|
// Return the net amount received from the swap
|
|
127
130
|
return outputBalance;
|
|
@@ -142,6 +145,8 @@ contract SwapProxy is ReentrancyGuard {
|
|
|
142
145
|
/**
|
|
143
146
|
* @title SpokePoolPeriphery
|
|
144
147
|
* @notice Contract for performing more complex interactions with an Across spoke pool deployment.
|
|
148
|
+
* @dev note: Token transfers here and in SwapProxy that fail the return-value check revert with the
|
|
149
|
+
* OZ v5 error `SafeERC20FailedOperation`, not the OZ v4 string (see `SafeTransferERC20`).
|
|
145
150
|
* @custom:security-contact bugs@across.to
|
|
146
151
|
*/
|
|
147
152
|
contract SpokePoolPeriphery is
|
|
@@ -149,9 +154,12 @@ contract SpokePoolPeriphery is
|
|
|
149
154
|
ReentrancyGuard,
|
|
150
155
|
MultiCaller,
|
|
151
156
|
EIP712,
|
|
152
|
-
ERC6492SignatureHandler
|
|
157
|
+
ERC6492SignatureHandler,
|
|
158
|
+
SafeTransferERC20
|
|
153
159
|
{
|
|
154
|
-
using
|
|
160
|
+
// `using` is restricted to `forceApprove`/`safeTransferFrom`; `safeTransfer` goes through the
|
|
161
|
+
// `_safeTransfer` hook so chain-specific variants (Tron) can override transfer semantics in one place.
|
|
162
|
+
using { SafeERC20.forceApprove, SafeERC20.safeTransferFrom } for IERC20;
|
|
155
163
|
using Address for address;
|
|
156
164
|
using AddressToBytes32 for address;
|
|
157
165
|
|
|
@@ -173,6 +181,12 @@ contract SpokePoolPeriphery is
|
|
|
173
181
|
bytes32 public constant AUTHORIZATION_NONCE_IDENTIFIER = keccak256("AuthorizationNonce");
|
|
174
182
|
bytes32 public constant DEPOSIT_NONCE_IDENTIFIER = keccak256("DepositNonce");
|
|
175
183
|
|
|
184
|
+
// One year in seconds, matching SpokePool.MAX_EXCLUSIVITY_PERIOD_SECONDS. `quoteTimestamp` and `fillDeadline`
|
|
185
|
+
// at or below this threshold are relative offsets, not absolute timestamps; no real timestamp is this small.
|
|
186
|
+
// They run in opposite directions: `quoteTimestamp` is subtracted (it prices existing HubPool state),
|
|
187
|
+
// `fillDeadline` is added (it is necessarily in the future).
|
|
188
|
+
uint32 public constant MAX_RELATIVE_TIME_SECONDS = 31_536_000;
|
|
189
|
+
|
|
176
190
|
event SwapBeforeBridge(
|
|
177
191
|
address exchange,
|
|
178
192
|
bytes exchangeCalldata,
|
|
@@ -191,6 +205,7 @@ contract SpokePoolPeriphery is
|
|
|
191
205
|
error InvalidMsgValue();
|
|
192
206
|
error InvalidMinExpectedInputAmount();
|
|
193
207
|
error InvalidNonce();
|
|
208
|
+
error SignatureExpired();
|
|
194
209
|
|
|
195
210
|
/**
|
|
196
211
|
* @notice Construct a new Periphery contract.
|
|
@@ -207,7 +222,13 @@ contract SpokePoolPeriphery is
|
|
|
207
222
|
permit2 = _permit2;
|
|
208
223
|
|
|
209
224
|
// Deploy the swap proxy with reference to the permit2 address
|
|
210
|
-
swapProxy =
|
|
225
|
+
swapProxy = _deploySwapProxy(address(_permit2));
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/// @dev Deploys the SwapProxy used to isolate swap execution. Virtual so chain-specific variants
|
|
229
|
+
/// (Tron) can substitute a SwapProxy variant with different transfer semantics.
|
|
230
|
+
function _deploySwapProxy(address _permit2) internal virtual returns (SwapProxy) {
|
|
231
|
+
return new SwapProxy(_permit2);
|
|
211
232
|
}
|
|
212
233
|
|
|
213
234
|
/**
|
|
@@ -237,8 +258,8 @@ contract SpokePoolPeriphery is
|
|
|
237
258
|
outputAmount,
|
|
238
259
|
destinationChainId,
|
|
239
260
|
exclusiveRelayer,
|
|
240
|
-
quoteTimestamp,
|
|
241
|
-
fillDeadline,
|
|
261
|
+
_resolveQuoteTimestamp(quoteTimestamp),
|
|
262
|
+
_resolveFillDeadline(fillDeadline),
|
|
242
263
|
exclusivityParameter,
|
|
243
264
|
message
|
|
244
265
|
);
|
|
@@ -294,6 +315,7 @@ contract SpokePoolPeriphery is
|
|
|
294
315
|
bytes calldata permitSignature,
|
|
295
316
|
bytes calldata swapAndDepositDataSignature
|
|
296
317
|
) external override nonReentrant {
|
|
318
|
+
_requireSignatureNotExpired(deadline);
|
|
297
319
|
(bytes32 r, bytes32 s, uint8 v) = PeripherySigningLib.deserializeSignature(permitSignature);
|
|
298
320
|
// Load variables used in this function onto the stack.
|
|
299
321
|
address _swapToken = swapAndDepositData.swapToken;
|
|
@@ -313,7 +335,7 @@ contract SpokePoolPeriphery is
|
|
|
313
335
|
// Verify that the signatureOwner signed the input swapAndDepositData.
|
|
314
336
|
_validateSignature(
|
|
315
337
|
signatureOwner,
|
|
316
|
-
PeripherySigningLib.
|
|
338
|
+
PeripherySigningLib.hashSignedSwapAndDepositData(swapAndDepositData, deadline),
|
|
317
339
|
swapAndDepositDataSignature
|
|
318
340
|
);
|
|
319
341
|
_swapAndBridge(swapAndDepositData, PERMIT_NONCE_IDENTIFIER, signatureOwner);
|
|
@@ -464,6 +486,7 @@ contract SpokePoolPeriphery is
|
|
|
464
486
|
bytes calldata permitSignature,
|
|
465
487
|
bytes calldata depositDataSignature
|
|
466
488
|
) external override nonReentrant {
|
|
489
|
+
_requireSignatureNotExpired(deadline);
|
|
467
490
|
(bytes32 r, bytes32 s, uint8 v) = PeripherySigningLib.deserializeSignature(permitSignature);
|
|
468
491
|
// Load variables used in this function onto the stack.
|
|
469
492
|
address _inputToken = depositData.baseDepositData.inputToken;
|
|
@@ -482,7 +505,11 @@ contract SpokePoolPeriphery is
|
|
|
482
505
|
// Verify and increment nonce to prevent replay attacks.
|
|
483
506
|
_validateAndIncrementNonce(signatureOwner, depositData.nonce);
|
|
484
507
|
// Verify that the signatureOwner signed the input depositData.
|
|
485
|
-
_validateSignature(
|
|
508
|
+
_validateSignature(
|
|
509
|
+
signatureOwner,
|
|
510
|
+
PeripherySigningLib.hashSignedDepositData(depositData, deadline),
|
|
511
|
+
depositDataSignature
|
|
512
|
+
);
|
|
486
513
|
_deposit(
|
|
487
514
|
depositData.spokePool,
|
|
488
515
|
depositData.baseDepositData.depositor,
|
|
@@ -738,6 +765,19 @@ contract SpokePoolPeriphery is
|
|
|
738
765
|
}
|
|
739
766
|
}
|
|
740
767
|
|
|
768
|
+
/**
|
|
769
|
+
* @notice Reverts unless the signed payload is still redeemable.
|
|
770
|
+
* @dev Only the ERC-2612 permit entrypoints need this. There, `permit` is called inside a try/catch, so an
|
|
771
|
+
* expired permit is silently tolerated and a standing allowance still funds the pull — leaving a payload
|
|
772
|
+
* with relative timestamps redeemable indefinitely. The deadline is bound into the payload signature via
|
|
773
|
+
* `hashSignedDepositData`/`hashSignedSwapAndDepositData` so the submitter cannot substitute it. Permit2 and
|
|
774
|
+
* ERC-3009 bind and enforce their own deadline the same way, so their entrypoints do not call this.
|
|
775
|
+
* @param signatureDeadline Timestamp after which the signature is no longer valid.
|
|
776
|
+
*/
|
|
777
|
+
function _requireSignatureNotExpired(uint256 signatureDeadline) private view {
|
|
778
|
+
if (block.timestamp > signatureDeadline) revert SignatureExpired();
|
|
779
|
+
}
|
|
780
|
+
|
|
741
781
|
/**
|
|
742
782
|
* @notice Validates and increments the user's nonce to prevent replay attacks.
|
|
743
783
|
* @param user The user whose nonce is being validated.
|
|
@@ -763,8 +803,10 @@ contract SpokePoolPeriphery is
|
|
|
763
803
|
* @param destinationChainId The network ID for the destination chain.
|
|
764
804
|
* @param exclusiveRelayer The optional address for an Across relayer which may fill the deposit exclusively.
|
|
765
805
|
* @param depositNonce The nonce for this deposit. If 0, calls regular deposit; if non-zero, calls unsafe deposit.
|
|
766
|
-
* @param quoteTimestamp The timestamp at which the relay and LP fee was calculated.
|
|
767
|
-
*
|
|
806
|
+
* @param quoteTimestamp The timestamp at which the relay and LP fee was calculated. If at most
|
|
807
|
+
* MAX_RELATIVE_TIME_SECONDS, this is instead interpreted as an age in seconds subtracted from block.timestamp.
|
|
808
|
+
* @param fillDeadline The timestamp at which the deposit must be filled before it will be refunded by Across. If
|
|
809
|
+
* at most MAX_RELATIVE_TIME_SECONDS, this is instead interpreted as an offset added to block.timestamp.
|
|
768
810
|
* @param exclusivityParameter The deadline or offset during which the exclusive relayer has rights to fill the deposit without contention.
|
|
769
811
|
* @param message The message to execute on the destination chain.
|
|
770
812
|
* @param nonceIdentifier The identifier for the nonce type (permit, permit2, or authorization).
|
|
@@ -799,8 +841,8 @@ contract SpokePoolPeriphery is
|
|
|
799
841
|
outputAmount,
|
|
800
842
|
destinationChainId,
|
|
801
843
|
exclusiveRelayer,
|
|
802
|
-
quoteTimestamp,
|
|
803
|
-
fillDeadline,
|
|
844
|
+
_resolveQuoteTimestamp(quoteTimestamp),
|
|
845
|
+
_resolveFillDeadline(fillDeadline),
|
|
804
846
|
exclusivityParameter,
|
|
805
847
|
message
|
|
806
848
|
);
|
|
@@ -815,14 +857,34 @@ contract SpokePoolPeriphery is
|
|
|
815
857
|
destinationChainId,
|
|
816
858
|
exclusiveRelayer,
|
|
817
859
|
_computeDepositNonce(nonceIdentifier, signatureOwner, depositNonce),
|
|
818
|
-
quoteTimestamp,
|
|
819
|
-
fillDeadline,
|
|
860
|
+
_resolveQuoteTimestamp(quoteTimestamp),
|
|
861
|
+
_resolveFillDeadline(fillDeadline),
|
|
820
862
|
exclusivityParameter,
|
|
821
863
|
message
|
|
822
864
|
);
|
|
823
865
|
}
|
|
824
866
|
}
|
|
825
867
|
|
|
868
|
+
/**
|
|
869
|
+
* @notice Resolves a quoteTimestamp to absolute form, ageing relative values into the past so they name an
|
|
870
|
+
* already-existing HubPool snapshot. An age of 0 prices the deposit as of the block it lands in.
|
|
871
|
+
* @param quoteTimestamp An absolute unix timestamp, or an age in seconds if at most MAX_RELATIVE_TIME_SECONDS.
|
|
872
|
+
* @return The absolute timestamp to forward to the spoke pool.
|
|
873
|
+
*/
|
|
874
|
+
function _resolveQuoteTimestamp(uint32 quoteTimestamp) private view returns (uint32) {
|
|
875
|
+
return quoteTimestamp <= MAX_RELATIVE_TIME_SECONDS ? uint32(block.timestamp) - quoteTimestamp : quoteTimestamp;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
/**
|
|
879
|
+
* @notice Resolves a fillDeadline to absolute form, projecting relative values into the future so that signed
|
|
880
|
+
* deposit data keeps a full fill window regardless of when it is submitted.
|
|
881
|
+
* @param fillDeadline An absolute unix timestamp, or an offset in seconds if at most MAX_RELATIVE_TIME_SECONDS.
|
|
882
|
+
* @return The absolute timestamp to forward to the spoke pool.
|
|
883
|
+
*/
|
|
884
|
+
function _resolveFillDeadline(uint32 fillDeadline) private view returns (uint32) {
|
|
885
|
+
return fillDeadline <= MAX_RELATIVE_TIME_SECONDS ? uint32(block.timestamp) + fillDeadline : fillDeadline;
|
|
886
|
+
}
|
|
887
|
+
|
|
826
888
|
/**
|
|
827
889
|
* @notice Computes a unique deposit nonce by hashing the nonce identifier, authorizer, and nonce.
|
|
828
890
|
* @param nonceIdentifier The identifier for the nonce type (permit, permit2, or authorization).
|
|
@@ -861,7 +923,7 @@ contract SpokePoolPeriphery is
|
|
|
861
923
|
uint256 _swapTokenAmount = swapAndDepositData.swapTokenAmount;
|
|
862
924
|
|
|
863
925
|
// Transfer tokens to the swap proxy for executing the swap
|
|
864
|
-
|
|
926
|
+
_safeTransfer(address(_swapToken), address(swapProxy), _swapTokenAmount);
|
|
865
927
|
|
|
866
928
|
// Execute the swap via the swap proxy using the appropriate transfer type
|
|
867
929
|
// This function will swap _swapToken for _acrossInputToken and return the amount of _acrossInputToken received
|
|
@@ -926,7 +988,7 @@ contract SpokePoolPeriphery is
|
|
|
926
988
|
if (amount > 0) {
|
|
927
989
|
// Use msg.sender as recipient if recipient is zero address, otherwise use the specified recipient
|
|
928
990
|
address feeRecipient = recipient == address(0) ? msg.sender : recipient;
|
|
929
|
-
|
|
991
|
+
_safeTransfer(feeToken, feeRecipient, amount);
|
|
930
992
|
}
|
|
931
993
|
}
|
|
932
994
|
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
2
|
+
pragma solidity ^0.8.0;
|
|
3
|
+
|
|
4
|
+
import { SpokePoolPeriphery, SwapProxy } from "./SpokePoolPeriphery.sol";
|
|
5
|
+
import { IPermit2 } from "../external/interfaces/IPermit2.sol";
|
|
6
|
+
import { TronTransferLib } from "../libraries/TronTransferLib.sol";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @title Tron_SwapProxy
|
|
10
|
+
* @notice Tron variant of `SwapProxy` for tokens like Tron USDT (whose `transfer` returns false on
|
|
11
|
+
* success). Overrides only the `_safeTransfer` hook to use a balance-delta success check;
|
|
12
|
+
* `forceApprove` and permit2 paths are unaffected.
|
|
13
|
+
* @custom:security-contact bugs@across.to
|
|
14
|
+
*/
|
|
15
|
+
contract Tron_SwapProxy is SwapProxy {
|
|
16
|
+
constructor(address _permit2) SwapProxy(_permit2) {} // solhint-disable-line no-empty-blocks
|
|
17
|
+
|
|
18
|
+
/// @dev TRON OVERRIDE of `_safeTransfer`: a balance-delta success check that tolerates Tron USDT's
|
|
19
|
+
/// non-standard `transfer` return value.
|
|
20
|
+
function _safeTransfer(address token, address to, uint256 amount) internal override {
|
|
21
|
+
TronTransferLib._safeTransferBalanceCheck(token, to, amount);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* @title Tron_SpokePoolPeriphery
|
|
27
|
+
* @notice Tron variant of `SpokePoolPeriphery` for tokens like Tron USDT (whose `transfer` returns
|
|
28
|
+
* false on success).
|
|
29
|
+
* @dev Inherits the mainline impl and overrides only `_safeTransfer` (swap-token handoff and
|
|
30
|
+
* submission-fee payout) plus `_deploySwapProxy` (so the constructor-deployed swap proxy is a
|
|
31
|
+
* `Tron_SwapProxy`). `transferFrom` is correct on Tron USDT, so `safeTransferFrom` pull paths and
|
|
32
|
+
* `forceApprove` are unchanged. The mainline EIP-712 name is inherited, which is safe: the domain
|
|
33
|
+
* separator commits to `chainId` and `verifyingContract`, so signatures cannot cross chains or
|
|
34
|
+
* deployments, and the variant changes only transfer semantics, not the signed outcome.
|
|
35
|
+
* @custom:security-contact bugs@across.to
|
|
36
|
+
*/
|
|
37
|
+
contract Tron_SpokePoolPeriphery is SpokePoolPeriphery {
|
|
38
|
+
// solhint-disable-next-line no-empty-blocks
|
|
39
|
+
constructor(IPermit2 _permit2, address _multicall3) SpokePoolPeriphery(_permit2, _multicall3) {}
|
|
40
|
+
|
|
41
|
+
/// @dev Deploys the Tron variant of the swap proxy so its exchange/output transfers also tolerate
|
|
42
|
+
/// Tron USDT's non-standard `transfer` return value.
|
|
43
|
+
function _deploySwapProxy(address _permit2) internal override returns (SwapProxy) {
|
|
44
|
+
return new Tron_SwapProxy(_permit2);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/// @dev TRON OVERRIDE of `_safeTransfer`: a balance-delta success check that tolerates Tron USDT's
|
|
48
|
+
/// non-standard `transfer` return value.
|
|
49
|
+
function _safeTransfer(address token, address to, uint256 amount) internal override {
|
|
50
|
+
TronTransferLib._safeTransferBalanceCheck(token, to, amount);
|
|
51
|
+
}
|
|
52
|
+
}
|