mirror of
				https://github.com/Instadapp/dsa-connectors.git
				synced 2024-07-29 22:37:00 +00:00 
			
		
		
		
	Socket contracts added
This commit is contained in:
		
							parent
							
								
									ae51a19713
								
							
						
					
					
						commit
						5beddb6efb
					
				
							
								
								
									
										14
									
								
								contracts/mainnet/connectors/socket/events.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								contracts/mainnet/connectors/socket/events.sol
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,14 @@ | |||
| //SPDX-License-Identifier: MIT | ||||
| pragma solidity ^0.7.0; | ||||
| pragma experimental ABIEncoderV2; | ||||
| 
 | ||||
| contract Events { | ||||
|     event LogBridge ( | ||||
|         address to, | ||||
|         bytes txData, | ||||
|         address token, | ||||
|         uint256 allowanceTarget, | ||||
|         uint256 amount, | ||||
|         uint256 getId | ||||
|     ); | ||||
| } | ||||
							
								
								
									
										68
									
								
								contracts/mainnet/connectors/socket/main.sol
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								contracts/mainnet/connectors/socket/main.sol
									
									
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,68 @@ | |||
| //SPDX-License-Identifier: MIT | ||||
| pragma solidity ^0.7.0; | ||||
| pragma experimental ABIEncoderV2; | ||||
| 
 | ||||
| /** | ||||
|  * @title Socket. | ||||
|  * @dev Multi-chain Bridge Aggregator. | ||||
|  */ | ||||
| 
 | ||||
| import { Basic } from "../../common/basic.sol"; | ||||
| import { TokenInterface } from "../../common/interfaces.sol"; | ||||
| import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | ||||
| 
 | ||||
| abstract contract SocketConnector is Basic { | ||||
| 
 | ||||
|     struct BridgeParams { | ||||
| 		address payable to;  | ||||
|         bytes txData; | ||||
|         address token; | ||||
|         address allowanceTarget; | ||||
|         uint256 amount; | ||||
| 	} | ||||
| 
 | ||||
|     function bridge(BridgeParams memory _params, uint256 _getId) | ||||
|         external  | ||||
|         payable  | ||||
|         returns (string memory _eventName, bytes memory _eventParam)  | ||||
|     { | ||||
|         _params.amount = getUint(_getId, _params.amount); | ||||
| 
 | ||||
|         if(_params.token == ethAddr) { | ||||
|             _params.amount = _params.amount == uint256(-1) | ||||
| 				? address(this).balance | ||||
| 				: _params.amount; | ||||
| 
 | ||||
|             (bool success, ) = _params.to.call{value: _params.amount}(_params.txData); | ||||
|             require(success); | ||||
| 
 | ||||
|         } else { | ||||
| 
 | ||||
|             IERC20 _tokenContract = IERC20(_params.token); | ||||
| 
 | ||||
|             _params.amount = _params.amount == uint256(-1) | ||||
| 				? _tokenContract.balanceOf(address(this)) | ||||
| 				: _params.amount; | ||||
| 
 | ||||
| 
 | ||||
|             _tokenContract.approve(_params.allowanceTarget, _params.amount); | ||||
|             (bool success, ) = _params.to.call(_params.txData); | ||||
|             require(success); | ||||
|         } | ||||
| 
 | ||||
|         _eventName = "LogSocketBridge(address,bytes,address,address,uint256,uint256)"; | ||||
| 		_eventParam = abi.encode( | ||||
| 			_params.to, | ||||
| 			_params.txData, | ||||
| 			_params.token, | ||||
| 			_params.allowanceTarget, | ||||
| 			_params.amount, | ||||
| 			_getId | ||||
| 		); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
| contract ConnectV2Socket is SocketConnector { | ||||
| 	string public constant name = "Socket-v1.0"; | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Shriya Tyagi
						Shriya Tyagi