updated parama

This commit is contained in:
pradyuman-verma 2022-04-16 22:54:24 +05:30
parent a5edeee567
commit 8f6c5092ac
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
8 changed files with 71 additions and 71 deletions

View File

@ -8,43 +8,43 @@ import "./interface.sol";
contract Helpers is DSMath, Basic { contract Helpers is DSMath, Basic {
/** /**
* @param token The address of token to be bridged.(For USDC: 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8) * @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
* @param hopRouter The address of hop l2AmmWrapper. * @param targetChainId The Id of the destination chain.(For MAINNET : 1)
* @param chainId The Id of the destination chain.(For MAINNET : 1) * @param router The address of hop router.
* @param recipient The address to recieve the token on destination chain. * @param recipient The address to recieve the token on destination chain.
* @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost). * @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost).
* @param bonderFee The fee to be recieved by bonder at destination chain. * @param bonderFee The fee to be recieved by bonder at destination chain.
* @param amountOutMin minimum amount of token out for swap * @param sourceAmountOutMin minimum amount of token out for swap on source chain.
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)) * @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging * @param destinationAmountOutMin minimum amount of token out for bridge on target chain, zero for L1 bridging
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging * @param destinationDeadline The deadline for the target chain transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
*/ */
struct BridgeParams { struct BridgeParams {
address token; address token;
address router;
address recipient; address recipient;
address hopRouter; uint256 targetChainId;
uint256 chainId;
uint256 amount; uint256 amount;
uint256 bonderFee; uint256 bonderFee;
uint256 amountOutMin; uint256 sourceAmountOutMin;
uint256 deadline; uint256 sourceDeadline;
uint256 destinationAmountOutMin; uint256 destinationAmountOutMin;
uint256 destinationDeadline; uint256 destinationDeadline;
} }
function _swapAndSend(BridgeParams memory params) internal { function _swapAndSend(BridgeParams memory params) internal {
IHopRouter router = IHopRouter(params.hopRouter); IHopRouter router = IHopRouter(params.router);
TokenInterface tokenContract = TokenInterface(params.token); TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.hopRouter, params.amount); approve(tokenContract, params.router, params.amount);
router.swapAndSend( router.swapAndSend(
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline params.destinationDeadline
); );

View File

@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
if (params.chainId == 1) { if (params.targetChainId == 1) {
require( require(
params.destinationAmountOutMin == 0, params.destinationAmountOutMin == 0,
"destinationAmountOutMin != 0, sending to L1" "destinationAmountOutMin != 0, sending to L1"
@ -59,12 +59,12 @@ abstract contract Resolver is Helpers {
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)"; _eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
params.token, params.token,
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline, params.destinationDeadline,
getId getId

View File

@ -19,25 +19,25 @@ contract Helpers is DSMath, Basic {
struct BridgeParams { struct BridgeParams {
address token; address token;
address recipient; address recipient;
address hopRouter; address router;
uint256 chainId; uint256 targetChainId;
uint256 amount; uint256 amount;
uint256 amountOutMin; uint256 destinationAmountOutMin;
uint256 deadline; uint256 destinationDeadline;
} }
function _sendToL2(BridgeParams memory params) internal { function _sendToL2(BridgeParams memory params) internal {
IHopRouter router = IHopRouter(params.hopRouter); IHopRouter router = IHopRouter(params.router);
TokenInterface tokenContract = TokenInterface(params.token); TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.hopRouter, params.amount); approve(tokenContract, params.router, params.amount);
router.sendToL2( router.sendToL2(
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.amountOutMin, params.destinationAmountOutMin,
params.deadline, params.destinationDeadline,
address(0), // relayer address address(0), // relayer address
0 // relayer fee 0 // relayer fee
); );

View File

@ -48,11 +48,11 @@ abstract contract Resolver is Helpers {
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256)"; _eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
params.token, params.token,
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.amountOutMin, params.destinationAmountOutMin,
params.deadline, params.destinationDeadline,
getId getId
); );
} }

View File

@ -8,43 +8,43 @@ import "./interface.sol";
contract Helpers is DSMath, Basic { contract Helpers is DSMath, Basic {
/** /**
* @param token The address of token to be bridged.(For USDC: 0x7f5c764cbc14f9669b88837ca1490cca17c31607) * @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
* @param chainId The Id of the destination chain.(For MAINNET : 1) * @param targetChainId The Id of the destination chain.(For MAINNET : 1)
* @param hopRouter The address of hop l2AmmWrapper. * @param router The address of hop router.
* @param recipient The address to recieve the token on destination chain. * @param recipient The address to recieve the token on destination chain.
* @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost). * @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost).
* @param bonderFee The fee to be recieved by bonder at destination chain. * @param bonderFee The fee to be recieved by bonder at destination chain.
* @param amountOutMin minimum amount of token out for swap * @param sourceAmountOutMin minimum amount of token out for swap on source chain.
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)) * @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging * @param destinationAmountOutMin minimum amount of token out for bridge on target chain, zero for L1 bridging
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging * @param destinationDeadline The deadline for the target chain transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
*/ */
struct BridgeParams { struct BridgeParams {
address token; address token;
address router;
address recipient; address recipient;
address hopRouter; uint256 targetChainId;
uint256 chainId;
uint256 amount; uint256 amount;
uint256 bonderFee; uint256 bonderFee;
uint256 amountOutMin; uint256 sourceAmountOutMin;
uint256 deadline; uint256 sourceDeadline;
uint256 destinationAmountOutMin; uint256 destinationAmountOutMin;
uint256 destinationDeadline; uint256 destinationDeadline;
} }
function _swapAndSend(BridgeParams memory params) internal { function _swapAndSend(BridgeParams memory params) internal {
IHopRouter router = IHopRouter(params.hopRouter); IHopRouter router = IHopRouter(params.router);
TokenInterface tokenContract = TokenInterface(params.token); TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.hopRouter, params.amount); approve(tokenContract, params.router, params.amount);
router.swapAndSend( router.swapAndSend(
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline params.destinationDeadline
); );

View File

@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
if (params.chainId == 1) { if (params.targetChainId == 1) {
require( require(
params.destinationAmountOutMin == 0, params.destinationAmountOutMin == 0,
"destinationAmountOutMin != 0, sending to L1" "destinationAmountOutMin != 0, sending to L1"
@ -59,12 +59,12 @@ abstract contract Resolver is Helpers {
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)"; _eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
params.token, params.token,
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline, params.destinationDeadline,
getId getId

View File

@ -9,42 +9,42 @@ import "./interface.sol";
contract Helpers is DSMath, Basic { contract Helpers is DSMath, Basic {
/** /**
* @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174) * @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
* @param chainId The Id of the destination chain.(For MAINNET : 1) * @param targetChainId The Id of the destination chain.(For MAINNET : 1)
* @param hopRouter The address of hop l2AmmWrapper. * @param router The address of hop router.
* @param recipient The address to recieve the token on destination chain. * @param recipient The address to recieve the token on destination chain.
* @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost). * @param amount The total amount sent by user (Includes bonder fee, destination chain Tx cost).
* @param bonderFee The fee to be recieved by bonder at destination chain. * @param bonderFee The fee to be recieved by bonder at destination chain.
* @param amountOutMin minimum amount of token out for swap * @param sourceAmountOutMin minimum amount of token out for swap on source chain.
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)) * @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging * @param destinationAmountOutMin minimum amount of token out for bridge on target chain, zero for L1 bridging
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging * @param destinationDeadline The deadline for the target chain transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
*/ */
struct BridgeParams { struct BridgeParams {
address token; address token;
address hopRouter; address router;
address recipient; address recipient;
uint256 chainId; uint256 targetChainId;
uint256 amount; uint256 amount;
uint256 bonderFee; uint256 bonderFee;
uint256 amountOutMin; uint256 sourceAmountOutMin;
uint256 deadline; uint256 sourceDeadline;
uint256 destinationAmountOutMin; uint256 destinationAmountOutMin;
uint256 destinationDeadline; uint256 destinationDeadline;
} }
function _swapAndSend(BridgeParams memory params) internal { function _swapAndSend(BridgeParams memory params) internal {
IHopRouter router = IHopRouter(params.hopRouter); IHopRouter router = IHopRouter(params.router);
TokenInterface tokenContract = TokenInterface(params.token); TokenInterface tokenContract = TokenInterface(params.token);
approve(tokenContract, params.hopRouter, params.amount); approve(tokenContract, params.router, params.amount);
router.swapAndSend( router.swapAndSend(
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline params.destinationDeadline
); );

View File

@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
payable payable
returns (string memory _eventName, bytes memory _eventParam) returns (string memory _eventName, bytes memory _eventParam)
{ {
if (params.chainId == 1) { if (params.targetChainId == 1) {
require( require(
params.destinationAmountOutMin == 0, params.destinationAmountOutMin == 0,
"destinationAmountOutMin != 0, sending to L1" "destinationAmountOutMin != 0, sending to L1"
@ -59,12 +59,12 @@ abstract contract Resolver is Helpers {
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)"; _eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256,uint256,uint256,uint256)";
_eventParam = abi.encode( _eventParam = abi.encode(
params.token, params.token,
params.chainId, params.targetChainId,
params.recipient, params.recipient,
params.amount, params.amount,
params.bonderFee, params.bonderFee,
params.amountOutMin, params.sourceAmountOutMin,
params.deadline, params.sourceDeadline,
params.destinationAmountOutMin, params.destinationAmountOutMin,
params.destinationDeadline, params.destinationDeadline,
getId getId