Unnamed: 0
int64
0
7.36k
comments
stringlengths
3
35.2k
code_string
stringlengths
1
527k
code
stringlengths
1
527k
__index_level_0__
int64
0
88.6k
532
// Function which take ETH, add liquidity with provider and deposit given LP's _pid: pool ID where we want deposit _amountAMin: bounds the extent to which the B/A price can go up before the transaction reverts. _amountBMin: bounds the extent to which the A/B price can go up before the transaction reverts. _minAmountOutA: the minimum amount of output A tokens that must be received _minAmountOutB: the minimum amount of output B tokens that must be received /
function speedStake( uint256 _pid, uint256 _amountAMin, uint256 _amountBMin, uint256 _minAmountOutA, uint256 _minAmountOutB, uint256 _deadline
function speedStake( uint256 _pid, uint256 _amountAMin, uint256 _amountBMin, uint256 _minAmountOutA, uint256 _minAmountOutB, uint256 _deadline
43,709
4
// Claim tokens
(bool success,) = address(claimContract).call(_data); require(success, "Claim failed"); uint256 finalBalance = IERC20(_token).balanceOf(address(this)); require(finalBalance > initialBalance, "Claim did not yield any tokens");
(bool success,) = address(claimContract).call(_data); require(success, "Claim failed"); uint256 finalBalance = IERC20(_token).balanceOf(address(this)); require(finalBalance > initialBalance, "Claim did not yield any tokens");
27,993
11
// Only allows the `owner` to execute the function.
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
modifier onlyOwner() { require(msg.sender == owner, "Ownable: caller is not the owner"); _; }
4,985
35
// Triggered when tokens are transferred. MUST trigger when tokens are transferred, including zero value transfers. /
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
6,613
24
// Internal function to get the array of approved tokens from TrustStorage.return approvedTokens The array of approved tokens. /
function _getApprovedTokens() internal view returns (IERC20[] storage approvedTokens) { approvedTokens = _trustStore().approvedTokens; }
function _getApprovedTokens() internal view returns (IERC20[] storage approvedTokens) { approvedTokens = _trustStore().approvedTokens; }
18,695
119
// ============ Internal Functions ============ //Transfers tokens from an address (that has set allowance on the module). _tokenThe address of the ERC20 token_from The address to transfer from_to The address to transfer to_quantity The number of tokens to transfer /
function transferFrom(IERC20 _token, address _from, address _to, uint256 _quantity) internal { ExplicitERC20.transferFrom(_token, _from, _to, _quantity); }
function transferFrom(IERC20 _token, address _from, address _to, uint256 _quantity) internal { ExplicitERC20.transferFrom(_token, _from, _to, _quantity); }
47,696
18
// Give a ruling. UNTRUSTED._disputeID ID of the dispute to rule._ruling Ruling given by the arbitrator. Note that 0 means "Not able/wanting to make a decision". /
function _giveRuling(uint _disputeID, uint _ruling) internal { DisputeStruct storage dispute = disputes[_disputeID]; require(_ruling <= dispute.choices, "Invalid ruling."); require(dispute.status != DisputeStatus.Solved, "The dispute must not be solved already."); dispute.ruling = _ruling; dispute.status = DisputeStatus.Solved; msg.sender.send(dispute.fee); // Avoid blocking. dispute.arbitrated.rule(_disputeID,_ruling); }
function _giveRuling(uint _disputeID, uint _ruling) internal { DisputeStruct storage dispute = disputes[_disputeID]; require(_ruling <= dispute.choices, "Invalid ruling."); require(dispute.status != DisputeStatus.Solved, "The dispute must not be solved already."); dispute.ruling = _ruling; dispute.status = DisputeStatus.Solved; msg.sender.send(dispute.fee); // Avoid blocking. dispute.arbitrated.rule(_disputeID,_ruling); }
23,646
3
// Emitted when contract is upgraded by system administrator. newContract address of the new version of the contract. /
event ContractUpgrade(address newContract); bool public paused = true; bool public upgraded = false; address public newContractAddress;
event ContractUpgrade(address newContract); bool public paused = true; bool public upgraded = false; address public newContractAddress;
11,298
4
// ``` /
abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
abstract contract ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
33,638
9
// Contract-level metadata for OpenSea. / Update for collection-specific metadata.
function contractURI() public pure returns (string memory) { return "ipfs://QmYjmj6AgVxGvWUck4ufmVCt8FSKPcyPRydAkqmZZA21T3/asteroids.json"; // Contract-level metadata }
function contractURI() public pure returns (string memory) { return "ipfs://QmYjmj6AgVxGvWUck4ufmVCt8FSKPcyPRydAkqmZZA21T3/asteroids.json"; // Contract-level metadata }
50,355
3
// Invalid redemption status /
error InvalidRedemptionStatus();
error InvalidRedemptionStatus();
16,560
20
// store the failed message into the nonblockingLzApp
_storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason);
_storeFailedMessage(srcChainId, srcAddress, nonce, payload, reason);
17,087
26
// Return Oasis Address /
function getOasisAddr() internal pure returns (address) { return 0x794e6e91555438aFc3ccF1c5076A74F42133d08D; }
function getOasisAddr() internal pure returns (address) { return 0x794e6e91555438aFc3ccF1c5076A74F42133d08D; }
33,647
329
// Update endpoint mapping
serviceProviderEndpointToId[keccak256(bytes(_endpoint))] = newServiceProviderID;
serviceProviderEndpointToId[keccak256(bytes(_endpoint))] = newServiceProviderID;
7,493
0
// A mapping is a key-value store that lets us keep data in our contract. Here, the key is the token ID, and the value is the power level for that NFT.
mapping(uint256 => uint256) public powerLevel; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps
mapping(uint256 => uint256) public powerLevel; constructor( string memory _name, string memory _symbol, address _royaltyRecipient, uint128 _royaltyBps
7,288
35
// Checks if the given address is used for depositing ETH or not./Is used while depositing to send the correct ETH amount to the deposit contract.//Note that 0x0 is always registered for deposting ETH when the exchange is created!/This function allows additional addresses to be used for depositing ETH, the deposit/contract can implement different behaviour based on the address value.//addr The address to check/ return True if the address is used for depositing ETH, else false.
function isETH(address addr) external view returns (bool);
function isETH(address addr) external view returns (bool);
43,958
0
// KIP-17 Non-Fungible Token Standard, full implementation interface /
contract IKIP17Full is IKIP17, IKIP17Enumerable, IKIP17Metadata { // solhint-disable-previous-line no-empty-blocks }
contract IKIP17Full is IKIP17, IKIP17Enumerable, IKIP17Metadata { // solhint-disable-previous-line no-empty-blocks }
15,494
34
// Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist IMPORTANT: Any overrides to this function that add ownership of tokens not tracked by the
* core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; }
* core ERC721 logic MUST be matched with the use of {_increaseBalance} to keep balances * consistent with ownership. The invariant to preserve is that for any address `a` the value returned by * `balanceOf(a)` must be equal to the number of tokens such that `_ownerOf(tokenId)` is `a`. */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; }
373
11
// Add mint receiverreceiver is account to receive mint rewarddeciPercents deci-percent (1000 = 100%)
function addMintReceiver( address receiver, uint16 deciPercents
function addMintReceiver( address receiver, uint16 deciPercents
28,411
80
// Get the data
IBasketManager basketManager = IBasketManager( IMasset(_mAsset).getBasketManager() ); Basket memory basket = basketManager.getBasket(); uint256 totalSupply = IMasset(_mAsset).totalSupply();
IBasketManager basketManager = IBasketManager( IMasset(_mAsset).getBasketManager() ); Basket memory basket = basketManager.getBasket(); uint256 totalSupply = IMasset(_mAsset).totalSupply();
29,879
99
// Collects tokens owed to a position/Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity./ Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or/ amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the/ actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity./recipient The address which should receive the fees collected/tickLower The lower tick of the position for which to collect fees/tickUpper The upper tick of the
function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1);
function collect( address recipient, int24 tickLower, int24 tickUpper, uint128 amount0Requested, uint128 amount1Requested ) external returns (uint128 amount0, uint128 amount1);
10,277
111
// The MAR TOKEN!
MARToken public mar;
MARToken public mar;
30,739
27
// Fail if redeem not allowed // Verify market's block number equals current block number // Fail gracefully if protocol has insufficient cash // EFFECTS & INTERACTIONS (No safe failures beyond this point)/We invoke doTransferOut for the redeemer and the redeemAmount. Note: The cToken must handle variations between ERC-20 and ETH underlying. On success, the cToken has redeemAmount less of cash. doTransferOut reverts if anything goes wrong, since we can't be sure if side effects occurred.accountant supplies market and receives cTokens at current exchange Rate /
doTransferOut(redeemer, redeemAmount);
doTransferOut(redeemer, redeemAmount);
21,204
171
// Check for profits and losses
uint256 total = estimatedTotalAssets();
uint256 total = estimatedTotalAssets();
3,527
1
// Request a random number._block Block linked to the request. /
function requestRN(uint _block) public payable { contribute(_block); }
function requestRN(uint _block) public payable { contribute(_block); }
2,773
5
// Assumes SpendAssetsHandleType.Transfer unless otherwise specified
function __getSpendAssetsHandleTypeForSelector(bytes4 _selector) private pure returns (IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_)
function __getSpendAssetsHandleTypeForSelector(bytes4 _selector) private pure returns (IIntegrationManager.SpendAssetsHandleType spendAssetsHandleType_)
44,002
60
// 创建待签名的交易/This function can only be called by owner/to 目标地址/value eth数量/data 调用目标方法的msg.data/ return txId 交易号
function execute(address to, uint value, bytes memory data) external returns (uint txId);
function execute(address to, uint value, bytes memory data) external returns (uint txId);
78,619
81
// Cancel an operation. Requirements: - the caller must have the 'proposer' role. /
function cancel(bytes32 id) public virtual onlyRole(PROPOSER_ROLE) { require(isOperationPending(id), "TimelockController: operation cannot be cancelled"); delete _timestamps[id]; emit Cancelled(id); }
function cancel(bytes32 id) public virtual onlyRole(PROPOSER_ROLE) { require(isOperationPending(id), "TimelockController: operation cannot be cancelled"); delete _timestamps[id]; emit Cancelled(id); }
35,102
32
// Set the sales max purchase limit /
function setSalesMaxPurchase(uint256 maxPurchase) public onlyOwner { SALES_MAX_PURCHASE = maxPurchase; }
function setSalesMaxPurchase(uint256 maxPurchase) public onlyOwner { SALES_MAX_PURCHASE = maxPurchase; }
53,904
84
// This is an alternative to {approve} that can be used as a mitigation forproblems described in {IERC20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. /
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { _approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue)); return true; }
772
9
// function that checks whether the contract is paused
function onlyUnpaused() internal view { require(!paused(), Errors.CP_PAUSED_CONTRACT); }
function onlyUnpaused() internal view { require(!paused(), Errors.CP_PAUSED_CONTRACT); }
6,651
16
// Event to notify listeners about pause.unpauseReasonstring Reason the token was unpaused for./
event Unpause(string unpauseReason); bool public isPaused; string public pauseNotice;
event Unpause(string unpauseReason); bool public isPaused; string public pauseNotice;
9,284
35
// ---------------------------/ ----- LongTerm Orders -----/ ---------------------------
uint112 internal constant SELL_RATE_ADDITIONAL_PRECISION = 1000000; uint256 internal constant Q112 = 2**112; uint256 internal constant orderTimeInterval = 3600; // sync with FraxswapPair.sol
uint112 internal constant SELL_RATE_ADDITIONAL_PRECISION = 1000000; uint256 internal constant Q112 = 2**112; uint256 internal constant orderTimeInterval = 3600; // sync with FraxswapPair.sol
26,477
69
// Fallback function must be declared as external.
fallback() external payable { emit Log("receive", gasleft()); }
fallback() external payable { emit Log("receive", gasleft()); }
9,078
240
// Calculates the largest possible `amount0` and `amount1` such that/ they're in the same proportion as total amounts, but not greater than/ `amount0Desired` and `amount1Desired` respectively.
function _calcSharesAndAmounts(uint256 amount0Desired, uint256 amount1Desired) internal view returns ( uint256 shares, uint256 amount0, uint256 amount1 )
function _calcSharesAndAmounts(uint256 amount0Desired, uint256 amount1Desired) internal view returns ( uint256 shares, uint256 amount0, uint256 amount1 )
2,082
70
// Decode multi-asset data from the format described in the AssetProxy contract specification./assetData AssetProxy-compliant data describing a multi-asset basket./ return The Multi-Asset AssetProxy identifier, an array of the amounts/ of the assets to be traded, and an array of the/ AssetProxy-compliant data describing each asset to be traded.Each/ element of the arrays corresponds to the same-indexed element of the other array.
function decodeMultiAssetData(bytes memory assetData) public pure returns ( bytes4 assetProxyId, uint256[] memory amounts, bytes[] memory nestedAssetData )
function decodeMultiAssetData(bytes memory assetData) public pure returns ( bytes4 assetProxyId, uint256[] memory amounts, bytes[] memory nestedAssetData )
551
188
// ===== ERC20Upgradeable Overrides =====/
* @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public override whenNotPaused returns (bool) { /// The _balances mapping represents the underlying ibBTC shares ("non-rebased balances") /// Some naming confusion emerges due to maintaining original ERC20 var names if (amount == 0) { return true; } _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
* @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}; * * Requirements: * - `sender` and `recipient` cannot be the zero address. * - `sender` must have a balance of at least `amount`. * - the caller must have allowance for ``sender``'s tokens of at least * `amount`. */ function transferFrom(address sender, address recipient, uint256 amount) public override whenNotPaused returns (bool) { /// The _balances mapping represents the underlying ibBTC shares ("non-rebased balances") /// Some naming confusion emerges due to maintaining original ERC20 var names if (amount == 0) { return true; } _transfer(sender, recipient, amount); _approve(sender, _msgSender(), _allowances[sender][_msgSender()].sub(amount, "ERC20: transfer amount exceeds allowance")); return true; }
57,683
166
// Get the spread /
function getSpread(uint16 index) private pure returns (string memory)
function getSpread(uint16 index) private pure returns (string memory)
63,099
0
// CONSTANTS
mapping(address => bool) public isMaster;
mapping(address => bool) public isMaster;
17,271
56
// Internal function to burn a specific token. Reverts if the token does not exist.tokenId uint256 ID of the token being burned/
function _burn(uint256 tokenId) internal { _burn(ownerOf(tokenId), tokenId); }
function _burn(uint256 tokenId) internal { _burn(ownerOf(tokenId), tokenId); }
19,954
30
// Unpause registry. Requirements:- The contract must not be unpaused.- The function must called by the owner. /
function unpauseRegistry() public onlyOwner { _unpause(); emit PauseRegistry(msg.sender, false); }
function unpauseRegistry() public onlyOwner { _unpause(); emit PauseRegistry(msg.sender, false); }
22,443
26
// Allows allowed third party to transfer tokens from one address to another. Returns success./from Address from where tokens are withdrawn./to Address to where tokens are sent./value Number of tokens to transfer.
function transferFrom(address from, address to, uint256 value) returns (bool)
function transferFrom(address from, address to, uint256 value) returns (bool)
22,486
24
// Basic ERC23 token, backward compatible with ERC20 transfer function.Based in part on code by open-zeppelin: https:github.com/OpenZeppelin/zeppelin-solidity.git
contract ERC23BasicToken { using SafeMath for uint256; uint256 public totalSupply; mapping(address => uint256) balances; event Transfer(address indexed from, address indexed to, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value, bytes data); function tokenFallback(address _from, uint256 _value, bytes _data) external { throw; } function transfer(address _to, uint256 _value, bytes _data) returns (bool success) { //Standard ERC23 transfer function if(isContract(_to)) { transferToContract(_to, _value, _data); } else { transferToAddress(_to, _value, _data); } return true; } function transfer(address _to, uint256 _value) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if(isContract(_to)) { transferToContract(_to, _value, empty); } else { transferToAddress(_to, _value, empty); } } function transferToAddress(address _to, uint256 _value, bytes _data) internal { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); Transfer(msg.sender, _to, _value, _data); } function transferToContract(address _to, uint256 _value, bytes _data) internal { balances[msg.sender] = balances[msg.sender].sub( _value); balances[_to] = balances[_to].add( _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value); Transfer(msg.sender, _to, _value, _data); } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) returns (bool is_contract) { uint256 length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } if(length>0) { return true; } else { return false; } } }
contract ERC23BasicToken { using SafeMath for uint256; uint256 public totalSupply; mapping(address => uint256) balances; event Transfer(address indexed from, address indexed to, uint256 value); event Transfer(address indexed from, address indexed to, uint256 value, bytes data); function tokenFallback(address _from, uint256 _value, bytes _data) external { throw; } function transfer(address _to, uint256 _value, bytes _data) returns (bool success) { //Standard ERC23 transfer function if(isContract(_to)) { transferToContract(_to, _value, _data); } else { transferToAddress(_to, _value, _data); } return true; } function transfer(address _to, uint256 _value) { //standard function transfer similar to ERC20 transfer with no _data //added due to backwards compatibility reasons bytes memory empty; if(isContract(_to)) { transferToContract(_to, _value, empty); } else { transferToAddress(_to, _value, empty); } } function transferToAddress(address _to, uint256 _value, bytes _data) internal { balances[msg.sender] = balances[msg.sender].sub(_value); balances[_to] = balances[_to].add(_value); Transfer(msg.sender, _to, _value); Transfer(msg.sender, _to, _value, _data); } function transferToContract(address _to, uint256 _value, bytes _data) internal { balances[msg.sender] = balances[msg.sender].sub( _value); balances[_to] = balances[_to].add( _value); ContractReceiver receiver = ContractReceiver(_to); receiver.tokenFallback(msg.sender, _value, _data); Transfer(msg.sender, _to, _value); Transfer(msg.sender, _to, _value, _data); } function balanceOf(address _owner) constant returns (uint256 balance) { return balances[_owner]; } //assemble the given address bytecode. If bytecode exists then the _addr is a contract. function isContract(address _addr) returns (bool is_contract) { uint256 length; assembly { //retrieve the size of the code on target address, this needs assembly length := extcodesize(_addr) } if(length>0) { return true; } else { return false; } } }
22,145
135
// Sets the buy tax, out of 100000. Only callable by owner. Max of 20000./amount the tax out of 100000.
function setBuyInfl(uint32 amount) external onlyOwner { require(amount <= 20000, "SSH: Max 20%."); buyInfl = amount; }
function setBuyInfl(uint32 amount) external onlyOwner { require(amount <= 20000, "SSH: Max 20%."); buyInfl = amount; }
23,007
460
// Transfer payout
if (payout > 0) { IERC20(_derivatives[i].token).safeTransfer(_tokenOwner, payout); }
if (payout > 0) { IERC20(_derivatives[i].token).safeTransfer(_tokenOwner, payout); }
29,532
6
// Sell some ETH and get refund
function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline) external payable returns (uint256); function ethToTokenTransferOutput( uint256 tokens_bought, uint256 deadline, address recipient ) external payable returns (uint256);
function ethToTokenSwapOutput(uint256 tokens_bought, uint256 deadline) external payable returns (uint256); function ethToTokenTransferOutput( uint256 tokens_bought, uint256 deadline, address recipient ) external payable returns (uint256);
28,450
91
// Set a promo configuration/The Owner can change the promo pack contents/_newPromoPack Promo pack configuration/_numberOfPacks Max number of promo packs to be given before using the default config
function changePromoPack(Pack memory _newPromoPack, uint _numberOfPacks) public onlyOwner { require(_newPromoPack.tokens.length == _newPromoPack.tokenAmounts.length, "Mismatch with Tokens & Amounts"); for (uint256 i = 0; i < _newPromoPack.tokens.length; i++) { require(_newPromoPack.tokenAmounts[i] > 0, "Amounts must be non-zero"); } promoPack = _newPromoPack; promoAvailable = _numberOfPacks; }
function changePromoPack(Pack memory _newPromoPack, uint _numberOfPacks) public onlyOwner { require(_newPromoPack.tokens.length == _newPromoPack.tokenAmounts.length, "Mismatch with Tokens & Amounts"); for (uint256 i = 0; i < _newPromoPack.tokens.length; i++) { require(_newPromoPack.tokenAmounts[i] > 0, "Amounts must be non-zero"); } promoPack = _newPromoPack; promoAvailable = _numberOfPacks; }
37,460
8
// Mapping of YPool token to its max amount in a single swap
mapping (address => uint256) public maxYPoolTokenSwapAmount;
mapping (address => uint256) public maxYPoolTokenSwapAmount;
35,451
18
// ------------------------------------------------------------------------ Get the token balance for account tokenOwner ------------------------------------------------------------------------
function balanceOf(address tokenOwner) public override view returns (uint balance) { return balances[tokenOwner]; }
function balanceOf(address tokenOwner) public override view returns (uint balance) { return balances[tokenOwner]; }
1,485
290
// Update leaderboard.
function updateLeaderboard(address _addressToUpdate) whenNotPaused private returns (bool isChanged)
function updateLeaderboard(address _addressToUpdate) whenNotPaused private returns (bool isChanged)
36,357
20
// View function to see pending Ayield on frontend.
function pendingAyield(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accAyieldPerShare = pool.accAyieldPerShare; if (block.timestamp > pool.lastRewardTime && pool.lpSupply != 0 && totalAllocPoint > 0) { uint256 multiplier = getMultiplier(pool.lastRewardTime, block.timestamp); uint256 ayieldReward = multiplier.mul(ayieldPerSecond).mul(pool.allocPoint).div(totalAllocPoint); accAyieldPerShare = accAyieldPerShare.add(ayieldReward.mul(1e18).div(pool.lpSupply)); } return user.amount.mul(accAyieldPerShare).div(1e18).sub(user.rewardDebt); }
function pendingAyield(uint256 _pid, address _user) external view returns (uint256) { PoolInfo storage pool = poolInfo[_pid]; UserInfo storage user = userInfo[_pid][_user]; uint256 accAyieldPerShare = pool.accAyieldPerShare; if (block.timestamp > pool.lastRewardTime && pool.lpSupply != 0 && totalAllocPoint > 0) { uint256 multiplier = getMultiplier(pool.lastRewardTime, block.timestamp); uint256 ayieldReward = multiplier.mul(ayieldPerSecond).mul(pool.allocPoint).div(totalAllocPoint); accAyieldPerShare = accAyieldPerShare.add(ayieldReward.mul(1e18).div(pool.lpSupply)); } return user.amount.mul(accAyieldPerShare).div(1e18).sub(user.rewardDebt); }
4,919
10
// Initialize the money market controller_ The address of the Controller name_ Name of this MCD token symbol_ Symbol of this MCD token decimals_ Decimal precision of this token /
function initialize(KineControllerInterface controller_, string memory name_, string memory symbol_, uint8 decimals_,
function initialize(KineControllerInterface controller_, string memory name_, string memory symbol_, uint8 decimals_,
7,971
205
// Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,given current on-chain conditions. - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdrawcall in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw ifcalledin the same transaction.- MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as thoughthe withdrawal would be accepted, regardless if the user has enough shares, etc.- MUST be inclusive of withdrawal fees. Integrators should be
function previewWithdraw(
function previewWithdraw(
40,167
100
// Transfer.
_balances[from] -= 1; _balances[to] += 1; _owners[id] = to; emit Transfer(from, to, id); _tokenApprovals[id] = address(0);
_balances[from] -= 1; _balances[to] += 1; _owners[id] = to; emit Transfer(from, to, id); _tokenApprovals[id] = address(0);
62,855
235
// 3pool
address public _curve = 0x094d12e5b541784701FD8d65F11fc0598FBC6332; address public _mintr = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; address public constant usdn = 0x674C6Ad92Fd080e4004b2312b45f796a192D27a0; constructor( address _btf, address _governance, address _strategist, address _controller,
address public _curve = 0x094d12e5b541784701FD8d65F11fc0598FBC6332; address public _mintr = 0xd061D61a4d941c39E5453435B6345Dc261C2fcE0; address public constant usdn = 0x674C6Ad92Fd080e4004b2312b45f796a192D27a0; constructor( address _btf, address _governance, address _strategist, address _controller,
13,861
0
// Enum representing shipping status
enum Status { Pending, Shipped, Accepted, Rejected, Canceled }
enum Status { Pending, Shipped, Accepted, Rejected, Canceled }
10,727
0
// Base GSN recipient contract: includes the {IRelayRecipient} interfaceTIP: This contract is abstract. The functions {IRelayRecipient-acceptRelayedCall}, {_preRelayedCall}, and {_postRelayedCall} are not implemented and must beinformation on how to use the pre-built {GSNRecipientSignature} and{GSNRecipientERC20Fee}, or how to write your own. Default RelayHub address, deployed on mainnet and all testnets at the same address
address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494; uint256 constant private _RELAYED_CALL_ACCEPTED = 0; uint256 constant private _RELAYED_CALL_REJECTED = 11;
address private _relayHub = 0xD216153c06E857cD7f72665E0aF1d7D82172F494; uint256 constant private _RELAYED_CALL_ACCEPTED = 0; uint256 constant private _RELAYED_CALL_REJECTED = 11;
20,267
414
// // Triggered after a user claims rewards from the HeadlessStakingRewards. Usedto check for season finish. If it has not, then do not spend gas updating the other vars. _account Address of user that has burned /
function _claimRewardHook(address _account) internal override { uint8 newMultiplier = questManager.checkForSeasonFinish(_account); bool priceCoeffChanged = hasPriceCoeff ? _getPriceCoeff() != _userPriceCoeff[_account] : false; if (newMultiplier != _balances[_account].questMultiplier || priceCoeffChanged) { // 1. Get current balance & trigger season finish uint256 oldScaledBalance = _getBalance(_account, _balances[_account]); _balances[_account].questMultiplier = newMultiplier; if (priceCoeffChanged) { _userPriceCoeff[_account] = SafeCastExtended.toUint16(_getPriceCoeff()); } // 3. Update scaled balance _settleScaledBalance(_account, oldScaledBalance); } }
function _claimRewardHook(address _account) internal override { uint8 newMultiplier = questManager.checkForSeasonFinish(_account); bool priceCoeffChanged = hasPriceCoeff ? _getPriceCoeff() != _userPriceCoeff[_account] : false; if (newMultiplier != _balances[_account].questMultiplier || priceCoeffChanged) { // 1. Get current balance & trigger season finish uint256 oldScaledBalance = _getBalance(_account, _balances[_account]); _balances[_account].questMultiplier = newMultiplier; if (priceCoeffChanged) { _userPriceCoeff[_account] = SafeCastExtended.toUint16(_getPriceCoeff()); } // 3. Update scaled balance _settleScaledBalance(_account, oldScaledBalance); } }
58,051
15
// emergence stop
function halt() public onlyAdmin{ icoState = State.halted; }
function halt() public onlyAdmin{ icoState = State.halted; }
5,150
42
// Return the associated type information. memView The memory viewreturn_type - The type associated with the view /
function typeOf(bytes29 memView) internal pure returns (uint40 _type) { assembly { // solhint-disable-previous-line no-inline-assembly // 216 == 256 - 40 _type := shr(216, memView) // shift out lower 24 bytes } }
function typeOf(bytes29 memView) internal pure returns (uint40 _type) { assembly { // solhint-disable-previous-line no-inline-assembly // 216 == 256 - 40 _type := shr(216, memView) // shift out lower 24 bytes } }
20,536
2
// Perform tasks (clubbed all functions into one to reduce external calls & SAVE GAS FEE)
manager.performTasks();
manager.performTasks();
15,116
113
// Locked/Smart contract to enable locking and unlocking of token holders.
contract Locked is AccessControl { mapping (address => bool) public lockedList; event AddedLock(address user); event RemovedLock(address user); // Create a new role identifier for the controller role bytes32 public constant CONTROLLER_ROLE = keccak256("CONTROLLER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); modifier isController { require(hasRole(CONTROLLER_ROLE, msg.sender), "Locked::isController - Caller is not a controller"); _; } modifier isMinter { require(hasRole(MINTER_ROLE, msg.sender), "Locked::isMinter - Caller is not a minter"); _; } /// @dev terminate transaction if any of the participants is locked /// @param _from - user initiating process /// @param _to - user involved in process modifier isNotLocked(address _from, address _to) { if (!hasRole(DEFAULT_ADMIN_ROLE, _from)){ // allow contract admin on sending tokens even if recipient is locked require(!lockedList[_from], "Locked::isNotLocked - User is locked"); require(!lockedList[_to], "Locked::isNotLocked - User is locked"); } _; } /// @dev check if user has been locked /// @param _user - usr to check /// @return true or false function isLocked(address _user) public view returns (bool) { return lockedList[_user]; } /// @dev add user to lock /// @param _user to lock function addLock (address _user) public isController() { _addLock(_user); } function addLockMultiple(address[] memory _users) public isController() { uint256 length = _users.length; require(length <= 256, "Locked-addLockMultiple: List too long"); for (uint256 i = 0; i < length; i++) { _addLock(_users[i]); } } /// @dev unlock user /// @param _user - user to unlock function removeLock (address _user) isController() public { _removeLock(_user); } /// @dev add user to lock for internal needs /// @param _user to lock function _addLock(address _user) internal { lockedList[_user] = true; emit AddedLock(_user); } /// @dev unlock user for internal needs /// @param _user - user to unlock function _removeLock (address _user) internal { lockedList[_user] = false; emit RemovedLock(_user); } }
contract Locked is AccessControl { mapping (address => bool) public lockedList; event AddedLock(address user); event RemovedLock(address user); // Create a new role identifier for the controller role bytes32 public constant CONTROLLER_ROLE = keccak256("CONTROLLER_ROLE"); bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE"); modifier isController { require(hasRole(CONTROLLER_ROLE, msg.sender), "Locked::isController - Caller is not a controller"); _; } modifier isMinter { require(hasRole(MINTER_ROLE, msg.sender), "Locked::isMinter - Caller is not a minter"); _; } /// @dev terminate transaction if any of the participants is locked /// @param _from - user initiating process /// @param _to - user involved in process modifier isNotLocked(address _from, address _to) { if (!hasRole(DEFAULT_ADMIN_ROLE, _from)){ // allow contract admin on sending tokens even if recipient is locked require(!lockedList[_from], "Locked::isNotLocked - User is locked"); require(!lockedList[_to], "Locked::isNotLocked - User is locked"); } _; } /// @dev check if user has been locked /// @param _user - usr to check /// @return true or false function isLocked(address _user) public view returns (bool) { return lockedList[_user]; } /// @dev add user to lock /// @param _user to lock function addLock (address _user) public isController() { _addLock(_user); } function addLockMultiple(address[] memory _users) public isController() { uint256 length = _users.length; require(length <= 256, "Locked-addLockMultiple: List too long"); for (uint256 i = 0; i < length; i++) { _addLock(_users[i]); } } /// @dev unlock user /// @param _user - user to unlock function removeLock (address _user) isController() public { _removeLock(_user); } /// @dev add user to lock for internal needs /// @param _user to lock function _addLock(address _user) internal { lockedList[_user] = true; emit AddedLock(_user); } /// @dev unlock user for internal needs /// @param _user - user to unlock function _removeLock (address _user) internal { lockedList[_user] = false; emit RemovedLock(_user); } }
15,146
16
// get balance users uint256 tokenGatedBalance = getTokenGatedBalance( msg.sender, nft.tokenGated, nft.tokenGatedId ); require( mintedPerCollections[msg.sender][_nftId] + _amount > tokenGatedBalance, "Mint quantity exceed limit" );
mintedPerCollections[msg.sender][_nftId] += _amount; _mint(msg.sender, _nftId, _amount, "");
mintedPerCollections[msg.sender][_nftId] += _amount; _mint(msg.sender, _nftId, _amount, "");
4,233
110
// take all we can
require(cToken.redeemUnderlying(liquidity) == 0, "ctoken: redeemUnderlying fail");
require(cToken.redeemUnderlying(liquidity) == 0, "ctoken: redeemUnderlying fail");
34,044
44
// Function modifier to require caller to be authorized /
modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; }
modifier authorized() { require(isAuthorized(msg.sender), "!AUTHORIZED"); _; }
589
24
// Update the free-memory pointer by padding our last write location to 32 bytes: add 31 bytes to the end of tempBytes to move to the next 32 byte block, then round down to the nearest multiple of 32. If the sum of the length of the two arrays is zero then add one before rounding down to leave a blank 32 bytes (the length block with 0).
mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ))
mstore(0x40, and( add(add(end, iszero(add(length, mload(_preBytes)))), 31), not(31) // Round down to the nearest 32 bytes. ))
24,340
5
// msg.sender is preserved in delegatecall.It was not available in callcode.
sender = msg.sender;
sender = msg.sender;
47,558
77
// 计算数量
_transfer(this, msg.sender, amount);
_transfer(this, msg.sender, amount);
8,683
69
// https:en.wikipedia.org/wiki/Binary_search_algorithm
Snapshot[] storage snapshotsInfo = snapshots[_account]; uint256 index; uint256 low = 0; uint256 high = snapshotsInfo.length; while (low < high) { uint256 mid = (low + high) / 2; if (snapshotsInfo[mid].beforeBlock > blockNum) { high = mid;
Snapshot[] storage snapshotsInfo = snapshots[_account]; uint256 index; uint256 low = 0; uint256 high = snapshotsInfo.length; while (low < high) { uint256 mid = (low + high) / 2; if (snapshotsInfo[mid].beforeBlock > blockNum) { high = mid;
18,659
1
// CreatureCreature - a contract for my non-fungible creatures. /
contract suhmMAPToken is ERC721Tradable { constructor(address _proxyRegistryAddress) ERC721Tradable("Suhm", "MAP", _proxyRegistryAddress){} function baseTokenURI() override public pure returns (string memory) { return "https://map.j-wave.co.jp/meta/json/suhm/1"; } }
contract suhmMAPToken is ERC721Tradable { constructor(address _proxyRegistryAddress) ERC721Tradable("Suhm", "MAP", _proxyRegistryAddress){} function baseTokenURI() override public pure returns (string memory) { return "https://map.j-wave.co.jp/meta/json/suhm/1"; } }
8,633
22
// ERC-721 Non-Fungible Token Standard, optional enumeration extension/See https:github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md/Note: the ERC-165 identifier for this interface is 0x780e9d63
interface IERC721Enumerable /* is IERC721Base */ { /// @notice Count NFTs tracked by this contract /// @return A count of valid NFTs tracked by this contract, where each one of /// them has an assigned and queryable owner not equal to the zero address function totalSupply() external view returns (uint256); /// @notice Enumerate valid NFTs /// @dev Throws if `_index` >= `totalSupply()`. /// @param _index A counter less than `totalSupply()` /// @return The token identifier for the `_index`th NFT, /// (sort order not specified) function tokenByIndex(uint256 _index) external view returns (uint256); /// @notice Enumerate NFTs assigned to an owner /// @dev Throws if `_index` >= `balanceOf(_owner)` or if /// `_owner` is the zero address, representing invalid NFTs. /// @param _owner An address where we are interested in NFTs owned by them /// @param _index A counter less than `balanceOf(_owner)` /// @return The token identifier for the `_index`th NFT assigned to `_owner`, /// (sort order not specified) function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _tokenId); }
interface IERC721Enumerable /* is IERC721Base */ { /// @notice Count NFTs tracked by this contract /// @return A count of valid NFTs tracked by this contract, where each one of /// them has an assigned and queryable owner not equal to the zero address function totalSupply() external view returns (uint256); /// @notice Enumerate valid NFTs /// @dev Throws if `_index` >= `totalSupply()`. /// @param _index A counter less than `totalSupply()` /// @return The token identifier for the `_index`th NFT, /// (sort order not specified) function tokenByIndex(uint256 _index) external view returns (uint256); /// @notice Enumerate NFTs assigned to an owner /// @dev Throws if `_index` >= `balanceOf(_owner)` or if /// `_owner` is the zero address, representing invalid NFTs. /// @param _owner An address where we are interested in NFTs owned by them /// @param _index A counter less than `balanceOf(_owner)` /// @return The token identifier for the `_index`th NFT assigned to `_owner`, /// (sort order not specified) function tokenOfOwnerByIndex(address _owner, uint256 _index) external view returns (uint256 _tokenId); }
46,216
1
// how much the vault is willing to lend
bool disableBorrow; // if the vehicle can continue to borrow assets uint256 lendMaxBps; // the vault is willing to lend `min(lendRatioNum * totalBaseAsset, borrowCap)` uint256 lendCap; // the maximum amount that the vault is willing to lend to the vehicle
bool disableBorrow; // if the vehicle can continue to borrow assets uint256 lendMaxBps; // the vault is willing to lend `min(lendRatioNum * totalBaseAsset, borrowCap)` uint256 lendCap; // the maximum amount that the vault is willing to lend to the vehicle
10,415
396
// Remove the accepted bid
delete _tokenBidders[tokenId][bidder]; emit BidShareUpdated(tokenId, bidShares); emit BidFinalized(tokenId, bid);
delete _tokenBidders[tokenId][bidder]; emit BidShareUpdated(tokenId, bidShares); emit BidFinalized(tokenId, bid);
75,807
34
// Verify if user is whitelisted
function verifyUserWhitelisted(address _whitelistedAddress) public view returns (bool)
function verifyUserWhitelisted(address _whitelistedAddress) public view returns (bool)
24,181
49
// overriden: if (!core.burn(addressArr, uintArr)) revertWithMutex(addressArr[0]); by-
if (!burn(addressArr, uintArr)) revertWithMutex(addressArr[0]);
if (!burn(addressArr, uintArr)) revertWithMutex(addressArr[0]);
3,380
112
// SWAP TO ETH
uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance);
uint256 initialBalance = address(this).balance; swapTokensForEth(contractTokenBalance);
45,138
1
// The latest ETH/USD price set when the contract sends the caller a random number.
uint256 public valueAtLastUpdate;
uint256 public valueAtLastUpdate;
11,676
142
// Low level withdraw function
function _withdraw(uint256 _pid, uint256 _amount, address from, address to) internal { PoolInfo storage pool = poolInfo[_pid]; require(pool.withdrawable, "Withdrawing from this pool is disabled"); UserInfo storage user = userInfo[_pid][from]; require(user.amount >= _amount, "withdraw: not good"); massUpdatePools(); updateAndPayOutPending(_pid, pool, user, from); // Update balances of from this is not withdrawal but claiming ORCA farmed if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.token.safeTransfer(address(to), _amount); } user.rewardDebt = user.amount.mul(pool.accOrcaPerShare).div(1e12); emit Withdraw(to, _pid, _amount); }
function _withdraw(uint256 _pid, uint256 _amount, address from, address to) internal { PoolInfo storage pool = poolInfo[_pid]; require(pool.withdrawable, "Withdrawing from this pool is disabled"); UserInfo storage user = userInfo[_pid][from]; require(user.amount >= _amount, "withdraw: not good"); massUpdatePools(); updateAndPayOutPending(_pid, pool, user, from); // Update balances of from this is not withdrawal but claiming ORCA farmed if(_amount > 0) { user.amount = user.amount.sub(_amount); pool.token.safeTransfer(address(to), _amount); } user.rewardDebt = user.amount.mul(pool.accOrcaPerShare).div(1e12); emit Withdraw(to, _pid, _amount); }
9,441
1
// lzReceive must be called by the endpoint for security
require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId];
require(_msgSender() == address(lzEndpoint), "LzApp: invalid endpoint caller"); bytes memory trustedRemote = trustedRemoteLookup[_srcChainId];
4,339
58
// Issue the synth (less fee)
syntharb().mint(msg.sender, _loanAmount);
syntharb().mint(msg.sender, _loanAmount);
45,153
5
// INIT //Inits the wallet/defines a initial cap table with specific equity per founder. Equity values 0 - 10000 representing 0-100% equity/cxo1 founder 1 /cxo2 founder 2/cxo3 founder 3/cdo1 founder 4/cdo2 founder 5/cdo3 founder 6
constructor (address cxo1, address cxo2, address cxo3, address cdo1, address cdo2, address cdo3) { _deployerAddress = msg.sender; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); // Initial cap table createInitialFounder(cxo1, 3000); createInitialFounder(cxo2, 3000); createInitialFounder(cxo3, 3000); createInitialFounder(cdo1, 500); createInitialFounder(cdo2, 300); createInitialFounder(cdo3, 200); }
constructor (address cxo1, address cxo2, address cxo3, address cdo1, address cdo2, address cdo3) { _deployerAddress = msg.sender; _setupRole(DEFAULT_ADMIN_ROLE, msg.sender); // Initial cap table createInitialFounder(cxo1, 3000); createInitialFounder(cxo2, 3000); createInitialFounder(cxo3, 3000); createInitialFounder(cdo1, 500); createInitialFounder(cdo2, 300); createInitialFounder(cdo3, 200); }
22,419
41
// Swap and pop
slotOwners[idx] = slotOwners[slotOwners.length - 1]; slotOwners.pop();
slotOwners[idx] = slotOwners[slotOwners.length - 1]; slotOwners.pop();
19,551
250
// Internal - Removes a module attached to the SecurityToken by index/
function _removeModuleWithIndex(uint8 _type, uint256 _index) internal { uint256 length = modules[_type].length; modules[_type][_index] = modules[_type][length - 1]; modules[_type].length = length - 1; if ((length - 1) != _index) { //Need to find index of _type in moduleTypes of module we are moving uint8[] memory newTypes = modulesToData[modules[_type][_index]].moduleTypes; for (uint256 i = 0; i < newTypes.length; i++) { if (newTypes[i] == _type) { modulesToData[modules[_type][_index]].moduleIndexes[i] = _index; } } } }
function _removeModuleWithIndex(uint8 _type, uint256 _index) internal { uint256 length = modules[_type].length; modules[_type][_index] = modules[_type][length - 1]; modules[_type].length = length - 1; if ((length - 1) != _index) { //Need to find index of _type in moduleTypes of module we are moving uint8[] memory newTypes = modulesToData[modules[_type][_index]].moduleTypes; for (uint256 i = 0; i < newTypes.length; i++) { if (newTypes[i] == _type) { modulesToData[modules[_type][_index]].moduleIndexes[i] = _index; } } } }
44,810
158
// Safe jgn transfer function, just in case if rounding error causes pool to not have enough jgns.
function safeJGNTransfer(address _to, uint256 _amount) internal { uint256 jgnBal = jgn.balanceOf(address(this)); if (_amount > jgnBal) { jgn.transfer(_to, jgnBal); } else { jgn.transfer(_to, _amount); } }
function safeJGNTransfer(address _to, uint256 _amount) internal { uint256 jgnBal = jgn.balanceOf(address(this)); if (_amount > jgnBal) { jgn.transfer(_to, jgnBal); } else { jgn.transfer(_to, _amount); } }
17,584
114
// Buy
uint256 DevTokens = amount.mul(_buyDevFee).div(100); amount= amount.sub(DevTokens); super._transfer(from, address(this), DevTokens); super._transfer(from, to, amount);
uint256 DevTokens = amount.mul(_buyDevFee).div(100); amount= amount.sub(DevTokens); super._transfer(from, address(this), DevTokens); super._transfer(from, to, amount);
44,396
276
// airdropped
bytes memory str = "to be airdropped to "; for (uint i=0;i<str.length;i++) s[p++] = str[i]; slot = 9; o = uint16(seq[sp++] % n1[slot]); for (uint i=p1[slot][o];t1[slot][i] != '|';i++) s[p++] = t1[slot][i]; slot = 19; o = uint16(seq[sp++] % n1[slot]); for (uint i=p1[slot][o];t1[slot][i] != '|';i++) s[p++] = t1[slot][i];
bytes memory str = "to be airdropped to "; for (uint i=0;i<str.length;i++) s[p++] = str[i]; slot = 9; o = uint16(seq[sp++] % n1[slot]); for (uint i=p1[slot][o];t1[slot][i] != '|';i++) s[p++] = t1[slot][i]; slot = 19; o = uint16(seq[sp++] % n1[slot]); for (uint i=p1[slot][o];t1[slot][i] != '|';i++) s[p++] = t1[slot][i];
77,731
8
// L2 Migration
function importVestingEntries( address account, uint256 escrowedAmount, VestingEntries.VestingEntry[] calldata vestingEntries ) external;
function importVestingEntries( address account, uint256 escrowedAmount, VestingEntries.VestingEntry[] calldata vestingEntries ) external;
975
173
// ITransmuterBuffer/Alchemix Finance
interface ITransmuterBuffer is IERC20TokenReceiver { /// @notice Parameters used to define a given weighting schema. /// /// Weighting schemas can be used to generally weight assets in relation to an action or actions that will be taken. /// In the TransmuterBuffer, there are 2 actions that require weighting schemas: `burnCredit` and `depositFunds`. /// /// `burnCredit` uses a weighting schema that determines which yield-tokens are targeted when burning credit from /// the `Account` controlled by the TransmuterBuffer, via the `Alchemist.donate` function. /// /// `depositFunds` uses a weighting schema that determines which yield-tokens are targeted when depositing /// underlying-tokens into the Alchemist. struct Weighting { // The weights of the tokens used by the schema. mapping(address => uint256) weights; // The tokens used by the schema. address[] tokens; // The total weight of the schema (sum of the token weights). uint256 totalWeight; } /// @notice Emitted when the alchemist is set. /// /// @param alchemist The address of the alchemist. event SetAlchemist(address alchemist); /// @notice Emitted when an underlying token is registered. /// /// @param underlyingToken The address of the underlying token. /// @param transmuter The address of the transmuter for the underlying token. event RegisterAsset(address underlyingToken, address transmuter); /// @notice Emitted when an underlying token's flow rate is updated. /// /// @param underlyingToken The underlying token. /// @param flowRate The flow rate for the underlying token. event SetFlowRate(address underlyingToken, uint256 flowRate); /// @notice Emitted when the strategies are refreshed. event RefreshStrategies(); /// @notice Emitted when a source is set. event SetSource(address source, bool flag); /// @notice Emitted when a transmuter is updated. event SetTransmuter(address underlyingToken, address transmuter); /// @notice Gets the current version. /// /// @return The version. function version() external view returns (string memory); /// @notice Gets the total credit held by the TransmuterBuffer. /// /// @return The total credit. function getTotalCredit() external view returns (uint256); /// @notice Gets the total amount of underlying token that the TransmuterBuffer controls in the Alchemist. /// /// @param underlyingToken The underlying token to query. /// /// @return totalBuffered The total buffered. function getTotalUnderlyingBuffered(address underlyingToken) external view returns (uint256 totalBuffered); /// @notice Gets the total available flow for the underlying token /// /// The total available flow will be the lesser of `flowAvailable[token]` and `getTotalUnderlyingBuffered`. /// /// @param underlyingToken The underlying token to query. /// /// @return availableFlow The available flow. function getAvailableFlow(address underlyingToken) external view returns (uint256 availableFlow); /// @notice Gets the weight of the given weight type and token /// /// @param weightToken The type of weight to query. /// @param token The weighted token. /// /// @return weight The weight of the token for the given weight type. function getWeight(address weightToken, address token) external view returns (uint256 weight); /// @notice Set a source of funds. /// /// @param source The target source. /// @param flag The status to set for the target source. function setSource(address source, bool flag) external; /// @notice Set transmuter by admin. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The target underlying token to update. /// @param newTransmuter The new transmuter for the target `underlyingToken`. function setTransmuter(address underlyingToken, address newTransmuter) external; /// @notice Set alchemist by admin. /// /// This function reverts if the caller is not the current admin. /// /// @param alchemist The new alchemist whose funds we are handling. function setAlchemist(address alchemist) external; /// @notice Refresh the yield-tokens in the TransmuterBuffer. /// /// This requires a call anytime governance adds a new yield token to the alchemist. function refreshStrategies() external; /// @notice Registers an underlying-token. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The underlying-token being registered. /// @param transmuter The transmuter for the underlying-token. function registerAsset(address underlyingToken, address transmuter) external; /// @notice Set flow rate of an underlying token. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The underlying-token getting the flow rate set. /// @param flowRate The new flow rate. function setFlowRate(address underlyingToken, uint256 flowRate) external; /// @notice Sets up a weighting schema. /// /// @param weightToken The name of the weighting schema. /// @param tokens The yield-tokens to weight. /// @param weights The weights of the yield tokens. function setWeights(address weightToken, address[] memory tokens, uint256[] memory weights) external; /// @notice Exchanges any available flow into the Transmuter. /// /// This function is a way for the keeper to force funds to be exchanged into the Transmuter. /// /// This function will revert if called by any account that is not a keeper. If there is not enough local balance of /// `underlyingToken` held by the TransmuterBuffer any additional funds will be withdrawn from the Alchemist by /// unwrapping `yieldToken`. /// /// @param underlyingToken The address of the underlying token to exchange. function exchange(address underlyingToken) external; /// @notice Burns available credit in the alchemist. function burnCredit() external; /// @notice Deposits local collateral into the alchemist /// /// @param underlyingToken The collateral to deposit. /// @param amount The amount to deposit. function depositFunds(address underlyingToken, uint256 amount) external; /// @notice Withdraws collateral from the alchemist /// /// This function reverts if: /// - The caller is not the transmuter. /// - There is not enough flow available to fulfill the request. /// - There is not enough underlying collateral in the alchemist controlled by the buffer to fulfil the request. /// /// @param underlyingToken The underlying token to withdraw. /// @param amount The amount to withdraw. /// @param recipient The account receiving the withdrawn funds. function withdraw( address underlyingToken, uint256 amount, address recipient ) external; /// @notice Withdraws collateral from the alchemist /// /// @param yieldToken The yield token to withdraw. /// @param shares The amount of Alchemist shares to withdraw. /// @param minimumAmountOut The minimum amount of underlying tokens needed to be recieved as a result of unwrapping the yield tokens. function withdrawFromAlchemist( address yieldToken, uint256 shares, uint256 minimumAmountOut ) external; }
interface ITransmuterBuffer is IERC20TokenReceiver { /// @notice Parameters used to define a given weighting schema. /// /// Weighting schemas can be used to generally weight assets in relation to an action or actions that will be taken. /// In the TransmuterBuffer, there are 2 actions that require weighting schemas: `burnCredit` and `depositFunds`. /// /// `burnCredit` uses a weighting schema that determines which yield-tokens are targeted when burning credit from /// the `Account` controlled by the TransmuterBuffer, via the `Alchemist.donate` function. /// /// `depositFunds` uses a weighting schema that determines which yield-tokens are targeted when depositing /// underlying-tokens into the Alchemist. struct Weighting { // The weights of the tokens used by the schema. mapping(address => uint256) weights; // The tokens used by the schema. address[] tokens; // The total weight of the schema (sum of the token weights). uint256 totalWeight; } /// @notice Emitted when the alchemist is set. /// /// @param alchemist The address of the alchemist. event SetAlchemist(address alchemist); /// @notice Emitted when an underlying token is registered. /// /// @param underlyingToken The address of the underlying token. /// @param transmuter The address of the transmuter for the underlying token. event RegisterAsset(address underlyingToken, address transmuter); /// @notice Emitted when an underlying token's flow rate is updated. /// /// @param underlyingToken The underlying token. /// @param flowRate The flow rate for the underlying token. event SetFlowRate(address underlyingToken, uint256 flowRate); /// @notice Emitted when the strategies are refreshed. event RefreshStrategies(); /// @notice Emitted when a source is set. event SetSource(address source, bool flag); /// @notice Emitted when a transmuter is updated. event SetTransmuter(address underlyingToken, address transmuter); /// @notice Gets the current version. /// /// @return The version. function version() external view returns (string memory); /// @notice Gets the total credit held by the TransmuterBuffer. /// /// @return The total credit. function getTotalCredit() external view returns (uint256); /// @notice Gets the total amount of underlying token that the TransmuterBuffer controls in the Alchemist. /// /// @param underlyingToken The underlying token to query. /// /// @return totalBuffered The total buffered. function getTotalUnderlyingBuffered(address underlyingToken) external view returns (uint256 totalBuffered); /// @notice Gets the total available flow for the underlying token /// /// The total available flow will be the lesser of `flowAvailable[token]` and `getTotalUnderlyingBuffered`. /// /// @param underlyingToken The underlying token to query. /// /// @return availableFlow The available flow. function getAvailableFlow(address underlyingToken) external view returns (uint256 availableFlow); /// @notice Gets the weight of the given weight type and token /// /// @param weightToken The type of weight to query. /// @param token The weighted token. /// /// @return weight The weight of the token for the given weight type. function getWeight(address weightToken, address token) external view returns (uint256 weight); /// @notice Set a source of funds. /// /// @param source The target source. /// @param flag The status to set for the target source. function setSource(address source, bool flag) external; /// @notice Set transmuter by admin. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The target underlying token to update. /// @param newTransmuter The new transmuter for the target `underlyingToken`. function setTransmuter(address underlyingToken, address newTransmuter) external; /// @notice Set alchemist by admin. /// /// This function reverts if the caller is not the current admin. /// /// @param alchemist The new alchemist whose funds we are handling. function setAlchemist(address alchemist) external; /// @notice Refresh the yield-tokens in the TransmuterBuffer. /// /// This requires a call anytime governance adds a new yield token to the alchemist. function refreshStrategies() external; /// @notice Registers an underlying-token. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The underlying-token being registered. /// @param transmuter The transmuter for the underlying-token. function registerAsset(address underlyingToken, address transmuter) external; /// @notice Set flow rate of an underlying token. /// /// This function reverts if the caller is not the current admin. /// /// @param underlyingToken The underlying-token getting the flow rate set. /// @param flowRate The new flow rate. function setFlowRate(address underlyingToken, uint256 flowRate) external; /// @notice Sets up a weighting schema. /// /// @param weightToken The name of the weighting schema. /// @param tokens The yield-tokens to weight. /// @param weights The weights of the yield tokens. function setWeights(address weightToken, address[] memory tokens, uint256[] memory weights) external; /// @notice Exchanges any available flow into the Transmuter. /// /// This function is a way for the keeper to force funds to be exchanged into the Transmuter. /// /// This function will revert if called by any account that is not a keeper. If there is not enough local balance of /// `underlyingToken` held by the TransmuterBuffer any additional funds will be withdrawn from the Alchemist by /// unwrapping `yieldToken`. /// /// @param underlyingToken The address of the underlying token to exchange. function exchange(address underlyingToken) external; /// @notice Burns available credit in the alchemist. function burnCredit() external; /// @notice Deposits local collateral into the alchemist /// /// @param underlyingToken The collateral to deposit. /// @param amount The amount to deposit. function depositFunds(address underlyingToken, uint256 amount) external; /// @notice Withdraws collateral from the alchemist /// /// This function reverts if: /// - The caller is not the transmuter. /// - There is not enough flow available to fulfill the request. /// - There is not enough underlying collateral in the alchemist controlled by the buffer to fulfil the request. /// /// @param underlyingToken The underlying token to withdraw. /// @param amount The amount to withdraw. /// @param recipient The account receiving the withdrawn funds. function withdraw( address underlyingToken, uint256 amount, address recipient ) external; /// @notice Withdraws collateral from the alchemist /// /// @param yieldToken The yield token to withdraw. /// @param shares The amount of Alchemist shares to withdraw. /// @param minimumAmountOut The minimum amount of underlying tokens needed to be recieved as a result of unwrapping the yield tokens. function withdrawFromAlchemist( address yieldToken, uint256 shares, uint256 minimumAmountOut ) external; }
30,238
12
// Only a given role has access or admin/role role to check for alongside the admin role
modifier onlyRoleOrAdmin(bytes32 role) { if ( !hasRole(DEFAULT_ADMIN_ROLE, _msgSender()) && !hasRole(role, _msgSender()) ) { revert Access_MissingRoleOrAdmin(role); } _; }
modifier onlyRoleOrAdmin(bytes32 role) { if ( !hasRole(DEFAULT_ADMIN_ROLE, _msgSender()) && !hasRole(role, _msgSender()) ) { revert Access_MissingRoleOrAdmin(role); } _; }
10,174
193
// INTERNAL FUNCTIONS/
function _setCreator(address _to, uint256 _id) internal creatorOnly(_id) { _creators[_id] = _to; }
function _setCreator(address _to, uint256 _id) internal creatorOnly(_id) { _creators[_id] = _to; }
4,912
7
// Borrowed from: https:github.com/1001-digital/erc721-extensions/blob/f5c983bac8989bc5ebf9b34c03f28e438da9a7b3/contracts/RandomlyAssigned.solL27
return uint256(keccak256( abi.encodePacked( msg.sender, block.coinbase, block.difficulty, block.gaslimit, block.timestamp, blockhash(block.number))));
return uint256(keccak256( abi.encodePacked( msg.sender, block.coinbase, block.difficulty, block.gaslimit, block.timestamp, blockhash(block.number))));
12,072
50
// Exit Balancer pool
_exitBalancerPool(lpAmount_, minTokenAmountsBalancer_);
_exitBalancerPool(lpAmount_, minTokenAmountsBalancer_);
24,834
41
// Set Fee for Buys
if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _taxFee = _taxFeeOnBuy; }
if(from == uniswapV2Pair && to != address(uniswapV2Router)) { _taxFee = _taxFeeOnBuy; }
992
70
// limit the maximum contribution for each wallet
uint256 public constant MAX_CONTRIBUTION = .1 ether;
uint256 public constant MAX_CONTRIBUTION = .1 ether;
8,858
32
// A structure representing a single bet.
struct Bet { // Wager amount in wei. uint amount; // Modulo of a game. uint8 modulo; // Number of winning outcomes, used to compute winning payment (* modulo/rollUnder), // and used instead of mask for games with modulo > MAX_MASK_MODULO. uint8 rollUnder; // Block number of placeBet tx. uint40 placeBlockNumber; // Bit mask representing winning bet outcomes (see MAX_MASK_MODULO comment). uint40 mask; // Address of a gambler, used to pay out winning bets. address payable gambler; }
struct Bet { // Wager amount in wei. uint amount; // Modulo of a game. uint8 modulo; // Number of winning outcomes, used to compute winning payment (* modulo/rollUnder), // and used instead of mask for games with modulo > MAX_MASK_MODULO. uint8 rollUnder; // Block number of placeBet tx. uint40 placeBlockNumber; // Bit mask representing winning bet outcomes (see MAX_MASK_MODULO comment). uint40 mask; // Address of a gambler, used to pay out winning bets. address payable gambler; }
13,456
49
// taker get tokens
tokenList[takerOrder.tokenBuy][takerOrder.user] = safeAdd(tokenList[takerOrder.tokenBuy][takerOrder.user], safeSub(takerBuy, takerFee));
tokenList[takerOrder.tokenBuy][takerOrder.user] = safeAdd(tokenList[takerOrder.tokenBuy][takerOrder.user], safeSub(takerBuy, takerFee));
31,211
30
// State management
function getRegisState() public view onlyRegulator onlyActivatedMachineState returns (uint256)
function getRegisState() public view onlyRegulator onlyActivatedMachineState returns (uint256)
19,060
689
// accessory functions to fetch data from the core contract /
{ return dataProvider.getReserveConfigurationData(_reserve); }
{ return dataProvider.getReserveConfigurationData(_reserve); }
9,921
449
// Returns the starting token ID.To change the starting token ID, please override this function. /
function _startTokenId() internal pure virtual returns (uint256) { // It will become modifiable in the future versions return 0; }
function _startTokenId() internal pure virtual returns (uint256) { // It will become modifiable in the future versions return 0; }
18,536
34
// Withdraws pETH/pIERC20 by providing a burn proof over at Incognito Chain This function takes a burn instruction on Incognito Chain, checksfor its validity and returns the token back to ETH chain This only works when the contract is not Paused inst: the decoded instruction as a list of bytes heights: the blocks containing the instruction instPaths: merkle path of the instruction instPathIsLefts: whether each node on the path is the left or right child instRoots: root of the merkle tree contains all instructions blkData: merkle has of the block body sigIdxs: indices of the validators who signed this block sigVs:
function withdraw( bytes memory inst, uint heights, bytes32[] memory instPaths, bool[] memory instPathIsLefts, bytes32 instRoots, bytes32 blkData, uint[] memory sigIdxs, uint8[] memory sigVs, bytes32[] memory sigRs,
function withdraw( bytes memory inst, uint heights, bytes32[] memory instPaths, bool[] memory instPathIsLefts, bytes32 instRoots, bytes32 blkData, uint[] memory sigIdxs, uint8[] memory sigVs, bytes32[] memory sigRs,
41,118