Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Update SwapAdapter.sol toEth #282

Merged
merged 2 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading