mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixed arbitrum connector
This commit is contained in:
parent
44e9968dac
commit
aa1d2b1a75
|
@ -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,
|
||||
|
|
|
@ -13,5 +13,5 @@ interface IHopRouter {
|
|||
uint256 deadline,
|
||||
uint256 destinationAmountOutMin,
|
||||
uint256 destinationDeadline
|
||||
) external;
|
||||
) external payable;
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in New Issue
Block a user