// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/Clones.sol)
pragma solidity ^0.8.0;
/**
* @dev https://eips.ethereum.org/EIPS/eip-1167[EIP 1167] is a standard for
* deploying minimal proxy contracts, also known as "clones".
*
* > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
* > a minimal bytecode implementation that delegates all calls to a known, fixed address.
*
* The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
* (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
* deterministic method.
*
* _Available since v3.4._
*/
library Clones {
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create opcode, which should never revert.
*/
function clone(address implementation) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create(0, ptr, 0x37)
}
require(instance != address(0), "ERC1167: create failed");
}
/**
* @dev Deploys and returns the address of a clone that mimics the behaviour of `implementation`.
*
* This function uses the create2 opcode and a `salt` to deterministically deploy
* the clone. Using the same `implementation` and `salt` multiple time will revert, since
* the clones cannot be deployed twice at the same address.
*/
function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
instance := create2(0, ptr, 0x37, salt)
}
require(instance != address(0), "ERC1167: create2 failed");
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
assembly {
let ptr := mload(0x40)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(ptr, 0x14), shl(0x60, implementation))
mstore(add(ptr, 0x28), 0x5af43d82803e903d91602b57fd5bf3ff00000000000000000000000000000000)
mstore(add(ptr, 0x38), shl(0x60, deployer))
mstore(add(ptr, 0x4c), salt)
mstore(add(ptr, 0x6c), keccak256(ptr, 0x37))
predicted := keccak256(add(ptr, 0x37), 0x55)
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(address implementation, bytes32 salt)
internal
view
returns (address predicted)
{
return predictDeterministicAddress(implementation, salt, address(this));
}
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/// @title Logium constants
/// @notice All constants relevant in Logium for ex. USDC address
/// @dev This library contains only "public constant" state variables
library Constants {
/// USDC contract
IERC20 public constant USDC =
IERC20(address(0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48));
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/ECDSA.sol)
pragma solidity ^0.8.0;
import "../Strings.sol";
/**
* @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
*
* These functions can be used to verify that a message was signed by the holder
* of the private keys of a given address.
*/
library ECDSA {
enum RecoverError {
NoError,
InvalidSignature,
InvalidSignatureLength,
InvalidSignatureS,
InvalidSignatureV
}
function _throwError(RecoverError error) private pure {
if (error == RecoverError.NoError) {
return; // no error: do nothing
} else if (error == RecoverError.InvalidSignature) {
revert("ECDSA: invalid signature");
} else if (error == RecoverError.InvalidSignatureLength) {
revert("ECDSA: invalid signature length");
} else if (error == RecoverError.InvalidSignatureS) {
revert("ECDSA: invalid signature 's' value");
} else if (error == RecoverError.InvalidSignatureV) {
revert("ECDSA: invalid signature 'v' value");
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature` or error string. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*
* Documentation for signature generation:
* - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
* - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
*
* _Available since v4.3._
*/
function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
// Check the signature length
// - case 65: r,s,v signature (standard)
// - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
if (signature.length == 65) {
bytes32 r;
bytes32 s;
uint8 v;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
s := mload(add(signature, 0x40))
v := byte(0, mload(add(signature, 0x60)))
}
return tryRecover(hash, v, r, s);
} else if (signature.length == 64) {
bytes32 r;
bytes32 vs;
// ecrecover takes the signature parameters, and the only way to get them
// currently is to use assembly.
assembly {
r := mload(add(signature, 0x20))
vs := mload(add(signature, 0x40))
}
return tryRecover(hash, r, vs);
} else {
return (address(0), RecoverError.InvalidSignatureLength);
}
}
/**
* @dev Returns the address that signed a hashed message (`hash`) with
* `signature`. This address can then be used for verification purposes.
*
* The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
* this function rejects them by requiring the `s` value to be in the lower
* half order, and the `v` value to be either 27 or 28.
*
* IMPORTANT: `hash` _must_ be the result of a hash operation for the
* verification to be secure: it is possible to craft signatures that
* recover to arbitrary addresses for non-hashed data. A safe way to ensure
* this is by receiving a hash of the original message (which may otherwise
* be too long), and then calling {toEthSignedMessageHash} on it.
*/
function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, signature);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
*
* See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address, RecoverError) {
bytes32 s;
uint8 v;
assembly {
s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
v := add(shr(255, vs), 27)
}
return tryRecover(hash, v, r, s);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
*
* _Available since v4.2._
*/
function recover(
bytes32 hash,
bytes32 r,
bytes32 vs
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, r, vs);
_throwError(error);
return recovered;
}
/**
* @dev Overload of {ECDSA-tryRecover} that receives the `v`,
* `r` and `s` signature fields separately.
*
* _Available since v4.3._
*/
function tryRecover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address, RecoverError) {
// EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
// unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
// the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
// signatures from current libraries generate a unique signature with an s-value in the lower half order.
//
// If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
// with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
// vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
// these malleable signatures as well.
if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
return (address(0), RecoverError.InvalidSignatureS);
}
if (v != 27 && v != 28) {
return (address(0), RecoverError.InvalidSignatureV);
}
// If the signature is valid (and not malleable), return the signer address
address signer = ecrecover(hash, v, r, s);
if (signer == address(0)) {
return (address(0), RecoverError.InvalidSignature);
}
return (signer, RecoverError.NoError);
}
/**
* @dev Overload of {ECDSA-recover} that receives the `v`,
* `r` and `s` signature fields separately.
*/
function recover(
bytes32 hash,
uint8 v,
bytes32 r,
bytes32 s
) internal pure returns (address) {
(address recovered, RecoverError error) = tryRecover(hash, v, r, s);
_throwError(error);
return recovered;
}
/**
* @dev Returns an Ethereum Signed Message, created from a `hash`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
// 32 is the length in bytes of hash,
// enforced by the type signature above
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
}
/**
* @dev Returns an Ethereum Signed Message, created from `s`. This
* produces hash corresponding to the one signed with the
* https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
* JSON-RPC method as part of EIP-191.
*
* See {recover}.
*/
function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", Strings.toString(s.length), s));
}
/**
* @dev Returns an Ethereum Signed Typed Data, created from a
* `domainSeparator` and a `structHash`. This produces hash corresponding
* to the one signed with the
* https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
* JSON-RPC method as part of EIP-712.
*
* See {recover}.
*/
function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
/// @title Bet interface required by the Logium master contract
/// @notice All non view functions here can only be called by LogiumCore
interface ILogiumBinaryBetCore {
/// @notice Initialization function. Initializes AND issues a bet. Will be called by the master contract once on only the first take of a given bet instance.
/// Master MUST transfer returned collaterals or revert.
/// @param detailsHash expected EIP-712 hash of decoded details implementation must validate this hash
/// @param trader trader address for the issuing bet
/// @param takeParams BetImplementation implementation specific ticket take parameters e.g. amount of bet units to open
/// @param volume total ticket volume, BetImplementation implementation should check issuer volume will not be exceeded
/// @param detailsEnc BetImplementation implementation specific ticket details
/// @return issuerPrice issuer USDC collateral expected
/// @return traderPrice trader USDC collateral expected
function initAndIssue(
bytes32 detailsHash,
address trader,
bytes32 takeParams,
uint128 volume,
bytes calldata detailsEnc
) external returns (uint256 issuerPrice, uint256 traderPrice);
/// @notice Issue a bet to a trader. Master will transfer returned collaterals or revert.
/// @param detailsHash expected EIP-712 hash of decoded details implementation must validate this hash
/// @param trader trader address
/// @param takeParams BetImplementation implementation specific ticket take parameters eg. amount of bet units to open
/// @param volume total ticket volume, BetImplementation implementation should check issuer volume will not be exceeded
/// @param detailsEnc BetImplementation implementation specific ticket details
/// @return issuerPrice issuer USDC collateral expected
/// @return traderPrice trader USDC collateral expected
function issue(
bytes32 detailsHash,
address trader,
bytes32 takeParams,
uint128 volume,
bytes calldata detailsEnc
) external returns (uint256 issuerPrice, uint256 traderPrice);
/// @notice Query total issuer used volume
/// @return the total USDC usage
function issuerTotal() external view returns (uint256);
/// @notice EIP712 type string of decoded details
/// @dev used by Core for calculation of Ticket type hash
/// @return the details type, must contain a definition of "Details"
// solhint-disable-next-line func-name-mixedcase
function DETAILS_TYPE() external pure returns (bytes memory);
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "../libraries/Ticket.sol";
import "./logiumCore/ILogiumCoreIssuer.sol";
import "./logiumCore/ILogiumCoreTrader.sol";
import "./logiumCore/ILogiumCoreState.sol";
import "./logiumCore/ILogiumCoreOwner.sol";
/// @title Logium master contract interface
/// @notice This interface is split into multiple small parts
// solhint-disable-next-line no-empty-blocks
interface ILogiumCore is
ILogiumCoreIssuer,
ILogiumCoreTrader,
ILogiumCoreState,
ILogiumCoreOwner
{
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
/// @title Issuer functionality of LogiumCore
/// @notice functions specified here are executed with msg.sender treated as issuer
interface ILogiumCoreIssuer {
/// Structure signed by an issuer that authorizes another account to withdraw all free collateral
/// - to - the address authorized to withdraw
/// - expiry - timestamp of authorization expiry
struct WithdrawAuthorization {
address to;
uint256 expiry;
}
/// Structure signed by an issuer that allows delegated invalidation increase
struct InvalidationMessage {
uint64 newInvalidation;
}
/// @notice emitted on any free collateral change (deposit, withdraw and takeTicket)
/// @param issuer issuer address whose free collateral is changing
/// @param change the change to free collateral positive on deposit, negative on withdrawal and takeTicket
event CollateralChange(address indexed issuer, int128 change);
/// @notice emitted on change of invalidation value
/// @param issuer issuer address who changed their invalidation value
/// @param newValue new invalidation value
event Invalidation(address indexed issuer, uint64 newValue);
/// @notice Withdraw caller USDC from free collateral
/// @param amount to withdraw. Reverts if amount exceeds balance.
function withdraw(uint128 amount) external;
/// @notice Withdraw all caller USDC from free collateral
/// @return _0 amount actually withdrawn
function withdrawAll() external returns (uint256);
/// @notice Withdraw free collateral from another issuer to the caller
/// @param amount to withdraw. Reverts if amount exceeds balance.
/// @param authorization authorization created and signed by the other account
/// @param signature signature of authorization by the from account
/// @return _0 recovered address of issuer account
function withdrawFrom(
uint128 amount,
WithdrawAuthorization calldata authorization,
bytes calldata signature
) external returns (address);
/// @notice Withdraw all from other issuer account freeCollateral USDC to caller address
/// @param authorization authorization created and signed by the other account
/// @param signature signature of authorization by the from account
/// @return _0 recovered address of issuer account
/// @return _1 amount actually withdrawn
function withdrawAllFrom(
WithdrawAuthorization calldata authorization,
bytes calldata signature
) external returns (address, uint256);
/// @notice Deposit caller USDC to free collateral. Requires approval on USDC contract
/// @param amount amount to deposit
function deposit(uint128 amount) external;
/// @notice Deposit from sender to target user freeCollateral
/// @param target target address for freeCollateral deposit
/// @param amount amount to deposit
function depositTo(address target, uint128 amount) external;
/// @notice Change caller invalidation value. Invalidation value can be only increased
/// @param newInvalidation new invalidation value
function invalidate(uint64 newInvalidation) external;
/// @notice Change other issuer invalidation value using an invalidation message signed by them. Invalidation value can be only increased
/// @param invalidationMsg the invalidation message containing new invalidation value
/// @param signature issuer signature over invalidation message
function invalidateOther(
InvalidationMessage calldata invalidationMsg,
bytes calldata signature
) external;
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "../logiumBinaryBet/ILogiumBinaryBetCore.sol";
/// @title LogiumCore owner interface for changing system parameters
/// @notice Functions specified here can only be called by the Owner of the Logium master contract
interface ILogiumCoreOwner {
/// @notice emitted when a new master bet contract address is allowed
/// @param newBetImplementation new address of the master bet contract
event AllowedBetImplementation(ILogiumBinaryBetCore newBetImplementation);
/// @notice emitted when a master bet contract address is blocked
/// @param blockedBetImplementation the address of the master bet contract
event DisallowedBetImplementation(
ILogiumBinaryBetCore blockedBetImplementation
);
/// @notice Allows a master bet contract address for use to create bet contract clones
/// @param newBetImplementation the new address, the contract under this address MUST follow ILogiumBinaryBetCore interface
function allowBetImplementation(ILogiumBinaryBetCore newBetImplementation)
external;
/// @notice Disallows a master bet contract address for use to create bet contract clones
/// @param blockedBetImplementation the previously allowed master bet contract address
function disallowBetImplementation(
ILogiumBinaryBetCore blockedBetImplementation
) external;
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "../logiumBinaryBet/ILogiumBinaryBetCore.sol";
/// @title Functions for querying the state of the Logium master contract
/// @notice All of these functions are "view". Some directly describe public state variables
interface ILogiumCoreState {
/// @notice Query all properties stored for a issuer/user
/// @dev To save gas all user properties fit in a single 256 bit storage slot
/// @param _0 the queries issuer/user address
/// @return freeUSDCCollateral free collateral for use with issued tickets
/// @return invalidation value for ticket invalidation
/// @return exists whether issuer/user has ever used our protocol
function users(address _0)
external
view
returns (
uint128 freeUSDCCollateral,
uint64 invalidation,
bool exists
);
/// @notice Check if a master bet contract can be used for creating bets
/// @param betImplementation the address of the contract
/// @return boolean if it can be used
function isAllowedBetImplementation(ILogiumBinaryBetCore betImplementation)
external
view
returns (bool);
/// Get a bet contract for ticket if it exists.
/// Returned contract is a thin clone of provided logiumBinaryBetImplementation
/// reverts if the provided logiumBinaryBetImplementation is not allowed
/// Note: LogiumBinaryBetImplementation may be upgraded/replaced and in the future it
/// MAY NOT follow ILogiumBinaryBet interface, but it will always follow ILogiumBinaryBetCore interface.
/// @param hashVal ticket hashVal (do not confuse with ticket hash for signing)
/// @param logiumBinaryBetImplementation address of bet_implementation of the ticket
/// @return address of the existing bet contract or 0x0 if the ticket was never taken
function contractFromTicketHash(
bytes32 hashVal,
ILogiumBinaryBetCore logiumBinaryBetImplementation
) external view returns (ILogiumBinaryBetCore);
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "../../libraries/Ticket.sol";
import "../logiumBinaryBet/ILogiumBinaryBetCore.sol";
/// @title Trader functionality of LogiumCore
/// @notice functions specified here are executed with msg.sender treated as trader
interface ILogiumCoreTrader {
/// @notice Emitted when a bet is taken (take ticket is successfully called)
/// @param issuer issuer/maker of the ticket/offer
/// @param trader trader/taker of the bet
/// @param betImplementation address of the bet master contract used
/// @param takeParams betImplementation dependent take params eg. "fraction" of the ticket to take
/// @param details betImplementation specific details of the ticket
event BetEmitted(
address indexed issuer,
address indexed trader,
ILogiumBinaryBetCore betImplementation,
bytes32 takeParams,
bytes details
);
/// @notice Take a specified amount of the ticket. Emits BetEmitted and CollateralChange events.
/// @param detailsHash EIP-712 hash of decoded Payload.details. Will be validated
/// @param payload ticket payload of the ticket to take
/// @param signature ticket signature of the ticket to take
/// @param takeParams BetImplementation implementation specific ticket take parameters e.g. amount of bet units to open
/// @return address of the bet contract.
/// Note: although after taking the implementation of a bet contract will not change, masterBetContract is subject to change and its interface MAY change
function takeTicket(
bytes memory signature,
Ticket.Payload memory payload,
bytes32 detailsHash,
bytes32 takeParams
) external returns (address);
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@openzeppelin/contracts/proxy/Clones.sol";
import "@openzeppelin/contracts/utils/math/SafeCast.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "./libraries/Constants.sol";
import "./libraries/Ticket.sol";
import "./interfaces/logiumBinaryBet/ILogiumBinaryBetCore.sol";
import "./interfaces/ILogiumCore.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Multicall.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
/// @title Logium master contract
/// @notice Contract managing core Logium logic incl. collateral, tickets, opening bets, and system parameters
/// @dev For interaction with this contract please refer to the interface. It's split into easily understood parts.
contract LogiumCore is Ownable, ILogiumCore, Multicall, EIP712 {
using SafeCast for uint256;
using SafeCast for int256;
using Ticket for Ticket.Payload;
using ECDSA for bytes32;
/// User structure for storing issuer related state.
/// Properties:
/// - freeUSDCCollateral - free collateral (USDC token amount)
/// - invalidation - value for ticket invalidation
/// - exists - used to make sure storage slots are not cleared on collateral withdrawal
/// @dev All properties size was adjusted to fit into one slot
/// @dev We make a silent assumption that there will never be more than 2^128 USDC (incl. decimals) in circulation.
struct User {
uint128 freeUSDCCollateral;
uint64 invalidation;
bool exists;
}
mapping(address => User) public override users;
mapping(ILogiumBinaryBetCore => bytes32)
private fullTypeHashForBetImplementation;
bytes32 internal constant WITHDRAW_AUTHORIZATION_TYPE =
keccak256("WithdrawAuthorization(address to,uint256 expiry)");
bytes32 internal constant INVALIDATION_MESSAGE_TYPE =
keccak256("InvalidationMessage(uint64 newInvalidation)");
// solhint-disable-next-line no-empty-blocks
constructor() EIP712("Logium Exchange", "1") {}
function allowBetImplementation(ILogiumBinaryBetCore newBetImplementation)
external
override
onlyOwner
{
require(
fullTypeHashForBetImplementation[newBetImplementation] == 0x0,
"Can't allow allowed"
);
bytes memory detailsType = newBetImplementation.DETAILS_TYPE();
fullTypeHashForBetImplementation[newBetImplementation] = Ticket
.fullTypeHash(detailsType);
emit AllowedBetImplementation(newBetImplementation);
}
function disallowBetImplementation(
ILogiumBinaryBetCore blockedBetImplementation
) external override onlyOwner {
require(
fullTypeHashForBetImplementation[blockedBetImplementation] != 0x0,
"Can't disallow disallowed"
);
fullTypeHashForBetImplementation[blockedBetImplementation] = 0x0;
emit DisallowedBetImplementation(blockedBetImplementation);
}
function isAllowedBetImplementation(ILogiumBinaryBetCore betImplementation)
external
view
override
returns (bool)
{
return fullTypeHashForBetImplementation[betImplementation] != 0x0;
}
function withdraw(uint128 amount) external override {
_withdrawFromTo(msg.sender, msg.sender, amount);
}
function withdrawAll() external override returns (uint256) {
return _withdrawAllFromTo(msg.sender, msg.sender);
}
function withdrawFrom(
uint128 amount,
WithdrawAuthorization calldata authorization,
bytes calldata signature
) external override returns (address) {
address from = validateAuthorization(authorization, signature);
_withdrawFromTo(from, msg.sender, amount);
return from;
}
function withdrawAllFrom(
WithdrawAuthorization calldata authorization,
bytes calldata signature
) external override returns (address, uint256) {
address from = validateAuthorization(authorization, signature);
return (from, _withdrawAllFromTo(from, msg.sender));
}
function validateAuthorization(
WithdrawAuthorization calldata authorization,
bytes calldata signature
) internal view returns (address) {
require(authorization.to == msg.sender, "Invalid 'to' in authorization");
require(authorization.expiry > block.timestamp, "Expired authorization");
address from = _hashTypedDataV4(
keccak256(
abi.encode(
WITHDRAW_AUTHORIZATION_TYPE,
authorization.to,
authorization.expiry
)
)
).recover(signature);
return from;
}
function _withdrawFromTo(
address from,
address to,
uint128 amount
) internal {
User storage user = users[from];
require(amount > 0, "Can't withdraw zero");
require(amount <= user.freeUSDCCollateral, "Not enough freeCollateral");
require(amount < uint128(type(int128).max), "Amount too large");
user.freeUSDCCollateral -= amount;
Constants.USDC.transfer(to, amount);
emit CollateralChange(from, -int128(amount));
}
function _withdrawAllFromTo(address from, address to)
internal
returns (uint256)
{
User storage user = users[from];
uint128 amount = user.freeUSDCCollateral;
require(amount > 0, "Can't withdraw zero");
require(amount < uint128(type(int128).max), "Amount too large");
user.freeUSDCCollateral = 0;
Constants.USDC.transfer(to, amount);
emit CollateralChange(from, -int128(amount));
return amount;
}
function deposit(uint128 amount) external override {
Constants.USDC.transferFrom(msg.sender, address(this), amount);
User storage user = users[msg.sender];
(user.freeUSDCCollateral, user.exists) = (
user.freeUSDCCollateral + amount,
true
);
emit CollateralChange(msg.sender, int256(uint256(amount)).toInt128());
}
function depositTo(address target, uint128 amount) external override {
Constants.USDC.transferFrom(msg.sender, address(this), amount);
User storage user = users[target];
(user.freeUSDCCollateral, user.exists) = (
user.freeUSDCCollateral + amount,
true
);
emit CollateralChange(target, int256(uint256(amount)).toInt128());
}
function invalidate(uint64 newInvalidation) external override {
_invalidate(msg.sender, newInvalidation);
}
function invalidateOther(
InvalidationMessage calldata invalidationMsg,
bytes calldata signature
) external override {
address issuer = _hashTypedDataV4(
keccak256(
abi.encode(INVALIDATION_MESSAGE_TYPE, invalidationMsg.newInvalidation)
)
).recover(signature);
_invalidate(issuer, invalidationMsg.newInvalidation);
}
function _invalidate(address issuer, uint64 newInvalidation) internal {
require(
users[issuer].invalidation <= newInvalidation,
"Too low invalidation"
);
users[issuer].invalidation = newInvalidation;
emit Invalidation(issuer, newInvalidation);
}
function takeTicket(
bytes memory signature,
Ticket.Payload memory payload,
bytes32 detailsHash,
bytes32 takeParams
) external override returns (address) {
address issuer = recoverTicketMaker(payload, detailsHash, signature);
address trader = msg.sender;
require(payload.nonce > users[issuer].invalidation, "Invalidated ticket");
require(payload.deadline > block.timestamp, "Ticket expired");
bytes32 hashVal = Ticket.hashVal(payload.details, issuer);
// contr=0 if this is the first take
ILogiumBinaryBetCore contr = contractFromTicketHash(
hashVal,
payload.betImplementation
);
uint256 issuerPrice;
uint256 traderPrice;
if (address(contr) == address(0x0))
(contr, issuerPrice, traderPrice) = createAndIssue(
hashVal,
payload,
detailsHash,
trader,
takeParams
);
else
(issuerPrice, traderPrice) = contr.issue(
detailsHash,
trader,
takeParams,
payload.volume,
payload.details
);
// note with specially crafted betImplementation reentrancy may happen here. In such a case issuer invalidation and freeCollateral may have changed.
// Thus issuer can't relay on invalidation being triggered by some call made by betImplementation issue function that involves untrusted contracts.
// Generally bet implementation should not perform any external calls that may call back to LogiumCore.
// BetImplementation address was accepted by issuer by signing the ticket, thus we can ignore if it would be violated now.
require(
issuerPrice <= users[issuer].freeUSDCCollateral,
"Collateral not available"
);
// perform contract issue state changes
// checks not needed as checked just above, overflow not possible as availableCollateral fits uint128
unchecked {
users[issuer].freeUSDCCollateral -= uint128(issuerPrice);
}
Constants.USDC.transferFrom(trader, address(contr), traderPrice);
Constants.USDC.transfer(address(contr), issuerPrice);
// will not overflow as issuerPrice < availableCollateral <= uint128.max
emit CollateralChange(issuer, (-int256(issuerPrice)).toInt128());
emit BetEmitted(
issuer,
trader,
payload.betImplementation,
takeParams,
payload.details
);
return address(contr);
}
function contractFromTicketHash(
bytes32 hashVal,
ILogiumBinaryBetCore logiumBinaryBetImplementation
) public view override returns (ILogiumBinaryBetCore) {
ILogiumBinaryBetCore contr = ILogiumBinaryBetCore(
Clones.predictDeterministicAddress(
address(logiumBinaryBetImplementation),
hashVal
)
);
if (Address.isContract(address(contr)))
//Call from constructor of contr is not possible
return contr;
else return ILogiumBinaryBetCore(address(0x0));
}
/// @notice Create contract for given ticket and issue specified amount of bet to trader
/// @dev Uses CREATE2 to make a thin clone on a predictable address
/// @param payload the bet ticket
/// @param trader trader/ticket taker address
/// @param takeParams BetImplementation implementation specific ticket take parameters eg. amount of bet units to open
/// @return address of the created bet contract
function createAndIssue(
bytes32 hashVal,
Ticket.Payload memory payload,
bytes32 detailsHash,
address trader,
bytes32 takeParams
)
internal
returns (
ILogiumBinaryBetCore,
uint256,
uint256
)
{
ILogiumBinaryBetCore newContr = ILogiumBinaryBetCore(
Clones.cloneDeterministic(address(payload.betImplementation), hashVal)
);
(uint256 issuerPrice, uint256 traderPrice) = newContr.initAndIssue(
detailsHash,
trader,
takeParams,
payload.volume,
payload.details
);
return (newContr, issuerPrice, traderPrice);
}
function recoverTicketMaker(
Ticket.Payload memory payload,
bytes32 detailsHash,
bytes memory signature
) internal view returns (address) {
bytes32 fullTypeHash = fullTypeHashForBetImplementation[
payload.betImplementation
];
require(fullTypeHash != 0x0, "Disallowed master");
return
_hashTypedDataV4(
keccak256(
abi.encode(
fullTypeHash,
payload.volume,
payload.nonce,
payload.deadline,
payload.betImplementation,
detailsHash
)
)
).recover(signature);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Multicall.sol)
pragma solidity ^0.8.0;
import "./Address.sol";
/**
* @dev Provides a function to batch together multiple calls in a single external call.
*
* _Available since v4.1._
*/
abstract contract Multicall {
/**
* @dev Receives and executes a batch of function calls on this contract.
*/
function multicall(bytes[] calldata data) external returns (bytes[] memory results) {
results = new bytes[](data.length);
for (uint256 i = 0; i < data.length; i++) {
results[i] = Address.functionDelegateCall(address(this), data[i]);
}
return results;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeCast.sol)
pragma solidity ^0.8.0;
/**
* @dev Wrappers over Solidity's uintXX/intXX casting operators with added overflow
* checks.
*
* Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
* easily result in undesired exploitation or bugs, since developers usually
* assume that overflows raise errors. `SafeCast` restores this intuition by
* reverting the transaction when such an operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*
* Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
* all math on `uint256` and `int256` and then downcasting.
*/
library SafeCast {
/**
* @dev Returns the downcasted uint224 from uint256, reverting on
* overflow (when the input is greater than largest uint224).
*
* Counterpart to Solidity's `uint224` operator.
*
* Requirements:
*
* - input must fit into 224 bits
*/
function toUint224(uint256 value) internal pure returns (uint224) {
require(value <= type(uint224).max, "SafeCast: value doesn't fit in 224 bits");
return uint224(value);
}
/**
* @dev Returns the downcasted uint128 from uint256, reverting on
* overflow (when the input is greater than largest uint128).
*
* Counterpart to Solidity's `uint128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*/
function toUint128(uint256 value) internal pure returns (uint128) {
require(value <= type(uint128).max, "SafeCast: value doesn't fit in 128 bits");
return uint128(value);
}
/**
* @dev Returns the downcasted uint96 from uint256, reverting on
* overflow (when the input is greater than largest uint96).
*
* Counterpart to Solidity's `uint96` operator.
*
* Requirements:
*
* - input must fit into 96 bits
*/
function toUint96(uint256 value) internal pure returns (uint96) {
require(value <= type(uint96).max, "SafeCast: value doesn't fit in 96 bits");
return uint96(value);
}
/**
* @dev Returns the downcasted uint64 from uint256, reverting on
* overflow (when the input is greater than largest uint64).
*
* Counterpart to Solidity's `uint64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*/
function toUint64(uint256 value) internal pure returns (uint64) {
require(value <= type(uint64).max, "SafeCast: value doesn't fit in 64 bits");
return uint64(value);
}
/**
* @dev Returns the downcasted uint32 from uint256, reverting on
* overflow (when the input is greater than largest uint32).
*
* Counterpart to Solidity's `uint32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*/
function toUint32(uint256 value) internal pure returns (uint32) {
require(value <= type(uint32).max, "SafeCast: value doesn't fit in 32 bits");
return uint32(value);
}
/**
* @dev Returns the downcasted uint16 from uint256, reverting on
* overflow (when the input is greater than largest uint16).
*
* Counterpart to Solidity's `uint16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*/
function toUint16(uint256 value) internal pure returns (uint16) {
require(value <= type(uint16).max, "SafeCast: value doesn't fit in 16 bits");
return uint16(value);
}
/**
* @dev Returns the downcasted uint8 from uint256, reverting on
* overflow (when the input is greater than largest uint8).
*
* Counterpart to Solidity's `uint8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*/
function toUint8(uint256 value) internal pure returns (uint8) {
require(value <= type(uint8).max, "SafeCast: value doesn't fit in 8 bits");
return uint8(value);
}
/**
* @dev Converts a signed int256 into an unsigned uint256.
*
* Requirements:
*
* - input must be greater than or equal to 0.
*/
function toUint256(int256 value) internal pure returns (uint256) {
require(value >= 0, "SafeCast: value must be positive");
return uint256(value);
}
/**
* @dev Returns the downcasted int128 from int256, reverting on
* overflow (when the input is less than smallest int128 or
* greater than largest int128).
*
* Counterpart to Solidity's `int128` operator.
*
* Requirements:
*
* - input must fit into 128 bits
*
* _Available since v3.1._
*/
function toInt128(int256 value) internal pure returns (int128) {
require(value >= type(int128).min && value <= type(int128).max, "SafeCast: value doesn't fit in 128 bits");
return int128(value);
}
/**
* @dev Returns the downcasted int64 from int256, reverting on
* overflow (when the input is less than smallest int64 or
* greater than largest int64).
*
* Counterpart to Solidity's `int64` operator.
*
* Requirements:
*
* - input must fit into 64 bits
*
* _Available since v3.1._
*/
function toInt64(int256 value) internal pure returns (int64) {
require(value >= type(int64).min && value <= type(int64).max, "SafeCast: value doesn't fit in 64 bits");
return int64(value);
}
/**
* @dev Returns the downcasted int32 from int256, reverting on
* overflow (when the input is less than smallest int32 or
* greater than largest int32).
*
* Counterpart to Solidity's `int32` operator.
*
* Requirements:
*
* - input must fit into 32 bits
*
* _Available since v3.1._
*/
function toInt32(int256 value) internal pure returns (int32) {
require(value >= type(int32).min && value <= type(int32).max, "SafeCast: value doesn't fit in 32 bits");
return int32(value);
}
/**
* @dev Returns the downcasted int16 from int256, reverting on
* overflow (when the input is less than smallest int16 or
* greater than largest int16).
*
* Counterpart to Solidity's `int16` operator.
*
* Requirements:
*
* - input must fit into 16 bits
*
* _Available since v3.1._
*/
function toInt16(int256 value) internal pure returns (int16) {
require(value >= type(int16).min && value <= type(int16).max, "SafeCast: value doesn't fit in 16 bits");
return int16(value);
}
/**
* @dev Returns the downcasted int8 from int256, reverting on
* overflow (when the input is less than smallest int8 or
* greater than largest int8).
*
* Counterpart to Solidity's `int8` operator.
*
* Requirements:
*
* - input must fit into 8 bits.
*
* _Available since v3.1._
*/
function toInt8(int256 value) internal pure returns (int8) {
require(value >= type(int8).min && value <= type(int8).max, "SafeCast: value doesn't fit in 8 bits");
return int8(value);
}
/**
* @dev Converts an unsigned uint256 into a signed int256.
*
* Requirements:
*
* - input must be less than or equal to maxInt256.
*/
function toInt256(uint256 value) internal pure returns (int256) {
// Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
require(value <= uint256(type(int256).max), "SafeCast: value doesn't fit in an int256");
return int256(value);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// SPDX-License-Identifier: NONE
/** =========================================================================
* LICENSE
* 1. The Source code developed by the Owner, may be used in interaction with
* any smart contract only within the logium.org platform on which all
* transactions using the Source code shall be conducted. The source code may
* be also used to develop tools for trading at logium.org platform.
* 2. It is unacceptable for third parties to undertake any actions aiming to
* modify the Source code of logium.org in order to adapt it to work with a
* different smart contract than the one indicated by the Owner by default,
* without prior notification to the Owner and obtaining its written consent.
* 3. It is prohibited to copy, distribute, or modify the Source code without
* the prior written consent of the Owner.
* 4. Source code is subject to copyright, and therefore constitutes the subject
* to legal protection. It is unacceptable for third parties to use all or
* any parts of the Source code for any purpose without the Owner's prior
* written consent.
* 5. All content within the framework of the Source code, including any
* modifications and changes to the Source code provided by the Owner,
* constitute the subject to copyright and is therefore protected by law. It
* is unacceptable for third parties to use contents found within the
* framework of the product without the Owner’s prior written consent.
* 6. To the extent permitted by applicable law, the Source code is provided on
* an "as is" basis. The Owner hereby disclaims all warranties and
* conditions, express or implied, including (without limitation) warranties
* of merchantability or fitness for a particular purpose.
* ========================================================================= */
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "../interfaces/logiumBinaryBet/ILogiumBinaryBetCore.sol";
/// @title Ticket library with structure and helper functions
/// @notice allows calculation of ticket properties and validation of an ticket
/// @dev It's recommended to use all of this function throw `using Ticket for Ticket.Payload;`
library Ticket {
using ECDSA for bytes32;
using Ticket for Payload;
/// Ticket structure as signed by issuer
/// Ticket parameters:
/// - nonce - ticket is only valid for taking if nonce > user.invalidation
/// - deadline - unix secs timestamp, ticket is only valid for taking if blocktime is < deadline
/// - volume - max issuer collateral allowed to be used by this ticket
/// - betImplementation - betImplementation that's code will govern this ticket
/// - details - extra ticket parameters interpreted by betImplementation
struct Payload {
uint128 volume;
uint64 nonce;
uint256 deadline;
ILogiumBinaryBetCore betImplementation;
bytes details;
}
/// Structure with ticket properties that affect hashVal
struct Immutable {
address maker;
bytes details;
}
/// @notice Calculates hashVal of a maker's ticket. For each unique HashVal only one BetContract is created.
/// Nonce, volume, deadline or betImplementation do not affect the hashVal. Ticket "details" and signer (signing by a different party) do.
/// @param self details
/// @param maker the maker/issuer address
/// @return the hashVal
function hashVal(bytes memory self, address maker)
internal
pure
returns (bytes32)
{
return keccak256(abi.encodePacked(maker, self));
}
function hashValImmutable(Immutable memory self)
internal
pure
returns (bytes32)
{
return keccak256(abi.encodePacked(self.maker, self.details));
}
function fullTypeHash(bytes memory detailsType)
internal
pure
returns (bytes32)
{
return
keccak256(
bytes.concat(
"Ticket(uint128 volume,uint64 nonce,uint256 deadline,address betImplementation,Details details)",
detailsType
)
);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)
pragma solidity ^0.8.0;
import "./ECDSA.sol";
/**
* @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
*
* The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
* thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
* they need in their contracts using a combination of `abi.encode` and `keccak256`.
*
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
address private immutable _CACHED_THIS;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256(
"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
);
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = block.chainid;
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_CACHED_THIS = address(this);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view returns (bytes32) {
if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(
bytes32 typeHash,
bytes32 nameHash,
bytes32 versionHash
) private view returns (bytes32) {
return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return ECDSA.toTypedDataHash(_domainSeparatorV4(), structHash);
}
}
{
"compilationTarget": {
"contracts/LogiumCore.sol": "LogiumCore"
},
"evmVersion": "london",
"libraries": {},
"metadata": {
"bytecodeHash": "ipfs",
"useLiteralContent": true
},
"optimizer": {
"enabled": true,
"runs": 1000000
},
"remappings": []
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ILogiumBinaryBetCore","name":"newBetImplementation","type":"address"}],"name":"AllowedBetImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"issuer","type":"address"},{"indexed":true,"internalType":"address","name":"trader","type":"address"},{"indexed":false,"internalType":"contract ILogiumBinaryBetCore","name":"betImplementation","type":"address"},{"indexed":false,"internalType":"bytes32","name":"takeParams","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"details","type":"bytes"}],"name":"BetEmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"issuer","type":"address"},{"indexed":false,"internalType":"int128","name":"change","type":"int128"}],"name":"CollateralChange","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract ILogiumBinaryBetCore","name":"blockedBetImplementation","type":"address"}],"name":"DisallowedBetImplementation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"issuer","type":"address"},{"indexed":false,"internalType":"uint64","name":"newValue","type":"uint64"}],"name":"Invalidation","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[{"internalType":"contract ILogiumBinaryBetCore","name":"newBetImplementation","type":"address"}],"name":"allowBetImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"hashVal","type":"bytes32"},{"internalType":"contract ILogiumBinaryBetCore","name":"logiumBinaryBetImplementation","type":"address"}],"name":"contractFromTicketHash","outputs":[{"internalType":"contract ILogiumBinaryBetCore","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"target","type":"address"},{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"depositTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ILogiumBinaryBetCore","name":"blockedBetImplementation","type":"address"}],"name":"disallowBetImplementation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint64","name":"newInvalidation","type":"uint64"}],"name":"invalidate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"uint64","name":"newInvalidation","type":"uint64"}],"internalType":"struct ILogiumCoreIssuer.InvalidationMessage","name":"invalidationMsg","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"invalidateOther","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract ILogiumBinaryBetCore","name":"betImplementation","type":"address"}],"name":"isAllowedBetImplementation","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"multicall","outputs":[{"internalType":"bytes[]","name":"results","type":"bytes[]"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"signature","type":"bytes"},{"components":[{"internalType":"uint128","name":"volume","type":"uint128"},{"internalType":"uint64","name":"nonce","type":"uint64"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"contract ILogiumBinaryBetCore","name":"betImplementation","type":"address"},{"internalType":"bytes","name":"details","type":"bytes"}],"internalType":"struct Ticket.Payload","name":"payload","type":"tuple"},{"internalType":"bytes32","name":"detailsHash","type":"bytes32"},{"internalType":"bytes32","name":"takeParams","type":"bytes32"}],"name":"takeTicket","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"users","outputs":[{"internalType":"uint128","name":"freeUSDCCollateral","type":"uint128"},{"internalType":"uint64","name":"invalidation","type":"uint64"},{"internalType":"bool","name":"exists","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint128","name":"amount","type":"uint128"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"withdrawAll","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"internalType":"struct ILogiumCoreIssuer.WithdrawAuthorization","name":"authorization","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"withdrawAllFrom","outputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"amount","type":"uint128"},{"components":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"expiry","type":"uint256"}],"internalType":"struct ILogiumCoreIssuer.WithdrawAuthorization","name":"authorization","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"withdrawFrom","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"nonpayable","type":"function"}]