Skip to content

Commit

Permalink
fix: Update SwapAdapter.sol toEth (#282)
Browse files Browse the repository at this point in the history
  • Loading branch information
lastperson authored Nov 14, 2024
1 parent b30cabd commit 9df8b94
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contracts/adapters/SwapAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions contracts/adapters/interfaces/INativeTokenAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9df8b94

Please sign in to comment.