diff --git a/contracts/adapters/SwapAdapter.sol b/contracts/adapters/SwapAdapter.sol index b3d9a5ef..47d96258 100644 --- a/contracts/adapters/SwapAdapter.sol +++ b/contracts/adapters/SwapAdapter.sol @@ -27,6 +27,7 @@ contract SwapAdapter is AccessControl { address public immutable _weth; IUniversalRouter public immutable _swapRouter; INativeTokenAdapter public immutable _nativeTokenAdapter; + bytes32 public immutable _nativeResourceID; IPermit2 public immutable _permit2; mapping(address => bytes32) public tokenToResourceID; @@ -76,6 +77,7 @@ contract SwapAdapter is AccessControl { _swapRouter = swapRouter; _permit2 = permit2; _nativeTokenAdapter = nativeTokenAdapter; + _nativeResourceID = nativeTokenAdapter._resourceID(); IERC20(_weth).approve(address(_permit2), type(uint256).max); _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); } @@ -115,8 +117,7 @@ contract SwapAdapter is AccessControl { uint24[] calldata pathFees ) external { LocalVars memory vars; - vars.resourceID = tokenToResourceID[token]; - if (vars.resourceID == bytes32(0)) revert TokenInvalid(); + vars.resourceID = _nativeResourceID; // Compose depositData vars.depositDataAfterAmount = abi.encodePacked( diff --git a/contracts/adapters/interfaces/INativeTokenAdapter.sol b/contracts/adapters/interfaces/INativeTokenAdapter.sol index 48fc769a..a937998e 100644 --- a/contracts/adapters/interfaces/INativeTokenAdapter.sol +++ b/contracts/adapters/interfaces/INativeTokenAdapter.sol @@ -7,6 +7,8 @@ pragma solidity 0.8.11; @author ChainSafe Systems. */ interface INativeTokenAdapter { + function _resourceID() external view returns(bytes32); + function depositToEVM( uint8 destinationDomainID, address recipientAddress