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
|
---|---|---|---|---|
1 | // CONSTANTS USED ACROSS CONTRACTS //Used by all contracts that interfaces with Ethernauts/The ERC-165 interface signature for ERC-721./Ref: https:github.com/ethereum/EIPs/issues/165/Ref: https:github.com/ethereum/EIPs/issues/721 | bytes4 constant InterfaceSignature_ERC721 =
bytes4(keccak256('name()')) ^
bytes4(keccak256('symbol()')) ^
bytes4(keccak256('totalSupply()')) ^
bytes4(keccak256('balanceOf(address)')) ^
bytes4(keccak256('ownerOf(uint256)')) ^
bytes4(keccak256('approve(address,uint256)')) ^
bytes4(keccak256('transfer(address,uint256)')) ^
bytes4(keccak256('transferFrom(address,address,uint256)')) ^
bytes4(keccak256('takeOwnership(uint256)')) ^
| bytes4 constant InterfaceSignature_ERC721 =
bytes4(keccak256('name()')) ^
bytes4(keccak256('symbol()')) ^
bytes4(keccak256('totalSupply()')) ^
bytes4(keccak256('balanceOf(address)')) ^
bytes4(keccak256('ownerOf(uint256)')) ^
bytes4(keccak256('approve(address,uint256)')) ^
bytes4(keccak256('transfer(address,uint256)')) ^
bytes4(keccak256('transferFrom(address,address,uint256)')) ^
bytes4(keccak256('takeOwnership(uint256)')) ^
| 29,935 |
27 | // Implementation of the {IERC20} interface./ Sets the values for {name} and {symbol}, initializes {decimals} witha default value of 18./ | constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
governance = tx.origin;
}
| constructor (string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_decimals = 18;
governance = tx.origin;
}
| 12,132 |
93 | // Returns a list of all Property IDs assigned to an address./_owner The owner whose Properties we are interested in./This method MUST NEVER be called by smart contract code. First, it&39;s fairly/expensive (it walks the entire Kitty array looking for cats belonging to owner),/but it also returns a dynamic array, which is only supported for web3 calls, and/not contract-to-contract calls. | function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalProperties = totalSupply();
uint256 resultIndex = 0;
// We count on the fact that all properties have IDs starting at 1 and increasing
// sequentially up to the totalProperties count.
uint256 tokenId;
for (tokenId = 1; tokenId <= totalProperties; tokenId++) {
if (propertyIndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| function tokensOfOwner(address _owner) external view returns(uint256[] ownerTokens) {
uint256 tokenCount = balanceOf(_owner);
if (tokenCount == 0) {
// Return an empty array
return new uint256[](0);
} else {
uint256[] memory result = new uint256[](tokenCount);
uint256 totalProperties = totalSupply();
uint256 resultIndex = 0;
// We count on the fact that all properties have IDs starting at 1 and increasing
// sequentially up to the totalProperties count.
uint256 tokenId;
for (tokenId = 1; tokenId <= totalProperties; tokenId++) {
if (propertyIndexToOwner[tokenId] == _owner) {
result[resultIndex] = tokenId;
resultIndex++;
}
}
return result;
}
}
| 49,527 |
36 | // store token in storage | listed.push(_tokenId);
| listed.push(_tokenId);
| 31,486 |
25 | // set the mPendleConvertor address/_mPendleConvertor the mPendleConvertor address | function setMPendleConvertor(address _mPendleConvertor) external onlyOwner {
address oldMPendleConvertor = mPendleConvertor;
mPendleConvertor = _mPendleConvertor;
emit SetMPendleConvertor(oldMPendleConvertor, mPendleConvertor);
}
| function setMPendleConvertor(address _mPendleConvertor) external onlyOwner {
address oldMPendleConvertor = mPendleConvertor;
mPendleConvertor = _mPendleConvertor;
emit SetMPendleConvertor(oldMPendleConvertor, mPendleConvertor);
}
| 24,395 |
252 | // Get the caller as a Safe instance. | TurboSafe safe = TurboSafe(msg.sender);
| TurboSafe safe = TurboSafe(msg.sender);
| 19,184 |
11 | // / | constructor(ClipperExchangeInterface initialExchangeInterface) payable ERC20("Clipper Pool Token", "CLPRPL") {
require(msg.value > 0, "Clipper: Must deposit ETH");
_mint(msg.sender, msg.value*10);
lastETHBalance = msg.value;
fullyDilutedSupply = totalSupply();
exchangeInterfaceContract = initialExchangeInterface;
// Create the deposit and escape contracts
// Can't do this for the exchangeInterfaceContract because it's too large
depositContract = address(new ClipperDeposit());
escapeContract = address(new ClipperEscapeContract());
}
| constructor(ClipperExchangeInterface initialExchangeInterface) payable ERC20("Clipper Pool Token", "CLPRPL") {
require(msg.value > 0, "Clipper: Must deposit ETH");
_mint(msg.sender, msg.value*10);
lastETHBalance = msg.value;
fullyDilutedSupply = totalSupply();
exchangeInterfaceContract = initialExchangeInterface;
// Create the deposit and escape contracts
// Can't do this for the exchangeInterfaceContract because it's too large
depositContract = address(new ClipperDeposit());
escapeContract = address(new ClipperEscapeContract());
}
| 58,862 |
49 | // max wallet code | if (!isMaxWalletExempt[recipient]) {
uint256 heldTokens = balanceOf(recipient);
require(
(heldTokens + amount) <= _maxWalletToken,
"Max wallet reached."
);
}
| if (!isMaxWalletExempt[recipient]) {
uint256 heldTokens = balanceOf(recipient);
require(
(heldTokens + amount) <= _maxWalletToken,
"Max wallet reached."
);
}
| 8,349 |
19 | // We now transform x into a 20 decimal fixed point number, to have enhanced precision when computing the smaller terms. | x *= 100;
| x *= 100;
| 16,760 |
487 | // creates a pool token for the specified token / | function createPoolToken(Token token) external returns (IPoolToken);
| function createPoolToken(Token token) external returns (IPoolToken);
| 75,629 |
198 | // Tells the address of the ownerreturn the address of the owner / | function upgradeabilityOwner() public view returns (address) {
return _upgradeabilityOwner;
}
| function upgradeabilityOwner() public view returns (address) {
return _upgradeabilityOwner;
}
| 43,058 |
356 | // Token Base/Shared logic for token contracts | contract FellowshipDailyArtCollection is ERC721, Ownable, RevokableDefaultOperatorFiltererUpgradeable {
uint256 private immutable MAX_SUPPLY;
address public royaltyReceiver;
address public minter;
address public metadataContract;
uint256 public royaltyFraction;
uint256 public royaltyDenominator = 100;
/// @notice Count of valid NFTs tracked by this contract
uint256 public totalSupply;
/// @notice Return the baseURI used for computing `tokenURI` values
string public baseURI;
error OnlyMinter();
/// @dev This event emits when the metadata of a token is changed. Anyone aware of ERC-4906 can update cached
/// attributes related to a given `tokenId`.
event MetadataUpdate(uint256 tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed. Anyone aware of ERC-4906 can update
/// cached attributes for tokens in the designated range.
event BatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId);
constructor(
string memory name,
string memory symbol,
string memory baseURI_,
uint256 maxSupply,
address royaltyReceiver_,
uint256 royaltyPercent
) ERC721(name, symbol) {
// CHECKS inputs
require(maxSupply > 0, "Max supply must not be zero");
require(royaltyReceiver_ != address(0), "Royalty receiver must not be the zero address");
require(royaltyPercent <= 100, "Royalty fraction must not be greater than 100%");
// EFFECTS
MAX_SUPPLY = maxSupply;
baseURI = baseURI_;
royaltyReceiver = royaltyReceiver_;
royaltyFraction = royaltyPercent;
}
modifier onlyMinter() {
if (msg.sender != minter) revert OnlyMinter();
_;
}
/// @inheritdoc Ownable
function owner() public view virtual override(Ownable, RevokableOperatorFiltererUpgradeable) returns (address) {
return Ownable.owner();
}
// MINTER FUNCTIONS
/// @notice Mint an unclaimed token to the given address
/// @dev Can only be called by the `minter` address
/// @param to The new token owner that will receive the minted token
/// @param tokenId The token being claimed. Reverts if invalid or already claimed.
function mint(address to, uint256 tokenId) external onlyMinter {
// CHECKS inputs
require(tokenId > 0 && tokenId <= MAX_SUPPLY, "Invalid token ID");
// CHECKS + EFFECTS (not _safeMint, so no interactions)
_mint(to, tokenId);
// More EFFECTS
unchecked {
totalSupply++;
}
}
// ERC721 OVERRIDES
/// @inheritdoc ERC721
function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
/// @inheritdoc ERC721
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
/// @inheritdoc ERC721
function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
/// @inheritdoc ERC721
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
/// @inheritdoc ERC721
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
public
override
onlyAllowedOperator(from)
{
super.safeTransferFrom(from, to, tokenId, data);
}
// OWNER FUNCTIONS
/// @notice Set the `minter` address
/// @dev Can only be called by the contract `owner`
function setMinter(address minter_) external onlyOwner {
minter = minter_;
}
/// @notice Set the `royaltyReceiver` address
/// @dev Can only be called by the contract `owner`
function setRoyaltyReceiver(address royaltyReceiver_) external onlyOwner {
// CHECKS inputs
require(royaltyReceiver_ != address(0), "Royalty receiver must not be the zero address");
// EFFECTS
royaltyReceiver = royaltyReceiver_;
}
/// @notice Update the royalty fraction
/// @dev Can only be called by the contract `owner`
function setRoyaltyFraction(uint256 royaltyFraction_, uint256 royaltyDenominator_) external onlyOwner {
// CHECKS inputss
require(royaltyDenominator_ != 0, "Royalty denominator must not be zero");
require(royaltyFraction_ <= royaltyDenominator_, "Royalty fraction must not be greater than 100%");
// EFFECTS
royaltyFraction = royaltyFraction_;
royaltyDenominator = royaltyDenominator_;
}
/// @notice Update the baseURI for all metadata
/// @dev Can only be called by the contract `owner`. Emits an ERC-4906 event.
/// @param baseURI_ The new URI base. When specified, token URIs are created by concatenating the baseURI,
/// token ID, and ".json".
function updateBaseURI(string calldata baseURI_) external onlyOwner {
// CHECKS inputs
require(bytes(baseURI_).length > 0, "New base URI must be provided");
// EFFECTS
baseURI = baseURI_;
metadataContract = address(0);
emit BatchMetadataUpdate(1, MAX_SUPPLY);
}
/// @notice Delegate all `tokenURI` calls to another contract
/// @dev Can only be called by the contract `owner`. Emits an ERC-4906 event.
/// @param delegate The contract that will handle `tokenURI` responses
function delegateTokenURIs(address delegate) external onlyOwner {
// CHECKS inputs
require(delegate != address(0), "New metadata delegate must not be the zero address");
require(delegate.code.length > 0, "New metadata delegate must be a contract");
// EFFECTS
baseURI = "";
metadataContract = delegate;
emit BatchMetadataUpdate(1, MAX_SUPPLY);
}
// VIEW FUNCTIONS
/// @notice The URI for the given token
/// @dev Throws if `tokenId` is not valid or has not been minted
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireMinted(tokenId);
if (bytes(baseURI).length > 0) {
return string(abi.encodePacked(baseURI, Strings.toString(tokenId), ".json"));
}
if (address(metadataContract) != address(0)) {
return IERC721Metadata(metadataContract).tokenURI(tokenId);
}
revert("tokenURI not configured");
}
/// @notice Return whether the given tokenId has been minted yet
function exists(uint256 tokenId) external view returns (bool) {
return _exists(tokenId);
}
/// @notice Calculate how much royalty is owed and to whom
/// @param salePrice - the sale price of the NFT asset
/// @return receiver - address of where the royalty payment should be sent
/// @return royaltyAmount - the royalty payment amount for salePrice
function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {
receiver = royaltyReceiver;
// Use OpenZeppelin math utils for full precision multiply and divide without overflow
royaltyAmount = Math.mulDiv(salePrice, royaltyFraction, royaltyDenominator, Math.Rounding.Up);
}
/// @notice Query if a contract implements an interface
/// @dev Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
/// @param interfaceId The interface identifier, as specified in ERC-165
/// @return `true` if the contract implements `interfaceID` and `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
return
interfaceId == 0x80ac58cd || // ERC-721 Non-Fungible Token Standard
interfaceId == 0x5b5e139f || // ERC-721 Non-Fungible Token Standard - metadata extension
interfaceId == 0x2a55205a || // ERC-2981 NFT Royalty Standard
interfaceId == 0x49064906 || // ERC-4906 Metadata Update Extension
interfaceId == 0x7f5828d0 || // ERC-173 Contract Ownership Standard
interfaceId == 0x01ffc9a7; // ERC-165 Standard Interface Detection
}
} | contract FellowshipDailyArtCollection is ERC721, Ownable, RevokableDefaultOperatorFiltererUpgradeable {
uint256 private immutable MAX_SUPPLY;
address public royaltyReceiver;
address public minter;
address public metadataContract;
uint256 public royaltyFraction;
uint256 public royaltyDenominator = 100;
/// @notice Count of valid NFTs tracked by this contract
uint256 public totalSupply;
/// @notice Return the baseURI used for computing `tokenURI` values
string public baseURI;
error OnlyMinter();
/// @dev This event emits when the metadata of a token is changed. Anyone aware of ERC-4906 can update cached
/// attributes related to a given `tokenId`.
event MetadataUpdate(uint256 tokenId);
/// @dev This event emits when the metadata of a range of tokens is changed. Anyone aware of ERC-4906 can update
/// cached attributes for tokens in the designated range.
event BatchMetadataUpdate(uint256 fromTokenId, uint256 toTokenId);
constructor(
string memory name,
string memory symbol,
string memory baseURI_,
uint256 maxSupply,
address royaltyReceiver_,
uint256 royaltyPercent
) ERC721(name, symbol) {
// CHECKS inputs
require(maxSupply > 0, "Max supply must not be zero");
require(royaltyReceiver_ != address(0), "Royalty receiver must not be the zero address");
require(royaltyPercent <= 100, "Royalty fraction must not be greater than 100%");
// EFFECTS
MAX_SUPPLY = maxSupply;
baseURI = baseURI_;
royaltyReceiver = royaltyReceiver_;
royaltyFraction = royaltyPercent;
}
modifier onlyMinter() {
if (msg.sender != minter) revert OnlyMinter();
_;
}
/// @inheritdoc Ownable
function owner() public view virtual override(Ownable, RevokableOperatorFiltererUpgradeable) returns (address) {
return Ownable.owner();
}
// MINTER FUNCTIONS
/// @notice Mint an unclaimed token to the given address
/// @dev Can only be called by the `minter` address
/// @param to The new token owner that will receive the minted token
/// @param tokenId The token being claimed. Reverts if invalid or already claimed.
function mint(address to, uint256 tokenId) external onlyMinter {
// CHECKS inputs
require(tokenId > 0 && tokenId <= MAX_SUPPLY, "Invalid token ID");
// CHECKS + EFFECTS (not _safeMint, so no interactions)
_mint(to, tokenId);
// More EFFECTS
unchecked {
totalSupply++;
}
}
// ERC721 OVERRIDES
/// @inheritdoc ERC721
function setApprovalForAll(address operator, bool approved) public override onlyAllowedOperatorApproval(operator) {
super.setApprovalForAll(operator, approved);
}
/// @inheritdoc ERC721
function approve(address operator, uint256 tokenId) public override onlyAllowedOperatorApproval(operator) {
super.approve(operator, tokenId);
}
/// @inheritdoc ERC721
function transferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.transferFrom(from, to, tokenId);
}
/// @inheritdoc ERC721
function safeTransferFrom(address from, address to, uint256 tokenId) public override onlyAllowedOperator(from) {
super.safeTransferFrom(from, to, tokenId);
}
/// @inheritdoc ERC721
function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data)
public
override
onlyAllowedOperator(from)
{
super.safeTransferFrom(from, to, tokenId, data);
}
// OWNER FUNCTIONS
/// @notice Set the `minter` address
/// @dev Can only be called by the contract `owner`
function setMinter(address minter_) external onlyOwner {
minter = minter_;
}
/// @notice Set the `royaltyReceiver` address
/// @dev Can only be called by the contract `owner`
function setRoyaltyReceiver(address royaltyReceiver_) external onlyOwner {
// CHECKS inputs
require(royaltyReceiver_ != address(0), "Royalty receiver must not be the zero address");
// EFFECTS
royaltyReceiver = royaltyReceiver_;
}
/// @notice Update the royalty fraction
/// @dev Can only be called by the contract `owner`
function setRoyaltyFraction(uint256 royaltyFraction_, uint256 royaltyDenominator_) external onlyOwner {
// CHECKS inputss
require(royaltyDenominator_ != 0, "Royalty denominator must not be zero");
require(royaltyFraction_ <= royaltyDenominator_, "Royalty fraction must not be greater than 100%");
// EFFECTS
royaltyFraction = royaltyFraction_;
royaltyDenominator = royaltyDenominator_;
}
/// @notice Update the baseURI for all metadata
/// @dev Can only be called by the contract `owner`. Emits an ERC-4906 event.
/// @param baseURI_ The new URI base. When specified, token URIs are created by concatenating the baseURI,
/// token ID, and ".json".
function updateBaseURI(string calldata baseURI_) external onlyOwner {
// CHECKS inputs
require(bytes(baseURI_).length > 0, "New base URI must be provided");
// EFFECTS
baseURI = baseURI_;
metadataContract = address(0);
emit BatchMetadataUpdate(1, MAX_SUPPLY);
}
/// @notice Delegate all `tokenURI` calls to another contract
/// @dev Can only be called by the contract `owner`. Emits an ERC-4906 event.
/// @param delegate The contract that will handle `tokenURI` responses
function delegateTokenURIs(address delegate) external onlyOwner {
// CHECKS inputs
require(delegate != address(0), "New metadata delegate must not be the zero address");
require(delegate.code.length > 0, "New metadata delegate must be a contract");
// EFFECTS
baseURI = "";
metadataContract = delegate;
emit BatchMetadataUpdate(1, MAX_SUPPLY);
}
// VIEW FUNCTIONS
/// @notice The URI for the given token
/// @dev Throws if `tokenId` is not valid or has not been minted
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireMinted(tokenId);
if (bytes(baseURI).length > 0) {
return string(abi.encodePacked(baseURI, Strings.toString(tokenId), ".json"));
}
if (address(metadataContract) != address(0)) {
return IERC721Metadata(metadataContract).tokenURI(tokenId);
}
revert("tokenURI not configured");
}
/// @notice Return whether the given tokenId has been minted yet
function exists(uint256 tokenId) external view returns (bool) {
return _exists(tokenId);
}
/// @notice Calculate how much royalty is owed and to whom
/// @param salePrice - the sale price of the NFT asset
/// @return receiver - address of where the royalty payment should be sent
/// @return royaltyAmount - the royalty payment amount for salePrice
function royaltyInfo(uint256, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount) {
receiver = royaltyReceiver;
// Use OpenZeppelin math utils for full precision multiply and divide without overflow
royaltyAmount = Math.mulDiv(salePrice, royaltyFraction, royaltyDenominator, Math.Rounding.Up);
}
/// @notice Query if a contract implements an interface
/// @dev Interface identification is specified in ERC-165. This function uses less than 30,000 gas.
/// @param interfaceId The interface identifier, as specified in ERC-165
/// @return `true` if the contract implements `interfaceID` and `interfaceID` is not 0xffffffff, `false` otherwise
function supportsInterface(bytes4 interfaceId) public pure virtual override returns (bool) {
return
interfaceId == 0x80ac58cd || // ERC-721 Non-Fungible Token Standard
interfaceId == 0x5b5e139f || // ERC-721 Non-Fungible Token Standard - metadata extension
interfaceId == 0x2a55205a || // ERC-2981 NFT Royalty Standard
interfaceId == 0x49064906 || // ERC-4906 Metadata Update Extension
interfaceId == 0x7f5828d0 || // ERC-173 Contract Ownership Standard
interfaceId == 0x01ffc9a7; // ERC-165 Standard Interface Detection
}
} | 22,057 |
5 | // Max gas to consume during the matching process for supply, borrow, withdraw and repay functions. | struct MaxGasForMatching {
uint64 supply;
uint64 borrow;
uint64 withdraw;
uint64 repay;
}
| struct MaxGasForMatching {
uint64 supply;
uint64 borrow;
uint64 withdraw;
uint64 repay;
}
| 34,581 |
92 | // don't swap or buy tokens when uniswapV2Pair is sender, to avoid circular loop | if(!inSwapAndLiquify && sender != uniswapV2Pair) {
bool swap = true;
uint256 contractBalance = address(this).balance;
| if(!inSwapAndLiquify && sender != uniswapV2Pair) {
bool swap = true;
uint256 contractBalance = address(this).balance;
| 14,761 |
152 | // `verifyVMInternal` serves to validate an arbitrary vm against a valid Guardian set if checkHash is set then the hash field of the vm is verified against the hash of its contents in the case that the vm is securely parsed and the hash field can be trusted, checkHash can be set to false as the check would be redundant/ | function verifyVMInternal(Structs.VM memory vm, bool checkHash) internal view returns (bool valid, string memory reason) {
/// @dev Obtain the current guardianSet for the guardianSetIndex provided
Structs.GuardianSet memory guardianSet = getGuardianSet(vm.guardianSetIndex);
/**
* Verify that the hash field in the vm matches with the hash of the contents of the vm if checkHash is set
* WARNING: This hash check is critical to ensure that the vm.hash provided matches with the hash of the body.
* Without this check, it would not be safe to call verifyVM on it's own as vm.hash can be a valid signed hash
* but the body of the vm could be completely different from what was actually signed by the guardians
*/
if(checkHash){
bytes memory body = abi.encodePacked(
vm.timestamp,
vm.nonce,
vm.emitterChainId,
vm.emitterAddress,
vm.sequence,
vm.consistencyLevel,
vm.payload
);
bytes32 vmHash = keccak256(abi.encodePacked(keccak256(body)));
if(vmHash != vm.hash){
return (false, "vm.hash doesn't match body");
}
}
/**
* @dev Checks whether the guardianSet has zero keys
* WARNING: This keys check is critical to ensure the guardianSet has keys present AND to ensure
* that guardianSet key size doesn't fall to zero and negatively impact quorum assessment. If guardianSet
* key length is 0 and vm.signatures length is 0, this could compromise the integrity of both vm and
* signature verification.
*/
if(guardianSet.keys.length == 0){
return (false, "invalid guardian set");
}
/// @dev Checks if VM guardian set index matches the current index (unless the current set is expired).
if(vm.guardianSetIndex != getCurrentGuardianSetIndex() && guardianSet.expirationTime < block.timestamp){
return (false, "guardian set has expired");
}
/**
* @dev We're using a fixed point number transformation with 1 decimal to deal with rounding.
* WARNING: This quorum check is critical to assessing whether we have enough Guardian signatures to validate a VM
* if making any changes to this, obtain additional peer review. If guardianSet key length is 0 and
* vm.signatures length is 0, this could compromise the integrity of both vm and signature verification.
*/
if (vm.signatures.length < quorum(guardianSet.keys.length)){
return (false, "no quorum");
}
/// @dev Verify the proposed vm.signatures against the guardianSet
(bool signaturesValid, string memory invalidReason) = verifySignatures(vm.hash, vm.signatures, guardianSet);
if(!signaturesValid){
return (false, invalidReason);
}
/// If we are here, we've validated the VM is a valid multi-sig that matches the guardianSet.
return (true, "");
}
| function verifyVMInternal(Structs.VM memory vm, bool checkHash) internal view returns (bool valid, string memory reason) {
/// @dev Obtain the current guardianSet for the guardianSetIndex provided
Structs.GuardianSet memory guardianSet = getGuardianSet(vm.guardianSetIndex);
/**
* Verify that the hash field in the vm matches with the hash of the contents of the vm if checkHash is set
* WARNING: This hash check is critical to ensure that the vm.hash provided matches with the hash of the body.
* Without this check, it would not be safe to call verifyVM on it's own as vm.hash can be a valid signed hash
* but the body of the vm could be completely different from what was actually signed by the guardians
*/
if(checkHash){
bytes memory body = abi.encodePacked(
vm.timestamp,
vm.nonce,
vm.emitterChainId,
vm.emitterAddress,
vm.sequence,
vm.consistencyLevel,
vm.payload
);
bytes32 vmHash = keccak256(abi.encodePacked(keccak256(body)));
if(vmHash != vm.hash){
return (false, "vm.hash doesn't match body");
}
}
/**
* @dev Checks whether the guardianSet has zero keys
* WARNING: This keys check is critical to ensure the guardianSet has keys present AND to ensure
* that guardianSet key size doesn't fall to zero and negatively impact quorum assessment. If guardianSet
* key length is 0 and vm.signatures length is 0, this could compromise the integrity of both vm and
* signature verification.
*/
if(guardianSet.keys.length == 0){
return (false, "invalid guardian set");
}
/// @dev Checks if VM guardian set index matches the current index (unless the current set is expired).
if(vm.guardianSetIndex != getCurrentGuardianSetIndex() && guardianSet.expirationTime < block.timestamp){
return (false, "guardian set has expired");
}
/**
* @dev We're using a fixed point number transformation with 1 decimal to deal with rounding.
* WARNING: This quorum check is critical to assessing whether we have enough Guardian signatures to validate a VM
* if making any changes to this, obtain additional peer review. If guardianSet key length is 0 and
* vm.signatures length is 0, this could compromise the integrity of both vm and signature verification.
*/
if (vm.signatures.length < quorum(guardianSet.keys.length)){
return (false, "no quorum");
}
/// @dev Verify the proposed vm.signatures against the guardianSet
(bool signaturesValid, string memory invalidReason) = verifySignatures(vm.hash, vm.signatures, guardianSet);
if(!signaturesValid){
return (false, invalidReason);
}
/// If we are here, we've validated the VM is a valid multi-sig that matches the guardianSet.
return (true, "");
}
| 11,935 |
6 | // Save box index to mappings for sender & recipient | senderMap[msg.sender].push(boxes.length - 1);
recipientMap[_recipient].push(boxes.length - 1);
if(_sendToken == ERC20Interface(address(0)))
| senderMap[msg.sender].push(boxes.length - 1);
recipientMap[_recipient].push(boxes.length - 1);
if(_sendToken == ERC20Interface(address(0)))
| 56,274 |
42 | // Charge fee | {
uint256 usedGas = startGas - gasleft();
uint256 fee = (usedGas * bank.TRANSFER_FEE_MULTIPLIER / bank.TRANSFER_FEE_DIVIDEND) * tx.gasprice;
if (fee > 0) {
require(msg.value >= fee, "Not enough fee.");
bank.suterAgency.transfer(fee);
bank.totalTransferFee = bank.totalTransferFee + fee;
}
| {
uint256 usedGas = startGas - gasleft();
uint256 fee = (usedGas * bank.TRANSFER_FEE_MULTIPLIER / bank.TRANSFER_FEE_DIVIDEND) * tx.gasprice;
if (fee > 0) {
require(msg.value >= fee, "Not enough fee.");
bank.suterAgency.transfer(fee);
bank.totalTransferFee = bank.totalTransferFee + fee;
}
| 8,241 |
32 | // Commits permission grants for the given address./Reverts if governance delay has not passed yet./target The given address. | function commitPermissionGrants(address target) external;
| function commitPermissionGrants(address target) external;
| 17,336 |
52 | // Deposit token to contract for a user anc charge a deposit fee | function depositTokenForUserWithFee(address token, uint128 amount, address user, uint256 depositFee) {
// Check sender is AMB bridge
if (safeMul(depositFee, 1e18) / amount > 1e17) revert(); // deposit fee is more than 10% of the deposit amount
addBalance(token, user, safeSub(amount, depositFee)); // adds the deposited amount to user balance
addBalance(token, gasFeeAccount, depositFee); // adds the deposit fee to the gasFeeAccount
//if (!Token(token).transferFrom(msg.sender, this, amount)) revert(); // attempts to transfer the token to this contract, if fails throws an error
emit Deposit(token, user, safeSub(amount, depositFee), balanceOf(token, user)); // fires the deposit event
}
| function depositTokenForUserWithFee(address token, uint128 amount, address user, uint256 depositFee) {
// Check sender is AMB bridge
if (safeMul(depositFee, 1e18) / amount > 1e17) revert(); // deposit fee is more than 10% of the deposit amount
addBalance(token, user, safeSub(amount, depositFee)); // adds the deposited amount to user balance
addBalance(token, gasFeeAccount, depositFee); // adds the deposit fee to the gasFeeAccount
//if (!Token(token).transferFrom(msg.sender, this, amount)) revert(); // attempts to transfer the token to this contract, if fails throws an error
emit Deposit(token, user, safeSub(amount, depositFee), balanceOf(token, user)); // fires the deposit event
}
| 8,880 |
268 | // Buy/Mints NFT/ | function mintNFT(uint256 numberOfNfts) public payable {
require(block.timestamp >= SALE_START_TIMESTAMP, "Sale has not started");
require(totalSupply() <= MAX_NFT_SUPPLY, "Sale has already ended");
require(numberOfNfts > 0, "numberOfNfts cannot be 0");
require(numberOfNfts <= 20, "You may not buy more than 20 NFTs at once");
require(totalSupply().add(numberOfNfts) <= MAX_NFT_SUPPLY, "Exceeds MAX_NFT_SUPPLY");
require(initNFTPrice().mul(numberOfNfts) == msg.value, "BNB value sent is not correct");
for (uint i = 0; i < numberOfNfts; i++) {
uint mintIndex = totalSupply();
if (block.timestamp < REVEAL_TIMESTAMP) {
_mintedWithBonusNCT[mintIndex] = true;
}
_tokenBNBClaimability[mintIndex] = true;
_safeMint(msg.sender, mintIndex);
}
pokeCommunityTakeHomeRate();
/**
* Source of randomness. Theoretical miner withhold manipulation possible but should be sufficient in a pragmatic sense
*/
if (startingIndexBlock == 0 && (totalSupply() == MAX_NFT_SUPPLY || block.timestamp >= REVEAL_TIMESTAMP)) {
startingIndexBlock = block.number;
}
}
| function mintNFT(uint256 numberOfNfts) public payable {
require(block.timestamp >= SALE_START_TIMESTAMP, "Sale has not started");
require(totalSupply() <= MAX_NFT_SUPPLY, "Sale has already ended");
require(numberOfNfts > 0, "numberOfNfts cannot be 0");
require(numberOfNfts <= 20, "You may not buy more than 20 NFTs at once");
require(totalSupply().add(numberOfNfts) <= MAX_NFT_SUPPLY, "Exceeds MAX_NFT_SUPPLY");
require(initNFTPrice().mul(numberOfNfts) == msg.value, "BNB value sent is not correct");
for (uint i = 0; i < numberOfNfts; i++) {
uint mintIndex = totalSupply();
if (block.timestamp < REVEAL_TIMESTAMP) {
_mintedWithBonusNCT[mintIndex] = true;
}
_tokenBNBClaimability[mintIndex] = true;
_safeMint(msg.sender, mintIndex);
}
pokeCommunityTakeHomeRate();
/**
* Source of randomness. Theoretical miner withhold manipulation possible but should be sufficient in a pragmatic sense
*/
if (startingIndexBlock == 0 && (totalSupply() == MAX_NFT_SUPPLY || block.timestamp >= REVEAL_TIMESTAMP)) {
startingIndexBlock = block.number;
}
}
| 21,851 |
2 | // Boolean that determines the operational status of application logic contracts | bool public isOperational;
| bool public isOperational;
| 17,143 |
121 | // Withdraws from funds from the Wise Vault _shares: Number of shares to withdraw / | function withdraw(uint256 _shares) public notContract {
UserInfo storage user = userInfo[msg.sender];
require(_shares > 0, "Nothing to withdraw");
require(_shares <= user.shares, "Withdraw amount exceeds balance");
uint256 currentAmount = (balanceOf().mul(_shares)).div(totalShares);
user.shares = user.shares.sub(_shares);
totalShares = totalShares.sub(_shares);
uint256 bal = available();
if (bal < currentAmount) {
uint256 balWithdraw = currentAmount.sub(bal);
IMasterChef(masterchef).withdraw(0,balWithdraw);
uint256 balAfter = available();
uint256 diff = balAfter.sub(bal);
if (diff < balWithdraw) {
currentAmount = bal.add(diff);
}
}
if (block.timestamp < user.lastDepositedTime.add(withdrawFeePeriod)) {
uint256 currentWithdrawFee = currentAmount.mul(withdrawFee).div(10000);
token.safeTransfer(treasury, currentWithdrawFee);
currentAmount = currentAmount.sub(currentWithdrawFee);
}
if (user.shares > 0) {
user.wiseAtLastUserAction = user.shares.mul(balanceOf()).div(totalShares);
} else {
user.wiseAtLastUserAction = 0;
}
user.lastUserActionTime = block.timestamp;
token.safeTransfer(msg.sender, currentAmount);
emit Withdraw(msg.sender, currentAmount, _shares);
}
| function withdraw(uint256 _shares) public notContract {
UserInfo storage user = userInfo[msg.sender];
require(_shares > 0, "Nothing to withdraw");
require(_shares <= user.shares, "Withdraw amount exceeds balance");
uint256 currentAmount = (balanceOf().mul(_shares)).div(totalShares);
user.shares = user.shares.sub(_shares);
totalShares = totalShares.sub(_shares);
uint256 bal = available();
if (bal < currentAmount) {
uint256 balWithdraw = currentAmount.sub(bal);
IMasterChef(masterchef).withdraw(0,balWithdraw);
uint256 balAfter = available();
uint256 diff = balAfter.sub(bal);
if (diff < balWithdraw) {
currentAmount = bal.add(diff);
}
}
if (block.timestamp < user.lastDepositedTime.add(withdrawFeePeriod)) {
uint256 currentWithdrawFee = currentAmount.mul(withdrawFee).div(10000);
token.safeTransfer(treasury, currentWithdrawFee);
currentAmount = currentAmount.sub(currentWithdrawFee);
}
if (user.shares > 0) {
user.wiseAtLastUserAction = user.shares.mul(balanceOf()).div(totalShares);
} else {
user.wiseAtLastUserAction = 0;
}
user.lastUserActionTime = block.timestamp;
token.safeTransfer(msg.sender, currentAmount);
emit Withdraw(msg.sender, currentAmount, _shares);
}
| 3,166 |
336 | // Prepare a users array to whitelist the Safe. | address[] memory users = new address[](1);
users[0] = address(safe);
| address[] memory users = new address[](1);
users[0] = address(safe);
| 61,600 |
150 | // 获取用户总体的存款和借款情况 | function getTotalDepositAndBorrow(address account)
public
view
returns (uint256, uint256)
| function getTotalDepositAndBorrow(address account)
public
view
returns (uint256, uint256)
| 75,872 |
61 | // The ConfirmedOwner contract A contract with helpers for basic contract ownership. / | contract ConfirmedOwnerWithProposal is OwnableInterface {
address private s_owner;
address private s_pendingOwner;
event OwnershipTransferRequested(address indexed from, address indexed to);
event OwnershipTransferred(address indexed from, address indexed to);
constructor(address newOwner, address pendingOwner) {
require(newOwner != address(0), "Cannot set owner to zero");
s_owner = newOwner;
if (pendingOwner != address(0)) {
_transferOwnership(pendingOwner);
}
}
/**
* @notice Allows an owner to begin transferring ownership to a new address,
* pending.
*/
function transferOwnership(address to) public override onlyOwner {
_transferOwnership(to);
}
/**
* @notice Allows an ownership transfer to be completed by the recipient.
*/
function acceptOwnership() external override {
require(msg.sender == s_pendingOwner, "Must be proposed owner");
address oldOwner = s_owner;
s_owner = msg.sender;
s_pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
/**
* @notice Get the current owner
*/
function owner() public view override returns (address) {
return s_owner;
}
/**
* @notice validate, transfer ownership, and emit relevant events
*/
function _transferOwnership(address to) private {
require(to != msg.sender, "Cannot transfer to self");
s_pendingOwner = to;
emit OwnershipTransferRequested(s_owner, to);
}
/**
* @notice validate access
*/
function _validateOwnership() internal view {
require(msg.sender == s_owner, "Only callable by owner");
}
/**
* @notice Reverts if called by anyone other than the contract owner.
*/
modifier onlyOwner() {
_validateOwnership();
_;
}
}
| contract ConfirmedOwnerWithProposal is OwnableInterface {
address private s_owner;
address private s_pendingOwner;
event OwnershipTransferRequested(address indexed from, address indexed to);
event OwnershipTransferred(address indexed from, address indexed to);
constructor(address newOwner, address pendingOwner) {
require(newOwner != address(0), "Cannot set owner to zero");
s_owner = newOwner;
if (pendingOwner != address(0)) {
_transferOwnership(pendingOwner);
}
}
/**
* @notice Allows an owner to begin transferring ownership to a new address,
* pending.
*/
function transferOwnership(address to) public override onlyOwner {
_transferOwnership(to);
}
/**
* @notice Allows an ownership transfer to be completed by the recipient.
*/
function acceptOwnership() external override {
require(msg.sender == s_pendingOwner, "Must be proposed owner");
address oldOwner = s_owner;
s_owner = msg.sender;
s_pendingOwner = address(0);
emit OwnershipTransferred(oldOwner, msg.sender);
}
/**
* @notice Get the current owner
*/
function owner() public view override returns (address) {
return s_owner;
}
/**
* @notice validate, transfer ownership, and emit relevant events
*/
function _transferOwnership(address to) private {
require(to != msg.sender, "Cannot transfer to self");
s_pendingOwner = to;
emit OwnershipTransferRequested(s_owner, to);
}
/**
* @notice validate access
*/
function _validateOwnership() internal view {
require(msg.sender == s_owner, "Only callable by owner");
}
/**
* @notice Reverts if called by anyone other than the contract owner.
*/
modifier onlyOwner() {
_validateOwnership();
_;
}
}
| 16,492 |
258 | // calculate player earning from their own buy (only based on the keys they just bought).& update player earnings mask | uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
| uint256 _pearn = (_ppt.mul(_keys)) / (1000000000000000000);
plyrRnds_[_pID][_rID].mask = (((round_[_rID].mask.mul(_keys)) / (1000000000000000000)).sub(_pearn)).add(plyrRnds_[_pID][_rID].mask);
| 7,753 |
22 | // Emit an event to notify clients | emit NewBooking(_sampleId, bookingId++);
| emit NewBooking(_sampleId, bookingId++);
| 42,276 |
15 | // Assume they always get the Headline | string Headline = newsDetails.Headline;
string Article;
string Image;
string Video;
| string Headline = newsDetails.Headline;
string Article;
string Image;
string Video;
| 38,292 |
41 | // PUBLIC READ FUNCTIONS | function getAvailableReward(address investor) public view returns(uint256) {
uint256 timeSinceLastAction = block.timestamp - lastAction[investor] > timer ? timer : block.timestamp - lastAction[investor];
uint256 availableReward = principalBalance[investor] * roi[investor] * timeSinceLastAction / timer / 1000;
return availableReward;
}
| function getAvailableReward(address investor) public view returns(uint256) {
uint256 timeSinceLastAction = block.timestamp - lastAction[investor] > timer ? timer : block.timestamp - lastAction[investor];
uint256 availableReward = principalBalance[investor] * roi[investor] * timeSinceLastAction / timer / 1000;
return availableReward;
}
| 31,876 |
9 | // Set subscription price. _price New price in USD. Must have `PRICE_PRECISION` decimals. Could only be invoked by the contract owner. / | function setPrice(uint256 _price) external onlyOwner {
require(_price > 0, "Cant be zero");
price = _price;
emit SetPrice(_price);
}
| function setPrice(uint256 _price) external onlyOwner {
require(_price > 0, "Cant be zero");
price = _price;
emit SetPrice(_price);
}
| 47,547 |
41 | // [--growth-window--][--max-window--][--freeze-window--] / | var call = FutureBlockCall(this);
uint cutoff = call.targetBlock() - BEFORE_CALL_FREEZE_WINDOW;
| var call = FutureBlockCall(this);
uint cutoff = call.targetBlock() - BEFORE_CALL_FREEZE_WINDOW;
| 16,897 |
259 | // Explicity sets and ERC-20 contract as an allowed payment method for minting_erc20TokenContract address of ERC-20 contract in question_isActive default status of if contract should be allowed to accept payments_chargeAmountInTokens fee (in tokens) to charge for mints for this specific ERC-20 token/ | function addOrUpdateERC20ContractAsPayment(address _erc20TokenContract, bool _isActive, uint256 _chargeAmountInTokens) public onlyTeamOrOwner {
allowedTokenContracts[_erc20TokenContract].isActive = _isActive;
allowedTokenContracts[_erc20TokenContract].chargeAmount = _chargeAmountInTokens;
}
| function addOrUpdateERC20ContractAsPayment(address _erc20TokenContract, bool _isActive, uint256 _chargeAmountInTokens) public onlyTeamOrOwner {
allowedTokenContracts[_erc20TokenContract].isActive = _isActive;
allowedTokenContracts[_erc20TokenContract].chargeAmount = _chargeAmountInTokens;
}
| 11,047 |
8 | // From state 1 - "Open to redeem" to state 2 - "Autograph requested" - Only owner of the NFT can change it | if(erc721.ownerOf(currentTokenId) != msg.sender) {
revert UTAutographControllerNotOwnerOfToken(msg.sender);
}
| if(erc721.ownerOf(currentTokenId) != msg.sender) {
revert UTAutographControllerNotOwnerOfToken(msg.sender);
}
| 13,888 |
21 | // make sure the message caller is the registration agent. this will fail when an event isn't registered, or the dispatcher isn't the one who registered the event. | require(msg.sender == eventDispatchers[eventHash], 'INVALID_DISPATCH');
| require(msg.sender == eventDispatchers[eventHash], 'INVALID_DISPATCH');
| 17,700 |
20 | // Returns true if this contract implements the interface defined by`interfaceId`. See the correspondingto learn more about how these ids are created. This function call must use less than 30 000 gas. / | function supportsInterface(bytes4 interfaceId) external view returns (bool);
| function supportsInterface(bytes4 interfaceId) external view returns (bool);
| 27,045 |
12 | // Subtracts two signed integers, reverts on overflow./ | function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
| function sub(int256 a, int256 b) internal pure returns (int256) {
int256 c = a - b;
require((b >= 0 && c <= a) || (b < 0 && c > a));
return c;
}
| 28,574 |
46 | // Gets all the recorded logs | function getRecordedLogs() external returns (Log[] memory logs);
| function getRecordedLogs() external returns (Log[] memory logs);
| 30,865 |
16 | // Calculate -x.Revert on overflow.x signed 64.64-bit fixed point numberreturn signed 64.64-bit fixed point number / | function neg (int128 x) internal pure returns (int128) {
require (x != MIN_64x64);
return -x;
}
| function neg (int128 x) internal pure returns (int128) {
require (x != MIN_64x64);
return -x;
}
| 8,237 |
23 | // function panelProposalsGetter (uint256 _electorateID) | // public constant returns (uint256[]) {
// return (electorateProposals[_electorateID]);
// }
| // public constant returns (uint256[]) {
// return (electorateProposals[_electorateID]);
// }
| 46,256 |
9 | // -------------------------------------------------------------------------/Send `(tokens/1000000000000000000).fixed(0,18)` PLAY to `to`./Throws if amount to send is zero. Throws if `msg.sender` has/insufficient balance for transfer. Throws if `to` is the zero address./to The address to where PLAY is being sent./tokens The number of tokens to send (in pWei)./ return True upon successful transfer. Will throw if unsuccessful.------------------------------------------------------------------------- | function transfer(address to, uint tokens)
public
notZero(uint(to))
notZero(tokens)
sufficientFunds(msg.sender, tokens)
returns(bool)
| function transfer(address to, uint tokens)
public
notZero(uint(to))
notZero(tokens)
sufficientFunds(msg.sender, tokens)
returns(bool)
| 14,610 |
198 | // Grab a reference to the potential matron | Pony storage matron = ponies[_matronId];
| Pony storage matron = ponies[_matronId];
| 2,404 |
66 | // only pay referrals for the first investment of each player | if(
(!m_referrals[msg.sender] && limitedReferralsMode == true)
||
limitedReferralsMode == false
) {
uint _referralEarning = m_refPercent.mul(value);
unclaimedReturns = unclaimedReturns.add(_referralEarning);
vaults[ref].totalReturns = vaults[ref].totalReturns.add(_referralEarning);
| if(
(!m_referrals[msg.sender] && limitedReferralsMode == true)
||
limitedReferralsMode == false
) {
uint _referralEarning = m_refPercent.mul(value);
unclaimedReturns = unclaimedReturns.add(_referralEarning);
vaults[ref].totalReturns = vaults[ref].totalReturns.add(_referralEarning);
| 23,993 |
3 | // solium-enable |
for (uint i = 0; i < len; i++) {
require(_endTimes[i] >= _startTimes[i]);
uint stageCap;
if (_capRatios[i] != 0) {
stageCap = cap.mul(uint(_capRatios[i])).div(coeff);
} else {
|
for (uint i = 0; i < len; i++) {
require(_endTimes[i] >= _startTimes[i]);
uint stageCap;
if (_capRatios[i] != 0) {
stageCap = cap.mul(uint(_capRatios[i])).div(coeff);
} else {
| 15,731 |
83 | // decrease in creditline impacts amount available for new loans | assessor.changeBorrowAmountEpoch(safeSub(assessor.borrowAmountEpoch(), amountDAI));
| assessor.changeBorrowAmountEpoch(safeSub(assessor.borrowAmountEpoch(), amountDAI));
| 30,522 |
2 | // Token Contract call and send Functions / | interface Token {
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function approveAndCall(address spender, uint tokens, bytes memory data) external returns (bool success);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
| interface Token {
function balanceOf(address who) external view returns (uint256);
function allowance(address owner, address spender) external view returns (uint256);
function transfer(address to, uint256 value) external returns (bool);
function approve(address spender, uint256 value) external returns (bool);
function approveAndCall(address spender, uint tokens, bytes memory data) external returns (bool success);
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
| 14,239 |
34 | // StoremanGroup unregistration application/StoremanGroup unregistration application/storemanGroup StoremanGroup's address | function applyUnregistration(address storemanGroup)
public
notHalted
onlyStoremanGroupAdmin
returns (bool)
| function applyUnregistration(address storemanGroup)
public
notHalted
onlyStoremanGroupAdmin
returns (bool)
| 43,156 |
44 | // Get the current and new invariants. Since we need a bigger new invariant, we round the current one up. | uint256 currentInvariant = _calculateInvariant(amp, balances, true);
uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(currentInvariant);
| uint256 currentInvariant = _calculateInvariant(amp, balances, true);
uint256 newInvariant = bptTotalSupply.sub(bptAmountIn).divUp(bptTotalSupply).mulUp(currentInvariant);
| 35,473 |
6 | // exec-tx GelatoCore internal gas requirement | function setInternalGasRequirement(uint256 _newRequirement) external override onlyOwner {
emit LogInternalGasRequirementSet(internalGasRequirement, _newRequirement);
internalGasRequirement = _newRequirement;
}
| function setInternalGasRequirement(uint256 _newRequirement) external override onlyOwner {
emit LogInternalGasRequirementSet(internalGasRequirement, _newRequirement);
internalGasRequirement = _newRequirement;
}
| 44,443 |
12 | // max elite whitelists | uint256 public constant maxEliteWhitelists = 1000; //max 1000 elite whitelistes
mapping(address => uint256) public eliteWhitelistsOf;
| uint256 public constant maxEliteWhitelists = 1000; //max 1000 elite whitelistes
mapping(address => uint256) public eliteWhitelistsOf;
| 1,621 |
20 | // ------------------------------------------------------------------------------ Get the token balance for the account ------------------------------------------------------------------------------ | function balanceOf(address tokenOwner) override public view returns(uint balance) {
return balances[tokenOwner];
}
| function balanceOf(address tokenOwner) override public view returns(uint balance) {
return balances[tokenOwner];
}
| 20,996 |
143 | // Updates beefy fee recipient. _beefyFeeRecipient new beefy fee recipient address. / | function setBeefyFeeRecipient(address _beefyFeeRecipient) external onlyOwner {
beefyFeeRecipient = _beefyFeeRecipient;
}
| function setBeefyFeeRecipient(address _beefyFeeRecipient) external onlyOwner {
beefyFeeRecipient = _beefyFeeRecipient;
}
| 18,040 |
43 | // does validator exist? return true if yes, false if no/ | function isValidator(address _validator) public view returns (bool) {
return validators[_validator];
}
| function isValidator(address _validator) public view returns (bool) {
return validators[_validator];
}
| 50,448 |
19 | // Update the given pool's V3S allocation point. Can only be called by the owner. | function set(uint256 _pid, uint256 _allocPoint) public onlyOperator {
massUpdatePools();
PoolInfo storage pool = poolInfo[_pid];
if (pool.isStarted) {
totalAllocPoint_ = totalAllocPoint_.sub(pool.allocPoint).add(_allocPoint);
}
pool.allocPoint = _allocPoint;
}
| function set(uint256 _pid, uint256 _allocPoint) public onlyOperator {
massUpdatePools();
PoolInfo storage pool = poolInfo[_pid];
if (pool.isStarted) {
totalAllocPoint_ = totalAllocPoint_.sub(pool.allocPoint).add(_allocPoint);
}
pool.allocPoint = _allocPoint;
}
| 14,806 |
101 | // Mutative Functions | function claimFees() external returns (bool);
function claimOnBehalf(address claimingForAddress) external returns (bool);
function closeCurrentFeePeriod() external;
| function claimFees() external returns (bool);
function claimOnBehalf(address claimingForAddress) external returns (bool);
function closeCurrentFeePeriod() external;
| 14,092 |
281 | // the operator can use to refund ETH or ERC20 to buyer _orderId the refund order id _recepient the receiver address _currency the refund currency (can be ETH or ERC20) _amount the refund amount / | function refund(
uint128 _orderId,
address _recepient,
address _currency,
uint256 _amount
| function refund(
uint128 _orderId,
address _recepient,
address _currency,
uint256 _amount
| 14,805 |
2 | // Constructor takes the address of the AAVE protocol addresses provider. Should not change once deployed. (https:docs.aave.com/developers/deployed-contracts) | constructor(address _lendingPoolAddressesProvider) public {
addressesProvider = ILendingPoolAddressesProvider(
_lendingPoolAddressesProvider
);
lendingPool = ILendingPool(addressesProvider.getLendingPool());
}
| constructor(address _lendingPoolAddressesProvider) public {
addressesProvider = ILendingPoolAddressesProvider(
_lendingPoolAddressesProvider
);
lendingPool = ILendingPool(addressesProvider.getLendingPool());
}
| 16,188 |
47 | // If offer has become dust during buy, we cancel it | if (isActive(id) && offers[id].pay_amt < _dust[address(offers[id].pay_gem)]) {
cancel(id);
}
| if (isActive(id) && offers[id].pay_amt < _dust[address(offers[id].pay_gem)]) {
cancel(id);
}
| 19,364 |
4 | // duration of a slice period for the vesting in seconds | uint256 slicePeriodSeconds;
| uint256 slicePeriodSeconds;
| 13,964 |
10 | // Asset suspension timestamp, used to suspend specific assets only on the current day (according to the time zone). | mapping(address => uint256) internal assetPauseTime;
| mapping(address => uint256) internal assetPauseTime;
| 52,116 |
23 | // Any board member can get seconds per blocks. | function getSecondsPerBlock() public view onlyVideoBaseBoardMembers
| function getSecondsPerBlock() public view onlyVideoBaseBoardMembers
| 49,844 |
35 | // mint | mintOnChainMfer(_dna);
| mintOnChainMfer(_dna);
| 2,119 |
98 | // mint 1:1 and deposit | bridgeableToken.mint(address(this), _depositAmount);
_posDeposit(bridgeableToken, _addrTo, _depositAmount);
| bridgeableToken.mint(address(this), _depositAmount);
_posDeposit(bridgeableToken, _addrTo, _depositAmount);
| 26,325 |
150 | // See {Governor-_quorumReached}. / | function _quorumReached(uint256 proposalId) internal view virtual override returns (bool) {
ProposalVote storage proposalvote = _proposalVotes[proposalId];
return quorum(proposalSnapshot(proposalId)) <= proposalvote.forVotes + proposalvote.abstainVotes;
}
| function _quorumReached(uint256 proposalId) internal view virtual override returns (bool) {
ProposalVote storage proposalvote = _proposalVotes[proposalId];
return quorum(proposalSnapshot(proposalId)) <= proposalvote.forVotes + proposalvote.abstainVotes;
}
| 80,666 |
58 | // IPFS Hashes to Score Query | mapping(bytes32 => ScoreQuery) scoreQueries;
| mapping(bytes32 => ScoreQuery) scoreQueries;
| 43,148 |
110 | // SPDX-License-Identifier: MIT SPDX-License-Identifier: MIT | interface UniswapRouterV2 {
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
}
| interface UniswapRouterV2 {
function swapExactTokensForTokens(
uint256 amountIn,
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external returns (uint256[] memory amounts);
function addLiquidity(
address tokenA,
address tokenB,
uint256 amountADesired,
uint256 amountBDesired,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
)
external
returns (
uint256 amountA,
uint256 amountB,
uint256 liquidity
);
function addLiquidityETH(
address token,
uint256 amountTokenDesired,
uint256 amountTokenMin,
uint256 amountETHMin,
address to,
uint256 deadline
)
external
payable
returns (
uint256 amountToken,
uint256 amountETH,
uint256 liquidity
);
function removeLiquidity(
address tokenA,
address tokenB,
uint256 liquidity,
uint256 amountAMin,
uint256 amountBMin,
address to,
uint256 deadline
) external returns (uint256 amountA, uint256 amountB);
function getAmountsOut(uint256 amountIn, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function getAmountsIn(uint256 amountOut, address[] calldata path)
external
view
returns (uint256[] memory amounts);
function swapETHForExactTokens(
uint256 amountOut,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
function swapExactETHForTokens(
uint256 amountOutMin,
address[] calldata path,
address to,
uint256 deadline
) external payable returns (uint256[] memory amounts);
}
| 16,612 |
103 | // normal case, where we are in the middle of the distribution | else {
_deltaBlock = block.number.sub(lastBlock);
}
| else {
_deltaBlock = block.number.sub(lastBlock);
}
| 19,119 |
5 | // Store params in memory | mstore(memPtr, schemaHash)
mstore(add(memPtr, 32), nameHash)
mstore(add(memPtr, 64), versionHash)
mstore(add(memPtr, 96), chainId)
mstore(add(memPtr, 128), verifyingContract)
| mstore(memPtr, schemaHash)
mstore(add(memPtr, 32), nameHash)
mstore(add(memPtr, 64), versionHash)
mstore(add(memPtr, 96), chainId)
mstore(add(memPtr, 128), verifyingContract)
| 6,406 |
8 | // burnerIndex[tokenAddress][poolIndex][userAddress]=> the index at which a user exceeded the trackBurnerIndexThreshold for a specific pool | mapping(address => mapping(uint256 => mapping(address => uint256))) public burnerIndex;
| mapping(address => mapping(uint256 => mapping(address => uint256))) public burnerIndex;
| 19,464 |
32 | // $1.8 | return 180 * 10**decimals / 100;
| return 180 * 10**decimals / 100;
| 26,822 |
43 | // uint256 public hump; surplus buffer [rad] | function hump() public view returns (uint256);
| function hump() public view returns (uint256);
| 40,811 |
51 | // Number of SECCoins sent to Ether contributors | uint public SECCoinSold;
| uint public SECCoinSold;
| 19,284 |
6 | // Emitted when a collateral factor is changed by admin | event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa);
| event NewCollateralFactor(CToken cToken, uint oldCollateralFactorMantissa, uint newCollateralFactorMantissa);
| 9,046 |
55 | // The ID a motion on an address is currently operating at. Zero if no such motion is running. | mapping(address => uint) public targetMotionID;
| mapping(address => uint) public targetMotionID;
| 35,712 |
0 | // Sets initial admin / | constructor(address _admin) {
Ownable.transferOwnership(_admin);
}
| constructor(address _admin) {
Ownable.transferOwnership(_admin);
}
| 14,007 |
7 | // Constructor, takes params to set up quasar contract plasmaFrameworkContract Plasma Framework contract address _quasarOwner Receiver address on Plasma _safeBlockMargin The Quasar will not accept exits for outputs younger than the current plasma block minus the safe block margin_waitingPeriod Waiting period from submission to processing claim _bondValue bond to obtain tickets/ | constructor (
address plasmaFrameworkContract,
address spendingConditionRegistryContract,
address _quasarOwner,
uint256 _safeBlockMargin,
uint256 _waitingPeriod,
uint256 _bondValue
| constructor (
address plasmaFrameworkContract,
address spendingConditionRegistryContract,
address _quasarOwner,
uint256 _safeBlockMargin,
uint256 _waitingPeriod,
uint256 _bondValue
| 40,723 |
43 | // sellAmount {sellTok} Surplus amount (whole tokens)/ buyAmount {buyTok} Deficit amount (whole tokens)/ sellPrice {UoA/sellTok}/ buyPrice {UoA/sellTok}/ Defining "sell" and "buy": If bal(e) > (quantity(e)range.top), then e is in surplus by the difference If bal(e) < (quantity(e)range.bottom), then e is in deficit by the difference First, ignoring RSR: `trade.sell` is the token from erc20s with the greatest surplus value (in UoA), and sellAmount is the quantity of that token that it's in surplus (in qTok). if `trade.sell` == 0, then no token is in surplus by at least minTradeSize,and `trade.sellAmount` and `trade.sellPrice` are unset. `trade.buy` is the token from erc20s with | function nextTradePair(
ComponentCache memory components,
TradingRules memory rules,
IERC20[] memory erc20s,
BasketRange memory range
) private view returns (TradeInfo memory trade) {
MaxSurplusDeficit memory maxes;
maxes.surplusStatus = CollateralStatus.IFFY; // least-desirable sell status
for (uint256 i = 0; i < erc20s.length; ++i) {
| function nextTradePair(
ComponentCache memory components,
TradingRules memory rules,
IERC20[] memory erc20s,
BasketRange memory range
) private view returns (TradeInfo memory trade) {
MaxSurplusDeficit memory maxes;
maxes.surplusStatus = CollateralStatus.IFFY; // least-desirable sell status
for (uint256 i = 0; i < erc20s.length; ++i) {
| 27,020 |
62 | // Upgradeability is only provided internally through {_upgradeTo}. For an externally upgradeable proxy see{TransparentUpgradeableProxy}. / | contract UpgradeableProxy is Proxy {
| contract UpgradeableProxy is Proxy {
| 62,710 |
16 | // The upper tick of the range | function tickUpper() external view returns (int24);
| function tickUpper() external view returns (int24);
| 21,557 |
59 | // Delete your Glofile uri with index `i` Deletes an uri with a specific index. i index of uri to delete / | function deleteUri(uint i) {
delete glofiles[msg.sender].uris[i];
Update(msg.sender);
}
| function deleteUri(uint i) {
delete glofiles[msg.sender].uris[i];
Update(msg.sender);
}
| 10,436 |
174 | // Get the (soon to be) popped strategy. | Strategy poppedStrategy = withdrawalStack[withdrawalStack.length - 1];
| Strategy poppedStrategy = withdrawalStack[withdrawalStack.length - 1];
| 6,266 |
71 | // Mapping owner address to address data. Bits Layout: - [0..63]`balance` - [64..127]`numberMinted` - [128..191] `numberBurned` - [192..255] `aux` | mapping(address => uint256) internal _packedAddressData;
| mapping(address => uint256) internal _packedAddressData;
| 5,163 |
0 | // -------------contract interfaces------------- / | function fundToken() internal view returns (address) {
return requireAndGetAddress(CONTRACT_FUNDTOKEN, "Missing FundToken Address");
}
| function fundToken() internal view returns (address) {
return requireAndGetAddress(CONTRACT_FUNDTOKEN, "Missing FundToken Address");
}
| 23,700 |
0 | // AppToken build contract interface (for apps ICO) / | interface AppTokenBuildI {
/**
* @dev CreateAppTokenContract - create new AppToken contract and return him address
*/
function CreateAppTokenContract(string _name, string _symbol, address _CrowdSale, address _PMFund, address _dev) external returns (address);
} | interface AppTokenBuildI {
/**
* @dev CreateAppTokenContract - create new AppToken contract and return him address
*/
function CreateAppTokenContract(string _name, string _symbol, address _CrowdSale, address _PMFund, address _dev) external returns (address);
} | 44,587 |
31 | // updates the deposit fee can only be called by the owner _depositFee new deposit fee in basis points / | function setDepositFee(uint256 _depositFee) external onlyOwner {
require(_depositFee <= DEPOSIT_FEE_CAP, 'setDepositFee: CAP_EXCEEDED');
depositFee = _depositFee;
emit SetDepositFee(_depositFee);
}
| function setDepositFee(uint256 _depositFee) external onlyOwner {
require(_depositFee <= DEPOSIT_FEE_CAP, 'setDepositFee: CAP_EXCEEDED');
depositFee = _depositFee;
emit SetDepositFee(_depositFee);
}
| 2,145 |
27 | // Returns the number of the first codepoint in the slice. self The slice to operate on.return The number of the first codepoint in the slice. / | function ord(slice memory self) internal pure returns (uint256 ret) {
if (self._len == 0) {
return 0;
}
uint256 word;
uint256 length;
uint256 divisor = 2**248;
// Load the rune into the MSBs of b
assembly {
word := mload(mload(add(self, 32)))
}
uint256 b = word / divisor;
if (b < 0x80) {
ret = b;
length = 1;
} else if (b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if (b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
ret = b & 0x07;
length = 4;
}
// Check for truncated codepoints
if (length > self._len) {
return 0;
}
for (uint256 i = 1; i < length; i++) {
divisor = divisor / 256;
b = (word / divisor) & 0xFF;
if (b & 0xC0 != 0x80) {
// Invalid UTF-8 sequence
return 0;
}
ret = (ret * 64) | (b & 0x3F);
}
return ret;
}
| function ord(slice memory self) internal pure returns (uint256 ret) {
if (self._len == 0) {
return 0;
}
uint256 word;
uint256 length;
uint256 divisor = 2**248;
// Load the rune into the MSBs of b
assembly {
word := mload(mload(add(self, 32)))
}
uint256 b = word / divisor;
if (b < 0x80) {
ret = b;
length = 1;
} else if (b < 0xE0) {
ret = b & 0x1F;
length = 2;
} else if (b < 0xF0) {
ret = b & 0x0F;
length = 3;
} else {
ret = b & 0x07;
length = 4;
}
// Check for truncated codepoints
if (length > self._len) {
return 0;
}
for (uint256 i = 1; i < length; i++) {
divisor = divisor / 256;
b = (word / divisor) & 0xFF;
if (b & 0xC0 != 0x80) {
// Invalid UTF-8 sequence
return 0;
}
ret = (ret * 64) | (b & 0x3F);
}
return ret;
}
| 17,894 |
203 | // the liquidation threshold of the reserve. Expressed in percentage (0-100) | uint256 liquidationThreshold;
| uint256 liquidationThreshold;
| 9,049 |
129 | // Helper function to migrate user's tokens. Should be called in migrateFunds() function._tokens address[] representing the token addresses which are going to be migrated./ | function migrateTokens(address[] _tokens) private {
for (uint256 index = 0; index < _tokens.length; index++) {
address tokenAddress = _tokens[index];
uint256 tokenAmount = balances[tokenAddress][msg.sender];
if (0 == tokenAmount) {
continue;
}
require(
Token(tokenAddress).approve(newExchangeAddress, tokenAmount),
"Approve failed"
);
balances[tokenAddress][msg.sender] = 0;
IUpgradableExchange(newExchangeAddress).importTokens(tokenAddress, tokenAmount, msg.sender);
}
}
| function migrateTokens(address[] _tokens) private {
for (uint256 index = 0; index < _tokens.length; index++) {
address tokenAddress = _tokens[index];
uint256 tokenAmount = balances[tokenAddress][msg.sender];
if (0 == tokenAmount) {
continue;
}
require(
Token(tokenAddress).approve(newExchangeAddress, tokenAmount),
"Approve failed"
);
balances[tokenAddress][msg.sender] = 0;
IUpgradableExchange(newExchangeAddress).importTokens(tokenAddress, tokenAmount, msg.sender);
}
}
| 12,662 |
122 | // Allow the Owner to withdraw any funds that have been 'wrongly'transferred to the migrator contract / | function withdrawFund(IERC20 token, uint256 amount) external onlyOwner {
if (token == IERC20(0)) {
(bool success, ) = owner().call{value: amount}("");
require(success, "Migrator: TRANSFER_ETH_FAILED");
} else {
token.safeTransfer(owner(), amount);
}
}
| function withdrawFund(IERC20 token, uint256 amount) external onlyOwner {
if (token == IERC20(0)) {
(bool success, ) = owner().call{value: amount}("");
require(success, "Migrator: TRANSFER_ETH_FAILED");
} else {
token.safeTransfer(owner(), amount);
}
}
| 59,972 |
72 | // Token address of the bridge asset that prices are derived from if the specified pair price is missing | address public masterQuoteAsset;
| address public masterQuoteAsset;
| 52,109 |
7 | // Resets all mocked methods and invocation counts. / | function reset() external;
| function reset() external;
| 27,300 |
257 | // Set the capitalization flags based on the characters and the checksums. | characterIsCapitalized[2 * i] = (
leftNibbleAddress > 9 &&
leftNibbleHash > 7
);
characterIsCapitalized[2 * i + 1] = (
rightNibbleAddress > 9 &&
rightNibbleHash > 7
);
| characterIsCapitalized[2 * i] = (
leftNibbleAddress > 9 &&
leftNibbleHash > 7
);
characterIsCapitalized[2 * i + 1] = (
rightNibbleAddress > 9 &&
rightNibbleHash > 7
);
| 23,160 |
270 | // register the supported interfaces to conform to ERC1155 via ERC165 | _registerInterface(_INTERFACE_ID_ERC1155);
| _registerInterface(_INTERFACE_ID_ERC1155);
| 4,836 |
109 | // Internal liquidation process asset The address of the main collateral token positionOwner The address of a position's owner mainAssetToLiquidator The amount of main asset to send to a liquidator colToLiquidator The amount of COL to send to a liquidator mainAssetToPositionOwner The amount of main asset to send to a position owner colToPositionOwner The amount of COL to send to a position owner repayment The repayment in USDP penalty The liquidation penalty in USDP liquidator The address of a liquidator / | {
require(liquidationBlock[asset][positionOwner] != 0, "Unit Protocol: NOT_TRIGGERED_LIQUIDATION");
uint mainAssetInPosition = collaterals[asset][positionOwner];
uint mainAssetToFoundation = mainAssetInPosition.sub(mainAssetToLiquidator).sub(mainAssetToPositionOwner);
uint colInPosition = colToken[asset][positionOwner];
uint colToFoundation = colInPosition.sub(colToLiquidator).sub(colToPositionOwner);
delete liquidationPrice[asset][positionOwner];
delete liquidationBlock[asset][positionOwner];
delete debts[asset][positionOwner];
delete collaterals[asset][positionOwner];
delete colToken[asset][positionOwner];
destroy(asset, positionOwner);
// charge liquidation fee and burn USDP
if (repayment > penalty) {
if (penalty != 0) {
TransferHelper.safeTransferFrom(usdp, liquidator, vaultParameters.foundation(), penalty);
}
USDP(usdp).burn(liquidator, repayment.sub(penalty));
} else {
if (repayment != 0) {
TransferHelper.safeTransferFrom(usdp, liquidator, vaultParameters.foundation(), repayment);
}
}
// send the part of collateral to a liquidator
if (mainAssetToLiquidator != 0) {
TransferHelper.safeTransfer(asset, liquidator, mainAssetToLiquidator);
}
if (colToLiquidator != 0) {
TransferHelper.safeTransfer(col, liquidator, colToLiquidator);
}
// send the rest of collateral to a position owner
if (mainAssetToPositionOwner != 0) {
TransferHelper.safeTransfer(asset, positionOwner, mainAssetToPositionOwner);
}
if (colToPositionOwner != 0) {
TransferHelper.safeTransfer(col, positionOwner, colToPositionOwner);
}
if (mainAssetToFoundation != 0) {
TransferHelper.safeTransfer(asset, vaultParameters.foundation(), mainAssetToFoundation);
}
if (colToFoundation != 0) {
TransferHelper.safeTransfer(col, vaultParameters.foundation(), colToFoundation);
}
}
| {
require(liquidationBlock[asset][positionOwner] != 0, "Unit Protocol: NOT_TRIGGERED_LIQUIDATION");
uint mainAssetInPosition = collaterals[asset][positionOwner];
uint mainAssetToFoundation = mainAssetInPosition.sub(mainAssetToLiquidator).sub(mainAssetToPositionOwner);
uint colInPosition = colToken[asset][positionOwner];
uint colToFoundation = colInPosition.sub(colToLiquidator).sub(colToPositionOwner);
delete liquidationPrice[asset][positionOwner];
delete liquidationBlock[asset][positionOwner];
delete debts[asset][positionOwner];
delete collaterals[asset][positionOwner];
delete colToken[asset][positionOwner];
destroy(asset, positionOwner);
// charge liquidation fee and burn USDP
if (repayment > penalty) {
if (penalty != 0) {
TransferHelper.safeTransferFrom(usdp, liquidator, vaultParameters.foundation(), penalty);
}
USDP(usdp).burn(liquidator, repayment.sub(penalty));
} else {
if (repayment != 0) {
TransferHelper.safeTransferFrom(usdp, liquidator, vaultParameters.foundation(), repayment);
}
}
// send the part of collateral to a liquidator
if (mainAssetToLiquidator != 0) {
TransferHelper.safeTransfer(asset, liquidator, mainAssetToLiquidator);
}
if (colToLiquidator != 0) {
TransferHelper.safeTransfer(col, liquidator, colToLiquidator);
}
// send the rest of collateral to a position owner
if (mainAssetToPositionOwner != 0) {
TransferHelper.safeTransfer(asset, positionOwner, mainAssetToPositionOwner);
}
if (colToPositionOwner != 0) {
TransferHelper.safeTransfer(col, positionOwner, colToPositionOwner);
}
if (mainAssetToFoundation != 0) {
TransferHelper.safeTransfer(asset, vaultParameters.foundation(), mainAssetToFoundation);
}
if (colToFoundation != 0) {
TransferHelper.safeTransfer(col, vaultParameters.foundation(), colToFoundation);
}
}
| 44,886 |
72 | // Creating locked balances | struct LockBox {
address beneficiary;
uint256 lockedBalance;
uint256 unlockTime;
bool locked;
}
| struct LockBox {
address beneficiary;
uint256 lockedBalance;
uint256 unlockTime;
bool locked;
}
| 31,482 |
9 | // return indicator whether encoded payload is a list. negate this function call for isData. | function isList(RLPItem memory item) internal pure returns (bool) {
if (item.len == 0) return false;
uint8 byte0;
uint memPtr = item.memPtr;
assembly {
byte0 := byte(0, mload(memPtr))
}
if (byte0 < LIST_SHORT_START)
return false;
return true;
}
| function isList(RLPItem memory item) internal pure returns (bool) {
if (item.len == 0) return false;
uint8 byte0;
uint memPtr = item.memPtr;
assembly {
byte0 := byte(0, mload(memPtr))
}
if (byte0 < LIST_SHORT_START)
return false;
return true;
}
| 12,571 |
41 | // Liquidate a Position/Steps to liquidate: update position's fixed and variable token balances to account for balances accumulated throughout the trades made since the last mint/burn/poke,/Check if the position is liquidatable by calling the isLiquidatablePosition function of the calculator, revert if that is not the case,/Calculate the liquidation reward = current margin of the positionliquidatorReward, subtract the liquidator reward from the position margin,/Burn the position's liquidity, unwind unnetted fixed and variable balances of a position, transfer the reward to the liquidator | function liquidatePosition(
address _owner,
int24 _tickLower,
int24 _tickUpper
) external returns (uint256);
| function liquidatePosition(
address _owner,
int24 _tickLower,
int24 _tickUpper
) external returns (uint256);
| 27,248 |
2 | // Fees declaration | uint256 public _burnFee = 1;
uint256 private _previousBurnFee = _burnFee;
uint256 public _deflectionFee = 1;
uint256 private _previousDeflectionFee = _deflectionFee;
| uint256 public _burnFee = 1;
uint256 private _previousBurnFee = _burnFee;
uint256 public _deflectionFee = 1;
uint256 private _previousDeflectionFee = _deflectionFee;
| 2,720 |
36 | // Base contract for contracts that should not own things. Remco Bloemen <remco@2π.com> Solves a class of errors where a contract accidentally becomes owner of Ether, Tokens orOwned contracts. See respective base contracts for details. / | contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {
}
| contract NoOwner is HasNoEther, HasNoTokens, HasNoContracts {
}
| 51,338 |
33 | // Approves an order. Cannot already be approved or canceled. orderThe order to approve / | function approveOrder(
Order memory order
)
public
| function approveOrder(
Order memory order
)
public
| 43,104 |
47 | // sy=((qy-py)/(qx-px))(px-sx)-py | (sy, dy) = projectiveSub(px, z1, sx, dx); // px-sx
(sy, dy) = projectiveMul(sy, dy, lx, lz); // ((qy-py)/(qx-px))(px-sx)
(sy, dy) = projectiveSub(sy, dy, py, z1); // ((qy-py)/(qx-px))(px-sx)-py
if (dx != dy) { // Cross-multiply to put everything over a common denominator
sx = mulmod(sx, dy, FIELD_SIZE);
sy = mulmod(sy, dx, FIELD_SIZE);
sz = mulmod(dx, dy, FIELD_SIZE);
} else { // Already over a common denominator, use that for z ordinate
| (sy, dy) = projectiveSub(px, z1, sx, dx); // px-sx
(sy, dy) = projectiveMul(sy, dy, lx, lz); // ((qy-py)/(qx-px))(px-sx)
(sy, dy) = projectiveSub(sy, dy, py, z1); // ((qy-py)/(qx-px))(px-sx)-py
if (dx != dy) { // Cross-multiply to put everything over a common denominator
sx = mulmod(sx, dy, FIELD_SIZE);
sy = mulmod(sy, dx, FIELD_SIZE);
sz = mulmod(dx, dy, FIELD_SIZE);
} else { // Already over a common denominator, use that for z ordinate
| 45,288 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.