dsa-connectors/contracts/optimism/connectors/approve-tokens-multisig/main.sol

38 lines
1.3 KiB
Solidity
Raw Normal View History

2023-09-01 13:15:49 +00:00
// SPDX-License-Identifier: MIT
2023-09-01 14:28:19 +00:00
pragma solidity ^0.7.0;
2023-09-01 13:15:49 +00:00
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
import "./events.sol";
import "./interface.sol";
contract ApproveTokensResolver is Events {
using SafeERC20 for IERC20;
IAvoFactoryMultisig public constant AVO_FACTORY = IAvoFactoryMultisig(0xe981E50c7c47F0Df8826B5ce3F533f5E4440e687);
function approveTokens(
address[] calldata tokens,
uint256[] calldata amounts,
uint32 index
) public returns (string memory _eventName, bytes memory _eventParam) {
require(tokens.length == amounts.length, "array-length-mismatch");
address avocadoAddress = AVO_FACTORY.computeAvocado(msg.sender, index);
for (uint256 i = 0; i < tokens.length; i++) {
uint256 allowanceAmount =
amounts[i] == type(uint256).max
? IERC20(tokens[i]).balanceOf(address(this))
: amounts[i];
IERC20(tokens[i]).safeApprove(avocadoAddress, allowanceAmount);
}
_eventName = "LogApproveTokensMultisig(address[],uint256[],uint32)";
_eventParam = abi.encode(tokens, amounts, index);
}
}
2023-09-01 14:28:19 +00:00
contract ConnectV2ApproveTokensMultisigOptimism is ApproveTokensResolver {
2023-09-01 13:15:49 +00:00
string constant public name = "ApproveTokens-v1";
}