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
11
// struct for the status of a pending operation.
struct PendingState { uint yetNeeded; uint ownersDone; uint index; }
struct PendingState { uint yetNeeded; uint ownersDone; uint index; }
19,455
30
// Calculate amount of DAI to Join (as erc20 WAD value)
uint256 daiToJoin = divup(daiAmt, RAY);
uint256 daiToJoin = divup(daiAmt, RAY);
6,206
17
// mapping of addresses with according balances
mapping(address => uint256) balances; uint256 public totalSupply;
mapping(address => uint256) balances; uint256 public totalSupply;
6,092
327
// Checks if any order transfers will fail./order Order struct of params that will be checked./fillTakerTokenAmount Desired amount of takerToken to fill./ return Predicted result of transfers.
function isTransferable(Order order, uint fillTakerTokenAmount) internal constant // The called token contracts may attempt to change state, but will not be able to due to gas limits on getBalance and getAllowance. returns (bool)
function isTransferable(Order order, uint fillTakerTokenAmount) internal constant // The called token contracts may attempt to change state, but will not be able to due to gas limits on getBalance and getAllowance. returns (bool)
25,076
64
// never exceed max leverage
maxPosition2 = type(int256).max;
maxPosition2 = type(int256).max;
21,786
38
// selfFreeze cannot more than 7 days
require(_seconds <= 7 * 24 * 3600);
require(_seconds <= 7 * 24 * 3600);
2,785
9
// Allows a CryptoPunk owner to offer it for sale /
function offerPunkForSale(uint punkIndex, uint minSalePriceInWei) public whenNotPaused nonReentrant() { require(punkIndex < 10000,"Token index not valid"); require(punksWrapperContract.ownerOf(punkIndex) == msg.sender,"you are not the owner of this token"); punksOfferedForSale[punkIndex] = Offer(true, punkIndex, msg.sender, minSalePriceInWei, address(0x0)); emit PunkOffered(punkIndex, minSalePriceInWei, address(0x0)); }
function offerPunkForSale(uint punkIndex, uint minSalePriceInWei) public whenNotPaused nonReentrant() { require(punkIndex < 10000,"Token index not valid"); require(punksWrapperContract.ownerOf(punkIndex) == msg.sender,"you are not the owner of this token"); punksOfferedForSale[punkIndex] = Offer(true, punkIndex, msg.sender, minSalePriceInWei, address(0x0)); emit PunkOffered(punkIndex, minSalePriceInWei, address(0x0)); }
2,227
3
// Emitted when an inscription is added to an NFT at 'nftAddress' with 'tokenId'
event InscriptionAdded(uint256 indexed inscriptionId, address indexed nftAddress, uint256 tokenId, address indexed inscriber, bytes32 contentHash);
event InscriptionAdded(uint256 indexed inscriptionId, address indexed nftAddress, uint256 tokenId, address indexed inscriber, bytes32 contentHash);
25,556
56
// Checks if the `RelayHub` will accept a relayed operation.Multiple things must be true for this to happen: - all arguments must be signed for by the sender (`from`) - the sender's nonce must be the current one - the recipient must accept this transaction (via {acceptRelayedCall}) Returns a `PreconditionCheck` value (`OK` when the transaction can be relayed), or a recipient-specific errorcode if it returns one in {acceptRelayedCall}. /
function canRelay( address relay, address from, address to, bytes memory encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce,
function canRelay( address relay, address from, address to, bytes memory encodedFunction, uint256 transactionFee, uint256 gasPrice, uint256 gasLimit, uint256 nonce,
16,066
215
// a valid keyset was added
event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes);
event SetValidKeyset(bytes32 indexed keysetHash, bytes keysetBytes);
36,695
97
// Returns address of oracle currency (0x0 for ETH)/
function getCurrencyAddress() external view returns(address);
function getCurrencyAddress() external view returns(address);
18,854
1
// Receive a flash loan. initiator The initiator of the loan. token The loan currency. amount The amount of tokens lent. fee The additional amount of tokens to repay. data Arbitrary data structure, intended to contain user-defined parameters.return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan" /
function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32);
function onFlashLoan( address initiator, address token, uint256 amount, uint256 fee, bytes calldata data ) external returns (bytes32);
27,537
62
// Query latest price info/tokenAddress Target address of token/payback As the charging fee may change, it is suggested that the caller pay more fees, / and the excess fees will be returned through this address/ return blockNumber Block number of price/ return priceEthAmount Oracle price - eth amount/ return priceTokenAmount Oracle price - token amount/ return avgPriceEthAmount Avg price - eth amount/ return avgPriceTokenAmount Avg price - token amount/ return sigmaSQ The square of the volatility (18 decimal places)
function latestPriceInfo(address tokenAddress, address payback) external payable returns ( uint blockNumber, uint priceEthAmount, uint priceTokenAmount, uint avgPriceEthAmount, uint avgPriceTokenAmount, uint sigmaSQ
function latestPriceInfo(address tokenAddress, address payback) external payable returns ( uint blockNumber, uint priceEthAmount, uint priceTokenAmount, uint avgPriceEthAmount, uint avgPriceTokenAmount, uint sigmaSQ
85,977
2
// All Bitcoin transaction inputs, prepended by the number of/ transaction inputs./`tx_in_count | tx_in` from raw Bitcoin transaction data.//The number of transaction inputs encoded as compactSize/unsigned integer, little-endian.//Note that some popular block explorers reverse the order of/bytes from `outpoint`'s `hash` and display it as big-endian./Solidity code of Bridge expects hashes in little-endian, just/like they are represented in a raw Bitcoin transaction.
bytes inputVector;
bytes inputVector;
10,825
90
// Company's next shares can be released only by the CEO of the company!So there should exist a CEO first
function releaseNextShares(uint _companyId) external
function releaseNextShares(uint _companyId) external
44,362
1
// /For the API query
event InDefault (string state);
event InDefault (string state);
25,810
3
// Presale arrays ------------------------------------------------------------------------
mapping(address => bool) private _presaleEligible; mapping(address => uint256) private _presaleClaimed; mapping(address => uint256) private _totalClaimed;
mapping(address => bool) private _presaleEligible; mapping(address => uint256) private _presaleClaimed; mapping(address => uint256) private _totalClaimed;
24,483
45
// TODO: delete some easy storage slots to recover more gas
selfdestruct(payable(msg.sender)); return true;
selfdestruct(payable(msg.sender)); return true;
25,689
28
// Check if pool has enough eth to give rewards to users
uint256 maxPayout = getRewardEst(_bet_event_id, winner); require(maxPayout < maxPoolReward, "Not enough eth at bet pool."); _;
uint256 maxPayout = getRewardEst(_bet_event_id, winner); require(maxPayout < maxPoolReward, "Not enough eth at bet pool."); _;
14,049
1
// Name of the token: DominoERC20 name of the token (long name)ERC20 `function name() public view returns (string)`Field is declared public: getter name() is created when compiled, it returns the name of the token. /
string public constant name = "Domino";
string public constant name = "Domino";
69,477
182
// Determine if the asset is outgoing or incoming, and store the post-balance for later use
postCallSpendAssetBalances[i] = __getVaultAssetBalance(_vaultProxy, _spendAssets[i]);
postCallSpendAssetBalances[i] = __getVaultAssetBalance(_vaultProxy, _spendAssets[i]);
79,192
5
// owner Owner address of this contract/baseURI Base for build token uri
constructor( address owner, address dollarJadeProxy, address withdrawableAccount, uint256 probabilityBasePrice, uint256 jadeBasePrice, string memory baseURI, address initialSupplyTo, uint256[] memory initialIds, uint256[] memory initialAmounts,
constructor( address owner, address dollarJadeProxy, address withdrawableAccount, uint256 probabilityBasePrice, uint256 jadeBasePrice, string memory baseURI, address initialSupplyTo, uint256[] memory initialIds, uint256[] memory initialAmounts,
30,793
95
// SCORES[0] = red, SCORES[1] = blueif red > blue, then award to redTeam, so bool _isRed = red > blue
distributeTeamCut((SCORES[0] > SCORES[1]),losingTeamCut);
distributeTeamCut((SCORES[0] > SCORES[1]),losingTeamCut);
4,316
517
// Check that the account is an already deployed non-destroyed contract. /
function checkContract(address _account) internal view { require(_account != address(0), "Account cannot be zero address"); uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(_account) } require(size > 0, "Account code size cannot be zero"); }
function checkContract(address _account) internal view { require(_account != address(0), "Account cannot be zero address"); uint256 size; // solhint-disable-next-line no-inline-assembly assembly { size := extcodesize(_account) } require(size > 0, "Account code size cannot be zero"); }
8,874
129
// EPOCH INDEXED STORAGE // EPOCH-TRANCHE INDEXED STORAGE / Array of arrays, example: tranche_SFI_earned[epoch][Tranche.S]
address[3][] public dsec_token_addresses; // Address for each dsec token address[3][] public principal_token_addresses; // Address for each principal token uint256[3][] public tranche_total_dsec; // Total dsec (tokens + vdsec) uint256[3][] public tranche_total_principal; // Total outstanding principal tokens uint256[3][] public tranche_total_utilized; // Total utilized balance in each tranche uint256[3][] public tranche_total_unutilized; // Total unutilized balance in each tranche uint256[3][] public tranche_S_virtual_utilized; // Total utilized virtual balance taken from tranche S (first index unused) uint256[3][] public tranche_S_virtual_unutilized; // Total unutilized virtual balance taken from tranche S (first index unused) uint256[3][] public tranche_interest_earned; // Interest earned (calculated at wind_down_epoch) uint256[3][] public tranche_SFI_earned; // Total SFI earned (minted at wind_down_epoch)
address[3][] public dsec_token_addresses; // Address for each dsec token address[3][] public principal_token_addresses; // Address for each principal token uint256[3][] public tranche_total_dsec; // Total dsec (tokens + vdsec) uint256[3][] public tranche_total_principal; // Total outstanding principal tokens uint256[3][] public tranche_total_utilized; // Total utilized balance in each tranche uint256[3][] public tranche_total_unutilized; // Total unutilized balance in each tranche uint256[3][] public tranche_S_virtual_utilized; // Total utilized virtual balance taken from tranche S (first index unused) uint256[3][] public tranche_S_virtual_unutilized; // Total unutilized virtual balance taken from tranche S (first index unused) uint256[3][] public tranche_interest_earned; // Interest earned (calculated at wind_down_epoch) uint256[3][] public tranche_SFI_earned; // Total SFI earned (minted at wind_down_epoch)
77,841
87
// add balance
_yamBalances[to] = _yamBalances[to].add(yamValue);
_yamBalances[to] = _yamBalances[to].add(yamValue);
59,094
73
// File: @openzeppelin/contracts/access/Roles.sol/ Roles Library for managing addresses assigned to a Role. /
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
library Roles { struct Role { mapping (address => bool) bearer; } /** * @dev Give an account access to this role. */ function add(Role storage role, address account) internal { require(!has(role, account), "Roles: account already has role"); role.bearer[account] = true; } /** * @dev Remove an account's access to this role. */ function remove(Role storage role, address account) internal { require(has(role, account), "Roles: account does not have role"); role.bearer[account] = false; } /** * @dev Check if an account has this role. * @return bool */ function has(Role storage role, address account) internal view returns (bool) { require(account != address(0), "Roles: account is the zero address"); return role.bearer[account]; } }
3,769
9
// Addresses to send percentage splits to
address public xDripBuybacksWallet; address public stakingRewardsWallet; address public marketingWallet; address public giveawaysWallet; address public teamWallet;
address public xDripBuybacksWallet; address public stakingRewardsWallet; address public marketingWallet; address public giveawaysWallet; address public teamWallet;
3,307
102
// solhint-disable-next-line no-empty-blocks
receive() external payable {} // use the proxy to execute calldata _data on contract _code // function execute(bytes memory _code, bytes memory _data) // public // payable // virtual // returns (address target, bytes32 response); function execute(address _target, bytes memory _data) public payable virtual returns (bytes32 response); //set new cache function setCache(address _cacheAddr) public virtual payable returns (bool); }
receive() external payable {} // use the proxy to execute calldata _data on contract _code // function execute(bytes memory _code, bytes memory _data) // public // payable // virtual // returns (address target, bytes32 response); function execute(address _target, bytes memory _data) public payable virtual returns (bytes32 response); //set new cache function setCache(address _cacheAddr) public virtual payable returns (bool); }
5,446
143
// Transfer ERC20 and update the required ERC20 to payout all rewards
function _erc20Transfer(address _to, uint256 _amount) internal { erc20.transfer(_to, _amount); paidOut += _amount; }
function _erc20Transfer(address _to, uint256 _amount) internal { erc20.transfer(_to, _amount); paidOut += _amount; }
7,080
167
// Grab the amount of pynths. Will fail if not approved first
pynthpUSD().transferFrom(msg.sender, address(this), amount);
pynthpUSD().transferFrom(msg.sender, address(this), amount);
28,238
48
// Using 1-based indexing to be able to make this check /
require(spaceIndex[spaceId] != 0, "The SPACE is not part of the Sector"); uint lastIndexInArray = spaceIds.length.sub(1);
require(spaceIndex[spaceId] != 0, "The SPACE is not part of the Sector"); uint lastIndexInArray = spaceIds.length.sub(1);
26,886
25
// Repay debt and withdraw collateral pool Pool address debtAmount Amount of debt to repay collateralAmount Amount of collateral to withdraw /
function repayDebtAndWithdrawCollateral(IERC20Pool pool, uint256 debtAmount, uint256 collateralAmount) public { address debtToken = pool.quoteTokenAddress(); address collateralToken = pool.collateralAddress(); _pull(debtToken, debtAmount); IERC20(debtToken).safeApprove(address(pool), debtAmount); (, , , , , uint256 lupIndex_) = poolInfoUtils.poolPricesInfo(address(pool)); pool.repayDebt( address(this), debtAmount * pool.quoteTokenScale(), collateralAmount * pool.collateralScale(), address(this), lupIndex_ ); _send(collateralToken, collateralAmount); emit ProxyActionsOperation("AjnaRepayWithdraw"); }
function repayDebtAndWithdrawCollateral(IERC20Pool pool, uint256 debtAmount, uint256 collateralAmount) public { address debtToken = pool.quoteTokenAddress(); address collateralToken = pool.collateralAddress(); _pull(debtToken, debtAmount); IERC20(debtToken).safeApprove(address(pool), debtAmount); (, , , , , uint256 lupIndex_) = poolInfoUtils.poolPricesInfo(address(pool)); pool.repayDebt( address(this), debtAmount * pool.quoteTokenScale(), collateralAmount * pool.collateralScale(), address(this), lupIndex_ ); _send(collateralToken, collateralAmount); emit ProxyActionsOperation("AjnaRepayWithdraw"); }
35,398
67
// join collateral into the cdp
collateral.approve(address(mgr), collateralDROP); mgr.join(collateralDROP);
collateral.approve(address(mgr), collateralDROP); mgr.join(collateralDROP);
59,979
4
// The multiplication in the next line has the same exact purpose as the one above.
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), 27)
let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), 27)
47,980
2
// Adds liquidity for the given recipient/tickLower/tickUpper position/The caller of this method receives a callback in the form of IUniswapV3MintCallbackuniswapV3MintCallback/ in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends/ on tickLower, tickUpper, the amount of liquidity, and the current price./recipient The address for which the liquidity will be created/tickLower The lower tick of the position in which to add liquidity/tickUpper The upper tick of the position in which to add liquidity/amount The amount of liquidity to mint/data Any data that should be passed through to the callback/ return amount0 The amount
function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1);
function mint( address recipient, int24 tickLower, int24 tickUpper, uint128 amount, bytes calldata data ) external returns (uint256 amount0, uint256 amount1);
24,541
14
// Otherwise, standard transfer functionality
_transfer(msg.sender, recipient, amount); return true;
_transfer(msg.sender, recipient, amount); return true;
6,517
0
// Constant used as input for decollateralization simulation for ordering batches with the same category and vintage
uint public constant DECOLLATERALIZATION_SIMULATION_INPUT = 1000e18; using CategoryRebalancer for SolidWorldManagerStorage.Storage; event TokensDecollateralized( uint indexed batchId, address indexed tokensOwner, uint amountIn, uint amountOut );
uint public constant DECOLLATERALIZATION_SIMULATION_INPUT = 1000e18; using CategoryRebalancer for SolidWorldManagerStorage.Storage; event TokensDecollateralized( uint indexed batchId, address indexed tokensOwner, uint amountIn, uint amountOut );
5,331
0
// testAreTransferRulesValid /
function testAreTransferRulesValid(address _token, address _caller, address _sender, address _receiver, uint256 _value) public view returns (bool)
function testAreTransferRulesValid(address _token, address _caller, address _sender, address _receiver, uint256 _value) public view returns (bool)
39,133
8
// if _message doesn't match any valid actions, revert
require(false, "!valid action");
require(false, "!valid action");
13,849
24
// Store "0123456789abcdef" in scratch space.
mstore(0x0f, 0x30313233343536373839616263646566) let temp := value
mstore(0x0f, 0x30313233343536373839616263646566) let temp := value
16,159
118
// Swap `amount` tokens for ETH. Emits {Transfer} event. From this contract to the token and WETH Pair. /
function swapTokensForEth(uint256 amount) private {
function swapTokensForEth(uint256 amount) private {
5,614
128
// Called prior to transfering given token from this contract to the account.This is good spot to doany checks and revert if the given account should be able to withdraw the specified token.Ths hook is ALWAYS called prior to a withdraw -- both the single and batch variants. /
function _beforeWithdraw( address account, address contractAddress, uint256 tokenId,
function _beforeWithdraw( address account, address contractAddress, uint256 tokenId,
65,912
15
// Function to check the amount of tokens that an owner allowed to a spender.owner address The address which owns the funds.spender address The address which will spend the funds. return A uint64 specifying the amount of tokens still available for the spender./
function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; }
function allowance(address owner, address spender) public view returns (uint256) { return _allowed[owner][spender]; }
34,191
24
// this function is implemented via burnNFA and called by InitialSale's burnNFA
function _burn( uint256 tokenId
function _burn( uint256 tokenId
18,078
10
// Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract/_tx Withdrawal transaction to hash./ return Hashed withdrawal transaction.
function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32)
function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32)
10,973
190
// Handles the bridged tokens for the first time, includes deployment of new TokenProxy contract. Checks that the value is inside the execution limits and invokes the method to execute the Mint or Unlock accordingly._token address of the bridged ERC20/ERC677 token on the foreign side._name name of the bridged token, "x" will be appended, if empty, symbol will be used instead._symbol symbol of the bridged token, "x" will be appended, if empty, name will be used instead._decimals decimals of the bridge foreign token._recipient address that will receive the tokens._value amount of tokens to be received./
function deployAndHandleBridgedTokens( address _token, string _name, string _symbol, uint8 _decimals, address _recipient, uint256 _value
function deployAndHandleBridgedTokens( address _token, string _name, string _symbol, uint8 _decimals, address _recipient, uint256 _value
49,231
10
// Triggers stopped state. Requirements: - The contract must not be paused. /
function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); }
function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); }
546
11
// Replaces `prevAccount` and `account` as owner
function _safeReplaceOwnerCut(address account, address prevAccount) internal
function _safeReplaceOwnerCut(address account, address prevAccount) internal
26,373
26
// Interface to interact with the `Join.sol` contract from MakerDAO using Dai
interface IDaiJoin { function rely(address usr) external; function deny(address usr) external; function cage() external; function join(address usr, uint WAD) external; function exit(address usr, uint WAD) external; }
interface IDaiJoin { function rely(address usr) external; function deny(address usr) external; function cage() external; function join(address usr, uint WAD) external; function exit(address usr, uint WAD) external; }
29,912
60
// get the keccak hash to get the contents of the array
mstore(0x0, _preBytes_slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength)
mstore(0x0, _preBytes_slot) let sc := keccak256(0x0, 0x20) let mc := add(_postBytes, 0x20) let end := add(mc, mlength)
950
11
// @custom:security-contact support@layer.com
contract LayerID_V1_1 is Pausable, Ownable, SoulboundBurnable { /** * Use for tracking users/tokens */ using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string private _rootURI = "https://app.staging.layer.com/api/layer-id/metadata/"; // Events and errors event NewHolderRegistered(uint256 id, address indexed owner); event HolderTokenBurned(uint256 id, address indexed owner); error HolderAlreadyExists(address holder); constructor() ERC721("Layer ID", "LAYER") {} /** * Base URI to be used on NFT metadata */ function _baseURI() internal view override returns (string memory) { return _rootURI; } /** * Owner function for setting the rootURI * * @param rootURI – Root URI to set */ function setRootURI(string memory rootURI) external onlyOwner { _rootURI = rootURI; } /** * Pause contract */ function pause() public onlyOwner { _pause(); } /** * Unpause contract */ function unpause() public onlyOwner { _unpause(); } /** * Registers new Layer ID, containing basic information about the holder later on minting the NFT. * @param holder – address * @param uri – CDI hash referencing the NFT metadata * @return _tokenId */ function registerLayerIDHolder( address holder, string memory uri ) public onlyOwner whenNotPaused returns (uint256) { // Only allow one token per address if (balanceOf(holder) > 0) { revert HolderAlreadyExists(holder); } uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); emit NewHolderRegistered(tokenId, holder); _safeMint(holder, tokenId); _setTokenURI(tokenId, uri); return tokenId; } /** * Allow burning of tokens by owner */ function burnToken(uint256 tokenId) external onlyOwner { emit HolderTokenBurned(tokenId, ownerOf(tokenId)); _burn(tokenId); } }
contract LayerID_V1_1 is Pausable, Ownable, SoulboundBurnable { /** * Use for tracking users/tokens */ using Counters for Counters.Counter; Counters.Counter private _tokenIdCounter; string private _rootURI = "https://app.staging.layer.com/api/layer-id/metadata/"; // Events and errors event NewHolderRegistered(uint256 id, address indexed owner); event HolderTokenBurned(uint256 id, address indexed owner); error HolderAlreadyExists(address holder); constructor() ERC721("Layer ID", "LAYER") {} /** * Base URI to be used on NFT metadata */ function _baseURI() internal view override returns (string memory) { return _rootURI; } /** * Owner function for setting the rootURI * * @param rootURI – Root URI to set */ function setRootURI(string memory rootURI) external onlyOwner { _rootURI = rootURI; } /** * Pause contract */ function pause() public onlyOwner { _pause(); } /** * Unpause contract */ function unpause() public onlyOwner { _unpause(); } /** * Registers new Layer ID, containing basic information about the holder later on minting the NFT. * @param holder – address * @param uri – CDI hash referencing the NFT metadata * @return _tokenId */ function registerLayerIDHolder( address holder, string memory uri ) public onlyOwner whenNotPaused returns (uint256) { // Only allow one token per address if (balanceOf(holder) > 0) { revert HolderAlreadyExists(holder); } uint256 tokenId = _tokenIdCounter.current(); _tokenIdCounter.increment(); emit NewHolderRegistered(tokenId, holder); _safeMint(holder, tokenId); _setTokenURI(tokenId, uri); return tokenId; } /** * Allow burning of tokens by owner */ function burnToken(uint256 tokenId) external onlyOwner { emit HolderTokenBurned(tokenId, ownerOf(tokenId)); _burn(tokenId); } }
28,928
13
// Events that notify clients about token transfer, approval and burn
event Transfer(address indexed from, address indexed to, uint256 value); event Mint(address indexed minter, uint256 value); event Burn(address indexed from, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint256 value); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MintFinished();
event Transfer(address indexed from, address indexed to, uint256 value); event Mint(address indexed minter, uint256 value); event Burn(address indexed from, uint256 value); event Approval(address indexed _owner, address indexed _spender, uint256 value); event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); event MintFinished();
44,802
26
// in the context of this contract the name of this is a bit confusing, this "wrapper" is the one that knows how to transfer a type of nft
address public nftTransferWrapper; address public beneficiary; address public wrappedNft; uint256 public wrappedNftId; bool private wrapping_; event Initialized(uint256 indexed tokenId); event NftWrapped(
address public nftTransferWrapper; address public beneficiary; address public wrappedNft; uint256 public wrappedNftId; bool private wrapping_; event Initialized(uint256 indexed tokenId); event NftWrapped(
48,370
227
// _lockTimes[account] = releaseTime;_lockAmounts[account] = amount; emit LockChanged( account, releaseTime, amount );
LockState memory lockState; lockState._lockTimes = releaseTime; lockState._lockAmounts = amount; lockState._account = account; _LockStates[lockState._account].push(lockState); emit LockChanged( account, releaseTime, amount );
LockState memory lockState; lockState._lockTimes = releaseTime; lockState._lockAmounts = amount; lockState._account = account; _LockStates[lockState._account].push(lockState); emit LockChanged( account, releaseTime, amount );
36,325
62
// ghi no citizen
citizen[_winner].citizenBalanceEth+=_value; CitizenContract.addGameEthSpendWin(_winner, _valuebet, _value, false); dividendRound[currentRoundDividend].totalEthCredit+=_value;
citizen[_winner].citizenBalanceEth+=_value; CitizenContract.addGameEthSpendWin(_winner, _valuebet, _value, false); dividendRound[currentRoundDividend].totalEthCredit+=_value;
34,178
5
// Note: This file has been modified to include the sqrt function for quadratic voting/ Standard math utilities missing in the Solidity language. /
library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } /** * Imported from: https://github.com/alianse777/solidity-standard-library/blob/master/Math.sol * @dev Compute square root of x * @return sqrt(x) */ function sqrt(uint256 x) internal pure returns (uint256) { uint256 n = x / 2; uint256 lstX = 0; while (n != lstX){ lstX = n; n = (n + x/n) / 2; } return uint256(n); } }
library Math { /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a >= b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow, so we distribute return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2); } /** * Imported from: https://github.com/alianse777/solidity-standard-library/blob/master/Math.sol * @dev Compute square root of x * @return sqrt(x) */ function sqrt(uint256 x) internal pure returns (uint256) { uint256 n = x / 2; uint256 lstX = 0; while (n != lstX){ lstX = n; n = (n + x/n) / 2; } return uint256(n); } }
30,635
19
// swapResult[0] is the input token amount swapResult[1] is the output of the first swap along the path and so on. swapResult.length-1 refers to the last token out => output token amount
uint256[] memory swapResult = IUniswapV2Router02(oolongRouter).getAmountsOut(_pendingOolong, path); profitInETH = profitInETH.add(swapResult[swapResult.length-1]);
uint256[] memory swapResult = IUniswapV2Router02(oolongRouter).getAmountsOut(_pendingOolong, path); profitInETH = profitInETH.add(swapResult[swapResult.length-1]);
26,681
28
// check already placed bid timelimted auction => lasted bid
if (bidIndex > 0 && auctionBids[_id][bidIndex - 1].active) { auctionBids[_id][bidIndex - 1].amount = auctionBids[_id][bidIndex - 1].amount.add(amount); emit NewBid(_msgSender(), _id, auctionBids[_id][bidIndex - 1].amount, currency, bidIndex - 1); } else {
if (bidIndex > 0 && auctionBids[_id][bidIndex - 1].active) { auctionBids[_id][bidIndex - 1].amount = auctionBids[_id][bidIndex - 1].amount.add(amount); emit NewBid(_msgSender(), _id, auctionBids[_id][bidIndex - 1].amount, currency, bidIndex - 1); } else {
39,769
12
// Current phase Id
uint256 public currentRoundId;
uint256 public currentRoundId;
15,876
23
// attempt to switch to the next tax interval tokensOnAccounts - how many tokens are there in total on all accounts subject to tax distribution (all except the router)
function TryNextTaxInterval(uint256 tokensOnAccounts) internal { if (block.timestamp < _lastTaxTime + _TaxIntervalMinutes * 1 minutes) return; //console.log("NEXT_TIME"); // we transfer all the collected for the distribution, plus what was not distributed _lastTaxPool = _lastTaxPool - _givedTax; _lastTaxPool += _currentTaxPool; // we reset the collection of funds and how much was issued _currentTaxPool = 0; _givedTax = 0; // we remember how much money the participants have in their hands (to calculate the share of each) _lastTotalOnAccounts = tokensOnAccounts; // we write the current date when the tax interval was changed _lastTaxTime = block.timestamp; // update the counter of tax intervals ++_TaxIntervalNumber; emit OnTaxInterval(_TaxIntervalNumber, _lastTaxPool, _lastTotalOnAccounts); }
function TryNextTaxInterval(uint256 tokensOnAccounts) internal { if (block.timestamp < _lastTaxTime + _TaxIntervalMinutes * 1 minutes) return; //console.log("NEXT_TIME"); // we transfer all the collected for the distribution, plus what was not distributed _lastTaxPool = _lastTaxPool - _givedTax; _lastTaxPool += _currentTaxPool; // we reset the collection of funds and how much was issued _currentTaxPool = 0; _givedTax = 0; // we remember how much money the participants have in their hands (to calculate the share of each) _lastTotalOnAccounts = tokensOnAccounts; // we write the current date when the tax interval was changed _lastTaxTime = block.timestamp; // update the counter of tax intervals ++_TaxIntervalNumber; emit OnTaxInterval(_TaxIntervalNumber, _lastTaxPool, _lastTotalOnAccounts); }
28,921
145
// iterate through the reserves and scale their balance by the ratio provided, or disable virtual balance altogether if a factor of 100% is passed in
IERC20Token reserveToken; for (uint16 i = 0; i < reserveTokens.length; i++) { reserveToken = reserveTokens[i]; Reserve storage reserve = reserves[reserveToken]; reserve.isVirtualBalanceEnabled = enable; reserve.virtualBalance = enable ? reserveToken.balanceOf(this).mul(_scaleFactor).div(100) : 0; }
IERC20Token reserveToken; for (uint16 i = 0; i < reserveTokens.length; i++) { reserveToken = reserveTokens[i]; Reserve storage reserve = reserves[reserveToken]; reserve.isVirtualBalanceEnabled = enable; reserve.virtualBalance = enable ? reserveToken.balanceOf(this).mul(_scaleFactor).div(100) : 0; }
10,336
14
// Create a new AddressValidator contract when initialize. /
constructor() public { _validator = new AddressValidator(); }
constructor() public { _validator = new AddressValidator(); }
49,259
100
// caculate the reward for specified user. Formula =>percentage(user invested) pool(usdt)
function getReward(address account) public view returns (uint ) { address _sender = msg.sender; if (_totalSupply>0) { uint rewardBalance; rewardBalance = rewardPoolBalance.add(rewardedTotalBalance).mul(_balances[account]).div(_totalSupply); if (rewardBalance > rewards[_sender].rewards) { return rewardBalance - rewards[_sender].rewards; } } return 0; }
function getReward(address account) public view returns (uint ) { address _sender = msg.sender; if (_totalSupply>0) { uint rewardBalance; rewardBalance = rewardPoolBalance.add(rewardedTotalBalance).mul(_balances[account]).div(_totalSupply); if (rewardBalance > rewards[_sender].rewards) { return rewardBalance - rewards[_sender].rewards; } } return 0; }
35,565
454
// AmmSwapsLens interface responsible for reading data related with swaps.
interface IAmmSwapsLens { /// @notice IPOR Swap structure. struct IporSwap { /// @notice Swap's ID. uint256 id; /// @notice Swap's asset (stablecoin / underlying token) address asset; /// @notice Swap's buyer address address buyer; /// @notice Swap's collateral, represented in 18 decimals. uint256 collateral; /// @notice Notional amount, represented in 18 decimals. uint256 notional; /// @notice Swap's leverage, represented in 18 decimals. uint256 leverage; /// @notice Swap's direction /// @dev 0 - Pay Fixed-Receive Floating, 1 - Receive Fixed - Pay Floading uint256 direction; /// @notice Swap's notional amount denominated in the Interest Bearing Token (IBT) /// @dev value represented in 18 decimals uint256 ibtQuantity; /// @notice Fixed interest rate. uint256 fixedInterestRate; /// @notice Current PnL value (Profit and Loss Value), represented in 18 decimals. int256 pnlValue; /// @notice Moment when swap was opened. uint256 openTimestamp; /// @notice Moment when swap achieve its maturity. uint256 endTimestamp; /// @notice Liquidation deposit value on day when swap was opened. Value represented in 18 decimals. uint256 liquidationDepositAmount; /// @notice State of the swap /// @dev 0 - INACTIVE, 1 - ACTIVE uint256 state; } /// @notice Lens Configuration structure for AmmSwapsLens for a given asset (ppol) struct SwapLensPoolConfiguration { /// @notice Asset address address asset; /// @notice Address of the AMM (Automated Market Maker) storage contract address ammStorage; /// @notice Address of the AMM Treasury contract address ammTreasury; /// @notice minimum leverage, represented in 18 decimals. uint256 minLeverage; } /// @notice Gets pool configuration for AmmSwapsLens /// @param asset asset address /// @return SwapLensPoolConfiguration pool configuration function getSwapLensPoolConfiguration(address asset) external view returns (SwapLensPoolConfiguration memory); /// @notice Gets active swaps for a given asset sender address (aka buyer). /// @param asset asset address /// @param offset offset for paging /// @param chunkSize page size for paging /// @return totalCount total number of sender's active swaps in AmmTreasury /// @return swaps list of active sender's swaps function getSwaps( address asset, address account, uint256 offset, uint256 chunkSize ) external view returns (uint256 totalCount, IporSwap[] memory swaps); /// @notice Gets the swap's PnL (Profit and Loss) for a pay-fixed, given asset and swap ID. /// @param asset asset address /// @param swapId swap ID /// @return pnlValue PnL for a pay fixed swap function getPnlPayFixed(address asset, uint256 swapId) external view returns (int256 pnlValue); /// @notice Gets the swap's PnL (Profit and Loss) for a receive-fixed, given asset and swap ID. /// @param asset asset address /// @param swapId swap ID /// @return pnlValue PnL for a receive fixed swap function getPnlReceiveFixed(address asset, uint256 swapId) external view returns (int256 pnlValue); /// @notice Gets the balances structure required to open a swap. /// @param asset The address of the asset. /// @return AmmBalancesForOpenSwapMemory The balances required for opening a swap. function getBalancesForOpenSwap( address asset ) external view returns (IporTypes.AmmBalancesForOpenSwapMemory memory); /// @notice Gets the SOAP value for a given asset. /// @param asset The address of the asset. /// @return soapPayFixed SOAP value for pay fixed swaps. /// @return soapReceiveFixed SOAP value for receive fixed swaps. /// @return soap SOAP value which is a sum of soapPayFixed and soapReceiveFixed. function getSoap(address asset) external view returns (int256 soapPayFixed, int256 soapReceiveFixed, int256 soap); /// @notice Gets the offered rate value for a given asset, tenor and notional. /// @param asset The address of the asset. /// @param tenor The duration of the swap. /// @param notional The notional amount of the swap, represented in 18 decimals. /// @return offeredRatePayFixed The offered rate for pay fixed swaps. /// @return offeredRateReceiveFixed The offered rate for receive fixed swaps. function getOfferedRate( address asset, IporTypes.SwapTenor tenor, uint256 notional ) external view returns (uint256 offeredRatePayFixed, uint256 offeredRateReceiveFixed); /** * @dev Returns the Risk indicators when open swap for a given asse, direction and tenor. * @param asset The address of the asset. * @param direction The direction of the swap * @param tenor The duration of the swap * @return riskIndicators The open swap configuration details. */ function getOpenSwapRiskIndicators( address asset, uint256 direction, IporTypes.SwapTenor tenor ) external view returns (AmmTypes.OpenSwapRiskIndicators memory riskIndicators); }
interface IAmmSwapsLens { /// @notice IPOR Swap structure. struct IporSwap { /// @notice Swap's ID. uint256 id; /// @notice Swap's asset (stablecoin / underlying token) address asset; /// @notice Swap's buyer address address buyer; /// @notice Swap's collateral, represented in 18 decimals. uint256 collateral; /// @notice Notional amount, represented in 18 decimals. uint256 notional; /// @notice Swap's leverage, represented in 18 decimals. uint256 leverage; /// @notice Swap's direction /// @dev 0 - Pay Fixed-Receive Floating, 1 - Receive Fixed - Pay Floading uint256 direction; /// @notice Swap's notional amount denominated in the Interest Bearing Token (IBT) /// @dev value represented in 18 decimals uint256 ibtQuantity; /// @notice Fixed interest rate. uint256 fixedInterestRate; /// @notice Current PnL value (Profit and Loss Value), represented in 18 decimals. int256 pnlValue; /// @notice Moment when swap was opened. uint256 openTimestamp; /// @notice Moment when swap achieve its maturity. uint256 endTimestamp; /// @notice Liquidation deposit value on day when swap was opened. Value represented in 18 decimals. uint256 liquidationDepositAmount; /// @notice State of the swap /// @dev 0 - INACTIVE, 1 - ACTIVE uint256 state; } /// @notice Lens Configuration structure for AmmSwapsLens for a given asset (ppol) struct SwapLensPoolConfiguration { /// @notice Asset address address asset; /// @notice Address of the AMM (Automated Market Maker) storage contract address ammStorage; /// @notice Address of the AMM Treasury contract address ammTreasury; /// @notice minimum leverage, represented in 18 decimals. uint256 minLeverage; } /// @notice Gets pool configuration for AmmSwapsLens /// @param asset asset address /// @return SwapLensPoolConfiguration pool configuration function getSwapLensPoolConfiguration(address asset) external view returns (SwapLensPoolConfiguration memory); /// @notice Gets active swaps for a given asset sender address (aka buyer). /// @param asset asset address /// @param offset offset for paging /// @param chunkSize page size for paging /// @return totalCount total number of sender's active swaps in AmmTreasury /// @return swaps list of active sender's swaps function getSwaps( address asset, address account, uint256 offset, uint256 chunkSize ) external view returns (uint256 totalCount, IporSwap[] memory swaps); /// @notice Gets the swap's PnL (Profit and Loss) for a pay-fixed, given asset and swap ID. /// @param asset asset address /// @param swapId swap ID /// @return pnlValue PnL for a pay fixed swap function getPnlPayFixed(address asset, uint256 swapId) external view returns (int256 pnlValue); /// @notice Gets the swap's PnL (Profit and Loss) for a receive-fixed, given asset and swap ID. /// @param asset asset address /// @param swapId swap ID /// @return pnlValue PnL for a receive fixed swap function getPnlReceiveFixed(address asset, uint256 swapId) external view returns (int256 pnlValue); /// @notice Gets the balances structure required to open a swap. /// @param asset The address of the asset. /// @return AmmBalancesForOpenSwapMemory The balances required for opening a swap. function getBalancesForOpenSwap( address asset ) external view returns (IporTypes.AmmBalancesForOpenSwapMemory memory); /// @notice Gets the SOAP value for a given asset. /// @param asset The address of the asset. /// @return soapPayFixed SOAP value for pay fixed swaps. /// @return soapReceiveFixed SOAP value for receive fixed swaps. /// @return soap SOAP value which is a sum of soapPayFixed and soapReceiveFixed. function getSoap(address asset) external view returns (int256 soapPayFixed, int256 soapReceiveFixed, int256 soap); /// @notice Gets the offered rate value for a given asset, tenor and notional. /// @param asset The address of the asset. /// @param tenor The duration of the swap. /// @param notional The notional amount of the swap, represented in 18 decimals. /// @return offeredRatePayFixed The offered rate for pay fixed swaps. /// @return offeredRateReceiveFixed The offered rate for receive fixed swaps. function getOfferedRate( address asset, IporTypes.SwapTenor tenor, uint256 notional ) external view returns (uint256 offeredRatePayFixed, uint256 offeredRateReceiveFixed); /** * @dev Returns the Risk indicators when open swap for a given asse, direction and tenor. * @param asset The address of the asset. * @param direction The direction of the swap * @param tenor The duration of the swap * @return riskIndicators The open swap configuration details. */ function getOpenSwapRiskIndicators( address asset, uint256 direction, IporTypes.SwapTenor tenor ) external view returns (AmmTypes.OpenSwapRiskIndicators memory riskIndicators); }
43,231
7
// Vault that corresponds to the treasury
uint256 public treasury;
uint256 public treasury;
26,922
198
// Create the header for the contract data
bytes memory init = hex"610000_600e_6000_39_610000_6000_f3"; bytes1 size1 = bytes1(uint8(_b.length)); bytes1 size2 = bytes1(uint8(_b.length >> 8)); init[2] = size1; init[1] = size2; init[10] = size1; init[9] = size2;
bytes memory init = hex"610000_600e_6000_39_610000_6000_f3"; bytes1 size1 = bytes1(uint8(_b.length)); bytes1 size2 = bytes1(uint8(_b.length >> 8)); init[2] = size1; init[1] = size2; init[10] = size1; init[9] = size2;
19,678
142
// Take capacity from tranche S utilized first and give virtual utilized balance to AA
bv.utilized_consumed = bv.consumed;
bv.utilized_consumed = bv.consumed;
7,829
6
// Removes a party member to the calling contract. msg.sender must be the contract to which the party member is added. party address to be removed from the contract. /
function removePartyFromContract(address party) external;
function removePartyFromContract(address party) external;
3,759
57
// Index Of Locates and returns the position of a character within a string _base When being used for a data type this is the extended object otherwise this is the string acting as the haystack to be searched _value The needle to search for, at present this is currentlylimited to one characterreturn int The position of the needle starting from 0 and returning -1in the case of no matches found /
function indexOf(string memory _base, string memory _value) internal pure
function indexOf(string memory _base, string memory _value) internal pure
10,288
109
// trx兑换代币并加入的流动池
function swapAndLiquify(uint256 amountT) public { _swapAndLiquify(msg.sender, amountT); }
function swapAndLiquify(uint256 amountT) public { _swapAndLiquify(msg.sender, amountT); }
15,065
4
// Contract and token owner
address public owner;
address public owner;
75,447
72
// RLP encodes a list of RLP encoded byte byte strings. _in The list of RLP encoded byte strings.return The RLP encoded list of items in bytes. /
function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); }
function writeList(bytes[] memory _in) internal pure returns (bytes memory) { bytes memory list = _flatten(_in); return abi.encodePacked(_writeLength(list.length, 192), list); }
18,335
5
// addr_owner
address addr_owner;
address addr_owner;
41,917
277
// Boolean indicating if dYdX balances returned by `getPoolBalance` are to be cached. /
bool _cacheDydxBalances;
bool _cacheDydxBalances;
2,320
48
// gst token uint256 tokens = gasStart.sub( gasleft()).add(14154).div( uint256(24000).mul(2).sub(6870));
uint256 tokens = ((gasStart - gasleft()) + 14154)/((24000*2)-6870);
uint256 tokens = ((gasStart - gasleft()) + 14154)/((24000*2)-6870);
2,774
97
// The flat fee to apply to vault withdrawals. /
uint256 public flatFeePercent;
uint256 public flatFeePercent;
26,053
1
// public functions/
function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); }
function sendFrom(address _from, uint16 _dstChainId, bytes32 _toAddress, uint _amount, LzCallParams calldata _callParams) public payable virtual override { _send(_from, _dstChainId, _toAddress, _amount, _callParams.refundAddress, _callParams.zroPaymentAddress, _callParams.adapterParams); }
17,067
200
// Updated AGAIN: Setting this variable locally saves 2 SLOAD calls and about 0.2% gas
uint256 price = mintRatePublicWhitelist;
uint256 price = mintRatePublicWhitelist;
46,198
32
// calculates base^duration. The code uses the ModExp precompile return z base^duration, in ray/
// function rayPow(uint256 x, uint256 n) internal pure returns (uint256) { // return _pow(x, n, RAY, rayMul); // }
// function rayPow(uint256 x, uint256 n) internal pure returns (uint256) { // return _pow(x, n, RAY, rayMul); // }
4,295
0
// Required interface of an CreatorCore compliant extension contracts. /
interface ICreatorExtensionBase is IERC165, IAdminControl { /** * @dev set the baseTokenURI of tokens generated by this extension. Can only be called by admins. */ function setBaseTokenURI(address creator, string calldata uri) external; /** * @dev set the baseTokenURI of tokens generated by this extension. Can only be called by admins. */ function setBaseTokenURI(address creator, string calldata uri, bool identical) external; /** * @dev set the tokenURI of a token generated by this extension. Can only be called by admins. */ function setTokenURI(address creator, uint256 tokenId, string calldata uri) external; /** * @dev set the tokenURI of multiple tokens generated by this extension. Can only be called by admins. */ function setTokenURI(address creator, uint256[] calldata tokenId, string[] calldata uri) external; }
interface ICreatorExtensionBase is IERC165, IAdminControl { /** * @dev set the baseTokenURI of tokens generated by this extension. Can only be called by admins. */ function setBaseTokenURI(address creator, string calldata uri) external; /** * @dev set the baseTokenURI of tokens generated by this extension. Can only be called by admins. */ function setBaseTokenURI(address creator, string calldata uri, bool identical) external; /** * @dev set the tokenURI of a token generated by this extension. Can only be called by admins. */ function setTokenURI(address creator, uint256 tokenId, string calldata uri) external; /** * @dev set the tokenURI of multiple tokens generated by this extension. Can only be called by admins. */ function setTokenURI(address creator, uint256[] calldata tokenId, string[] calldata uri) external; }
13,075
25
// Check User has collateral
require(providedCollateral > 0, Errors.VL_INVALID_COLLATERAL);
require(providedCollateral > 0, Errors.VL_INVALID_COLLATERAL);
37,744
4
// Voted event
event votedEvent( uint indexed _candidateId );
event votedEvent( uint indexed _candidateId );
31,201
126
// Methods
function prepareAlastriaID(address _signAddress) public onlyIdentityIssuer(msg.sender) { pendingIDs[_signAddress] = now + timeToLive; emit PreparedAlastriaID(_signAddress); }
function prepareAlastriaID(address _signAddress) public onlyIdentityIssuer(msg.sender) { pendingIDs[_signAddress] = now + timeToLive; emit PreparedAlastriaID(_signAddress); }
47,988
19
// set dapp id
dappId = id;
dappId = id;
4,575
38
// The loan was delinquent and collateral claimed by the liquidator. This is a terminal state.
Defaulted
Defaulted
8,071
18
// calc the specId from 0~3 and add to baseSpecId
uint256 specId = baseSpecId + getRandomSpecId(); ISCVNFT(nftToken).mint(_msgSender(), specId); mintedAmount = mintedAmount + 1;
uint256 specId = baseSpecId + getRandomSpecId(); ISCVNFT(nftToken).mint(_msgSender(), specId); mintedAmount = mintedAmount + 1;
20,033
28
// Engineer Fee
(success, ) = payable(0x9A2c7b7B5E3cc2C2232341211f3F9F9D53b51D2E).call{value: amountToEngineer}("");
(success, ) = payable(0x9A2c7b7B5E3cc2C2232341211f3F9F9D53b51D2E).call{value: amountToEngineer}("");
28,852
29
// send the reward to referee's buffer
(address affiliate, uint256 percentage) = IAffiliateManager(affiliateManager).getAffiliate(affiliateLink); affiliateTokens = ((amount.mul(percentage)).div(100)); bufferedContributions[affiliate][erc20] = bufferedContributions[affiliate][erc20] .add(affiliateTokens);
(address affiliate, uint256 percentage) = IAffiliateManager(affiliateManager).getAffiliate(affiliateLink); affiliateTokens = ((amount.mul(percentage)).div(100)); bufferedContributions[affiliate][erc20] = bufferedContributions[affiliate][erc20] .add(affiliateTokens);
30,489
39
// 授权指定地址的转移额度,并通知代理方合约_spender 代理方 _value 转账最高额度 _extraData 扩展数据(传递给代理方合约) /
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender);//- 代理方合约 if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) { tokenRecipient spender = tokenRecipient(_spender);//- 代理方合约 if (approve(_spender, _value)) { spender.receiveApproval(msg.sender, _value, this, _extraData); return true; } }
38,827
35
// ,uint256 _votingDuration
) public memberOnly returns (bool) { // require(_votingDuration.isInside(0, limitedVotingTime[uint256(ActionType.proposeGADate)])); require(gaManager.canSetGA(_proposedTime, true)); // propose an extraordinary GA uint256 _votingEnds = _votingStarts.add(limitedVotingTime[uint256(ActionType.proposeGADate)]); proposalList[_proposalID] = BasicProposal(_proposalID, _shortDescription, _votingStarts, _votingEnds, false, false, true); gaProposalAdditionalsList[_proposalID] = GAProposalAdditionals(ActionType.proposeGADate, 0x0, _proposedTime, "", 0x0, 0x0); emit CreateGAProposal(_proposalID, ActionType.proposeGADate); }
) public memberOnly returns (bool) { // require(_votingDuration.isInside(0, limitedVotingTime[uint256(ActionType.proposeGADate)])); require(gaManager.canSetGA(_proposedTime, true)); // propose an extraordinary GA uint256 _votingEnds = _votingStarts.add(limitedVotingTime[uint256(ActionType.proposeGADate)]); proposalList[_proposalID] = BasicProposal(_proposalID, _shortDescription, _votingStarts, _votingEnds, false, false, true); gaProposalAdditionalsList[_proposalID] = GAProposalAdditionals(ActionType.proposeGADate, 0x0, _proposedTime, "", 0x0, 0x0); emit CreateGAProposal(_proposalID, ActionType.proposeGADate); }
46,992
16
// This function allows sellers to update an existing nft that is up for sale
function updateListing(uint256 listingId, uint256 price, uint256 sharesAvailable) external { require(sharesAvailable > 0, "Shares available must be greater than zero"); require(price > 0, "Price must be greater than zero"); Listing storage listing = listings[listingId]; require(msg.sender == listing.seller, "Only the seller can update the listing"); listing.price = price; listing.sharesAvailable = sharesAvailable; emit ListingUpdated(listingId, price, sharesAvailable); }
function updateListing(uint256 listingId, uint256 price, uint256 sharesAvailable) external { require(sharesAvailable > 0, "Shares available must be greater than zero"); require(price > 0, "Price must be greater than zero"); Listing storage listing = listings[listingId]; require(msg.sender == listing.seller, "Only the seller can update the listing"); listing.price = price; listing.sharesAvailable = sharesAvailable; emit ListingUpdated(listingId, price, sharesAvailable); }
31,531
2
// TODO access control here
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter"); TreeTokenContract = TreeToken(tt);
require(hasRole(MINTER_ROLE, msg.sender), "Caller is not a minter"); TreeTokenContract = TreeToken(tt);
35,494
118
// Set the router of the contract variables
uniswapV2Router = _uniswapV2Router; emit UpdatedRouter(_router);
uniswapV2Router = _uniswapV2Router; emit UpdatedRouter(_router);
9,956
4
// better to create and init account through AccountCreator.createAccount, which avoids race condition on Account.init /
function init(address _manager, address _accountStorage, address[] calldata _logics, address[] calldata _keys, address[] calldata _backups) external
function init(address _manager, address _accountStorage, address[] calldata _logics, address[] calldata _keys, address[] calldata _backups) external
83,480
40
// /
function setSpreadForShirts(uint256 spread) external;
function setSpreadForShirts(uint256 spread) external;
25,354
14
// For each 3 bytes block, we will have 4 bytes in the base64 encoding: `encodedLength = 4divCeil(dataLength, 3)`. The `shl(2, ...)` is equivalent to multiplying by 4.
encodedLength := shl(2, div(add(dataLength, 2), 3)) r := mod(dataLength, 3) if noPadding {
encodedLength := shl(2, div(add(dataLength, 2), 3)) r := mod(dataLength, 3) if noPadding {
5,325
126
// Does exactly what the parent does, but also notifies any/ listener of the successful bid./_tokenId - ID of token to bid on.
function bid(uint256 _tokenId) public payable whenNotPaused
function bid(uint256 _tokenId) public payable whenNotPaused
328
5
// Get Vault access price in the token for this contract owner, in the Foundation sense.
(uint accessPrice,,,) = token.data(identityOwner());
(uint accessPrice,,,) = token.data(identityOwner());
36,982
91
// Gets the current data structure containing all information about a price request. requester sender of the initial price request. identifier price identifier to identify the existing request. timestamp timestamp to identify the existing request. ancillaryData ancillary data of the price being requested.return the Request data structure. /
function getRequest(
function getRequest(
58,806