mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
updated parama
This commit is contained in:
parent
a5edeee567
commit
8f6c5092ac
|
@ -8,43 +8,43 @@ import "./interface.sol";
|
|||
|
||||
contract Helpers is DSMath, Basic {
|
||||
/**
|
||||
* @param token The address of token to be bridged.(For USDC: 0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8)
|
||||
* @param hopRouter The address of hop l2AmmWrapper.
|
||||
* @param chainId The Id of the destination chain.(For MAINNET : 1)
|
||||
* @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
|
||||
* @param targetChainId 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 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 amountOutMin minimum amount of token out for swap
|
||||
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging
|
||||
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
|
||||
* @param sourceAmountOutMin minimum amount of token out for swap on source chain.
|
||||
* @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge on target chain, 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 {
|
||||
address token;
|
||||
address router;
|
||||
address recipient;
|
||||
address hopRouter;
|
||||
uint256 chainId;
|
||||
uint256 targetChainId;
|
||||
uint256 amount;
|
||||
uint256 bonderFee;
|
||||
uint256 amountOutMin;
|
||||
uint256 deadline;
|
||||
uint256 sourceAmountOutMin;
|
||||
uint256 sourceDeadline;
|
||||
uint256 destinationAmountOutMin;
|
||||
uint256 destinationDeadline;
|
||||
}
|
||||
|
||||
function _swapAndSend(BridgeParams memory params) internal {
|
||||
IHopRouter router = IHopRouter(params.hopRouter);
|
||||
IHopRouter router = IHopRouter(params.router);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.hopRouter, params.amount);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
|
||||
router.swapAndSend(
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
|
|||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
if (params.chainId == 1) {
|
||||
if (params.targetChainId == 1) {
|
||||
require(
|
||||
params.destinationAmountOutMin == 0,
|
||||
"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)";
|
||||
_eventParam = abi.encode(
|
||||
params.token,
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline,
|
||||
getId
|
||||
|
|
|
@ -19,25 +19,25 @@ contract Helpers is DSMath, Basic {
|
|||
struct BridgeParams {
|
||||
address token;
|
||||
address recipient;
|
||||
address hopRouter;
|
||||
uint256 chainId;
|
||||
address router;
|
||||
uint256 targetChainId;
|
||||
uint256 amount;
|
||||
uint256 amountOutMin;
|
||||
uint256 deadline;
|
||||
uint256 destinationAmountOutMin;
|
||||
uint256 destinationDeadline;
|
||||
}
|
||||
|
||||
function _sendToL2(BridgeParams memory params) internal {
|
||||
IHopRouter router = IHopRouter(params.hopRouter);
|
||||
IHopRouter router = IHopRouter(params.router);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.hopRouter, params.amount);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
|
||||
router.sendToL2(
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline,
|
||||
address(0), // relayer address
|
||||
0 // relayer fee
|
||||
);
|
||||
|
|
|
@ -48,11 +48,11 @@ abstract contract Resolver is Helpers {
|
|||
_eventName = "LogBridge(address,uint256,address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(
|
||||
params.token,
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline,
|
||||
getId
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,43 +8,43 @@ import "./interface.sol";
|
|||
|
||||
contract Helpers is DSMath, Basic {
|
||||
/**
|
||||
* @param token The address of token to be bridged.(For USDC: 0x7f5c764cbc14f9669b88837ca1490cca17c31607)
|
||||
* @param chainId The Id of the destination chain.(For MAINNET : 1)
|
||||
* @param hopRouter The address of hop l2AmmWrapper.
|
||||
* @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
|
||||
* @param targetChainId 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 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 amountOutMin minimum amount of token out for swap
|
||||
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging
|
||||
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
|
||||
* @param sourceAmountOutMin minimum amount of token out for swap on source chain.
|
||||
* @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge on target chain, 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 {
|
||||
address token;
|
||||
address router;
|
||||
address recipient;
|
||||
address hopRouter;
|
||||
uint256 chainId;
|
||||
uint256 targetChainId;
|
||||
uint256 amount;
|
||||
uint256 bonderFee;
|
||||
uint256 amountOutMin;
|
||||
uint256 deadline;
|
||||
uint256 sourceAmountOutMin;
|
||||
uint256 sourceDeadline;
|
||||
uint256 destinationAmountOutMin;
|
||||
uint256 destinationDeadline;
|
||||
}
|
||||
|
||||
function _swapAndSend(BridgeParams memory params) internal {
|
||||
IHopRouter router = IHopRouter(params.hopRouter);
|
||||
IHopRouter router = IHopRouter(params.router);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.hopRouter, params.amount);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
|
||||
router.swapAndSend(
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
|
|||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
if (params.chainId == 1) {
|
||||
if (params.targetChainId == 1) {
|
||||
require(
|
||||
params.destinationAmountOutMin == 0,
|
||||
"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)";
|
||||
_eventParam = abi.encode(
|
||||
params.token,
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline,
|
||||
getId
|
||||
|
|
|
@ -9,42 +9,42 @@ import "./interface.sol";
|
|||
contract Helpers is DSMath, Basic {
|
||||
/**
|
||||
* @param token The address of token to be bridged.(For USDC: 0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174)
|
||||
* @param chainId The Id of the destination chain.(For MAINNET : 1)
|
||||
* @param hopRouter The address of hop l2AmmWrapper.
|
||||
* @param targetChainId 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 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 amountOutMin minimum amount of token out for swap
|
||||
* @param deadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge, zero for L1 bridging
|
||||
* @param destinationDeadline The deadline for the transaction (Recommended - Date.now() + 604800 (1 week)), zero for L1 bridging
|
||||
* @param sourceAmountOutMin minimum amount of token out for swap on source chain.
|
||||
* @param sourceDeadline The deadline for the source chain transaction (Recommended - Date.now() + 604800 (1 week))
|
||||
* @param destinationAmountOutMin minimum amount of token out for bridge on target chain, 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 {
|
||||
address token;
|
||||
address hopRouter;
|
||||
address router;
|
||||
address recipient;
|
||||
uint256 chainId;
|
||||
uint256 targetChainId;
|
||||
uint256 amount;
|
||||
uint256 bonderFee;
|
||||
uint256 amountOutMin;
|
||||
uint256 deadline;
|
||||
uint256 sourceAmountOutMin;
|
||||
uint256 sourceDeadline;
|
||||
uint256 destinationAmountOutMin;
|
||||
uint256 destinationDeadline;
|
||||
}
|
||||
|
||||
function _swapAndSend(BridgeParams memory params) internal {
|
||||
IHopRouter router = IHopRouter(params.hopRouter);
|
||||
IHopRouter router = IHopRouter(params.router);
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(params.token);
|
||||
approve(tokenContract, params.hopRouter, params.amount);
|
||||
approve(tokenContract, params.router, params.amount);
|
||||
|
||||
router.swapAndSend(
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline
|
||||
);
|
||||
|
|
|
@ -25,7 +25,7 @@ abstract contract Resolver is Helpers {
|
|||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
if (params.chainId == 1) {
|
||||
if (params.targetChainId == 1) {
|
||||
require(
|
||||
params.destinationAmountOutMin == 0,
|
||||
"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)";
|
||||
_eventParam = abi.encode(
|
||||
params.token,
|
||||
params.chainId,
|
||||
params.targetChainId,
|
||||
params.recipient,
|
||||
params.amount,
|
||||
params.bonderFee,
|
||||
params.amountOutMin,
|
||||
params.deadline,
|
||||
params.sourceAmountOutMin,
|
||||
params.sourceDeadline,
|
||||
params.destinationAmountOutMin,
|
||||
params.destinationDeadline,
|
||||
getId
|
||||
|
|
Loading…
Reference in New Issue
Block a user