zellic-audit
Initial commit
f998fcd
raw
history blame
81.4 kB
{
"language": "Solidity",
"sources": {
"contracts/MagpieRouter.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport \"./interfaces/balancer-v2/IVault.sol\";\nimport \"./interfaces/uniswap-v2/IUniswapV2Router02.sol\";\nimport \"./interfaces/uniswap-v3/IUniswapV3Router.sol\";\nimport \"./lib/LibAsset.sol\";\nimport \"./lib/LibBytes.sol\";\nimport \"./lib/LibSwap.sol\";\nimport \"./interfaces/IWETH.sol\";\n\ncontract MagpieRouter is ReentrancyGuard, Ownable, IMagpieRouter {\n using LibSwap for IMagpieRouter.SwapArgs;\n using LibAsset for address;\n using LibBytes for bytes;\n address public magpieCoreAddress;\n\n mapping(uint16 => Amm) private amms;\n\n modifier onlyMagpieCore() {\n require(\n msg.sender == magpieCoreAddress,\n \"MagpieRouter: only MagpieCore allowed\"\n );\n _;\n }\n\n function updateMagpieCore(address _magpieCoreAddress)\n external\n override\n onlyOwner\n {\n magpieCoreAddress = _magpieCoreAddress;\n }\n\n function updateAmms(Amm[] calldata _amms) external override onlyOwner {\n require(_amms.length > 0, \"MagpieRouter: invalid amms\");\n for (uint256 i = 0; i < _amms.length; i++) {\n Amm memory amm = Amm({\n id: _amms[i].id,\n index: _amms[i].index,\n protocolIndex: _amms[i].protocolIndex\n });\n\n require(amm.id != address(0), \"MagpieRouter: invalid amm address\");\n require(amm.index > 0, \"MagpieRouter: invalid amm index\");\n require(\n amm.protocolIndex > 0,\n \"MagpieRouter: invalid amm protocolIndex\"\n );\n\n amms[amm.index] = amm;\n }\n\n emit AmmsUpdated(_amms, msg.sender);\n }\n\n receive() external payable {}\n\n function withdraw(address weth, uint256 amount) external onlyMagpieCore override {\n IWETH(weth).withdraw(amount);\n (bool success, ) = msg.sender.call{value: amount}(new bytes(0));\n require(success, \"MagpieRouter: eth transfer failed\");\n }\n\n function swap(SwapArgs memory swapArgs)\n external\n override\n onlyMagpieCore\n returns (uint256[] memory amountOuts)\n {\n amountOuts = new uint256[](swapArgs.routes.length);\n address fromAssetAddress = swapArgs.getFromAssetAddress();\n address toAssetAddress = swapArgs.getToAssetAddress();\n uint256 startingBalance = toAssetAddress.getBalance();\n uint256 amountIn = swapArgs.getAmountIn();\n\n for (uint256 i = 0; i < swapArgs.routes.length; i++) {\n Route memory route = swapArgs.routes[i];\n Hop memory firstHop = route.hops[0];\n Hop memory lastHop = route.hops[route.hops.length - 1];\n require(\n fromAssetAddress == swapArgs.assets[firstHop.path[0]],\n \"MagpieRouter: invalid fromAssetAddress\"\n );\n require(\n toAssetAddress ==\n swapArgs.assets[lastHop.path[lastHop.path.length - 1]],\n \"MagpieRouter: invalid toAssetAddress\"\n );\n\n amountOuts[i] = _swapRoute(\n route,\n swapArgs.assets,\n swapArgs.deadline\n );\n }\n\n uint256 amountOut = 0;\n for (uint256 i = 0; i < amountOuts.length; i++) {\n amountOut += amountOuts[i];\n }\n\n if (fromAssetAddress == toAssetAddress) {\n startingBalance -= amountIn;\n }\n\n require(\n toAssetAddress.getBalance() == startingBalance + amountOut,\n \"MagpieRouter: invalid amountOut\"\n );\n\n for (uint256 j = 0; j < swapArgs.assets.length; j++) {\n require(\n swapArgs.assets[j] != address(0),\n \"MagpieRouter: invalid asset - address0\"\n );\n }\n\n require(\n amountOut >= swapArgs.amountOutMin,\n \"MagpieRouter: insufficient output amount\"\n );\n\n toAssetAddress.transfer(payable(msg.sender), amountOut);\n }\n\n function _swapRoute(\n Route memory route,\n address[] memory assets,\n uint256 deadline\n ) private returns (uint256) {\n require(route.hops.length > 0, \"MagpieRouter: invalid hop size\");\n uint256 lastAmountOut = 0;\n\n for (uint256 i = 0; i < route.hops.length; i++) {\n uint256 amountIn = i == 0 ? route.amountIn : lastAmountOut;\n Hop memory hop = route.hops[i];\n address toAssetAddress = assets[hop.path[hop.path.length - 1]];\n uint256 beforeSwapBalance = toAssetAddress.getBalance();\n _swapHop(amountIn, hop, assets, deadline);\n uint256 afterSwapBalance = toAssetAddress.getBalance();\n lastAmountOut = afterSwapBalance - beforeSwapBalance;\n }\n\n return lastAmountOut;\n }\n\n function _swapHop(\n uint256 amountIn,\n Hop memory hop,\n address[] memory assets,\n uint256 deadline\n ) private {\n Amm memory amm = amms[hop.ammIndex];\n\n require(amm.id != address(0), \"MagpieRouter: invalid amm\");\n require(hop.path.length > 1, \"MagpieRouter: invalid path size\");\n address fromAssetAddress = assets[hop.path[0]];\n\n if (fromAssetAddress.getAllowance(address(this), amm.id) < amountIn) {\n fromAssetAddress.approve(amm.id, type(uint256).max);\n }\n\n if (amm.protocolIndex == 1) {\n _swapUniswapV2(amountIn, hop, assets, deadline);\n } else if (amm.protocolIndex == 2 || amm.protocolIndex == 3) {\n _swapBalancerV2(amountIn, hop, assets, deadline);\n } else if (amm.protocolIndex == 6) {\n _swapUniswapV3(amountIn, hop, assets, deadline);\n }\n }\n\n function _swapUniswapV2(\n uint256 amountIn,\n Hop memory hop,\n address[] memory assets,\n uint256 deadline\n ) private {\n Amm memory amm = amms[hop.ammIndex];\n address[] memory path = new address[](hop.path.length);\n for (uint256 i = 0; i < hop.path.length; i++) {\n path[i] = assets[hop.path[i]];\n }\n IUniswapV2Router02(amm.id).swapExactTokensForTokens(\n amountIn,\n 0,\n path,\n address(this),\n deadline\n );\n }\n\n function _swapUniswapV3(\n uint256 amountIn,\n Hop memory hop,\n address[] memory assets,\n uint256 deadline\n ) private {\n Amm memory amm = amms[hop.ammIndex];\n uint256 poolIdIndex = 0;\n bytes memory path;\n for (uint256 i = 0; i < hop.path.length; i++) {\n path = bytes.concat(path, abi.encodePacked(assets[hop.path[i]]));\n if (i < hop.path.length - 1) {\n path = bytes.concat(\n path,\n abi.encodePacked(hop.poolData.toUint24(poolIdIndex))\n );\n poolIdIndex += 3;\n }\n }\n require(\n hop.poolData.length == poolIdIndex,\n \"MagpieRouter: poolData is invalid\"\n );\n\n IUniswapV3Router.ExactInputParams memory params = IUniswapV3Router\n .ExactInputParams(path, address(this), deadline, amountIn, 0);\n IUniswapV3Router(amm.id).exactInput(params);\n }\n\n function _swapBalancerV2(\n uint256 amountIn,\n Hop memory hop,\n address[] memory assets,\n uint256 deadline\n ) private {\n Amm memory amm = amms[hop.ammIndex];\n IVault.BatchSwapStep[] memory swaps = new IVault.BatchSwapStep[](\n hop.path.length - 1\n );\n uint256 poolIdIndex = 0;\n IAsset[] memory balancerAssets = new IAsset[](hop.path.length);\n int256[] memory limits = new int256[](hop.path.length);\n for (uint256 i = 0; i < hop.path.length - 1; i++) {\n swaps[i] = IVault.BatchSwapStep({\n poolId: hop.poolData.toBytes32(poolIdIndex),\n assetInIndex: i,\n assetOutIndex: i + 1,\n amount: i == 0 ? amountIn : 0,\n userData: \"0x\"\n });\n poolIdIndex += 32;\n balancerAssets[i] = IAsset(assets[hop.path[i]]);\n limits[i] = i == 0 ? int256(amountIn) : int256(0);\n\n if (i == hop.path.length - 2) {\n balancerAssets[i + 1] = IAsset(assets[hop.path[i + 1]]);\n limits[i + 1] = int256(0);\n }\n }\n require(\n hop.poolData.length == poolIdIndex,\n \"MagpieRouter: poolData is invalid\"\n );\n IVault.FundManagement memory funds = IVault.FundManagement({\n sender: address(this),\n fromInternalBalance: false,\n recipient: payable(address(this)),\n toInternalBalance: false\n });\n\n IVault(amm.id).batchSwap(\n IVault.SwapKind.GIVEN_IN,\n swaps,\n balancerAssets,\n funds,\n limits,\n deadline\n );\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/IERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts/access/Ownable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n constructor() {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions anymore. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby removing any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n}\n"
},
"@openzeppelin/contracts/security/ReentrancyGuard.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n // Booleans are more expensive than uint256 or any type that takes up a full\n // word because each write operation emits an extra SLOAD to first read the\n // slot's contents, replace the bits taken up by the boolean, and then write\n // back. This is the compiler's defense against contract upgrades and\n // pointer aliasing, and it cannot be disabled.\n\n // The values being non-zero value makes deployment a bit more expensive,\n // but in exchange the refund on every call to nonReentrant will be lower in\n // amount. Since refunds are capped to a percentage of the total\n // transaction's gas, it is best to keep them low in cases like this one, to\n // increase the likelihood of the full refund coming into effect.\n uint256 private constant _NOT_ENTERED = 1;\n uint256 private constant _ENTERED = 2;\n\n uint256 private _status;\n\n constructor() {\n _status = _NOT_ENTERED;\n }\n\n /**\n * @dev Prevents a contract from calling itself, directly or indirectly.\n * Calling a `nonReentrant` function from another `nonReentrant`\n * function is not supported. It is possible to prevent this from happening\n * by making the `nonReentrant` function external, and making it call a\n * `private` function that does the actual work.\n */\n modifier nonReentrant() {\n // On the first call to nonReentrant, _notEntered will be true\n require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n // Any calls to nonReentrant after this point will fail\n _status = _ENTERED;\n\n _;\n\n // By storing the original value once again, a refund is triggered (see\n // https://eips.ethereum.org/EIPS/eip-2200)\n _status = _NOT_ENTERED;\n }\n}\n"
},
"contracts/interfaces/balancer-v2/IVault.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nimport \"./IAsset.sol\";\n\ninterface IVault {\n\n enum SwapKind { GIVEN_IN, GIVEN_OUT }\n\n function swap(\n SingleSwap memory singleSwap,\n FundManagement memory funds,\n uint256 limit,\n uint256 deadline\n ) external payable returns (uint256);\n\n struct SingleSwap {\n bytes32 poolId;\n SwapKind kind;\n IAsset assetIn;\n IAsset assetOut;\n uint256 amount;\n bytes userData;\n }\n\n function batchSwap(\n SwapKind kind,\n BatchSwapStep[] memory swaps,\n IAsset[] memory assets,\n FundManagement memory funds,\n int256[] memory limits,\n uint256 deadline\n ) external payable returns (int256[] memory);\n\n struct BatchSwapStep {\n bytes32 poolId;\n uint256 assetInIndex;\n uint256 assetOutIndex;\n uint256 amount;\n bytes userData;\n }\n\n struct FundManagement {\n address sender;\n bool fromInternalBalance;\n address payable recipient;\n bool toInternalBalance;\n }\n\n function queryBatchSwap(\n SwapKind kind,\n BatchSwapStep[] memory swaps,\n IAsset[] memory assets,\n FundManagement memory funds\n ) external returns (int256[] memory assetDeltas);\n\n}\n"
},
"contracts/interfaces/uniswap-v2/IUniswapV2Router02.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.6.2;\n\nimport \"./IUniswapV2Router01.sol\";\n\ninterface IUniswapV2Router02 is IUniswapV2Router01 {\n function removeLiquidityETHSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountETH);\n\n function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountETH);\n\n function swapExactTokensForTokensSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n\n function swapExactETHForTokensSupportingFeeOnTransferTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable;\n\n function swapExactTokensForETHSupportingFeeOnTransferTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external;\n}\n"
},
"contracts/interfaces/uniswap-v3/IUniswapV3Router.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.6.2;\n\ninterface IUniswapV3Router{\n struct ExactInputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactInputSingleParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInputSingle(ExactInputSingleParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactInputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountIn;\n uint256 amountOutMinimum;\n }\n\n /// @notice Swaps `amountIn` of one token for as much as possible of another along the specified path\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactInputParams` in calldata\n /// @return amountOut The amount of the received token\n function exactInput(ExactInputParams calldata params) external payable returns (uint256 amountOut);\n\n struct ExactOutputSingleParams {\n address tokenIn;\n address tokenOut;\n uint24 fee;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n uint160 sqrtPriceLimitX96;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another token\n /// @param params The parameters necessary for the swap, encoded as `ExactOutputSingleParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutputSingle(ExactOutputSingleParams calldata params) external payable returns (uint256 amountIn);\n\n struct ExactOutputParams {\n bytes path;\n address recipient;\n uint256 deadline;\n uint256 amountOut;\n uint256 amountInMaximum;\n }\n\n /// @notice Swaps as little as possible of one token for `amountOut` of another along the specified path (reversed)\n /// @param params The parameters necessary for the multi-hop swap, encoded as `ExactOutputParams` in calldata\n /// @return amountIn The amount of the input token\n function exactOutput(ExactOutputParams calldata params) external payable returns (uint256 amountIn);\n}\n"
},
"contracts/lib/LibAsset.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"@openzeppelin/contracts/utils/Address.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\nlibrary LibAsset {\n using LibAsset for address;\n\n address constant NATIVE_ASSETID = address(0);\n\n function isNative(address self) internal pure returns (bool) {\n return self == NATIVE_ASSETID;\n }\n\n function getBalance(address self) internal view returns (uint256) {\n return\n self.isNative()\n ? address(this).balance\n : IERC20(self).balanceOf(address(this));\n }\n\n function transferFrom(\n address self,\n address from,\n address to,\n uint256 amount\n ) internal {\n SafeERC20.safeTransferFrom(IERC20(self), from, to, amount);\n }\n\n function increaseAllowance(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be increased for native asset\"\n );\n SafeERC20.safeIncreaseAllowance(IERC20(self), spender, amount);\n }\n\n function decreaseAllowance(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be decreased for native asset\"\n );\n SafeERC20.safeDecreaseAllowance(IERC20(self), spender, amount);\n }\n\n function transfer(\n address self,\n address payable recipient,\n uint256 amount\n ) internal {\n self.isNative()\n ? Address.sendValue(recipient, amount)\n : SafeERC20.safeTransfer(IERC20(self), recipient, amount);\n }\n\n function approve(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be increased for native asset\"\n );\n SafeERC20.safeApprove(IERC20(self), spender, amount);\n }\n\n function getAllowance(\n address self,\n address owner,\n address spender\n ) internal view returns (uint256) {\n return IERC20(self).allowance(owner, spender);\n }\n}\n"
},
"contracts/lib/LibBytes.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\nimport \"../interfaces/IMagpieBridge.sol\";\n\nlibrary LibBytes {\n using LibBytes for bytes;\n\n function toAddress(bytes memory self, uint256 start)\n internal\n pure\n returns (address)\n {\n return address(uint160(uint256(self.toBytes32(start))));\n }\n\n function toBool(bytes memory self, uint256 start)\n internal\n pure\n returns (bool)\n {\n return self.toUint8(start) == 1 ? true : false;\n }\n\n function toUint8(bytes memory self, uint256 start)\n internal\n pure\n returns (uint8)\n {\n require(self.length >= start + 1, \"LibBytes: toUint8 outOfBounds\");\n uint8 tempUint;\n\n assembly {\n tempUint := mload(add(add(self, 0x1), start))\n }\n\n return tempUint;\n }\n\n function toUint16(bytes memory self, uint256 start)\n internal\n pure\n returns (uint16)\n {\n require(self.length >= start + 2, \"LibBytes: toUint16 outOfBounds\");\n uint16 tempUint;\n\n assembly {\n tempUint := mload(add(add(self, 0x2), start))\n }\n\n return tempUint;\n }\n\n function toUint24(bytes memory self, uint256 start)\n internal\n pure\n returns (uint24)\n {\n require(self.length >= start + 3, \"LibBytes: toUint24 outOfBounds\");\n uint24 tempUint;\n\n assembly {\n tempUint := mload(add(add(self, 0x3), start))\n }\n\n return tempUint;\n }\n\n function toUint64(bytes memory self, uint256 start)\n internal\n pure\n returns (uint64)\n {\n require(self.length >= start + 8, \"LibBytes: toUint64 outOfBounds\");\n uint64 tempUint;\n\n assembly {\n tempUint := mload(add(add(self, 0x8), start))\n }\n\n return tempUint;\n }\n\n function toUint256(bytes memory self, uint256 start)\n internal\n pure\n returns (uint256)\n {\n require(self.length >= start + 32, \"LibBytes: toUint256 outOfBounds\");\n uint256 tempUint;\n\n assembly {\n tempUint := mload(add(add(self, 0x20), start))\n }\n\n return tempUint;\n }\n\n function toBytes32(bytes memory self, uint256 start)\n internal\n pure\n returns (bytes32)\n {\n require(self.length >= start + 32, \"LibBytes: toBytes32 outOfBounds\");\n bytes32 tempBytes32;\n\n assembly {\n tempBytes32 := mload(add(add(self, 0x20), start))\n }\n\n return tempBytes32;\n }\n\n function toBridgeType(bytes memory self, uint256 start)\n internal\n pure\n returns (IMagpieBridge.BridgeType)\n {\n return\n self.toUint8(start) == 0\n ? IMagpieBridge.BridgeType.Wormhole\n : IMagpieBridge.BridgeType.Stargate;\n }\n\n function parse(bytes memory self)\n internal\n pure\n returns (IMagpieBridge.ValidationOutPayload memory payload)\n {\n uint256 i = 0;\n\n payload.fromAssetAddress = self.toAddress(i);\n i += 32;\n\n payload.toAssetAddress = self.toAddress(i);\n i += 32;\n\n payload.to = self.toAddress(i);\n i += 32;\n\n payload.recipientCoreAddress = self.toAddress(i);\n i += 32;\n\n payload.senderCoreAddress = self.toBytes32(i);\n i += 32;\n\n payload.amountOutMin = self.toUint256(i);\n i += 32;\n\n payload.swapOutGasFee = self.toUint256(i);\n i += 32;\n\n payload.amountIn = self.toUint256(i);\n i += 32;\n\n payload.tokenSequence = self.toUint64(i);\n i += 8;\n\n payload.senderIntermediaryDecimals = self.toUint8(i);\n i += 1;\n\n payload.senderNetworkId = self.toUint8(i);\n i += 1;\n\n payload.recipientNetworkId = self.toUint8(i);\n i += 1;\n\n payload.bridgeType = self.toBridgeType(i);\n i += 1;\n\n require(self.length == i, \"LibBytes: payload is invalid\");\n }\n\n function parseSgPayload(bytes memory self)\n internal\n pure\n returns (uint8 networkId, bytes32 sender, uint64 coreSequence)\n {\n uint256 i = 0;\n networkId = self.toUint8(i);\n i += 1;\n sender = self.toBytes32(i);\n i += 32;\n coreSequence = self.toUint64(i);\n i += 8;\n require(self.length == i, \"LibBytes: payload is invalid\");\n }\n}\n"
},
"contracts/lib/LibSwap.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"../interfaces/IMagpieCore.sol\";\nimport \"../interfaces/IMagpieRouter.sol\";\nimport \"../interfaces/IWETH.sol\";\nimport \"./LibAssetUpgradeable.sol\";\n\nlibrary LibSwap {\n using LibAssetUpgradeable for address;\n using LibSwap for IMagpieRouter.SwapArgs;\n\n function getFromAssetAddress(IMagpieRouter.SwapArgs memory self)\n internal\n pure\n returns (address)\n {\n return self.assets[self.routes[0].hops[0].path[0]];\n }\n\n function getToAssetAddress(IMagpieRouter.SwapArgs memory self)\n internal\n pure\n returns (address)\n {\n IMagpieRouter.Hop memory hop = self.routes[0].hops[\n self.routes[0].hops.length - 1\n ];\n return self.assets[hop.path[hop.path.length - 1]];\n }\n\n function getAmountIn(IMagpieRouter.SwapArgs memory self)\n internal\n pure\n returns (uint256)\n {\n uint256 amountIn = 0;\n\n for (uint256 i = 0; i < self.routes.length; i++) {\n amountIn += self.routes[i].amountIn;\n }\n\n return amountIn;\n }\n}\n"
},
"contracts/interfaces/IWETH.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.5.0;\n\ninterface IWETH {\n function deposit() external payable;\n function transfer(address to, uint value) external returns (bool);\n function withdraw(uint) external;\n}\n"
},
"@openzeppelin/contracts/utils/Context.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n}\n"
},
"contracts/interfaces/balancer-v2/IAsset.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @dev This is an empty interface used to represent either ERC20-conforming token contracts or ETH (using the zero\n * address sentinel value). We're just relying on the fact that `interface` can be used to declare new address-like\n * types.\n *\n * This concept is unrelated to a Pool's Asset Managers.\n */\ninterface IAsset {\n}\n"
},
"contracts/interfaces/uniswap-v2/IUniswapV2Router01.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.6.2;\n\ninterface IUniswapV2Router01 {\n function factory() external pure returns (address);\n\n function WETH() external pure returns (address);\n\n function addLiquidity(\n address tokenA,\n address tokenB,\n uint256 amountADesired,\n uint256 amountBDesired,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n )\n external\n returns (\n uint256 amountA,\n uint256 amountB,\n uint256 liquidity\n );\n\n function addLiquidityETH(\n address token,\n uint256 amountTokenDesired,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n )\n external\n payable\n returns (\n uint256 amountToken,\n uint256 amountETH,\n uint256 liquidity\n );\n\n function removeLiquidity(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETH(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function removeLiquidityWithPermit(\n address tokenA,\n address tokenB,\n uint256 liquidity,\n uint256 amountAMin,\n uint256 amountBMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountA, uint256 amountB);\n\n function removeLiquidityETHWithPermit(\n address token,\n uint256 liquidity,\n uint256 amountTokenMin,\n uint256 amountETHMin,\n address to,\n uint256 deadline,\n bool approveMax,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external returns (uint256 amountToken, uint256 amountETH);\n\n function swapExactTokensForTokens(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapTokensForExactTokens(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactETHForTokens(\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function swapTokensForExactETH(\n uint256 amountOut,\n uint256 amountInMax,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapExactTokensForETH(\n uint256 amountIn,\n uint256 amountOutMin,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external returns (uint256[] memory amounts);\n\n function swapETHForExactTokens(\n uint256 amountOut,\n address[] calldata path,\n address to,\n uint256 deadline\n ) external payable returns (uint256[] memory amounts);\n\n function quote(\n uint256 amountA,\n uint256 reserveA,\n uint256 reserveB\n ) external pure returns (uint256 amountB);\n\n function getAmountOut(\n uint256 amountIn,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountOut);\n\n function getAmountIn(\n uint256 amountOut,\n uint256 reserveIn,\n uint256 reserveOut\n ) external pure returns (uint256 amountIn);\n\n function getAmountsOut(uint256 amountIn, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n\n function getAmountsIn(uint256 amountOut, address[] calldata path)\n external\n view\n returns (uint256[] memory amounts);\n}\n"
},
"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n using Address for address;\n\n function safeTransfer(\n IERC20 token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20 token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20 token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20Permit token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20 token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
},
"@openzeppelin/contracts/utils/Address.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(isContract(target), \"Address: delegate call to non-contract\");\n\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
},
"contracts/interfaces/IMagpieBridge.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IMagpieBridge {\n enum BridgeType {\n Wormhole,\n Stargate\n }\n\n struct BridgeConfig {\n address stargateRouterAddress;\n address tokenBridgeAddress;\n address coreBridgeAddress;\n uint8 consistencyLevel;\n uint8 networkId;\n }\n\n struct BridgeArgs {\n bytes encodedVmBridge;\n bytes encodedVmCore;\n bytes senderStargateBridgeAddress;\n uint256 nonce;\n uint16 senderStargateChainId;\n }\n\n struct ValidationInPayload {\n bytes32 fromAssetAddress;\n bytes32 toAssetAddress;\n bytes32 to;\n bytes32 recipientCoreAddress;\n uint256 amountOutMin;\n uint256 layerZeroRecipientChainId;\n uint256 sourcePoolId;\n uint256 destPoolId;\n uint256 swapOutGasFee;\n uint16 recipientBridgeChainId;\n uint8 recipientNetworkId;\n }\n\n struct ValidationOutPayload {\n address fromAssetAddress;\n address toAssetAddress;\n address to;\n address recipientCoreAddress;\n bytes32 senderCoreAddress;\n uint256 amountOutMin;\n uint256 swapOutGasFee;\n uint256 amountIn;\n uint64 tokenSequence;\n uint8 senderIntermediaryDecimals;\n uint8 senderNetworkId;\n uint8 recipientNetworkId;\n BridgeType bridgeType;\n }\n\n function updateConfig(BridgeConfig calldata _bridgeConfig) external;\n\n function bridgeIn(\n BridgeType bridgeType,\n ValidationInPayload memory payload,\n uint256 amount,\n address toAssetAddress,\n address refundAddress\n )\n external\n payable\n returns (\n uint256 depositAmount,\n uint64 coreSequence,\n uint64 tokenSequence\n );\n\n function getPayload(bytes memory encodedVm)\n external\n view\n returns (ValidationOutPayload memory payload, uint64 sequence);\n\n function bridgeOut(\n ValidationOutPayload memory payload,\n BridgeArgs memory bridgeArgs,\n uint64 tokenSequence,\n address assetAddress\n ) external returns (uint256 amount);\n\n function updateMagpieCore(address _magpieCoreAddress) external;\n\n function adjustAssetDecimals(\n address assetAddress,\n uint8 fromDecimals,\n uint256 amountIn\n ) external view returns (uint256 amount);\n}\n"
},
"contracts/interfaces/IMagpieCore.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"./IMagpieRouter.sol\";\nimport \"./IMagpieBridge.sol\";\n\ninterface IMagpieCore {\n struct Config {\n address weth;\n address pauserAddress;\n address magpieRouterAddress;\n address magpieBridgeAddress;\n address stargateAddress;\n address tokenBridgeAddress;\n address coreBridgeAddress;\n uint8 consistencyLevel;\n uint8 networkId;\n }\n\n struct SwapInArgs {\n IMagpieRouter.SwapArgs swapArgs;\n IMagpieBridge.ValidationInPayload payload;\n IMagpieBridge.BridgeType bridgeType;\n }\n\n struct SwapOutArgs {\n IMagpieRouter.SwapArgs swapArgs;\n IMagpieBridge.BridgeArgs bridgeArgs;\n }\n\n struct WrapSwapConfig {\n bool transferFromSender;\n bool prepareFromAsset;\n bool prepareToAsset;\n bool unwrapToAsset;\n bool swap;\n }\n\n function updateConfig(Config calldata config) external;\n\n function swap(IMagpieRouter.SwapArgs calldata args)\n external\n payable\n returns (uint256[] memory amountOuts);\n\n function swapIn(SwapInArgs calldata swapArgs)\n external\n payable\n returns (\n uint256[] memory amountOuts,\n uint256 depositAmount,\n uint64,\n uint64\n );\n\n function swapOut(SwapOutArgs calldata args)\n external\n returns (uint256[] memory amountOuts);\n\n function sgReceive(\n uint16 senderChainId,\n bytes memory magpieBridgeAddress,\n uint256 nonce,\n address assetAddress,\n uint256 amount,\n bytes memory payload\n ) external;\n\n event ConfigUpdated(Config config, address caller);\n\n event Swapped(\n IMagpieRouter.SwapArgs swapArgs,\n uint256[] amountOuts,\n address caller\n );\n\n event SwappedIn(\n SwapInArgs args,\n uint256[] amountOuts,\n uint256 depositAmount,\n uint8 receipientNetworkId,\n uint64 coreSequence,\n uint64 tokenSequence,\n address caller\n );\n\n event SwappedOut(\n SwapOutArgs args,\n uint256[] amountOuts,\n uint8 senderNetworkId,\n uint64 coreSequence,\n address caller\n );\n\n event GasFeeWithdraw(\n address indexed tokenAddress,\n address indexed owner,\n uint256 indexed amount\n );\n}\n"
},
"contracts/interfaces/IMagpieRouter.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\ninterface IMagpieRouter {\n struct Amm {\n address id;\n uint16 index;\n uint8 protocolIndex;\n }\n\n struct Hop {\n uint16 ammIndex;\n uint8[] path;\n bytes poolData;\n }\n\n struct Route {\n uint256 amountIn;\n Hop[] hops;\n }\n\n struct SwapArgs {\n Route[] routes;\n address[] assets;\n address payable to;\n uint256 amountOutMin;\n uint256 deadline;\n }\n\n function updateAmms(Amm[] calldata amms) external;\n\n function swap(SwapArgs memory swapArgs)\n external\n returns (uint256[] memory amountOuts);\n\n function updateMagpieCore(address _magpieCoreAddress) external;\n\n function withdraw(address weth, uint256 amount) external;\n\n event AmmsUpdated(Amm[] amms, address caller);\n\n}\n"
},
"contracts/lib/LibAssetUpgradeable.sol": {
"content": "// SPDX-License-Identifier: Unlicense\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nlibrary LibAssetUpgradeable {\n using LibAssetUpgradeable for address;\n\n address constant NATIVE_ASSETID = address(0);\n\n function isNative(address self) internal pure returns (bool) {\n return self == NATIVE_ASSETID;\n }\n\n function getBalance(address self) internal view returns (uint256) {\n return\n self.isNative()\n ? address(this).balance\n : IERC20Upgradeable(self).balanceOf(address(this));\n }\n\n function transferFrom(\n address self,\n address from,\n address to,\n uint256 amount\n ) internal {\n SafeERC20Upgradeable.safeTransferFrom(IERC20Upgradeable(self), from, to, amount);\n }\n\n function increaseAllowance(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be increased for native asset\"\n );\n SafeERC20Upgradeable.safeIncreaseAllowance(IERC20Upgradeable(self), spender, amount);\n }\n\n function decreaseAllowance(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be decreased for native asset\"\n );\n SafeERC20Upgradeable.safeDecreaseAllowance(IERC20Upgradeable(self), spender, amount);\n }\n\n function transfer(\n address self,\n address payable recipient,\n uint256 amount\n ) internal {\n self.isNative()\n ? AddressUpgradeable.sendValue(recipient, amount)\n : SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(self), recipient, amount);\n }\n\n function approve(\n address self,\n address spender,\n uint256 amount\n ) internal {\n require(\n !self.isNative(),\n \"LibAsset: Allowance can't be increased for native asset\"\n );\n SafeERC20Upgradeable.safeApprove(IERC20Upgradeable(self), spender, amount);\n }\n\n function getAllowance(\n address self,\n address owner,\n address spender\n ) internal view returns (uint256) {\n return IERC20Upgradeable(self).allowance(owner, spender);\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20Upgradeable.sol\";\nimport \"../extensions/draft-IERC20PermitUpgradeable.sol\";\nimport \"../../../utils/AddressUpgradeable.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n function safeTransfer(\n IERC20Upgradeable token,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n function safeTransferFrom(\n IERC20Upgradeable token,\n address from,\n address to,\n uint256 value\n ) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n function safeIncreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n uint256 newAllowance = token.allowance(address(this), spender) + value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n\n function safeDecreaseAllowance(\n IERC20Upgradeable token,\n address spender,\n uint256 value\n ) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n uint256 newAllowance = oldAllowance - value;\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n }\n }\n\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n if (returndata.length > 0) {\n // Return data is optional\n require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length > 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCall(target, data, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance >= value, \"Address: insufficient balance for call\");\n require(isContract(target), \"Address: call to non-contract\");\n\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n require(isContract(target), \"Address: static call to non-contract\");\n\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResult(success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n // Look for revert reason and bubble it up if present\n if (returndata.length > 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n }\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(\n address from,\n address to,\n uint256 amount\n ) external returns (bool);\n}\n"
},
"@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-IERC20PermitUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
}
},
"settings": {
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"metadata": {
"useLiteralContent": true
},
"libraries": {}
}
}