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 | // Promise not to modify or read from the state. | function add(uint256 i, uint256 j) public pure returns (uint256) {
return i + j;
}
| function add(uint256 i, uint256 j) public pure returns (uint256) {
return i + j;
}
| 8,832 |
51 | // The total supply available | uint256 maxSupply;
| uint256 maxSupply;
| 298 |
25 | // Internal function to safely mint a new token.Reverts if the given token ID already exists.If the target address is a contract, it must implement `onERC721Received`,which is called upon a safe transfer, and return the magic value`bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,the transfer is reverted. to The address that will own the minted token tokenId uint256 ID of the token to be minted _data bytes data to send along with a safe transfer check / | function _safeMint(address to, uint256 tokenId, bytes memory _data) internal {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| function _safeMint(address to, uint256 tokenId, bytes memory _data) internal {
_mint(to, tokenId);
require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
| 11,414 |
114 | // Mapping owner address to token count | mapping(address => uint256) private _balances;
| mapping(address => uint256) private _balances;
| 33,183 |
20 | // Migrate LP token to another LP contract through the `migrator` contract./_pid The index of the pool. See `poolInfo`. | function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "MasterChefV2: no migrator set");
IERC20 _lpToken = lpToken[_pid];
uint256 bal = _lpToken.balanceOf(address(this));
_lpToken.approve(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(_lpToken);
require(bal == newLpToken.balanceOf(address(this)), "MasterChefV2: migrated balance must match");
lpToken[_pid] = newLpToken;
}
| function migrate(uint256 _pid) public {
require(address(migrator) != address(0), "MasterChefV2: no migrator set");
IERC20 _lpToken = lpToken[_pid];
uint256 bal = _lpToken.balanceOf(address(this));
_lpToken.approve(address(migrator), bal);
IERC20 newLpToken = migrator.migrate(_lpToken);
require(bal == newLpToken.balanceOf(address(this)), "MasterChefV2: migrated balance must match");
lpToken[_pid] = newLpToken;
}
| 10,361 |
4 | // Event is emitted if an operator job execution fails / | event FailedOperatorJob(bytes32 jobHash);
| event FailedOperatorJob(bytes32 jobHash);
| 17,310 |
1 | // Simple send by Checque / | function signerOfSimpleCheque(address _token, address _to, uint256 _amount, bytes _data, uint256 _nonce, bytes _sig) private pure returns (address) {
return keccak256(abi.encodePacked(_token, _to, _amount, _data, _nonce)).toEthSignedMessageHash().recover(_sig);
}
| function signerOfSimpleCheque(address _token, address _to, uint256 _amount, bytes _data, uint256 _nonce, bytes _sig) private pure returns (address) {
return keccak256(abi.encodePacked(_token, _to, _amount, _data, _nonce)).toEthSignedMessageHash().recover(_sig);
}
| 14,891 |
341 | // Credit line terms | address public override borrower;
uint256 public override limit;
uint256 public override interestApr;
uint256 public override paymentPeriodInDays;
uint256 public override termInDays;
uint256 public override lateFeeApr;
| address public override borrower;
uint256 public override limit;
uint256 public override interestApr;
uint256 public override paymentPeriodInDays;
uint256 public override termInDays;
uint256 public override lateFeeApr;
| 52,776 |
21 | // GENESIS/MOB | function isGenesisMOBOn(
uint256 publicPriceWei,
uint256 GenesisMobTime
| function isGenesisMOBOn(
uint256 publicPriceWei,
uint256 GenesisMobTime
| 66,152 |
2 | // Revoke controller permission for an address. | function removeController(address controller) external;
| function removeController(address controller) external;
| 26,958 |
231 | // decreases the total borrows at a stable rate on a specific reserve and updates the average stable rate consequently_reserve the reserve object_amount the amount to substract to the total borrows stable_rate the rate at which the amount has been repaid/ | ) internal {
require(_reserve.totalBorrowsStable >= _amount, "Invalid amount to decrease");
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.sub(_amount);
if (_reserve.totalBorrowsStable == 0) {
_reserve.currentAverageStableBorrowRate = 0; //no income if there are no stable rate borrows
return;
}
//update the average stable rate
//weighted average of all the borrows
uint256 weightedLastBorrow = _amount.wadToRay().rayMul(_rate);
uint256 weightedPreviousTotalBorrows = previousTotalBorrowStable.wadToRay().rayMul(
_reserve.currentAverageStableBorrowRate
);
require(
weightedPreviousTotalBorrows >= weightedLastBorrow,
"The amounts to subtract don't match"
);
_reserve.currentAverageStableBorrowRate = weightedPreviousTotalBorrows
.sub(weightedLastBorrow)
.rayDiv(_reserve.totalBorrowsStable.wadToRay());
}
| ) internal {
require(_reserve.totalBorrowsStable >= _amount, "Invalid amount to decrease");
uint256 previousTotalBorrowStable = _reserve.totalBorrowsStable;
//updating reserve borrows stable
_reserve.totalBorrowsStable = _reserve.totalBorrowsStable.sub(_amount);
if (_reserve.totalBorrowsStable == 0) {
_reserve.currentAverageStableBorrowRate = 0; //no income if there are no stable rate borrows
return;
}
//update the average stable rate
//weighted average of all the borrows
uint256 weightedLastBorrow = _amount.wadToRay().rayMul(_rate);
uint256 weightedPreviousTotalBorrows = previousTotalBorrowStable.wadToRay().rayMul(
_reserve.currentAverageStableBorrowRate
);
require(
weightedPreviousTotalBorrows >= weightedLastBorrow,
"The amounts to subtract don't match"
);
_reserve.currentAverageStableBorrowRate = weightedPreviousTotalBorrows
.sub(weightedLastBorrow)
.rayDiv(_reserve.totalBorrowsStable.wadToRay());
}
| 34,048 |
61 | // Event log. | emit RewardClaimed(_userAddress, _poolToken, userAccumulatedReward);
| emit RewardClaimed(_userAddress, _poolToken, userAccumulatedReward);
| 12,346 |
162 | // Address to pull rewards from. Must have provided an allowance to this contract. | address public immutable REWARDS_TREASURY;
| address public immutable REWARDS_TREASURY;
| 81,151 |
219 | // The fee is expressed as a percentage. E.g. a value of 40 stands for a 40% fee, so the recipient will be charged for 1.4 times the spent amount. | return (gas * gasPrice * (100 + serviceFee)) / 100;
| return (gas * gasPrice * (100 + serviceFee)) / 100;
| 21,315 |
203 | // Check that the transaction batch is well-formed | require(
_amounts.length == _destinations.length &&
_amounts.length == _fees.length,
"Malformed batch of transactions"
);
| require(
_amounts.length == _destinations.length &&
_amounts.length == _fees.length,
"Malformed batch of transactions"
);
| 27,714 |
14 | // Returns the addresses of the current and new owner. / | function owner() public view returns (address currentOwner, address newOwner) {
currentOwner = _owner;
newOwner = _newOwner;
}
| function owner() public view returns (address currentOwner, address newOwner) {
currentOwner = _owner;
newOwner = _newOwner;
}
| 18,726 |
7 | // disables a controller by setting its worker to address(0). _controller The controller to disable. / | function removeController(address _controller) public onlyOwner {
require(
_controller != address(0),
"Controller must be a non-zero address"
);
require(
controllers[_controller] != address(0),
"Worker must be a non-zero address"
);
controllers[_controller] = address(0);
emit ControllerRemoved(_controller);
}
| function removeController(address _controller) public onlyOwner {
require(
_controller != address(0),
"Controller must be a non-zero address"
);
require(
controllers[_controller] != address(0),
"Worker must be a non-zero address"
);
controllers[_controller] = address(0);
emit ControllerRemoved(_controller);
}
| 47,496 |
22 | // hxb contract setup | address internal hxbAddress = 0x9BB6fd000109E24Eb38B0Deb806382fF9247E478;
IERC20 internal hxbInterface = IERC20(hxbAddress);
HXB internal hxbControl = HXB(hxbAddress);
address payable public liquidityBuyback = 0xf72842821c58aDe72EDa5ec5399B959b499d4AA4;
address public hexDividendContract = 0x7d68C0321cf6B3A12E6e5D5ABbAA8F2A13d77FDd;
address public hxyDividendContract = 0x8530261684C0549D5E85A30934e30D60C46AA8a1;
| address internal hxbAddress = 0x9BB6fd000109E24Eb38B0Deb806382fF9247E478;
IERC20 internal hxbInterface = IERC20(hxbAddress);
HXB internal hxbControl = HXB(hxbAddress);
address payable public liquidityBuyback = 0xf72842821c58aDe72EDa5ec5399B959b499d4AA4;
address public hexDividendContract = 0x7d68C0321cf6B3A12E6e5D5ABbAA8F2A13d77FDd;
address public hxyDividendContract = 0x8530261684C0549D5E85A30934e30D60C46AA8a1;
| 60,725 |
42 | // check whether caller requested for this data | uint k = findIndexOfPriceId(priceIds, priceId);
| uint k = findIndexOfPriceId(priceIds, priceId);
| 14,855 |
143 | // Function to deposit tokens to bridge on specified network | function depositTokens(
address token,
uint256 amount,
uint256 networkId
)
public
isBridgeNotFrozen
isAmountGreaterThanZero(amount)
isAssetNotFrozen(token)
isPathNotPaused(token, "depositTokens")
| function depositTokens(
address token,
uint256 amount,
uint256 networkId
)
public
isBridgeNotFrozen
isAmountGreaterThanZero(amount)
isAssetNotFrozen(token)
isPathNotPaused(token, "depositTokens")
| 53,982 |
37 | // Increment the number of bounty created by this user | createdBountyCount[msg.sender]++;
| createdBountyCount[msg.sender]++;
| 1,395 |
53 | // MSJ: Get Contract Balanve | function getContractBalance() public requireIsOperational returns(uint)
| function getContractBalance() public requireIsOperational returns(uint)
| 39,727 |
61 | // units = ((T + B)(tB + Tb))/(4TB) (part1(part2 + part3)) / part4 | uint part1 = T.add(B);
uint part2 = t.mul(B);
uint part3 = T.mul(b);
uint numerator = part1.mul((part2.add(part3)));
uint part4 = 4 * (T.mul(B));
return numerator.div(part4);
| uint part1 = T.add(B);
uint part2 = t.mul(B);
uint part3 = T.mul(b);
uint numerator = part1.mul((part2.add(part3)));
uint part4 = 4 * (T.mul(B));
return numerator.div(part4);
| 48,955 |
5 | // Function to create a new proposal | function createProposal(
string memory _goal,
uint256 _fundingRequired,
uint256 _duration,
string memory projectId
| function createProposal(
string memory _goal,
uint256 _fundingRequired,
uint256 _duration,
string memory projectId
| 19,417 |
13 | // Returns the remaining number of tokens that `spender` will be | * allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| * allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*/
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
| 7,288 |
150 | // Extend parent behavior requiring beneficiary to be in whitelist. _beneficiary Token beneficiary _weiAmount Amount of wei contributed / | function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
onlyIfWhitelisted(_beneficiary)
| function _preValidatePurchase(
address _beneficiary,
uint256 _weiAmount
)
internal
onlyIfWhitelisted(_beneficiary)
| 36,227 |
11 | // bool submitBid = (a.status != AuctionStatus.End && !compareTo(bidder, a.currentBidder) && !compareTo(bidder, a.assetOwner)); | return (_auctionId, a.assetName, a.assetOwner, a.basePrice, a.currentBid, a.currentBidder, a.auctionExpiry, a.result, a.status);
| return (_auctionId, a.assetName, a.assetOwner, a.basePrice, a.currentBid, a.currentBidder, a.auctionExpiry, a.result, a.status);
| 43,002 |
24 | // expmods[19] = trace_generator^(251trace_length / 256). | mstore(0x4680, expmod(/*trace_generator*/ mload(0x3a0), div(mul(251, /*trace_length*/ mload(0x80)), 256), PRIME))
| mstore(0x4680, expmod(/*trace_generator*/ mload(0x3a0), div(mul(251, /*trace_length*/ mload(0x80)), 256), PRIME))
| 56,543 |
11 | // Update the given pool's PKKT allocation point. Can only be called by the owner. | function set(Pool.UpdatePoolParameters memory _newSetting, bool _withUpdate) external
onlyOwner validatePoolById(_newSetting.pid)
| function set(Pool.UpdatePoolParameters memory _newSetting, bool _withUpdate) external
onlyOwner validatePoolById(_newSetting.pid)
| 40,012 |
41 | // pass _parentId = 0 if you want the contract to search free slot for you, else passing non zero _parent id will be considered as desired parent, and will save little gas | function regUser(uint256 _networkId,uint256 _referrerId,uint256 _parentId, uint256 amount) public payable returns(bool)
| function regUser(uint256 _networkId,uint256 _referrerId,uint256 _parentId, uint256 amount) public payable returns(bool)
| 26,727 |
2 | // Fidi.Cash Core Contract Core contract for managing Fidi Offers and Deals / | contract FidiCore {
event OfferCreated(address indexed seller, address offer);
event DealCreated(address indexed buyer, address deal, address offer);
function createOffer(address tokenAddress) public returns (address) {
address seller = msg.sender;
address offerAddress = address(new Offer(tokenAddress, seller));
emit OfferCreated(seller, offerAddress);
return offerAddress;
}
function createDeal(address tokenAddress, address offerAddress)
public
returns (address)
{
address buyer = msg.sender;
address dealAddress = address(new Deal(tokenAddress, offerAddress, buyer));
emit DealCreated(buyer, dealAddress, offerAddress);
return dealAddress;
}
}
| contract FidiCore {
event OfferCreated(address indexed seller, address offer);
event DealCreated(address indexed buyer, address deal, address offer);
function createOffer(address tokenAddress) public returns (address) {
address seller = msg.sender;
address offerAddress = address(new Offer(tokenAddress, seller));
emit OfferCreated(seller, offerAddress);
return offerAddress;
}
function createDeal(address tokenAddress, address offerAddress)
public
returns (address)
{
address buyer = msg.sender;
address dealAddress = address(new Deal(tokenAddress, offerAddress, buyer));
emit DealCreated(buyer, dealAddress, offerAddress);
return dealAddress;
}
}
| 28,820 |
20 | // liquidationIncentiveMantissa must be no greater than this value | uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5
| uint256 internal constant liquidationIncentiveMaxMantissa = 1.5e18; // 1.5
| 34,867 |
6 | // Testing the getArrayOfNumericalInformation() function for all types of information: price, percent and increment | function testArrayOfNumericalInformation() public {
uint[expectedItemCount] memory returnedPriceArray = auction.getArrayOfNumericalInformation(1);
uint[expectedItemCount] memory returnedPercentArray = auction.getArrayOfNumericalInformation(2);
uint[expectedItemCount] memory returnedIncrementArray = auction.getArrayOfNumericalInformation(3);
for (uint i=0;i<expectedItemCount;i++) {
Assert.equal(returnedPriceArray[i], expectedPriceArray[i], "Expected and returned price arrays match.");
Assert.equal(returnedPercentArray[i], expectedPercentArray[i], "Expected and returned percent arrays match.");
Assert.equal(returnedIncrementArray[i], expectedIncrementArray[i], "Expected and returned increment arrays match.");
}
}
| function testArrayOfNumericalInformation() public {
uint[expectedItemCount] memory returnedPriceArray = auction.getArrayOfNumericalInformation(1);
uint[expectedItemCount] memory returnedPercentArray = auction.getArrayOfNumericalInformation(2);
uint[expectedItemCount] memory returnedIncrementArray = auction.getArrayOfNumericalInformation(3);
for (uint i=0;i<expectedItemCount;i++) {
Assert.equal(returnedPriceArray[i], expectedPriceArray[i], "Expected and returned price arrays match.");
Assert.equal(returnedPercentArray[i], expectedPercentArray[i], "Expected and returned percent arrays match.");
Assert.equal(returnedIncrementArray[i], expectedIncrementArray[i], "Expected and returned increment arrays match.");
}
}
| 31,449 |
283 | // Reassign ownership (also clears pending approvals and emits Transfer event). | _transfer(_from, _to, _tokenId);
| _transfer(_from, _to, _tokenId);
| 40,858 |
113 | // Cannot add ABI if name is already used for an existing network contract | require(
getAddress(
keccak256(abi.encodePacked("contract.address", _name))
) == address(0x0),
"ABI name is already in use"
);
| require(
getAddress(
keccak256(abi.encodePacked("contract.address", _name))
) == address(0x0),
"ABI name is already in use"
);
| 7,991 |
103 | // Yeld To receive ETH after converting it from USDC | function () external payable {}
function setRetirementYeldTreasury(address payable _treasury) public onlyOwner {
retirementYeldTreasury = _treasury;
}
| function () external payable {}
function setRetirementYeldTreasury(address payable _treasury) public onlyOwner {
retirementYeldTreasury = _treasury;
}
| 47,189 |
305 | // Address of the Sorbetto's owner | address public governance;
| address public governance;
| 5,322 |
20 | // Responsible for access rights to the contract | MISOAccessControls public accessControls;
function setContracts(
address _tokenFactory,
address _market,
address _launcher,
address _farmFactory
| MISOAccessControls public accessControls;
function setContracts(
address _tokenFactory,
address _market,
address _launcher,
address _farmFactory
| 46,581 |
17 | // When a srcChain has the ability to transfer more chainIds in a single tx than the dst can do. Needs the ability to iterate and stop if the minGasToTransferAndStore is not met | function _creditTill(uint16 _srcChainId, address _toAddress, uint _startIndex, uint[] memory _tokenIds) internal returns (uint256){
uint i = _startIndex;
while (i < _tokenIds.length) {
// if not enough gas to process, store this index for next loop
if (gasleft() < minGasToTransferAndStore) break;
_creditTo(_srcChainId, _toAddress, _tokenIds[i]);
i++;
}
// indicates the next index to send of tokenIds,
// if i == tokenIds.length, we are finished
return i;
}
| function _creditTill(uint16 _srcChainId, address _toAddress, uint _startIndex, uint[] memory _tokenIds) internal returns (uint256){
uint i = _startIndex;
while (i < _tokenIds.length) {
// if not enough gas to process, store this index for next loop
if (gasleft() < minGasToTransferAndStore) break;
_creditTo(_srcChainId, _toAddress, _tokenIds[i]);
i++;
}
// indicates the next index to send of tokenIds,
// if i == tokenIds.length, we are finished
return i;
}
| 13,771 |
56 | // State data for statistical purposes ONLY | uint256 private referralCount;
uint256 private totalReferralReward;
mapping(address => uint256) private userReferralCount;
mapping(address => uint256) private userReferralReward;
address public referralCodeRegistrator; // Address who allowed to register code for users (will be used later)
address public marketingWallet;
address private constant _DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
mapping(address => uint256) private _rOwned;
| uint256 private referralCount;
uint256 private totalReferralReward;
mapping(address => uint256) private userReferralCount;
mapping(address => uint256) private userReferralReward;
address public referralCodeRegistrator; // Address who allowed to register code for users (will be used later)
address public marketingWallet;
address private constant _DEAD_ADDRESS = 0x000000000000000000000000000000000000dEaD;
mapping(address => uint256) private _rOwned;
| 2,533 |
267 | // The EIP-712 typehash for the contract's domain | bytes32 public constant DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
| bytes32 public constant DOMAIN_TYPEHASH =
keccak256("EIP712Domain(string name,uint256 chainId,address verifyingContract)");
| 1,027 |
110 | // Whether `a` is less than or equal to `b`. a an int256. b a FixedPoint.Signed.return True if `a <= b`, or False. / | function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue <= b.rawValue;
}
| function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue <= b.rawValue;
}
| 31,660 |
53 | // Send the money back | msg.sender.transfer(weiVal);
| msg.sender.transfer(weiVal);
| 41,266 |
206 | // The amount of tokens from the `_amount` to pay as a fee. | return
_amount - PRBMath.mulDiv(_amount, JBConstants.MAX_FEE, _discountedFee + JBConstants.MAX_FEE);
| return
_amount - PRBMath.mulDiv(_amount, JBConstants.MAX_FEE, _discountedFee + JBConstants.MAX_FEE);
| 36,205 |
5 | // number of days since unix epoch in UTC | function getDaysSinceEpoch() public view returns (uint256) {
(uint256 year, uint256 month, uint256 day) = BokkyPooBahsDateTimeLibrary
.timestampToDate(block.timestamp);
return BokkyPooBahsDateTimeLibrary._daysFromDate(year, month, day);
}
| function getDaysSinceEpoch() public view returns (uint256) {
(uint256 year, uint256 month, uint256 day) = BokkyPooBahsDateTimeLibrary
.timestampToDate(block.timestamp);
return BokkyPooBahsDateTimeLibrary._daysFromDate(year, month, day);
}
| 55,639 |
1 | // initialize _avatar the avatar to mint reputation from _reputationReward the total reputation this contract will reward for the token locking _lockingStartTime locking starting period time. _lockingEndTime the locking end time. locking is disable after this time. _redeemEnableTime redeem enable time . redeem reputation can be done after this time. _maxLockingPeriod maximum locking period allowed. _priceOracleContract the price oracle contract which the locked token will be validated against / | function initialize(
Avatar _avatar,
uint256 _reputationReward,
uint256 _lockingStartTime,
uint256 _lockingEndTime,
uint256 _redeemEnableTime,
| function initialize(
Avatar _avatar,
uint256 _reputationReward,
uint256 _lockingStartTime,
uint256 _lockingEndTime,
uint256 _redeemEnableTime,
| 20,489 |
19 | // returns whether a given address has the admin role for this contract | function isContractAdmin(address _admin) public view override returns (bool) {
return _core.hasRole(CONTRACT_ADMIN_ROLE, _admin);
}
| function isContractAdmin(address _admin) public view override returns (bool) {
return _core.hasRole(CONTRACT_ADMIN_ROLE, _admin);
}
| 18,716 |
26 | // To change circuit breaker state | function toggleCircuitBreaker() public onlyAdmin{
stopped = !stopped;
}
| function toggleCircuitBreaker() public onlyAdmin{
stopped = !stopped;
}
| 36,819 |
33 | // zero all bytes to the right | exp(0x100, sub(32, mlength))
),
| exp(0x100, sub(32, mlength))
),
| 5,521 |
5 | // Sells an ERC721 asset to fill the given order./buyOrder The ERC721 buy order./signature The order signature from the maker./erc721TokenId The ID of the ERC721 asset being/sold. If the given order specifies properties,/the asset must satisfy those properties. Otherwise,/it must equal the tokenId in the order./unwrapNativeToken If this parameter is true and the/ERC20 token of the order is e.g. WETH, unwraps the/token before transferring it to the taker./callbackData If this parameter is non-zero, invokes/`zeroExERC721OrderCallback` on `msg.sender` after/the ERC20 tokens have been transferred to `msg.sender`/but before transferring the ERC721 asset to the buyer. | function sellERC721(
LibNFTOrder.ERC721Order memory buyOrder,
LibSignature.Signature memory signature,
uint256 erc721TokenId,
bool unwrapNativeToken,
bytes memory callbackData
)
public
override
| function sellERC721(
LibNFTOrder.ERC721Order memory buyOrder,
LibSignature.Signature memory signature,
uint256 erc721TokenId,
bool unwrapNativeToken,
bytes memory callbackData
)
public
override
| 32,083 |
190 | // simplistic. not accurate | change = asset;
| change = asset;
| 21,116 |
8 | // Moves tokens from an address to Solo. Can either repay a borrow or provide additional supply. / | struct DepositArgs {
Types.AssetAmount amount;
Account.Info account;
uint256 market;
address from;
}
| struct DepositArgs {
Types.AssetAmount amount;
Account.Info account;
uint256 market;
address from;
}
| 20,508 |
32 | // DODO ERC20V2Factory DODO BreederHelp user to create erc20 token / | contract ERC20V2Factory is InitializableOwnable {
// ============ Templates ============
address public immutable _CLONE_FACTORY_;
address public _ERC20_TEMPLATE_;
address public _CUSTOM_ERC20_TEMPLATE_;
uint256 public _CREATE_FEE_;
// ============ Events ============
// 0 Std 1 TradeBurn or TradeFee 2 Mintable
event NewERC20(address erc20, address creator, uint256 erc20Type);
event ChangeCreateFee(uint256 newFee);
event Withdraw(address account, uint256 amount);
event ChangeStdTemplate(address newStdTemplate);
event ChangeCustomTemplate(address newCustomTemplate);
// ============ Registry ============
// creator -> token address list
mapping(address => address[]) public _USER_STD_REGISTRY_;
mapping(address => address[]) public _USER_CUSTOM_REGISTRY_;
// ============ Functions ============
fallback() external payable {}
receive() external payable {}
constructor(
address cloneFactory,
address erc20Template,
address customErc20Template
) public {
_CLONE_FACTORY_ = cloneFactory;
_ERC20_TEMPLATE_ = erc20Template;
_CUSTOM_ERC20_TEMPLATE_ = customErc20Template;
}
function createStdERC20(
uint256 totalSupply,
string memory name,
string memory symbol,
uint8 decimals
) external payable returns (address newERC20) {
require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH");
newERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_ERC20_TEMPLATE_);
IStdERC20(newERC20).init(msg.sender, totalSupply, name, symbol, decimals);
_USER_STD_REGISTRY_[msg.sender].push(newERC20);
emit NewERC20(newERC20, msg.sender, 0);
}
function createCustomERC20(
uint256 initSupply,
string memory name,
string memory symbol,
uint8 decimals,
uint256 tradeBurnRatio,
uint256 tradeFeeRatio,
address teamAccount,
bool isMintable
) external payable returns (address newCustomERC20) {
require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH");
newCustomERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_CUSTOM_ERC20_TEMPLATE_);
ICustomERC20(newCustomERC20).init(
msg.sender,
initSupply,
name,
symbol,
decimals,
tradeBurnRatio,
tradeFeeRatio,
teamAccount,
isMintable
);
_USER_CUSTOM_REGISTRY_[msg.sender].push(newCustomERC20);
if(isMintable)
emit NewERC20(newCustomERC20, msg.sender, 2);
else
emit NewERC20(newCustomERC20, msg.sender, 1);
}
// ============ View ============
function getTokenByUser(address user)
external
view
returns (address[] memory stds,address[] memory customs)
{
return (_USER_STD_REGISTRY_[user], _USER_CUSTOM_REGISTRY_[user]);
}
// ============ Ownable =============
function changeCreateFee(uint256 newFee) external onlyOwner {
_CREATE_FEE_ = newFee;
emit ChangeCreateFee(newFee);
}
function withdraw() external onlyOwner {
uint256 amount = address(this).balance;
msg.sender.transfer(amount);
emit Withdraw(msg.sender, amount);
}
function updateStdTemplate(address newStdTemplate) external onlyOwner {
_ERC20_TEMPLATE_ = newStdTemplate;
emit ChangeStdTemplate(newStdTemplate);
}
function updateCustomTemplate(address newCustomTemplate) external onlyOwner {
_CUSTOM_ERC20_TEMPLATE_ = newCustomTemplate;
emit ChangeCustomTemplate(newCustomTemplate);
}
} | contract ERC20V2Factory is InitializableOwnable {
// ============ Templates ============
address public immutable _CLONE_FACTORY_;
address public _ERC20_TEMPLATE_;
address public _CUSTOM_ERC20_TEMPLATE_;
uint256 public _CREATE_FEE_;
// ============ Events ============
// 0 Std 1 TradeBurn or TradeFee 2 Mintable
event NewERC20(address erc20, address creator, uint256 erc20Type);
event ChangeCreateFee(uint256 newFee);
event Withdraw(address account, uint256 amount);
event ChangeStdTemplate(address newStdTemplate);
event ChangeCustomTemplate(address newCustomTemplate);
// ============ Registry ============
// creator -> token address list
mapping(address => address[]) public _USER_STD_REGISTRY_;
mapping(address => address[]) public _USER_CUSTOM_REGISTRY_;
// ============ Functions ============
fallback() external payable {}
receive() external payable {}
constructor(
address cloneFactory,
address erc20Template,
address customErc20Template
) public {
_CLONE_FACTORY_ = cloneFactory;
_ERC20_TEMPLATE_ = erc20Template;
_CUSTOM_ERC20_TEMPLATE_ = customErc20Template;
}
function createStdERC20(
uint256 totalSupply,
string memory name,
string memory symbol,
uint8 decimals
) external payable returns (address newERC20) {
require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH");
newERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_ERC20_TEMPLATE_);
IStdERC20(newERC20).init(msg.sender, totalSupply, name, symbol, decimals);
_USER_STD_REGISTRY_[msg.sender].push(newERC20);
emit NewERC20(newERC20, msg.sender, 0);
}
function createCustomERC20(
uint256 initSupply,
string memory name,
string memory symbol,
uint8 decimals,
uint256 tradeBurnRatio,
uint256 tradeFeeRatio,
address teamAccount,
bool isMintable
) external payable returns (address newCustomERC20) {
require(msg.value >= _CREATE_FEE_, "CREATE_FEE_NOT_ENOUGH");
newCustomERC20 = ICloneFactory(_CLONE_FACTORY_).clone(_CUSTOM_ERC20_TEMPLATE_);
ICustomERC20(newCustomERC20).init(
msg.sender,
initSupply,
name,
symbol,
decimals,
tradeBurnRatio,
tradeFeeRatio,
teamAccount,
isMintable
);
_USER_CUSTOM_REGISTRY_[msg.sender].push(newCustomERC20);
if(isMintable)
emit NewERC20(newCustomERC20, msg.sender, 2);
else
emit NewERC20(newCustomERC20, msg.sender, 1);
}
// ============ View ============
function getTokenByUser(address user)
external
view
returns (address[] memory stds,address[] memory customs)
{
return (_USER_STD_REGISTRY_[user], _USER_CUSTOM_REGISTRY_[user]);
}
// ============ Ownable =============
function changeCreateFee(uint256 newFee) external onlyOwner {
_CREATE_FEE_ = newFee;
emit ChangeCreateFee(newFee);
}
function withdraw() external onlyOwner {
uint256 amount = address(this).balance;
msg.sender.transfer(amount);
emit Withdraw(msg.sender, amount);
}
function updateStdTemplate(address newStdTemplate) external onlyOwner {
_ERC20_TEMPLATE_ = newStdTemplate;
emit ChangeStdTemplate(newStdTemplate);
}
function updateCustomTemplate(address newCustomTemplate) external onlyOwner {
_CUSTOM_ERC20_TEMPLATE_ = newCustomTemplate;
emit ChangeCustomTemplate(newCustomTemplate);
}
} | 33,694 |
1 | // Extract the owner from the state object data field | address owner = getOwner(_checkpoint.stateUpdate);
| address owner = getOwner(_checkpoint.stateUpdate);
| 1,686 |
71 | // In case of emgergency - withdrawal all eth.Contract must be offline/ | function EmergencyWithdrawalETH() isOffline public returns (bool){
require(!Online, "Contract is not turned off");
require(_deposits_eth[_msgSender()] > 0, "You have no deposits");
_payBackBrrrETH(_balances[_msgSender()], _msgSender(), _deposits_eth[_msgSender()]);
return true;
}
| function EmergencyWithdrawalETH() isOffline public returns (bool){
require(!Online, "Contract is not turned off");
require(_deposits_eth[_msgSender()] > 0, "You have no deposits");
_payBackBrrrETH(_balances[_msgSender()], _msgSender(), _deposits_eth[_msgSender()]);
return true;
}
| 31,864 |
26 | // Verify the task results signature | function verifyCommitSig(Task task, bytes data, bytes sig)
internal
returns (address)
| function verifyCommitSig(Task task, bytes data, bytes sig)
internal
returns (address)
| 7,533 |
26 | // Check whether the address is in the blocklist | function checkBlocklist(address add) public view returns(bool) {
return _blocklist[add];
}
| function checkBlocklist(address add) public view returns(bool) {
return _blocklist[add];
}
| 42,831 |
5 | // Treasury events | event TreasuryChange(address treasury);
event FeeChange(uint256 depositFee, uint256 withdrawFee, uint256 nftFee);
| event TreasuryChange(address treasury);
event FeeChange(uint256 depositFee, uint256 withdrawFee, uint256 nftFee);
| 21,155 |
4 | // harvest from masterChef harvest from masterChef token1 token1 deposited of LP token token2 token2 deposited LP token setId ID stores Pool ID data the metadata struct / | function harvest(
address token1,
address token2,
uint256 setId,
Metadata memory data
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
| function harvest(
address token1,
address token2,
uint256 setId,
Metadata memory data
)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
| 34,633 |
16 | // implementation for a TRIBE Reserve Stabilizer/Fei Protocol | contract TribeReserveStabilizer is ITribeReserveStabilizer, ReserveStabilizer, Timed {
using Decimal for Decimal.D256;
/// @notice a collateralization oracle
ICollateralizationOracle public override collateralizationOracle;
/// @notice the TRIBE minter address
ITribeMinter public immutable tribeMinter;
Decimal.D256 private _collateralizationThreshold;
/// @notice Tribe Reserve Stabilizer constructor
/// @param _core Fei Core to reference
/// @param _tribeOracle the TRIBE price oracle to reference
/// @param _backupOracle the backup oracle to reference
/// @param _usdPerFeiBasisPoints the USD price per FEI to sell TRIBE at
/// @param _collateralizationOracle the collateralization oracle to reference
/// @param _collateralizationThresholdBasisPoints the collateralization ratio below which the stabilizer becomes active. Reported in basis points (1/10000)
/// @param _tribeMinter the tribe minter contract
/// @param _osmDuration the amount of delay time before the TribeReserveStabilizer begins minting TRIBE
constructor(
address _core,
address _tribeOracle,
address _backupOracle,
uint256 _usdPerFeiBasisPoints,
ICollateralizationOracle _collateralizationOracle,
uint256 _collateralizationThresholdBasisPoints,
ITribeMinter _tribeMinter,
uint256 _osmDuration
)
ReserveStabilizer(_core, _tribeOracle, _backupOracle, IERC20(address(0)), _usdPerFeiBasisPoints)
Timed(_osmDuration)
{
collateralizationOracle = _collateralizationOracle;
emit CollateralizationOracleUpdate(address(0), address(_collateralizationOracle));
_collateralizationThreshold = Decimal.ratio(_collateralizationThresholdBasisPoints, Constants.BASIS_POINTS_GRANULARITY);
emit CollateralizationThresholdUpdate(0, _collateralizationThresholdBasisPoints);
// Setting token here because it isn't available until after CoreRef is constructed
// This does skip the _setDecimalsNormalizerFromToken call in ReserveStabilizer constructor, but it isn't needed because TRIBE is 18 decimals
token = tribe();
tribeMinter = _tribeMinter;
}
/// @notice exchange FEI for minted TRIBE
/// @dev the timer counts down from first time below threshold and opens after window
function exchangeFei(uint256 feiAmount) public override afterTime returns(uint256) {
require(isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio above threshold");
return super.exchangeFei(feiAmount);
}
/// @dev reverts. Held TRIBE should only be released by exchangeFei or mint
function withdraw(address, uint256) external pure override {
revert("TribeReserveStabilizer: can't withdraw TRIBE");
}
/// @notice check whether collateralization ratio is below the threshold set
/// @dev returns false if the oracle is invalid
function isCollateralizationBelowThreshold() public override view returns(bool) {
(Decimal.D256 memory ratio, bool valid) = collateralizationOracle.read();
return valid && ratio.lessThanOrEqualTo(_collateralizationThreshold);
}
/// @notice delay the opening of the TribeReserveStabilizer until oracle delay duration is met
function startOracleDelayCountdown() external override {
require(isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio above threshold");
require(!isTimeStarted(), "TribeReserveStabilizer: timer started");
_initTimed();
}
/// @notice reset the opening of the TribeReserveStabilizer oracle delay as soon as above CR target
function resetOracleDelayCountdown() external override {
require(!isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio under threshold");
require(isTimeStarted(), "TribeReserveStabilizer: timer started");
_pauseTimer();
}
/// @notice set the Collateralization oracle
function setCollateralizationOracle(ICollateralizationOracle newCollateralizationOracle) external override onlyGovernor {
require(address(newCollateralizationOracle) != address(0), "TribeReserveStabilizer: zero address");
address oldCollateralizationOracle = address(collateralizationOracle);
collateralizationOracle = newCollateralizationOracle;
emit CollateralizationOracleUpdate(oldCollateralizationOracle, address(newCollateralizationOracle));
}
/// @notice set the collateralization threshold below which exchanging becomes active
function setCollateralizationThreshold(uint256 newCollateralizationThresholdBasisPoints) external override onlyGovernor {
uint256 oldCollateralizationThresholdBasisPoints = _collateralizationThreshold.mul(Constants.BASIS_POINTS_GRANULARITY).asUint256();
_collateralizationThreshold = Decimal.ratio(newCollateralizationThresholdBasisPoints, Constants.BASIS_POINTS_GRANULARITY);
emit CollateralizationThresholdUpdate(oldCollateralizationThresholdBasisPoints, newCollateralizationThresholdBasisPoints);
}
/// @notice the collateralization threshold below which exchanging becomes active
function collateralizationThreshold() external view override returns(Decimal.D256 memory) {
return _collateralizationThreshold;
}
// Call out to TRIBE minter for transferring
function _transfer(address to, uint256 amount) internal override {
tribeMinter.mint(to, amount);
}
function _pauseTimer() internal {
// setting start time to 0 means isTimeStarted is false
startTime = 0;
emit TimerReset(0);
}
}
| contract TribeReserveStabilizer is ITribeReserveStabilizer, ReserveStabilizer, Timed {
using Decimal for Decimal.D256;
/// @notice a collateralization oracle
ICollateralizationOracle public override collateralizationOracle;
/// @notice the TRIBE minter address
ITribeMinter public immutable tribeMinter;
Decimal.D256 private _collateralizationThreshold;
/// @notice Tribe Reserve Stabilizer constructor
/// @param _core Fei Core to reference
/// @param _tribeOracle the TRIBE price oracle to reference
/// @param _backupOracle the backup oracle to reference
/// @param _usdPerFeiBasisPoints the USD price per FEI to sell TRIBE at
/// @param _collateralizationOracle the collateralization oracle to reference
/// @param _collateralizationThresholdBasisPoints the collateralization ratio below which the stabilizer becomes active. Reported in basis points (1/10000)
/// @param _tribeMinter the tribe minter contract
/// @param _osmDuration the amount of delay time before the TribeReserveStabilizer begins minting TRIBE
constructor(
address _core,
address _tribeOracle,
address _backupOracle,
uint256 _usdPerFeiBasisPoints,
ICollateralizationOracle _collateralizationOracle,
uint256 _collateralizationThresholdBasisPoints,
ITribeMinter _tribeMinter,
uint256 _osmDuration
)
ReserveStabilizer(_core, _tribeOracle, _backupOracle, IERC20(address(0)), _usdPerFeiBasisPoints)
Timed(_osmDuration)
{
collateralizationOracle = _collateralizationOracle;
emit CollateralizationOracleUpdate(address(0), address(_collateralizationOracle));
_collateralizationThreshold = Decimal.ratio(_collateralizationThresholdBasisPoints, Constants.BASIS_POINTS_GRANULARITY);
emit CollateralizationThresholdUpdate(0, _collateralizationThresholdBasisPoints);
// Setting token here because it isn't available until after CoreRef is constructed
// This does skip the _setDecimalsNormalizerFromToken call in ReserveStabilizer constructor, but it isn't needed because TRIBE is 18 decimals
token = tribe();
tribeMinter = _tribeMinter;
}
/// @notice exchange FEI for minted TRIBE
/// @dev the timer counts down from first time below threshold and opens after window
function exchangeFei(uint256 feiAmount) public override afterTime returns(uint256) {
require(isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio above threshold");
return super.exchangeFei(feiAmount);
}
/// @dev reverts. Held TRIBE should only be released by exchangeFei or mint
function withdraw(address, uint256) external pure override {
revert("TribeReserveStabilizer: can't withdraw TRIBE");
}
/// @notice check whether collateralization ratio is below the threshold set
/// @dev returns false if the oracle is invalid
function isCollateralizationBelowThreshold() public override view returns(bool) {
(Decimal.D256 memory ratio, bool valid) = collateralizationOracle.read();
return valid && ratio.lessThanOrEqualTo(_collateralizationThreshold);
}
/// @notice delay the opening of the TribeReserveStabilizer until oracle delay duration is met
function startOracleDelayCountdown() external override {
require(isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio above threshold");
require(!isTimeStarted(), "TribeReserveStabilizer: timer started");
_initTimed();
}
/// @notice reset the opening of the TribeReserveStabilizer oracle delay as soon as above CR target
function resetOracleDelayCountdown() external override {
require(!isCollateralizationBelowThreshold(), "TribeReserveStabilizer: Collateralization ratio under threshold");
require(isTimeStarted(), "TribeReserveStabilizer: timer started");
_pauseTimer();
}
/// @notice set the Collateralization oracle
function setCollateralizationOracle(ICollateralizationOracle newCollateralizationOracle) external override onlyGovernor {
require(address(newCollateralizationOracle) != address(0), "TribeReserveStabilizer: zero address");
address oldCollateralizationOracle = address(collateralizationOracle);
collateralizationOracle = newCollateralizationOracle;
emit CollateralizationOracleUpdate(oldCollateralizationOracle, address(newCollateralizationOracle));
}
/// @notice set the collateralization threshold below which exchanging becomes active
function setCollateralizationThreshold(uint256 newCollateralizationThresholdBasisPoints) external override onlyGovernor {
uint256 oldCollateralizationThresholdBasisPoints = _collateralizationThreshold.mul(Constants.BASIS_POINTS_GRANULARITY).asUint256();
_collateralizationThreshold = Decimal.ratio(newCollateralizationThresholdBasisPoints, Constants.BASIS_POINTS_GRANULARITY);
emit CollateralizationThresholdUpdate(oldCollateralizationThresholdBasisPoints, newCollateralizationThresholdBasisPoints);
}
/// @notice the collateralization threshold below which exchanging becomes active
function collateralizationThreshold() external view override returns(Decimal.D256 memory) {
return _collateralizationThreshold;
}
// Call out to TRIBE minter for transferring
function _transfer(address to, uint256 amount) internal override {
tribeMinter.mint(to, amount);
}
function _pauseTimer() internal {
// setting start time to 0 means isTimeStarted is false
startTime = 0;
emit TimerReset(0);
}
}
| 31,829 |
4 | // Function to add patient addresses to patients arrayRestricted to Owner within MVF scope/ | function addPatient(address patientAddress, address[] requestors, uint[2][] costpairs) public onlyOwner {
require(whitelists[patientAddress].patient == address(0x0));
patients.push(patientAddress);
whitelists[patientAddress] = Whitelist(patientAddress, requestors, costpairs);
| function addPatient(address patientAddress, address[] requestors, uint[2][] costpairs) public onlyOwner {
require(whitelists[patientAddress].patient == address(0x0));
patients.push(patientAddress);
whitelists[patientAddress] = Whitelist(patientAddress, requestors, costpairs);
| 10,225 |
0 | // 토큰 정보 | string constant public NAME = "EtherShip";
string constant public SYMBOL = "SHIP";
MersenneTwister32 internal mersenneTwister32;
| string constant public NAME = "EtherShip";
string constant public SYMBOL = "SHIP";
MersenneTwister32 internal mersenneTwister32;
| 11,212 |
18 | // De-whitelist TaskSpecs (A combination of a Condition, Action(s) and a gasPriceCeil) that users can select from/If gasPriceCeil was set to NO_CEIL, Input NO_CEIL constant as GasPriceCeil/_taskSpecs Task Receipt List defined in IGelatoCore | function unprovideTaskSpecs(TaskSpec[] calldata _taskSpecs) external;
| function unprovideTaskSpecs(TaskSpec[] calldata _taskSpecs) external;
| 11,623 |
1 | // require a function to be called through GSN only / | modifier trustedForwarderOnly() {
require(msg.sender == address(trustedForwarder), "Function can only be called through trustedForwarder");
_;
}
| modifier trustedForwarderOnly() {
require(msg.sender == address(trustedForwarder), "Function can only be called through trustedForwarder");
_;
}
| 25,717 |
62 | // make sure we capture all ETH that may or may not be sent to this contract | payable(walletaddress).transfer(address(this).balance);
| payable(walletaddress).transfer(address(this).balance);
| 44,783 |
121 | // now we have yUnderlying asset | uint256 yUnderlyingBalanceAfter = IERC20(yVault).balanceOf(address(this));
if (yUnderlyingBalanceAfter > yUnderlyingBalanceBefore) {
| uint256 yUnderlyingBalanceAfter = IERC20(yVault).balanceOf(address(this));
if (yUnderlyingBalanceAfter > yUnderlyingBalanceBefore) {
| 35,255 |
68 | // release block interval | uint256 private _releaseInterval = 585000;
| uint256 private _releaseInterval = 585000;
| 17,031 |
1 | // Construct defining an offer did Deed ID the offer is bound to toBePaid Nn amount to be paid back (borrowed + interest) lender Address of the lender to be the loan withdrawn from loan Consisting of another an `Asset` struct defined in the MultiToken library / | struct Offer {
uint256 did;
uint256 toBePaid;
address lender;
MultiToken.Asset loan;
}
| struct Offer {
uint256 did;
uint256 toBePaid;
address lender;
MultiToken.Asset loan;
}
| 7,684 |
570 | // Validate that the total service provider balance is between the min and max stakes _serviceProvider - address of service provider / | function validateAccountStakeBalance(address _serviceProvider)
external view
| function validateAccountStakeBalance(address _serviceProvider)
external view
| 26,116 |
5 | // stores the review submitted by an agent in the scores data structure/map scores data structure/reviewer index of the reviewer in the proposals set/reviewed index of the reviewed agent/evaluation score submitted by the reviewer | function setReview(ScoreMap storage map, uint reviewer, uint reviewed, uint evaluation) external {
set(map.reviewsTo[reviewer], reviewed, evaluation);
set(map.reviewsFrom[reviewed], reviewer, evaluation);
}
| function setReview(ScoreMap storage map, uint reviewer, uint reviewed, uint evaluation) external {
set(map.reviewsTo[reviewer], reviewed, evaluation);
set(map.reviewsFrom[reviewed], reviewer, evaluation);
}
| 47,992 |
18 | // requires to pick a winner or extends duration if not enough participants | require(TotalTickets<=minTickets,"A winner has to be picked first");
NextRaffle = NextRaffle.add((((now.sub(NextRaffle)).div(60)).add(1)).mul(60));
| require(TotalTickets<=minTickets,"A winner has to be picked first");
NextRaffle = NextRaffle.add((((now.sub(NextRaffle)).div(60)).add(1)).mul(60));
| 40,537 |
36 | // The contract used for airdrop campaign of ATT token / | contract Airdrop {
using SafeMath for uint256;
using SafeERC20 for ERC20;
// The token being sold
ERC20 public token;
address owner = 0x0;
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 public rate;
modifier isOwner {
assert(owner == msg.sender);
_;
}
/**
* Event for token drop logging
* @param sender who send the tokens
* @param beneficiary who got the tokens
* @param value weis sent
* @param amount amount of tokens dropped
*/
event TokenDropped(
address indexed sender,
address indexed beneficiary,
uint256 value,
uint256 amount
);
/**
* @param _token Address of the token being sold
*/
constructor(ERC20 _token) public
{
require(_token != address(0));
owner = msg.sender;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
sendAirDrops(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function sendAirDrops(address _beneficiary) public payable
{
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = 50 * (10 ** 6);
_processAirdrop(_beneficiary, tokens);
emit TokenDropped(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
}
function collect(uint256 _weiAmount) isOwner public {
address thisAddress = this;
owner.transfer(thisAddress.balance);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase( address _beneficiary, uint256 _weiAmount) internal
{
require(_beneficiary != address(0));
require(_weiAmount >= 1 * (10 ** 15));
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
token.safeTransfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processAirdrop(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
_deliverTokens(_beneficiary, _tokenAmount);
}
} | contract Airdrop {
using SafeMath for uint256;
using SafeERC20 for ERC20;
// The token being sold
ERC20 public token;
address owner = 0x0;
// How many token units a buyer gets per wei.
// The rate is the conversion between wei and the smallest and indivisible token unit.
// So, if you are using a rate of 1 with a DetailedERC20 token with 3 decimals called TOK
// 1 wei will give you 1 unit, or 0.001 TOK.
uint256 public rate;
modifier isOwner {
assert(owner == msg.sender);
_;
}
/**
* Event for token drop logging
* @param sender who send the tokens
* @param beneficiary who got the tokens
* @param value weis sent
* @param amount amount of tokens dropped
*/
event TokenDropped(
address indexed sender,
address indexed beneficiary,
uint256 value,
uint256 amount
);
/**
* @param _token Address of the token being sold
*/
constructor(ERC20 _token) public
{
require(_token != address(0));
owner = msg.sender;
token = _token;
}
// -----------------------------------------
// Crowdsale external interface
// -----------------------------------------
/**
* @dev fallback function ***DO NOT OVERRIDE***
*/
function () external payable {
sendAirDrops(msg.sender);
}
/**
* @dev low level token purchase ***DO NOT OVERRIDE***
* @param _beneficiary Address performing the token purchase
*/
function sendAirDrops(address _beneficiary) public payable
{
uint256 weiAmount = msg.value;
_preValidatePurchase(_beneficiary, weiAmount);
// calculate token amount to be created
uint256 tokens = 50 * (10 ** 6);
_processAirdrop(_beneficiary, tokens);
emit TokenDropped(
msg.sender,
_beneficiary,
weiAmount,
tokens
);
}
function collect(uint256 _weiAmount) isOwner public {
address thisAddress = this;
owner.transfer(thisAddress.balance);
}
// -----------------------------------------
// Internal interface (extensible)
// -----------------------------------------
/**
* @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met. Use super to concatenate validations.
* @param _beneficiary Address performing the token purchase
* @param _weiAmount Value in wei involved in the purchase
*/
function _preValidatePurchase( address _beneficiary, uint256 _weiAmount) internal
{
require(_beneficiary != address(0));
require(_weiAmount >= 1 * (10 ** 15));
}
/**
* @dev Source of tokens. Override this method to modify the way in which the crowdsale ultimately gets and sends its tokens.
* @param _beneficiary Address performing the token purchase
* @param _tokenAmount Number of tokens to be emitted
*/
function _deliverTokens(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
token.safeTransfer(_beneficiary, _tokenAmount);
}
/**
* @dev Executed when a purchase has been validated and is ready to be executed.
* @param _beneficiary Address receiving the tokens
* @param _tokenAmount Number of tokens to be purchased
*/
function _processAirdrop(
address _beneficiary,
uint256 _tokenAmount
)
internal
{
_deliverTokens(_beneficiary, _tokenAmount);
}
} | 8,050 |
4 | // | library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
| library SafeMath {
function mul(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a * b;
assert(a == 0 || c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal constant returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal constant returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
| 29,780 |
93 | // Calculate Dividend | calDividendPercentage = SafeMath.percent(incomingEthereum,dividendFeePercent,100,18);
| calDividendPercentage = SafeMath.percent(incomingEthereum,dividendFeePercent,100,18);
| 29,945 |
20 | // locked token structure / | struct lockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| struct lockToken {
uint256 amount;
uint256 validity;
bool claimed;
}
| 48,719 |
92 | // Events |
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event GuardianTransferred(address indexed previousGuardian, address indexed newGuardian);
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event GuardianTransferred(address indexed previousGuardian, address indexed newGuardian);
| 2,400 |
120 | // return 120-180 randomly / | function _randtimeBetweenLotteryDraw() private view returns(uint256) {
uint256 seed = _semiRandom();
return 120 + seed % 61;
}
| function _randtimeBetweenLotteryDraw() private view returns(uint256) {
uint256 seed = _semiRandom();
return 120 + seed % 61;
}
| 22,511 |
13 | // Bridges ERC20 to the remote chain/Locks an ERC20 on the source chain and sends LZ message to the remote chain to mint a wrapped token | function bridge(address token, uint amountLD, address to, LzLib.CallParams calldata callParams, bytes memory adapterParams) external payable nonReentrant {
require(supportedTokens[token], "OriginalTokenBridge: token is not supported");
// Supports tokens with transfer fee
uint balanceBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amountLD);
uint balanceAfter = IERC20(token).balanceOf(address(this));
(uint amountWithoutDustLD, uint dust) = _removeDust(token, balanceAfter - balanceBefore);
// return dust to the sender
if (dust > 0) {
IERC20(token).safeTransfer(msg.sender, dust);
}
_bridge(token, amountWithoutDustLD, to, msg.value, callParams, adapterParams);
}
| function bridge(address token, uint amountLD, address to, LzLib.CallParams calldata callParams, bytes memory adapterParams) external payable nonReentrant {
require(supportedTokens[token], "OriginalTokenBridge: token is not supported");
// Supports tokens with transfer fee
uint balanceBefore = IERC20(token).balanceOf(address(this));
IERC20(token).safeTransferFrom(msg.sender, address(this), amountLD);
uint balanceAfter = IERC20(token).balanceOf(address(this));
(uint amountWithoutDustLD, uint dust) = _removeDust(token, balanceAfter - balanceBefore);
// return dust to the sender
if (dust > 0) {
IERC20(token).safeTransfer(msg.sender, dust);
}
_bridge(token, amountWithoutDustLD, to, msg.value, callParams, adapterParams);
}
| 19,636 |
379 | // Overwrite service index | uint256 lastIndex = validServiceTypes.length - 1;
validServiceTypes[serviceIndex] = validServiceTypes[lastIndex];
validServiceTypes.length--;
| uint256 lastIndex = validServiceTypes.length - 1;
validServiceTypes[serviceIndex] = validServiceTypes[lastIndex];
validServiceTypes.length--;
| 25,994 |
53 | // Implementation of the ERC20Decimals. Extension of {ERC20} that adds decimals storage slot./ Sets the value of the `decimals`. This value is immutable, it can only beset once during construction. / | constructor(uint8 decimals_) {
_decimals = decimals_;
}
| constructor(uint8 decimals_) {
_decimals = decimals_;
}
| 41 |
25 | // Modifier that allows only the owner or guardian to call a function / | modifier onlyOwnerOrGuardian() {
if ((guardian == msg.sender || avatar == msg.sender || owner() == msg.sender) == false)
revert NOT_GUARDIAN(msg.sender);
_;
}
| modifier onlyOwnerOrGuardian() {
if ((guardian == msg.sender || avatar == msg.sender || owner() == msg.sender) == false)
revert NOT_GUARDIAN(msg.sender);
_;
}
| 38,311 |
13 | // Token transfer function Token amount should be in 18 decimals (eg. 1991018) | function transfer(address _to, uint256 _amount ) public {
require(balances[msg.sender] >= _amount && _amount >= 0);
balances[msg.sender] = sub(balances[msg.sender], _amount);
balances[_to] = add(balances[_to], _amount);
emit Transfer(msg.sender, _to, _amount);
}
| function transfer(address _to, uint256 _amount ) public {
require(balances[msg.sender] >= _amount && _amount >= 0);
balances[msg.sender] = sub(balances[msg.sender], _amount);
balances[_to] = add(balances[_to], _amount);
emit Transfer(msg.sender, _to, _amount);
}
| 41,381 |
6 | // reverts or returns data stored at "ptr" | switch result
| switch result
| 20,350 |
75 | // Approve SarcoDao - PurchaseExecutor's total USDC tokens (Execute Purchase) | USDC_TOKEN.approve(
_sarco_dao,
((_sarco_allocations_total * usdc_to_sarco_precision) /
_usdc_to_sarco_rate) / sarco_to_usdc_decimal_fix
);
| USDC_TOKEN.approve(
_sarco_dao,
((_sarco_allocations_total * usdc_to_sarco_precision) /
_usdc_to_sarco_rate) / sarco_to_usdc_decimal_fix
);
| 8,303 |
23 | // Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called./ | function allowance(address owner, address spender) external view returns (uint256);
| function allowance(address owner, address spender) external view returns (uint256);
| 36,598 |
17 | // sum up original payout amount (self.balance changes during payouts) | totalPayoutAmount += pots[j + numPots * round].amount;
| totalPayoutAmount += pots[j + numPots * round].amount;
| 11,426 |
5 | // e como um array[], so que ha situacoes que eu quero localizar algo pelo nome, endereco ou numero que eu "defina" o que muda e a forma que identifico o id entre parenteses eu defino o tipo de dado(string) tipo de dado que quero achar dentro(ofertante) tipo de dado a ser armanezado | Ofertante[] public ofertantes;
bool public encerrado;
| Ofertante[] public ofertantes;
bool public encerrado;
| 43,901 |
9 | // This is an alternative to {approve} that can be used as a mitigation forproblems described in {IBEP20-approve}. Emits an {Approval} event indicating the updated allowance. Requirements: - `spender` cannot be the zero address. / |
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
|
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
_approve(_msgSender(), spender, _allowances[_msgSender()][spender].add(addedValue));
return true;
}
| 26,065 |
0 | // Kongliang Zhong - <kongliang@loopring.org>/IFeeHolder - A contract holding fees. | contract IFeeHolder {
event TokenWithdrawn(
address owner,
address token,
uint value
);
// A map of all fee balances
mapping(address => mapping(address => uint)) public feeBalances;
/// @dev Allows withdrawing the tokens to be burned by
/// authorized contracts.
/// @param token The token to be used to burn buy and burn LRC
/// @param value The amount of tokens to withdraw
function withdrawBurned(
address token,
uint value
)
external
returns (bool success);
/// @dev Allows withdrawing the fee payments funds
/// @param token The token to withdraw
/// @param value The amount of tokens to withdraw
function withdrawToken(
address token,
uint value
)
external
returns (bool success);
function batchAddFeeBalances(
bytes32[] batch
)
external;
}
| contract IFeeHolder {
event TokenWithdrawn(
address owner,
address token,
uint value
);
// A map of all fee balances
mapping(address => mapping(address => uint)) public feeBalances;
/// @dev Allows withdrawing the tokens to be burned by
/// authorized contracts.
/// @param token The token to be used to burn buy and burn LRC
/// @param value The amount of tokens to withdraw
function withdrawBurned(
address token,
uint value
)
external
returns (bool success);
/// @dev Allows withdrawing the fee payments funds
/// @param token The token to withdraw
/// @param value The amount of tokens to withdraw
function withdrawToken(
address token,
uint value
)
external
returns (bool success);
function batchAddFeeBalances(
bytes32[] batch
)
external;
}
| 41,889 |
173 | // percentage of treasury to send to public goods address | uint256 public public_goods_perc;
| uint256 public public_goods_perc;
| 12,730 |
30 | // Update active collateral | epochStrikeData[epoch][strike].activeCollateral += requiredCollateral;
| epochStrikeData[epoch][strike].activeCollateral += requiredCollateral;
| 22,866 |
98 | // update fee growth global and, if necessary, protocol fees overflow is acceptable, protocol has to withdraw before it hits type(uint128).max fees | if (zeroForOne) {
feeGrowthGlobal0X128 = state.feeGrowthGlobalX128;
unchecked {
if (state.protocolFee > 0) protocolFees.token0 += state.protocolFee;
}
| if (zeroForOne) {
feeGrowthGlobal0X128 = state.feeGrowthGlobalX128;
unchecked {
if (state.protocolFee > 0) protocolFees.token0 += state.protocolFee;
}
| 4,275 |
4 | // structs can act like objects | struct MarketToken {
uint itemId;
address nftContract;
uint256 tokenId;
address payable seller;
address payable owner;
uint256 price;
bool sold;
uint256 power;
uint lvl;
uint lastClaim;
}
| struct MarketToken {
uint itemId;
address nftContract;
uint256 tokenId;
address payable seller;
address payable owner;
uint256 price;
bool sold;
uint256 power;
uint lvl;
uint lastClaim;
}
| 53,736 |
8 | // create mapping to access bbcount | mapping(uint => BBcount) public bbcount;
mapping(uint => sendLog) public sent;
mapping(uint => recdLog) public rec;
uint public donorCount;
uint public recptCount;
uint public bbcounter;
uint public scount;
uint public rcount;
| mapping(uint => BBcount) public bbcount;
mapping(uint => sendLog) public sent;
mapping(uint => recdLog) public rec;
uint public donorCount;
uint public recptCount;
uint public bbcounter;
uint public scount;
uint public rcount;
| 41,539 |
166 | // if we have xyz to sell, then sell some of it | uint256 _xyzBalance = xyz.balanceOf(address(this));
if (_xyzBalance > 0) {
| uint256 _xyzBalance = xyz.balanceOf(address(this));
if (_xyzBalance > 0) {
| 59,577 |
45 | // read-only offer. Modify an offer by directly accessing offers[id] | OfferInfo memory offer = offers[id];
delete offers[id];
require( offer.pay_gem.transfer(offer.owner, offer.pay_amt) );
LogItemUpdate(id);
LogKill(
bytes32(id),
keccak256(offer.pay_gem, offer.buy_gem),
offer.owner,
| OfferInfo memory offer = offers[id];
delete offers[id];
require( offer.pay_gem.transfer(offer.owner, offer.pay_amt) );
LogItemUpdate(id);
LogKill(
bytes32(id),
keccak256(offer.pay_gem, offer.buy_gem),
offer.owner,
| 16,643 |
12 | // LPChainlinkOracleV1/BoringCrypto/Oracle used for getting the price of an LP token based on an chainlink oracle with 18 decimals/Optimized version based on https:blog.alphafinance.io/fair-lp-token-pricing/ | contract LPChainlinkOracleV1 is IAggregator {
using BoringMath for uint256;
IUniswapV2Pair public immutable pair;
IAggregator public immutable tokenOracle;
constructor(IUniswapV2Pair pair_, IAggregator tokenOracle_) public {
pair = pair_;
tokenOracle = tokenOracle_;
}
// credit for this implementation goes to
// https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol
function sqrt(uint256 x) internal pure returns (uint128) {
if (x == 0) return 0;
uint256 xx = x;
uint256 r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r <<= 32;
}
if (xx >= 0x100000000) {
xx >>= 32;
r <<= 16;
}
if (xx >= 0x10000) {
xx >>= 16;
r <<= 8;
}
if (xx >= 0x100) {
xx >>= 8;
r <<= 4;
}
if (xx >= 0x10) {
xx >>= 4;
r <<= 2;
}
if (xx >= 0x8) {
r <<= 1;
}
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1; // Seven iterations should be enough
uint256 r1 = x / r;
return uint128(r < r1 ? r : r1);
}
// Calculates the lastest exchange rate
function latestAnswer() external view override returns (int256) {
(uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pair).getReserves();
uint256 totalSupply = pair.totalSupply();
uint256 k = reserve0.mul(reserve1);
uint256 value = sqrt((k / 1e18).mul(uint256(tokenOracle.latestAnswer())));
uint256 totalValue = value.mul(2);
return int256(totalValue.mul(1e18) / totalSupply);
}
}
| contract LPChainlinkOracleV1 is IAggregator {
using BoringMath for uint256;
IUniswapV2Pair public immutable pair;
IAggregator public immutable tokenOracle;
constructor(IUniswapV2Pair pair_, IAggregator tokenOracle_) public {
pair = pair_;
tokenOracle = tokenOracle_;
}
// credit for this implementation goes to
// https://github.com/abdk-consulting/abdk-libraries-solidity/blob/master/ABDKMath64x64.sol
function sqrt(uint256 x) internal pure returns (uint128) {
if (x == 0) return 0;
uint256 xx = x;
uint256 r = 1;
if (xx >= 0x100000000000000000000000000000000) {
xx >>= 128;
r <<= 64;
}
if (xx >= 0x10000000000000000) {
xx >>= 64;
r <<= 32;
}
if (xx >= 0x100000000) {
xx >>= 32;
r <<= 16;
}
if (xx >= 0x10000) {
xx >>= 16;
r <<= 8;
}
if (xx >= 0x100) {
xx >>= 8;
r <<= 4;
}
if (xx >= 0x10) {
xx >>= 4;
r <<= 2;
}
if (xx >= 0x8) {
r <<= 1;
}
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1;
r = (r + x / r) >> 1; // Seven iterations should be enough
uint256 r1 = x / r;
return uint128(r < r1 ? r : r1);
}
// Calculates the lastest exchange rate
function latestAnswer() external view override returns (int256) {
(uint256 reserve0, uint256 reserve1, ) = IUniswapV2Pair(pair).getReserves();
uint256 totalSupply = pair.totalSupply();
uint256 k = reserve0.mul(reserve1);
uint256 value = sqrt((k / 1e18).mul(uint256(tokenOracle.latestAnswer())));
uint256 totalValue = value.mul(2);
return int256(totalValue.mul(1e18) / totalSupply);
}
}
| 35,215 |
22 | // Support interfaces for Access Control and ERC721 | function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721A)
returns (bool)
| function supportsInterface(bytes4 interfaceId)
public
view
override(ERC721A)
returns (bool)
| 74,385 |
9 | // we get msg.sender's % of pool and then use that to convert to tokens | function withdraw(uint amountShares) external {
require(amountShares <= IERC20(address(this)).balanceOf(msg.sender), "no");
require(amountShares > 0, "cannot withdraw 0");
//then we pass this to the strategy contract to withdraw the correct % of LP tokens (I think??)
uint beforeBal = usdc.balanceOf(address(this));
deltaNeutral.close(msg.sender, amountShares);
uint afterBal = usdc.balanceOf(address(this));
_burn(msg.sender, amountShares);
//send back user their usdc
uint amountToWithdraw = afterBal - beforeBal;
usdc.transfer(msg.sender, amountToWithdraw);
}
| function withdraw(uint amountShares) external {
require(amountShares <= IERC20(address(this)).balanceOf(msg.sender), "no");
require(amountShares > 0, "cannot withdraw 0");
//then we pass this to the strategy contract to withdraw the correct % of LP tokens (I think??)
uint beforeBal = usdc.balanceOf(address(this));
deltaNeutral.close(msg.sender, amountShares);
uint afterBal = usdc.balanceOf(address(this));
_burn(msg.sender, amountShares);
//send back user their usdc
uint amountToWithdraw = afterBal - beforeBal;
usdc.transfer(msg.sender, amountToWithdraw);
}
| 38,902 |
148 | // Internal deposit logic to be implemented by Stratgies | function _deposit(uint256 _want) internal virtual;
| function _deposit(uint256 _want) internal virtual;
| 1,873 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.