-
Notifications
You must be signed in to change notification settings - Fork 0
/
AxelarIntegration.sol
42 lines (32 loc) · 1.76 KB
/
AxelarIntegration.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16;
pragma abicoder v2;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@uniswap/v3-periphery/contracts/libraries/TransferHelper.sol";
// import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./interfaces/IAxelarGateway.sol";
import "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
// import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";
contract AxelarIntegration is Ownable, ReentrancyGuard {
IAxelarGateway public axelarGateway;
IERC20 private axlUSDC;
constructor(address firstOwner, address _axelarGatewayAddress, address _axlUSDCAddress) Ownable(firstOwner) {
axelarGateway = IAxelarGateway(_axelarGatewayAddress);
axlUSDC = IERC20(_axlUSDCAddress);
}
function sendTokensToAnotherChain(string memory destChain, string memory destination, string memory symbol, uint256 amount) public nonReentrant onlyOwner {
uint256 balance = axlUSDC.balanceOf(address(this));
require(balance >= amount, "amount > balance");
require(keccak256(bytes(symbol)) == keccak256(bytes("axlUSDC")), "only axlUSDC enabled");
// Polygon
TransferHelper.safeApprove(address(axlUSDC), address(axelarGateway), amount);
axelarGateway.sendToken(destChain, destination, symbol, amount);
}
function recoverToken(address _tokenAddress, address recipient, uint256 _amount) external nonReentrant onlyOwner {
IERC20 _token = IERC20(_tokenAddress);
uint256 balance = _token.balanceOf(address(this));
require(balance >= _amount, "_amount > balance");
TransferHelper.safeTransferFrom(_tokenAddress, address(this), recipient, _amount);
}
}