mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixed native token transfer bug: mainnet
This commit is contained in:
parent
15040444a0
commit
e9ccd751bc
|
@ -26,13 +26,16 @@ contract Helpers is DSMath, Basic {
|
|||
uint256 destinationDeadline;
|
||||
}
|
||||
|
||||
function _sendToL2(BridgeParams memory params) internal {
|
||||
function _sendToL2(BridgeParams memory params, bool isNative) internal {
|
||||
IHopRouter router = IHopRouter(params.router);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
uint256 nativeTokenAmt = isNative ? params.amount : 0;
|
||||
if (!isNative) {
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
}
|
||||
|
||||
router.sendToL2(
|
||||
router.sendToL2{ value: nativeTokenAmt }(
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
|
|
|
@ -12,5 +12,5 @@ interface IHopRouter {
|
|||
uint256 deadline,
|
||||
address relayer,
|
||||
uint256 relayerFee
|
||||
) external;
|
||||
) external payable;
|
||||
}
|
||||
|
|
|
@ -26,24 +26,26 @@ abstract contract Resolver is Helpers {
|
|||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
params.amount = getUint(getId, params.amount);
|
||||
|
||||
bool isEth = params.token == ethAddr;
|
||||
params.token = params.token == ethAddr ? wethAddr : params.token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
|
||||
if (isEth) {
|
||||
if (params.token == wethAddr) {
|
||||
convertWethToEth(true, tokenContract, params.amount);
|
||||
params.token = ethAddr;
|
||||
}
|
||||
|
||||
bool isNative = params.token == ethAddr;
|
||||
|
||||
if (isNative) {
|
||||
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;
|
||||
}
|
||||
|
||||
_sendToL2(params);
|
||||
_sendToL2(params, isNative);
|
||||
|
||||
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(
|
||||
|
|
Loading…
Reference in New Issue
Block a user