Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00
Cross-Chain Transactions
Loading...
Loading
Contract Name:
SportsAMMV2LiquidityPoolData
Compiler Version
v0.8.20+commit.a1b79de6
Optimization Enabled:
Yes with 200 runs
Other Settings:
paris EvmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "../../utils/proxy/ProxyOwned.sol";
import "../../utils/proxy/ProxyPausable.sol";
import "./../LiquidityPool/SportsAMMV2LiquidityPool.sol";
contract SportsAMMV2LiquidityPoolData is Initializable, ProxyOwned, ProxyPausable {
struct LiquidityPoolData {
address collateral;
bool started;
uint maxAllowedDeposit;
uint round;
uint totalDeposited;
uint minDepositAmount;
uint maxAllowedUsers;
uint usersCurrentlyInPool;
bool canCloseCurrentRound;
bool paused;
uint roundLength;
uint allocationCurrentRound;
uint lifetimePnl;
uint roundEndTime;
}
struct UserLiquidityPoolData {
uint balanceCurrentRound;
uint balanceNextRound;
bool withdrawalRequested;
uint withdrawalShare;
}
struct RoundTicketsData {
uint totalTickets;
uint numOfClosedTickets;
uint numOfPendingTickets;
address[] pendingTickets;
}
function initialize(address _owner) external initializer {
setOwner(_owner);
}
/// @notice getLiquidityPoolData returns liquidity pool data
/// @param liquidityPool SportsAMMV2LiquidityPool
/// @return LiquidityPoolData
function getLiquidityPoolData(SportsAMMV2LiquidityPool liquidityPool) external view returns (LiquidityPoolData memory) {
uint round = liquidityPool.round();
return
LiquidityPoolData(
address(liquidityPool.collateral()),
liquidityPool.started(),
liquidityPool.maxAllowedDeposit(),
round,
liquidityPool.totalDeposited(),
liquidityPool.minDepositAmount(),
liquidityPool.maxAllowedUsers(),
liquidityPool.usersCurrentlyInPool(),
liquidityPool.canCloseCurrentRound(),
liquidityPool.paused(),
liquidityPool.roundLength(),
liquidityPool.allocationPerRound(round),
liquidityPool.cumulativeProfitAndLoss(round > 0 ? round - 1 : 0),
liquidityPool.getRoundEndTime(round)
);
}
/// @notice getUserLiquidityPoolData returns user liquidity pool data
/// @param liquidityPool SportsAMMV2LiquidityPool
/// @param user address of the user
/// @return UserLiquidityPoolData
function getUserLiquidityPoolData(
SportsAMMV2LiquidityPool liquidityPool,
address user
) external view returns (UserLiquidityPoolData memory) {
uint round = liquidityPool.round();
return
UserLiquidityPoolData(
liquidityPool.balancesPerRound(round, user),
liquidityPool.balancesPerRound(round + 1, user),
liquidityPool.withdrawalRequested(user),
liquidityPool.withdrawalShare(user)
);
}
/// @notice getCurrentRoundTicketsData returns current round ticket data
/// @param liquidityPool SportsAMMV2LiquidityPool
/// @return RoundTicketsData
function getCurrentRoundTicketsData(
SportsAMMV2LiquidityPool liquidityPool
) external view returns (RoundTicketsData memory) {
uint round = liquidityPool.round();
uint numberOfTradingTickets = liquidityPool.getNumberOfTradingTicketsPerRound(round);
address[] memory tradingTickets = new address[](numberOfTradingTickets);
address ticket;
uint counter;
for (uint i = 0; i < numberOfTradingTickets; i++) {
ticket = liquidityPool.tradingTicketsPerRound(round, i);
if (!liquidityPool.ticketAlreadyExercisedInRound(round, ticket)) {
tradingTickets[i] = ticket;
++counter;
}
}
address[] memory pendingTickets = new address[](counter);
uint j;
for (uint i = 0; i < numberOfTradingTickets; i++) {
if (tradingTickets[i] != address(0) && j < counter) {
pendingTickets[j] = tradingTickets[i];
++j;
}
}
return
RoundTicketsData(
numberOfTradingTickets,
(numberOfTradingTickets - pendingTickets.length),
pendingTickets.length,
pendingTickets
);
}
/// @notice getCurrentRoundTickets returns current round tickets
/// @param liquidityPool SportsAMMV2LiquidityPool
/// @return tickets
function getCurrentRoundTickets(
SportsAMMV2LiquidityPool liquidityPool
) external view returns (address[] memory tickets) {
uint round = liquidityPool.round();
return _getRoundTickets(liquidityPool, round);
}
/// @notice getRoundTickets returns round tickets
/// @param liquidityPool SportsAMMV2LiquidityPool
/// @param round round to get tickets for
/// @return tickets
function getRoundTickets(
SportsAMMV2LiquidityPool liquidityPool,
uint round
) external view returns (address[] memory tickets) {
return _getRoundTickets(liquidityPool, round);
}
function _getRoundTickets(
SportsAMMV2LiquidityPool liquidityPool,
uint round
) internal view returns (address[] memory tickets) {
uint numberOfTradingTickets = liquidityPool.getNumberOfTradingTicketsPerRound(round);
tickets = new address[](numberOfTradingTickets);
for (uint i = 0; i < numberOfTradingTickets; i++) {
tickets[i] = liquidityPool.tradingTicketsPerRound(round, i);
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.20;
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```solidity
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
*
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Storage of the initializable contract.
*
* It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
* when using with upgradeable contracts.
*
* @custom:storage-location erc7201:openzeppelin.storage.Initializable
*/
struct InitializableStorage {
/**
* @dev Indicates that the contract has been initialized.
*/
uint64 _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool _initializing;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;
/**
* @dev The contract is already initialized.
*/
error InvalidInitialization();
/**
* @dev The contract is not initializing.
*/
error NotInitializing();
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint64 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts.
*
* Similar to `reinitializer(1)`, except that in the context of a constructor an `initializer` may be invoked any
* number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
* production.
*
* Emits an {Initialized} event.
*/
modifier initializer() {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
// Cache values to avoid duplicated sloads
bool isTopLevelCall = !$._initializing;
uint64 initialized = $._initialized;
// Allowed calls:
// - initialSetup: the contract is not in the initializing state and no previous version was
// initialized
// - construction: the contract is initialized at version 1 (no reininitialization) and the
// current contract is just being deployed
bool initialSetup = initialized == 0 && isTopLevelCall;
bool construction = initialized == 1 && address(this).code.length == 0;
if (!initialSetup && !construction) {
revert InvalidInitialization();
}
$._initialized = 1;
if (isTopLevelCall) {
$._initializing = true;
}
_;
if (isTopLevelCall) {
$._initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* A reinitializer may be used after the original initialization step. This is essential to configure modules that
* are added through upgrades and that require initialization.
*
* When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
* cannot be nested. If one is invoked in the context of another, execution will revert.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*
* WARNING: Setting the version to 2**64 - 1 will prevent any future reinitialization.
*
* Emits an {Initialized} event.
*/
modifier reinitializer(uint64 version) {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing || $._initialized >= version) {
revert InvalidInitialization();
}
$._initialized = version;
$._initializing = true;
_;
$._initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
_checkInitializing();
_;
}
/**
* @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
*/
function _checkInitializing() internal view virtual {
if (!_isInitializing()) {
revert NotInitializing();
}
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*
* Emits an {Initialized} event the first time it is successfully executed.
*/
function _disableInitializers() internal virtual {
// solhint-disable-next-line var-name-mixedcase
InitializableStorage storage $ = _getInitializableStorage();
if ($._initializing) {
revert InvalidInitialization();
}
if ($._initialized != type(uint64).max) {
$._initialized = type(uint64).max;
emit Initialized(type(uint64).max);
}
}
/**
* @dev Returns the highest version that has been initialized. See {reinitializer}.
*/
function _getInitializedVersion() internal view returns (uint64) {
return _getInitializableStorage()._initialized;
}
/**
* @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
*/
function _isInitializing() internal view returns (bool) {
return _getInitializableStorage()._initializing;
}
/**
* @dev Returns a pointer to the storage namespace.
*/
// solhint-disable-next-line var-name-mixedcase
function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
assembly {
$.slot := INITIALIZABLE_STORAGE
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Context.sol)
pragma solidity ^0.8.20;
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @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 ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
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 (last updated v5.0.0) (utils/Pausable.sol)
pragma solidity ^0.8.20;
import {ContextUpgradeable} from "../utils/ContextUpgradeable.sol";
import {Initializable} from "../proxy/utils/Initializable.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
/// @custom:storage-location erc7201:openzeppelin.storage.Pausable
struct PausableStorage {
bool _paused;
}
// keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Pausable")) - 1)) & ~bytes32(uint256(0xff))
bytes32 private constant PausableStorageLocation = 0xcd5ed15c6e187e77e9aee88184c21f4f2182ab5827cb3b7e07fbedcd63f03300;
function _getPausableStorage() private pure returns (PausableStorage storage $) {
assembly {
$.slot := PausableStorageLocation
}
}
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
/**
* @dev The operation failed because the contract is paused.
*/
error EnforcedPause();
/**
* @dev The operation failed because the contract is not paused.
*/
error ExpectedPause();
/**
* @dev Initializes the contract in unpaused state.
*/
function __Pausable_init() internal onlyInitializing {
__Pausable_init_unchained();
}
function __Pausable_init_unchained() internal onlyInitializing {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
PausableStorage storage $ = _getPausableStorage();
return $._paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
if (paused()) {
revert EnforcedPause();
}
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
if (!paused()) {
revert ExpectedPause();
}
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
PausableStorage storage $ = _getPausableStorage();
$._paused = false;
emit Unpaused(_msgSender());
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (proxy/Clones.sol)
pragma solidity ^0.8.20;
/**
* @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.
*/
library Clones {
/**
* @dev A clone instance deployment failed.
*/
error ERC1167FailedCreateClone();
/**
* @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) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create(0, 0x09, 0x37)
}
if (instance == address(0)) {
revert ERC1167FailedCreateClone();
}
}
/**
* @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) {
/// @solidity memory-safe-assembly
assembly {
// Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
// of the `implementation` address with the bytecode before the address.
mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
// Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
instance := create2(0, 0x09, 0x37, salt)
}
if (instance == address(0)) {
revert ERC1167FailedCreateClone();
}
}
/**
* @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
*/
function predictDeterministicAddress(
address implementation,
bytes32 salt,
address deployer
) internal pure returns (address predicted) {
/// @solidity memory-safe-assembly
assembly {
let ptr := mload(0x40)
mstore(add(ptr, 0x38), deployer)
mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
mstore(add(ptr, 0x14), implementation)
mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
mstore(add(ptr, 0x58), salt)
mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
predicted := keccak256(add(ptr, 0x43), 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: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @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);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC20Permit} from "../extensions/IERC20Permit.sol";
import {Address} from "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev An operation with an ERC20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data);
if (returndata.length != 0 && !abi.decode(returndata, (bool))) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return success && (returndata.length == 0 || abi.decode(returndata, (bool))) && address(token).code.length > 0;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (utils/Address.sol)
pragma solidity ^0.8.20;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev The ETH balance of the account is not enough to perform the operation.
*/
error AddressInsufficientBalance(address account);
/**
* @dev There's no code at `target` (it is not a contract).
*/
error AddressEmptyCode(address target);
/**
* @dev A call to an address target failed. The target may have reverted.
*/
error FailedInnerCall();
/**
* @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://consensys.net/diligence/blog/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.8.20/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
if (address(this).balance < amount) {
revert AddressInsufficientBalance(address(this));
}
(bool success, ) = recipient.call{value: amount}("");
if (!success) {
revert FailedInnerCall();
}
}
/**
* @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 or custom error, it is bubbled
* up by this function (like regular Solidity function calls). However, if
* the call reverted with no returned reason, this function reverts with a
* {FailedInnerCall} error.
*
* 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.
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0);
}
/**
* @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`.
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
if (address(this).balance < value) {
revert AddressInsufficientBalance(address(this));
}
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and reverts if the target
* was not a contract or bubbling up the revert reason (falling back to {FailedInnerCall}) in case of an
* unsuccessful call.
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata
) internal view returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
// only check if target is a contract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
if (returndata.length == 0 && target.code.length == 0) {
revert AddressEmptyCode(target);
}
return returndata;
}
}
/**
* @dev Tool to verify that a low level call was successful, and reverts if it wasn't, either by bubbling the
* revert reason or with a default {FailedInnerCall} error.
*/
function verifyCallResult(bool success, bytes memory returndata) internal pure returns (bytes memory) {
if (!success) {
_revert(returndata);
} else {
return returndata;
}
}
/**
* @dev Reverts with returndata if present. Otherwise reverts with {FailedInnerCall}.
*/
function _revert(bytes memory returndata) private pure {
// 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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert FailedInnerCall();
}
}
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IAddressManager {
struct Addresses {
address safeBox;
address referrals;
address stakingThales;
address multiCollateralOnOffRamp;
address pyth;
address speedMarketsAMM;
}
function safeBox() external view returns (address);
function referrals() external view returns (address);
function stakingThales() external view returns (address);
function multiCollateralOnOffRamp() external view returns (address);
function pyth() external view returns (address);
function speedMarketsAMM() external view returns (address);
function getAddresses() external view returns (Addresses memory);
function getAddresses(string[] calldata _contractNames) external view returns (address[] memory contracts);
function getAddress(string memory _contractName) external view returns (address contract_);
function checkIfContractExists(string memory _contractName) external view returns (bool contractExists);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IPriceFeed {
// Structs
struct RateAndUpdatedTime {
uint216 rate;
uint40 time;
}
// Mutative functions
function addAggregator(bytes32 currencyKey, address aggregatorAddress) external;
function removeAggregator(bytes32 currencyKey) external;
// Views
function rateForCurrency(bytes32 currencyKey) external view returns (uint);
function rateAndUpdatedTime(bytes32 currencyKey) external view returns (uint rate, uint time);
function getRates() external view returns (uint[] memory);
function getCurrencies() external view returns (bytes32[] memory);
}// SPDX-License-Identifier: MIT
pragma solidity >=0.5.16;
interface IStakingThales {
function updateVolume(address account, uint amount) external;
function updateStakingRewards(
uint _currentPeriodRewards,
uint _extraRewards,
uint _revShare
) external;
/* ========== VIEWS / VARIABLES ========== */
function totalStakedAmount() external view returns (uint);
function stakedBalanceOf(address account) external view returns (uint);
function currentPeriodRewards() external view returns (uint);
function currentPeriodFees() external view returns (uint);
function getLastPeriodOfClaimedRewards(address account) external view returns (uint);
function getRewardsAvailable(address account) external view returns (uint);
function getRewardFeesAvailable(address account) external view returns (uint);
function getAlreadyClaimedRewards(address account) external view returns (uint);
function getContractRewardFunds() external view returns (uint);
function getContractFeeFunds() external view returns (uint);
function getAMMVolume(address account) external view returns (uint);
function decreaseAndTransferStakedThales(address account, uint amount) external;
function increaseAndTransferStakedThales(address account, uint amount) external;
function updateVolumeAtAmountDecimals(
address account,
uint amount,
uint decimals
) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// internal
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";
contract Ticket {
using SafeERC20 for IERC20;
uint private constant ONE = 1e18;
enum Phase {
Trading,
Maturity,
Expiry
}
struct MarketData {
bytes32 gameId;
uint16 sportId;
uint16 typeId;
uint maturity;
uint8 status;
int24 line;
uint24 playerId;
uint8 position;
uint odd;
ISportsAMMV2.CombinedPosition[] combinedPositions;
}
struct TicketInit {
MarketData[] _markets;
uint _buyInAmount;
uint _fees;
uint _totalQuote;
address _sportsAMM;
address _ticketOwner;
IERC20 _collateral;
uint _expiry;
bool _isLive;
}
ISportsAMMV2 public sportsAMM;
address public ticketOwner;
IERC20 public collateral;
uint public buyInAmount;
uint public fees;
uint public totalQuote;
uint public numOfMarkets;
uint public expiry;
uint public createdAt;
bool public resolved;
bool public paused;
bool public initialized;
bool public cancelled;
bool public isLive;
mapping(uint => MarketData) public markets;
uint public finalPayout;
/* ========== CONSTRUCTOR ========== */
/// @notice initialize the ticket contract
/// @param params all parameters for Init
function initialize(TicketInit calldata params) external {
require(!initialized, "Ticket already initialized");
initialized = true;
sportsAMM = ISportsAMMV2(params._sportsAMM);
numOfMarkets = params._markets.length;
for (uint i = 0; i < numOfMarkets; i++) {
markets[i] = params._markets[i];
}
buyInAmount = params._buyInAmount;
fees = params._fees;
totalQuote = params._totalQuote;
ticketOwner = params._ticketOwner;
collateral = params._collateral;
expiry = params._expiry;
isLive = params._isLive;
createdAt = block.timestamp;
}
/* ========== EXTERNAL READ FUNCTIONS ========== */
/// @notice checks if the user lost the ticket
/// @return isTicketLost true/false
function isTicketLost() public view returns (bool) {
for (uint i = 0; i < numOfMarkets; i++) {
bool isMarketResolved = sportsAMM.resultManager().isMarketResolved(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].combinedPositions
);
bool isWinningMarketPosition = sportsAMM.resultManager().isWinningMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
if (isMarketResolved && !isWinningMarketPosition) {
return true;
}
}
return false;
}
/// @notice checks are all markets of the ticket resolved
/// @return areAllMarketsResolved true/false
function areAllMarketsResolved() public view returns (bool) {
for (uint i = 0; i < numOfMarkets; i++) {
if (
!sportsAMM.resultManager().isMarketResolved(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].combinedPositions
)
) {
return false;
}
}
return true;
}
/// @notice checks if the user won the ticket
/// @return hasUserWon true/false
function isUserTheWinner() external view returns (bool hasUserWon) {
hasUserWon = _isUserTheWinner();
}
/// @notice checks if the ticket ready to be exercised
/// @return isExercisable true/false
function isTicketExercisable() public view returns (bool isExercisable) {
isExercisable = !resolved && (areAllMarketsResolved() || isTicketLost());
}
/// @notice gets current phase of the ticket
/// @return phase ticket phase
function phase() public view returns (Phase) {
return
isTicketExercisable() || resolved ? ((expiry < block.timestamp) ? Phase.Expiry : Phase.Maturity) : Phase.Trading;
}
/// @notice gets combined positions of the game
/// @return combinedPositions game combined positions
function getCombinedPositions(
uint _marketIndex
) public view returns (ISportsAMMV2.CombinedPosition[] memory combinedPositions) {
return markets[_marketIndex].combinedPositions;
}
/* ========== EXTERNAL WRITE FUNCTIONS ========== */
/// @notice exercise ticket
function exercise(address _exerciseCollateral) external onlyAMM returns (uint) {
require(!paused, "Market paused");
bool isExercisable = isTicketExercisable();
require(isExercisable, "Ticket not exercisable yet");
uint payoutWithFees = collateral.balanceOf(address(this));
uint payout = payoutWithFees - fees;
bool isCancelled = false;
if (_isUserTheWinner()) {
finalPayout = payout;
isCancelled = true;
for (uint i = 0; i < numOfMarkets; i++) {
bool isCancelledMarketPosition = sportsAMM.resultManager().isCancelledMarketPosition(
markets[i].gameId,
markets[i].typeId,
markets[i].playerId,
markets[i].line,
markets[i].position,
markets[i].combinedPositions
);
if (isCancelledMarketPosition) {
finalPayout = (finalPayout * markets[i].odd) / ONE;
} else {
isCancelled = false;
}
}
if (isCancelled) {
finalPayout = buyInAmount;
}
collateral.safeTransfer(
_exerciseCollateral == address(0) || _exerciseCollateral == address(collateral)
? address(ticketOwner)
: address(sportsAMM),
finalPayout
);
}
// if user is lost or if the user payout was less than anticipated due to cancelled games, send the remainder to AMM
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(address(sportsAMM), balance);
}
_resolve(!isTicketLost(), isCancelled);
return finalPayout;
}
/// @notice expire ticket
function expire(address _beneficiary) external onlyAMM {
require(phase() == Phase.Expiry, "Ticket not in expiry phase");
require(!resolved, "Can't expire resolved ticket");
emit Expired(_beneficiary);
_selfDestruct(_beneficiary);
}
/// @notice cancel the ticket
function cancel() external onlyAMM returns (uint) {
require(!paused, "Market paused");
finalPayout = buyInAmount;
collateral.safeTransfer(address(ticketOwner), finalPayout);
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(address(sportsAMM), balance);
}
_resolve(true, true);
return finalPayout;
}
/// @notice withdraw collateral from the ticket
function withdrawCollateral(address recipient) external onlyAMM {
collateral.safeTransfer(recipient, collateral.balanceOf(address(this)));
}
/* ========== INTERNAL FUNCTIONS ========== */
function _resolve(bool _hasUserWon, bool _cancelled) internal {
resolved = true;
cancelled = _cancelled;
emit Resolved(_hasUserWon, _cancelled);
}
function _selfDestruct(address beneficiary) internal {
uint balance = collateral.balanceOf(address(this));
if (balance != 0) {
collateral.safeTransfer(beneficiary, balance);
}
}
function _isUserTheWinner() internal view returns (bool hasUserWon) {
if (areAllMarketsResolved()) {
hasUserWon = !isTicketLost();
}
}
/* ========== SETTERS ========== */
function setPaused(bool _paused) external {
require(msg.sender == address(sportsAMM.manager()), "Invalid sender");
if (paused == _paused) return;
paused = _paused;
emit PauseUpdated(_paused);
}
/* ========== MODIFIERS ========== */
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "Only the AMM may perform these methods");
_;
}
/* ========== EVENTS ========== */
event Resolved(bool isUserTheWinner, bool cancelled);
event Expired(address beneficiary);
event PauseUpdated(bool paused);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/PausableUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/proxy/Clones.sol";
import "../../utils/proxy/ProxyReentrancyGuard.sol";
import "../../utils/proxy/ProxyOwned.sol";
import "@thales-dao/contracts/contracts/interfaces/IStakingThales.sol";
import "@thales-dao/contracts/contracts/interfaces/IPriceFeed.sol";
import "@thales-dao/contracts/contracts/interfaces/IAddressManager.sol";
import "./SportsAMMV2LiquidityPoolRound.sol";
import "../AMM/Ticket.sol";
import "../../interfaces/ISportsAMMV2Manager.sol";
import "../../interfaces/ISportsAMMV2.sol";
import "../../interfaces/ISportsAMMV2RiskManager.sol";
contract SportsAMMV2LiquidityPool is Initializable, ProxyOwned, PausableUpgradeable, ProxyReentrancyGuard {
/* ========== LIBRARIES ========== */
using SafeERC20 for IERC20;
/* ========== STRUCT DEFINITION ========== */
struct InitParams {
address _owner;
address _sportsAMM;
address _addressManager;
IERC20 _collateral;
uint _roundLength;
uint _maxAllowedDeposit;
uint _minDepositAmount;
uint _maxAllowedUsers;
uint _utilizationRate;
address _safeBox;
uint _safeBoxImpact;
bytes32 _collateralKey;
}
/* ========== CONSTANTS ========== */
uint private constant ONE = 1e18;
uint private constant ONE_PERCENT = 1e16;
uint private constant MAX_APPROVAL = type(uint256).max;
/* ========== STATE VARIABLES ========== */
ISportsAMMV2 public sportsAMM;
IERC20 public collateral;
bool public started;
uint public round;
uint public roundLength;
// actually second round, as first one is default for mixed round and never closes
uint public firstRoundStartTime;
mapping(uint => address) public roundPools;
mapping(uint => address[]) public usersPerRound;
mapping(uint => mapping(address => bool)) public userInRound;
mapping(uint => mapping(address => uint)) public balancesPerRound;
mapping(uint => uint) public allocationPerRound;
mapping(address => bool) public withdrawalRequested;
mapping(address => uint) public withdrawalShare;
mapping(uint => address[]) public tradingTicketsPerRound;
mapping(uint => mapping(address => bool)) public isTradingTicketInARound;
mapping(uint => mapping(address => bool)) public ticketAlreadyExercisedInRound;
mapping(address => uint) public roundPerTicket;
mapping(uint => uint) public profitAndLossPerRound;
mapping(uint => uint) public cumulativeProfitAndLoss;
uint public maxAllowedDeposit;
uint public minDepositAmount;
uint public maxAllowedUsers;
uint public usersCurrentlyInPool;
address public defaultLiquidityProvider;
address public poolRoundMastercopy;
uint public totalDeposited;
bool public roundClosingPrepared;
uint public usersProcessedInRound;
uint public utilizationRate;
address public safeBox;
uint public safeBoxImpact;
IAddressManager public addressManager;
bytes32 public collateralKey;
/* ========== CONSTRUCTOR ========== */
function initialize(InitParams calldata params) external initializer {
setOwner(params._owner);
initNonReentrant();
sportsAMM = ISportsAMMV2(params._sportsAMM);
addressManager = IAddressManager(params._addressManager);
collateral = params._collateral;
collateralKey = params._collateralKey;
roundLength = params._roundLength;
maxAllowedDeposit = params._maxAllowedDeposit;
minDepositAmount = params._minDepositAmount;
maxAllowedUsers = params._maxAllowedUsers;
require(params._utilizationRate <= 1e18, "Utilization rate can't exceed 100%");
utilizationRate = params._utilizationRate;
safeBox = params._safeBox;
require(params._safeBoxImpact <= 1e18, "Safe Box impact can't exceed 100%");
safeBoxImpact = params._safeBoxImpact;
collateral.approve(params._sportsAMM, MAX_APPROVAL);
round = 1;
}
/* ========== EXTERNAL WRITE FUNCTIONS ========== */
/// @notice start pool and begin round #2
function start() external onlyOwner {
require(!started, "LP has already started");
require(allocationPerRound[2] > 0, "Can not start with 0 deposits");
firstRoundStartTime = block.timestamp;
round = 2;
address roundPool = _getOrCreateRoundPool(2);
SportsAMMV2LiquidityPoolRound(roundPool).updateRoundTimes(firstRoundStartTime, getRoundEndTime(2));
started = true;
emit PoolStarted();
}
/// @notice deposit funds from user into pool for the next round
/// @param amount value to be deposited
function deposit(uint amount) external canDeposit(amount) nonReentrant whenNotPaused roundClosingNotPrepared {
_deposit(amount);
}
/// @notice deposit funds from user into pool for the next round
/// @param amount value to be deposited
function _deposit(uint amount) internal {
uint nextRound = round + 1;
address roundPool = _getOrCreateRoundPool(nextRound);
collateral.safeTransferFrom(msg.sender, roundPool, amount);
require(msg.sender != defaultLiquidityProvider, "Can't deposit directly as default LP");
// new user enters the pool
if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[nextRound][msg.sender] == 0) {
require(usersCurrentlyInPool < maxAllowedUsers, "Max amount of users reached");
usersPerRound[nextRound].push(msg.sender);
usersCurrentlyInPool = usersCurrentlyInPool + 1;
}
balancesPerRound[nextRound][msg.sender] += amount;
allocationPerRound[nextRound] += amount;
totalDeposited += amount;
_updateStakingVolume(
IStakingThales(addressManager.getAddress("StakingThales")),
msg.sender,
amount,
address(sportsAMM.defaultCollateral()) == address(collateral)
);
emit Deposited(msg.sender, amount, round);
}
/// @notice get collateral amount needed for trade and store ticket as trading in the round
/// @param ticket to trade
/// @param amount amount to get
function commitTrade(address ticket, uint amount) external nonReentrant whenNotPaused onlyAMM roundClosingNotPrepared {
require(started, "Pool has not started");
require(amount > 0, "Can't commit a zero trade");
uint ticketRound = getTicketRound(ticket);
roundPerTicket[ticket] = ticketRound;
address liquidityPoolRound = _getOrCreateRoundPool(ticketRound);
if (ticketRound == round) {
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
require(
collateral.balanceOf(liquidityPoolRound) >=
(allocationPerRound[round] - ((allocationPerRound[round] * utilizationRate) / ONE)),
"Amount exceeds available utilization for round"
);
} else if (ticketRound > round) {
uint poolBalance = collateral.balanceOf(liquidityPoolRound);
if (poolBalance >= amount) {
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
} else {
uint differenceToLPAsDefault = amount - poolBalance;
_depositAsDefault(differenceToLPAsDefault, liquidityPoolRound, ticketRound);
collateral.safeTransferFrom(liquidityPoolRound, address(sportsAMM), amount);
}
} else {
require(ticketRound == 1, "Invalid round");
_provideAsDefault(amount);
}
tradingTicketsPerRound[ticketRound].push(ticket);
isTradingTicketInARound[ticketRound][ticket] = true;
}
/// @notice transfer collateral amount from AMM to LP (ticket liquidity pool round)
/// @param _ticket to trade
function transferToPool(address _ticket, uint _amount) external whenNotPaused roundClosingNotPrepared onlyAMM {
uint ticketRound = getTicketRound(_ticket);
// if this is a past round, but not the default one, then we send the funds to the current round
if (ticketRound > 1 && ticketRound < round) {
ticketRound = round;
}
address liquidityPoolRound = ticketRound <= 1 ? defaultLiquidityProvider : _getOrCreateRoundPool(ticketRound);
collateral.safeTransferFrom(address(sportsAMM), liquidityPoolRound, _amount);
if (isTradingTicketInARound[ticketRound][_ticket]) {
ticketAlreadyExercisedInRound[ticketRound][_ticket] = true;
}
}
/// @notice request withdrawal from the LP
function withdrawalRequest() external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared {
if (totalDeposited > balancesPerRound[round][msg.sender]) {
totalDeposited -= balancesPerRound[round][msg.sender];
} else {
totalDeposited = 0;
}
usersCurrentlyInPool = usersCurrentlyInPool - 1;
withdrawalRequested[msg.sender] = true;
emit WithdrawalRequested(msg.sender);
}
/// @notice request partial withdrawal from the LP
/// @param _share the percentage the user is wihdrawing from his total deposit
function partialWithdrawalRequest(uint _share) external nonReentrant canWithdraw whenNotPaused roundClosingNotPrepared {
require(_share >= ONE_PERCENT * 10 && _share <= ONE_PERCENT * 90, "Share has to be between 10% and 90%");
uint toWithdraw = (balancesPerRound[round][msg.sender] * _share) / ONE;
if (totalDeposited > toWithdraw) {
totalDeposited -= toWithdraw;
} else {
totalDeposited = 0;
}
withdrawalRequested[msg.sender] = true;
withdrawalShare[msg.sender] = _share;
emit WithdrawalRequested(msg.sender);
}
/// @notice prepare round closing - excercise tickets and ensure there are no tickets left unresolved, handle SB profit and calculate PnL
function prepareRoundClosing() external nonReentrant whenNotPaused roundClosingNotPrepared {
require(canCloseCurrentRound(), "Can't close current round");
// excercise tickets
exerciseTicketsReadyToBeExercised();
address roundPool = roundPools[round];
// final balance is the final amount of collateral in the round pool
uint currentBalance = collateral.balanceOf(roundPool);
// send profit reserved for SafeBox if positive round
if (currentBalance > allocationPerRound[round]) {
uint safeBoxAmount = ((currentBalance - allocationPerRound[round]) * safeBoxImpact) / ONE;
collateral.safeTransferFrom(roundPool, safeBox, safeBoxAmount);
currentBalance = currentBalance - safeBoxAmount;
emit SafeBoxSharePaid(safeBoxImpact, safeBoxAmount);
}
// calculate PnL
// if no allocation for current round
if (allocationPerRound[round] == 0) {
profitAndLossPerRound[round] = 1 ether;
} else {
profitAndLossPerRound[round] = (currentBalance * ONE) / allocationPerRound[round];
}
roundClosingPrepared = true;
emit RoundClosingPrepared(round);
}
/// @notice process round closing batch - update balances and handle withdrawals
/// @param _batchSize size of batch
function processRoundClosingBatch(uint _batchSize) external nonReentrant whenNotPaused {
require(roundClosingPrepared, "Round closing not prepared");
require(usersProcessedInRound < usersPerRound[round].length, "All users already processed");
require(_batchSize > 0, "Batch size has to be greater than 0");
address roundPool = roundPools[round];
uint endCursor = usersProcessedInRound + _batchSize;
if (endCursor > usersPerRound[round].length) {
endCursor = usersPerRound[round].length;
}
bool isDefaultCollateral = address(sportsAMM.defaultCollateral()) == address(collateral);
IStakingThales stakingThales = IStakingThales(addressManager.getAddress("StakingThales"));
for (uint i = usersProcessedInRound; i < endCursor; i++) {
address user = usersPerRound[round][i];
uint balanceAfterCurRound = (balancesPerRound[round][user] * profitAndLossPerRound[round]) / ONE;
if (!withdrawalRequested[user] && (profitAndLossPerRound[round] > 0)) {
balancesPerRound[round + 1][user] = balancesPerRound[round + 1][user] + balanceAfterCurRound;
usersPerRound[round + 1].push(user);
_updateStakingVolume(stakingThales, user, balanceAfterCurRound, isDefaultCollateral);
} else {
if (withdrawalShare[user] > 0) {
uint amountToClaim = (balanceAfterCurRound * withdrawalShare[user]) / ONE;
collateral.safeTransferFrom(roundPool, user, amountToClaim);
emit Claimed(user, amountToClaim);
withdrawalRequested[user] = false;
withdrawalShare[user] = 0;
usersPerRound[round + 1].push(user);
balancesPerRound[round + 1][user] = balanceAfterCurRound - amountToClaim;
_updateStakingVolume(stakingThales, user, (balanceAfterCurRound - amountToClaim), isDefaultCollateral);
} else {
balancesPerRound[round + 1][user] = 0;
collateral.safeTransferFrom(roundPool, user, balanceAfterCurRound);
withdrawalRequested[user] = false;
emit Claimed(user, balanceAfterCurRound);
}
}
usersProcessedInRound = usersProcessedInRound + 1;
}
emit RoundClosingBatchProcessed(round, _batchSize);
}
/// @notice close current round and begin next round - calculate cumulative PnL
function closeRound() external nonReentrant whenNotPaused {
require(roundClosingPrepared, "Round closing not prepared");
require(usersProcessedInRound == usersPerRound[round].length, "Not all users processed yet");
// set for next round to false
roundClosingPrepared = false;
address roundPool = roundPools[round];
// always claim for defaultLiquidityProvider
if (balancesPerRound[round][defaultLiquidityProvider] > 0) {
uint balanceAfterCurRound = (balancesPerRound[round][defaultLiquidityProvider] * profitAndLossPerRound[round]) /
ONE;
collateral.safeTransferFrom(roundPool, defaultLiquidityProvider, balanceAfterCurRound);
emit Claimed(defaultLiquidityProvider, balanceAfterCurRound);
}
if (round == 2) {
cumulativeProfitAndLoss[round] = profitAndLossPerRound[round];
} else {
cumulativeProfitAndLoss[round] = (cumulativeProfitAndLoss[round - 1] * profitAndLossPerRound[round]) / ONE;
}
// start next round
++round;
//add all carried over collateral
allocationPerRound[round] += collateral.balanceOf(roundPool);
totalDeposited = allocationPerRound[round] - balancesPerRound[round][defaultLiquidityProvider];
address roundPoolNewRound = _getOrCreateRoundPool(round);
collateral.safeTransferFrom(roundPool, roundPoolNewRound, collateral.balanceOf(roundPool));
usersProcessedInRound = 0;
emit RoundClosed(round - 1, profitAndLossPerRound[round - 1]);
}
/// @notice iterate all tickets in the current round and exercise those ready to be exercised
function exerciseTicketsReadyToBeExercised() public roundClosingNotPrepared whenNotPaused {
_exerciseTicketsReadyToBeExercised(round);
}
/// @notice iterate all tickets in the default round and exercise those ready to be exercised
function exerciseDefaultRoundTicketsReadyToBeExercised() external whenNotPaused {
_exerciseTicketsReadyToBeExercised(1);
}
/// @notice iterate all tickets in the current round and exercise those ready to be exercised (batch)
/// @param _batchSize number of tickets to be processed
function exerciseTicketsReadyToBeExercisedBatch(
uint _batchSize
) external nonReentrant whenNotPaused roundClosingNotPrepared {
_exerciseTicketsReadyToBeExercisedBatch(_batchSize, round);
}
/// @notice iterate all default round tickets in the current round and exercise those ready to be exercised (batch)
/// @param _batchSize number of tickets to be processed
function exerciseDefaultRoundTicketsReadyToBeExercisedBatch(
uint _batchSize
) external nonReentrant whenNotPaused roundClosingNotPrepared {
_exerciseTicketsReadyToBeExercisedBatch(_batchSize, 1);
}
/* ========== EXTERNAL READ FUNCTIONS ========== */
/// @notice whether the user is currently LPing
/// @param _user to check
/// @return isUserInLP whether the user is currently LPing
function isUserLPing(address _user) external view returns (bool isUserInLP) {
isUserInLP =
(balancesPerRound[round][_user] > 0 || balancesPerRound[round + 1][_user] > 0) &&
(!withdrawalRequested[_user] || withdrawalShare[_user] > 0);
}
/// @notice return the price of the pool collateral
function getCollateralPrice() public view returns (uint) {
return IPriceFeed(addressManager.getAddress("PriceFeed")).rateForCurrency(collateralKey);
}
/// @notice get the pool address for the ticket
/// @param _ticket to check
/// @return roundPool the pool address for the ticket
function getTicketPool(address _ticket) external view returns (address roundPool) {
roundPool = roundPools[getTicketRound(_ticket)];
}
/// @notice checks if all conditions are met to close the round
/// @return bool
function canCloseCurrentRound() public view returns (bool) {
if (!started || block.timestamp < getRoundEndTime(round)) {
return false;
}
Ticket ticket;
address ticketAddress;
for (uint i = 0; i < tradingTicketsPerRound[round].length; i++) {
ticketAddress = tradingTicketsPerRound[round][i];
if (!ticketAlreadyExercisedInRound[round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (!ticket.areAllMarketsResolved()) {
return false;
}
}
}
return true;
}
/// @notice iterate all tickets in the current round and return true if at least one can be exercised
/// @return bool
function hasTicketsReadyToBeExercised() external view returns (bool) {
return _hasTicketsReadyToBeExercised(round);
}
/// @notice iterate all tickets in the default round and return true if at least one can be exercised
/// @return bool
function hasDefaultRoundTicketsReadyToBeExercised() external view returns (bool) {
return _hasTicketsReadyToBeExercised(1);
}
function _hasTicketsReadyToBeExercised(uint _round) internal view returns (bool) {
Ticket ticket;
address ticketAddress;
for (uint i = 0; i < tradingTicketsPerRound[_round].length; i++) {
ticketAddress = tradingTicketsPerRound[_round][i];
if (!ticketAlreadyExercisedInRound[_round][ticketAddress]) {
ticket = Ticket(ticketAddress);
if (ticket.isTicketExercisable() && !ticket.isUserTheWinner()) {
return true;
}
}
}
return false;
}
/// @notice return multiplied PnLs between rounds
/// @param _roundA round number from
/// @param _roundB round number to
/// @return uint
function cumulativePnLBetweenRounds(uint _roundA, uint _roundB) public view returns (uint) {
return (cumulativeProfitAndLoss[_roundB] * profitAndLossPerRound[_roundA]) / cumulativeProfitAndLoss[_roundA];
}
/// @notice return the start time of the passed round
/// @param _round number
/// @return uint the start time of the given round
function getRoundStartTime(uint _round) public view returns (uint) {
return firstRoundStartTime + (_round - 2) * roundLength;
}
/// @notice return the end time of the passed round
/// @param _round number
/// @return uint the end time of the given round
function getRoundEndTime(uint _round) public view returns (uint) {
return firstRoundStartTime + (_round - 1) * roundLength;
}
/// @notice return the round to which a ticket belongs to
/// @param _ticket to get the round for
/// @return ticketRound the min round which the ticket belongs to
function getTicketRound(address _ticket) public view returns (uint ticketRound) {
ticketRound = roundPerTicket[_ticket];
if (ticketRound == 0) {
Ticket ticket = Ticket(_ticket);
uint maturity;
uint16 sportId;
for (uint i = 0; i < ticket.numOfMarkets(); i++) {
(, sportId, , maturity, , , , , ) = ticket.markets(i);
bool isFuture = ISportsAMMV2RiskManager(addressManager.getAddress("SportsAMMV2RiskManager")).isSportIdFuture(
sportId
);
if (maturity > firstRoundStartTime && !isFuture) {
if (i == 0) {
ticketRound = (maturity - firstRoundStartTime) / roundLength + 2;
} else {
// if ticket is cross rounds, use the default round
if (((maturity - firstRoundStartTime) / roundLength + 2) != ticketRound) {
ticketRound = 1;
break;
}
}
} else {
ticketRound = 1;
break;
}
}
}
}
/// @notice return the count of users in current round
/// @return uint the count of users in current round
function getUsersCountInCurrentRound() external view returns (uint) {
return usersPerRound[round].length;
}
/// @notice return the number of tickets in current rount
/// @return numOfTickets the number of tickets in urrent rount
function getNumberOfTradingTicketsPerRound(uint _round) external view returns (uint numOfTickets) {
numOfTickets = tradingTicketsPerRound[_round].length;
}
/* ========== INTERNAL FUNCTIONS ========== */
function _exerciseTicketsReadyToBeExercisedBatch(uint _batchSize, uint _roundNumber) internal {
require(_batchSize > 0, "Batch size has to be greater than 0");
uint count = 0;
for (uint i = 0; i < tradingTicketsPerRound[_roundNumber].length; i++) {
if (count == _batchSize) break;
if (_exerciseTicket(_roundNumber, tradingTicketsPerRound[_roundNumber][i])) {
count += 1;
}
}
}
function _exerciseTicketsReadyToBeExercised(uint _roundNumber) internal {
for (uint i = 0; i < tradingTicketsPerRound[_roundNumber].length; i++) {
_exerciseTicket(_roundNumber, tradingTicketsPerRound[_roundNumber][i]);
}
}
function _exerciseTicket(uint _roundNumber, address ticketAddress) internal returns (bool exercised) {
if (!ticketAlreadyExercisedInRound[_roundNumber][ticketAddress]) {
Ticket ticket = Ticket(ticketAddress);
bool isWinner = ticket.isUserTheWinner();
if (ticket.isTicketExercisable() && !isWinner) {
sportsAMM.exerciseTicket(ticketAddress);
}
if (isWinner || ticket.resolved()) {
ticketAlreadyExercisedInRound[_roundNumber][ticketAddress] = true;
exercised = true;
}
}
}
function _depositAsDefault(uint _amount, address _roundPool, uint _round) internal {
require(defaultLiquidityProvider != address(0), "Default LP not set");
collateral.safeTransferFrom(defaultLiquidityProvider, _roundPool, _amount);
balancesPerRound[_round][defaultLiquidityProvider] += _amount;
allocationPerRound[_round] += _amount;
emit Deposited(defaultLiquidityProvider, _amount, _round);
}
function _provideAsDefault(uint _amount) internal {
require(defaultLiquidityProvider != address(0), "Default LP not set");
collateral.safeTransferFrom(defaultLiquidityProvider, address(sportsAMM), _amount);
balancesPerRound[1][defaultLiquidityProvider] += _amount;
allocationPerRound[1] += _amount;
emit Deposited(defaultLiquidityProvider, _amount, 1);
}
function _getOrCreateRoundPool(uint _round) internal returns (address roundPool) {
roundPool = roundPools[_round];
if (roundPool == address(0)) {
if (_round == 1) {
roundPools[_round] = defaultLiquidityProvider;
roundPool = defaultLiquidityProvider;
} else {
require(poolRoundMastercopy != address(0), "Round pool mastercopy not set");
SportsAMMV2LiquidityPoolRound newRoundPool = SportsAMMV2LiquidityPoolRound(
Clones.clone(poolRoundMastercopy)
);
newRoundPool.initialize(
address(this),
collateral,
_round,
getRoundEndTime(_round - 1),
getRoundEndTime(_round)
);
roundPool = address(newRoundPool);
roundPools[_round] = roundPool;
emit RoundPoolCreated(_round, roundPool);
}
}
}
function _updateStakingVolume(
IStakingThales stakingThales,
address _forUser,
uint _amount,
bool _isDefaultCollateral
) internal {
if (address(stakingThales) != address(0)) {
uint collateralDecimals = ISportsAMMV2Manager(address(collateral)).decimals();
if (!_isDefaultCollateral) {
_amount = (_amount * getCollateralPrice()) / ONE;
}
stakingThales.updateVolumeAtAmountDecimals(_forUser, _amount, collateralDecimals);
}
}
/* ========== SETTERS ========== */
/// @notice Pause/unpause LP
/// @param _setPausing true/false
function setPaused(bool _setPausing) external onlyOwner {
_setPausing ? _pause() : _unpause();
}
/// @notice Set _poolRoundMastercopy
/// @param _poolRoundMastercopy to clone round pools from
function setPoolRoundMastercopy(address _poolRoundMastercopy) external onlyOwner {
require(_poolRoundMastercopy != address(0), "Can not set a zero address!");
poolRoundMastercopy = _poolRoundMastercopy;
emit PoolRoundMastercopyChanged(poolRoundMastercopy);
}
/// @notice Set max allowed deposit
/// @param _maxAllowedDeposit Deposit value
function setMaxAllowedDeposit(uint _maxAllowedDeposit) external onlyOwner {
maxAllowedDeposit = _maxAllowedDeposit;
emit MaxAllowedDepositChanged(_maxAllowedDeposit);
}
/// @notice Set min allowed deposit
/// @param _minDepositAmount Deposit value
function setMinAllowedDeposit(uint _minDepositAmount) external onlyOwner {
minDepositAmount = _minDepositAmount;
emit MinAllowedDepositChanged(_minDepositAmount);
}
/// @notice Set _maxAllowedUsers
/// @param _maxAllowedUsers Deposit value
function setMaxAllowedUsers(uint _maxAllowedUsers) external onlyOwner {
maxAllowedUsers = _maxAllowedUsers;
emit MaxAllowedUsersChanged(_maxAllowedUsers);
}
/// @notice Set SportsAMM contract
/// @param _sportsAMM SportsAMM address
function setSportsAMM(ISportsAMMV2 _sportsAMM) external onlyOwner {
require(address(_sportsAMM) != address(0), "Can not set a zero address!");
if (address(sportsAMM) != address(0)) {
collateral.approve(address(sportsAMM), 0);
}
sportsAMM = _sportsAMM;
collateral.approve(address(sportsAMM), MAX_APPROVAL);
emit SportAMMChanged(address(_sportsAMM));
}
/// @notice Set defaultLiquidityProvider wallet
/// @param _defaultLiquidityProvider default liquidity provider
function setDefaultLiquidityProvider(address _defaultLiquidityProvider) external onlyOwner {
require(_defaultLiquidityProvider != address(0), "Can not set a zero address!");
defaultLiquidityProvider = _defaultLiquidityProvider;
emit DefaultLiquidityProviderChanged(_defaultLiquidityProvider);
}
/// @notice Set length of rounds
/// @param _roundLength Length of a round in seconds
function setRoundLength(uint _roundLength) external onlyOwner {
require(!started, "Can't change round length after start");
roundLength = _roundLength;
emit RoundLengthChanged(_roundLength);
}
/// @notice set utilization rate parameter
/// @param _utilizationRate value as percentage
function setUtilizationRate(uint _utilizationRate) external onlyOwner {
require(_utilizationRate <= 1e18, "Utilization rate can't exceed 100%");
utilizationRate = _utilizationRate;
emit UtilizationRateChanged(_utilizationRate);
}
/// @notice set SafeBox params
/// @param _safeBox where to send a profit reserved for protocol from each round
/// @param _safeBoxImpact how much is the SafeBox percentage
function setSafeBoxParams(address _safeBox, uint _safeBoxImpact) external onlyOwner {
safeBox = _safeBox;
require(safeBoxImpact <= 1e18, "Safe Box impact can't exceed 100%");
safeBoxImpact = _safeBoxImpact;
emit SetSafeBoxParams(_safeBox, _safeBoxImpact);
}
/* ========== MODIFIERS ========== */
modifier canDeposit(uint amount) {
require(!withdrawalRequested[msg.sender], "Withdrawal is requested, cannot deposit");
require(totalDeposited + amount <= maxAllowedDeposit, "Deposit amount exceeds AMM LP cap");
if (balancesPerRound[round][msg.sender] == 0 && balancesPerRound[round + 1][msg.sender] == 0) {
require(amount >= minDepositAmount, "Amount less than minDepositAmount");
}
_;
}
modifier canWithdraw() {
require(started, "Pool has not started");
require(!withdrawalRequested[msg.sender], "Withdrawal already requested");
require(balancesPerRound[round][msg.sender] > 0, "Nothing to withdraw");
require(balancesPerRound[round + 1][msg.sender] == 0, "Can't withdraw as you already deposited for next round");
_;
}
modifier onlyAMM() {
require(msg.sender == address(sportsAMM), "Only the AMM may perform these methods");
_;
}
modifier roundClosingNotPrepared() {
require(!roundClosingPrepared, "Not allowed during roundClosingPrepared");
_;
}
/* ========== EVENTS ========== */
event PoolStarted();
event RoundPoolCreated(uint round, address roundPool);
event Deposited(address user, uint amount, uint round);
event WithdrawalRequested(address user);
event SafeBoxSharePaid(uint safeBoxShare, uint safeBoxAmount);
event RoundClosingPrepared(uint round);
event Claimed(address user, uint amount);
event RoundClosingBatchProcessed(uint round, uint batchSize);
event RoundClosed(uint round, uint roundPnL);
event PoolRoundMastercopyChanged(address newMastercopy);
event SportAMMChanged(address sportAMM);
event DefaultLiquidityProviderChanged(address newProvider);
event RoundLengthChanged(uint roundLength);
event MaxAllowedDepositChanged(uint maxAllowedDeposit);
event MinAllowedDepositChanged(uint minAllowedDeposit);
event MaxAllowedUsersChanged(uint maxAllowedUsersChanged);
event UtilizationRateChanged(uint utilizationRate);
event SetSafeBoxParams(address safeBox, uint safeBoxImpact);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
contract SportsAMMV2LiquidityPoolRound {
/* ========== LIBRARIES ========== */
using SafeERC20 for IERC20;
/* ========== STATE VARIABLES ========== */
// the adddress of the LP contract
address public liquidityPool;
// the adddress of collateral that LP accepts
IERC20 public collateral;
// the round number
uint public round;
// the round start time
uint public roundStartTime;
// the round end time
uint public roundEndTime;
// initialized flag
bool public initialized;
/* ========== CONSTRUCTOR ========== */
/// @notice initialize the storage in the contract with the parameters
/// @param _liquidityPool the adddress of the LP contract
/// @param _collateral the adddress of collateral that LP accepts
/// @param _round the round number
/// @param _roundStartTime the round start time
/// @param _roundEndTime the round end time
function initialize(
address _liquidityPool,
IERC20 _collateral,
uint _round,
uint _roundStartTime,
uint _roundEndTime
) external {
require(!initialized, "Already initialized");
initialized = true;
liquidityPool = _liquidityPool;
collateral = _collateral;
round = _round;
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
collateral.approve(_liquidityPool, type(uint256).max);
}
/// @notice update round times
/// @param _roundStartTime the round start time
/// @param _roundEndTime the round end time
function updateRoundTimes(uint _roundStartTime, uint _roundEndTime) external onlyLiquidityPool {
roundStartTime = _roundStartTime;
roundEndTime = _roundEndTime;
emit RoundTimesUpdated(_roundStartTime, _roundEndTime);
}
modifier onlyLiquidityPool() {
require(msg.sender == liquidityPool, "Only LP may perform this method");
_;
}
event RoundTimesUpdated(uint roundStartTime, uint roundEndTime);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IProxyBetting.sol";
interface IFreeBetsHolder is IProxyBetting {
function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount, address _collateral) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
interface IProxyBetting {
function getActiveTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfActiveTicketsPerUser(address _user) external view returns (uint);
function getResolvedTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfResolvedTicketsPerUser(address _user) external view returns (uint);
function confirmTicketResolved(address _resolvedTicket) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
import "../interfaces/ISportsAMMV2ResultManager.sol";
import "../interfaces/ISportsAMMV2RiskManager.sol";
import "../interfaces/ISportsAMMV2Manager.sol";
import "../interfaces/IFreeBetsHolder.sol";
import "../interfaces/IStakingThalesBettingProxy.sol";
interface ISportsAMMV2 {
struct CombinedPosition {
uint16 typeId;
uint8 position;
int24 line;
}
struct TradeData {
bytes32 gameId;
uint16 sportId;
uint16 typeId;
uint maturity;
uint8 status;
int24 line;
uint24 playerId;
uint[] odds;
bytes32[] merkleProof;
uint8 position;
CombinedPosition[][] combinedPositions;
}
function defaultCollateral() external view returns (IERC20);
function manager() external view returns (ISportsAMMV2Manager);
function resultManager() external view returns (ISportsAMMV2ResultManager);
function safeBoxFee() external view returns (uint);
function exerciseTicket(address _ticket) external;
function riskManager() external view returns (ISportsAMMV2RiskManager);
function freeBetsHolder() external view returns (IFreeBetsHolder);
function stakingThalesBettingProxy() external view returns (IStakingThalesBettingProxy);
function tradeLive(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedQuote,
address _recipient,
address _referrer,
address _collateral
) external returns (address _createdTicket);
function trade(
TradeData[] calldata _tradeData,
uint _buyInAmount,
uint _expectedQuote,
uint _additionalSlippage,
address _referrer,
address _collateral,
bool _isEth
) external returns (address _createdTicket);
function rootPerGame(bytes32 game) external view returns (bytes32);
function paused() external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ISportsAMMV2.sol";
interface ISportsAMMV2Manager {
enum Role {
ROOT_SETTING,
RISK_MANAGING,
MARKET_RESOLVING,
TICKET_PAUSER
}
function isWhitelistedAddress(address _address, Role role) external view returns (bool);
function decimals() external view returns (uint);
function feeToken() external view returns (address);
function isActiveTicket(address _ticket) external view returns (bool);
function getActiveTickets(uint _index, uint _pageSize) external view returns (address[] memory);
function numOfActiveTickets() external view returns (uint);
function getActiveTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfActiveTicketsPerUser(address _user) external view returns (uint);
function getResolvedTicketsPerUser(uint _index, uint _pageSize, address _user) external view returns (address[] memory);
function numOfResolvedTicketsPerUser(address _user) external view returns (uint);
function getTicketsPerGame(uint _index, uint _pageSize, bytes32 _gameId) external view returns (address[] memory);
function numOfTicketsPerGame(bytes32 _gameId) external view returns (uint);
function isKnownTicket(address _ticket) external view returns (bool);
function addNewKnownTicket(ISportsAMMV2.TradeData[] memory _tradeData, address ticket, address user) external;
function resolveKnownTicket(address ticket, address ticketOwner) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ISportsAMMV2.sol";
interface ISportsAMMV2ResultManager {
enum MarketPositionStatus {
Open,
Cancelled,
Winning,
Losing
}
function isMarketResolved(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
ISportsAMMV2.CombinedPosition[] memory combinedPositions
) external view returns (bool isResolved);
function getMarketPositionStatus(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (MarketPositionStatus status);
function isWinningMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isWinning);
function isCancelledMarketPosition(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _position,
ISportsAMMV2.CombinedPosition[] memory _combinedPositions
) external view returns (bool isCancelled);
function getResultsPerMarket(
bytes32 _gameId,
uint16 _typeId,
uint24 _playerId
) external view returns (int24[] memory results);
function resultTypePerMarketType(uint _typeId) external view returns (uint8 marketType);
function setResultsPerMarkets(
bytes32[] memory _gameIds,
uint16[] memory _typeIds,
uint24[] memory _playerIds,
int24[][] memory _results
) external;
function isGameCancelled(bytes32 _gameId) external view returns (bool);
function cancelGames(bytes32[] memory _gameIds) external;
function cancelMarkets(
bytes32[] memory _gameIds,
uint16[] memory _typeIds,
uint24[] memory _playerIds,
int24[] memory _lines
) external;
function cancelMarket(bytes32 _gameId, uint16 _typeId, uint24 _playerId, int24 _line) external;
function cancelGame(bytes32 _gameId) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./ISportsAMMV2.sol";
interface ISportsAMMV2RiskManager {
struct TypeCap {
uint typeId;
uint cap;
}
struct CapData {
uint capPerSport;
uint capPerChild;
TypeCap[] capPerType;
}
struct DynamicLiquidityData {
uint cutoffTimePerSport;
uint cutoffDividerPerSport;
}
struct RiskData {
uint sportId;
CapData capData;
uint riskMultiplierPerSport;
DynamicLiquidityData dynamicLiquidityData;
}
enum RiskStatus {
NoRisk,
OutOfLiquidity,
InvalidCombination
}
function minBuyInAmount() external view returns (uint);
function maxTicketSize() external view returns (uint);
function maxSupportedAmount() external view returns (uint);
function maxSupportedOdds() external view returns (uint);
function expiryDuration() external view returns (uint);
function liveTradingPerSportAndTypeEnabled(uint _sportId, uint _typeId) external view returns (bool _enabled);
function calculateCapToBeUsed(
bytes32 _gameId,
uint16 _sportId,
uint16 _typeId,
uint24 _playerId,
int24 _line,
uint _maturity,
bool _isLive
) external view returns (uint cap);
function checkRisks(
ISportsAMMV2.TradeData[] memory _tradeData,
uint _buyInAmount,
bool _isLive
) external view returns (ISportsAMMV2RiskManager.RiskStatus riskStatus, bool[] memory isMarketOutOfLiquidity);
function checkLimits(
uint _buyInAmount,
uint _totalQuote,
uint _payout,
uint _expectedPayout,
uint _additionalSlippage,
uint _ticketSize
) external view;
function checkAndUpdateRisks(ISportsAMMV2.TradeData[] memory _tradeData, uint _buyInAmount, bool _isLive) external;
function verifyMerkleTree(ISportsAMMV2.TradeData memory _marketTradeData, bytes32 _rootPerGame) external pure;
function isSportIdFuture(uint16 _sportsId) external view returns (bool);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import "./IProxyBetting.sol";
interface IStakingThalesBettingProxy is IProxyBetting {
function preConfirmLiveTrade(bytes32 requestId, uint _buyInAmount) external;
function confirmLiveTrade(bytes32 requestId, address _createdTicket, uint _buyInAmount) external;
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Clone of syntetix contract without constructor
contract ProxyOwned {
address public owner;
address public nominatedOwner;
bool private _initialized;
bool private _transferredAtInit;
function setOwner(address _owner) public {
require(_owner != address(0), "Owner address cannot be 0");
require(!_initialized, "Already initialized, use nominateNewOwner");
_initialized = true;
owner = _owner;
emit OwnerChanged(address(0), _owner);
}
function nominateNewOwner(address _owner) external onlyOwner {
nominatedOwner = _owner;
emit OwnerNominated(_owner);
}
function acceptOwnership() external {
require(msg.sender == nominatedOwner, "You must be nominated before you can accept ownership");
emit OwnerChanged(owner, nominatedOwner);
owner = nominatedOwner;
nominatedOwner = address(0);
}
function transferOwnershipAtInit(address proxyAddress) external onlyOwner {
require(proxyAddress != address(0), "Invalid address");
require(!_transferredAtInit, "Already transferred");
owner = proxyAddress;
_transferredAtInit = true;
emit OwnerChanged(owner, proxyAddress);
}
modifier onlyOwner() {
_onlyOwner();
_;
}
function _onlyOwner() private view {
require(msg.sender == owner, "Only the contract owner may perform this action");
}
event OwnerNominated(address newOwner);
event OwnerChanged(address oldOwner, address newOwner);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
// Inheritance
import "./ProxyOwned.sol";
// Clone of syntetix contract without constructor
contract ProxyPausable is ProxyOwned {
uint public lastPauseTime;
bool public paused;
/**
* @notice Change the paused state of the contract
* @dev Only the contract owner may call this.
*/
function setPaused(bool _paused) external onlyOwner {
// Ensure we're actually changing the state before we do anything
if (_paused == paused) {
return;
}
// Set our paused state.
paused = _paused;
// If applicable, set the last pause time.
if (paused) {
lastPauseTime = block.timestamp;
}
// Let everyone know that our pause state has changed.
emit PauseChanged(paused);
}
event PauseChanged(bool isPaused);
modifier notPaused() {
require(!paused, "This action cannot be performed while the contract is paused");
_;
}
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the `nonReentrant` modifier
* available, which can be aplied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*/
contract ProxyReentrancyGuard {
/// @dev counter to allow mutex lock with only one SSTORE operation
uint256 private _guardCounter;
bool private _initialized;
function initNonReentrant() public {
require(!_initialized, "Already initialized");
_initialized = true;
_guardCounter = 1;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and make it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_guardCounter += 1;
uint256 localCounter = _guardCounter;
_;
require(localCounter == _guardCounter, "ReentrancyGuard: reentrant call");
}
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "paris",
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
},
"libraries": {}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[],"name":"InvalidInitialization","type":"error"},{"inputs":[],"name":"NotInitializing","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"version","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldOwner","type":"address"},{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerNominated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"isPaused","type":"bool"}],"name":"PauseChanged","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract SportsAMMV2LiquidityPool","name":"liquidityPool","type":"address"}],"name":"getCurrentRoundTickets","outputs":[{"internalType":"address[]","name":"tickets","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract SportsAMMV2LiquidityPool","name":"liquidityPool","type":"address"}],"name":"getCurrentRoundTicketsData","outputs":[{"components":[{"internalType":"uint256","name":"totalTickets","type":"uint256"},{"internalType":"uint256","name":"numOfClosedTickets","type":"uint256"},{"internalType":"uint256","name":"numOfPendingTickets","type":"uint256"},{"internalType":"address[]","name":"pendingTickets","type":"address[]"}],"internalType":"struct SportsAMMV2LiquidityPoolData.RoundTicketsData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract SportsAMMV2LiquidityPool","name":"liquidityPool","type":"address"}],"name":"getLiquidityPoolData","outputs":[{"components":[{"internalType":"address","name":"collateral","type":"address"},{"internalType":"bool","name":"started","type":"bool"},{"internalType":"uint256","name":"maxAllowedDeposit","type":"uint256"},{"internalType":"uint256","name":"round","type":"uint256"},{"internalType":"uint256","name":"totalDeposited","type":"uint256"},{"internalType":"uint256","name":"minDepositAmount","type":"uint256"},{"internalType":"uint256","name":"maxAllowedUsers","type":"uint256"},{"internalType":"uint256","name":"usersCurrentlyInPool","type":"uint256"},{"internalType":"bool","name":"canCloseCurrentRound","type":"bool"},{"internalType":"bool","name":"paused","type":"bool"},{"internalType":"uint256","name":"roundLength","type":"uint256"},{"internalType":"uint256","name":"allocationCurrentRound","type":"uint256"},{"internalType":"uint256","name":"lifetimePnl","type":"uint256"},{"internalType":"uint256","name":"roundEndTime","type":"uint256"}],"internalType":"struct SportsAMMV2LiquidityPoolData.LiquidityPoolData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract SportsAMMV2LiquidityPool","name":"liquidityPool","type":"address"},{"internalType":"uint256","name":"round","type":"uint256"}],"name":"getRoundTickets","outputs":[{"internalType":"address[]","name":"tickets","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract SportsAMMV2LiquidityPool","name":"liquidityPool","type":"address"},{"internalType":"address","name":"user","type":"address"}],"name":"getUserLiquidityPoolData","outputs":[{"components":[{"internalType":"uint256","name":"balanceCurrentRound","type":"uint256"},{"internalType":"uint256","name":"balanceNextRound","type":"uint256"},{"internalType":"bool","name":"withdrawalRequested","type":"bool"},{"internalType":"uint256","name":"withdrawalShare","type":"uint256"}],"internalType":"struct SportsAMMV2LiquidityPoolData.UserLiquidityPoolData","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"lastPauseTime","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"nominateNewOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"nominatedOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"_paused","type":"bool"}],"name":"setPaused","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"proxyAddress","type":"address"}],"name":"transferOwnershipAtInit","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
608060405234801561001057600080fd5b50611a34806100206000396000f3fe608060405234801561001057600080fd5b50600436106100f55760003560e01c80635cb40e3e11610097578063a19b984211610066578063a19b984214610218578063c3b83f5f1461022b578063c4d66de81461023e578063d9fefe2a1461025157600080fd5b80635cb40e3e146101c657806379ba5097146101e65780638da5cb5b146101ee57806391b4ded91461020157600080fd5b80633b7540af116100d35780633b7540af1461013557806353a47bb71461015e5780635910dcfe146101895780635c975abb146101a957600080fd5b806313af4035146100fa5780631627540c1461010f57806316c38b3c14610122575b600080fd5b61010d6101083660046116ff565b610299565b005b61010d61011d3660046116ff565b6103cf565b61010d61013036600461172a565b610425565b6101486101433660046116ff565b610497565b6040516101559190611747565b60405180910390f35b600154610171906001600160a01b031681565b6040516001600160a01b039091168152602001610155565b61019c6101973660046116ff565b61084f565b60405161015591906117c0565b6003546101b69060ff1681565b6040519015158152602001610155565b6101d96101d4366004611878565b610ed6565b60405161015591906118a4565b61010d610eeb565b600054610171906001600160a01b031681565b61020a60025481565b604051908152602001610155565b6101d96102263660046116ff565b610fd5565b61010d6102393660046116ff565b61104e565b61010d61024c3660046116ff565b611157565b61026461025f3660046118f1565b611267565b604051610155919081518152602080830151908201526040808301511515908201526060918201519181019190915260800190565b6001600160a01b0381166102f45760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156103605760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016102eb565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6103d7611501565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020016103c4565b61042d611501565b60035460ff16151581151514610494576003805460ff191682151590811790915560ff161561045b57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5906020016103c4565b50565b6104c26040518060800160405280600081526020016000815260200160008152602001606081525090565b6000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015610502573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610526919061192a565b60405163145dee7d60e01b8152600481018290529091506000906001600160a01b0385169063145dee7d90602401602060405180830381865afa158015610571573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610595919061192a565b905060008167ffffffffffffffff8111156105b2576105b2611943565b6040519080825280602002602001820160405280156105db578160200160208202803683370190505b50905060008060005b8481101561071e576040516303d868db60e01b815260048101879052602481018290526001600160a01b038916906303d868db90604401602060405180830381865afa158015610638573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065c9190611959565b6040516313e1422160e11b8152600481018890526001600160a01b038083166024830152919450908916906327c2844290604401602060405180830381865afa1580156106ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d19190611976565b61070c57828482815181106106e8576106e8611993565b6001600160a01b0390921660209283029190910190910152610709826119bf565b91505b80610716816119bf565b9150506105e4565b5060008167ffffffffffffffff81111561073a5761073a611943565b604051908082528060200260200182016040528015610763578160200160208202803683370190505b5090506000805b868110156108145760006001600160a01b031686828151811061078f5761078f611993565b60200260200101516001600160a01b0316141580156107ad57508382105b15610802578581815181106107c4576107c4611993565b60200260200101518383815181106107de576107de611993565b6001600160a01b03909216602092830291909101909101526107ff826119bf565b91505b8061080c816119bf565b91505061076a565b50604051806080016040528087815260200183518861083391906119d8565b8152835160208201526040019290925250979650505050505050565b6108d0604051806101c0016040528060006001600160a01b03168152602001600015158152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600015158152602001600015158152602001600081526020016000815260200160008152602001600081525090565b6000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015610910573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610934919061192a565b9050604051806101c00160405280846001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610980573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a49190611959565b6001600160a01b03168152602001846001600160a01b0316631f2698ab6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a149190611976565b15158152602001846001600160a01b031663d27c07976040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d919061192a565b8152602001828152602001846001600160a01b031663ff50abdc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aea919061192a565b8152602001846001600160a01b031663645006ca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b51919061192a565b8152602001846001600160a01b031663610589e16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb8919061192a565b8152602001846001600160a01b031663bdcc22e96040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1f919061192a565b8152602001846001600160a01b031663ee161cce6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c869190611976565b15158152602001846001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef9190611976565b15158152602001846001600160a01b0316638b649b946040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d58919061192a565b8152602001846001600160a01b0316634ae7937f846040518263ffffffff1660e01b8152600401610d8b91815260200190565b602060405180830381865afa158015610da8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcc919061192a565b8152602001846001600160a01b031663336d30ed60008511610def576000610dfa565b610dfa6001866119d8565b6040518263ffffffff1660e01b8152600401610e1891815260200190565b602060405180830381865afa158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e59919061192a565b8152602001846001600160a01b03166312b19a13846040518263ffffffff1660e01b8152600401610e8c91815260200190565b602060405180830381865afa158015610ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecd919061192a565b90529392505050565b6060610ee28383611575565b90505b92915050565b6001546001600160a01b03163314610f635760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016102eb565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60606000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103b919061192a565b90506110478382611575565b9392505050565b611056611501565b6001600160a01b03811661109e5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016102eb565b600154600160a81b900460ff16156110ee5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016102eb565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016103c4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561119d5750825b905060008267ffffffffffffffff1660011480156111ba5750303b155b9050811580156111c8575080155b156111e65760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561121057845460ff60401b1916600160401b1785555b61121986610299565b831561125f57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b61129460405180608001604052806000815260200160008152602001600015158152602001600081525090565b6000836001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f8919061192a565b604080516080810191829052635ddd3e8360e01b909152909150806001600160a01b038616635ddd3e836113428588608486019182526001600160a01b0316602082015260400190565b602060405180830381865afa15801561135f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611383919061192a565b81526020016001600160a01b038616635ddd3e836113a28560016119eb565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0388166024820152604401602060405180830381865afa1580156113ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611411919061192a565b8152604051631daae17360e01b81526001600160a01b038681166004830152602090920191871690631daae17390602401602060405180830381865afa15801561145f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114839190611976565b1515815260405163f61fcb8b60e01b81526001600160a01b03868116600483015260209092019187169063f61fcb8b90602401602060405180830381865afa1580156114d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f7919061192a565b9052949350505050565b6000546001600160a01b031633146115735760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016102eb565b565b60405163145dee7d60e01b8152600481018290526060906000906001600160a01b0385169063145dee7d90602401602060405180830381865afa1580156115c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e4919061192a565b90508067ffffffffffffffff8111156115ff576115ff611943565b604051908082528060200260200182016040528015611628578160200160208202803683370190505b50915060005b818110156116e2576040516303d868db60e01b815260048101859052602481018290526001600160a01b038616906303d868db90604401602060405180830381865afa158015611682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a69190611959565b8382815181106116b8576116b8611993565b6001600160a01b0390921660209283029190910190910152806116da816119bf565b91505061162e565b505092915050565b6001600160a01b038116811461049457600080fd5b60006020828403121561171157600080fd5b8135611047816116ea565b801515811461049457600080fd5b60006020828403121561173c57600080fd5b81356110478161171c565b6000602080835260a0830184518285015281850151604085015260408501516060850152606085015160808086015281815180845260c0870191508483019350600092505b808310156117b55783516001600160a01b0316825292840192600192909201919084019061178c565b509695505050505050565b81516001600160a01b031681526101c0810160208301516117e5602084018215159052565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516118368285018215159052565b5050610120838101511515908301526101408084015190830152610160808401519083015261018080840151908301526101a092830151929091019190915290565b6000806040838503121561188b57600080fd5b8235611896816116ea565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156118e55783516001600160a01b0316835292840192918401916001016118c0565b50909695505050505050565b6000806040838503121561190457600080fd5b823561190f816116ea565b9150602083013561191f816116ea565b809150509250929050565b60006020828403121561193c57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561196b57600080fd5b8151611047816116ea565b60006020828403121561198857600080fd5b81516110478161171c565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016119d1576119d16119a9565b5060010190565b81810381811115610ee557610ee56119a9565b80820180821115610ee557610ee56119a956fea2646970667358221220f145a887098e4569cbbf5903700b91246a5e8e05158e4496c5997ff889ee4ad664736f6c63430008140033
Deployed Bytecode
0x608060405234801561001057600080fd5b50600436106100f55760003560e01c80635cb40e3e11610097578063a19b984211610066578063a19b984214610218578063c3b83f5f1461022b578063c4d66de81461023e578063d9fefe2a1461025157600080fd5b80635cb40e3e146101c657806379ba5097146101e65780638da5cb5b146101ee57806391b4ded91461020157600080fd5b80633b7540af116100d35780633b7540af1461013557806353a47bb71461015e5780635910dcfe146101895780635c975abb146101a957600080fd5b806313af4035146100fa5780631627540c1461010f57806316c38b3c14610122575b600080fd5b61010d6101083660046116ff565b610299565b005b61010d61011d3660046116ff565b6103cf565b61010d61013036600461172a565b610425565b6101486101433660046116ff565b610497565b6040516101559190611747565b60405180910390f35b600154610171906001600160a01b031681565b6040516001600160a01b039091168152602001610155565b61019c6101973660046116ff565b61084f565b60405161015591906117c0565b6003546101b69060ff1681565b6040519015158152602001610155565b6101d96101d4366004611878565b610ed6565b60405161015591906118a4565b61010d610eeb565b600054610171906001600160a01b031681565b61020a60025481565b604051908152602001610155565b6101d96102263660046116ff565b610fd5565b61010d6102393660046116ff565b61104e565b61010d61024c3660046116ff565b611157565b61026461025f3660046118f1565b611267565b604051610155919081518152602080830151908201526040808301511515908201526060918201519181019190915260800190565b6001600160a01b0381166102f45760405162461bcd60e51b815260206004820152601960248201527f4f776e657220616464726573732063616e6e6f7420626520300000000000000060448201526064015b60405180910390fd5b600154600160a01b900460ff16156103605760405162461bcd60e51b815260206004820152602960248201527f416c726561647920696e697469616c697a65642c20757365206e6f6d696e617460448201526832a732bba7bbb732b960b91b60648201526084016102eb565b6001805460ff60a01b1916600160a01b179055600080546001600160a01b0383166001600160a01b0319909116811782556040805192835260208301919091527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91015b60405180910390a150565b6103d7611501565b600180546001600160a01b0319166001600160a01b0383169081179091556040519081527f906a1c6bd7e3091ea86693dd029a831c19049ce77f1dce2ce0bab1cacbabce22906020016103c4565b61042d611501565b60035460ff16151581151514610494576003805460ff191682151590811790915560ff161561045b57426002555b60035460405160ff909116151581527f8fb6c181ee25a520cf3dd6565006ef91229fcfe5a989566c2a3b8c115570cec5906020016103c4565b50565b6104c26040518060800160405280600081526020016000815260200160008152602001606081525090565b6000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015610502573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610526919061192a565b60405163145dee7d60e01b8152600481018290529091506000906001600160a01b0385169063145dee7d90602401602060405180830381865afa158015610571573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610595919061192a565b905060008167ffffffffffffffff8111156105b2576105b2611943565b6040519080825280602002602001820160405280156105db578160200160208202803683370190505b50905060008060005b8481101561071e576040516303d868db60e01b815260048101879052602481018290526001600160a01b038916906303d868db90604401602060405180830381865afa158015610638573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061065c9190611959565b6040516313e1422160e11b8152600481018890526001600160a01b038083166024830152919450908916906327c2844290604401602060405180830381865afa1580156106ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106d19190611976565b61070c57828482815181106106e8576106e8611993565b6001600160a01b0390921660209283029190910190910152610709826119bf565b91505b80610716816119bf565b9150506105e4565b5060008167ffffffffffffffff81111561073a5761073a611943565b604051908082528060200260200182016040528015610763578160200160208202803683370190505b5090506000805b868110156108145760006001600160a01b031686828151811061078f5761078f611993565b60200260200101516001600160a01b0316141580156107ad57508382105b15610802578581815181106107c4576107c4611993565b60200260200101518383815181106107de576107de611993565b6001600160a01b03909216602092830291909101909101526107ff826119bf565b91505b8061080c816119bf565b91505061076a565b50604051806080016040528087815260200183518861083391906119d8565b8152835160208201526040019290925250979650505050505050565b6108d0604051806101c0016040528060006001600160a01b03168152602001600015158152602001600081526020016000815260200160008152602001600081526020016000815260200160008152602001600015158152602001600015158152602001600081526020016000815260200160008152602001600081525090565b6000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015610910573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610934919061192a565b9050604051806101c00160405280846001600160a01b031663d8dfeb456040518163ffffffff1660e01b8152600401602060405180830381865afa158015610980573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109a49190611959565b6001600160a01b03168152602001846001600160a01b0316631f2698ab6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156109f0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a149190611976565b15158152602001846001600160a01b031663d27c07976040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a7d919061192a565b8152602001828152602001846001600160a01b031663ff50abdc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ac6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aea919061192a565b8152602001846001600160a01b031663645006ca6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b2d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b51919061192a565b8152602001846001600160a01b031663610589e16040518163ffffffff1660e01b8152600401602060405180830381865afa158015610b94573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bb8919061192a565b8152602001846001600160a01b031663bdcc22e96040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bfb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c1f919061192a565b8152602001846001600160a01b031663ee161cce6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c62573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c869190611976565b15158152602001846001600160a01b0316635c975abb6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ccb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cef9190611976565b15158152602001846001600160a01b0316638b649b946040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d34573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d58919061192a565b8152602001846001600160a01b0316634ae7937f846040518263ffffffff1660e01b8152600401610d8b91815260200190565b602060405180830381865afa158015610da8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dcc919061192a565b8152602001846001600160a01b031663336d30ed60008511610def576000610dfa565b610dfa6001866119d8565b6040518263ffffffff1660e01b8152600401610e1891815260200190565b602060405180830381865afa158015610e35573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e59919061192a565b8152602001846001600160a01b03166312b19a13846040518263ffffffff1660e01b8152600401610e8c91815260200190565b602060405180830381865afa158015610ea9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ecd919061192a565b90529392505050565b6060610ee28383611575565b90505b92915050565b6001546001600160a01b03163314610f635760405162461bcd60e51b815260206004820152603560248201527f596f75206d757374206265206e6f6d696e61746564206265666f726520796f7560448201527402063616e20616363657074206f776e65727368697605c1b60648201526084016102eb565b600054600154604080516001600160a01b0393841681529290911660208301527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c910160405180910390a160018054600080546001600160a01b03199081166001600160a01b03841617909155169055565b60606000826001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa158015611017573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103b919061192a565b90506110478382611575565b9392505050565b611056611501565b6001600160a01b03811661109e5760405162461bcd60e51b815260206004820152600f60248201526e496e76616c6964206164647265737360881b60448201526064016102eb565b600154600160a81b900460ff16156110ee5760405162461bcd60e51b8152602060048201526013602482015272105b1c9958591e481d1c985b9cd9995c9c9959606a1b60448201526064016102eb565b600080546001600160a01b0383166001600160a01b031990911681179091556001805460ff60a81b1916600160a81b1790556040805182815260208101929092527fb532073b38c83145e3e5135377a08bf9aab55bc0fd7c1179cd4fb995d2a5159c91016103c4565b7ff0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a008054600160401b810460ff16159067ffffffffffffffff1660008115801561119d5750825b905060008267ffffffffffffffff1660011480156111ba5750303b155b9050811580156111c8575080155b156111e65760405163f92ee8a960e01b815260040160405180910390fd5b845467ffffffffffffffff19166001178555831561121057845460ff60401b1916600160401b1785555b61121986610299565b831561125f57845460ff60401b19168555604051600181527fc7f505b2f371ae2175ee4913f4499e1f2633a7b5936321eed1cdaeb6115181d29060200160405180910390a15b505050505050565b61129460405180608001604052806000815260200160008152602001600015158152602001600081525090565b6000836001600160a01b031663146ca5316040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112d4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112f8919061192a565b604080516080810191829052635ddd3e8360e01b909152909150806001600160a01b038616635ddd3e836113428588608486019182526001600160a01b0316602082015260400190565b602060405180830381865afa15801561135f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611383919061192a565b81526020016001600160a01b038616635ddd3e836113a28560016119eb565b6040516001600160e01b031960e084901b16815260048101919091526001600160a01b0388166024820152604401602060405180830381865afa1580156113ed573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611411919061192a565b8152604051631daae17360e01b81526001600160a01b038681166004830152602090920191871690631daae17390602401602060405180830381865afa15801561145f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114839190611976565b1515815260405163f61fcb8b60e01b81526001600160a01b03868116600483015260209092019187169063f61fcb8b90602401602060405180830381865afa1580156114d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f7919061192a565b9052949350505050565b6000546001600160a01b031633146115735760405162461bcd60e51b815260206004820152602f60248201527f4f6e6c792074686520636f6e7472616374206f776e6572206d6179207065726660448201526e37b936903a3434b99030b1ba34b7b760891b60648201526084016102eb565b565b60405163145dee7d60e01b8152600481018290526060906000906001600160a01b0385169063145dee7d90602401602060405180830381865afa1580156115c0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e4919061192a565b90508067ffffffffffffffff8111156115ff576115ff611943565b604051908082528060200260200182016040528015611628578160200160208202803683370190505b50915060005b818110156116e2576040516303d868db60e01b815260048101859052602481018290526001600160a01b038616906303d868db90604401602060405180830381865afa158015611682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116a69190611959565b8382815181106116b8576116b8611993565b6001600160a01b0390921660209283029190910190910152806116da816119bf565b91505061162e565b505092915050565b6001600160a01b038116811461049457600080fd5b60006020828403121561171157600080fd5b8135611047816116ea565b801515811461049457600080fd5b60006020828403121561173c57600080fd5b81356110478161171c565b6000602080835260a0830184518285015281850151604085015260408501516060850152606085015160808086015281815180845260c0870191508483019350600092505b808310156117b55783516001600160a01b0316825292840192600192909201919084019061178c565b509695505050505050565b81516001600160a01b031681526101c0810160208301516117e5602084018215159052565b5060408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160e0830152610100808401516118368285018215159052565b5050610120838101511515908301526101408084015190830152610160808401519083015261018080840151908301526101a092830151929091019190915290565b6000806040838503121561188b57600080fd5b8235611896816116ea565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156118e55783516001600160a01b0316835292840192918401916001016118c0565b50909695505050505050565b6000806040838503121561190457600080fd5b823561190f816116ea565b9150602083013561191f816116ea565b809150509250929050565b60006020828403121561193c57600080fd5b5051919050565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561196b57600080fd5b8151611047816116ea565b60006020828403121561198857600080fd5b81516110478161171c565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b6000600182016119d1576119d16119a9565b5060010190565b81810381811115610ee557610ee56119a9565b80820180821115610ee557610ee56119a956fea2646970667358221220f145a887098e4569cbbf5903700b91246a5e8e05158e4496c5997ff889ee4ad664736f6c63430008140033
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 34 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.