fixed arbitrum connector

This commit is contained in:
pradyuman-verma 2022-05-12 01:02:55 +05:30
parent 44e9968dac
commit aa1d2b1a75
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
3 changed files with 15 additions and 10 deletions

View File

@ -32,13 +32,16 @@ contract Helpers is DSMath, Basic {
uint256 destinationDeadline;
}
function _swapAndSend(BridgeParams memory params) internal {
function _swapAndSend(BridgeParams memory params, bool isEth) internal {
IHopRouter router = IHopRouter(params.router);
TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.router, params.amount);
uint256 nativeTokenAmt = isEth ? params.amount : 0;
if (!isEth) {
TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.router, params.amount);
}
router.swapAndSend(
router.swapAndSend{ value: nativeTokenAmt }(
params.targetChainId,
params.recipient,
params.amount,

View File

@ -13,5 +13,5 @@ interface IHopRouter {
uint256 deadline,
uint256 destinationAmountOutMin,
uint256 destinationDeadline
) external;
) external payable;
}

View File

@ -37,24 +37,26 @@ abstract contract Resolver is Helpers {
}
params.amount = getUint(getId, params.amount);
TokenInterface tokenContract = TokenInterface(params.token);
if (params.token == wethAddr) {
convertWethToEth(true, tokenContract, params.amount);
params.token = ethAddr;
}
bool isEth = params.token == ethAddr;
params.token = params.token == ethAddr ? wethAddr : params.token;
TokenInterface tokenContract = TokenInterface(params.token);
if (isEth) {
params.amount = params.amount == uint256(-1)
? address(this).balance
: params.amount;
convertEthToWeth(isEth, tokenContract, params.amount);
} else {
params.amount = params.amount == uint256(-1)
? tokenContract.balanceOf(address(this))
: params.amount;
}
_swapAndSend(params);
_swapAndSend(params, isEth);
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode(