More Info
Private Name Tags
ContractCreator
Latest 25 from a total of 614 transactions
Transaction Hash |
Method
|
Block
|
From
|
To
|
|||||
---|---|---|---|---|---|---|---|---|---|
Withdraw | 64924109 | 11 days ago | IN | 0 POL | 0.01782528 | ||||
Withdraw | 64335726 | 26 days ago | IN | 0 POL | 0.0599169 | ||||
Withdraw | 63319258 | 51 days ago | IN | 0 POL | 0.01287352 | ||||
Withdraw | 63312429 | 51 days ago | IN | 0 POL | 0.0428926 | ||||
Withdraw | 56338602 | 227 days ago | IN | 0 POL | 0.0577434 | ||||
Withdraw | 56338112 | 227 days ago | IN | 0 POL | 0.06161271 | ||||
Withdraw | 55629182 | 246 days ago | IN | 0 POL | 0.13438576 | ||||
Withdraw | 53283920 | 307 days ago | IN | 0 POL | 0.01518253 | ||||
Withdraw | 51474821 | 354 days ago | IN | 0 POL | 0.02996184 | ||||
Withdraw | 51314165 | 358 days ago | IN | 0 POL | 0.20637229 | ||||
Withdraw | 51164888 | 362 days ago | IN | 0 POL | 0.04763036 | ||||
Withdraw | 51163983 | 362 days ago | IN | 0 POL | 0.0375205 | ||||
Withdraw | 50358466 | 383 days ago | IN | 0 POL | 0.04917743 | ||||
Withdraw | 50167793 | 387 days ago | IN | 0 POL | 0.03043079 | ||||
Withdraw | 50167474 | 387 days ago | IN | 0 POL | 0.03099399 | ||||
Withdraw | 49984630 | 392 days ago | IN | 0 POL | 0.05816795 | ||||
Withdraw | 49872418 | 395 days ago | IN | 0 POL | 0.02022095 | ||||
Withdraw | 49823473 | 396 days ago | IN | 0 POL | 0.03504593 | ||||
Withdraw | 49621920 | 401 days ago | IN | 0 POL | 0.03214749 | ||||
Withdraw | 49611811 | 401 days ago | IN | 0 POL | 0.11008623 | ||||
Withdraw | 49611784 | 401 days ago | IN | 0 POL | 0.10352455 | ||||
Withdraw | 49611755 | 401 days ago | IN | 0 POL | 0.10130488 | ||||
Withdraw | 49611729 | 401 days ago | IN | 0 POL | 0.09952644 | ||||
Withdraw | 49611697 | 401 days ago | IN | 0 POL | 0.09110228 | ||||
Withdraw | 49611678 | 401 days ago | IN | 0 POL | 0.09194666 |
Loading...
Loading
Similar Match Source Code This contract matches the deployed Bytecode of the Source Code for Contract 0x4E31fEF7...22D0f03cc The constructor portion of the code might be different and could alter the actual behaviour of the contract
Contract Name:
Pool
Compiler Version
v0.8.7+commit.e28d00a7
Optimization Enabled:
Yes with 10 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: UNLICENSED pragma solidity 0.8.7; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/security/Pausable.sol"; import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; // import "hardhat/console.sol"; import "./strategies/IStrategy.sol"; //*********************************************************************// // --------------------------- custom errors ------------------------- // //*********************************************************************// error ADMIN_FEE_WITHDRAWN(); error DEPOSIT_NOT_ALLOWED(); error EARLY_EXIT_NOT_POSSIBLE(); error GAME_ALREADY_INITIALIZED(); error GAME_ALREADY_STARTED(); error GAME_COMPLETED(); error GAME_NOT_COMPLETED(); error GAME_NOT_INITIALIZED(); error INVALID_CUSTOM_FEE(); error INVALID_DEPOSIT_COUNT(); error INVALID_EARLY_WITHDRAW_FEE(); error INVALID_FLEXIBLE_AMOUNT(); error INVALID_INBOUND_TOKEN(); error INVALID_INCENTIVE_TOKEN(); error INVALID_MAX_FLEXIBLE_AMOUNT(); error INVALID_MAX_PLAYER_COUNT(); error INVALID_NET_DEPOSIT_AMOUNT(); error INVALID_TRANSACTIONAL_TOKEN_SENDER(); error INVALID_OWNER(); error INVALID_SEGMENT_LENGTH(); error INVALID_SEGMENT_PAYMENT(); error INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); error INVALID_STRATEGY(); error INVALID_WAITING_ROUND_SEGMENT_LENGTH(); error MAX_PLAYER_COUNT_REACHED(); error NOT_PLAYER(); error PLAYER_ALREADY_JOINED(); error PLAYER_ALREADY_PAID_IN_CURRENT_SEGMENT(); error PLAYER_DID_NOT_PAID_PREVIOUS_SEGMENT(); error PLAYER_ALREADY_WITHDREW_EARLY(); error PLAYER_ALREADY_WITHDREW(); error PLAYER_DOES_NOT_EXIST(); error TOKEN_TRANSFER_FAILURE(); error TRANSACTIONAL_TOKEN_TRANSFER_FAILURE(); error RENOUNCE_OWNERSHIP_NOT_ALLOWED(); /** @title GoodGhosting V2 Hodl Contract @notice Allows users to join a pool with a yield bearing strategy, the winners get interest and rewards, losers get their principal back. @author Francis Odisi & Viraz Malhotra. */ contract Pool is Ownable, Pausable, ReentrancyGuard { /// @notice Multiplier used for calculating playerIndex to avoid precision issues. uint256 public constant MULTIPLIER = 10 ** 12; /// @notice Maximum Flexible Deposit Amount in case of flexible pools. uint256 public immutable maxFlexibleSegmentPaymentAmount; /// @notice The time duration (in seconds) of each segment. uint64 public immutable segmentLength; /// @notice The performance admin fee (percentage). uint64 public immutable adminFee; /// @notice The time duration (in seconds) of last segment (waiting round). uint64 public immutable waitingRoundSegmentLength; /// @notice Defines the max quantity of players allowed in the game. uint64 public immutable maxPlayersCount; /// @notice The amount to be paid on each segment in case "flexibleSegmentPayment" is false (fixed payments). uint256 public immutable segmentPayment; /// @notice Address of the token used for depositing into the game by players. address public immutable inboundToken; /// @notice Flag which determines whether the segment payment is fixed or not. bool public immutable flexibleSegmentPayment; /// @notice Flag which determines whether the deposit token is a transactional token like eth or matic (blockchain native token, not ERC20). bool public immutable isTransactionalToken; /// @notice When the game started (game initialized timestamp). uint64 public firstSegmentStart; /// @notice Timestamp when the waiting segment starts. uint64 public waitingRoundSegmentStart; /// @notice The number of segments in the game (segment count). uint64 public depositCount; /// @notice The early withdrawal fee (percentage). uint64 public earlyWithdrawalFee; /// @notice Controls the amount of active players in the game (ignores players that early withdraw). uint64 public activePlayersCount; /// @notice winner counter to track no of winners. uint64 public winnerCount; /// @notice counter to track no of winners lef to withdraw for admin accounting. uint64 public winnersLeftToWithdraw; /// @notice the % share of interest accrued during the total duration of deposit rounds. /// @dev the interest/rewards/incentive accounting is divided in two phases: /// a) the total duration of deposit rounds in the game /// b) the total duration of the waiting round in the game /// These are compared against the total game duration to calculate the weight uint64 public depositRoundInterestSharePercentage; /// @notice Stores the total amount of net interest received in the game. uint256 public totalGameInterest; /// @notice net total principal amount to reduce the slippage imapct from amm strategies. uint256 public netTotalGamePrincipal; /// @notice total principal amount only used to keep a track of the gross deposits. uint256 public totalGamePrincipal; /// @notice performance fee amount allocated to the admin. uint256[] public adminFeeAmount; /// @notice total amount of incentive tokens to be distributed among winners. uint256 public totalIncentiveAmount; /// @notice share % from impermanent loss. uint256 public impermanentLossShare; /// @notice total rewardTokenAmounts. uint256[] public rewardTokenAmounts; /// @notice emaergency withdraw flag. bool public emergencyWithdraw; /// @notice Checks if admin fee has been assigned. bool public adminFeeSet; /// @notice Controls if reward tokens are to be claimed at the time of redeem. bool public disableRewardTokenClaim; /// @notice controls if admin withdrew or not the performance fee. bool public adminWithdraw; /// @notice Ownership Control flag. bool public allowRenouncingOwnership; /// @notice Strategy Contract Address IStrategy public strategy; /// @notice Defines an optional token address used to provide additional incentives to users. Accepts "0x0" adresses when no incentive token exists. IERC20 public incentiveToken; /// @notice address of additional reward token accured from investing via different strategies like wmatic. IERC20[] public rewardTokens; /// @notice struct for storing all player stats. /// @param withdrawn boolean flag indicating whether a player has withdrawn or not /// @param canRejoin boolean flag indicating whether a player can re-join or not /// @param isWinner boolean flag indicating whether a player is a winner or not /// @param addr player address /// @param withdrawalSegment segment at which a player withdraws /// @param mostRecentSegmentPaid is the most recent segment in which the deposit was made by the player /// @param amountPaid the total amount paid by a player /// @param netAmountPaid the new total amount paid by a player considering the slippage & fees for amm strategies /// @param depositAmount the deposit amount the player has decided to pay per segment needed for variable deposit game struct Player { bool withdrawn; bool canRejoin; bool isWinner; address addr; uint64 withdrawalSegment; uint64 mostRecentSegmentPaid; uint256 amountPaid; uint256 netAmountPaid; uint256 depositAmount; } /// @notice Stores info about the players in the game. mapping(address => Player) public players; /// @notice Stores info about the player index which is used to determine the share of interest of each winner. mapping(address => mapping(uint256 => uint256)) public playerIndex; /// @notice Stores info of the no of players that deposited in each segment. mapping(uint256 => uint256) public segmentCounter; /// @notice Stores info of cumulativePlayerIndexSum for each segment for early exit scenario. /// so if for the key as segment `3` cumulativePlayerIndexSum will have player index sum /// of all players who have deposited in segment `3` from the current segment and previous segments. mapping(uint256 => uint256) public cumulativePlayerIndexSum; /// @notice Stores the total deposited amount by winners in each segment. /// @dev we need this for calculating the waiting round share amount of the /// winners depending on their total deposit size (individual ratio compared to all winners). /// totalWinnerDepositsPerSegment for let's say segment `3` will be the sum of deposits from // all winning players who have deposited in segment `3` & other previous segments. mapping(uint256 => uint256) public totalWinnerDepositsPerSegment; /// @notice list of players. address[] public iterablePlayers; //*********************************************************************// // ------------------------- events -------------------------- // //*********************************************************************// event JoinedGame(address indexed player, uint256 amount, uint256 netAmount); event Deposit(address indexed player, uint256 indexed segment, uint256 amount, uint256 netAmount); event WithdrawInboundTokens(address indexed player, uint256 amount); event WithdrawIncentiveToken(address indexed player, uint256 amount); event WithdrawRewardTokens(address indexed player, uint256[] amounts); event UpdateGameStats( address indexed player, uint256 totalBalance, uint256 totalGamePrincipal, uint256 netTotalGamePrincipal, uint256 totalGameInterest, uint256 totalIncentiveAmount, uint256[] totalRewardAmounts, uint256 impermanentLossShare ); event EarlyWithdrawal( address indexed player, uint256 amount, uint256 totalGamePrincipal, uint256 netTotalGamePrincipal, uint256 depositedAmount, uint256 depositedNetAmount ); event AdminWithdrawal( address indexed admin, uint256 totalGameInterest, uint256 adminIncentiveAmount, uint256[] adminFeeAmounts ); event EndGameStats( address indexed player, uint256 totalBalance, uint256 totalGamePrincipal, uint256 netTotalGamePricipal, uint256 totalGameInterest, uint256[] grossRewardTokenAmount, uint256 totalIncentiveAmount, uint256 impermanentLossShare ); event AdminFee(uint256[] adminFeeAmounts); event ExternalTokenTransferError(address indexed token, bytes reason); event ExternalTokenGetBalanceError(address indexed token, bytes reason); event Initialized(uint64 firstSegmentStart, uint64 waitingRoundSegmentStart); event IncentiveTokenSet(address token); event EmergencyWithdrawalEnabled( uint64 currentSegment, uint64 winnerCount, uint64 depositRoundInterestSharePercentage ); event EarlyWithdrawalFeeChanged(uint64 currentSegment, uint64 oldFee, uint64 newFee); event ClaimRewardTokensDisabled(uint64 currentSegment); //*********************************************************************// // ------------------------- modifiers -------------------------- // //*********************************************************************// modifier whenGameIsCompleted() { if (!isGameCompleted()) { revert GAME_NOT_COMPLETED(); } _; } modifier whenGameIsNotCompleted() { if (isGameCompleted()) { revert GAME_COMPLETED(); } _; } modifier whenGameIsInitialized() { if (firstSegmentStart == 0) { revert GAME_NOT_INITIALIZED(); } _; } modifier whenGameIsNotInitialized() { if (firstSegmentStart != 0) { revert GAME_ALREADY_INITIALIZED(); } _; } //*********************************************************************// // ------------------------- external views -------------------------- // //*********************************************************************// /// @dev Checks if the game is completed or not. /// @return "true" if completeted; otherwise, "false". function isGameCompleted() public view returns (bool) { // Game is completed when the current segment is greater than "depositCount" of the game // or if "emergencyWithdraw" was enabled. return getCurrentSegment() > depositCount || emergencyWithdraw; } /// @dev Checks if player is a winner. /// @param _player player address /// @return "true" if player is a winner; otherwise, return "false". function isWinner(address _player) external view returns (bool) { if (players[_player].amountPaid == 0) { return false; } return _isWinner(players[_player], depositCount); } /// @dev gets the number of players in the game. /// @return number of players. function getNumberOfPlayers() external view returns (uint256) { return iterablePlayers.length; } /// @dev Calculates the current segment of the game. /// @return current game segment. // UPDATE - A1 Audit Report function getCurrentSegment() public view whenGameIsInitialized returns (uint64) { uint256 currentSegment; // to avoid SLOAD multiple times uint256 _waitingRoundSegmentStart = waitingRoundSegmentStart; uint256 endOfWaitingRound = _waitingRoundSegmentStart + waitingRoundSegmentLength; // logic for getting the current segment while the game is on waiting round if (_waitingRoundSegmentStart <= block.timestamp && block.timestamp < endOfWaitingRound) { currentSegment = depositCount; } else if (block.timestamp >= endOfWaitingRound) { // logic for getting the current segment after the game completes (waiting round is over) currentSegment = depositCount + 1 + ((block.timestamp - endOfWaitingRound) / segmentLength); } else { // logic for getting the current segment during segments that allows depositing (before waiting round) currentSegment = (block.timestamp - firstSegmentStart) / segmentLength; } return uint64(currentSegment); } /// @dev Checks if the game has been initialized or not. function isInitialized() external view returns (bool) { return firstSegmentStart != 0; } //*********************************************************************// // ------------------------- constructor -------------------------- // //*********************************************************************// /** Creates a new instance of GoodGhosting game @param _inboundCurrency Smart contract address of inbound currency used for the game. @param _maxFlexibleSegmentPaymentAmount Maximum Flexible Deposit Amount in case of flexible pools. @param _depositCount Number of segments in the game. @param _segmentLength Lenght of each segment, in seconds (i.e., 180 (sec) => 3 minutes). @param _waitingRoundSegmentLength Lenght of waiting round segment, in seconds (i.e., 180 (sec) => 3 minutes). @param _segmentPayment Amount of tokens each player needs to contribute per segment @param _earlyWithdrawalFee Fee paid by users on early withdrawals (before the game completes). Used as an integer percentage (i.e., 10 represents 10%). @param _customFee performance fee charged by admin. Used as an integer percentage (i.e., 10 represents 10%). Does not accept "decimal" fees like "0.5". @param _maxPlayersCount max quantity of players allowed to join the game @param _strategy investment strategy contract address. @param _isTransactionalToken isTransactionalToken flag. */ constructor( address _inboundCurrency, uint256 _maxFlexibleSegmentPaymentAmount, uint64 _depositCount, uint64 _segmentLength, uint64 _waitingRoundSegmentLength, uint256 _segmentPayment, uint64 _earlyWithdrawalFee, uint64 _customFee, uint64 _maxPlayersCount, bool _flexibleSegmentPayment, IStrategy _strategy, bool _isTransactionalToken ) { flexibleSegmentPayment = _flexibleSegmentPayment; isTransactionalToken = _isTransactionalToken; if (_customFee > 100) { revert INVALID_CUSTOM_FEE(); } if (_earlyWithdrawalFee > 99) { revert INVALID_EARLY_WITHDRAW_FEE(); } if (_maxPlayersCount == 0) { revert INVALID_MAX_PLAYER_COUNT(); } if (address(_inboundCurrency) == address(0) && !_isTransactionalToken) { revert INVALID_INBOUND_TOKEN(); } if (address(_strategy) == address(0)) { revert INVALID_STRATEGY(); } if (_depositCount == 0) { revert INVALID_DEPOSIT_COUNT(); } if (_segmentLength == 0) { revert INVALID_SEGMENT_LENGTH(); } if (!_flexibleSegmentPayment && _segmentPayment == 0) { revert INVALID_SEGMENT_PAYMENT(); } if (_waitingRoundSegmentLength == 0) { revert INVALID_WAITING_ROUND_SEGMENT_LENGTH(); } if (_waitingRoundSegmentLength < _segmentLength) { revert INVALID_WAITING_ROUND_SEGMENT_LENGTH(); } if (_flexibleSegmentPayment && _maxFlexibleSegmentPaymentAmount == 0) { revert INVALID_MAX_FLEXIBLE_AMOUNT(); } address _underlyingAsset = _strategy.getUnderlyingAsset(); // UPDATE - A4 Audit Report if (_underlyingAsset != _inboundCurrency && !_isTransactionalToken) { revert INVALID_INBOUND_TOKEN(); } // Initializes default variables depositCount = _depositCount; segmentLength = _segmentLength; waitingRoundSegmentLength = _waitingRoundSegmentLength; segmentPayment = _segmentPayment; earlyWithdrawalFee = _earlyWithdrawalFee; adminFee = _customFee; inboundToken = _inboundCurrency; strategy = _strategy; maxPlayersCount = _maxPlayersCount; maxFlexibleSegmentPaymentAmount = _maxFlexibleSegmentPaymentAmount; rewardTokens = strategy.getRewardTokens(); rewardTokenAmounts = new uint256[](rewardTokens.length); // length of the array is more, considering the inbound token since there would be fee on interest adminFeeAmount = new uint256[](rewardTokens.length + 1); } /** @dev Initializes the pool by setting the start time, the waiting round start time, incentive token (optional) & updates the interest share % of the deposit phase @param _incentiveToken Incentive token address (optional to set). */ function initialize(IERC20 _incentiveToken) public virtual onlyOwner whenGameIsNotInitialized whenNotPaused { if (strategy.strategyOwner() != address(this)) { revert INVALID_OWNER(); } firstSegmentStart = uint64(block.timestamp); //gets current time unchecked { waitingRoundSegmentStart = firstSegmentStart + (segmentLength * depositCount); } _updateInterestShares(0); setIncentiveToken(_incentiveToken); emit Initialized(firstSegmentStart, waitingRoundSegmentStart); } //*********************************************************************// // ------------------------- internal methods -------------------------- // //*********************************************************************// /** @dev Transfer external tokens with try/catch in place so the external token transfer failures don't affect the transaction confirmation @param _token token address. @param _to recipient of the token. @param _amount transfer amount. */ // UPDATE - N1 Audit Report function _transferTokenOrContinueOnFailure( address _token, address _to, uint256 _amount ) internal returns (uint256) { try IERC20(_token).balanceOf(address(this)) returns (uint256 tokenBalance) { if (_amount > tokenBalance) { _amount = tokenBalance; } } catch (bytes memory reason) { _amount = 0; emit ExternalTokenGetBalanceError(_token, reason); } if (_amount != 0) { try IERC20(_token).transfer(_to, _amount) returns (bool success) { if (!success) { // forces error event to be emitted in case false is returned from ERC20.transfer. revert TOKEN_TRANSFER_FAILURE(); } } catch (bytes memory reason) { emit ExternalTokenTransferError(_token, reason); } } return _amount; } /** @dev Winner interest accounting based on the interest amount share in the deposit rounds & waiting round. @param _segment last deposit segment for the winners. @param _impermanentLossShare impermanent loss share during the current withdrawal. @return _playerIndexSharePercentage is the percentage share of the winners during deposit rounds for getting interest/rewards/incentives based on player index. @return _playerDepositAmountSharePercentage is the percentage share of the winners during waiting round for getting interest/rewards/incentives based on player deposits. @return _payout total amount to be transferred to the winners. */ function _calculateAndUpdateWinnerInterestAccounting( uint64 _segment, uint256 _impermanentLossShare ) internal returns (uint256 _playerIndexSharePercentage, uint256 _playerDepositAmountSharePercentage, uint256 _payout) { // memory variables for the player interest amount accounting for both deposits and waiting rounds. uint256 playerInterestAmountDuringDepositRounds; uint256 playerInterestAmountDuringWaitingRounds; // winners of the game get a share of the interest, reward & incentive tokens based on how early they deposit, the amount they deposit in case of avriable deposit pool & the ratio of the deposit & waiting round. // Calculate Cummalative index of the withdrawing player uint256 playerIndexSum = 0; // calculate playerIndexSum for each player for (uint256 i = 0; i <= _segment; ) { playerIndexSum += playerIndex[msg.sender][i]; unchecked { ++i; } } // calculate playerIndexSharePercentage for each player // UPDATE - H3 Audit Report _playerIndexSharePercentage = (playerIndexSum * MULTIPLIER) / cumulativePlayerIndexSum[_segment]; // reduce cumulativePlayerIndexSum since a winner only withdraws their own funds. cumulativePlayerIndexSum[_segment] -= playerIndexSum; _payout = players[msg.sender].netAmountPaid; // calculate _playerDepositAmountSharePercentage for each player for waiting round calculations depending on how much deposit share the player has. // have a safety check players[msg.sender].netAmountPaid > totalWinnerDepositsPerSegment[segment] in case of a impermanent loss // in case of a impermanent loss although we probably won't need it since we reduce player's netAmountPaid too but just in case. _playerDepositAmountSharePercentage = _payout > totalWinnerDepositsPerSegment[_segment] ? MULTIPLIER // UPDATE - H3 Audit Report : (_payout * MULTIPLIER) / totalWinnerDepositsPerSegment[_segment]; // update storage vars since each winner withdraws only funds entitled to them. if (totalWinnerDepositsPerSegment[_segment] < _payout) { totalWinnerDepositsPerSegment[_segment] = 0; } else { totalWinnerDepositsPerSegment[_segment] -= _payout; } // checking for impermenent loss if (_impermanentLossShare != 0) { // new payput in case of impermanent loss _payout = (_payout * _impermanentLossShare) / 100; // update netAmountPaid in case of impermanent loss players[msg.sender].netAmountPaid = _payout; } // checking for impermenent loss // save gas by checking the interest before entering in the if block if (_impermanentLossShare == 0 && totalGameInterest != 0) { // calculating the interest amount accrued in waiting & deposit Rounds. uint256 interestAccruedDuringDepositRounds = (totalGameInterest * depositRoundInterestSharePercentage) / MULTIPLIER; // we calculate interestAccruedDuringWaitingRound by subtracting the totalGameInterest by interestAccruedDuringDepositRounds uint256 interestAccruedDuringWaitingRound = depositRoundInterestSharePercentage == MULTIPLIER ? 0 : totalGameInterest - interestAccruedDuringDepositRounds; // calculating the player interest share split b/w the waiting & deposit rounds. playerInterestAmountDuringWaitingRounds = (interestAccruedDuringWaitingRound * _playerDepositAmountSharePercentage) / MULTIPLIER; playerInterestAmountDuringDepositRounds = (interestAccruedDuringDepositRounds * _playerIndexSharePercentage) / MULTIPLIER; // update the total amount to be redeemed _payout += playerInterestAmountDuringDepositRounds + playerInterestAmountDuringWaitingRounds; // reduce totalGameInterest since a winner only withdraws their own funds. totalGameInterest -= (playerInterestAmountDuringDepositRounds + playerInterestAmountDuringWaitingRounds); } winnersLeftToWithdraw -= 1; } /** @dev Non-winner amount accounting. @param _impermanentLossShare impermanent loss share %. @param _netAmountPaid net amount paid by the player. @return payout amount to be sent to the player. */ function _calculateAndUpdateNonWinnerAccounting( uint256 _impermanentLossShare, uint256 _netAmountPaid ) internal returns (uint256 payout) { if (_impermanentLossShare != 0) { // new payput in case of impermanent loss payout = (_netAmountPaid * _impermanentLossShare) / 100; // reduce player netAmountPaid in case of impermanent loss players[msg.sender].netAmountPaid = payout; } else { payout = _netAmountPaid; } // non-winners don't get any rewards/incentives uint256[] memory rewardAmounts = new uint256[](rewardTokens.length); emit WithdrawIncentiveToken(msg.sender, 0); emit WithdrawRewardTokens(msg.sender, rewardAmounts); } /** @dev Winner reward accounting based on the player amount share % calculated based on player index & total deposits made. @param playerDepositAmountSharePercentage Deposit amount share %. @param playerIndexSharePercentage Player index share %.. */ function _calculateAndUpdateWinnerRewardAccounting( uint256 playerDepositAmountSharePercentage, uint256 playerIndexSharePercentage ) internal { // calculating winners share of the reward amounts // memory vars to avoid SLOADS & for the player rewards share accounting IERC20[] memory _rewardTokens = rewardTokens; uint256[] memory _rewardTokenAmounts = rewardTokenAmounts; uint256[] memory playerRewards = new uint256[](_rewardTokens.length); // reference for array length to save gas uint256 _rewardLength = _rewardTokens.length; for (uint256 i = 0; i < _rewardLength; ) { if (address(_rewardTokens[i]) != address(0) && _rewardTokenAmounts[i] != 0) { // calculating the reward token amount split b/w waiting & deposit Rounds. uint256 totalRewardAmountsDuringDepositRounds = (_rewardTokenAmounts[i] * depositRoundInterestSharePercentage) / MULTIPLIER; // we calculate totalRewardAmountsWaitingRounds by subtracting the rewardTokenAmounts by totalRewardAmountsDuringDepositRounds uint256 totalRewardAmountsWaitingRounds = depositRoundInterestSharePercentage == MULTIPLIER ? 0 : _rewardTokenAmounts[i] - totalRewardAmountsDuringDepositRounds; // calculating the winner reward token amount share split b/w the waiting & deposit rounds. uint256 playerRewardShareAmountDuringDepositRounds = (totalRewardAmountsDuringDepositRounds * playerIndexSharePercentage) / MULTIPLIER; uint256 playerRewardShareAmountDuringWaitingRounds = (totalRewardAmountsWaitingRounds * playerDepositAmountSharePercentage) / MULTIPLIER; // update the rewards to be transferred playerRewards[i] = playerRewardShareAmountDuringDepositRounds + playerRewardShareAmountDuringWaitingRounds; // update storage var since each winner withdraws only funds entitled to them. _rewardTokenAmounts[i] -= playerRewards[i]; // transferring the reward token share to the winner // updates variable value to make sure on a failure, event is emitted w/ correct value. // UPDATE - Related to N1 Audit Report (If an external protocol reward token get's compromised) playerRewards[i] = _transferTokenOrContinueOnFailure( address(_rewardTokens[i]), msg.sender, playerRewards[i] ); } unchecked { ++i; } } // avoid SSTORE inside loop rewardTokenAmounts = _rewardTokenAmounts; // We have to ignore the "check-effects-interactions" pattern here and emit the event // only at the end of the function, in order to emit it w/ the correct withdrawal amount. // In case the safety checks above are evaluated to true, payout, playerIncentiv and playerReward // are updated, so we need the event to be emitted with the correct info. emit WithdrawRewardTokens(msg.sender, playerRewards); } /** @dev Winner incentive accounting based on the player amount share % calculated based on player index & total deposits made. @param playerDepositAmountSharePercentage Deposit amount share %. @param playerIndexSharePercentage Player index share %.. */ function _calculateAndUpdateWinnerIncentivesAccounting( uint256 playerDepositAmountSharePercentage, uint256 playerIndexSharePercentage ) internal { uint256 playerIncentive; if (totalIncentiveAmount != 0) { // calculating the incentive amount split b/w waiting & deposit Rounds. uint256 incentiveAmountSharedDuringDepositRounds = (totalIncentiveAmount * depositRoundInterestSharePercentage) / MULTIPLIER; // we calculate incentiveAmountShareDuringWaitingRound by subtracting the totalIncentiveAmount by incentiveAmountSharedDuringDepositRounds uint256 incentiveAmountShareDuringWaitingRound = depositRoundInterestSharePercentage == MULTIPLIER ? 0 : totalIncentiveAmount - incentiveAmountSharedDuringDepositRounds; // calculating the winner incentive amount share split b/w the waiting & deposit rounds. uint256 playerIncentiveAmountDuringDepositRounds = (incentiveAmountSharedDuringDepositRounds * playerIndexSharePercentage) / MULTIPLIER; uint256 playerIncentiveAmountDuringWaitingRounds = (incentiveAmountShareDuringWaitingRound * playerDepositAmountSharePercentage) / MULTIPLIER; playerIncentive = playerIncentiveAmountDuringDepositRounds + playerIncentiveAmountDuringWaitingRounds; // update storage var since each winner withdraws only funds entitled to them. totalIncentiveAmount -= playerIncentive; // transferring the incentive share to the winner // updates variable value to make sure on a failure, event is emitted w/ correct value. // UPDATE - N1 Audit Report playerIncentive = _transferTokenOrContinueOnFailure(address(incentiveToken), msg.sender, playerIncentive); } // We have to ignore the "check-effects-interactions" pattern here and emit the event // only at the end of the function, in order to emit it w/ the correct withdrawal amount. // In case the safety checks above are evaluated to true, payout, playerIncentiv and playerReward // are updated, so we need the event to be emitted with the correct info. emit WithdrawIncentiveToken(msg.sender, playerIncentive); } /** @notice updates the waiting and deposit rounds time percentages based on the total duration of the pool, total deposit round & waiting round duration. @param _currentSegment current segment value. */ function _updateInterestShares(uint64 _currentSegment) internal { // if emergencyWithdraw hasn't been enabled then the calculation of the percentages is pretty straightforward // we get the total durations of the deposit and waiting round and get the % share out of the total duration if (!emergencyWithdraw) { uint64 endOfWaitingRound = waitingRoundSegmentStart + waitingRoundSegmentLength; uint64 totalGameDuration = endOfWaitingRound - firstSegmentStart; depositRoundInterestSharePercentage = uint64( (segmentLength * depositCount * MULTIPLIER) / totalGameDuration ); } else { // if emergencyWithdraw is enabled & it got enabled during the waiting round then we re-calculate the waiting round period // we then get the total durations of the deposit and waiting round and get the % share out of the total duration if (_currentSegment == depositCount) { uint64 totalGameDuration = uint64(block.timestamp) - firstSegmentStart; depositRoundInterestSharePercentage = uint64( (segmentLength * depositCount * MULTIPLIER) / totalGameDuration ); } else { // if emergencyWithdraw is enabled & it got enabled before the waiting round then we set the depositRoundInterestSharePercentage to 100 % and waitingRoundInterestSharePercentage will indirectly be 0. depositRoundInterestSharePercentage = uint64(MULTIPLIER); } } } /** @notice check if there are any rewards to claim for the admin. @param _adminFeeAmount admin fee amount value. */ function _checkRewardsClaimableByAdmin(uint256[] memory _adminFeeAmount) internal pure returns (bool) { // reference for array length to save gas uint256 _adminFeeAmountsLength = _adminFeeAmount.length; // starts loop from 1, because first spot of _adminFeeAmount is reserved for admin interest share. for (uint256 i = 1; i < _adminFeeAmountsLength; ) { if (_adminFeeAmount[i] != 0) { return true; } unchecked { ++i; } } return false; } /** @notice Transfer funds after balance checks to the players / admin. @param _recepient address which will receive tokens. @param _amount transfer amount. */ // UPDATE - A3 Audit Report function _transferFundsSafelyOrFail(address _recepient, uint256 _amount) internal returns (uint256) { if (isTransactionalToken) { // safety check // this scenario is very tricky to mock // and our mock contracts are pretty complex currently so haven't tested this line with unit tests if (_amount > address(this).balance) { _amount = address(this).balance; } (bool success, ) = _recepient.call{ value: _amount }(""); if (!success) { revert TRANSACTIONAL_TOKEN_TRANSFER_FAILURE(); } } else { // safety check if (_amount > IERC20(inboundToken).balanceOf(address(this))) { _amount = IERC20(inboundToken).balanceOf(address(this)); } bool success = IERC20(inboundToken).transfer(_recepient, _amount); if (!success) { revert TOKEN_TRANSFER_FAILURE(); } } return _amount; } /** @notice Calculates and updates's game accounting called by methods _setGlobalPoolParams. Updates the game storage vars used for calculating player interest, incentives etc. @param _totalBalance Total inbound token balance in the contract. @param _grossRewardTokenAmount Gross reward amounts. */ function _calculateAndUpdateGameAccounting( uint256 _totalBalance, uint256[] memory _grossRewardTokenAmount ) internal returns (uint256) { uint256 _grossInterest = 0; if (_totalBalance >= netTotalGamePrincipal) { // calculates the gross interest _grossInterest = _totalBalance - netTotalGamePrincipal; } else { // handling impermanent loss case impermanentLossShare = (_totalBalance * 100) / netTotalGamePrincipal; netTotalGamePrincipal = _totalBalance; } // sets the totalIncentiveAmount if available // UPDATE - N1 Audit Report address _incentiveToken = address(incentiveToken); if (_incentiveToken != address(0)) { try IERC20(_incentiveToken).balanceOf(address(this)) returns (uint256 _totalIncentiveAmount) { totalIncentiveAmount = _totalIncentiveAmount; } catch (bytes memory reason) { emit ExternalTokenGetBalanceError(_incentiveToken, reason); } } // this condition is added because emit is to only be emitted when adminFeeSet flag is false but this mehtod is called for every player withdrawal in variable deposit pool. if (!adminFeeSet) { winnersLeftToWithdraw = winnerCount; emit EndGameStats( msg.sender, _totalBalance, totalGamePrincipal, netTotalGamePrincipal, _grossInterest, _grossRewardTokenAmount, totalIncentiveAmount, impermanentLossShare ); } return _grossInterest; } /** @notice Calculates and set's admin accounting called by methods _setGlobalPoolParams. Updates the admin fee storage var used for admin fee. @param _grossInterest Gross interest amount. @param _grossRewardTokenAmount Gross reward amount array. */ function _calculateAndSetAdminAccounting( uint256 _grossInterest, uint256[] memory _grossRewardTokenAmount ) internal { // calculates the performance/admin fee (takes a cut - the admin percentage fee - from the pool's interest, strategy rewards). // calculates the "gameInterest" (net interest) that will be split among winners in the game // calculates the rewardTokenAmounts that will be split among winners in the game // when there's no winners, admin takes all the interest + rewards // to avoid SLOAD multiple times IERC20[] memory _rewardTokens = rewardTokens; uint256[] memory _adminFeeAmount = adminFeeAmount; uint256[] memory _rewardTokenAmounts = rewardTokenAmounts; // handling the scenario when some winners withdraw later so they should get extra interest/rewards // the scenario wasn't handled before if (adminFeeSet) { // if the admin fee is set a check is made to check whether the admin has withdrawn or not if (adminWithdraw) { // we update the totalGameInterest/reward amounts as the gross values totalGameInterest = _grossInterest; _rewardTokenAmounts = _grossRewardTokenAmount; } else { uint256 _interestIncludingFee = totalGameInterest + _adminFeeAmount[0]; // if the admin hasn't made a withdrawal yet so we calculate the rise in interest & update the admin fee & interest if (_grossInterest >= _interestIncludingFee) { uint256 difference = _grossInterest - _interestIncludingFee; uint256 adminfeeShareForDifference; // if there are no winners then set the difference as the admin share & total game interest if (winnerCount == 0 || winnersLeftToWithdraw == 0) { adminfeeShareForDifference = difference; totalGameInterest += difference; } else { // if there are winners then calculate the rise in admin fee & update both admin fee & interest accordingly adminfeeShareForDifference = (difference * adminFee) / 100; totalGameInterest = difference > 0 ? _grossInterest - adminfeeShareForDifference : totalGameInterest; } _adminFeeAmount[0] += adminfeeShareForDifference; } else { // if _grossInterest is non zero then update admin fee & game interest with the new gross interest uint256 adminfeeShareForDifference; if (winnerCount == 0 || winnersLeftToWithdraw == 0) { // if there are no winners then set the _grossInterest as the admin share & total game interest adminfeeShareForDifference = _grossInterest; totalGameInterest = _grossInterest; } else { // if there are winners then calculate the new admin fee share based on the gross interest & update both admin fee & interest adminfeeShareForDifference = (_grossInterest * adminFee) / 100; totalGameInterest = _grossInterest - adminfeeShareForDifference; } _adminFeeAmount[0] = adminfeeShareForDifference; } // reference for array length to save gas uint256 _rewardsLength = _rewardTokens.length; for (uint256 i = 0; i < _rewardsLength; ) { // first slot is reserved for admin interest amount, so starts at 1. if (_grossRewardTokenAmount[i] >= _rewardTokenAmounts[i]) { uint256 difference = _grossRewardTokenAmount[i] - _rewardTokenAmounts[i]; uint256 adminfeeShareForDifference; if (winnerCount == 0 || winnersLeftToWithdraw == 0) { adminfeeShareForDifference = difference; _rewardTokenAmounts[i] += difference; } else { adminfeeShareForDifference = (difference * adminFee) / 100; _rewardTokenAmounts[i] = difference > 0 ? _grossRewardTokenAmount[i] - adminfeeShareForDifference : _rewardTokenAmounts[i]; } _adminFeeAmount[i + 1] += adminfeeShareForDifference; } else { uint256 adminfeeShareForDifference; if (winnerCount == 0 || winnersLeftToWithdraw == 0) { adminfeeShareForDifference = _grossRewardTokenAmount[i]; _rewardTokenAmounts[i] = _grossRewardTokenAmount[i]; } else { adminfeeShareForDifference = (_grossRewardTokenAmount[i] * adminFee) / 100; _rewardTokenAmounts[i] = _grossRewardTokenAmount[i] - adminfeeShareForDifference; } _adminFeeAmount[i + 1] = adminfeeShareForDifference; } unchecked { ++i; } } } } else { // reference for array length to save gas uint256 _rewardsLength = _rewardTokens.length; // if the admin fee isn't set then we set it in the else part // UPDATE - N2 Audit Report if (winnerCount == 0) { // in case of no winners the admin takes all the interest and the rewards & the incentive amount (check adminFeeWithdraw method) _adminFeeAmount[0] = _grossInterest; // just setting these for consistency since if there are no winners then for accounting both these vars aren't used totalGameInterest = _grossInterest; for (uint256 i = 0; i < _rewardsLength; ) { _rewardTokenAmounts[i] = _grossRewardTokenAmount[i]; // first slot is reserved for admin interest amount, so starts at 1. _adminFeeAmount[i + 1] = _grossRewardTokenAmount[i]; unchecked { ++i; } } } else if (adminFee != 0) { // if admin fee != 0 then the admin get's a share based on the adminFee % _adminFeeAmount[0] = (_grossInterest * adminFee) / 100; totalGameInterest = _grossInterest - _adminFeeAmount[0]; for (uint256 i = 0; i < _rewardsLength; ) { // first slot is reserved for admin interest amount, so starts at 1. _adminFeeAmount[i + 1] = (_grossRewardTokenAmount[i] * adminFee) / 100; _rewardTokenAmounts[i] = _grossRewardTokenAmount[i] - _adminFeeAmount[i + 1]; unchecked { ++i; } } } else { // if there are winners and there is no admin fee in that case the admin fee will always be 0 totalGameInterest = _grossInterest; for (uint256 i = 0; i < _rewardsLength; ) { _rewardTokenAmounts[i] = _grossRewardTokenAmount[i]; unchecked { ++i; } } } emit AdminFee(_adminFeeAmount); } // avoid SSTORE in loop rewardTokenAmounts = _rewardTokenAmounts; adminFeeAmount = _adminFeeAmount; } /** @dev Initializes the player stats when they join. @param _minAmount Slippage based amount to cover for impermanent loss scenario. @param _depositAmount Variable Deposit Amount in case of a variable deposit pool. */ function _joinGame(uint256 _minAmount, uint256 _depositAmount) internal virtual { if (getCurrentSegment() != 0) { revert GAME_ALREADY_STARTED(); } bool canRejoin = players[msg.sender].canRejoin; if (players[msg.sender].addr == msg.sender && !canRejoin) { revert PLAYER_ALREADY_JOINED(); } activePlayersCount += 1; if (activePlayersCount > maxPlayersCount) { revert MAX_PLAYER_COUNT_REACHED(); } if (flexibleSegmentPayment && (_depositAmount == 0 || _depositAmount > maxFlexibleSegmentPaymentAmount)) { revert INVALID_FLEXIBLE_AMOUNT(); } uint256 amount = flexibleSegmentPayment ? _depositAmount : segmentPayment; if (isTransactionalToken) { if (msg.value != amount) { revert INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); } } else { if (msg.value != 0) { revert INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); } } // get net deposit amount from the strategy uint256 netAmount = strategy.getNetDepositAmount(amount); if (netAmount == 0) { revert INVALID_NET_DEPOSIT_AMOUNT(); } Player memory newPlayer = Player({ addr: msg.sender, withdrawalSegment: 0, mostRecentSegmentPaid: 0, amountPaid: 0, netAmountPaid: 0, withdrawn: false, canRejoin: false, isWinner: false, depositAmount: amount }); players[msg.sender] = newPlayer; if (!canRejoin) { iterablePlayers.push(msg.sender); } emit JoinedGame(msg.sender, amount, netAmount); _transferInboundTokenToContract(_minAmount, amount, netAmount); } /** @dev Manages the transfer of funds from the player to the specific strategy used for the game/pool and updates the player index which determines the interest and reward share of the winner based on the deposit amount amount and the time they deposit in a particular segment. @param _minAmount Slippage based amount to cover for impermanent loss scenario. @param _depositAmount Variable Deposit Amount in case of a variable deposit pool. @param _netDepositAmount Net deposit amount. */ function _transferInboundTokenToContract( uint256 _minAmount, uint256 _depositAmount, uint256 _netDepositAmount ) internal virtual { // this scenario given the inputs to the mock contract methods isn't possible to mock locally // UPDATE - H1 Audit Report if (_netDepositAmount > _depositAmount) { revert INVALID_NET_DEPOSIT_AMOUNT(); } uint64 currentSegment = getCurrentSegment(); players[msg.sender].mostRecentSegmentPaid = currentSegment; players[msg.sender].amountPaid += _depositAmount; players[msg.sender].netAmountPaid += _netDepositAmount; // PLAYER INDEX CALCULATION TO DETERMINE INTEREST SHARE // player index = prev. segment player index + segment amount deposited / difference in time of deposit from the current segment starting time // UPDATE - H2 Audit Report uint256 currentSegmentplayerIndex = (_netDepositAmount * MULTIPLIER) / (segmentLength + block.timestamp - (firstSegmentStart + (currentSegment * segmentLength))); playerIndex[msg.sender][currentSegment] = currentSegmentplayerIndex; // updating the cummulative player Index with all the deposits made by the player till that segment // Avoids SLOAD in loop uint256 cummalativePlayerIndexSumInMemory = cumulativePlayerIndexSum[currentSegment]; for (uint256 i = 0; i <= currentSegment; ) { cummalativePlayerIndexSumInMemory += playerIndex[msg.sender][i]; unchecked { ++i; } } cumulativePlayerIndexSum[currentSegment] = cummalativePlayerIndexSumInMemory; // update totalWinnerDepositsPerSegment for every segment for every deposit made totalWinnerDepositsPerSegment[currentSegment] += players[msg.sender].netAmountPaid; // check if this is deposit for the last segment. If yes, the player is a winner. // since both join game and deposit method call this method so having it here if (currentSegment == (depositCount - 1)) { // array indexes start from 0 unchecked { winnerCount += 1; } players[msg.sender].isWinner = true; } // segment counter calculation unchecked { segmentCounter[currentSegment] += 1; if (currentSegment != 0 && segmentCounter[currentSegment - 1] != 0) { segmentCounter[currentSegment - 1] -= 1; } } // updating both totalGamePrincipal & netTotalGamePrincipal to maintain consistency totalGamePrincipal += _depositAmount; netTotalGamePrincipal += _netDepositAmount; if (!isTransactionalToken) { bool success = IERC20(inboundToken).transferFrom(msg.sender, address(strategy), _depositAmount); if (!success) { revert TOKEN_TRANSFER_FAILURE(); } } strategy.invest{ value: msg.value }(inboundToken, _minAmount); } /// @dev Sets the game stats without redeeming the funds from the strategy. /// Can only be called after the game is completed when each player withdraws. function _setGlobalPoolParams() internal virtual whenGameIsCompleted { // this method is called everytime a player decides to withdraw, // to update the game storage vars because every player withdraw's their entitled amount that includes the incentive & reward tokens. // so totalBalance keeps a track of the ucrrent balance & the accumulated principal + interest stored in the strategy protocol. uint256 totalBalance = isTransactionalToken ? address(this).balance + strategy.getTotalAmount() : IERC20(inboundToken).balanceOf(address(this)) + strategy.getTotalAmount(); // to avoid SLOAD multiple times IERC20[] memory _rewardTokens = rewardTokens; uint256[] memory _rewardTokenAmounts = rewardTokenAmounts; uint256[] memory grossRewardTokenAmount = new uint256[](_rewardTokens.length); // get the accumulated reward tokens from the strategy uint256[] memory accumulatedRewardTokenAmount = strategy.getAccumulatedRewardTokenAmounts( disableRewardTokenClaim ); // reference for array length to save gas uint256 _rewardsLength = _rewardTokens.length; // iterate through the reward token array to set the total reward amounts accumulated for (uint256 i = 0; i < _rewardsLength; ) { // the reward calculation is the sum of the current reward amount the remaining rewards being accumulated in the strategy protocols. // the reason being like totalBalance for every player this is updated and prev. value is used to add any left over value if (address(_rewardTokens[i]) != address(0) && inboundToken != address(_rewardTokens[i])) { grossRewardTokenAmount[i] = _rewardTokenAmounts[i] + accumulatedRewardTokenAmount[i]; } unchecked { ++i; } } // gets the grossInterest after updating the game accounting uint256 grossInterest = _calculateAndUpdateGameAccounting(totalBalance, grossRewardTokenAmount); _calculateAndSetAdminAccounting(grossInterest, grossRewardTokenAmount); adminFeeSet = true; } /// @dev Checks if player is a winner. /// @dev this function assumes that the player has already joined the game. /// We check if the player is a participant in the pool before using this function. /// @return "true" if player is a winner; otherwise, return "false". function _isWinner(Player storage _player, uint64 _depositCountMemory) internal view returns (bool) { // considers the emergency withdraw scenario too where if a player has paid in that or the previous segment they are considered as a winner return _player.isWinner || (emergencyWithdraw && ( _depositCountMemory == 0 ? _player.mostRecentSegmentPaid >= _depositCountMemory : _player.mostRecentSegmentPaid >= (_depositCountMemory - 1) )); } /** Returns the maximum amount that can be redeemed from a strategy for a player/admin */ function getRedemptionValue(uint256 _amountToRedeem, uint256 _totalAmount) internal returns (uint256) { if (_amountToRedeem > _totalAmount) { return _totalAmount; } return _amountToRedeem; } //*********************************************************************// // ------------------------- external/public methods -------------------------- // //*********************************************************************// /** @dev Enable early game completion in case of a emergency like the strategy contract becomes inactive in the midddle of the game etc. // Once enabled players can withdraw their funds along with interest for winners. */ function enableEmergencyWithdraw() external onlyOwner whenGameIsNotCompleted { if (totalGamePrincipal == 0) { revert EARLY_EXIT_NOT_POSSIBLE(); } uint64 currentSegment = getCurrentSegment(); // UPDATE - N2 Audit Report // updates the winner count based on the segment counter winnerCount = currentSegment != 0 ? uint64(segmentCounter[currentSegment] + segmentCounter[currentSegment - 1]) : uint64(segmentCounter[currentSegment]); emergencyWithdraw = true; // updates the interest shhare % for the deposit round _updateInterestShares(currentSegment); // setting depositCount as current segment to manage all scenario's to handle emergency withdraw depositCount = currentSegment; emit EmergencyWithdrawalEnabled(currentSegment, winnerCount, depositRoundInterestSharePercentage); } /** @dev Set's the incentive token address. @param _incentiveToken Incentive token address */ function setIncentiveToken(IERC20 _incentiveToken) public onlyOwner whenGameIsNotCompleted { // incentiveToken can only be set once, so we check if it has already been set if not then we check the inbound token is same as incentive token if ( (address(incentiveToken) != address(0)) || (inboundToken != address(0) && inboundToken == address(_incentiveToken)) ) { revert INVALID_INCENTIVE_TOKEN(); } // incentiveToken cannot be the same as one of the reward tokens. IERC20[] memory _rewardTokens = rewardTokens; // reference for array length to save gas uint256 _rewardsLength = _rewardTokens.length; for (uint256 i = 0; i < _rewardsLength; ) { if ((address(_rewardTokens[i]) != address(0) && address(_rewardTokens[i]) == address(_incentiveToken))) { revert INVALID_INCENTIVE_TOKEN(); } unchecked { ++i; } } incentiveToken = _incentiveToken; emit IncentiveTokenSet(address(_incentiveToken)); } /** @dev Disable claiming reward tokens for emergency scenarios, like when external reward contracts become inactive or rewards funds aren't available, allowing users to withdraw principal + interest from contract. */ function disableClaimingRewardTokens() external onlyOwner whenGameIsNotCompleted { disableRewardTokenClaim = true; emit ClaimRewardTokensDisabled(getCurrentSegment()); } /// @dev pauses the game. This function can be called only by the contract's admin. function pause() external onlyOwner whenNotPaused { _pause(); } /// @dev unpauses the game. This function can be called only by the contract's admin. function unpause() external onlyOwner whenPaused { _unpause(); } /// @dev Unlocks renounceOwnership. function unlockRenounceOwnership() external onlyOwner { allowRenouncingOwnership = true; } /// @dev Renounces Ownership. function renounceOwnership() public override onlyOwner { if (!allowRenouncingOwnership) { revert RENOUNCE_OWNERSHIP_NOT_ALLOWED(); } super.renounceOwnership(); } /** @dev Allows admin to set a lower early withdrawal fee. @param _newEarlyWithdrawFee New earlywithdrawal fee. */ function lowerEarlyWithdrawFee(uint64 _newEarlyWithdrawFee) external virtual onlyOwner { uint64 currentFee = earlyWithdrawalFee; if (_newEarlyWithdrawFee >= currentFee) { revert INVALID_EARLY_WITHDRAW_FEE(); } earlyWithdrawalFee = _newEarlyWithdrawFee; emit EarlyWithdrawalFeeChanged(getCurrentSegment(), currentFee, _newEarlyWithdrawFee); } /// @dev Allows the admin to withdraw the performance fee, if applicable. This function can be called only by the contract's admin. /// Cannot be called before the game ends. /// @param _minAmount Slippage based amount to cover for impermanent loss scenario. function adminFeeWithdraw(uint256 _minAmount) external virtual onlyOwner whenGameIsCompleted { if (adminWithdraw) { revert ADMIN_FEE_WITHDRAWN(); } adminWithdraw = true; // UPDATE - C2 Audit Report - removing redeem method _setGlobalPoolParams(); // to avoid SLOAD multiple times // UPDATE - A5 Audit Report uint256[] memory _adminFeeAmount = adminFeeAmount; IERC20[] memory _rewardTokens = rewardTokens; // flag that indicates if there are any rewards claimable by the admin bool _claimableRewards = _checkRewardsClaimableByAdmin(_adminFeeAmount); // have to check for both since the rewards, interest accumulated along with the total deposit is withdrawn in a single redeem call if (_adminFeeAmount[0] != 0 || _claimableRewards) { // safety check in case some incentives in the form of the deposit tokens are transferred to the pool uint256 _amountToRedeem = getRedemptionValue(_adminFeeAmount[0], strategy.getTotalAmount()); strategy.redeem(inboundToken, _amountToRedeem, _minAmount, disableRewardTokenClaim); // need the updated value for the event // balance check before transferring the funds _adminFeeAmount[0] = _transferFundsSafelyOrFail(owner(), _adminFeeAmount[0]); if (_claimableRewards) { // reference for array length to save gas uint256 _rewardsLength = _rewardTokens.length; for (uint256 i = 0; i < _rewardsLength; ) { if (address(_rewardTokens[i]) != address(0)) { // updates variable value to make sure on a failure, event is emitted w/ correct value. // first slot is reserved for admin interest amount, so starts at 1. _adminFeeAmount[i + 1] = _transferTokenOrContinueOnFailure( address(_rewardTokens[i]), owner(), _adminFeeAmount[i + 1] ); } unchecked { ++i; } } } } uint256 _adminIncentiveAmount; // winnerCount will always have the correct number of winners fetched from segment counter if emergency withdraw is enabled. // UPDATE - N2 Audit Report if (winnerCount == 0) { if (totalIncentiveAmount != 0) { // updates variable value to make sure on a failure, event is emitted w/ correct value. // UPDATE - N1 Audit Report _adminIncentiveAmount = _transferTokenOrContinueOnFailure( address(incentiveToken), owner(), totalIncentiveAmount ); } } // emitting it here since to avoid duplication made the if block common for incentive and reward tokens emit AdminWithdrawal(owner(), totalGameInterest, _adminIncentiveAmount, _adminFeeAmount); } /** @dev Allows a player to join the game/pool by makking the first deposit. @param _minAmount Slippage based amount to cover for impermanent loss scenario. @param _depositAmount Variable Deposit Amount in case of a variable deposit pool. */ function joinGame( uint256 _minAmount, uint256 _depositAmount ) external payable virtual whenGameIsInitialized whenNotPaused whenGameIsNotCompleted nonReentrant { _joinGame(_minAmount, _depositAmount); } /** @dev Allows a player to withdraw funds before the game ends. An early withdrawal fee is charged. @param _minAmount Slippage based amount to cover for impermanent loss scenario in case of a amm strategy like curve or mobius. */ // UPDATE - L1 Audit Report function earlyWithdraw(uint256 _minAmount) external whenNotPaused whenGameIsNotCompleted nonReentrant { Player storage player = players[msg.sender]; if (player.amountPaid == 0) { revert PLAYER_DOES_NOT_EXIST(); } if (player.withdrawn) { revert PLAYER_ALREADY_WITHDREW_EARLY(); } player.withdrawn = true; activePlayersCount -= 1; // In an early withdraw, users get their principal minus the earlyWithdrawalFee % defined in the constructor & it also considers the impermanent loss. uint256 _totalBalance = isTransactionalToken ? address(this).balance + strategy.getTotalAmount() : IERC20(inboundToken).balanceOf(address(this)) + strategy.getTotalAmount(); uint256 withdrawAmount = player.netAmountPaid - ((player.netAmountPaid * earlyWithdrawalFee) / 100); if (_totalBalance < netTotalGamePrincipal) { // handling impermanent loss case uint256 _impermanentLossShare = (_totalBalance * 100) / netTotalGamePrincipal; withdrawAmount = (withdrawAmount * _impermanentLossShare) / 100; } // Decreases the totalGamePrincipal & netTotalGamePrincipal on earlyWithdraw totalGamePrincipal -= player.amountPaid; netTotalGamePrincipal -= player.netAmountPaid; uint64 currentSegment = getCurrentSegment(); player.withdrawalSegment = currentSegment; uint256 playerIndexSum; // calculate playerIndexSum for each player for (uint256 i = 0; i <= player.mostRecentSegmentPaid; ) { playerIndexSum += playerIndex[msg.sender][i]; unchecked { ++i; } } // Users that early withdraw during the first segment, are allowed to rejoin. if (currentSegment == 0) { player.canRejoin = true; playerIndex[msg.sender][currentSegment] = 0; } // FIX - C3 Audit Report // reduce the cumulativePlayerIndexSum for the segment where the player doing the early withdraw deposited last // cumulativePlayerIndexSum has the value of the player index sums for all player till the current segment. cumulativePlayerIndexSum[player.mostRecentSegmentPaid] -= playerIndexSum; // reduce the totalWinnerDepositsPerSegment for the segment. totalWinnerDepositsPerSegment[player.mostRecentSegmentPaid] -= player.netAmountPaid; unchecked { // update winner count if (winnerCount != 0 && player.isWinner) { winnerCount -= 1; player.isWinner = false; } // segment counter calculation needed for ui as backup in case graph goes down if (segmentCounter[currentSegment] != 0) { segmentCounter[currentSegment] -= 1; } } strategy.earlyWithdraw(inboundToken, withdrawAmount, _minAmount); // balance check before transferring the funds uint256 actualTransferredAmount = _transferFundsSafelyOrFail(msg.sender, withdrawAmount); // We have to ignore the "check-effects-interactions" pattern here and emit the event // only at the end of the function, in order to emit it w/ the correct withdrawal amount. // In case the safety checks above are evaluated to true, withdrawAmount is updated, // so we need the event to be emitted with the correct info. emit EarlyWithdrawal( msg.sender, actualTransferredAmount, totalGamePrincipal, netTotalGamePrincipal, player.amountPaid, player.netAmountPaid ); } /** @dev Allows player to withdraw their funds after the game ends with no loss (fee). Winners get a share of the interest earned & additional rewards based on the player index. @param _minAmount Slippage based amount to cover for impermanent loss scenario in case of a amm strategy like curve or mobius. */ // UPDATE - L1 Audit Report function withdraw(uint256 _minAmount) external virtual nonReentrant { Player storage player = players[msg.sender]; if (player.amountPaid == 0) { revert PLAYER_DOES_NOT_EXIST(); } if (player.withdrawn) { revert PLAYER_ALREADY_WITHDREW(); } player.withdrawn = true; // UPDATE - C2 Audit Report - removing redeem method _setGlobalPoolParams(); // to avoid SLOAD multiple times uint64 depositCountMemory = depositCount; uint256 _impermanentLossShare = impermanentLossShare; uint256 payout; if (_isWinner(player, depositCountMemory)) { // determining last game segment considering the possibility of emergencyWithdraw uint64 segment = depositCountMemory == 0 ? 0 : uint64(depositCountMemory - 1); ( uint256 playerIndexSharePercentage, uint256 playerDepositAmountSharePercentage, uint256 _payout ) = _calculateAndUpdateWinnerInterestAccounting(segment, _impermanentLossShare); payout = _payout; // safety check in case some incentives in the form of the deposit tokens are transferred to the pool\ uint256 _amountToRedeem = getRedemptionValue(payout, strategy.getTotalAmount()); strategy.redeem(inboundToken, _amountToRedeem, _minAmount, disableRewardTokenClaim); // calculating winners share of the incentive amount _calculateAndUpdateWinnerIncentivesAccounting( playerDepositAmountSharePercentage, playerIndexSharePercentage ); // calculating winners share of the reward earned from the external protocol deposits/no_strategy _calculateAndUpdateWinnerRewardAccounting(playerDepositAmountSharePercentage, playerIndexSharePercentage); } else { payout = _calculateAndUpdateNonWinnerAccounting(_impermanentLossShare, player.netAmountPaid); // safety check in case some incentives in the form of the deposit tokens are transferred to the pool uint256 _amountToRedeem = getRedemptionValue(payout, strategy.getTotalAmount()); // Withdraws the principal for non-winners strategy.redeem(inboundToken, _amountToRedeem, _minAmount, disableRewardTokenClaim); } // sets withdrawalSegment for the player player.withdrawalSegment = getCurrentSegment(); if (_impermanentLossShare != 0) { // resetting I.Loss Share % after every withdrawal to be consistent impermanentLossShare = 0; } // Updating total principal as well after each player withdraws this is separate since we have to do this for non-players if (netTotalGamePrincipal < player.netAmountPaid) { netTotalGamePrincipal = 0; totalGamePrincipal = 0; } else { netTotalGamePrincipal -= player.netAmountPaid; totalGamePrincipal -= player.amountPaid; } // sending the inbound token amount i.e principal + interest to the winners and just the principal in case of players // adding a balance safety check to ensure the tx does not revert in case of impermanent loss uint256 actualTransferredAmount = _transferFundsSafelyOrFail(msg.sender, payout); // We have to ignore the "check-effects-interactions" pattern here and emit the event // only at the end of the function, in order to emit it w/ the correct withdrawal amount. // In case the safety checks above are evaluated to true, payout, playerIncentive and playerReward // are updated, so we need the event to be emitted with the correct info. emit WithdrawInboundTokens(msg.sender, actualTransferredAmount); emit UpdateGameStats( msg.sender, isTransactionalToken ? address(this).balance : IERC20(inboundToken).balanceOf(address(this)), totalGamePrincipal, netTotalGamePrincipal, totalGameInterest, totalIncentiveAmount, rewardTokenAmounts, impermanentLossShare ); } /** @dev Allows players to make deposits for the game segments, after joining the game. @param _minAmount Slippage based amount to cover for impermanent loss scenario. @param _depositAmount Variable Deposit Amount in case of a variable deposit pool. */ function makeDeposit(uint256 _minAmount, uint256 _depositAmount) external payable whenNotPaused nonReentrant { if (players[msg.sender].withdrawn) { revert PLAYER_ALREADY_WITHDREW_EARLY(); } // only registered players can deposit if (players[msg.sender].addr != msg.sender) { revert NOT_PLAYER(); } if (flexibleSegmentPayment) { if (_depositAmount != players[msg.sender].depositAmount) { revert INVALID_FLEXIBLE_AMOUNT(); } } uint256 currentSegment = getCurrentSegment(); // User can only deposit between segment 1 and segment n-1 (where n is the number of segments for the game) or if the emergencyWithdraw flag has not been enabled. // Details: // Segment 0 is paid when user joins the game (the first deposit window). // Last segment doesn't accept payments, because the payment window for the last // segment happens on segment n-1 (penultimate segment). // Any segment greater than the last segment means the game is completed, and cannot // receive payments if (currentSegment == 0 || currentSegment >= depositCount || emergencyWithdraw) { revert DEPOSIT_NOT_ALLOWED(); } //check if current segment is currently unpaid if (players[msg.sender].mostRecentSegmentPaid == currentSegment) { revert PLAYER_ALREADY_PAID_IN_CURRENT_SEGMENT(); } // check if player has made payments up to the previous segment if (players[msg.sender].mostRecentSegmentPaid != (currentSegment - 1)) { revert PLAYER_DID_NOT_PAID_PREVIOUS_SEGMENT(); } uint256 amount = flexibleSegmentPayment ? _depositAmount : segmentPayment; if (isTransactionalToken) { if (msg.value != amount) { revert INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); } } else { if (msg.value != 0) { revert INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); } } // get net deposit amount from the strategy uint256 netAmount = strategy.getNetDepositAmount(amount); if (netAmount == 0) { revert INVALID_NET_DEPOSIT_AMOUNT(); } emit Deposit(msg.sender, currentSegment, amount, netAmount); _transferInboundTokenToContract(_minAmount, amount, netAmount); } // Fallback Functions for calldata and reciever for handling only ether transfer // UPDATE - A7 Audit Report receive() external payable { if (msg.sender != address(strategy)) { revert INVALID_TRANSACTIONAL_TOKEN_SENDER(); } if (!isTransactionalToken) { revert INVALID_TRANSACTIONAL_TOKEN_AMOUNT(); } } }
pragma solidity 0.8.7; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; interface IStrategy { function invest(address _inboundCurrency, uint256 _minAmount) external payable; function earlyWithdraw(address _inboundCurrency, uint256 _amount, uint256 _minAmount) external; function redeem( address _inboundCurrency, uint256 _amount, uint256 _minAmount, bool disableRewardTokenClaim ) external; function getTotalAmount() external view returns (uint256); function getLPTokenAmount(uint256 _amount) external view returns (uint256); function getFee() external view returns (uint256); function getNetDepositAmount(uint256 _amount) external view returns (uint256); function getAccumulatedRewardTokenAmounts(bool disableRewardTokenClaim) external returns (uint256[] memory); function getRewardTokens() external view returns (IERC20[] memory); function getUnderlyingAsset() external view returns (address); function strategyOwner() external view returns (address); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @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 amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol) pragma solidity ^0.8.0; /** * @dev Contract module that helps prevent reentrant calls to a function. * * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier * available, which can be applied 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. * * TIP: If you would like to learn more about reentrancy and alternative ways * to protect against it, check out our blog post * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul]. */ abstract contract ReentrancyGuard { // Booleans are more expensive than uint256 or any type that takes up a full // word because each write operation emits an extra SLOAD to first read the // slot's contents, replace the bits taken up by the boolean, and then write // back. This is the compiler's defense against contract upgrades and // pointer aliasing, and it cannot be disabled. // The values being non-zero value makes deployment a bit more expensive, // but in exchange the refund on every call to nonReentrant will be lower in // amount. Since refunds are capped to a percentage of the total // transaction's gas, it is best to keep them low in cases like this one, to // increase the likelihood of the full refund coming into effect. uint256 private constant _NOT_ENTERED = 1; uint256 private constant _ENTERED = 2; uint256 private _status; constructor() { _status = _NOT_ENTERED; } /** * @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 making it call a * `private` function that does the actual work. */ modifier nonReentrant() { _nonReentrantBefore(); _; _nonReentrantAfter(); } function _nonReentrantBefore() private { // On the first call to nonReentrant, _status will be _NOT_ENTERED require(_status != _ENTERED, "ReentrancyGuard: reentrant call"); // Any calls to nonReentrant after this point will fail _status = _ENTERED; } function _nonReentrantAfter() private { // By storing the original value once again, a refund is triggered (see // https://eips.ethereum.org/EIPS/eip-2200) _status = _NOT_ENTERED; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol) pragma solidity ^0.8.0; import "../utils/Context.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 Pausable is Context { /** * @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); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ constructor() { _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) { return _paused; } /** * @dev Throws if the contract is paused. */ function _requireNotPaused() internal view virtual { require(!paused(), "Pausable: paused"); } /** * @dev Throws if the contract is not paused. */ function _requirePaused() internal view virtual { require(paused(), "Pausable: not paused"); } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
{ "remappings": [], "optimizer": { "enabled": true, "runs": 10 }, "evmVersion": "london", "libraries": {}, "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"_inboundCurrency","type":"address"},{"internalType":"uint256","name":"_maxFlexibleSegmentPaymentAmount","type":"uint256"},{"internalType":"uint64","name":"_depositCount","type":"uint64"},{"internalType":"uint64","name":"_segmentLength","type":"uint64"},{"internalType":"uint64","name":"_waitingRoundSegmentLength","type":"uint64"},{"internalType":"uint256","name":"_segmentPayment","type":"uint256"},{"internalType":"uint64","name":"_earlyWithdrawalFee","type":"uint64"},{"internalType":"uint64","name":"_customFee","type":"uint64"},{"internalType":"uint64","name":"_maxPlayersCount","type":"uint64"},{"internalType":"bool","name":"_flexibleSegmentPayment","type":"bool"},{"internalType":"contract IStrategy","name":"_strategy","type":"address"},{"internalType":"bool","name":"_isTransactionalToken","type":"bool"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ADMIN_FEE_WITHDRAWN","type":"error"},{"inputs":[],"name":"DEPOSIT_NOT_ALLOWED","type":"error"},{"inputs":[],"name":"EARLY_EXIT_NOT_POSSIBLE","type":"error"},{"inputs":[],"name":"GAME_ALREADY_INITIALIZED","type":"error"},{"inputs":[],"name":"GAME_ALREADY_STARTED","type":"error"},{"inputs":[],"name":"GAME_COMPLETED","type":"error"},{"inputs":[],"name":"GAME_NOT_COMPLETED","type":"error"},{"inputs":[],"name":"GAME_NOT_INITIALIZED","type":"error"},{"inputs":[],"name":"INVALID_CUSTOM_FEE","type":"error"},{"inputs":[],"name":"INVALID_DEPOSIT_COUNT","type":"error"},{"inputs":[],"name":"INVALID_EARLY_WITHDRAW_FEE","type":"error"},{"inputs":[],"name":"INVALID_FLEXIBLE_AMOUNT","type":"error"},{"inputs":[],"name":"INVALID_INBOUND_TOKEN","type":"error"},{"inputs":[],"name":"INVALID_INCENTIVE_TOKEN","type":"error"},{"inputs":[],"name":"INVALID_MAX_FLEXIBLE_AMOUNT","type":"error"},{"inputs":[],"name":"INVALID_MAX_PLAYER_COUNT","type":"error"},{"inputs":[],"name":"INVALID_NET_DEPOSIT_AMOUNT","type":"error"},{"inputs":[],"name":"INVALID_OWNER","type":"error"},{"inputs":[],"name":"INVALID_SEGMENT_LENGTH","type":"error"},{"inputs":[],"name":"INVALID_SEGMENT_PAYMENT","type":"error"},{"inputs":[],"name":"INVALID_STRATEGY","type":"error"},{"inputs":[],"name":"INVALID_TRANSACTIONAL_TOKEN_AMOUNT","type":"error"},{"inputs":[],"name":"INVALID_TRANSACTIONAL_TOKEN_SENDER","type":"error"},{"inputs":[],"name":"INVALID_WAITING_ROUND_SEGMENT_LENGTH","type":"error"},{"inputs":[],"name":"MAX_PLAYER_COUNT_REACHED","type":"error"},{"inputs":[],"name":"NOT_PLAYER","type":"error"},{"inputs":[],"name":"PLAYER_ALREADY_JOINED","type":"error"},{"inputs":[],"name":"PLAYER_ALREADY_PAID_IN_CURRENT_SEGMENT","type":"error"},{"inputs":[],"name":"PLAYER_ALREADY_WITHDREW","type":"error"},{"inputs":[],"name":"PLAYER_ALREADY_WITHDREW_EARLY","type":"error"},{"inputs":[],"name":"PLAYER_DID_NOT_PAID_PREVIOUS_SEGMENT","type":"error"},{"inputs":[],"name":"PLAYER_DOES_NOT_EXIST","type":"error"},{"inputs":[],"name":"RENOUNCE_OWNERSHIP_NOT_ALLOWED","type":"error"},{"inputs":[],"name":"TOKEN_TRANSFER_FAILURE","type":"error"},{"inputs":[],"name":"TRANSACTIONAL_TOKEN_TRANSFER_FAILURE","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256[]","name":"adminFeeAmounts","type":"uint256[]"}],"name":"AdminFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalGameInterest","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"adminIncentiveAmount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"adminFeeAmounts","type":"uint256[]"}],"name":"AdminWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"currentSegment","type":"uint64"}],"name":"ClaimRewardTokensDisabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":true,"internalType":"uint256","name":"segment","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netAmount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalGamePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netTotalGamePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositedAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"depositedNetAmount","type":"uint256"}],"name":"EarlyWithdrawal","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"currentSegment","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"oldFee","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"newFee","type":"uint64"}],"name":"EarlyWithdrawalFeeChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"currentSegment","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"winnerCount","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"depositRoundInterestSharePercentage","type":"uint64"}],"name":"EmergencyWithdrawalEnabled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalGamePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netTotalGamePricipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalGameInterest","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"grossRewardTokenAmount","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"totalIncentiveAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"impermanentLossShare","type":"uint256"}],"name":"EndGameStats","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"ExternalTokenGetBalanceError","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":false,"internalType":"bytes","name":"reason","type":"bytes"}],"name":"ExternalTokenTransferError","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"token","type":"address"}],"name":"IncentiveTokenSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint64","name":"firstSegmentStart","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"waitingRoundSegmentStart","type":"uint64"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netAmount","type":"uint256"}],"name":"JoinedGame","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"totalBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalGamePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"netTotalGamePrincipal","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalGameInterest","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"totalIncentiveAmount","type":"uint256"},{"indexed":false,"internalType":"uint256[]","name":"totalRewardAmounts","type":"uint256[]"},{"indexed":false,"internalType":"uint256","name":"impermanentLossShare","type":"uint256"}],"name":"UpdateGameStats","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawInboundTokens","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"WithdrawIncentiveToken","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"player","type":"address"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"WithdrawRewardTokens","type":"event"},{"inputs":[],"name":"MULTIPLIER","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"activePlayersCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFee","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"adminFeeAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"adminFeeSet","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"adminFeeWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"adminWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowRenouncingOwnership","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"cumulativePlayerIndexSum","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"depositRoundInterestSharePercentage","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"disableClaimingRewardTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"disableRewardTokenClaim","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"earlyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"earlyWithdrawalFee","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emergencyWithdraw","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"enableEmergencyWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"firstSegmentStart","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flexibleSegmentPayment","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getCurrentSegment","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getNumberOfPlayers","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"impermanentLossShare","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"inboundToken","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"incentiveToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_incentiveToken","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"isGameCompleted","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isInitialized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isTransactionalToken","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_player","type":"address"}],"name":"isWinner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"iterablePlayers","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount","type":"uint256"},{"internalType":"uint256","name":"_depositAmount","type":"uint256"}],"name":"joinGame","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint64","name":"_newEarlyWithdrawFee","type":"uint64"}],"name":"lowerEarlyWithdrawFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount","type":"uint256"},{"internalType":"uint256","name":"_depositAmount","type":"uint256"}],"name":"makeDeposit","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"maxFlexibleSegmentPaymentAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxPlayersCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"netTotalGamePrincipal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"playerIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"players","outputs":[{"internalType":"bool","name":"withdrawn","type":"bool"},{"internalType":"bool","name":"canRejoin","type":"bool"},{"internalType":"bool","name":"isWinner","type":"bool"},{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"withdrawalSegment","type":"uint64"},{"internalType":"uint64","name":"mostRecentSegmentPaid","type":"uint64"},{"internalType":"uint256","name":"amountPaid","type":"uint256"},{"internalType":"uint256","name":"netAmountPaid","type":"uint256"},{"internalType":"uint256","name":"depositAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokenAmounts","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"rewardTokens","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"segmentCounter","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"segmentLength","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"segmentPayment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC20","name":"_incentiveToken","type":"address"}],"name":"setIncentiveToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"strategy","outputs":[{"internalType":"contract IStrategy","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalGameInterest","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalGamePrincipal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalIncentiveAmount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"totalWinnerDepositsPerSegment","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unlockRenounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"waitingRoundSegmentLength","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"waitingRoundSegmentStart","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"winnerCount","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"winnersLeftToWithdraw","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_minAmount","type":"uint256"}],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Deployed Bytecode
0x6080604052600436106102c65760003560e01c80638014c113116101775780638014c113146107645780638456cb5914610791578063872a61f2146107a65780638da5cb5b146107d357806395224b33146107e85780639d9ca28d146107fe5780639f60d9a11461081e578063a0be06f914610845578063a8c62e7614610879578063aad739f5146108a0578063ae545311146108c0578063b60b9fcb146108e0578063b6e4ca08146108f3578063c00a866214610913578063c22b5bbd14610929578063c39b583c1461095d578063c4d66de814610972578063c68e0a0414610992578063ca920b98146109ca578063caa02e08146109ea578063d013666e14610a11578063db2e21bc14610a45578063dbe3cbe514610a5f578063e2eb41ff14610a93578063e843633614610b75578063ebca4eeb14610b9c578063f18d20be14610bbb578063f2fde38b14610bdc578063f4ceab1c14610bfc578063f5c9786714610c11578063fd6673f514610c2657600080fd5b8063059f8b161461034257806306c6e5361461036e578063088e0ed1146103a25780630c423f32146103c25780630c8ac6451461040e5780630f1e37ea1461044257806316330d4014610458578063250a2b0d1461047f5780632dfdf0b51461049f5780632e1a7d4d146104c657806336301533146104e6578063392e53cd146104fb5780633e7433eb146105275780633f0f4076146105475780633f4ba83a1461055a5780634281b1fb1461056f57806349761947146105b0578063537788fd146105c55780635a497ad4146105e55780635c975abb1461060c5780635faeea3714610621578063638126f8146106375780636a79328a146106575780636b5b96961461066d5780636e8108a11461068d5780636fc3f8f6146106ba578063715018a6146106da5780637bb7bed1146106ef5780637c80e6da1461070f5780637e5f84761461074357600080fd5b3661033d57600b54600160281b90046001600160a01b031633146102fd576040516305ca55ed60e11b815260040160405180910390fd5b7f000000000000000000000000000000000000000000000000000000000000000061033b5760405163e1f0844960e01b815260040160405180910390fd5b005b600080fd5b34801561034e57600080fd5b5061035b64e8d4a5100081565b6040519081526020015b60405180910390f35b34801561037a57600080fd5b5061035b7f0000000000000000000000000000000000000000000000000000000011e1a30081565b3480156103ae57600080fd5b5061035b6103bd3660046156f9565b610c3b565b3480156103ce57600080fd5b506103f67f0000000000000000000000000000000000000000000000000000000000700f8081565b6040516001600160401b039091168152602001610365565b34801561041a57600080fd5b5061035b7f000000000000000000000000000000000000000000000000000000000000000081565b34801561044e57600080fd5b5061035b60095481565b34801561046457600080fd5b506002546103f690600160c01b90046001600160401b031681565b34801561048b57600080fd5b506003546103f6906001600160401b031681565b3480156104ab57600080fd5b506002546103f690600160801b90046001600160401b031681565b3480156104d257600080fd5b5061033b6104e13660046156f9565b610c5c565b3480156104f257600080fd5b5061033b611182565b34801561050757600080fd5b506002546001600160401b031615155b6040519015158152602001610365565b34801561053357600080fd5b506002546103f6906001600160401b031681565b61033b61055536600461572b565b611316565b34801561056657600080fd5b5061033b611684565b34801561057b57600080fd5b506105a37f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd681565b60405161036591906157b1565b3480156105bc57600080fd5b5061033b61169e565b3480156105d157600080fd5b50600b546105179062010000900460ff1681565b3480156105f157600080fd5b506003546103f690600160801b90046001600160401b031681565b34801561061857600080fd5b50610517611724565b34801561062d57600080fd5b5061035b60065481565b34801561064357600080fd5b50600c546105a3906001600160a01b031681565b34801561066357600080fd5b5061035b60085481565b34801561067957600080fd5b5061033b6106883660046156f9565b611734565b34801561069957600080fd5b5061035b6106a83660046156f9565b60116020526000908152604090205481565b3480156106c657600080fd5b5061035b6106d53660046156f9565b611d90565b3480156106e657600080fd5b5061033b611da0565b3480156106fb57600080fd5b506105a361070a3660046156f9565b611dda565b34801561071b57600080fd5b506103f67f00000000000000000000000000000000000000000000000000000000000007d081565b34801561074f57600080fd5b50600b5461051790600160201b900460ff1681565b34801561077057600080fd5b5061035b61077f3660046156f9565b60106020526000908152604090205481565b34801561079d57600080fd5b5061033b611e04565b3480156107b257600080fd5b5061035b6107c13660046156f9565b60126020526000908152604090205481565b3480156107df57600080fd5b506105a3611e1c565b3480156107f457600080fd5b5061035b60045481565b34801561080a57600080fd5b506105176108193660046155ad565b611e2b565b34801561082a57600080fd5b506003546103f690600160c01b90046001600160401b031681565b34801561085157600080fd5b506103f67f000000000000000000000000000000000000000000000000000000000000000a81565b34801561088557600080fd5b50600b546105a390600160281b90046001600160a01b031681565b3480156108ac57600080fd5b506105a36108bb3660046156f9565b611e8e565b3480156108cc57600080fd5b5061033b6108db3660046155ad565b611e9e565b61033b6108ee36600461572b565b6120ba565b3480156108ff57600080fd5b5061033b61090e3660046156f9565b61212c565b34801561091f57600080fd5b5061035b60055481565b34801561093557600080fd5b506105177f000000000000000000000000000000000000000000000000000000000000000181565b34801561096957600080fd5b50610517612540565b34801561097e57600080fd5b5061033b61098d3660046155ad565b61257a565b34801561099e57600080fd5b5061035b6109ad3660046155e7565b600f60209081526000928352604080842090915290825290205481565b3480156109d657600080fd5b5061033b6109e536600461574d565b612724565b3480156109f657600080fd5b506003546103f690600160401b90046001600160401b031681565b348015610a1d57600080fd5b506103f67f00000000000000000000000000000000000000000000000000000000006ebe0081565b348015610a5157600080fd5b50600b546105179060ff1681565b348015610a6b57600080fd5b506105177f000000000000000000000000000000000000000000000000000000000000000081565b348015610a9f57600080fd5b50610b18610aae3660046155ad565b600e602052600090815260409020805460018201546002830154600384015460049094015460ff80851695610100860482169562010000810490921694630100000083046001600160a01b031694600160b81b9093046001600160401b0390811694911692919089565b604080519915158a5297151560208a0152951515968801969096526001600160a01b0390931660608701526001600160401b0391821660808701521660a085015260c084015260e083019190915261010082015261012001610365565b348015610b8157600080fd5b506002546103f690600160401b90046001600160401b031681565b348015610ba857600080fd5b50600b5461051790610100900460ff1681565b348015610bc757600080fd5b50600b54610517906301000000900460ff1681565b348015610be857600080fd5b5061033b610bf73660046155ad565b6127c9565b348015610c0857600080fd5b5061033b612844565b348015610c1d57600080fd5b506103f6612861565b348015610c3257600080fd5b5060135461035b565b600a8181548110610c4b57600080fd5b600091825260209091200154905081565b610c646129d0565b336000908152600e602052604090206002810154610c955760405163c5e3efc560e01b815260040160405180910390fd5b805460ff1615610cb8576040516323791bbf60e21b815260040160405180910390fd5b805460ff19166001178155610ccb612a2a565b600254600954600160801b9091046001600160401b0316906000610cef8484612efb565b15610e8b5760006001600160401b03841615610d1557610d10600185615a3d565b610d18565b60005b90506000806000610d298487612f6b565b9250925092508094506000610dc386600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8657600080fd5b505afa158015610d9a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610dbe9190615712565b613277565b9050600b60059054906101000a90046001600160a01b03166001600160a01b03166365e0d7317f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd6838d600b60029054906101000a900460ff166040518563ffffffff1660e01b8152600401610e3b94939291906157de565b600060405180830381600087803b158015610e5557600080fd5b505af1158015610e69573d6000803e3d6000fd5b50505050610e77838561328f565b610e8183856133b1565b5050505050610f89565b610e9982856003015461370f565b90506000610eef82600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8657600080fd5b600b546040516365e0d73160e01b8152919250600160281b81046001600160a01b0316916365e0d73191610f55917f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd69186918c9162010000900460ff16906004016157de565b600060405180830381600087803b158015610f6f57600080fd5b505af1158015610f83573d6000803e3d6000fd5b50505050505b610f91612861565b84546001600160401b0391909116600160b81b02600160b81b600160f81b03199091161784558115610fc35760006009555b83600301546005541015610fe05760006005819055600655611018565b836003015460056000828254610ff69190615a26565b9091555050600284015460068054600090611012908490615a26565b90915550505b600061102433836137f0565b60405181815290915033907faa7d2735c626954bee68a4b13fc5d4947d926e5d80e93302cdb6ab18972577cd9060200160405180910390a2337f2a50b398a66bfcb585c9bcdc7098260605df7cb8a35aff4ced17628b9a00d7ba7f0000000000000000000000000000000000000000000000000000000000000000611144576040516370a0823160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906370a08231906110ef9030906004016157b1565b60206040518083038186803b15801561110757600080fd5b505afa15801561111b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113f9190615712565b611146565b475b600654600554600454600854600954604051611169969594939291600a916158d7565b60405180910390a2505050505061117f60018055565b50565b61118a613aab565b611192612540565b156111b0576040516302066c1160e61b815260040160405180910390fd5b6006546111d05760405163f585c2c160e01b815260040160405180910390fd5b60006111da612861565b90506001600160401b038116611208576001600160401b038116600090815260106020526040902054611256565b60106000611217600184615a3d565b6001600160401b031681526020019081526020016000205460106000836001600160401b03168152602001908152602001600020546112569190615973565b600380546001600160401b0392909216600160401b02600160401b600160801b0319909216919091179055600b805460ff1916600117905561129781613b0a565b600280546001600160401b03808416600160801b02600160801b600160c01b0319909216919091179091556003546040517fb6b6b40c75a707f2e02161e4c3a0fedc1b52de156954e15ca2c0cd0cc77e721d9261130b928592600160401b8204831692600160c01b90920490911690615950565b60405180910390a150565b61131e613ce7565b6113266129d0565b336000908152600e602052604090205460ff16156113575760405163b3db1d7f60e01b815260040160405180910390fd5b336000818152600e6020526040902054630100000090046001600160a01b03161461139557604051633fa546c360e01b815260040160405180910390fd5b7f0000000000000000000000000000000000000000000000000000000000000001156113ed57336000908152600e602052604090206004015481146113ed57604051637292a14360e11b815260040160405180910390fd5b60006113f7612861565b6001600160401b031690508015806114215750600254600160801b90046001600160401b03168110155b8061142e5750600b5460ff165b1561144c5760405163a406d3cf60e01b815260040160405180910390fd5b336000908152600e60205260409020600101546001600160401b03168114156114885760405163bdf3e4c560e01b815260040160405180910390fd5b611493600182615a26565b336000908152600e60205260409020600101546001600160401b0316146114cd576040516378e1742160e01b815260040160405180910390fd5b60007f000000000000000000000000000000000000000000000000000000000000000161151a577f000000000000000000000000000000000000000000000000000000000000000061151c565b825b90507f000000000000000000000000000000000000000000000000000000000000000015611569578034146115645760405163e1f0844960e01b815260040160405180910390fd5b611588565b34156115885760405163e1f0844960e01b815260040160405180910390fd5b600b546040516365237abb60e01b815260048101839052600091600160281b90046001600160a01b0316906365237abb9060240160206040518083038186803b1580156115d457600080fd5b505afa1580156115e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061160c9190615712565b90508061162c57604051630d2eb29360e41b815260040160405180910390fd5b6040805183815260208101839052849133917f36af321ec8d3c75236829c5317affd40ddb308863a1236d2d277a4025cccee1e910160405180910390a3611674858383613d2f565b50505061168060018055565b5050565b61168c613aab565b6116946141e4565b61169c61422f565b565b6116a6613aab565b6116ae612540565b156116cc576040516302066c1160e61b815260040160405180910390fd5b600b805462ff00001916620100001790557f58ef3e4ef459813e0b4b35635d3f11015f47a47986df341c25242e98073c0c29611706612861565b6040516001600160401b0390911681526020015b60405180910390a1565b600054600160a01b900460ff1690565b61173c613ce7565b611744612540565b15611762576040516302066c1160e61b815260040160405180910390fd5b61176a6129d0565b336000908152600e60205260409020600281015461179b5760405163c5e3efc560e01b815260040160405180910390fd5b805460ff16156117be5760405163b3db1d7f60e01b815260040160405180910390fd5b805460ff191660019081178255600380546000906117e69084906001600160401b0316615a3d565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060007f000000000000000000000000000000000000000000000000000000000000000061196257600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b15801561187f57600080fd5b505afa158015611893573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b79190615712565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906370a08231906119039030906004016157b1565b60206040518083038186803b15801561191b57600080fd5b505afa15801561192f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119539190615712565b61195d9190615973565b6119f2565b600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b1580156119b057600080fd5b505afa1580156119c4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119e89190615712565b6119f29047615973565b905060006064600260189054906101000a90046001600160401b03166001600160401b03168460030154611a2691906159d8565b611a3091906159b6565b8360030154611a3f9190615a26565b9050600554821015611a8257600554600090611a5c8460646159d8565b611a6691906159b6565b90506064611a7482846159d8565b611a7e91906159b6565b9150505b826002015460066000828254611a989190615a26565b9091555050600383015460058054600090611ab4908490615a26565b9091555060009050611ac4612861565b8454600160b81b600160f81b031916600160b81b6001600160401b0383160217855590506000805b60018601546001600160401b03168111611b2f57336000908152600f60209081526040808320848452909152902054611b259083615973565b9150600101611aec565b506001600160401b038216611b7057845461ff001916610100178555336000908152600f602090815260408083206001600160401b03861684529091528120555b60018501546001600160401b031660009081526011602052604081208054839290611b9c908490615a26565b9091555050600385015460018601546001600160401b031660009081526012602052604081208054909190611bd2908490615a26565b9091555050600354600160401b90046001600160401b031615801590611bff5750845462010000900460ff165b15611c4057600380546000196001600160401b03600160401b8084048216929092011602600160401b600160801b0319909116179055845462ff0000191685555b6001600160401b03821660009081526010602052604090205415611c7f576001600160401b038216600090815260106020526040902080546000190190555b600b54604051634bfd657160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd6811660048301526024820186905260448201899052600160281b90920490911690634bfd657190606401600060405180830381600087803b158015611cfc57600080fd5b505af1158015611d10573d6000803e3d6000fd5b505050506000611d2033856137f0565b600654600554600289015460038a01546040805186815260208101959095528401929092526060830152608082015290915033907fd1e498a71981c6add75842aca59b74fe9c9b81dac4a208cd4da9360499205da49060a00160405180910390a250505050505061117f60018055565b60078181548110610c4b57600080fd5b611da8613aab565b600b54600160201b900460ff16611dd25760405163243f519360e21b815260040160405180910390fd5b61169c614274565b600d8181548110611dea57600080fd5b6000918252602090912001546001600160a01b0316905081565b611e0c613aab565b611e14613ce7565b61169c614286565b6000546001600160a01b031690565b6001600160a01b0381166000908152600e6020526040812060020154611e5357506000919050565b6001600160a01b0382166000908152600e60205260409020600254611e889190600160801b90046001600160401b0316612efb565b92915050565b60138181548110611dea57600080fd5b611ea6613aab565b611eae612540565b15611ecc576040516302066c1160e61b815260040160405180910390fd5b600c546001600160a01b0316151580611f4957507f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd66001600160a01b031615801590611f495750806001600160a01b03167f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd66001600160a01b0316145b15611f675760405163cd2ac49f60e01b815260040160405180910390fd5b6000600d805480602002602001604051908101604052809291908181526020018280548015611fbf57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611fa1575b505083519394506000925050505b818110156120615760006001600160a01b0316838281518110611ff257611ff2615a7b565b60200260200101516001600160a01b03161415801561203b5750836001600160a01b031683828151811061202857612028615a7b565b60200260200101516001600160a01b0316145b156120595760405163cd2ac49f60e01b815260040160405180910390fd5b600101611fcd565b50600c80546001600160a01b0319166001600160a01b0385161790556040517fdfb445dece52cc4e5554970d1ff164cd2eaa0babde21897b763c96655125f390906120ad9085906157b1565b60405180910390a1505050565b6002546001600160401b03166120e35760405163c4a5ed8960e01b815260040160405180910390fd5b6120eb613ce7565b6120f3612540565b15612111576040516302066c1160e61b815260040160405180910390fd5b6121196129d0565b61212382826142c9565b61168060018055565b612134613aab565b61213c612540565b61215957604051630418dd1f60e21b815260040160405180910390fd5b600b546301000000900460ff16156121845760405163f788b3bd60e01b815260040160405180910390fd5b600b805463ff0000001916630100000017905561219f612a2a565b600060078054806020026020016040519081016040528092919081815260200182805480156121ed57602002820191906000526020600020905b8154815260200190600101908083116121d9575b505050505090506000600d80548060200260200160405190810160405280929190818152602001828054801561224c57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161222e575b50505050509050600061225e83614747565b90508260008151811061227357612273615a7b565b602002602001015160001415806122875750805b156124a65760006122fa846000815181106122a4576122a4615a7b565b6020026020010151600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b158015610d8657600080fd5b600b546040516365e0d73160e01b8152919250600160281b81046001600160a01b0316916365e0d73191612360917f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd69186918b9162010000900460ff16906004016157de565b600060405180830381600087803b15801561237a57600080fd5b505af115801561238e573d6000803e3d6000fd5b505050506123bd61239d611e1c565b856000815181106123b0576123b0615a7b565b60200260200101516137f0565b846000815181106123d0576123d0615a7b565b60200260200101818152505081156124a457825160005b818110156124a15760006001600160a01b031685828151811061240c5761240c615a7b565b60200260200101516001600160a01b0316146124995761247085828151811061243757612437615a7b565b6020026020010151612447611e1c565b88612453856001615973565b8151811061246357612463615a7b565b6020026020010151614794565b8661247c836001615973565b8151811061248c5761248c615a7b565b6020026020010181815250505b6001016123e7565b50505b505b600354600090600160401b90046001600160401b03166124eb57600854156124eb57600c546124e8906001600160a01b03166124e0611e1c565b600854614794565b90505b6124f3611e1c565b6001600160a01b03167f390c89b8a52039f3cc9dc1e4fa212f6b6227a4e37b93dd8455bbe3f092a3a95b60045483876040516125319392919061586e565b60405180910390a25050505050565b600254600090600160801b90046001600160401b031661255e612861565b6001600160401b031611806125755750600b5460ff165b905090565b612582613aab565b6002546001600160401b0316156125ac57604051638cb3c0bd60e01b815260040160405180910390fd5b6125b4613ce7565b600b54604080516371ed7a2b60e11b815290513092600160281b90046001600160a01b03169163e3daf456916004808301926020929190829003018186803b1580156125ff57600080fd5b505afa158015612613573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061263791906155ca565b6001600160a01b03161461265e57604051639d2d273160e01b815260040160405180910390fd5b600280547f00000000000000000000000000000000000000000000000000000000006ebe00600160801b6001600160401b034281166001600160401b031985168117929092048116929092028101909116600160401b026001600160801b0319909216171790556126cf6000613b0a565b6126d881611e9e565b600254604080516001600160401b038084168252600160401b90930490921660208301527f0709318331fb59e779a19041b4e090bf8f8481b96601401c9b6887924248fec9910161130b565b61272c613aab565b6002546001600160401b03600160c01b9091048116908216811161276357604051633686fa6760e21b815260040160405180910390fd5b600280546001600160c01b0316600160c01b6001600160401b038516021790557f21020cbcf9f28164b52dd3fbd0e7dd8219bf982577046ed79c1c44c28a5d07f06127ac612861565b82846040516127bd93929190615950565b60405180910390a15050565b6127d1613aab565b6001600160a01b03811661283b5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084015b60405180910390fd5b61117f816149a6565b61284c613aab565b600b805460ff60201b1916600160201b179055565b6002546000906001600160401b031661288d5760405163c4a5ed8960e01b815260040160405180910390fd5b6002546000906001600160401b03600160401b90910481169082906128d4907f0000000000000000000000000000000000000000000000000000000000700f801683615973565b90504282111580156128e557508042105b1561290457600254600160801b90046001600160401b031692506129c8565b804210612981576001600160401b037f00000000000000000000000000000000000000000000000000000000006ebe001661293f8242615a26565b61294991906159b6565b60025461296790600160801b90046001600160401b0316600161598b565b6001600160401b031661297a9190615973565b92506129c8565b6002546001600160401b037f00000000000000000000000000000000000000000000000000000000006ebe008116916129bb911642615a26565b6129c591906159b6565b92505b509091505090565b60026001541415612a235760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401612832565b6002600155565b612a32612540565b612a4f57604051630418dd1f60e21b815260040160405180910390fd5b60007f0000000000000000000000000000000000000000000000000000000000000000612ba757600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b158015612ac457600080fd5b505afa158015612ad8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612afc9190615712565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906370a0823190612b489030906004016157b1565b60206040518083038186803b158015612b6057600080fd5b505afa158015612b74573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b989190615712565b612ba29190615973565b612c37565b600b60059054906101000a90046001600160a01b03166001600160a01b03166365ac43416040518163ffffffff1660e01b815260040160206040518083038186803b158015612bf557600080fd5b505afa158015612c09573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c2d9190615712565b612c379047615973565b90506000600d805480602002602001604051908101604052809291908181526020018280548015612c9157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612c73575b505050505090506000600a805480602002602001604051908101604052809291908181526020018280548015612ce657602002820191906000526020600020905b815481526020019060010190808311612cd2575b50505050509050600082516001600160401b03811115612d0857612d08615a91565b604051908082528060200260200182016040528015612d31578160200160208202803683370190505b50600b5460405163ca63279b60e01b815262010000820460ff1615156004820152919250600091600160281b9091046001600160a01b03169063ca63279b90602401600060405180830381600087803b158015612d8d57600080fd5b505af1158015612da1573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612dc99190810190615613565b845190915060005b81811015612eca5760006001600160a01b0316868281518110612df657612df6615a7b565b60200260200101516001600160a01b031614158015612e605750858181518110612e2257612e22615a7b565b60200260200101516001600160a01b03167f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd66001600160a01b031614155b15612ec257828181518110612e7757612e77615a7b565b6020026020010151858281518110612e9157612e91615a7b565b6020026020010151612ea39190615973565b848281518110612eb557612eb5615a7b565b6020026020010181815250505b600101612dd1565b506000612ed787856149f6565b9050612ee38185614bc0565b5050600b805461ff0019166101001790555050505050565b815460009062010000900460ff1680612f645750600b5460ff168015612f6457506001600160401b03821615612f4f57612f36600183615a3d565b60018401546001600160401b0391821691161015612f64565b60018301546001600160401b03808416911610155b9392505050565b60008080808080805b886001600160401b03168111612fb357336000908152600f60209081526040808320848452909152902054612fa99083615973565b9150600101612f74565b506001600160401b038816600090815260116020526040902054612fdc64e8d4a51000836159d8565b612fe691906159b6565b955080601160008a6001600160401b0316815260200190815260200160002060008282546130149190615a26565b9091555050336000908152600e60209081526040808320600301546001600160401b038c1684526012909252909120549094508411613084576001600160401b03881660009081526012602052604090205461307564e8d4a51000866159d8565b61307f91906159b6565b61308b565b64e8d4a510005b6001600160401b0389166000908152601260205260409020549095508411156130cc576001600160401b0388166000908152601260205260408120556130fa565b6001600160401b038816600090815260126020526040812080548692906130f4908490615a26565b90915550505b861561312e57606461310c88866159d8565b61311691906159b6565b336000908152600e6020526040902060030181905593505b8615801561313d575060045415155b156132245760035460045460009164e8d4a510009161316c91600160c01b90046001600160401b0316906159d8565b61317691906159b6565b6003549091506000906001600160401b03600160c01b9091041664e8d4a51000146131ae57816004546131a99190615a26565b6131b1565b60005b905064e8d4a510006131c388836159d8565b6131cd91906159b6565b935064e8d4a510006131df89846159d8565b6131e991906159b6565b94506131f58486615973565b6131ff9087615973565b955061320b8486615973565b6004600082825461321c9190615a26565b909155505050505b6001600360108282829054906101000a90046001600160401b03166132499190615a3d565b92506101000a8154816001600160401b0302191690836001600160401b031602179055505050509250925092565b600081831115613288575080611e88565b5090919050565b60006008546000146133895760035460085460009164e8d4a51000916132c591600160c01b90046001600160401b0316906159d8565b6132cf91906159b6565b6003549091506000906001600160401b03600160c01b9091041664e8d4a510001461330757816008546133029190615a26565b61330a565b60005b9050600064e8d4a5100061331e86856159d8565b61332891906159b6565b9050600064e8d4a5100061333c88856159d8565b61334691906159b6565b90506133528183615973565b945084600860008282546133669190615a26565b9091555050600c54613382906001600160a01b03163387614794565b9450505050505b6040518181523390600080516020615abd8339815191529060200160405180910390a2505050565b6000600d80548060200260200160405190810160405280929190818152602001828054801561340957602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116133eb575b505050505090506000600a80548060200260200160405190810160405280929190818152602001828054801561345e57602002820191906000526020600020905b81548152602001906001019080831161344a575b50505050509050600082516001600160401b0381111561348057613480615a91565b6040519080825280602002602001820160405280156134a9578160200160208202803683370190505b50835190915060005b818110156136c35760006001600160a01b03168582815181106134d7576134d7615a7b565b60200260200101516001600160a01b031614158015613510575083818151811061350357613503615a7b565b6020026020010151600014155b156136bb57600064e8d4a51000600360189054906101000a90046001600160401b03166001600160401b031686848151811061354e5761354e615a7b565b602002602001015161356091906159d8565b61356a91906159b6565b6003549091506000906001600160401b03600160c01b9091041664e8d4a51000146135b957818684815181106135a2576135a2615a7b565b60200260200101516135b49190615a26565b6135bc565b60005b9050600064e8d4a510006135d08a856159d8565b6135da91906159b6565b9050600064e8d4a510006135ee8c856159d8565b6135f891906159b6565b90506136048183615973565b87868151811061361657613616615a7b565b60200260200101818152505086858151811061363457613634615a7b565b602002602001015188868151811061364e5761364e615a7b565b602002602001018181516136629190615a26565b9052508851613698908a908790811061367d5761367d615a7b565b60200260200101513389888151811061246357612463615a7b565b8786815181106136aa576136aa615a7b565b602002602001018181525050505050505b6001016134b2565b5082516136d790600a90602086019061554d565b50336001600160a01b0316600080516020615afd833981519152836040516136ff9190615806565b60405180910390a2505050505050565b6000821561374957606461372384846159d8565b61372d91906159b6565b336000908152600e60205260409020600301819055905061374c565b50805b600d546000906001600160401b0381111561376957613769615a91565b604051908082528060200260200182016040528015613792578160200160208202803683370190505b50604051600081529091503390600080516020615abd8339815191529060200160405180910390a2336001600160a01b0316600080516020615afd833981519152826040516137e19190615806565b60405180910390a25092915050565b60007f00000000000000000000000000000000000000000000000000000000000000001561389e5747821115613824574791505b6000836001600160a01b03168360405160006040518083038185875af1925050503d8060008114613871576040519150601f19603f3d011682016040523d82523d6000602084013e613876565b606091505b505090508061389857604051634d4c5bd160e11b815260040160405180910390fd5b50613aa5565b6040516370a0823160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906370a08231906138ea9030906004016157b1565b60206040518083038186803b15801561390257600080fd5b505afa158015613916573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061393a9190615712565b8211156139e0576040516370a0823160e01b81526001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906370a082319061398d9030906004016157b1565b60206040518083038186803b1580156139a557600080fd5b505afa1580156139b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139dd9190615712565b91505b60405163a9059cbb60e01b81526000906001600160a01b037f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd6169063a9059cbb90613a3190879087906004016157c5565b602060405180830381600087803b158015613a4b57600080fd5b505af1158015613a5f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a8391906156d7565b905080613aa357604051638dc18fdb60e01b815260040160405180910390fd5b505b50919050565b33613ab4611e1c565b6001600160a01b03161461169c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401612832565b600b5460ff16613c0457600254600090613b55907f0000000000000000000000000000000000000000000000000000000000700f8090600160401b90046001600160401b031661598b565b600254909150600090613b71906001600160401b031683615a3d565b6002549091506001600160401b038083169164e8d4a5100091613bbc91600160801b9004167f00000000000000000000000000000000000000000000000000000000006ebe006159f7565b6001600160401b0316613bcf91906159d8565b613bd991906159b6565b600360186101000a8154816001600160401b0302191690836001600160401b03160217905550505050565b6002546001600160401b03828116600160801b909204161415613ccc57600254600090613c3a906001600160401b031642615a3d565b6002549091506001600160401b038083169164e8d4a5100091613c8591600160801b9004167f00000000000000000000000000000000000000000000000000000000006ebe006159f7565b6001600160401b0316613c9891906159d8565b613ca291906159b6565b600360186101000a8154816001600160401b0302191690836001600160401b031602179055505050565b50600380546001600160c01b0316630e8d4a5160cc1b179055565b613cef611724565b1561169c5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401612832565b81811115613d5057604051630d2eb29360e41b815260040160405180910390fd5b6000613d5a612861565b336000908152600e602052604081206001810180546001600160401b0319166001600160401b03851617905560020180549293508592909190613d9e908490615973565b9091555050336000908152600e602052604081206003018054849290613dc5908490615973565b9091555060009050613df77f00000000000000000000000000000000000000000000000000000000006ebe00836159f7565b600254613e0d91906001600160401b031661598b565b6001600160401b0316427f00000000000000000000000000000000000000000000000000000000006ebe006001600160401b0316613e4b9190615973565b613e559190615a26565b613e6464e8d4a51000856159d8565b613e6e91906159b6565b336000908152600f602090815260408083206001600160401b0387168452825280832084905560119091528120549192505b836001600160401b03168111613edf57336000908152600f60209081526040808320848452909152902054613ed59083615973565b9150600101613ea0565b506001600160401b0383166000818152601160209081526040808320859055338352600e825280832060030154938352601290915281208054909190613f26908490615973565b9091555050600254613f4a90600190600160801b90046001600160401b0316615a3d565b6001600160401b0316836001600160401b03161415613fb157600380546001600160401b03600160401b808304821660010190911602600160401b600160801b0319909116179055336000908152600e60205260409020805462ff00001916620100001790555b6001600160401b03831660008181526010602052604090208054600101905515801590613ff957506001600160401b0360001984011660009081526010602052604090205415155b15614023576000198381016001600160401b03166000908152601060205260409020805490910190555b84600660008282546140359190615973565b92505081905550836005600082825461404e9190615973565b909155507f0000000000000000000000000000000000000000000000000000000000000000905061415057600b546040516323b872dd60e01b81523360048201526001600160a01b03600160281b90920482166024820152604481018790526000917f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd616906323b872dd90606401602060405180830381600087803b1580156140f657600080fd5b505af115801561410a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061412e91906156d7565b90508061414e57604051638dc18fdb60e01b815260040160405180910390fd5b505b600b54604051635cdc612360e11b8152600160281b9091046001600160a01b03169063b9b8c2469034906141aa907f0000000000000000000000001bfd67037b42cf73acf2047067bd4f2c47d9bfd6908b906004016157c5565b6000604051808303818588803b1580156141c357600080fd5b505af11580156141d7573d6000803e3d6000fd5b5050505050505050505050565b6141ec611724565b61169c5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401612832565b6142376141e4565b6000805460ff60a01b191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b60405161171a91906157b1565b61427c613aab565b61169c60006149a6565b61428e613ce7565b6000805460ff60a01b1916600160a01b1790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586142673390565b6142d1612861565b6001600160401b0316156142f8576040516359d9d9a760e11b815260040160405180910390fd5b336000818152600e602052604090205460ff6101008204169163010000009091046001600160a01b031614801561432d575080155b1561434b5760405163a510df3760e01b815260040160405180910390fd5b600380546001919060009061436a9084906001600160401b031661598b565b82546101009290920a6001600160401b038181021990931691831602179091556003547f00000000000000000000000000000000000000000000000000000000000007d082169116111590506143d35760405163e7b9e0e760e01b815260040160405180910390fd5b7f00000000000000000000000000000000000000000000000000000000000000018015614427575081158061442757507f0000000000000000000000000000000000000000000000000000000011e1a30082115b1561444557604051637292a14360e11b815260040160405180910390fd5b60007f0000000000000000000000000000000000000000000000000000000000000001614492577f0000000000000000000000000000000000000000000000000000000000000000614494565b825b90507f0000000000000000000000000000000000000000000000000000000000000000156144e1578034146144dc5760405163e1f0844960e01b815260040160405180910390fd5b614500565b34156145005760405163e1f0844960e01b815260040160405180910390fd5b600b546040516365237abb60e01b815260048101839052600091600160281b90046001600160a01b0316906365237abb9060240160206040518083038186803b15801561454c57600080fd5b505afa158015614560573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145849190615712565b9050806145a457604051630d2eb29360e41b815260040160405180910390fd5b60408051610120810182526000808252602080830182815283850183815233606086018181526080870186815260a0880187815260c0890188815260e08a01898152610100808c018f8152968b52600e9099529a90982089518154975196519451935161ffff1990981690151561ff001916179515159097029490941762010000600160b81b03191662010000921515929092026301000000600160b81b0319169190911763010000006001600160a01b039092169190910217600160b81b600160f81b031916600160b81b6001600160401b039485160217845590516001840180546001600160401b0319169190931617909155915160028201559251600384015551600490920191909155836146f957601380546001810182556000919091527f66de8ffda797e3de9c05e8fc57b3bf0ec28a930d40b0d285d93c06501cf6a0900180546001600160a01b031916331790555b604080518481526020810184905233917f53d337ea1dc431137693f9a003695ac0fde36068f5fc73370015168b9e64cf9e910160405180910390a261473f868484613d2f565b505050505050565b805160009060015b8181101561478a5783818151811061476957614769615a7b565b6020026020010151600014614782575060019392505050565b60010161474f565b5060009392505050565b6040516370a0823160e01b81526000906001600160a01b038516906370a08231906147c39030906004016157b1565b60206040518083038186803b1580156147db57600080fd5b505afa92505050801561480b575060408051601f3d908101601f1916820190925261480891810190615712565b60015b614878573d808015614839576040519150601f19603f3d011682016040523d82523d6000602084013e61483e565b606091505b5060009250846001600160a01b0316600080516020615add8339815191528260405161486a9190615819565b60405180910390a250614886565b80831115614884578092505b505b811561499f5760405163a9059cbb60e01b81526001600160a01b0385169063a9059cbb906148ba90869086906004016157c5565b602060405180830381600087803b1580156148d457600080fd5b505af1925050508015614904575060408051601f3d908101601f19168201909252614901918101906156d7565b60015b61497f573d808015614932576040519150601f19603f3d011682016040523d82523d6000602084013e614937565b606091505b50846001600160a01b03167ffdba62ff5ed53473134bad9bdefe10d1bbc01c3cb36e9660032a629b6c926a61826040516149719190615819565b60405180910390a25061499f565b8061499d57604051638dc18fdb60e01b815260040160405180910390fd5b505b5092915050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60055460009081908410614a1857600554614a119085615a26565b9050614a39565b600554614a268560646159d8565b614a3091906159b6565b60095560058490555b600c546001600160a01b03168015614b2c576040516370a0823160e01b81526001600160a01b038216906370a0823190614a779030906004016157b1565b60206040518083038186803b158015614a8f57600080fd5b505afa925050508015614abf575060408051601f3d908101601f19168201909252614abc91810190615712565b60015b614b28573d808015614aed576040519150601f19603f3d011682016040523d82523d6000602084013e614af2565b606091505b50816001600160a01b0316600080516020615add83398151915282604051614b1a9190615819565b60405180910390a250614b2c565b6008555b600b54610100900460ff16614bb85760038054600160801b6001600160401b03600160401b83041602600160801b600160c01b031990911617905560065460055460085460095460405133947f5a8920b0ea1c4677685868cec72bce61e9a586ef5f317707ecc34ae94018567594614baf948c94929391928a928d929190615896565b60405180910390a25b509392505050565b6000600d805480602002602001604051908101604052809291908181526020018280548015614c1857602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311614bfa575b5050505050905060006007805480602002602001604051908101604052809291908181526020018280548015614c6d57602002820191906000526020600020905b815481526020019060010190808311614c59575b505050505090506000600a805480602002602001604051908101604052809291908181526020018280548015614cc257602002820191906000526020600020905b815481526020019060010190808311614cae575b50505050509050600b60019054906101000a900460ff161561522057600b546301000000900460ff1615614cfc575060048490558261552a565b600082600081518110614d1157614d11615a7b565b6020026020010151600454614d269190615973565b9050808610614e27576000614d3b8288615a26565b600354909150600090600160401b90046001600160401b03161580614d705750600354600160801b90046001600160401b0316155b15614d95578190508160046000828254614d8a9190615973565b90915550614df49050565b6064614dca6001600160401b037f000000000000000000000000000000000000000000000000000000000000000a16846159d8565b614dd491906159b6565b905060008211614de657600454614df0565b614df08189615a26565b6004555b8085600081518110614e0857614e08615a7b565b60200260200101818151614e1c9190615973565b905250614edb915050565b600354600090600160401b90046001600160401b03161580614e595750600354600160801b90046001600160401b0316155b15614e6a5750600486905585614eb9565b6064614e9f6001600160401b037f000000000000000000000000000000000000000000000000000000000000000a16896159d8565b614ea991906159b6565b9050614eb58188615a26565b6004555b8084600081518110614ecd57614ecd615a7b565b602002602001018181525050505b835160005b8181101561521857838181518110614efa57614efa615a7b565b6020026020010151878281518110614f1457614f14615a7b565b6020026020010151106150b5576000848281518110614f3557614f35615a7b565b6020026020010151888381518110614f4f57614f4f615a7b565b6020026020010151614f619190615a26565b600354909150600090600160401b90046001600160401b03161580614f965750600354600160801b90046001600160401b0316155b15614fcd5781905081868481518110614fb157614fb1615a7b565b60200260200101818151614fc59190615973565b905250615079565b60646150026001600160401b037f000000000000000000000000000000000000000000000000000000000000000a16846159d8565b61500c91906159b6565b9050600082116150355785838151811061502857615028615a7b565b602002602001015161505a565b8089848151811061504857615048615a7b565b602002602001015161505a9190615a26565b86848151811061506c5761506c615a7b565b6020026020010181815250505b8087615086856001615973565b8151811061509657615096615a7b565b602002602001018181516150aa9190615973565b905250615210915050565b600354600090600160401b90046001600160401b031615806150e75750600354600160801b90046001600160401b0316155b15615145578782815181106150fe576150fe615a7b565b6020026020010151905087828151811061511a5761511a615a7b565b602002602001015185838151811061513457615134615a7b565b6020026020010181815250506151e5565b60647f000000000000000000000000000000000000000000000000000000000000000a6001600160401b031689848151811061518357615183615a7b565b602002602001015161519591906159d8565b61519f91906159b6565b9050808883815181106151b4576151b4615a7b565b60200260200101516151c69190615a26565b8583815181106151d8576151d8615a7b565b6020026020010181815250505b80866151f2846001615973565b8151811061520257615202615a7b565b602002602001018181525050505b600101614ee0565b50505061552a565b8251600354600160401b90046001600160401b03166152f157858360008151811061524d5761524d615a7b565b6020908102919091010152600486905560005b818110156152eb5785818151811061527a5761527a615a7b565b602002602001015183828151811061529457615294615a7b565b6020026020010181815250508581815181106152b2576152b2615a7b565b6020026020010151848260016152c89190615973565b815181106152d8576152d8615a7b565b6020908102919091010152600101615260565b506154f1565b6001600160401b037f000000000000000000000000000000000000000000000000000000000000000a16156154a05760646153556001600160401b037f000000000000000000000000000000000000000000000000000000000000000a16886159d8565b61535f91906159b6565b8360008151811061537257615372615a7b565b6020026020010181815250508260008151811061539157615391615a7b565b6020026020010151866153a49190615a26565b60045560005b818110156152eb5760647f000000000000000000000000000000000000000000000000000000000000000a6001600160401b03168783815181106153f0576153f0615a7b565b602002602001015161540291906159d8565b61540c91906159b6565b84615418836001615973565b8151811061542857615428615a7b565b60209081029190910101528361543f826001615973565b8151811061544f5761544f615a7b565b602002602001015186828151811061546957615469615a7b565b602002602001015161547b9190615a26565b83828151811061548d5761548d615a7b565b60209081029190910101526001016153aa565b600486905560005b818110156154ef578581815181106154c2576154c2615a7b565b60200260200101518382815181106154dc576154dc615a7b565b60209081029190910101526001016154a8565b505b7f4d58284f2a68a6d9baded7cdff0efbca82dbc7d35a3571c1d8bb6d06eb252827836040516155209190615806565b60405180910390a1505b805161553d90600a90602084019061554d565b50815161473f9060079060208501905b828054828255906000526020600020908101928215615588579160200282015b8281111561558857825182559160200191906001019061556d565b50615594929150615598565b5090565b5b808211156155945760008155600101615599565b6000602082840312156155bf57600080fd5b8135612f6481615aa7565b6000602082840312156155dc57600080fd5b8151612f6481615aa7565b600080604083850312156155fa57600080fd5b823561560581615aa7565b946020939093013593505050565b6000602080838503121561562657600080fd5b82516001600160401b038082111561563d57600080fd5b818501915085601f83011261565157600080fd5b81518181111561566357615663615a91565b8060051b604051601f19603f8301168101818110858211171561568857615688615a91565b604052828152858101935084860182860187018a10156156a757600080fd5b600095505b838610156156ca5780518552600195909501949386019386016156ac565b5098975050505050505050565b6000602082840312156156e957600080fd5b81518015158114612f6457600080fd5b60006020828403121561570b57600080fd5b5035919050565b60006020828403121561572457600080fd5b5051919050565b6000806040838503121561573e57600080fd5b50508035926020909101359150565b60006020828403121561575f57600080fd5b81356001600160401b0381168114612f6457600080fd5b600081518084526020808501945080840160005b838110156157a65781518752958201959082019060010161578a565b509495945050505050565b6001600160a01b0391909116815260200190565b6001600160a01b03929092168252602082015260400190565b6001600160a01b03949094168452602084019290925260408301521515606082015260800190565b602081526000612f646020830184615776565b600060208083528351808285015260005b818110156158465785810183015185820160400152820161582a565b81811115615858576000604083870101525b50601f01601f1916929092016040019392505050565b83815282602082015260606040820152600061588d6060830184615776565b95945050505050565b87815286602082015285604082015284606082015260e0608082015260006158c160e0830186615776565b60a08301949094525060c0015295945050505050565b600060e082018983526020898185015288604085015287606085015286608085015260e060a0850152818654808452610100860191508760005282600020935060005b818110156159365784548352600194850194928401920161591a565b50508093505050508260c083015298975050505050505050565b6001600160401b0393841681529183166020830152909116604082015260600190565b6000821982111561598657615986615a65565b500190565b60006001600160401b038281168482168083038211156159ad576159ad615a65565b01949350505050565b6000826159d357634e487b7160e01b600052601260045260246000fd5b500490565b60008160001904831182151516156159f2576159f2615a65565b500290565b60006001600160401b0382811684821681151582840482111615615a1d57615a1d615a65565b02949350505050565b600082821015615a3857615a38615a65565b500390565b60006001600160401b0383811690831681811015615a5d57615a5d615a65565b039392505050565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461117f57600080fdfe977e26f874eac308da255c037e203c4a501cf2cb08a8abf87e011d750f657ccf7a30d31a8bd18ad5251980ab4105d3f180c3cc00767d79b1393c3e4ca392638e38a6a91aca8b2590b32c77b7f06e41eafed98470306bce6fe498c5bfd7346926a264697066735822122040546c36ab4f6c104763fd2268017fb3bc62e5091d952899d5d5e1dbfa8287b964736f6c63430008070033
Loading...
Loading
Loading...
Loading
Multichain Portfolio | 30 Chains
Chain | Token | Portfolio % | Price | Amount | Value |
---|
[ Download: CSV Export ]
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.