{"sources":{"WeUSDMintRedeem.sol":{"content":"// File: @openzeppelin/contracts/token/ERC20/IERC20.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n/**\r\n * @dev Interface of the ERC-20 standard as defined in the ERC.\r\n */\r\ninterface IERC20 {\r\n    /**\r\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\r\n     * another (`to`).\r\n     *\r\n     * Note that `value` may be zero.\r\n     */\r\n    event Transfer(address indexed from, address indexed to, uint256 value);\r\n\r\n    /**\r\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\r\n     * a call to {approve}. `value` is the new allowance.\r\n     */\r\n    event Approval(address indexed owner, address indexed spender, uint256 value);\r\n\r\n    /**\r\n     * @dev Returns the value of tokens in existence.\r\n     */\r\n    function totalSupply() external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Returns the value of tokens owned by `account`.\r\n     */\r\n    function balanceOf(address account) external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * Emits a {Transfer} event.\r\n     */\r\n    function transfer(address to, uint256 value) external returns (bool);\r\n\r\n    /**\r\n     * @dev Returns the remaining number of tokens that `spender` will be\r\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\r\n     * zero by default.\r\n     *\r\n     * This value changes when {approve} or {transferFrom} are called.\r\n     */\r\n    function allowance(address owner, address spender) external view returns (uint256);\r\n\r\n    /**\r\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\r\n     * caller's tokens.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\r\n     * that someone may use both the old and the new allowance by unfortunate\r\n     * transaction ordering. One possible solution to mitigate this race\r\n     * condition is to first reduce the spender's allowance to 0 and set the\r\n     * desired value afterwards:\r\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\r\n     *\r\n     * Emits an {Approval} event.\r\n     */\r\n    function approve(address spender, uint256 value) external returns (bool);\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the\r\n     * allowance mechanism. `value` is then deducted from the caller's\r\n     * allowance.\r\n     *\r\n     * Returns a boolean value indicating whether the operation succeeded.\r\n     *\r\n     * Emits a {Transfer} event.\r\n     */\r\n    function transferFrom(address from, address to, uint256 value) external returns (bool);\r\n}\r\n\r\n// File: @openzeppelin/contracts/interfaces/IERC20.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)\r\n\r\npragma solidity >=0.4.16;\r\n\r\n\r\n// File: @openzeppelin/contracts/utils/introspection/IERC165.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)\r\n\r\npragma solidity >=0.4.16;\r\n\r\n/**\r\n * @dev Interface of the ERC-165 standard, as defined in the\r\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\r\n *\r\n * Implementers can declare support of contract interfaces, which can then be\r\n * queried by others ({ERC165Checker}).\r\n *\r\n * For an implementation, see {ERC165}.\r\n */\r\ninterface IERC165 {\r\n    /**\r\n     * @dev Returns true if this contract implements the interface defined by\r\n     * `interfaceId`. See the corresponding\r\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\r\n     * to learn more about how these ids are created.\r\n     *\r\n     * This function call must use less than 30 000 gas.\r\n     */\r\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\r\n}\r\n\r\n// File: @openzeppelin/contracts/interfaces/IERC165.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)\r\n\r\npragma solidity >=0.4.16;\r\n\r\n\r\n// File: @openzeppelin/contracts/interfaces/IERC1363.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)\r\n\r\npragma solidity >=0.6.2;\r\n\r\n\r\n\r\n/**\r\n * @title IERC1363\r\n * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].\r\n *\r\n * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract\r\n * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.\r\n */\r\ninterface IERC1363 is IERC20, IERC165 {\r\n    /*\r\n     * Note: the ERC-165 identifier for this interface is 0xb0202a11.\r\n     * 0xb0202a11 ===\r\n     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^\r\n     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^\r\n     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^\r\n     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^\r\n     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^\r\n     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))\r\n     */\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`\r\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\r\n     * @param to The address which you want to transfer to.\r\n     * @param value The amount of tokens to be transferred.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function transferAndCall(address to, uint256 value) external returns (bool);\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from the caller's account to `to`\r\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\r\n     * @param to The address which you want to transfer to.\r\n     * @param value The amount of tokens to be transferred.\r\n     * @param data Additional data with no specified format, sent in call to `to`.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\r\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\r\n     * @param from The address which you want to send tokens from.\r\n     * @param to The address which you want to transfer to.\r\n     * @param value The amount of tokens to be transferred.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);\r\n\r\n    /**\r\n     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism\r\n     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.\r\n     * @param from The address which you want to send tokens from.\r\n     * @param to The address which you want to transfer to.\r\n     * @param value The amount of tokens to be transferred.\r\n     * @param data Additional data with no specified format, sent in call to `to`.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);\r\n\r\n    /**\r\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\r\n     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\r\n     * @param spender The address which will spend the funds.\r\n     * @param value The amount of tokens to be spent.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function approveAndCall(address spender, uint256 value) external returns (bool);\r\n\r\n    /**\r\n     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the\r\n     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.\r\n     * @param spender The address which will spend the funds.\r\n     * @param value The amount of tokens to be spent.\r\n     * @param data Additional data with no specified format, sent in call to `spender`.\r\n     * @return A boolean value indicating whether the operation succeeded unless throwing.\r\n     */\r\n    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n\r\n\r\n/**\r\n * @title SafeERC20\r\n * @dev Wrappers around ERC-20 operations that throw on failure (when the token\r\n * contract returns false). Tokens that return no value (and instead revert or\r\n * throw on failure) are also supported, non-reverting calls are assumed to be\r\n * successful.\r\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\r\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\r\n */\r\nlibrary SafeERC20 {\r\n    /**\r\n     * @dev An operation with an ERC-20 token failed.\r\n     */\r\n    error SafeERC20FailedOperation(address token);\r\n\r\n    /**\r\n     * @dev Indicates a failed `decreaseAllowance` request.\r\n     */\r\n    error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);\r\n\r\n    /**\r\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\r\n     * non-reverting calls are assumed to be successful.\r\n     */\r\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\r\n        _callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));\r\n    }\r\n\r\n    /**\r\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\r\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\r\n     */\r\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\r\n        _callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));\r\n    }\r\n\r\n    /**\r\n     * @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.\r\n     */\r\n    function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {\r\n        return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));\r\n    }\r\n\r\n    /**\r\n     * @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.\r\n     */\r\n    function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {\r\n        return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));\r\n    }\r\n\r\n    /**\r\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\r\n     * non-reverting calls are assumed to be successful.\r\n     *\r\n     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\r\n     * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\r\n     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\r\n     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\r\n     */\r\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\r\n        uint256 oldAllowance = token.allowance(address(this), spender);\r\n        forceApprove(token, spender, oldAllowance + value);\r\n    }\r\n\r\n    /**\r\n     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no\r\n     * value, non-reverting calls are assumed to be successful.\r\n     *\r\n     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the \"client\"\r\n     * smart contract uses ERC-7674 to set temporary allowances, then the \"client\" smart contract should avoid using\r\n     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract\r\n     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.\r\n     */\r\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {\r\n        unchecked {\r\n            uint256 currentAllowance = token.allowance(address(this), spender);\r\n            if (currentAllowance < requestedDecrease) {\r\n                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);\r\n            }\r\n            forceApprove(token, spender, currentAllowance - requestedDecrease);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\r\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\r\n     * to be set to zero before setting it to a non-zero value, such as USDT.\r\n     *\r\n     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function\r\n     * only sets the \"standard\" allowance. Any temporary allowance will remain active, in addition to the value being\r\n     * set here.\r\n     */\r\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\r\n        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));\r\n\r\n        if (!_callOptionalReturnBool(token, approvalCall)) {\r\n            _callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));\r\n            _callOptionalReturn(token, approvalCall);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no\r\n     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\r\n     * targeting contracts.\r\n     *\r\n     * Reverts if the returned value is other than `true`.\r\n     */\r\n    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\r\n        if (to.code.length == 0) {\r\n            safeTransfer(token, to, value);\r\n        } else if (!token.transferAndCall(to, value, data)) {\r\n            revert SafeERC20FailedOperation(address(token));\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target\r\n     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\r\n     * targeting contracts.\r\n     *\r\n     * Reverts if the returned value is other than `true`.\r\n     */\r\n    function transferFromAndCallRelaxed(\r\n        IERC1363 token,\r\n        address from,\r\n        address to,\r\n        uint256 value,\r\n        bytes memory data\r\n    ) internal {\r\n        if (to.code.length == 0) {\r\n            safeTransferFrom(token, from, to, value);\r\n        } else if (!token.transferFromAndCall(from, to, value, data)) {\r\n            revert SafeERC20FailedOperation(address(token));\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no\r\n     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when\r\n     * targeting contracts.\r\n     *\r\n     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.\r\n     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}\r\n     * once without retrying, and relies on the returned value to be true.\r\n     *\r\n     * Reverts if the returned value is other than `true`.\r\n     */\r\n    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {\r\n        if (to.code.length == 0) {\r\n            forceApprove(token, to, value);\r\n        } else if (!token.approveAndCall(to, value, data)) {\r\n            revert SafeERC20FailedOperation(address(token));\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\r\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\r\n     * @param token The token targeted by the call.\r\n     * @param data The call data (encoded using abi.encode or one of its variants).\r\n     *\r\n     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.\r\n     */\r\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\r\n        uint256 returnSize;\r\n        uint256 returnValue;\r\n        assembly (\"memory-safe\") {\r\n            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\r\n            // bubble errors\r\n            if iszero(success) {\r\n                let ptr := mload(0x40)\r\n                returndatacopy(ptr, 0, returndatasize())\r\n                revert(ptr, returndatasize())\r\n            }\r\n            returnSize := returndatasize()\r\n            returnValue := mload(0)\r\n        }\r\n\r\n        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {\r\n            revert SafeERC20FailedOperation(address(token));\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\r\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\r\n     * @param token The token targeted by the call.\r\n     * @param data The call data (encoded using abi.encode or one of its variants).\r\n     *\r\n     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.\r\n     */\r\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\r\n        bool success;\r\n        uint256 returnSize;\r\n        uint256 returnValue;\r\n        assembly (\"memory-safe\") {\r\n            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)\r\n            returnSize := returndatasize()\r\n            returnValue := mload(0)\r\n        }\r\n        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);\r\n    }\r\n}\r\n\r\n// File: @openzeppelin/contracts/access/IAccessControl.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (access/IAccessControl.sol)\r\n\r\npragma solidity >=0.8.4;\r\n\r\n/**\r\n * @dev External interface of AccessControl declared to support ERC-165 detection.\r\n */\r\ninterface IAccessControl {\r\n    /**\r\n     * @dev The `account` is missing a role.\r\n     */\r\n    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);\r\n\r\n    /**\r\n     * @dev The caller of a function is not the expected one.\r\n     *\r\n     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.\r\n     */\r\n    error AccessControlBadConfirmation();\r\n\r\n    /**\r\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\r\n     *\r\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\r\n     * {RoleAdminChanged} not being emitted to signal this.\r\n     */\r\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\r\n\r\n    /**\r\n     * @dev Emitted when `account` is granted `role`.\r\n     *\r\n     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).\r\n     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.\r\n     */\r\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\r\n\r\n    /**\r\n     * @dev Emitted when `account` is revoked `role`.\r\n     *\r\n     * `sender` is the account that originated the contract call:\r\n     *   - if using `revokeRole`, it is the admin role bearer\r\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\r\n     */\r\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\r\n\r\n    /**\r\n     * @dev Returns `true` if `account` has been granted `role`.\r\n     */\r\n    function hasRole(bytes32 role, address account) external view returns (bool);\r\n\r\n    /**\r\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\r\n     * {revokeRole}.\r\n     *\r\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\r\n     */\r\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\r\n\r\n    /**\r\n     * @dev Grants `role` to `account`.\r\n     *\r\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\r\n     * event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must have ``role``'s admin role.\r\n     */\r\n    function grantRole(bytes32 role, address account) external;\r\n\r\n    /**\r\n     * @dev Revokes `role` from `account`.\r\n     *\r\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must have ``role``'s admin role.\r\n     */\r\n    function revokeRole(bytes32 role, address account) external;\r\n\r\n    /**\r\n     * @dev Revokes `role` from the calling account.\r\n     *\r\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\r\n     * purpose is to provide a mechanism for accounts to lose their privileges\r\n     * if they are compromised (such as when a trusted device is misplaced).\r\n     *\r\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\r\n     * event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must be `callerConfirmation`.\r\n     */\r\n    function renounceRole(bytes32 role, address callerConfirmation) external;\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/Context.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n/**\r\n * @dev Provides information about the current execution context, including the\r\n * sender of the transaction and its data. While these are generally available\r\n * via msg.sender and msg.data, they should not be accessed in such a direct\r\n * manner, since when dealing with meta-transactions the account sending and\r\n * paying for execution may not be the actual sender (as far as an application\r\n * is concerned).\r\n *\r\n * This contract is only required for intermediate, library-like contracts.\r\n */\r\nabstract contract Context {\r\n    function _msgSender() internal view virtual returns (address) {\r\n        return msg.sender;\r\n    }\r\n\r\n    function _msgData() internal view virtual returns (bytes calldata) {\r\n        return msg.data;\r\n    }\r\n\r\n    function _contextSuffixLength() internal view virtual returns (uint256) {\r\n        return 0;\r\n    }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/introspection/ERC165.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/ERC165.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n\r\n/**\r\n * @dev Implementation of the {IERC165} interface.\r\n *\r\n * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check\r\n * for the additional interface id that will be supported. For example:\r\n *\r\n * ```solidity\r\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\r\n * }\r\n * ```\r\n */\r\nabstract contract ERC165 is IERC165 {\r\n    /// @inheritdoc IERC165\r\n    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {\r\n        return interfaceId == type(IERC165).interfaceId;\r\n    }\r\n}\r\n\r\n// File: @openzeppelin/contracts/access/AccessControl.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.4.0) (access/AccessControl.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n\r\n\r\n\r\n/**\r\n * @dev Contract module that allows children to implement role-based access\r\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\r\n * members except through off-chain means by accessing the contract event logs. Some\r\n * applications may benefit from on-chain enumerability, for those cases see\r\n * {AccessControlEnumerable}.\r\n *\r\n * Roles are referred to by their `bytes32` identifier. These should be exposed\r\n * in the external API and be unique. The best way to achieve this is by\r\n * using `public constant` hash digests:\r\n *\r\n * ```solidity\r\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\r\n * ```\r\n *\r\n * Roles can be used to represent a set of permissions. To restrict access to a\r\n * function call, use {hasRole}:\r\n *\r\n * ```solidity\r\n * function foo() public {\r\n *     require(hasRole(MY_ROLE, msg.sender));\r\n *     ...\r\n * }\r\n * ```\r\n *\r\n * Roles can be granted and revoked dynamically via the {grantRole} and\r\n * {revokeRole} functions. Each role has an associated admin role, and only\r\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\r\n *\r\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\r\n * that only accounts with this role will be able to grant or revoke other\r\n * roles. More complex role relationships can be created by using\r\n * {_setRoleAdmin}.\r\n *\r\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\r\n * grant and revoke this role. Extra precautions should be taken to secure\r\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\r\n * to enforce additional security measures for this role.\r\n */\r\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\r\n    struct RoleData {\r\n        mapping(address account => bool) hasRole;\r\n        bytes32 adminRole;\r\n    }\r\n\r\n    mapping(bytes32 role => RoleData) private _roles;\r\n\r\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\r\n\r\n    /**\r\n     * @dev Modifier that checks that an account has a specific role. Reverts\r\n     * with an {AccessControlUnauthorizedAccount} error including the required role.\r\n     */\r\n    modifier onlyRole(bytes32 role) {\r\n        _checkRole(role);\r\n        _;\r\n    }\r\n\r\n    /// @inheritdoc IERC165\r\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\r\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\r\n    }\r\n\r\n    /**\r\n     * @dev Returns `true` if `account` has been granted `role`.\r\n     */\r\n    function hasRole(bytes32 role, address account) public view virtual returns (bool) {\r\n        return _roles[role].hasRole[account];\r\n    }\r\n\r\n    /**\r\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`\r\n     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.\r\n     */\r\n    function _checkRole(bytes32 role) internal view virtual {\r\n        _checkRole(role, _msgSender());\r\n    }\r\n\r\n    /**\r\n     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`\r\n     * is missing `role`.\r\n     */\r\n    function _checkRole(bytes32 role, address account) internal view virtual {\r\n        if (!hasRole(role, account)) {\r\n            revert AccessControlUnauthorizedAccount(account, role);\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\r\n     * {revokeRole}.\r\n     *\r\n     * To change a role's admin, use {_setRoleAdmin}.\r\n     */\r\n    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {\r\n        return _roles[role].adminRole;\r\n    }\r\n\r\n    /**\r\n     * @dev Grants `role` to `account`.\r\n     *\r\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\r\n     * event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must have ``role``'s admin role.\r\n     *\r\n     * May emit a {RoleGranted} event.\r\n     */\r\n    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\r\n        _grantRole(role, account);\r\n    }\r\n\r\n    /**\r\n     * @dev Revokes `role` from `account`.\r\n     *\r\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must have ``role``'s admin role.\r\n     *\r\n     * May emit a {RoleRevoked} event.\r\n     */\r\n    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {\r\n        _revokeRole(role, account);\r\n    }\r\n\r\n    /**\r\n     * @dev Revokes `role` from the calling account.\r\n     *\r\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\r\n     * purpose is to provide a mechanism for accounts to lose their privileges\r\n     * if they are compromised (such as when a trusted device is misplaced).\r\n     *\r\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\r\n     * event.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - the caller must be `callerConfirmation`.\r\n     *\r\n     * May emit a {RoleRevoked} event.\r\n     */\r\n    function renounceRole(bytes32 role, address callerConfirmation) public virtual {\r\n        if (callerConfirmation != _msgSender()) {\r\n            revert AccessControlBadConfirmation();\r\n        }\r\n\r\n        _revokeRole(role, callerConfirmation);\r\n    }\r\n\r\n    /**\r\n     * @dev Sets `adminRole` as ``role``'s admin role.\r\n     *\r\n     * Emits a {RoleAdminChanged} event.\r\n     */\r\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\r\n        bytes32 previousAdminRole = getRoleAdmin(role);\r\n        _roles[role].adminRole = adminRole;\r\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\r\n    }\r\n\r\n    /**\r\n     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.\r\n     *\r\n     * Internal function without access restriction.\r\n     *\r\n     * May emit a {RoleGranted} event.\r\n     */\r\n    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {\r\n        if (!hasRole(role, account)) {\r\n            _roles[role].hasRole[account] = true;\r\n            emit RoleGranted(role, account, _msgSender());\r\n            return true;\r\n        } else {\r\n            return false;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.\r\n     *\r\n     * Internal function without access restriction.\r\n     *\r\n     * May emit a {RoleRevoked} event.\r\n     */\r\n    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {\r\n        if (hasRole(role, account)) {\r\n            _roles[role].hasRole[account] = false;\r\n            emit RoleRevoked(role, account, _msgSender());\r\n            return true;\r\n        } else {\r\n            return false;\r\n        }\r\n    }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/Pausable.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n\r\n/**\r\n * @dev Contract module which allows children to implement an emergency stop\r\n * mechanism that can be triggered by an authorized account.\r\n *\r\n * This module is used through inheritance. It will make available the\r\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\r\n * the functions of your contract. Note that they will not be pausable by\r\n * simply including this module, only once the modifiers are put in place.\r\n */\r\nabstract contract Pausable is Context {\r\n    bool private _paused;\r\n\r\n    /**\r\n     * @dev Emitted when the pause is triggered by `account`.\r\n     */\r\n    event Paused(address account);\r\n\r\n    /**\r\n     * @dev Emitted when the pause is lifted by `account`.\r\n     */\r\n    event Unpaused(address account);\r\n\r\n    /**\r\n     * @dev The operation failed because the contract is paused.\r\n     */\r\n    error EnforcedPause();\r\n\r\n    /**\r\n     * @dev The operation failed because the contract is not paused.\r\n     */\r\n    error ExpectedPause();\r\n\r\n    /**\r\n     * @dev Modifier to make a function callable only when the contract is not paused.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The contract must not be paused.\r\n     */\r\n    modifier whenNotPaused() {\r\n        _requireNotPaused();\r\n        _;\r\n    }\r\n\r\n    /**\r\n     * @dev Modifier to make a function callable only when the contract is paused.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The contract must be paused.\r\n     */\r\n    modifier whenPaused() {\r\n        _requirePaused();\r\n        _;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns true if the contract is paused, and false otherwise.\r\n     */\r\n    function paused() public view virtual returns (bool) {\r\n        return _paused;\r\n    }\r\n\r\n    /**\r\n     * @dev Throws if the contract is paused.\r\n     */\r\n    function _requireNotPaused() internal view virtual {\r\n        if (paused()) {\r\n            revert EnforcedPause();\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Throws if the contract is not paused.\r\n     */\r\n    function _requirePaused() internal view virtual {\r\n        if (!paused()) {\r\n            revert ExpectedPause();\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @dev Triggers stopped state.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The contract must not be paused.\r\n     */\r\n    function _pause() internal virtual whenNotPaused {\r\n        _paused = true;\r\n        emit Paused(_msgSender());\r\n    }\r\n\r\n    /**\r\n     * @dev Returns to normal state.\r\n     *\r\n     * Requirements:\r\n     *\r\n     * - The contract must be paused.\r\n     */\r\n    function _unpause() internal virtual whenPaused {\r\n        _paused = false;\r\n        emit Unpaused(_msgSender());\r\n    }\r\n}\r\n\r\n// File: @openzeppelin/contracts/utils/ReentrancyGuard.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n/**\r\n * @dev Contract module that helps prevent reentrant calls to a function.\r\n *\r\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\r\n * available, which can be applied to functions to make sure there are no nested\r\n * (reentrant) calls to them.\r\n *\r\n * Note that because there is a single `nonReentrant` guard, functions marked as\r\n * `nonReentrant` may not call one another. This can be worked around by making\r\n * those functions `private`, and then adding `external` `nonReentrant` entry\r\n * points to them.\r\n *\r\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\r\n * consider using {ReentrancyGuardTransient} instead.\r\n *\r\n * TIP: If you would like to learn more about reentrancy and alternative ways\r\n * to protect against it, check out our blog post\r\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\r\n */\r\nabstract contract ReentrancyGuard {\r\n    // Booleans are more expensive than uint256 or any type that takes up a full\r\n    // word because each write operation emits an extra SLOAD to first read the\r\n    // slot's contents, replace the bits taken up by the boolean, and then write\r\n    // back. This is the compiler's defense against contract upgrades and\r\n    // pointer aliasing, and it cannot be disabled.\r\n\r\n    // The values being non-zero value makes deployment a bit more expensive,\r\n    // but in exchange the refund on every call to nonReentrant will be lower in\r\n    // amount. Since refunds are capped to a percentage of the total\r\n    // transaction's gas, it is best to keep them low in cases like this one, to\r\n    // increase the likelihood of the full refund coming into effect.\r\n    uint256 private constant NOT_ENTERED = 1;\r\n    uint256 private constant ENTERED = 2;\r\n\r\n    uint256 private _status;\r\n\r\n    /**\r\n     * @dev Unauthorized reentrant call.\r\n     */\r\n    error ReentrancyGuardReentrantCall();\r\n\r\n    constructor() {\r\n        _status = NOT_ENTERED;\r\n    }\r\n\r\n    /**\r\n     * @dev Prevents a contract from calling itself, directly or indirectly.\r\n     * Calling a `nonReentrant` function from another `nonReentrant`\r\n     * function is not supported. It is possible to prevent this from happening\r\n     * by making the `nonReentrant` function external, and making it call a\r\n     * `private` function that does the actual work.\r\n     */\r\n    modifier nonReentrant() {\r\n        _nonReentrantBefore();\r\n        _;\r\n        _nonReentrantAfter();\r\n    }\r\n\r\n    function _nonReentrantBefore() private {\r\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\r\n        if (_status == ENTERED) {\r\n            revert ReentrancyGuardReentrantCall();\r\n        }\r\n\r\n        // Any calls to nonReentrant after this point will fail\r\n        _status = ENTERED;\r\n    }\r\n\r\n    function _nonReentrantAfter() private {\r\n        // By storing the original value once again, a refund is triggered (see\r\n        // https://eips.ethereum.org/EIPS/eip-2200)\r\n        _status = NOT_ENTERED;\r\n    }\r\n\r\n    /**\r\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\r\n     * `nonReentrant` function in the call stack.\r\n     */\r\n    function _reentrancyGuardEntered() internal view returns (bool) {\r\n        return _status == ENTERED;\r\n    }\r\n}\r\n\r\n// File: contracts/weusd/IPicweUSD.sol\r\n\r\n\r\npragma solidity ^0.8.22;\r\n\r\n\r\n/**\r\n * @title IPicweUSD\r\n * @dev Interface for the PicweUSD token with additional mint and burn functions\r\n */\r\ninterface IPicweUSD is IERC20 {\r\n    function mint(address to, uint256 amount) external;\r\n    function burn(uint256 amount) external;\r\n    function burnFrom(address from, uint256 amount) external;\r\n    function decimals() external view returns (uint8);\r\n}\r\n\r\n// File: @openzeppelin/contracts/token/ERC20/extensions/IERC20Metadata.sol\r\n\r\n\r\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/extensions/IERC20Metadata.sol)\r\n\r\npragma solidity ^0.8.20;\r\n\r\n\r\n/**\r\n * @dev Interface for the optional metadata functions from the ERC-20 standard.\r\n */\r\ninterface IERC20Metadata is IERC20 {\r\n    /**\r\n     * @dev Returns the name of the token.\r\n     */\r\n    function name() external view returns (string memory);\r\n\r\n    /**\r\n     * @dev Returns the symbol of the token.\r\n     */\r\n    function symbol() external view returns (string memory);\r\n\r\n    /**\r\n     * @dev Returns the decimals places of the token.\r\n     */\r\n    function decimals() external view returns (uint8);\r\n}\r\n\r\n// File: contracts/weusd/WeUSDMintRedeem.sol\r\n\r\n\r\npragma solidity ^0.8.22;\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * @title WeUSDMintRedeem\r\n * @author WeUSD Protocol Team\r\n * @notice Contract for minting and redeeming WeUSD tokens with cross-chain support\r\n * @dev This contract manages the minting and redemption of WeUSD tokens backed by stablecoins,\r\n *      with integrated cross-chain reserve management and fee collection mechanisms.\r\n *      Uses role-based access control for administrative functions and reentrancy protection\r\n *      for all state-changing operations involving external calls.\r\n */\r\ncontract WeUSDMintRedeem is AccessControl, ReentrancyGuard, Pausable {\r\n    using SafeERC20 for IERC20;\r\n\r\n    /// @notice Role identifier for admin operations\r\n    bytes32 public constant ADMIN_ROLE = keccak256(\"ADMIN_ROLE\");\r\n    /// @notice Role identifier for balancer operations\r\n    bytes32 public constant BALANCER_ROLE = keccak256(\"BALANCER_ROLE\");\r\n    /// @notice Role identifier for cross-chain operations\r\n    bytes32 public constant CROSS_CHAIN_ROLE = keccak256(\"CROSS_CHAIN_ROLE\");\r\n    /// @notice Role identifier for withdrawal operations\r\n    bytes32 public constant WITHDRAW_ROLE = keccak256(\"WITHDRAW_ROLE\");\r\n    \r\n    /// @notice WeUSD token decimal places (immutable after deployment)\r\n    uint8 public constant WEUSD_DECIMALS = 6;\r\n    /// @notice Maximum fee ratio allowed (20% in basis points)\r\n    uint256 public constant MAX_FEE_RATIO = 2000;\r\n    /// @notice Minimum fee ratio allowed (0.1% in basis points)\r\n    uint256 public constant MIN_FEE_RATIO = 10;\r\n    /// @notice Maximum minimum amount (1000 WeUSD)\r\n    uint256 public constant MAX_MIN_AMOUNT = 1000000000;\r\n    /// @notice Minimum minimum amount (0.001 WeUSD)\r\n    uint256 public constant MIN_MIN_AMOUNT = 1000;\r\n    \r\n    /// @notice WeUSD token contract (immutable after deployment)\r\n    IPicweUSD public immutable weUSD;\r\n    /// @notice Stablecoin token contract used for backing\r\n    IERC20 public stablecoin;\r\n    /// @notice Decimal places of the stablecoin\r\n    uint8 public stablecoinDecimals;\r\n    /// @notice Cross-chain contract address for cross-chain operations\r\n    address public crossChainContract;\r\n    \r\n    /// @notice Address that receives transaction fees\r\n    address public feeRecipient;\r\n    /// @notice Fee ratio in basis points (100 = 1%)\r\n    uint256 public feeRatio = 100;\r\n    /// @notice Minimum amount for mint/redeem operations (in WeUSD units)\r\n    uint256 public minAmount = 10000;\r\n    \r\n    /// @notice Total stablecoin reserves held by the contract\r\n    uint256 public stablecoinReserves;\r\n    /// @notice Total fees accumulated from redemption operations\r\n    uint256 public accumulatedFees;\r\n    /// @notice Stablecoin reserves allocated for cross-chain operations\r\n    uint256 public crossChainReserves;\r\n    /// @notice Outstanding deficit from cross-chain operations\r\n    uint256 public crossChainDeficit;\r\n    \r\n    /// @notice Emitted when WeUSD tokens are minted\r\n    /// @param user Address of the user who minted tokens\r\n    /// @param costStablecoinAmount Amount of stablecoin used for minting\r\n    /// @param weUSDAmount Amount of WeUSD tokens minted\r\n    /// @param fee Fee charged for the operation (always 0 for minting)\r\n    event MintedWeUSD(address indexed user, uint256 costStablecoinAmount, uint256 weUSDAmount, uint256 fee);\r\n    \r\n    /// @notice Emitted when WeUSD tokens are redeemed\r\n    /// @param user Address of the user who redeemed tokens\r\n    /// @param receivedStablecoinAmount Amount of stablecoin received after fees\r\n    /// @param weUSDAmount Amount of WeUSD tokens redeemed\r\n    /// @param fee Fee charged for the operation\r\n    event BurnedWeUSD(address indexed user, uint256 receivedStablecoinAmount, uint256 weUSDAmount, uint256 fee);\r\n    \r\n    /// @notice Emitted when fee ratio is updated\r\n    /// @param newFeeRatio New fee ratio in basis points\r\n    event FeeRatioSet(uint256 newFeeRatio);\r\n    \r\n    /// @notice Emitted when minimum amount is updated\r\n    /// @param newMinAmount New minimum amount for operations\r\n    event MinAmountSet(uint256 newMinAmount);\r\n    \r\n    /// @notice Emitted when fee recipient is updated\r\n    /// @param newFeeRecipient New address to receive fees\r\n    event FeeRecipientSet(address newFeeRecipient);\r\n    \r\n    /// @notice Emitted when cross-chain reserves are withdrawn\r\n    /// @param sender Address that initiated the withdrawal\r\n    /// @param amount Amount withdrawn\r\n    /// @param recipient Address that received the funds\r\n    event CrossChainReservesWithdrawn(address indexed sender, uint256 amount, address recipient);\r\n    \r\n    /// @notice Emitted when cross-chain contract address is set\r\n    /// @param crossChainContract Address of the cross-chain contract\r\n    event CrossChainContractSet(address indexed crossChainContract);\r\n    \r\n    /// @notice Emitted when stablecoin is reserved for cross-chain operations\r\n    /// @param amount Amount reserved (in WeUSD units)\r\n    event StablecoinReserved(uint256 amount);\r\n    \r\n    /// @notice Emitted when stablecoin is returned from cross-chain operations\r\n    /// @param amount Amount returned (in WeUSD units)\r\n    /// @param deficit Any deficit incurred during the operation\r\n    event StablecoinReturned(uint256 amount, uint256 deficit);\r\n    \r\n    /// @notice Emitted when stablecoin contract is updated\r\n    /// @param newStablecoin Address of the new stablecoin contract\r\n    /// @param decimals Decimal places of the new stablecoin\r\n    event StablecoinSet(address indexed newStablecoin, uint8 decimals);\r\n    \r\n    /// @notice Thrown when fee calculation results in insufficient amount\r\n    error InsufficientFee();\r\n    /// @notice Thrown when contract has insufficient reserves for operation\r\n    error InsufficientReserves();\r\n    /// @notice Thrown when operation amount is below minimum threshold\r\n    error InsufficientAmount();\r\n    /// @notice Thrown when calculated amount is zero\r\n    error ZeroAmount();\r\n    /// @notice Thrown when caller lacks required authorization\r\n    error Unauthorized();\r\n    /// @notice Thrown when zero address is provided where not allowed\r\n    error ZeroAddress();\r\n\r\n    /**\r\n     * @notice Constructor to initialize the WeUSDMintRedeem contract\r\n     * @dev Sets up initial roles and validates all input addresses\r\n     * @param _weUSD Address of the WeUSD token contract\r\n     * @param _stablecoin Address of the stablecoin token contract\r\n     * @param _feeRecipient Address to receive transaction fees\r\n     * @param _balancer Address to be granted balancer role\r\n     */\r\n    constructor(\r\n        address _weUSD,\r\n        address _stablecoin,\r\n        address _feeRecipient,\r\n        address _balancer\r\n    ) {\r\n        // L-4 Fix: Add zero address checks\r\n        require(_weUSD != address(0), \"WeUSD address cannot be zero\");\r\n        require(_stablecoin != address(0), \"Stablecoin address cannot be zero\");\r\n        require(_feeRecipient != address(0), \"Fee recipient cannot be zero\");\r\n        require(_balancer != address(0), \"Balancer address cannot be zero\");\r\n\r\n        // Initialize immutable variables\r\n        weUSD = IPicweUSD(_weUSD);\r\n        \r\n        // Initialize state variables\r\n        stablecoin = IERC20(_stablecoin);\r\n        stablecoinDecimals = IERC20Metadata(_stablecoin).decimals();\r\n        feeRecipient = _feeRecipient;\r\n        \r\n        // Set up role-based access control\r\n        _grantRole(DEFAULT_ADMIN_ROLE, msg.sender);\r\n        _grantRole(ADMIN_ROLE, msg.sender);\r\n        _grantRole(BALANCER_ROLE, _balancer);\r\n        _grantRole(WITHDRAW_ROLE, msg.sender);\r\n        _grantRole(WITHDRAW_ROLE, _balancer);\r\n\r\n        // Configure role hierarchy\r\n        _setRoleAdmin(WITHDRAW_ROLE, ADMIN_ROLE);\r\n    }\r\n    \r\n    /**\r\n     * @notice Pause the contract (only admin can pause)\r\n     * @dev Pauses only public user functions (mint/redeem), admin functions remain available\r\n     */\r\n    function pause() external onlyRole(ADMIN_ROLE) {\r\n        _pause();\r\n    }\r\n    \r\n    /**\r\n     * @notice Unpause the contract (only admin can unpause)\r\n     * @dev Unpauses all public user functions\r\n     */\r\n    function unpause() external onlyRole(ADMIN_ROLE) {\r\n        _unpause();\r\n    }\r\n    \r\n    /**\r\n     * @notice Set the cross-chain contract address and grant it the cross-chain role\r\n     * @dev Only admin can call this function. Grants CROSS_CHAIN_ROLE to the new contract\r\n     *      and revokes the role from the previous contract if it exists.\r\n     * @param _crossChainContract Address of the WeUSDCrossChain contract\r\n     */\r\n    function setCrossChainContract(address _crossChainContract) external onlyRole(ADMIN_ROLE) {\r\n        require(_crossChainContract != address(0), \"Cross-chain contract cannot be zero\");\r\n        \r\n        // WUS1-2 Fix: Revoke role from old cross-chain contract if it exists\r\n        if (crossChainContract != address(0)) {\r\n            _revokeRole(CROSS_CHAIN_ROLE, crossChainContract);\r\n        }\r\n        \r\n        crossChainContract = _crossChainContract;\r\n        _grantRole(CROSS_CHAIN_ROLE, _crossChainContract);\r\n        emit CrossChainContractSet(_crossChainContract);\r\n    }\r\n    \r\n    /**\r\n     * @notice Convert WeUSD amount to stablecoin amount with rounding down\r\n     * @dev Used for redemption calculations to ensure users don't receive more than they should\r\n     * @param weUSDAmount Amount in WeUSD decimals\r\n     * @return Amount in stablecoin decimals (rounded down)\r\n     */\r\n    function _toStablecoinAmountDown(uint256 weUSDAmount) internal view returns (uint256) {\r\n        if (stablecoinDecimals == WEUSD_DECIMALS) {\r\n            return weUSDAmount;\r\n        } else if (stablecoinDecimals > WEUSD_DECIMALS) {\r\n            // Scale up: multiply by 10^(difference)\r\n            return weUSDAmount * (10 ** (stablecoinDecimals - WEUSD_DECIMALS));\r\n        } else {\r\n            // Scale down: divide by 10^(difference), truncating remainder\r\n            uint256 divisor = 10 ** (WEUSD_DECIMALS - stablecoinDecimals);\r\n            return weUSDAmount / divisor;\r\n        }\r\n    }\r\n\r\n    /**\r\n     * @notice Convert WeUSD amount to stablecoin amount with rounding up for minting\r\n     * @dev Used for minting calculations to ensure protocol collects sufficient stablecoin.\r\n     *      Rounds up when there's a remainder to maintain 1:1 backing ratio.\r\n     * @param weUSDAmount Amount in WeUSD decimals\r\n     * @return Amount in stablecoin decimals (rounded up if remainder exists)\r\n     */\r\n    function _toStablecoinAmountUp(uint256 weUSDAmount) internal view returns (uint256) {\r\n        if (stablecoinDecimals == WEUSD_DECIMALS) {\r\n            return weUSDAmount;\r\n        } else if (stablecoinDecimals > WEUSD_DECIMALS) {\r\n            // Scale up: multiply by 10^(difference)\r\n            return weUSDAmount * (10 ** (stablecoinDecimals - WEUSD_DECIMALS));\r\n        } else {\r\n            // Scale down: divide by 10^(difference), round up if remainder\r\n            uint256 divisor = 10 ** (WEUSD_DECIMALS - stablecoinDecimals);\r\n            uint256 quotient = weUSDAmount / divisor;\r\n            // Round up: add 1 if there's a remainder\r\n            if (weUSDAmount % divisor > 0) {\r\n                quotient += 1;\r\n            }\r\n            return quotient;\r\n        }\r\n    }\r\n    \r\n    /**\r\n     * @notice Mint WeUSD tokens by depositing stablecoin\r\n     * @dev Transfers stablecoin from user and mints equivalent WeUSD tokens.\r\n     *      Uses rounding up conversion to ensure sufficient collateral.\r\n     * @param weUSDAmount Amount of WeUSD tokens to mint\r\n     */\r\n    function mintWeUSD(uint256 weUSDAmount) external nonReentrant whenNotPaused {\r\n        require(weUSDAmount >= minAmount, \"Amount too small\");\r\n        \r\n        // Calculate required stablecoin amount (rounded up)\r\n        uint256 scMintAmount = _toStablecoinAmountUp(weUSDAmount);\r\n        \r\n        // Validate user has sufficient balance and allowance\r\n        require(stablecoin.balanceOf(msg.sender) >= scMintAmount, \"Insufficient balance\");\r\n        require(stablecoin.allowance(msg.sender, address(this)) >= scMintAmount, \"Insufficient allowance\");\r\n        \r\n        // Transfer stablecoin from user to contract\r\n        stablecoin.safeTransferFrom(msg.sender, address(this), scMintAmount);\r\n        \r\n        // Update reserves and mint WeUSD tokens\r\n        stablecoinReserves += scMintAmount;\r\n        weUSD.mint(msg.sender, weUSDAmount);\r\n        \r\n        emit MintedWeUSD(msg.sender, scMintAmount, weUSDAmount, 0);\r\n    }\r\n    \r\n    /**\r\n     * @notice Redeem WeUSD tokens for stablecoin\r\n     * @dev Burns WeUSD tokens and transfers stablecoin to user after deducting fees.\r\n     *      Uses rounding down conversion and applies redemption fee.\r\n     * @param weUSDAmount Amount of WeUSD tokens to redeem\r\n     */\r\n    function redeemWeUSD(uint256 weUSDAmount) external nonReentrant whenNotPaused {\r\n        require(weUSDAmount >= minAmount, \"Amount too small\");\r\n        \r\n        // Calculate stablecoin amount to redeem (rounded down)\r\n        uint256 scRedeemAmount = _toStablecoinAmountDown(weUSDAmount);\r\n        require(stablecoinReserves >= scRedeemAmount, \"Insufficient reserves\");\r\n        \r\n        // Calculate fee and net amount\r\n        uint256 feeSC = (scRedeemAmount * feeRatio) / 10000;\r\n        uint256 actualSC = scRedeemAmount - feeSC;\r\n        require(actualSC > 0, \"Zero amount after fee\");\r\n        \r\n        // Update state before external calls (CEI pattern)\r\n        stablecoinReserves -= scRedeemAmount;\r\n        accumulatedFees += feeSC;\r\n        \r\n        // Burn WeUSD tokens and transfer stablecoin\r\n        weUSD.burnFrom(msg.sender, weUSDAmount);\r\n        stablecoin.safeTransfer(msg.sender, actualSC);\r\n        \r\n        // Transfer fee to recipient if non-zero\r\n        if (feeSC > 0) {\r\n            stablecoin.safeTransfer(feeRecipient, feeSC);\r\n        }\r\n        \r\n        emit BurnedWeUSD(msg.sender, actualSC, weUSDAmount, feeSC);\r\n    }\r\n    \r\n    /**\r\n     * @notice Set the fee ratio for redemption operations\r\n     * @dev Only admin can call this function. Fee is applied only to redemptions.\r\n     * @param newFeeRatio New fee ratio in basis points (100 = 1%)\r\n     */\r\n    function setFeeRatio(uint256 newFeeRatio) external onlyRole(ADMIN_ROLE) {\r\n        require(newFeeRatio >= MIN_FEE_RATIO && newFeeRatio <= MAX_FEE_RATIO, \"Invalid fee ratio\");\r\n        feeRatio = newFeeRatio;\r\n        emit FeeRatioSet(newFeeRatio);\r\n    }\r\n    \r\n    /**\r\n     * @notice Set the minimum amount for mint/redeem operations\r\n     * @dev Only admin can call this function. Prevents dust attacks and maintains efficiency.\r\n     * @param newMinAmount New minimum amount in WeUSD units\r\n     */\r\n    function setMinAmount(uint256 newMinAmount) external onlyRole(ADMIN_ROLE) {\r\n        // L-4 Fix: Add reasonable validation range\r\n        require(newMinAmount >= MIN_MIN_AMOUNT && newMinAmount <= MAX_MIN_AMOUNT, \"Invalid min amount\");\r\n        minAmount = newMinAmount;\r\n        emit MinAmountSet(newMinAmount);\r\n    }\r\n    \r\n    /**\r\n     * @notice Set the fee recipient address\r\n     * @dev Only admin can call this function. All redemption fees are sent to this address.\r\n     * @param newFeeRecipient New address to receive fees\r\n     */\r\n    function setFeeRecipient(address newFeeRecipient) external onlyRole(ADMIN_ROLE) {\r\n        require(newFeeRecipient != address(0), \"Fee recipient cannot be zero\");\r\n        feeRecipient = newFeeRecipient;\r\n        emit FeeRecipientSet(newFeeRecipient);\r\n    }\r\n    \r\n    /**\r\n     * @notice Reserve stablecoin for cross-chain operations\r\n     * @dev Only cross-chain contract can call this. Implements atomic state updates\r\n     *      and handles deficit repayment logic. Converts WeUSD amounts to stablecoin.\r\n     * @param amount Amount to reserve in WeUSD units\r\n     */\r\n    function reserveStablecoinForCrossChain(uint256 amount) external onlyRole(CROSS_CHAIN_ROLE){\r\n        // Convert WeUSD amount to stablecoin amount\r\n        uint256 scAmount = _toStablecoinAmountDown(amount);\r\n        \r\n        // Calculate all values before any state changes (CEI pattern)\r\n        uint256 toReserve = scAmount;\r\n        uint256 deficitRepayment = 0;\r\n        \r\n        // Calculate deficit repayment if applicable\r\n        if (crossChainDeficit > 0) {\r\n            deficitRepayment = toReserve <= crossChainDeficit ? toReserve : crossChainDeficit;\r\n            toReserve = scAmount - deficitRepayment;\r\n        }\r\n        \r\n        // Perform all checks before state updates\r\n        require(stablecoinReserves >= toReserve, \"Insufficient reserves\");\r\n        \r\n        // Atomic state updates - all or nothing\r\n        if (deficitRepayment > 0) {\r\n            crossChainDeficit -= deficitRepayment;\r\n        }\r\n        \r\n        if (toReserve > 0) {\r\n            stablecoinReserves -= toReserve;\r\n            crossChainReserves += toReserve;\r\n        }\r\n        \r\n        emit StablecoinReserved(amount);\r\n    }\r\n    \r\n    /**\r\n     * @notice Return stablecoin from cross-chain operations\r\n     * @dev Only cross-chain contract can call this. Handles cases where returned\r\n     *      amount exceeds available reserves by tracking deficit.\r\n     * @param amount Amount to return in WeUSD units\r\n     */\r\n    function returnStablecoinFromCrossChain(uint256 amount) external onlyRole(CROSS_CHAIN_ROLE){\r\n        // Convert WeUSD amount to stablecoin amount\r\n        uint256 scAmount = _toStablecoinAmountDown(amount);\r\n        \r\n        // Calculate all values before any state changes (CEI pattern)\r\n        uint256 deficit = 0;\r\n        uint256 reservesToReturn = 0;\r\n        uint256 deficitToAdd = 0;\r\n        \r\n        if (crossChainReserves >= scAmount) {\r\n            // We have enough reserves to return\r\n            reservesToReturn = scAmount;\r\n        } else {\r\n            // Not enough reserves, calculate deficit\r\n            reservesToReturn = crossChainReserves;\r\n            deficitToAdd = scAmount - crossChainReserves;\r\n            deficit = deficitToAdd;\r\n        }\r\n        \r\n        // Atomic state updates - all or nothing\r\n        if (reservesToReturn > 0) {\r\n            crossChainReserves -= reservesToReturn;\r\n            stablecoinReserves += reservesToReturn;\r\n        }\r\n        \r\n        if (deficitToAdd > 0) {\r\n            crossChainDeficit += deficitToAdd;\r\n        }\r\n        \r\n        emit StablecoinReturned(amount, deficit);\r\n    }\r\n    \r\n    /**\r\n     * @notice Withdraw cross-chain reserves to specified recipient\r\n     * @dev Only withdraw role can call this. Transfers actual stablecoin tokens.\r\n     * @param amount Amount to withdraw in stablecoin units\r\n     * @param recipient Address to receive the withdrawn funds\r\n     */\r\n    function withdrawCrossChainReserves(uint256 amount, address recipient) external onlyRole(WITHDRAW_ROLE){\r\n        require(recipient != address(0), \"Recipient cannot be zero\");\r\n        require(crossChainReserves >= amount, \"Insufficient reserves\");\r\n        \r\n        // Transfer tokens and update state\r\n        stablecoin.safeTransfer(recipient, amount);\r\n        crossChainReserves -= amount;\r\n        \r\n        emit CrossChainReservesWithdrawn(msg.sender, amount, recipient);\r\n    }\r\n    \r\n    /**\r\n     * @notice Withdraw cross-chain reserves to the caller (balancer)\r\n     * @dev Only balancer role can call this. Convenience function for balancer operations.\r\n     * @param amount Amount to withdraw in stablecoin units\r\n     */\r\n    function withdrawCrossChainReservesToBalancer(uint256 amount) external onlyRole(BALANCER_ROLE){\r\n        require(crossChainReserves >= amount, \"Insufficient reserves\");\r\n        \r\n        // Transfer tokens and update state\r\n        stablecoin.safeTransfer(msg.sender, amount);\r\n        crossChainReserves -= amount;\r\n        \r\n        emit CrossChainReservesWithdrawn(msg.sender, amount, msg.sender);\r\n    }\r\n    \r\n    /**\r\n     * @notice Get total accumulated fees from redemption operations\r\n     * @return Total accumulated fees in stablecoin units\r\n     */\r\n    function getAccumulatedFees() external view returns (uint256) {\r\n        return accumulatedFees;\r\n    }\r\n    \r\n    /**\r\n     * @notice Get total stablecoin reserves available for operations\r\n     * @return Total stablecoin reserves in stablecoin units\r\n     */\r\n    function getTotalReserves() external view returns (uint256) {\r\n        return stablecoinReserves;\r\n    }\r\n    \r\n    /**\r\n     * @notice Get current mint state configuration\r\n     * @return feeRecipient Current fee recipient address\r\n     * @return feeRatio Current fee ratio in basis points\r\n     * @return minAmount Current minimum amount for operations\r\n     */\r\n    function getMintStateFields() external view returns (address, uint256, uint256) {\r\n        return (feeRecipient, feeRatio, minAmount);\r\n    }\r\n    \r\n    /**\r\n     * @notice Get total cross-chain reserves\r\n     * @return Total cross-chain reserves in stablecoin units\r\n     */\r\n    function getCrossChainReserves() external view returns (uint256) {\r\n        return crossChainReserves;\r\n    }\r\n    \r\n    /**\r\n     * @notice Get current cross-chain deficit\r\n     * @return Total cross-chain deficit in stablecoin units\r\n     */\r\n    function getCrossChainDeficit() external view returns (uint256) {\r\n        return crossChainDeficit;\r\n    }\r\n    \r\n    /**\r\n     * @notice Set a new stablecoin contract and update its decimals\r\n     * @dev Only admin can call this. Updates both contract reference and cached decimals.\r\n     * @param _stablecoin Address of the new stablecoin token contract\r\n     */\r\n    function setStablecoin(address _stablecoin) external onlyRole(ADMIN_ROLE) {\r\n        require(_stablecoin != address(0), \"Stablecoin address cannot be zero\");\r\n        stablecoin = IERC20(_stablecoin);\r\n        stablecoinDecimals = IERC20Metadata(_stablecoin).decimals();\r\n        emit StablecoinSet(_stablecoin, stablecoinDecimals);\r\n    }\r\n}"}},"abi":[{"type":"constructor","inputs":[{"name":"_weUSD","type":"address","internalType":"address"},{"name":"_stablecoin","type":"address","internalType":"address"},{"name":"_feeRecipient","type":"address","internalType":"address"},{"name":"_balancer","type":"address","internalType":"address"}],"stateMutability":"nonpayable"},{"name":"AccessControlBadConfirmation","type":"error","inputs":[]},{"name":"AccessControlUnauthorizedAccount","type":"error","inputs":[{"name":"account","type":"address","internalType":"address"},{"name":"neededRole","type":"bytes32","internalType":"bytes32"}]},{"name":"EnforcedPause","type":"error","inputs":[]},{"name":"ExpectedPause","type":"error","inputs":[]},{"name":"InsufficientAmount","type":"error","inputs":[]},{"name":"InsufficientFee","type":"error","inputs":[]},{"name":"InsufficientReserves","type":"error","inputs":[]},{"name":"ReentrancyGuardReentrantCall","type":"error","inputs":[]},{"name":"SafeERC20FailedOperation","type":"error","inputs":[{"name":"token","type":"address","internalType":"address"}]},{"name":"Unauthorized","type":"error","inputs":[]},{"name":"ZeroAddress","type":"error","inputs":[]},{"name":"ZeroAmount","type":"error","inputs":[]},{"name":"BurnedWeUSD","type":"event","inputs":[{"name":"user","type":"address","indexed":true,"internalType":"address"},{"name":"receivedStablecoinAmount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"weUSDAmount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"fee","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"CrossChainContractSet","type":"event","inputs":[{"name":"crossChainContract","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"CrossChainReservesWithdrawn","type":"event","inputs":[{"name":"sender","type":"address","indexed":true,"internalType":"address"},{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"recipient","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"name":"FeeRatioSet","type":"event","inputs":[{"name":"newFeeRatio","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"FeeRecipientSet","type":"event","inputs":[{"name":"newFeeRecipient","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"name":"MinAmountSet","type":"event","inputs":[{"name":"newMinAmount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"MintedWeUSD","type":"event","inputs":[{"name":"user","type":"address","indexed":true,"internalType":"address"},{"name":"costStablecoinAmount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"weUSDAmount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"fee","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"Paused","type":"event","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"name":"RoleAdminChanged","type":"event","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"previousAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"newAdminRole","type":"bytes32","indexed":true,"internalType":"bytes32"}],"anonymous":false},{"name":"RoleGranted","type":"event","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"RoleRevoked","type":"event","inputs":[{"name":"role","type":"bytes32","indexed":true,"internalType":"bytes32"},{"name":"account","type":"address","indexed":true,"internalType":"address"},{"name":"sender","type":"address","indexed":true,"internalType":"address"}],"anonymous":false},{"name":"StablecoinReserved","type":"event","inputs":[{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"StablecoinReturned","type":"event","inputs":[{"name":"amount","type":"uint256","indexed":false,"internalType":"uint256"},{"name":"deficit","type":"uint256","indexed":false,"internalType":"uint256"}],"anonymous":false},{"name":"StablecoinSet","type":"event","inputs":[{"name":"newStablecoin","type":"address","indexed":true,"internalType":"address"},{"name":"decimals","type":"uint8","indexed":false,"internalType":"uint8"}],"anonymous":false},{"name":"Unpaused","type":"event","inputs":[{"name":"account","type":"address","indexed":false,"internalType":"address"}],"anonymous":false},{"name":"ADMIN_ROLE","type":"function","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"BALANCER_ROLE","type":"function","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"CROSS_CHAIN_ROLE","type":"function","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"DEFAULT_ADMIN_ROLE","type":"function","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"MAX_FEE_RATIO","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MAX_MIN_AMOUNT","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MIN_FEE_RATIO","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"MIN_MIN_AMOUNT","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"WEUSD_DECIMALS","type":"function","inputs":[],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"name":"WITHDRAW_ROLE","type":"function","inputs":[],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"accumulatedFees","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"crossChainContract","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"crossChainDeficit","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"crossChainReserves","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"feeRatio","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"feeRecipient","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"}],"stateMutability":"view"},{"name":"getAccumulatedFees","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"getCrossChainDeficit","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"getCrossChainReserves","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"getMintStateFields","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"address"},{"name":"","type":"uint256","internalType":"uint256"},{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"getRoleAdmin","type":"function","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"}],"outputs":[{"name":"","type":"bytes32","internalType":"bytes32"}],"stateMutability":"view"},{"name":"getTotalReserves","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"grantRole","type":"function","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"hasRole","type":"function","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"minAmount","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"mintWeUSD","type":"function","inputs":[{"name":"weUSDAmount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"pause","type":"function","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"name":"paused","type":"function","inputs":[],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"redeemWeUSD","type":"function","inputs":[{"name":"weUSDAmount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"renounceRole","type":"function","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"callerConfirmation","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"reserveStablecoinForCrossChain","type":"function","inputs":[{"name":"amount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"returnStablecoinFromCrossChain","type":"function","inputs":[{"name":"amount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"revokeRole","type":"function","inputs":[{"name":"role","type":"bytes32","internalType":"bytes32"},{"name":"account","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setCrossChainContract","type":"function","inputs":[{"name":"_crossChainContract","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setFeeRatio","type":"function","inputs":[{"name":"newFeeRatio","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setFeeRecipient","type":"function","inputs":[{"name":"newFeeRecipient","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setMinAmount","type":"function","inputs":[{"name":"newMinAmount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"setStablecoin","type":"function","inputs":[{"name":"_stablecoin","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"stablecoin","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IERC20"}],"stateMutability":"view"},{"name":"stablecoinDecimals","type":"function","inputs":[],"outputs":[{"name":"","type":"uint8","internalType":"uint8"}],"stateMutability":"view"},{"name":"stablecoinReserves","type":"function","inputs":[],"outputs":[{"name":"","type":"uint256","internalType":"uint256"}],"stateMutability":"view"},{"name":"supportsInterface","type":"function","inputs":[{"name":"interfaceId","type":"bytes4","internalType":"bytes4"}],"outputs":[{"name":"","type":"bool","internalType":"bool"}],"stateMutability":"view"},{"name":"unpause","type":"function","inputs":[],"outputs":[],"stateMutability":"nonpayable"},{"name":"weUSD","type":"function","inputs":[],"outputs":[{"name":"","type":"address","internalType":"contract IPicweUSD"}],"stateMutability":"view"},{"name":"withdrawCrossChainReserves","type":"function","inputs":[{"name":"amount","type":"uint256","internalType":"uint256"},{"name":"recipient","type":"address","internalType":"address"}],"outputs":[],"stateMutability":"nonpayable"},{"name":"withdrawCrossChainReservesToBalancer","type":"function","inputs":[{"name":"amount","type":"uint256","internalType":"uint256"}],"outputs":[],"stateMutability":"nonpayable"}],"matchId":"30702703","creationMatch":"match","runtimeMatch":"match","verifiedAt":"2026-06-03T21:34:53Z","match":"match","chainId":"56","address":"0x5D54f1092FD1750A3ab96972dc1867c5B23eF22C"}