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
|
|---|---|---|---|---|
12
|
// main
|
acceptedTokens[address(0x0000000000000000000000000000000000000000)] = 1; // BNB
acceptedTokens[address(0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c)] = 2; // BTC
acceptedTokens[address(0x2170Ed0880ac9A755fd29B2688956BD959F933F8)] = 3; // ETH
acceptedTokens[address(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56)] = 4; // BUSD
|
acceptedTokens[address(0x0000000000000000000000000000000000000000)] = 1; // BNB
acceptedTokens[address(0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c)] = 2; // BTC
acceptedTokens[address(0x2170Ed0880ac9A755fd29B2688956BD959F933F8)] = 3; // ETH
acceptedTokens[address(0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56)] = 4; // BUSD
| 28,680
|
42
|
// Get total token balance token The token to checkreturn balance the total active balance of `token` /
|
function totalTokenBalance(address token) external view returns(TokenBalance memory balance){
for (uint256 i; i < numLocks; i++) {
Lock memory tokenLock = tokenLocks[i];
if(tokenLock.token == token && tokenLock.amount != tokenLock.amountClaimed){
balance.totalAmount = balance.totalAmount.add(tokenLock.amount);
balance.votingPower = balance.votingPower.add(tokenLock.votingPower);
if(block.timestamp > tokenLock.startTime) {
balance.claimedAmount = balance.claimedAmount.add(tokenLock.amountClaimed);
uint256 elapsedTime = block.timestamp.sub(tokenLock.startTime);
uint256 elapsedDays = elapsedTime.div(SECONDS_PER_DAY);
if (
elapsedDays >= tokenLock.cliffDurationInDays
) {
if (elapsedDays >= tokenLock.vestingDurationInDays) {
balance.claimableAmount = balance.claimableAmount.add(tokenLock.amount).sub(tokenLock.amountClaimed);
} else {
uint256 vestingDurationInSecs = uint256(tokenLock.vestingDurationInDays).mul(SECONDS_PER_DAY);
uint256 vestingAmountPerSec = tokenLock.amount.div(vestingDurationInSecs);
uint256 amountVested = vestingAmountPerSec.mul(elapsedTime);
balance.claimableAmount = balance.claimableAmount.add(amountVested.sub(tokenLock.amountClaimed));
}
}
}
}
}
}
|
function totalTokenBalance(address token) external view returns(TokenBalance memory balance){
for (uint256 i; i < numLocks; i++) {
Lock memory tokenLock = tokenLocks[i];
if(tokenLock.token == token && tokenLock.amount != tokenLock.amountClaimed){
balance.totalAmount = balance.totalAmount.add(tokenLock.amount);
balance.votingPower = balance.votingPower.add(tokenLock.votingPower);
if(block.timestamp > tokenLock.startTime) {
balance.claimedAmount = balance.claimedAmount.add(tokenLock.amountClaimed);
uint256 elapsedTime = block.timestamp.sub(tokenLock.startTime);
uint256 elapsedDays = elapsedTime.div(SECONDS_PER_DAY);
if (
elapsedDays >= tokenLock.cliffDurationInDays
) {
if (elapsedDays >= tokenLock.vestingDurationInDays) {
balance.claimableAmount = balance.claimableAmount.add(tokenLock.amount).sub(tokenLock.amountClaimed);
} else {
uint256 vestingDurationInSecs = uint256(tokenLock.vestingDurationInDays).mul(SECONDS_PER_DAY);
uint256 vestingAmountPerSec = tokenLock.amount.div(vestingDurationInSecs);
uint256 amountVested = vestingAmountPerSec.mul(elapsedTime);
balance.claimableAmount = balance.claimableAmount.add(amountVested.sub(tokenLock.amountClaimed));
}
}
}
}
}
}
| 51,342
|
25
|
// settle debug log /
|
event SettleLog (string name, uint strikePrice, uint etherPrice, uint totalProfit, uint totalOptionSold, uint premiumShare);
|
event SettleLog (string name, uint strikePrice, uint etherPrice, uint totalProfit, uint totalOptionSold, uint premiumShare);
| 18,370
|
8
|
// Public View Functions
|
function getBuildings() public view returns (Building[] memory) {
return buildings;
}
|
function getBuildings() public view returns (Building[] memory) {
return buildings;
}
| 1,797
|
6
|
// Deposit `amount` stablecoin to vault
|
vault.deposit(amount);
|
vault.deposit(amount);
| 23,997
|
25
|
// Kine's KErc20Delegator Contract KTokens which wrap an EIP-20 underlying and delegate to an implementation Kine /
|
contract KErc20Delegator is KTokenInterface, KErc20Interface, KDelegatorInterface {
/**
* @notice Construct a new money market
* @param underlying_ The address of the underlying asset
* @param controller_ The address of the Controller
* @param name_ ERC-20 name of this token
* @param symbol_ ERC-20 symbol of this token
* @param decimals_ ERC-20 decimal precision of this token
* @param admin_ Address of the administrator of this token
* @param implementation_ The address of the implementation the contract delegates to
* @param becomeImplementationData The encoded args for becomeImplementation
*/
constructor(address underlying_,
KineControllerInterface controller_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_,
address implementation_,
bytes memory becomeImplementationData) public {
// Creator of the contract is admin during initialization
admin = msg.sender;
initialized = false;
// First delegate gets to initialize the delegator (i.e. storage contract)
delegateTo(implementation_, abi.encodeWithSignature("initialize(address,address,string,string,uint8)",
underlying_,
controller_,
name_,
symbol_,
decimals_));
// New implementations always get set via the settor (post-initialize)
_setImplementation(implementation_, false, becomeImplementationData);
// Set the proper admin now that initialization is done
admin = admin_;
}
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
require(msg.sender == admin, "KErc20Delegator::_setImplementation: Caller must be admin");
if (allowResign) {
delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
}
address oldImplementation = implementation;
implementation = implementation_;
delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));
emit NewImplementation(oldImplementation, implementation);
}
/**
* @notice Sender supplies assets into the market and receives kTokens in exchange
* @param mintAmount The amount of the underlying asset to supply
* @return the actual mint amount.
*/
function mint(uint mintAmount) external returns (uint) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("mint(uint256)", mintAmount));
return abi.decode(data, (uint));
}
/**
* @notice Sender redeems kTokens in exchange for the underlying asset
* @param redeemTokens The number of kTokens to redeem into underlying
*/
function redeem(uint redeemTokens) external {
delegateToImplementation(abi.encodeWithSignature("redeem(uint256)", redeemTokens));
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("transfer(address,uint256)", dst, amount));
return abi.decode(data, (bool));
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint256 amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("transferFrom(address,address,uint256)", src, dst, amount));
return abi.decode(data, (bool));
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("approve(address,uint256)", spender, amount));
return abi.decode(data, (bool));
}
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("allowance(address,address)", owner, spender));
return abi.decode(data, (uint));
}
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("balanceOf(address)", owner));
return abi.decode(data, (uint));
}
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by controller to more efficiently perform liquidity checks.
* and for kTokens, there is only token balance, for kMCD, there is only borrow balance
* @param account Address of the account to snapshot
* @return (token balance, borrow balance)
*/
function getAccountSnapshot(address account) external view returns (uint, uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getAccountSnapshot(address)", account));
return abi.decode(data, (uint, uint));
}
/**
* @notice Get cash balance of this kToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getCash()"));
return abi.decode(data, (uint));
}
/**
* @notice Transfers collateral tokens (this market) to the liquidator.
* @dev Will fail unless called by another kToken during the process of liquidation.
* Its absolutely critical to use msg.sender as the borrowed kToken and not a parameter.
* @param liquidator The account receiving seized collateral
* @param borrower The account having collateral seized
* @param seizeTokens The number of kTokens to seize
*/
function seize(address liquidator, address borrower, uint seizeTokens) external {
delegateToImplementation(abi.encodeWithSignature("seize(address,address,uint256)", liquidator, borrower, seizeTokens));
}
/*** Admin Functions ***/
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
*/
function _setPendingAdmin(address payable newPendingAdmin) external {
delegateToImplementation(abi.encodeWithSignature("_setPendingAdmin(address)", newPendingAdmin));
}
/**
* @notice Sets a new controller for the market
* @dev Admin function to set a new controller
*/
function _setController(KineControllerInterface newController) public {
delegateToImplementation(abi.encodeWithSignature("_setController(address)", newController));
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
*/
function _acceptAdmin() external {
delegateToImplementation(abi.encodeWithSignature("_acceptAdmin()"));
}
/**
* @notice Internal method to delegate execution to another contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param callee The contract to delegatecall
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return returnData;
}
/**
* @notice Delegates execution to the implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToImplementation(bytes memory data) public returns (bytes memory) {
return delegateTo(implementation, data);
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return abi.decode(returnData, (bytes));
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
*/
function () external payable {
require(msg.value == 0,"KErc20Delegator:fallback: cannot send value to fallback");
// delegate all other functions to current implementation
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
}
|
contract KErc20Delegator is KTokenInterface, KErc20Interface, KDelegatorInterface {
/**
* @notice Construct a new money market
* @param underlying_ The address of the underlying asset
* @param controller_ The address of the Controller
* @param name_ ERC-20 name of this token
* @param symbol_ ERC-20 symbol of this token
* @param decimals_ ERC-20 decimal precision of this token
* @param admin_ Address of the administrator of this token
* @param implementation_ The address of the implementation the contract delegates to
* @param becomeImplementationData The encoded args for becomeImplementation
*/
constructor(address underlying_,
KineControllerInterface controller_,
string memory name_,
string memory symbol_,
uint8 decimals_,
address payable admin_,
address implementation_,
bytes memory becomeImplementationData) public {
// Creator of the contract is admin during initialization
admin = msg.sender;
initialized = false;
// First delegate gets to initialize the delegator (i.e. storage contract)
delegateTo(implementation_, abi.encodeWithSignature("initialize(address,address,string,string,uint8)",
underlying_,
controller_,
name_,
symbol_,
decimals_));
// New implementations always get set via the settor (post-initialize)
_setImplementation(implementation_, false, becomeImplementationData);
// Set the proper admin now that initialization is done
admin = admin_;
}
/**
* @notice Called by the admin to update the implementation of the delegator
* @param implementation_ The address of the new implementation for delegation
* @param allowResign Flag to indicate whether to call _resignImplementation on the old implementation
* @param becomeImplementationData The encoded bytes data to be passed to _becomeImplementation
*/
function _setImplementation(address implementation_, bool allowResign, bytes memory becomeImplementationData) public {
require(msg.sender == admin, "KErc20Delegator::_setImplementation: Caller must be admin");
if (allowResign) {
delegateToImplementation(abi.encodeWithSignature("_resignImplementation()"));
}
address oldImplementation = implementation;
implementation = implementation_;
delegateToImplementation(abi.encodeWithSignature("_becomeImplementation(bytes)", becomeImplementationData));
emit NewImplementation(oldImplementation, implementation);
}
/**
* @notice Sender supplies assets into the market and receives kTokens in exchange
* @param mintAmount The amount of the underlying asset to supply
* @return the actual mint amount.
*/
function mint(uint mintAmount) external returns (uint) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("mint(uint256)", mintAmount));
return abi.decode(data, (uint));
}
/**
* @notice Sender redeems kTokens in exchange for the underlying asset
* @param redeemTokens The number of kTokens to redeem into underlying
*/
function redeem(uint redeemTokens) external {
delegateToImplementation(abi.encodeWithSignature("redeem(uint256)", redeemTokens));
}
/**
* @notice Transfer `amount` tokens from `msg.sender` to `dst`
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transfer(address dst, uint amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("transfer(address,uint256)", dst, amount));
return abi.decode(data, (bool));
}
/**
* @notice Transfer `amount` tokens from `src` to `dst`
* @param src The address of the source account
* @param dst The address of the destination account
* @param amount The number of tokens to transfer
* @return Whether or not the transfer succeeded
*/
function transferFrom(address src, address dst, uint256 amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("transferFrom(address,address,uint256)", src, dst, amount));
return abi.decode(data, (bool));
}
/**
* @notice Approve `spender` to transfer up to `amount` from `src`
* @dev This will overwrite the approval amount for `spender`
* and is subject to issues noted [here](https://eips.ethereum.org/EIPS/eip-20#approve)
* @param spender The address of the account which may transfer tokens
* @param amount The number of tokens that are approved (-1 means infinite)
* @return Whether or not the approval succeeded
*/
function approve(address spender, uint256 amount) external returns (bool) {
bytes memory data = delegateToImplementation(abi.encodeWithSignature("approve(address,uint256)", spender, amount));
return abi.decode(data, (bool));
}
/**
* @notice Get the current allowance from `owner` for `spender`
* @param owner The address of the account which owns the tokens to be spent
* @param spender The address of the account which may transfer tokens
* @return The number of tokens allowed to be spent (-1 means infinite)
*/
function allowance(address owner, address spender) external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("allowance(address,address)", owner, spender));
return abi.decode(data, (uint));
}
/**
* @notice Get the token balance of the `owner`
* @param owner The address of the account to query
* @return The number of tokens owned by `owner`
*/
function balanceOf(address owner) external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("balanceOf(address)", owner));
return abi.decode(data, (uint));
}
/**
* @notice Get a snapshot of the account's balances, and the cached exchange rate
* @dev This is used by controller to more efficiently perform liquidity checks.
* and for kTokens, there is only token balance, for kMCD, there is only borrow balance
* @param account Address of the account to snapshot
* @return (token balance, borrow balance)
*/
function getAccountSnapshot(address account) external view returns (uint, uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getAccountSnapshot(address)", account));
return abi.decode(data, (uint, uint));
}
/**
* @notice Get cash balance of this kToken in the underlying asset
* @return The quantity of underlying asset owned by this contract
*/
function getCash() external view returns (uint) {
bytes memory data = delegateToViewImplementation(abi.encodeWithSignature("getCash()"));
return abi.decode(data, (uint));
}
/**
* @notice Transfers collateral tokens (this market) to the liquidator.
* @dev Will fail unless called by another kToken during the process of liquidation.
* Its absolutely critical to use msg.sender as the borrowed kToken and not a parameter.
* @param liquidator The account receiving seized collateral
* @param borrower The account having collateral seized
* @param seizeTokens The number of kTokens to seize
*/
function seize(address liquidator, address borrower, uint seizeTokens) external {
delegateToImplementation(abi.encodeWithSignature("seize(address,address,uint256)", liquidator, borrower, seizeTokens));
}
/*** Admin Functions ***/
/**
* @notice Begins transfer of admin rights. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @dev Admin function to begin change of admin. The newPendingAdmin must call `_acceptAdmin` to finalize the transfer.
* @param newPendingAdmin New pending admin.
*/
function _setPendingAdmin(address payable newPendingAdmin) external {
delegateToImplementation(abi.encodeWithSignature("_setPendingAdmin(address)", newPendingAdmin));
}
/**
* @notice Sets a new controller for the market
* @dev Admin function to set a new controller
*/
function _setController(KineControllerInterface newController) public {
delegateToImplementation(abi.encodeWithSignature("_setController(address)", newController));
}
/**
* @notice Accepts transfer of admin rights. msg.sender must be pendingAdmin
* @dev Admin function for pending admin to accept role and update admin
*/
function _acceptAdmin() external {
delegateToImplementation(abi.encodeWithSignature("_acceptAdmin()"));
}
/**
* @notice Internal method to delegate execution to another contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param callee The contract to delegatecall
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateTo(address callee, bytes memory data) internal returns (bytes memory) {
(bool success, bytes memory returnData) = callee.delegatecall(data);
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return returnData;
}
/**
* @notice Delegates execution to the implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToImplementation(bytes memory data) public returns (bytes memory) {
return delegateTo(implementation, data);
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
* There are an additional 2 prefix uints from the wrapper returndata, which we ignore since we make an extra hop.
* @param data The raw data to delegatecall
* @return The returned bytes from the delegatecall
*/
function delegateToViewImplementation(bytes memory data) public view returns (bytes memory) {
(bool success, bytes memory returnData) = address(this).staticcall(abi.encodeWithSignature("delegateToImplementation(bytes)", data));
assembly {
if eq(success, 0) {
revert(add(returnData, 0x20), returndatasize)
}
}
return abi.decode(returnData, (bytes));
}
/**
* @notice Delegates execution to an implementation contract
* @dev It returns to the external caller whatever the implementation returns or forwards reverts
*/
function () external payable {
require(msg.value == 0,"KErc20Delegator:fallback: cannot send value to fallback");
// delegate all other functions to current implementation
(bool success, ) = implementation.delegatecall(msg.data);
assembly {
let free_mem_ptr := mload(0x40)
returndatacopy(free_mem_ptr, 0, returndatasize)
switch success
case 0 { revert(free_mem_ptr, returndatasize) }
default { return(free_mem_ptr, returndatasize) }
}
}
}
| 6,730
|
225
|
// update alpaca energy
|
user.alpacaEnergy = _newEnergy;
|
user.alpacaEnergy = _newEnergy;
| 15,501
|
172
|
// Simple interest calculated per second Interest = Principalratetime
|
interestAmount = _loanAmount.multiplyDecimalRound(
interestPerSecond.mul(_seconds)
);
|
interestAmount = _loanAmount.multiplyDecimalRound(
interestPerSecond.mul(_seconds)
);
| 15,745
|
14
|
// percentage deducted to the advertising fund
|
uint projectPercent = 2;
|
uint projectPercent = 2;
| 35,043
|
7
|
// For miscellaneous variable(s) pertaining to the address (e.g. number of whitelist mint slots used). If there are multiple variables, please pack them into a uint64.
|
uint64 aux;
|
uint64 aux;
| 1,067
|
180
|
// числитель
|
сущ(
числитель,
МУЖ, НЕОДУШ,
"[\\&а\\&б\\&й]+ТЕЛЬ",
"[\\&а\\&б\\&й]+ТЕЛЯ",
"[\\&а\\&б\\&й]+ТЕЛЕМ",
"[\\&а\\&б\\&й]+ТЕЛЬ",
"[\\&а\\&б\\&й]+ТЕЛЮ",
"[\\&а\\&б\\&й]+ТЕЛЕ",
"[\\&а\\&б\\&й]+ТЕЛИ",
|
сущ(
числитель,
МУЖ, НЕОДУШ,
"[\\&а\\&б\\&й]+ТЕЛЬ",
"[\\&а\\&б\\&й]+ТЕЛЯ",
"[\\&а\\&б\\&й]+ТЕЛЕМ",
"[\\&а\\&б\\&й]+ТЕЛЬ",
"[\\&а\\&б\\&й]+ТЕЛЮ",
"[\\&а\\&б\\&й]+ТЕЛЕ",
"[\\&а\\&б\\&й]+ТЕЛИ",
| 29,116
|
114
|
// Admin Events // Event emitted when comptroller is changed /
|
event NewComptroller(IComptroller oldComptroller, IComptroller newComptroller);
|
event NewComptroller(IComptroller oldComptroller, IComptroller newComptroller);
| 797
|
312
|
// Add this to our running sum of borrows
|
(err, localResults.sumBorrows) = addExp(
localResults.borrowTotalValue,
localResults.sumBorrows
);
if (err != Error.NO_ERROR) {
return (err, Exp({mantissa: 0}), Exp({mantissa: 0}));
|
(err, localResults.sumBorrows) = addExp(
localResults.borrowTotalValue,
localResults.sumBorrows
);
if (err != Error.NO_ERROR) {
return (err, Exp({mantissa: 0}), Exp({mantissa: 0}));
| 21,066
|
49
|
// 2% fee if a user deposits and withdraws between after 1 day but before 3 days.
|
pool.lpToken.safeTransfer(
address(msg.sender),
_amount.mul(userFeeStage[3]).div(100)
);
pool.lpToken.safeTransfer(
address(devaddr),
_amount.mul(devFeeStage[3]).div(100)
);
|
pool.lpToken.safeTransfer(
address(msg.sender),
_amount.mul(userFeeStage[3]).div(100)
);
pool.lpToken.safeTransfer(
address(devaddr),
_amount.mul(devFeeStage[3]).div(100)
);
| 17,136
|
34
|
// Owner can set extentions. _whitelist Value in bool. True if using whitelist /
|
function setPoolExtentions(bool _whitelist) external onlyOwner {
useWhitelist = _whitelist;
emit PoolStatsChanged();
}
|
function setPoolExtentions(bool _whitelist) external onlyOwner {
useWhitelist = _whitelist;
emit PoolStatsChanged();
}
| 24,214
|
15
|
// return offset The offset of the packed immutable args in calldata
|
function _getImmutableArgsOffset() internal pure returns (uint256 offset) {
// solhint-disable-next-line no-inline-assembly
assembly {
offset := sub(
calldatasize(),
shr(0xf0, calldataload(sub(calldatasize(), 2)))
)
}
}
|
function _getImmutableArgsOffset() internal pure returns (uint256 offset) {
// solhint-disable-next-line no-inline-assembly
assembly {
offset := sub(
calldatasize(),
shr(0xf0, calldataload(sub(calldatasize(), 2)))
)
}
}
| 29,835
|
98
|
// return Returns the fundsAddress
|
function getFundsAddress() public view returns (address) {
return fundsAddress;
}
|
function getFundsAddress() public view returns (address) {
return fundsAddress;
}
| 13,164
|
224
|
// Get trade taker relative fee at given block number, possibly discounted by discount tier value/blockNumber The concerned block number/discountTier The concerned discount tier
|
function tradeTakerFee(uint256 blockNumber, int256 discountTier)
public
view
returns (int256)
|
function tradeTakerFee(uint256 blockNumber, int256 discountTier)
public
view
returns (int256)
| 58,971
|
61
|
// set the new price of the celebrity
|
celeb.price = _nextPrice(salePrice);
|
celeb.price = _nextPrice(salePrice);
| 6,377
|
72
|
// refund dust
|
if (hdcoreAmount > optimalHdcoreAmount)
IERC20(_hdcoreToken).transfer(to, hdcoreAmount.sub(optimalHdcoreAmount));
if (wethAmount > optimalWETHAmount) {
uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount);
_WETH.withdraw(withdrawAmount);
to.transfer(withdrawAmount);
}
|
if (hdcoreAmount > optimalHdcoreAmount)
IERC20(_hdcoreToken).transfer(to, hdcoreAmount.sub(optimalHdcoreAmount));
if (wethAmount > optimalWETHAmount) {
uint256 withdrawAmount = wethAmount.sub(optimalWETHAmount);
_WETH.withdraw(withdrawAmount);
to.transfer(withdrawAmount);
}
| 22,761
|
43
|
// Note that there is no minimum amountOut parameter: this is handled by `IVault.exitPool`.
|
_require(tokenIndex < balances.length, Errors.OUT_OF_BOUNDS);
uint256 amountOut = WeightedMath._calcTokenOutGivenExactBptIn(
balances[tokenIndex],
normalizedWeights[tokenIndex],
bptAmountIn,
totalSupply(),
getSwapFeePercentage()
);
|
_require(tokenIndex < balances.length, Errors.OUT_OF_BOUNDS);
uint256 amountOut = WeightedMath._calcTokenOutGivenExactBptIn(
balances[tokenIndex],
normalizedWeights[tokenIndex],
bptAmountIn,
totalSupply(),
getSwapFeePercentage()
);
| 4,093
|
271
|
// Cap for total amount deposited into vault
|
uint256 public cap;
|
uint256 public cap;
| 18,768
|
53
|
// prepare our msg data.by storing this we are able to verify that all admins are approving the same argument input to be executed for the function.we hash it and store in bytes32 so its size is known and comparable
|
bytes32 _msgData = keccak256(msg.data);
|
bytes32 _msgData = keccak256(msg.data);
| 227
|
15
|
// Emitted when a new log was created author Author address contentHash Deterministic unique ID, hash of the content content Content string /
|
event Content(address indexed author, bytes32 indexed contentHash, string content);
|
event Content(address indexed author, bytes32 indexed contentHash, string content);
| 9,426
|
6
|
// Purchase oToken
|
(bool success,) = exchange.call{value: _0xFee}(_0xSwapData);
|
(bool success,) = exchange.call{value: _0xFee}(_0xSwapData);
| 50,617
|
0
|
// quando usa barra asterisco serve abrir e fazer comentários maiores com mais linhas e tem que terminar e termina o comentário com asterisco barra/ string = é igual a texto, uma variável, pode colocar o que quiser, mas temque colocar entre aspasuint256 = e igual a número inteiro de 0 até 256 caracteres quase infinito, pode usar só o termo UINT, ou uint8 cabe até 8 caracteres, não tem numeros negativosaddress = e igual a endereço ethereumbool = e igual a verdadeiro ou falsouint256 constant = e uma variavel constante e tem que definir valoresquando coloca ponto e virgula é
|
string public locatario;
string public locador;
uint256 private valor;
uint256 constant numeroMaximoLegalDeAlugieisParaMulta = 3;
constructor(string memory nomeLocador, string memory nomeLocatario, uint256 valorDoAluguel) public
|
string public locatario;
string public locador;
uint256 private valor;
uint256 constant numeroMaximoLegalDeAlugieisParaMulta = 3;
constructor(string memory nomeLocador, string memory nomeLocatario, uint256 valorDoAluguel) public
| 19,099
|
2
|
// xpGainLose
|
uint8 public xpGainLose = 5;
|
uint8 public xpGainLose = 5;
| 40,041
|
14
|
// royalties by xrpant/junk
|
function supportsInterface(bytes4 interfaceID) public view override returns(bool) {
return interfaceID == type(IERC2981Royalties).interfaceId || super.supportsInterface(interfaceID);
}
|
function supportsInterface(bytes4 interfaceID) public view override returns(bool) {
return interfaceID == type(IERC2981Royalties).interfaceId || super.supportsInterface(interfaceID);
}
| 25,396
|
9
|
// Sets the `platformFeePBS`. Calling conditions:- The caller must be the owner of the contract.platformFeeBPS_ Platform fee amount in bps (basis points). /
|
function setPlatformFeeBPS(uint16 platformFeeBPS_) external;
|
function setPlatformFeeBPS(uint16 platformFeeBPS_) external;
| 42,571
|
237
|
// Set crowdsale address which can distribute tokens even when onlyWhenTransferAllowed is false.crowdsaleAddr Address of token offering contract./
|
function setCrowdsaleAddress(
address crowdsaleAddr
)
external
onlyOwner()
|
function setCrowdsaleAddress(
address crowdsaleAddr
)
external
onlyOwner()
| 25,146
|
80
|
// divisor cannot be zero with existing outflow
|
return totalRewardLeft / totalGDAOutFlowrate > (liquidationPeriod - patricianPeriod).toInt256();
|
return totalRewardLeft / totalGDAOutFlowrate > (liquidationPeriod - patricianPeriod).toInt256();
| 10,716
|
177
|
// A descriptive name for a collection of NFTs in this contract return descriptive name./
|
function name() external pure override returns (string memory) {
return NAME;
}
|
function name() external pure override returns (string memory) {
return NAME;
}
| 20,317
|
1
|
// Events /
|
event ERC20DepositInitiated(
address indexed _l1Token,
address indexed _l2Token,
address indexed _from,
address _to,
uint256 _amount,
bytes _data
);
|
event ERC20DepositInitiated(
address indexed _l1Token,
address indexed _l2Token,
address indexed _from,
address _to,
uint256 _amount,
bytes _data
);
| 39,614
|
182
|
// Math Library for non-standard Math functionsNOTE: This file is a clone of the dydx protocol's Decimal.sol contract.2d8454e02702fe5bc455b848556660629c3cad36. It has not been modified other than to use anewer solidity in the pragma to match the rest of the contract suite of this project. /
|
library Math {
|
library Math {
| 41,934
|
0
|
// using SafeERC20 for DAOToken;
|
ProposalInterface proposalGate;
|
ProposalInterface proposalGate;
| 40,733
|
6
|
// tokens addresses
|
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
|
address aTokenAddress;
address stableDebtTokenAddress;
address variableDebtTokenAddress;
| 15,071
|
0
|
// Initializing service contract address in constructor
|
constructor(){
serviceContractAddress = 0xA6Abc17819738299B3B2c1CE46d55c74f04E290C;
}
|
constructor(){
serviceContractAddress = 0xA6Abc17819738299B3B2c1CE46d55c74f04E290C;
}
| 11,420
|
339
|
// Reveal `_outcome` vote of `_voter` for vote `_voteId`_voteId ID of the vote instance to reveal a vote of_voter Address of the voter to reveal a vote for_outcome Outcome revealed by the voter_salt Salt to decrypt and validate the committed vote of the voter/
|
function reveal(uint256 _voteId, address _voter, uint8 _outcome, bytes32 _salt) external voteExists(_voteId) {
Vote storage vote = voteRecords[_voteId];
CastVote storage castVote = vote.votes[_voter];
_checkValidSalt(castVote, _outcome, _salt);
require(_isValidOutcome(vote, _outcome), ERROR_INVALID_OUTCOME);
uint256 weight = _ensureVoterCanReveal(_voteId, _voter);
castVote.outcome = _outcome;
_updateTally(vote, _outcome, weight);
emit VoteRevealed(_voteId, _voter, _outcome);
}
|
function reveal(uint256 _voteId, address _voter, uint8 _outcome, bytes32 _salt) external voteExists(_voteId) {
Vote storage vote = voteRecords[_voteId];
CastVote storage castVote = vote.votes[_voter];
_checkValidSalt(castVote, _outcome, _salt);
require(_isValidOutcome(vote, _outcome), ERROR_INVALID_OUTCOME);
uint256 weight = _ensureVoterCanReveal(_voteId, _voter);
castVote.outcome = _outcome;
_updateTally(vote, _outcome, weight);
emit VoteRevealed(_voteId, _voter, _outcome);
}
| 44,893
|
247
|
// Balance of want + balance in AAVE
|
uint256 liquidBalance =
want.balanceOf(address(this)).add(deposited()).sub(borrowed());
|
uint256 liquidBalance =
want.balanceOf(address(this)).add(deposited()).sub(borrowed());
| 11,086
|
114
|
// Executed when a purchase has been validated and is ready to be executed. Doesn't necessarily emit/sendtokens. beneficiary Address receiving the tokens tokenAmount Number of tokens to be purchased /
|
function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
_deliverTokens(beneficiary, tokenAmount);
}
|
function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
_deliverTokens(beneficiary, tokenAmount);
}
| 8,120
|
25
|
// uint radius = calculateRadius(8, offset);
|
uint radius = calculateRadius(tokenAttributes[tokenId].intensity, offset);
pathItems = string.concat(pathItems,
"<g class='c' style='--n: ",
Strings.toString(offset),
";' >",
"<circle class='cs-c1' stroke-width='",
Strings.toString(radius / 3), // Strings.toString(rads[offset - 1] / 2),
"' cx='320' cy='320' r='",
Strings.toString(radius),
|
uint radius = calculateRadius(tokenAttributes[tokenId].intensity, offset);
pathItems = string.concat(pathItems,
"<g class='c' style='--n: ",
Strings.toString(offset),
";' >",
"<circle class='cs-c1' stroke-width='",
Strings.toString(radius / 3), // Strings.toString(rads[offset - 1] / 2),
"' cx='320' cy='320' r='",
Strings.toString(radius),
| 7,756
|
97
|
// organizationId => averageBoostDownstakes
|
mapping(bytes32 => uint256 ) public averagesDownstakesOfBoosted;
uint256 constant public NUM_OF_CHOICES = 2;
uint256 constant public NO = 2;
uint256 constant public YES = 1;
uint256 public proposalsCnt; // Total number of proposals
IERC20 public stakingToken;
address constant private GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf;
uint256 constant private MAX_BOOSTED_PROPOSALS = 4096;
|
mapping(bytes32 => uint256 ) public averagesDownstakesOfBoosted;
uint256 constant public NUM_OF_CHOICES = 2;
uint256 constant public NO = 2;
uint256 constant public YES = 1;
uint256 public proposalsCnt; // Total number of proposals
IERC20 public stakingToken;
address constant private GEN_TOKEN_ADDRESS = 0x543Ff227F64Aa17eA132Bf9886cAb5DB55DCAddf;
uint256 constant private MAX_BOOSTED_PROPOSALS = 4096;
| 18,538
|
10
|
// Internal function that removes the given `account` from `_mintLimiters`.Emits a MintLimiterRemoved event.account The account address having access removed from the mintLimiter role /
|
function _removeMintLimiter(address account) internal {
_mintLimiters.remove(account);
emit MintLimiterRemoved(account);
}
|
function _removeMintLimiter(address account) internal {
_mintLimiters.remove(account);
emit MintLimiterRemoved(account);
}
| 8,682
|
111
|
// `maxBatchSize` refers to how much a minter can mint at a time. `collectionSize_` refers to how many tokens are in the collection./
|
constructor(
string memory name_,
string memory symbol_,
uint256 maxBatchSize_,
uint256 collectionSize_
|
constructor(
string memory name_,
string memory symbol_,
uint256 maxBatchSize_,
uint256 collectionSize_
| 34,385
|
32
|
// Checks if a given address is on the merkle tree allowlist/Merkle trees can be generated using https:github.com/OpenZeppelin/merkle-tree/account The address to check/merkleProof The merkle proof to check/ return Whether the address is on the allowlist or not
|
function isValidMerkleProof(
address account,
bytes32[] calldata merkleProof
|
function isValidMerkleProof(
address account,
bytes32[] calldata merkleProof
| 7,228
|
17
|
// import "Permissioned.sol";/Permissioned
|
contract Permissioned is Owned {
using SafeMath for uint;
struct Permission {
bool active;
uint maximum;
uint processed;
}
uint public constant ROLE_MINTER = 1;
// Don't need ROLE_BURNER at the moment
// uint public constant ROLE_BURNER = 2;
mapping(address => mapping(uint => Permission)) public permissions;
modifier permitted(uint role, uint tokens) {
Permission storage permission = permissions[msg.sender][role];
require(permission.active && (permission.maximum == 0 || permission.processed + tokens < permission.maximum), "Not permissioned");
permission.processed = permission.processed.add(tokens);
_;
}
function initPermissioned(address _owner) internal {
initOwned(_owner);
setPermission(_owner, ROLE_MINTER, true, 0);
// setPermission(_owner, ROLE_BURNER, true, 0);
}
function setPermission(address account, uint role, bool active, uint maximum) public {
uint processed = permissions[account][role].processed;
permissions[account][role] = Permission({ active: active, maximum: maximum, processed: processed });
}
}
|
contract Permissioned is Owned {
using SafeMath for uint;
struct Permission {
bool active;
uint maximum;
uint processed;
}
uint public constant ROLE_MINTER = 1;
// Don't need ROLE_BURNER at the moment
// uint public constant ROLE_BURNER = 2;
mapping(address => mapping(uint => Permission)) public permissions;
modifier permitted(uint role, uint tokens) {
Permission storage permission = permissions[msg.sender][role];
require(permission.active && (permission.maximum == 0 || permission.processed + tokens < permission.maximum), "Not permissioned");
permission.processed = permission.processed.add(tokens);
_;
}
function initPermissioned(address _owner) internal {
initOwned(_owner);
setPermission(_owner, ROLE_MINTER, true, 0);
// setPermission(_owner, ROLE_BURNER, true, 0);
}
function setPermission(address account, uint role, bool active, uint maximum) public {
uint processed = permissions[account][role].processed;
permissions[account][role] = Permission({ active: active, maximum: maximum, processed: processed });
}
}
| 13,441
|
61
|
// a matrix designating the legal state transitions for a promise (see constructor)
|
mapping (uint => mapping(uint => bool)) stateTransitionMatrix;
|
mapping (uint => mapping(uint => bool)) stateTransitionMatrix;
| 14,689
|
190
|
// _amount = 10000000000000000000000000 (mints 10M tokens right away)
|
constructor(
address _vestingBeneficiary,
uint256 _amount
|
constructor(
address _vestingBeneficiary,
uint256 _amount
| 18,286
|
17
|
// calculate amount of dai we need
|
uint256 requiredDAI;
{
requiredDAI = (toDAI(amount, token) * _COLLAT_RATIO_PRECISION) / collatRatioDAI;
uint256 requiredDAIToCloseLTVGap = 0;
if (depositToCloseLTVGap > 0) {
requiredDAIToCloseLTVGap = toDAI(depositToCloseLTVGap, token);
requiredDAI = requiredDAI + requiredDAIToCloseLTVGap;
}
|
uint256 requiredDAI;
{
requiredDAI = (toDAI(amount, token) * _COLLAT_RATIO_PRECISION) / collatRatioDAI;
uint256 requiredDAIToCloseLTVGap = 0;
if (depositToCloseLTVGap > 0) {
requiredDAIToCloseLTVGap = toDAI(depositToCloseLTVGap, token);
requiredDAI = requiredDAI + requiredDAIToCloseLTVGap;
}
| 704
|
0
|
// IERC725Y type variable representing the account from where to retrieve the keys /
|
IERC725Y public erc725Y;
|
IERC725Y public erc725Y;
| 37,368
|
58
|
// Check that there are funds to drain
|
uint256 balance = address(this).balance;
require(balance > 0, "No funds to drain");
uint256[] memory shares = new uint256[](recipients.length);
|
uint256 balance = address(this).balance;
require(balance > 0, "No funds to drain");
uint256[] memory shares = new uint256[](recipients.length);
| 16,117
|
47
|
// 8. Transfer token
|
obToken.transfer(buyer, rewardAmount);
|
obToken.transfer(buyer, rewardAmount);
| 1,404
|
231
|
// Ensures that only transactions with a trusted signature can be relayed through the GSN. /
|
function acceptRelayedCall(
address relay,
address from,
bytes memory encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
bytes memory approvalData,
uint256 /* maxPossibleCharge */
|
function acceptRelayedCall(
address relay,
address from,
bytes memory encodedFunction,
uint256 transactionFee,
uint256 gasPrice,
uint256 gasLimit,
uint256 nonce,
bytes memory approvalData,
uint256 /* maxPossibleCharge */
| 43,394
|
3
|
// Retrieves the total supply at the time `snapshotId` was created. /
|
function totalSupplyAt(uint256 snapshotId)
public
view
virtual
returns (uint256)
|
function totalSupplyAt(uint256 snapshotId)
public
view
virtual
returns (uint256)
| 8,529
|
199
|
// Helper function to get the decimals of an asset. Will just hardcode for the time being. asset is the token which we want to know the decimals /
|
function assetDecimals(address asset) private view returns (uint256) {
// USDC
if (asset == USDC) {
return 6;
}
return 18;
}
|
function assetDecimals(address asset) private view returns (uint256) {
// USDC
if (asset == USDC) {
return 6;
}
return 18;
}
| 28,690
|
27
|
// openTrading
|
function kamehameha() external onlyOwner() {
require(!tradingOpen, "trading is already open");
uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 10000000 * DECIMAL_FACTOR;
tradingOpen = true;
IERC20(address(uniswapV2Pair)).approve(
address(uniswapV2Router),
type(uint256).max
);
emit TradingStarted(uniswapV2Pair.token0(), uniswapV2Pair.token1());
}
|
function kamehameha() external onlyOwner() {
require(!tradingOpen, "trading is already open");
uniswapV2Router.addLiquidityETH{value: address(this).balance}(
address(this),
balanceOf(address(this)),
0,
0,
owner(),
block.timestamp
);
swapEnabled = true;
cooldownEnabled = true;
_maxTxAmount = 10000000 * DECIMAL_FACTOR;
tradingOpen = true;
IERC20(address(uniswapV2Pair)).approve(
address(uniswapV2Router),
type(uint256).max
);
emit TradingStarted(uniswapV2Pair.token0(), uniswapV2Pair.token1());
}
| 77,982
|
9
|
// solium-disable-next-line arg-overflow
|
return ecrecover(hash, v, r, s);
|
return ecrecover(hash, v, r, s);
| 5,676
|
73
|
// Finalizes the relay entry timeout notification reward/ multiplier update process./Can be called only by the contract owner, after the governance/delay elapses.
|
function finalizeRelayEntryTimeoutNotificationRewardMultiplierUpdate()
external
onlyOwner
onlyAfterGovernanceDelay(
relayEntryTimeoutNotificationRewardMultiplierChangeInitiated,
STANDARD_PARAMETER_GOVERNANCE_DELAY
)
|
function finalizeRelayEntryTimeoutNotificationRewardMultiplierUpdate()
external
onlyOwner
onlyAfterGovernanceDelay(
relayEntryTimeoutNotificationRewardMultiplierChangeInitiated,
STANDARD_PARAMETER_GOVERNANCE_DELAY
)
| 35,590
|
133
|
// returns the array of reserve tokens return array of reserve tokens /
|
function reserveTokens() public view returns (IERC20Token[] memory) {
return __reserveTokens;
}
|
function reserveTokens() public view returns (IERC20Token[] memory) {
return __reserveTokens;
}
| 38,220
|
658
|
// column21_row9/ mload(0x2e20), Numerator: 1. val = 1. val := mulmod(val, 1, PRIME). Denominator: point^(trace_length / 4096) - 1. val = denominator_invs[20].
|
val := mulmod(val, mload(0x3de0), PRIME)
|
val := mulmod(val, mload(0x3de0), PRIME)
| 59,079
|
0
|
// used for representation of collateralization collateralization between 0 and 1 (1=100%)value might be larger when overcollateralization
|
uint256 public constant FULL_COLLATERALIZATION_LEVEL = 10**18;
string public constant DEFAULT_FILTER_DATA_STRUCTURE = "";
IInstanceService internal _instanceService;
IRiskpoolService internal _riskpoolService;
IERC721 internal _bundleToken;
|
uint256 public constant FULL_COLLATERALIZATION_LEVEL = 10**18;
string public constant DEFAULT_FILTER_DATA_STRUCTURE = "";
IInstanceService internal _instanceService;
IRiskpoolService internal _riskpoolService;
IERC721 internal _bundleToken;
| 40,679
|
10
|
// emit an event
|
emit TokensSold(msg.sender, address(token), _amount, rate);
|
emit TokensSold(msg.sender, address(token), _amount, rate);
| 16,666
|
23
|
// Sets `swapper` as an authorized address for swap operations.swapper Address of the swapper to allow/disallow. allowed "true" to allow, "false" to disallow.Requirements: - `swapper` must be a non-zero address. - `allowed` must be different the previously recorded for the same `swapper`. - Emits a `AllowSwapper` event. /
|
function allowSwapper(address swapper, bool allowed) external onlyTimelock {
_checkInputIsNotZeroAddress(swapper);
if (allowedSwapper[swapper] == allowed) {
revert Chief__allowSwapper_noAllowChange();
}
allowedSwapper[swapper] = allowed;
emit AllowSwapper(swapper, allowed);
}
|
function allowSwapper(address swapper, bool allowed) external onlyTimelock {
_checkInputIsNotZeroAddress(swapper);
if (allowedSwapper[swapper] == allowed) {
revert Chief__allowSwapper_noAllowChange();
}
allowedSwapper[swapper] = allowed;
emit AllowSwapper(swapper, allowed);
}
| 13,606
|
3
|
// safe approve
|
IERC20(manager.stableSwapMetaPoolAddress()).safeApprove(
address(this),
amount
);
|
IERC20(manager.stableSwapMetaPoolAddress()).safeApprove(
address(this),
amount
);
| 51,558
|
5
|
// Get liquidity node at tick tick Tickreturn Liquidity node /
|
function liquidityNode(uint128 tick) external view returns (NodeInfo memory);
|
function liquidityNode(uint128 tick) external view returns (NodeInfo memory);
| 13,627
|
35
|
// Set the address mapping to false to indicate it is NOT an administrator account.
|
administrators[adminToRemove] = false;
|
administrators[adminToRemove] = false;
| 9,067
|
64
|
// Now remit any collected fees. Since the constructor enforces that creatorFee + poolFee < 1, the balance in the contract will be sufficient to cover these transfers.
|
IERC20 sUSD = _sUSD();
uint _deposited = deposited;
uint poolFees = _deposited.multiplyDecimalRound(fees.poolFee);
uint creatorFees = _deposited.multiplyDecimalRound(fees.creatorFee);
_decrementDeposited(creatorFees.add(poolFees));
sUSD.transfer(_feePool().FEE_ADDRESS(), poolFees);
sUSD.transfer(creator, creatorFees);
emit MarketResolved(_result(), price, updatedAt, deposited, poolFees, creatorFees);
|
IERC20 sUSD = _sUSD();
uint _deposited = deposited;
uint poolFees = _deposited.multiplyDecimalRound(fees.poolFee);
uint creatorFees = _deposited.multiplyDecimalRound(fees.creatorFee);
_decrementDeposited(creatorFees.add(poolFees));
sUSD.transfer(_feePool().FEE_ADDRESS(), poolFees);
sUSD.transfer(creator, creatorFees);
emit MarketResolved(_result(), price, updatedAt, deposited, poolFees, creatorFees);
| 32,926
|
72
|
// Worker with qualification "ONE" earn 1 token per minute, "TWO" earn 2 tokens, etc...
|
uint256 profitMinutes = uint256(SafeMath.div(SafeMath.sub(now, WorkerWorkStart[msg.sender]), 60));
if (profitMinutes > 0) {
uint8 qualification = WorkerQualification[msg.sender];
uint256 profitEFT = SafeMath.mul(uint256(qualification),profitMinutes);
require (profitEFT > 0);
mint(msg.sender,profitEFT);
|
uint256 profitMinutes = uint256(SafeMath.div(SafeMath.sub(now, WorkerWorkStart[msg.sender]), 60));
if (profitMinutes > 0) {
uint8 qualification = WorkerQualification[msg.sender];
uint256 profitEFT = SafeMath.mul(uint256(qualification),profitMinutes);
require (profitEFT > 0);
mint(msg.sender,profitEFT);
| 30,389
|
305
|
// Checks for rounding errors and returns value of potential partial amounts of a principal _principal Number fractional amount is derived from_numerator Numerator of fraction_denominator Denominator of fractionreturn uint256Fractional amount of principal calculated /
|
function getPartialAmount(
uint256 _principal,
uint256 _numerator,
uint256 _denominator
)
internal
pure
returns (uint256)
|
function getPartialAmount(
uint256 _principal,
uint256 _numerator,
uint256 _denominator
)
internal
pure
returns (uint256)
| 12,397
|
263
|
// 2. Encode arguments of functions and create action for calling it
|
bytes memory data = abi.encode(deficit, amountWant);
operations[1] = _getCallAction(
data
);
|
bytes memory data = abi.encode(deficit, amountWant);
operations[1] = _getCallAction(
data
);
| 44,816
|
3
|
// Check the the mint request wouldn't exceed the total supply. This must be performed here using whatever mechanism you use to track the token number
|
require(
(_tokenIdCounter.current() + quantityToMint_) <= maxSupply,
"Amount to mint exceeds supply"
);
|
require(
(_tokenIdCounter.current() + quantityToMint_) <= maxSupply,
"Amount to mint exceeds supply"
);
| 28,082
|
224
|
// get price for a currency
|
function getPrice(bytes32 currencyName) external view returns (uint);
|
function getPrice(bytes32 currencyName) external view returns (uint);
| 10,445
|
89
|
// Adds two exponentials, returning a new exponential. /
|
function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {
(MathError error, uint result) = addUInt(a.mantissa, b.mantissa);
return (error, Exp({mantissa: result}));
}
|
function addExp(Exp memory a, Exp memory b) pure internal returns (MathError, Exp memory) {
(MathError error, uint result) = addUInt(a.mantissa, b.mantissa);
return (error, Exp({mantissa: result}));
}
| 17,295
|
118
|
// sumCollateral += tokensToDenomjTokenBalance
|
vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.jTokenBalance, vars.sumCollateral);
|
vars.sumCollateral = mul_ScalarTruncateAddUInt(vars.tokensToDenom, vars.jTokenBalance, vars.sumCollateral);
| 8,610
|
13
|
// Burns the LiquidityCertificate.spender The account which is performing the burn. certificateId The id of the LiquidityCertificate. /
|
function burn(address spender, uint certificateId) external onlyLiquidityPool {
require(_isApprovedOrOwner(spender, certificateId), "attempted to burn nonexistent certificate, or not owner");
delete _certificateData[certificateId];
_burn(certificateId);
}
|
function burn(address spender, uint certificateId) external onlyLiquidityPool {
require(_isApprovedOrOwner(spender, certificateId), "attempted to burn nonexistent certificate, or not owner");
delete _certificateData[certificateId];
_burn(certificateId);
}
| 16,718
|
20
|
// TRANSFER FROM MSG.SENDER TO ADDRESS(THIS)
|
IERC20(token).transferFrom(msg.sender, address(this), msg.value);
|
IERC20(token).transferFrom(msg.sender, address(this), msg.value);
| 19,043
|
33
|
// Caps per token supply to 10 editions
|
require(
(_globalEditions[id] + amount) <= _editionLimit,
"ERC1155: exceeded token maximum editions"
);
address operator = _msgSender();
_beforeTokenTransfer(
operator,
address(0),
|
require(
(_globalEditions[id] + amount) <= _editionLimit,
"ERC1155: exceeded token maximum editions"
);
address operator = _msgSender();
_beforeTokenTransfer(
operator,
address(0),
| 22,220
|
1
|
// Function responsible for cross chain transfer from l2 to l1 or supported l2s. Called by the registry when the selected bridge is Hop bridge.Try to check for the liquidity on the other side before calling this._amount amount to be sent._from sender address_receiverAddress receiver address_toChainId Destination Chain Id_token address of the token to bridged to the destination chain. _data data required to call the Hop swap and send function. hopAmm address, boderfee, amount out min and deadline./
|
function outboundTransferTo(
uint256 _amount,
address _from,
address _receiverAddress,
address _token,
uint256 _toChainId,
bytes calldata _data
|
function outboundTransferTo(
uint256 _amount,
address _from,
address _receiverAddress,
address _token,
uint256 _toChainId,
bytes calldata _data
| 17,475
|
599
|
// _updateRole(_firstAB, uint(Role.Member), true);
|
launchedOn = 0;
|
launchedOn = 0;
| 28,766
|
137
|
// Tranche balance
|
uint256 deposit; // User deposit
uint256 capacity; // Capacity for user's intended tranche
uint256 change; // Change from deposit - capacity
|
uint256 deposit; // User deposit
uint256 capacity; // Capacity for user's intended tranche
uint256 change; // Change from deposit - capacity
| 50,610
|
27
|
// Returns the block coinbase
|
function getCurrentBlockCoinbase() public view returns (address coinbase) {
coinbase = block.coinbase;
}
|
function getCurrentBlockCoinbase() public view returns (address coinbase) {
coinbase = block.coinbase;
}
| 10,718
|
79
|
// Get target address from the serialized migration data ser_data Serialized migration datareturn target Target contract address /
|
function _getMigrationTarget(bytes memory ser_data) internal pure returns (address target) {
target = ser_data.toAddress(ser_data.length - 20);
}
|
function _getMigrationTarget(bytes memory ser_data) internal pure returns (address target) {
target = ser_data.toAddress(ser_data.length - 20);
}
| 32,077
|
175
|
// fee charged for flashloans (WAD, 100% == 1 WAD)
|
uint256 public flashLoanFee;
|
uint256 public flashLoanFee;
| 50,562
|
2
|
// Get the pool id of the maker address.
|
bytes32 poolId = poolIdByMaker[makerAddress];
|
bytes32 poolId = poolIdByMaker[makerAddress];
| 21,917
|
154
|
// Execute a transfer with a signed authorization fromPayer's address (Authorizer) toPayee's address value Amount to be transferred validAfterThe time after which this is valid (unix time) validBefore The time before which this is valid (unix time) nonce Unique nonce v v of the signature r r of the signature s s of the signature /
|
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
|
function transferWithAuthorization(
address from,
address to,
uint256 value,
uint256 validAfter,
uint256 validBefore,
bytes32 nonce,
uint8 v,
bytes32 r,
bytes32 s
| 20,254
|
52
|
// See {IERC721Metadata-tokenURI}. The implementation of this method was taken from {ERC721URIStorage} butmade tweakings as necessary to the use case. /
|
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721URIStorage: URI query for nonexistent token"
|
function tokenURI(uint256 tokenId)
public
view
virtual
override
returns (string memory)
{
require(
_exists(tokenId),
"ERC721URIStorage: URI query for nonexistent token"
| 52,626
|
48
|
// if there's no fee for the individual user then set it to the general fee
|
v = genFee;
|
v = genFee;
| 80,928
|
1
|
// Returns the current implementation of a proxy.This is needed because only the proxy admin can query it.return The address of the current implementation of the proxy. /
|
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
|
function getProxyImplementation(AdminUpgradeabilityProxy proxy) public view returns (address) {
// We need to manually run the static call since the getter cannot be flagged as view
// bytes4(keccak256("implementation()")) == 0x5c60da1b
(bool success, bytes memory returndata) = address(proxy).staticcall(hex"5c60da1b");
require(success);
return abi.decode(returndata, (address));
}
| 31,227
|
50
|
// Returns the pending YAXs for a given account _account The address to query /
|
function pendingYax(address _account) public view returns (uint _pending) {
UserInfo storage user = userInfo[_account];
uint _accYaxPerShare = accYaxPerShare;
uint lpSupply = balanceOf(address(this));
if (block.number > lastRewardBlock && lpSupply != 0) {
uint256 _multiplier = getMultiplier(lastRewardBlock, block.number);
_accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply));
}
_pending = user.amount.mul(_accYaxPerShare).div(1e12).sub(user.yaxRewardDebt);
}
|
function pendingYax(address _account) public view returns (uint _pending) {
UserInfo storage user = userInfo[_account];
uint _accYaxPerShare = accYaxPerShare;
uint lpSupply = balanceOf(address(this));
if (block.number > lastRewardBlock && lpSupply != 0) {
uint256 _multiplier = getMultiplier(lastRewardBlock, block.number);
_accYaxPerShare = accYaxPerShare.add(_multiplier.mul(yaxPerBlock).mul(1e12).div(lpSupply));
}
_pending = user.amount.mul(_accYaxPerShare).div(1e12).sub(user.yaxRewardDebt);
}
| 19,879
|
29
|
// 清算线
|
uint256 public constant KILL_FACTOR_MANTISSA = 1.1 * 1e18; //110%
|
uint256 public constant KILL_FACTOR_MANTISSA = 1.1 * 1e18; //110%
| 48,831
|
67
|
// how much ETH did we just swap into?
|
uint256 newBalance = address(this).balance.sub(initialBalance);
|
uint256 newBalance = address(this).balance.sub(initialBalance);
| 29,700
|
43
|
// If we check and the interest rate is no longer negative then we allow normal 1 to 1 withdraws [even if the speedbump was hit less than 48 hours ago, to prevent possible griefing]
|
if (holdings < localSupply) {
|
if (holdings < localSupply) {
| 24,271
|
10
|
// Returns the downcasted int32 from int256, reverting onoverflow (when the input is less than smallest int32 orgreater than largest int32). Counterpart to Solidity's `int32` operator. Requirements: - input must fit into 32 bits _Available since v3.1._ /
|
function toInt32(int256 value) internal pure returns (int32) {
require(
value >= type(int32).min && value <= type(int32).max,
"SafeCast: value doesn't fit in 32 bits"
);
return int32(value);
}
|
function toInt32(int256 value) internal pure returns (int32) {
require(
value >= type(int32).min && value <= type(int32).max,
"SafeCast: value doesn't fit in 32 bits"
);
return int32(value);
}
| 7,822
|
161
|
// only take fees on buys/sells, do not take on wallet transfers
|
if(takeFee){
|
if(takeFee){
| 6,955
|
9
|
// Super token factory interface Superfluid /
|
interface ISuperTokenFactory {
/**************************************************************************
* Errors
*************************************************************************/
error SUPER_TOKEN_FACTORY_ALREADY_EXISTS(); // 0x91d67972
error SUPER_TOKEN_FACTORY_DOES_NOT_EXIST(); // 0x872cac48
error SUPER_TOKEN_FACTORY_UNINITIALIZED(); // 0x1b39b9b4
error SUPER_TOKEN_FACTORY_ONLY_HOST(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_NON_UPGRADEABLE_IS_DEPRECATED(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_ZERO_ADDRESS(); // 0x305c9e82
/**************************************************************************
* Immutable Variables
**************************************************************************/
/**
* @dev Get superfluid host contract address
*/
function getHost() external view returns(address host);
/// @dev Initialize the contract
function initialize() external;
/**
* @notice Get the canonical super token logic.
*/
function getSuperTokenLogic() external view returns (ISuperToken superToken);
/**
* @dev Upgradability modes
*/
enum Upgradability {
/// Non upgradable super token, `host.updateSuperTokenLogic` will revert
NON_UPGRADABLE,
/// Upgradable through `host.updateSuperTokenLogic` operation
SEMI_UPGRADABLE,
/// Always using the latest super token logic
FULL_UPGRADABLE
}
/**
* @notice Create new super token wrapper for the underlying ERC20 token
* @param underlyingToken Underlying ERC20 token
* @param underlyingDecimals Underlying token decimals
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @return superToken The deployed and initialized wrapper super token
*/
function createERC20Wrapper(
IERC20 underlyingToken,
uint8 underlyingDecimals,
Upgradability upgradability,
string calldata name,
string calldata symbol
)
external
returns (ISuperToken superToken);
/**
* @notice Create new super token wrapper for the underlying ERC20 token with extra token info
* @param underlyingToken Underlying ERC20 token
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @return superToken The deployed and initialized wrapper super token
* NOTE:
* - It assumes token provide the .decimals() function
*/
function createERC20Wrapper(
ERC20WithTokenInfo underlyingToken,
Upgradability upgradability,
string calldata name,
string calldata symbol
)
external
returns (ISuperToken superToken);
/**
* @notice Creates a wrapper super token AND sets it in the canonical list OR reverts if it already exists
* @dev salt for create2 is the keccak256 hash of abi.encode(address(_underlyingToken))
* @param _underlyingToken Underlying ERC20 token
* @return ISuperToken the created supertoken
*/
function createCanonicalERC20Wrapper(ERC20WithTokenInfo _underlyingToken)
external
returns (ISuperToken);
/**
* @notice Computes/Retrieves wrapper super token address given the underlying token address
* @dev We return from our canonical list if it already exists, otherwise we compute it
* @dev note that this function only computes addresses for SEMI_UPGRADABLE SuperTokens
* @param _underlyingToken Underlying ERC20 token address
* @return superTokenAddress Super token address
* @return isDeployed whether the super token is deployed AND set in the canonical mapping
*/
function computeCanonicalERC20WrapperAddress(address _underlyingToken)
external
view
returns (address superTokenAddress, bool isDeployed);
/**
* @notice Gets the canonical ERC20 wrapper super token address given the underlying token address
* @dev We return the address if it exists and the zero address otherwise
* @param _underlyingTokenAddress Underlying ERC20 token address
* @return superTokenAddress Super token address
*/
function getCanonicalERC20Wrapper(address _underlyingTokenAddress)
external
view
returns (address superTokenAddress);
/**
* @dev Creates a new custom super token
* @param customSuperTokenProxy address of the custom supertoken proxy
*/
function initializeCustomSuperToken(
address customSuperTokenProxy
)
external;
/**
* @dev Super token logic created event
* @param tokenLogic Token logic address
*/
event SuperTokenLogicCreated(ISuperToken indexed tokenLogic);
/**
* @dev Super token created event
* @param token Newly created super token address
*/
event SuperTokenCreated(ISuperToken indexed token);
/**
* @dev Custom super token created event
* @param token Newly created custom super token address
*/
event CustomSuperTokenCreated(ISuperToken indexed token);
}
|
interface ISuperTokenFactory {
/**************************************************************************
* Errors
*************************************************************************/
error SUPER_TOKEN_FACTORY_ALREADY_EXISTS(); // 0x91d67972
error SUPER_TOKEN_FACTORY_DOES_NOT_EXIST(); // 0x872cac48
error SUPER_TOKEN_FACTORY_UNINITIALIZED(); // 0x1b39b9b4
error SUPER_TOKEN_FACTORY_ONLY_HOST(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_NON_UPGRADEABLE_IS_DEPRECATED(); // 0x478b8e83
error SUPER_TOKEN_FACTORY_ZERO_ADDRESS(); // 0x305c9e82
/**************************************************************************
* Immutable Variables
**************************************************************************/
/**
* @dev Get superfluid host contract address
*/
function getHost() external view returns(address host);
/// @dev Initialize the contract
function initialize() external;
/**
* @notice Get the canonical super token logic.
*/
function getSuperTokenLogic() external view returns (ISuperToken superToken);
/**
* @dev Upgradability modes
*/
enum Upgradability {
/// Non upgradable super token, `host.updateSuperTokenLogic` will revert
NON_UPGRADABLE,
/// Upgradable through `host.updateSuperTokenLogic` operation
SEMI_UPGRADABLE,
/// Always using the latest super token logic
FULL_UPGRADABLE
}
/**
* @notice Create new super token wrapper for the underlying ERC20 token
* @param underlyingToken Underlying ERC20 token
* @param underlyingDecimals Underlying token decimals
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @return superToken The deployed and initialized wrapper super token
*/
function createERC20Wrapper(
IERC20 underlyingToken,
uint8 underlyingDecimals,
Upgradability upgradability,
string calldata name,
string calldata symbol
)
external
returns (ISuperToken superToken);
/**
* @notice Create new super token wrapper for the underlying ERC20 token with extra token info
* @param underlyingToken Underlying ERC20 token
* @param upgradability Upgradability mode
* @param name Super token name
* @param symbol Super token symbol
* @return superToken The deployed and initialized wrapper super token
* NOTE:
* - It assumes token provide the .decimals() function
*/
function createERC20Wrapper(
ERC20WithTokenInfo underlyingToken,
Upgradability upgradability,
string calldata name,
string calldata symbol
)
external
returns (ISuperToken superToken);
/**
* @notice Creates a wrapper super token AND sets it in the canonical list OR reverts if it already exists
* @dev salt for create2 is the keccak256 hash of abi.encode(address(_underlyingToken))
* @param _underlyingToken Underlying ERC20 token
* @return ISuperToken the created supertoken
*/
function createCanonicalERC20Wrapper(ERC20WithTokenInfo _underlyingToken)
external
returns (ISuperToken);
/**
* @notice Computes/Retrieves wrapper super token address given the underlying token address
* @dev We return from our canonical list if it already exists, otherwise we compute it
* @dev note that this function only computes addresses for SEMI_UPGRADABLE SuperTokens
* @param _underlyingToken Underlying ERC20 token address
* @return superTokenAddress Super token address
* @return isDeployed whether the super token is deployed AND set in the canonical mapping
*/
function computeCanonicalERC20WrapperAddress(address _underlyingToken)
external
view
returns (address superTokenAddress, bool isDeployed);
/**
* @notice Gets the canonical ERC20 wrapper super token address given the underlying token address
* @dev We return the address if it exists and the zero address otherwise
* @param _underlyingTokenAddress Underlying ERC20 token address
* @return superTokenAddress Super token address
*/
function getCanonicalERC20Wrapper(address _underlyingTokenAddress)
external
view
returns (address superTokenAddress);
/**
* @dev Creates a new custom super token
* @param customSuperTokenProxy address of the custom supertoken proxy
*/
function initializeCustomSuperToken(
address customSuperTokenProxy
)
external;
/**
* @dev Super token logic created event
* @param tokenLogic Token logic address
*/
event SuperTokenLogicCreated(ISuperToken indexed tokenLogic);
/**
* @dev Super token created event
* @param token Newly created super token address
*/
event SuperTokenCreated(ISuperToken indexed token);
/**
* @dev Custom super token created event
* @param token Newly created custom super token address
*/
event CustomSuperTokenCreated(ISuperToken indexed token);
}
| 13,774
|
39
|
// /
|
function registerSubdomain(
uint256 parentId,
string memory label,
address owner
) external;
|
function registerSubdomain(
uint256 parentId,
string memory label,
address owner
) external;
| 16,528
|
89
|
// Send split amounts to respective balances
|
function _applyShare(address _seller, address _auctioneer, uint _cut) internal
returns (bool success)
|
function _applyShare(address _seller, address _auctioneer, uint _cut) internal
returns (bool success)
| 40,087
|
160
|
// Cancel a single RFQ order. The caller must be the maker or a valid order signer./Silently succeeds if the order has already been cancelled./order The RFQ order.
|
function cancelRfqOrder(LibNativeOrder.RfqOrder calldata order)
external;
|
function cancelRfqOrder(LibNativeOrder.RfqOrder calldata order)
external;
| 47,461
|
16
|
// Implementation of the {IERC20} interface.Additionally, an {Approval} event is emitted on calls to {transferFrom}./ Sets the values for {name}, {symbol} and {decimals} and mints {supply} to {mintAddress} All of these values are immutable: they can only be set once duringconstruction. /
|
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 supply_,
address mintAddress_
) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
|
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_,
uint256 supply_,
address mintAddress_
) {
_name = name_;
_symbol = symbol_;
_decimals = decimals_;
| 31,930
|
5
|
// /
|
function distributeYieldToTreasury() external;
|
function distributeYieldToTreasury() external;
| 21,755
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.