-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e87ddb2
commit 375fdeb
Showing
2 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-FileCopyrightText: 2023 Snowfork <[email protected]> | ||
pragma solidity 0.8.25; | ||
|
||
import {IGateway} from "./interfaces/IGateway.sol"; | ||
import {WETH9} from "canonical-weth/WETH9.sol"; | ||
import {ParaID, MultiAddress} from "./Types.sol"; | ||
|
||
contract DepositWETH9AndSend { | ||
address public immutable GATEWAY_PROXY; | ||
address payable public immutable WETH_INSTANCE; | ||
|
||
constructor(address _gatewayProxy, address payable _wethInstance) { | ||
GATEWAY_PROXY = _gatewayProxy; | ||
WETH_INSTANCE = _wethInstance; | ||
} | ||
|
||
// Transfer ERC20 tokens to a Polkadot parachain | ||
function sendToken( | ||
ParaID destinationChain, | ||
MultiAddress calldata destinationAddress, | ||
uint128 destinationFee, | ||
uint128 amount | ||
) external payable { | ||
WETH9(WETH_INSTANCE).deposit{value: amount}(); | ||
WETH9(WETH_INSTANCE).approve(GATEWAY_PROXY, amount); | ||
|
||
uint256 fee = msg.value - amount; | ||
IGateway(GATEWAY_PROXY).sendToken{value: fee}( | ||
WETH_INSTANCE, destinationChain, destinationAddress, destinationFee, amount | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters