{ "language": "Solidity", "sources": { "src/actions/ActionBase.sol": { "content": "/**\n * Created by Pragma Labs\n * SPDX-License-Identifier: BUSL-1.1\n */\npragma solidity ^0.8.13;\n\nimport { ActionData } from \"../actions/utils/ActionData.sol\";\n\nabstract contract ActionBase {\n /**\n * @notice Calls a series of addresses with arbitrary calldata.\n * @param actionData A bytes object containing two actionAssetData structs, an address array and a bytes array.\n * @return resultData An actionAssetData struct with the balances of this ActionMultiCall address.\n */\n function executeAction(bytes calldata actionData) external virtual returns (ActionData memory resultData) { }\n}\n" }, "src/actions/MultiCall.sol": { "content": "/**\n * Created by Pragma Labs\n * SPDX-License-Identifier: BUSL-1.1\n */\npragma solidity ^0.8.13;\n\nimport { ActionBase, ActionData } from \"./ActionBase.sol\";\nimport { IERC20 } from \"../interfaces/IERC20.sol\";\nimport { IERC1155 } from \"../interfaces/IERC1155.sol\";\n\n/**\n * @title Generic multicall action\n * @author Pragma Labs\n * @notice Calls any external contract with arbitrary data.\n * @dev Only calls are used, no delegatecalls.\n * @dev This address will approve random addresses. Do not store any funds on this address!\n */\ncontract ActionMultiCall is ActionBase {\n /* //////////////////////////////////////////////////////////////\n CONSTRUCTOR\n ////////////////////////////////////////////////////////////// */\n\n constructor() { }\n\n /* //////////////////////////////////////////////////////////////\n ACTION LOGIC\n ////////////////////////////////////////////////////////////// */\n\n /**\n * @notice Calls a series of addresses with arbitrary calldata.\n * @param actionData A bytes object containing two actionAssetData structs, an address array and a bytes array.\n * @return resultData An actionAssetData struct with the balances of this ActionMultiCall address.\n * @dev input address is not used in this generic action.\n */\n function executeAction(bytes calldata actionData) external override returns (ActionData memory) {\n (, ActionData memory incoming, address[] memory to, bytes[] memory data) =\n abi.decode(actionData, (ActionData, ActionData, address[], bytes[]));\n\n uint256 callLength = to.length;\n\n require(data.length == callLength, \"EA: Length mismatch\");\n\n for (uint256 i; i < callLength;) {\n (bool success, bytes memory result) = to[i].call(data[i]);\n require(success, string(result));\n\n unchecked {\n ++i;\n }\n }\n\n for (uint256 i; i < incoming.assets.length;) {\n if (incoming.assetTypes[i] == 0) {\n incoming.assetAmounts[i] = IERC20(incoming.assets[i]).balanceOf(address(this));\n } else if (incoming.assetTypes[i] == 1) {\n incoming.assetAmounts[i] = 1;\n } else if (incoming.assetTypes[i] == 2) {\n incoming.assetAmounts[i] = IERC1155(incoming.assets[i]).balanceOf(address(this), incoming.assetIds[i]);\n }\n unchecked {\n ++i;\n }\n }\n\n return incoming;\n }\n\n /* //////////////////////////////////////////////////////////////\n HELPER FUNCTIONS\n ////////////////////////////////////////////////////////////// */\n\n /**\n * @notice Repays an exact amount to a creditor.\n * @param creditor The contract address of the creditor.\n * @param asset The contract address of the asset that is being repaid.\n * @param vault The contract address of the vault for which the debt is being repaid.\n * @param amount The amount of debt to.\n * @dev Can be called as one of the calls in executeAction, but fetches the actual contract balance after other DeFi interactions.\n */\n function executeRepay(address creditor, address asset, address vault, uint256 amount) external {\n if (amount < 1) {\n amount = IERC20(asset).balanceOf(address(this));\n }\n\n (bool success, bytes memory data) =\n creditor.call(abi.encodeWithSignature(\"repay(uint256,address)\", amount, vault));\n require(success, string(data));\n }\n}\n" }, "src/actions/utils/ActionData.sol": { "content": "/**\n * Created by Pragma Labs\n * SPDX-License-Identifier: BUSL-1.1\n */\npragma solidity ^0.8.13;\n\n// Struct with information to pass to and from actionHandlers.\nstruct ActionData {\n address[] assets; // Array of the contract addresses of the assets.\n uint256[] assetIds; // Array of the IDs of the assets.\n uint256[] assetAmounts; // Array with the amounts of the assets.\n uint256[] assetTypes; // Array with the types of the assets.\n uint256[] actionBalances; // Array with the balances of the actionHandler.\n}\n" }, "src/interfaces/IERC1155.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IERC1155 {\n function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;\n\n function balanceOf(address account, uint256 id) external view returns (uint256);\n}\n" }, "src/interfaces/IERC20.sol": { "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.13;\n\ninterface IERC20 {\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n\n function transfer(address to, uint256 amount) external returns (bool);\n\n function balanceOf(address owner) external view returns (uint256);\n\n function decimals() external view returns (uint256);\n}\n" } }, "settings": { "remappings": [ "arcadia-lending/=lib/arcadia-lending/", "ds-test/=lib/ds-test/src/", "forge-std/=lib/forge-std/src/", "solmate/=lib/solmate/src/", "v2-periphery/=lib/v2-periphery/contracts/" ], "optimizer": { "enabled": true, "runs": 200 }, "metadata": { "bytecodeHash": "ipfs" }, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } }, "evmVersion": "london", "libraries": {} } }