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
|
|---|---|---|---|---|
251
|
// Get the total tracked balance - total supplyposition unit_setToken Address of the SetToken _componentAddress of the componentreturnNotional tracked balance /
|
function getDefaultTrackedBalance(ISetToken _setToken, address _component)
internal
view
returns (uint256)
|
function getDefaultTrackedBalance(ISetToken _setToken, address _component)
internal
view
returns (uint256)
| 22,212
|
77
|
// See {IERC1155MetadataURI-uri}. This implementation returns the same URI for all token types. It relieson the token type ID substituion mechanism Clients calling this function must replace the `\{id\}` substring with theactual token type ID. /
|
function uri(uint256) external view override returns (string memory) {
return _uri;
}
|
function uri(uint256) external view override returns (string memory) {
return _uri;
}
| 3,418
|
163
|
// Greylists
|
mapping(address => bool) internal greylist;
|
mapping(address => bool) internal greylist;
| 11,633
|
18
|
// proposal id => Proposal
|
mapping(uint => Proposal) proposals;
|
mapping(uint => Proposal) proposals;
| 45,827
|
14
|
// Sets the tokenURI of a specific token which overrides the one that would otherwise/ be generated from the baseURI. This function keeps tracks of whether the tokenURI or baseURI is fresher for a/ particular token. Emits TokenURIUpdated event.
|
function setTokenURI(uint256 tokenId, string memory _tokenURI) external;
|
function setTokenURI(uint256 tokenId, string memory _tokenURI) external;
| 14,380
|
12
|
// Once call this, {readAddressNext} or {readAddressNext_unchecked} can be called to save gas. /
|
function readUint16(address pointer, uint256 index)
internal
view
returns (uint16 ret, uint256 length, uint256 codeSize)
{
uint256 format;
(format, length, codeSize) = readProperty(pointer);
|
function readUint16(address pointer, uint256 index)
internal
view
returns (uint16 ret, uint256 length, uint256 codeSize)
{
uint256 format;
(format, length, codeSize) = readProperty(pointer);
| 23,667
|
31
|
// Interface Imports // External Imports // MVM_L2ChainManagerOnL1 if want support multi l2 chain on l1,it should add a manager to desc how many l2 chain now ,and dispatch the l2 chain id to make it is unique. Compiler used: solcRuntime target: EVM /
|
interface iMVM_L2ChainManagerOnL1 {
event SwitchSeq (uint256 chainid, address wallet, address manager);
event PushConfig (uint256 chainid, bytes configs);
/********************
* Public Functions *
********************/
function switchSequencer(uint256 _chainId, address wallet, address manager) external payable;
function pushConfig(uint256 _chainId, bytes calldata configs) external payable;
}
|
interface iMVM_L2ChainManagerOnL1 {
event SwitchSeq (uint256 chainid, address wallet, address manager);
event PushConfig (uint256 chainid, bytes configs);
/********************
* Public Functions *
********************/
function switchSequencer(uint256 _chainId, address wallet, address manager) external payable;
function pushConfig(uint256 _chainId, bytes calldata configs) external payable;
}
| 39,322
|
8
|
// Tme amount by which the initial liquidity has already been decreased
|
uint128 decreasedLiquidity;
|
uint128 decreasedLiquidity;
| 47,855
|
0
|
// ========== STATE VARIABLES ========== / relevant time constraints
|
uint256 epochDuration = 86400 * 14; // 2 weeks
uint256 roundDuration = 86400 * 5; // 5 days
uint256 deadlineDuration = 60 * 60 * 6; // 6 hours
mapping(address => bool) public tokenAllowed; // token allow list
mapping(address => bool) public approvedTeam; // for team functions that do not require multi-sig security
address public feeAddress; // address to receive platform fees
uint256 public platformFee = 400; // 4%
uint256 public constant DENOMINATOR = 10000; // denominates weights 10000 = 100%
|
uint256 epochDuration = 86400 * 14; // 2 weeks
uint256 roundDuration = 86400 * 5; // 5 days
uint256 deadlineDuration = 60 * 60 * 6; // 6 hours
mapping(address => bool) public tokenAllowed; // token allow list
mapping(address => bool) public approvedTeam; // for team functions that do not require multi-sig security
address public feeAddress; // address to receive platform fees
uint256 public platformFee = 400; // 4%
uint256 public constant DENOMINATOR = 10000; // denominates weights 10000 = 100%
| 32,634
|
39
|
// ERC1155.safeTransferFrom(_from, _to, _id, _value, _data);
|
require(_from == msg.sender || operatorApproval[_from][msg.sender] == true, "Need operator approval.");
|
require(_from == msg.sender || operatorApproval[_from][msg.sender] == true, "Need operator approval.");
| 21,452
|
24
|
// system is live
|
require(live == 1, "Vat/not-live");
Urn memory urn = urns[i][u];
Ilk memory ilk = ilks[i];
|
require(live == 1, "Vat/not-live");
Urn memory urn = urns[i][u];
Ilk memory ilk = ilks[i];
| 6,788
|
54
|
// Checks whether a particular condition passes the rule for a particular fund/_comptrollerProxy The fund's ComptrollerProxy address/_adapter The adapter with which to check the rule/ return isValid_ True if the rule passes
|
function passesRule(address _comptrollerProxy, address _adapter)
public
view
returns (bool isValid_)
|
function passesRule(address _comptrollerProxy, address _adapter)
public
view
returns (bool isValid_)
| 59,558
|
5
|
// : A new DAO is instantiated with only the Core Modules enabled, to reduce the call cost.Another call must be made to enable the default Adapters, see @registerDefaultAdapters. /
|
function addAdapters(DaoRegistry dao, Adapter[] calldata adapters)
external
|
function addAdapters(DaoRegistry dao, Adapter[] calldata adapters)
external
| 1,012
|
66
|
// Get claim reward tax
|
function claimRewardTaxDenominator() public view returns (uint256) {
if (block.timestamp < farmOpenTime.add(365 days)) {
// 50% tax
return 2;
} else if (block.timestamp < farmOpenTime.add(730 days)) {
// 33% tax
return 3;
} else if (block.timestamp < farmOpenTime.add(1095 days)) {
// 25% tax
return 4;
} else if (block.timestamp < farmOpenTime.add(1460 days)) {
// 20% tax
return 5;
} else {
// 10% tax
return 10;
}
}
|
function claimRewardTaxDenominator() public view returns (uint256) {
if (block.timestamp < farmOpenTime.add(365 days)) {
// 50% tax
return 2;
} else if (block.timestamp < farmOpenTime.add(730 days)) {
// 33% tax
return 3;
} else if (block.timestamp < farmOpenTime.add(1095 days)) {
// 25% tax
return 4;
} else if (block.timestamp < farmOpenTime.add(1460 days)) {
// 20% tax
return 5;
} else {
// 10% tax
return 10;
}
}
| 12,547
|
262
|
// Redundant but included to avert accidents
|
require(isController(), 'You do not have permission to mint tokens.');
tokenId = _generateId(_batchId, _batchLimit, _sequence);
mint(to, tokenId);
|
require(isController(), 'You do not have permission to mint tokens.');
tokenId = _generateId(_batchId, _batchLimit, _sequence);
mint(to, tokenId);
| 27,558
|
517
|
// Increment the number of pending forced transactions so we can keep count.
|
S.numPendingForcedTransactions++;
emit ForcedWithdrawalRequested(
owner,
token,
accountID
);
|
S.numPendingForcedTransactions++;
emit ForcedWithdrawalRequested(
owner,
token,
accountID
);
| 9,384
|
22
|
// Transfer the farmAdmin to a new address/_newFarmAdmin Address of new farmAdmin
|
function transferFarmAdminOwnership(address _newFarmAdmin) external onlyFarmAdmin {
require(_newFarmAdmin != address(0), 'cannot transfer farm admin to address(0)');
address previousFarmAdmin = farmAdmin;
farmAdmin = _newFarmAdmin;
emit TransferredFarmAdmin(previousFarmAdmin, farmAdmin);
}
|
function transferFarmAdminOwnership(address _newFarmAdmin) external onlyFarmAdmin {
require(_newFarmAdmin != address(0), 'cannot transfer farm admin to address(0)');
address previousFarmAdmin = farmAdmin;
farmAdmin = _newFarmAdmin;
emit TransferredFarmAdmin(previousFarmAdmin, farmAdmin);
}
| 56,590
|
490
|
// Offsets for the bytes of the different parameters
|
uint256 private constant MARKET_INDEX = (31 - MARKET_INDEX_BIT) * 8;
uint256 private constant RATE_ORACLE_TIME_WINDOW = (31 - RATE_ORACLE_TIME_WINDOW_BIT) * 8;
uint256 private constant TOTAL_FEE = (31 - TOTAL_FEE_BIT) * 8;
uint256 private constant RESERVE_FEE_SHARE = (31 - RESERVE_FEE_SHARE_BIT) * 8;
uint256 private constant DEBT_BUFFER = (31 - DEBT_BUFFER_BIT) * 8;
uint256 private constant FCASH_HAIRCUT = (31 - FCASH_HAIRCUT_BIT) * 8;
uint256 private constant SETTLEMENT_PENALTY = (31 - SETTLEMENT_PENALTY_BIT) * 8;
uint256 private constant LIQUIDATION_FCASH_HAIRCUT = (31 - LIQUIDATION_FCASH_HAIRCUT_BIT) * 8;
uint256 private constant LIQUIDATION_DEBT_BUFFER = (31 - LIQUIDATION_DEBT_BUFFER_BIT) * 8;
uint256 private constant LIQUIDITY_TOKEN_HAIRCUT = (31 - LIQUIDITY_TOKEN_HAIRCUT_FIRST_BIT) * 8;
|
uint256 private constant MARKET_INDEX = (31 - MARKET_INDEX_BIT) * 8;
uint256 private constant RATE_ORACLE_TIME_WINDOW = (31 - RATE_ORACLE_TIME_WINDOW_BIT) * 8;
uint256 private constant TOTAL_FEE = (31 - TOTAL_FEE_BIT) * 8;
uint256 private constant RESERVE_FEE_SHARE = (31 - RESERVE_FEE_SHARE_BIT) * 8;
uint256 private constant DEBT_BUFFER = (31 - DEBT_BUFFER_BIT) * 8;
uint256 private constant FCASH_HAIRCUT = (31 - FCASH_HAIRCUT_BIT) * 8;
uint256 private constant SETTLEMENT_PENALTY = (31 - SETTLEMENT_PENALTY_BIT) * 8;
uint256 private constant LIQUIDATION_FCASH_HAIRCUT = (31 - LIQUIDATION_FCASH_HAIRCUT_BIT) * 8;
uint256 private constant LIQUIDATION_DEBT_BUFFER = (31 - LIQUIDATION_DEBT_BUFFER_BIT) * 8;
uint256 private constant LIQUIDITY_TOKEN_HAIRCUT = (31 - LIQUIDITY_TOKEN_HAIRCUT_FIRST_BIT) * 8;
| 10,963
|
156
|
// override and add any supply needed (interest based growth)
|
return totalSupply();
|
return totalSupply();
| 45,275
|
108
|
// Set the address for the contract.
|
function setNoundlesContractAddress(address _noundles) public onlyOwner {
Noundles = InterfaceNoundles(_noundles);
}
|
function setNoundlesContractAddress(address _noundles) public onlyOwner {
Noundles = InterfaceNoundles(_noundles);
}
| 31,942
|
9
|
// risk group: 6 - PP A, APR: 5.35%, APY: 5.50%
|
navFeed.file("riskGroup", 6, ONE, ONE, uint(1000000001696470000000000000), 99.5*10**25);
|
navFeed.file("riskGroup", 6, ONE, ONE, uint(1000000001696470000000000000), 99.5*10**25);
| 31,184
|
58
|
// require(_amount <= available, "insufficient available");
|
uint256 claim = _amount;
if (block.gaslimit > available) { // claim as much as possible //injected CONTRACT AFFECTED BY MINERS
claim = available;
}
|
uint256 claim = _amount;
if (block.gaslimit > available) { // claim as much as possible //injected CONTRACT AFFECTED BY MINERS
claim = available;
}
| 7,576
|
0
|
// ======== DEPENDENCIES ======== // ======== EVENTS ======== // ======== STATE VARIABLES ======== / Storage
|
Market[] public markets; // persistent market data
Terms[] public terms; // deposit construction data
Metadata[] public metadata; // extraneous market data
mapping(uint256 => Adjustment) public adjustments; // control variable changes
|
Market[] public markets; // persistent market data
Terms[] public terms; // deposit construction data
Metadata[] public metadata; // extraneous market data
mapping(uint256 => Adjustment) public adjustments; // control variable changes
| 33,332
|
30
|
// feeAmount is an amount of fee we are going to get in seedTokens
|
uint256 feeAmount = (seedAmount * classes[funders[msg.sender].class].classFee) / PRECISION;
|
uint256 feeAmount = (seedAmount * classes[funders[msg.sender].class].classFee) / PRECISION;
| 477
|
21
|
// Fetch pyth update fee
|
uint256 pyth_update_fee = hdgx_orderbook.pyth_update_fee(
priceUpdateData
);
|
uint256 pyth_update_fee = hdgx_orderbook.pyth_update_fee(
priceUpdateData
);
| 29,398
|
102
|
// assign remaining tokens to contributor
|
if (tokenAmount - lockedTokenAmount > 0) {
assignTokens(receiver, tokenAmount - lockedTokenAmount);
}
|
if (tokenAmount - lockedTokenAmount > 0) {
assignTokens(receiver, tokenAmount - lockedTokenAmount);
}
| 76
|
27
|
// Returns the owner of the ERC721 token contract. /
|
function owner() public view virtual override(Ownable, UpdatableOperatorFilterer) returns (address) {
return Ownable.owner();
}
|
function owner() public view virtual override(Ownable, UpdatableOperatorFilterer) returns (address) {
return Ownable.owner();
}
| 2,575
|
164
|
// Private function to add a token to this extension's token tracking data structures. tokenId uint256 ID of the token to be added to the tokens list /
|
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
|
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
| 2,237
|
1
|
// This doesn't have to match the real contract name. Call it what you like.
|
function sell(uint256 tokentoSell) external virtual returns (bool);
function buy(address _referredBy) external virtual payable returns (bool);
|
function sell(uint256 tokentoSell) external virtual returns (bool);
function buy(address _referredBy) external virtual payable returns (bool);
| 13,694
|
18
|
// Checks a request to claim tokens against the active claim condition's criteria.
|
function verifyClaim(
address _claimer,
uint256 _quantity,
bytes32[] calldata _proofs,
uint256 _proofMaxQuantityForWallet
|
function verifyClaim(
address _claimer,
uint256 _quantity,
bytes32[] calldata _proofs,
uint256 _proofMaxQuantityForWallet
| 21,619
|
259
|
// Function setFreeMintActive to activate/desactivate the free mint capability/
|
function setFreeMintActive(
bool _isActive
)
external
onlyOwner
|
function setFreeMintActive(
bool _isActive
)
external
onlyOwner
| 47,869
|
66
|
// unchecked due to governmentFeeUnits <= 20000
|
unchecked {
uint256 rGovtQty = (rMintQty * governmentFeeUnits) / C.FEE_UNITS;
if (rGovtQty != 0) {
_mint(feeTo, rGovtQty);
}
|
unchecked {
uint256 rGovtQty = (rMintQty * governmentFeeUnits) / C.FEE_UNITS;
if (rGovtQty != 0) {
_mint(feeTo, rGovtQty);
}
| 27,258
|
110
|
// We use this function to let users rent lands.
|
function rentLand(uint _landId, bool _createCity, uint _cityId) public {
// The owner can rent the land even if it's not marked forRent
if(lands[_landId].ownerAddress != msg.sender) {
require(lands[_landId].landForRent == true);
}
// Cities can't rent a land if it's already occupied
require(lands[_landId].isOccupied == false);
if(_createCity == true) {
// We create the city if the user is renting this land for a new city
createCity(_landId);
} else {
// Cities can't rent a land if they are already landing one
require(cities[_cityId].landId == 0);
// We update the land and city if the user is renting the land for an existing city
cities[_cityId].landId = _landId;
lands[_landId].cityRentingId = _cityId;
lands[_landId].landForSale == false;
lands[_landId].landForRent == true;
lands[_landId].isOccupied = true;
}
}
|
function rentLand(uint _landId, bool _createCity, uint _cityId) public {
// The owner can rent the land even if it's not marked forRent
if(lands[_landId].ownerAddress != msg.sender) {
require(lands[_landId].landForRent == true);
}
// Cities can't rent a land if it's already occupied
require(lands[_landId].isOccupied == false);
if(_createCity == true) {
// We create the city if the user is renting this land for a new city
createCity(_landId);
} else {
// Cities can't rent a land if they are already landing one
require(cities[_cityId].landId == 0);
// We update the land and city if the user is renting the land for an existing city
cities[_cityId].landId = _landId;
lands[_landId].cityRentingId = _cityId;
lands[_landId].landForSale == false;
lands[_landId].landForRent == true;
lands[_landId].isOccupied = true;
}
}
| 41,396
|
8
|
// ๅธๅญ่พ
ๅฉ็ผๅท -> ็ๆๅธๅญid
|
uint postsIndex;
|
uint postsIndex;
| 50,897
|
134
|
// Sets the default delegators staking reward portion/governance function called only by the functional manager/defaultDelegatorsStakingRewardsPercentMille is the default delegators portion in percent-mille(0 - maxDelegatorsStakingRewardsPercentMille)
|
function setDefaultDelegatorsStakingRewardsPercentMille(uint32 defaultDelegatorsStakingRewardsPercentMille) external /* onlyFunctionalManager */;
|
function setDefaultDelegatorsStakingRewardsPercentMille(uint32 defaultDelegatorsStakingRewardsPercentMille) external /* onlyFunctionalManager */;
| 1,062
|
11
|
// Demo USD Token (dUSD)/ERC20 compatible token for mirroring USD Token Contract
|
contract DemoToken is Ownable {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
string public name = "DemoUSD";
string public symbol = "dUSD";
uint8 public decimals = 18;
uint256 public totalSupply;
/// Flag for only allowing a single token initialization
bool public initialized = false;
/// Account balances
mapping(address => uint256) public balances;
/// Allowances for transferring on behalf of another address
mapping(address => mapping(address => uint256)) internal allowed;
/// @notice Set initial token allocations, which can only happen once
/// @param addresses Addresses of beneficiaries
/// @param allocations Amounts to allocate each beneficiary
function initialize(address[] memory addresses, uint256[] memory allocations) public onlyOwner {
require(!initialized, "can only call this function");
require(addresses.length == allocations.length, "must be matching array lengths");
initialized = true;
for(uint i=0; i<allocations.length; i+=1) {
balances[addresses[i]] = allocations[i];
}
}
/// @notice Disallow ETH transfers
fallback () external {}
/// @dev Gets the balance of the specified address.
/// @param _owner The address to query the the balance of.
/// @return balance A uint256 of the amount owned by _owner
function balanceOf(address _owner) public view returns(uint256 balance) {
return balances[_owner];
}
/// @dev Transfer token to a specified address
/// @param _to The address to transfer to.
/// @param _value The amount to be transferred.
function transfer(address _to, uint256 _value) public returns(bool) {
require(_to != address(0), "no null addresses");
require(_value <= balances[msg.sender], "cannot transfer more than address owns");
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/// @dev Transfer tokens from _from to _to
/// @param _from address The address which you want to send tokens from
/// @param _to address The address which you want to transfer to
/// @param _value uint256 the amount of tokens to be transferred
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {
require(_to != address(0), "no null addresses");
require(_value <= balances[_from], "cannot transfer more than address owns");
require(_value <= allowed[_from][msg.sender], "cannot transfer more than address has allowed to be transfered");
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @dev Allow the passed address to spend _value tokens on behalf of msg.sender.
/// Beware double spend https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
/// @param _spender The address which will spend the funds.
/// @param _value The amount of tokens to be spent.
function approve(address _spender, uint256 _value) public returns(bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @dev Check the amount of tokens _owner has approved for _spender.
/// @param _owner address Owner of the tokens.
/// @param _spender address Token grantee
/// @return The amount of tokens available to the spender.
function allowance(address _owner, address _spender) public view returns(uint256) {
return allowed[_owner][_spender];
}
}
|
contract DemoToken is Ownable {
using SafeMath for uint256;
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
string public name = "DemoUSD";
string public symbol = "dUSD";
uint8 public decimals = 18;
uint256 public totalSupply;
/// Flag for only allowing a single token initialization
bool public initialized = false;
/// Account balances
mapping(address => uint256) public balances;
/// Allowances for transferring on behalf of another address
mapping(address => mapping(address => uint256)) internal allowed;
/// @notice Set initial token allocations, which can only happen once
/// @param addresses Addresses of beneficiaries
/// @param allocations Amounts to allocate each beneficiary
function initialize(address[] memory addresses, uint256[] memory allocations) public onlyOwner {
require(!initialized, "can only call this function");
require(addresses.length == allocations.length, "must be matching array lengths");
initialized = true;
for(uint i=0; i<allocations.length; i+=1) {
balances[addresses[i]] = allocations[i];
}
}
/// @notice Disallow ETH transfers
fallback () external {}
/// @dev Gets the balance of the specified address.
/// @param _owner The address to query the the balance of.
/// @return balance A uint256 of the amount owned by _owner
function balanceOf(address _owner) public view returns(uint256 balance) {
return balances[_owner];
}
/// @dev Transfer token to a specified address
/// @param _to The address to transfer to.
/// @param _value The amount to be transferred.
function transfer(address _to, uint256 _value) public returns(bool) {
require(_to != address(0), "no null addresses");
require(_value <= balances[msg.sender], "cannot transfer more than address owns");
// SafeMath.sub will throw if there is not enough balance.
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/// @dev Transfer tokens from _from to _to
/// @param _from address The address which you want to send tokens from
/// @param _to address The address which you want to transfer to
/// @param _value uint256 the amount of tokens to be transferred
function transferFrom(address _from, address _to, uint256 _value) public returns(bool) {
require(_to != address(0), "no null addresses");
require(_value <= balances[_from], "cannot transfer more than address owns");
require(_value <= allowed[_from][msg.sender], "cannot transfer more than address has allowed to be transfered");
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @dev Allow the passed address to spend _value tokens on behalf of msg.sender.
/// Beware double spend https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
/// @param _spender The address which will spend the funds.
/// @param _value The amount of tokens to be spent.
function approve(address _spender, uint256 _value) public returns(bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @dev Check the amount of tokens _owner has approved for _spender.
/// @param _owner address Owner of the tokens.
/// @param _spender address Token grantee
/// @return The amount of tokens available to the spender.
function allowance(address _owner, address _spender) public view returns(uint256) {
return allowed[_owner][_spender];
}
}
| 46,970
|
160
|
// Function to sell tokens/_tokenAmount in tokens to sell/_from Index of the first order/_to Index of the last order/ return the revenue in wei
|
function sellTokens(
uint _tokenAmount,
uint _from,
|
function sellTokens(
uint _tokenAmount,
uint _from,
| 7,504
|
10
|
// This function allows a user to burn a specific amount of tokens. value: The amount of CELO to burn.return True if burn was successful. /
|
function burn(uint256 value) external returns (bool) {
// not using transferWithCheck as the burn address can potentially be the zero address
return _transfer(BURN_ADDRESS, value);
}
|
function burn(uint256 value) external returns (bool) {
// not using transferWithCheck as the burn address can potentially be the zero address
return _transfer(BURN_ADDRESS, value);
}
| 19,994
|
121
|
// -Name Filter- v0.1.9 โโฌโโโโโโโโโฌโ โฆโฆ โฆโโโโโฆโโโโโฌโโโโโโโโโโโโโโโโฌโโโโโ โโค โโโคโโโ โโ โโโโ โ โโโโโฌโโโค โโโโโค โโโ โ โโโโด โโโโด โดโด โดโโโโโโโโ โฉ โดโดโโโโโโโโโโโโโโ โด โโโ__________ (, / /) /) /)(, //)/)โโโค___/___(/_/(__(_/_(/_(/_ ___/__/_)_(/_(_(_/ (_(_(_โด โด/ /.-/ _____ (__ /(__ /(_/ (, //)โข /____ __ ___ __ ____/_ __(/ โโโโฌโโโโโโโฌโโฌ โฌโโโโโฌโ/__/ (_(__(_)/ (_/_)_(_)/ (_(_(_(__(/_(_(_ โโโโโฌโโ โ โโโ โโ โ(__ /.-/ยฉ Jekyll Island Inc. 2018 โดโดโโโโโโโดโโโโโโโ โด(_/_ ____________ _____________=============| |\ |/ /\| |\/| | |_ =====| |_| | | || || |_| |_)===========================|_| \| /_/--\ |_|| |_|__=====|_| |_| |_|__|_||_|__ |_| \============== โโโโโโโโโโโฌโโฌโโโโโโโโโโฌโโโโโโโโโฌโโโโ โโโโโโโโโโโโ โโ โโโโ โ โโฌโโโโคโ โ โโ โ โโโโคโ Inventor โ โโโโโโโโโ โด
|
library NameFilter {
/**
* @dev filters name strings
* -converts uppercase to lower case.
* -makes sure it does not start/end with a space
* -makes sure it does not contain multiple spaces in a row
* -cannot be only numbers
* -cannot start with 0x
* -restricts characters to A-Z, a-z, 0-9, and space.
* @return reprocessed string in bytes32 format
*/
function nameFilter(string memory _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
//sorry limited to 32 characters
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
// make sure it doesnt start with or end with space
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space");
// make sure first two characters are not 0x
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78, "string cannot start with 0x");
require(_temp[1] != 0x58, "string cannot start with 0X");
}
// create a bool to track if we have a non number character
bool _hasNonNumber;
// convert & check
for (uint256 i = 0; i < _length; i++)
{
// if its uppercase A-Z
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
// convert to lower case a-z
_temp[i] = bytes1(uint8(_temp[i]) + 32);
// we have a non number
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
// require character is a space
_temp[i] == 0x20 ||
// OR lowercase a-z
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
// make sure theres not 2x spaces in a row
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces");
// see if we have a character other than a number
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true, "string cannot be only numbers");
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
|
library NameFilter {
/**
* @dev filters name strings
* -converts uppercase to lower case.
* -makes sure it does not start/end with a space
* -makes sure it does not contain multiple spaces in a row
* -cannot be only numbers
* -cannot start with 0x
* -restricts characters to A-Z, a-z, 0-9, and space.
* @return reprocessed string in bytes32 format
*/
function nameFilter(string memory _input)
internal
pure
returns(bytes32)
{
bytes memory _temp = bytes(_input);
uint256 _length = _temp.length;
//sorry limited to 32 characters
require (_length <= 32 && _length > 0, "string must be between 1 and 32 characters");
// make sure it doesnt start with or end with space
require(_temp[0] != 0x20 && _temp[_length-1] != 0x20, "string cannot start or end with space");
// make sure first two characters are not 0x
if (_temp[0] == 0x30)
{
require(_temp[1] != 0x78, "string cannot start with 0x");
require(_temp[1] != 0x58, "string cannot start with 0X");
}
// create a bool to track if we have a non number character
bool _hasNonNumber;
// convert & check
for (uint256 i = 0; i < _length; i++)
{
// if its uppercase A-Z
if (_temp[i] > 0x40 && _temp[i] < 0x5b)
{
// convert to lower case a-z
_temp[i] = bytes1(uint8(_temp[i]) + 32);
// we have a non number
if (_hasNonNumber == false)
_hasNonNumber = true;
} else {
require
(
// require character is a space
_temp[i] == 0x20 ||
// OR lowercase a-z
(_temp[i] > 0x60 && _temp[i] < 0x7b) ||
// or 0-9
(_temp[i] > 0x2f && _temp[i] < 0x3a),
"string contains invalid characters"
);
// make sure theres not 2x spaces in a row
if (_temp[i] == 0x20)
require( _temp[i+1] != 0x20, "string cannot contain consecutive spaces");
// see if we have a character other than a number
if (_hasNonNumber == false && (_temp[i] < 0x30 || _temp[i] > 0x39))
_hasNonNumber = true;
}
}
require(_hasNonNumber == true, "string cannot be only numbers");
bytes32 _ret;
assembly {
_ret := mload(add(_temp, 32))
}
return (_ret);
}
}
| 8,270
|
16
|
// Proposals.
|
mapping(uint256 => mapping(address => Proposal)) public proposals;
|
mapping(uint256 => mapping(address => Proposal)) public proposals;
| 28,254
|
54
|
// Implementation of the {IERC20} interface.Additionally, an {Approval} event is emitted on calls to {transferFrom}.Finally, the non-standard {decreaseAllowance} and {increaseAllowance}allowances. See {IERC20-approve}./We have made some light modifications to the openzeppelin ER20located here "../node_modules/@openzeppelin/contracts/token/ERC20/ERC20.sol".Please read below for a quick overview of what has been changed: We have changed one function:- `_transfer` to apply a transfer fee We have added 5 variables- `txFee` the transaction fee to be applied.- `feeDistributor` the contract address to recieve the fees.- `feelessSender` map containing senders who will not have txFees applied.- `feelessReciever` map containing recipients who will not have txFee applied.- `canFeeWhitelist` map containing recipients who will
|
uint8 public txFee = 3; // artifical cap of 255 e.g. 25.5%
address feeDistributor; // fees are sent to fee distributer
|
uint8 public txFee = 3; // artifical cap of 255 e.g. 25.5%
address feeDistributor; // fees are sent to fee distributer
| 2,372
|
146
|
// Withdraw collected service fees. Only by fee account./amount Amount to withdraw
|
function withdrawFees(uint amount) public onlyFeeAccount {
require(collectedFee >= amount);
collectedFee = SafeMath.safeSub(collectedFee, amount);
require(feeAccount.send(amount));
}
|
function withdrawFees(uint amount) public onlyFeeAccount {
require(collectedFee >= amount);
collectedFee = SafeMath.safeSub(collectedFee, amount);
require(feeAccount.send(amount));
}
| 4,948
|
13
|
// Performs slippages check before redeemal. ssts Amount of strategy tokens to be redeemed. slippages Slippages to check against. /
|
function beforeRedeemalCheck(uint256 ssts, uint256[] calldata slippages) external;
|
function beforeRedeemalCheck(uint256 ssts, uint256[] calldata slippages) external;
| 31,044
|
13
|
// End the auction and send the highest bid/ to the beneficiary
|
function auctionEnd() public onlyAfter(revealEnd) {
require(!ended);
emit AuctionEnded(highestBidder, highestBid);
ended = true;
beneficiary.transfer(highestBid);
}
|
function auctionEnd() public onlyAfter(revealEnd) {
require(!ended);
emit AuctionEnded(highestBidder, highestBid);
ended = true;
beneficiary.transfer(highestBid);
}
| 36,630
|
88
|
// if token URI is set
|
if(bytes(_tokenURI).length > 0) {
|
if(bytes(_tokenURI).length > 0) {
| 50,365
|
7
|
// By category.
|
mapping(uint8 => uint256) public categoryBalance;
|
mapping(uint8 => uint256) public categoryBalance;
| 36,113
|
10
|
// deep space buff
|
_planet.range = (_planet.range * 3) / 2;
_planet.speed = (_planet.speed * 3) / 2;
_planet.populationCap = (_planet.populationCap * 3) / 2;
_planet.populationGrowth = (_planet.populationGrowth * 3) / 2;
_planet.silverCap = (_planet.silverCap * 3) / 2;
_planet.silverGrowth = (_planet.silverGrowth * 3) / 2;
|
_planet.range = (_planet.range * 3) / 2;
_planet.speed = (_planet.speed * 3) / 2;
_planet.populationCap = (_planet.populationCap * 3) / 2;
_planet.populationGrowth = (_planet.populationGrowth * 3) / 2;
_planet.silverCap = (_planet.silverCap * 3) / 2;
_planet.silverGrowth = (_planet.silverGrowth * 3) / 2;
| 15,098
|
3
|
// returns whether the address is in the registerbool whether the address is registered_vesting - is the address of vesting that will be checked return bool whether the address is registered /
|
function isRegistered(address _vesting)
external
view
override
returns (bool)
|
function isRegistered(address _vesting)
external
view
override
returns (bool)
| 51,533
|
18
|
// Receives `_paymentToken` from `sender`. sender Address of the sender. amount Amount of tokens to receive.
|
* Emits a {PaymentReceived} event.
* Emits a {Snapshot} event on {ForeverNft} contract.
*
* Requirements:
*
* - Total shares must be non-zero at the time of receiving payment. Else,
* payment will get locked in this contract forever with no one to claim
* it.
* - `amount` must be non-zero.
* - Sender must have already allowed {ForeverSplitter} to draw
* `amount` tokens from `sender` address.
* - This contract must have {SNAPSHOT_CREATOR} role in {ForeverNft}.
*/
function receivePayment(address sender, uint256 amount) internal {
if (_sharesToken.totalSupply() <= 0) revert NoRevenue();
if (amount <= 0) revert InvalidAmount();
_paymentToken.transferFrom(sender, address(this), amount);
emit PaymentReceived(sender, amount);
_totalReceived += amount;
_totalReceivedFrom[sender] += amount;
uint256 nextSnapshotId = _sharesToken.createSnapshot();
_received.push(Received({
snapshotId: nextSnapshotId,
amount: amount,
from: sender
}));
}
|
* Emits a {PaymentReceived} event.
* Emits a {Snapshot} event on {ForeverNft} contract.
*
* Requirements:
*
* - Total shares must be non-zero at the time of receiving payment. Else,
* payment will get locked in this contract forever with no one to claim
* it.
* - `amount` must be non-zero.
* - Sender must have already allowed {ForeverSplitter} to draw
* `amount` tokens from `sender` address.
* - This contract must have {SNAPSHOT_CREATOR} role in {ForeverNft}.
*/
function receivePayment(address sender, uint256 amount) internal {
if (_sharesToken.totalSupply() <= 0) revert NoRevenue();
if (amount <= 0) revert InvalidAmount();
_paymentToken.transferFrom(sender, address(this), amount);
emit PaymentReceived(sender, amount);
_totalReceived += amount;
_totalReceivedFrom[sender] += amount;
uint256 nextSnapshotId = _sharesToken.createSnapshot();
_received.push(Received({
snapshotId: nextSnapshotId,
amount: amount,
from: sender
}));
}
| 27,888
|
23
|
// transfer erc1155 to seller
|
IERC1155(tokenAddress).safeTransferFrom(address(this), seller, tokenId, 1, new bytes(0x0));
ended = true;
|
IERC1155(tokenAddress).safeTransferFrom(address(this), seller, tokenId, 1, new bytes(0x0));
ended = true;
| 59,177
|
67
|
// Issue token based on Ether received./_beneficiary Address that newly issued token will be sent to.
|
function purchaseTokens(address _beneficiary) public payable inProgress {
// only accept a minimum amount of ETH?
require(msg.value >= 0.01 ether);
uint256 tokens = computeTokenAmount(msg.value);
doIssueTokens(_beneficiary, tokens);
/// forward the raised funds to the fund address
fundsTreasury.transfer(msg.value);
}
|
function purchaseTokens(address _beneficiary) public payable inProgress {
// only accept a minimum amount of ETH?
require(msg.value >= 0.01 ether);
uint256 tokens = computeTokenAmount(msg.value);
doIssueTokens(_beneficiary, tokens);
/// forward the raised funds to the fund address
fundsTreasury.transfer(msg.value);
}
| 32,130
|
13
|
// Platform fee percent
|
uint256 public platformFee;
|
uint256 public platformFee;
| 17,439
|
37
|
// Event emitted when a borrow is repaid /
|
event RepayBorrowToken(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);
|
event RepayBorrowToken(address payer, address borrower, uint repayAmount, uint accountBorrows, uint totalBorrows);
| 5,252
|
8
|
// Emitted when Watcher permissions are changed domain the remote domain of the Home contract for the Replica watcher the address of the Watcher access TRUE if the Watcher was given permissions, FALSE if permissions were removed /
|
event WatcherPermissionSet(uint32 indexed domain, address watcher, bool access);
|
event WatcherPermissionSet(uint32 indexed domain, address watcher, bool access);
| 20,716
|
132
|
// The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encodingthey need in their contracts using a combination of `abi.encode` and `keccak256`.
|
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = _getChainId();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view virtual returns (bytes32) {
if (_getChainId() == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
_getChainId(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash));
}
function _getChainId() private view returns (uint256 chainId) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
}
}
|
* This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
* scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
* ({_hashTypedDataV4}).
*
* The implementation of the domain separator was designed to be as efficient as possible while still properly updating
* the chain id to protect against replay attacks on an eventual fork of the chain.
*
* NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
* https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
*
* _Available since v3.4._
*/
abstract contract EIP712 {
/* solhint-disable var-name-mixedcase */
// Cache the domain separator as an immutable value, but also store the chain id that it corresponds to, in order to
// invalidate the cached domain separator if the chain id changes.
bytes32 private immutable _CACHED_DOMAIN_SEPARATOR;
uint256 private immutable _CACHED_CHAIN_ID;
bytes32 private immutable _HASHED_NAME;
bytes32 private immutable _HASHED_VERSION;
bytes32 private immutable _TYPE_HASH;
/* solhint-enable var-name-mixedcase */
/**
* @dev Initializes the domain separator and parameter caches.
*
* The meaning of `name` and `version` is specified in
* https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
*
* - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
* - `version`: the current major version of the signing domain.
*
* NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
* contract upgrade].
*/
constructor(string memory name, string memory version) {
bytes32 hashedName = keccak256(bytes(name));
bytes32 hashedVersion = keccak256(bytes(version));
bytes32 typeHash = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");
_HASHED_NAME = hashedName;
_HASHED_VERSION = hashedVersion;
_CACHED_CHAIN_ID = _getChainId();
_CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
_TYPE_HASH = typeHash;
}
/**
* @dev Returns the domain separator for the current chain.
*/
function _domainSeparatorV4() internal view virtual returns (bytes32) {
if (_getChainId() == _CACHED_CHAIN_ID) {
return _CACHED_DOMAIN_SEPARATOR;
} else {
return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
}
}
function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {
return keccak256(
abi.encode(
typeHash,
name,
version,
_getChainId(),
address(this)
)
);
}
/**
* @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
* function returns the hash of the fully encoded EIP712 message for this domain.
*
* This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
*
* ```solidity
* bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
* keccak256("Mail(address to,string contents)"),
* mailTo,
* keccak256(bytes(mailContents))
* )));
* address signer = ECDSA.recover(digest, signature);
* ```
*/
function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
return keccak256(abi.encodePacked("\x19\x01", _domainSeparatorV4(), structHash));
}
function _getChainId() private view returns (uint256 chainId) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
// solhint-disable-next-line no-inline-assembly
assembly {
chainId := chainid()
}
}
}
| 2,870
|
4
|
// stake
|
IHypervisor(hypervisor).stake(vault, amount, permission);
|
IHypervisor(hypervisor).stake(vault, amount, permission);
| 22,156
|
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)
| 27,455
|
18
|
// Configures the reserve collateralization parametersall the values are expressed in percentages with two decimals of precision. A valid value is 10000, which means 100.00% asset The address of the underlying asset of the reserve ltv The loan to value of the asset when used as collateral liquidationThreshold The threshold at which loans using this asset as collateral will be considered undercollateralized liquidationBonus The bonus liquidators receive to liquidate this asset. The values is always above 100%. A value of 105%means the liquidator will receive a 5% bonus /
|
) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
//validation of the parameters: the LTV can
//only be lower or equal than the liquidation threshold
//(otherwise a loan against the asset would cause instantaneous liquidation)
require(ltv <= liquidationThreshold, Errors.LPC_INVALID_CONFIGURATION);
if (liquidationThreshold != 0) {
//liquidation bonus must be bigger than 100.00%, otherwise the liquidator would receive less
//collateral than needed to cover the debt
require(
liquidationBonus > PercentageMath.PERCENTAGE_FACTOR,
Errors.LPC_INVALID_CONFIGURATION
);
//if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment
//a loan is taken there is enough collateral available to cover the liquidation bonus
require(
liquidationThreshold.percentMul(liquidationBonus) <= PercentageMath.PERCENTAGE_FACTOR,
Errors.LPC_INVALID_CONFIGURATION
);
} else {
require(liquidationBonus == 0, Errors.LPC_INVALID_CONFIGURATION);
//if the liquidation threshold is being set to 0,
// the reserve is being disabled as collateral. To do so,
//we need to ensure no liquidity is deposited
_checkNoLiquidity(asset);
}
currentConfig.setLtv(ltv);
currentConfig.setLiquidationThreshold(liquidationThreshold);
currentConfig.setLiquidationBonus(liquidationBonus);
pool.setConfiguration(asset, currentConfig.data);
emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus);
}
|
) external onlyPoolAdmin {
DataTypes.ReserveConfigurationMap memory currentConfig = pool.getConfiguration(asset);
//validation of the parameters: the LTV can
//only be lower or equal than the liquidation threshold
//(otherwise a loan against the asset would cause instantaneous liquidation)
require(ltv <= liquidationThreshold, Errors.LPC_INVALID_CONFIGURATION);
if (liquidationThreshold != 0) {
//liquidation bonus must be bigger than 100.00%, otherwise the liquidator would receive less
//collateral than needed to cover the debt
require(
liquidationBonus > PercentageMath.PERCENTAGE_FACTOR,
Errors.LPC_INVALID_CONFIGURATION
);
//if threshold * bonus is less than PERCENTAGE_FACTOR, it's guaranteed that at the moment
//a loan is taken there is enough collateral available to cover the liquidation bonus
require(
liquidationThreshold.percentMul(liquidationBonus) <= PercentageMath.PERCENTAGE_FACTOR,
Errors.LPC_INVALID_CONFIGURATION
);
} else {
require(liquidationBonus == 0, Errors.LPC_INVALID_CONFIGURATION);
//if the liquidation threshold is being set to 0,
// the reserve is being disabled as collateral. To do so,
//we need to ensure no liquidity is deposited
_checkNoLiquidity(asset);
}
currentConfig.setLtv(ltv);
currentConfig.setLiquidationThreshold(liquidationThreshold);
currentConfig.setLiquidationBonus(liquidationBonus);
pool.setConfiguration(asset, currentConfig.data);
emit CollateralConfigurationChanged(asset, ltv, liquidationThreshold, liquidationBonus);
}
| 30,539
|
1
|
// Maximum amount of token0 to swap for the reward token
|
uint256 max0;
|
uint256 max0;
| 24,503
|
138
|
// Save current value for use in log
|
uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;
|
uint oldLiquidationIncentiveMantissa = liquidationIncentiveMantissa;
| 36,141
|
3
|
// The onDelete function is called when a flow is deleted./token the super token passed from the CFA (flowVars)/flowSender the flow sender/flowReceiver the flow receiver
|
function onDelete(ISuperfluidToken token, address flowSender, address flowReceiver) external;
|
function onDelete(ISuperfluidToken token, address flowSender, address flowReceiver) external;
| 4,937
|
20
|
// Gets the service fees for the given interval. loan_The address of the loan contract. interval_The time, in seconds, to get the proportional fee for return serviceFees_ The amount of platform service fee to be paid. /
|
function getServiceFeesForPeriod(address loan_, uint256 interval_) external view returns (uint256 serviceFees_);
|
function getServiceFeesForPeriod(address loan_, uint256 interval_) external view returns (uint256 serviceFees_);
| 11,747
|
75
|
// Emitted when relays are added by a relayManager
|
event RelayWorkersAdded(
address indexed relayManager,
address[] newRelayWorkers,
uint256 workersCount
);
|
event RelayWorkersAdded(
address indexed relayManager,
address[] newRelayWorkers,
uint256 workersCount
);
| 6,617
|
202
|
// Reset the prepared reserve deviation.return `true` if success. /
|
function resetNewReserveDeviation() external onlyGovernance returns (bool) {
return _resetUInt256Config(_RESERVE_DEVIATION_KEY);
}
|
function resetNewReserveDeviation() external onlyGovernance returns (bool) {
return _resetUInt256Config(_RESERVE_DEVIATION_KEY);
}
| 16,366
|
29
|
// Claim rewards for array of MAYC NFTs and send to recipient _nfts Array of NFTs owned and committed by the msg.sender _recipient Address to send claim reward to /
|
function claimMAYC(uint256[] calldata _nfts, address _recipient) external {
_claimNft(MAYC_POOL_ID, _nfts, _recipient);
}
|
function claimMAYC(uint256[] calldata _nfts, address _recipient) external {
_claimNft(MAYC_POOL_ID, _nfts, _recipient);
}
| 11,504
|
90
|
// risk groups are extended by the recoveryRatePD parameter compared with NFTFeed The following score cards just examples that are mostly optimized for the system test cases risk group: 0 - APR: 5.83%
|
file("riskGroup", 0, ONE, 85*10**25, uint(1000000001847729578893962455), 99.96*10**25);
|
file("riskGroup", 0, ONE, 85*10**25, uint(1000000001847729578893962455), 99.96*10**25);
| 40,271
|
18
|
// Delete the index entry for the deleted value
|
delete set.index[value];
|
delete set.index[value];
| 933
|
307
|
// Rewards and profits already claimed
|
uint256 internal constant ALREADY_CLAIMED = 12;
|
uint256 internal constant ALREADY_CLAIMED = 12;
| 67,912
|
7
|
// user has counted tokens from presale contract/s (default=false)
|
mapping(address => bool) internal _initialized;
|
mapping(address => bool) internal _initialized;
| 23,099
|
202
|
// Destroy Tokens
|
require(
estateLandBalance.destroyTokens(msg.sender, currentBalance),
"Unregister Balance::Could not destroy tokens"
);
|
require(
estateLandBalance.destroyTokens(msg.sender, currentBalance),
"Unregister Balance::Could not destroy tokens"
);
| 7,390
|
309
|
// Public function to update the metadata IPFS URI prefix ipfsUriPrefix string the new IPFS URI prefix /
|
function setIPFSUriPrefix(string calldata ipfsUriPrefix) external onlyOwner {
_ipfsUriPrefix = ipfsUriPrefix;
}
|
function setIPFSUriPrefix(string calldata ipfsUriPrefix) external onlyOwner {
_ipfsUriPrefix = ipfsUriPrefix;
}
| 40,548
|
67
|
// populate the string starting with the least-significant character
|
j = input;
for (uint256 i = length; i > 0; ) {
|
j = input;
for (uint256 i = length; i > 0; ) {
| 1,228
|
434
|
// DAO
|
address internal crv;
constructor(
address _controller,
address _vault,
address _underlying
|
address internal crv;
constructor(
address _controller,
address _vault,
address _underlying
| 17,478
|
20
|
// Returns true if the address is FlashBorrower, false otherwise borrower The address to checkreturn True if the given address is FlashBorrower, false otherwise /
|
function isFlashBorrower(address borrower) external view returns (bool);
|
function isFlashBorrower(address borrower) external view returns (bool);
| 11,257
|
323
|
// Decrement the sponsor's collateral and global collateral amounts.
|
amountWithdrawn = _decrementCollateralBalances(positionData, collateralRedeemed);
|
amountWithdrawn = _decrementCollateralBalances(positionData, collateralRedeemed);
| 30,798
|
8
|
// Leaves the contract without owner. It will not be possible to call`onlyOwner` functions anymore. Can only be called by the current owner. /
|
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_ownerAddress = address(0);
}
|
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_ownerAddress = address(0);
}
| 3,229
|
102
|
// The length of the time window where a rebase operation is allowed to execute, in seconds.
|
uint256 public rebaseWindowLengthSec;
|
uint256 public rebaseWindowLengthSec;
| 4,279
|
21
|
// Withdraw accumulated balance, called by payee
|
function withdrawPayments() internal returns (bool) {
address payee = msg.sender;
uint payment = payments[payee];
if (payment == 0) {
revert();
}
if (this.balance < payment) {
revert();
}
payments[payee] = 0;
if (!payee.send(payment)) {
revert();
}
RefundETH(payee, payment);
return true;
}
|
function withdrawPayments() internal returns (bool) {
address payee = msg.sender;
uint payment = payments[payee];
if (payment == 0) {
revert();
}
if (this.balance < payment) {
revert();
}
payments[payee] = 0;
if (!payee.send(payment)) {
revert();
}
RefundETH(payee, payment);
return true;
}
| 47,202
|
85
|
// Mapping from token ID to approved address
|
mapping(uint256 => address) private _tokenApprovals;
|
mapping(uint256 => address) private _tokenApprovals;
| 44,903
|
0
|
// the event emitted from the depositERC20 function /
|
event DepositedERC20(
address token,
uint256 amount,
bytes32 salt,
bytes bundle,
string network,
string receiver,
bool isWrapped
);
|
event DepositedERC20(
address token,
uint256 amount,
bytes32 salt,
bytes bundle,
string network,
string receiver,
bool isWrapped
);
| 32,965
|
798
|
// Allow any amount of gas to be used on this withdrawal (which allows the transfer to be skipped)
|
withdrawal.minGas = 0;
|
withdrawal.minGas = 0;
| 19,939
|
13
|
// Snapshot sync counter: the initial state is 0, the sync starts to accumulate 1,and the when netx sync starting reset to 0
|
uint32 syncCounter;
|
uint32 syncCounter;
| 33,891
|
16
|
// solhint-disable-next-line no-simple-event-func-name
|
address winner_TOD31;
|
address winner_TOD31;
| 4,657
|
1
|
// Storage slot with the admin of the contract.This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and isvalidated in the constructor. /
|
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
|
bytes32 internal constant ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
| 16,122
|
66
|
// Returns true if `account` is a contract. [IMPORTANT]====It is unsafe to assume that an address for which this function returnsfalse is an externally-owned account (EOA) and not a contract. Among others, `isContract` will return false for the followingtypes of addresses:- an externally-owned account - a contract in construction - an address where a contract will be created - an address where a contract lived, but was destroyed==== /
|
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
|
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
// solhint-disable-next-line no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
| 127
|
25
|
// owner of the token is able to set a minimum price for their NFTtokenId is the unique identifier of the NFT whose minimum price will be settokenAmount represents the amount of payment tokens needed to purchase the NFT
|
function setMinimumPrice(uint256 tokenId, uint256 paymentAmount) public returns (bool) {
//verification check that the minimum price is only set by the owner of the token
require(msg.sender == ownerOf(tokenId), "price can only be set by the owner");
//map the minimum price to the unique token identifer
_minPrice[tokenId] = paymentAmount;
return true;
}
|
function setMinimumPrice(uint256 tokenId, uint256 paymentAmount) public returns (bool) {
//verification check that the minimum price is only set by the owner of the token
require(msg.sender == ownerOf(tokenId), "price can only be set by the owner");
//map the minimum price to the unique token identifer
_minPrice[tokenId] = paymentAmount;
return true;
}
| 45,608
|
56
|
// Throws if the contract is paused. /
|
function _requireNotStakingPaused() internal view virtual {
require(!stakingPaused(), "Pausable: paused");
}
|
function _requireNotStakingPaused() internal view virtual {
require(!stakingPaused(), "Pausable: paused");
}
| 1,221
|
282
|
// Deposit ether to get wrapped ether
|
function deposit() external payable;
|
function deposit() external payable;
| 2,926
|
32
|
// Emits a {TransferSingle} event. Requirements: - `from` cannot be the zero address.- `from` must have at least `amount` tokens of token type `id`. /
|
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
|
function _burn(
address from,
uint256 id,
uint256 amount
) internal virtual {
require(from != address(0), "ERC1155: burn from the zero address");
address operator = _msgSender();
uint256[] memory ids = _asSingletonArray(id);
uint256[] memory amounts = _asSingletonArray(amount);
| 5,831
|
88
|
// See {IERC20-totalSupply}./
|
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
|
function totalSupply() external override view returns (uint256) {
return _totalSupply;
}
| 16,419
|
19
|
// length prefix + 1 entry for each
|
bytes29[] memory _encodedCalls = new bytes29[](
_calls.length + CALLS_PREFIX_ITEMS
);
_encodedCalls[0] = abi.encodePacked(uint8(_calls.length)).ref(0);
|
bytes29[] memory _encodedCalls = new bytes29[](
_calls.length + CALLS_PREFIX_ITEMS
);
_encodedCalls[0] = abi.encodePacked(uint8(_calls.length)).ref(0);
| 26,742
|
58
|
// Construct a new Route token /
|
constructor() public {
balances[_msgSender()] = uint256(totalSupply);
emit Transfer(address(0), _msgSender(), totalSupply);
}
|
constructor() public {
balances[_msgSender()] = uint256(totalSupply);
emit Transfer(address(0), _msgSender(), totalSupply);
}
| 23,233
|
10
|
// How much platform fees have been accrued. /
|
uint128 public platformFeesAccrued;
|
uint128 public platformFeesAccrued;
| 8,048
|
19
|
// Allow _spender to withdraw from your account, multiple times, up to the _value amount. If this function is called again it overwrites the current allowance with _value.
|
function approve(address _spender, uint256 _value) returns(bool){
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
|
function approve(address _spender, uint256 _value) returns(bool){
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
| 29,565
|
20
|
// ่ฎฎๅๅฏน็ฌฌ_indexไธชๆๆก่ฟ่กๆ็ฅจ
|
function examine(uint256 _index, bool _bool)
public
|
function examine(uint256 _index, bool _bool)
public
| 15,723
|
51
|
// Crowdsale Start time has been changed
|
event StartsAtChanged(uint256 startsAt);
|
event StartsAtChanged(uint256 startsAt);
| 36,550
|
319
|
// with 0 amount{0,1} and sending the donation amount(s) from the callback/recipient The address which will receive the token0 and token1 amounts/amount0 The amount of token0 to send/amount1 The amount of token1 to send/data Any data to be passed through to the callback
|
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
|
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
| 5,328
|
139
|
// Called by buyers to purchase tokens. All ETH sent to this function is converted into tokens, which are sentto `beneficiary`. Tokens can only be bought while the Crowdsale is active. The amount of ETH received must not be less than theminimum or more than the maximum. /
|
function buyTokens(address beneficiary) public payable nonReentrant {
require(isActive(), "Crowdsale: not active");
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE_AMOUNT, "Crowdsale: insufficient ETH");
require(weiAmount <= MAX_PURCHASE_AMOUNT, "Crowdsale: excessive ETH");
// Convert wei to token units, taking into account the number of decimals of the token and of ETH (18)
uint256 tokenAmount = weiAmount.mul(rate).mul(10**_decimals).div(10**18);
// Transfer tokens to the beneficiary
token.safeTransfer(beneficiary, tokenAmount);
// Transfer ETh to the wallet, forwarding all gas
wallet.sendValue(msg.value);
emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokenAmount);
}
|
function buyTokens(address beneficiary) public payable nonReentrant {
require(isActive(), "Crowdsale: not active");
uint256 weiAmount = msg.value;
require(weiAmount >= MIN_PURCHASE_AMOUNT, "Crowdsale: insufficient ETH");
require(weiAmount <= MAX_PURCHASE_AMOUNT, "Crowdsale: excessive ETH");
// Convert wei to token units, taking into account the number of decimals of the token and of ETH (18)
uint256 tokenAmount = weiAmount.mul(rate).mul(10**_decimals).div(10**18);
// Transfer tokens to the beneficiary
token.safeTransfer(beneficiary, tokenAmount);
// Transfer ETh to the wallet, forwarding all gas
wallet.sendValue(msg.value);
emit TokensPurchased(msg.sender, beneficiary, weiAmount, tokenAmount);
}
| 22,268
|
46
|
// Check exit is valid and doesn't already exist.
|
require(_amount > 0);
require(exits[_utxoPos].amount == 0);
|
require(_amount > 0);
require(exits[_utxoPos].amount == 0);
| 53,126
|
3
|
// This initializes our contract state (sets enum to Pending once the program starts)
|
constructor () public {
}
|
constructor () public {
}
| 40,241
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.