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 |
|---|---|---|---|---|
248 | // only allow vault owner or vault operator to deposit collateral | require((_args.from == msg.sender) || (_args.from == _args.owner), "C20");
require(whitelist.isWhitelistedCollateral(_args.asset), "C21");
(, uint256 typeVault, ) = getVaultWithDetails(_args.owner, _args.vaultId);
if (typeVault == 1) {
nakedPoolBalance[_args.asset] = nakedPoolBalance[_args.asset].add(_args.amount);
require(nakedPoolBalance[_args.asset] <= nakedCap[_args.asset], "C37");
| require((_args.from == msg.sender) || (_args.from == _args.owner), "C20");
require(whitelist.isWhitelistedCollateral(_args.asset), "C21");
(, uint256 typeVault, ) = getVaultWithDetails(_args.owner, _args.vaultId);
if (typeVault == 1) {
nakedPoolBalance[_args.asset] = nakedPoolBalance[_args.asset].add(_args.amount);
require(nakedPoolBalance[_args.asset] <= nakedCap[_args.asset], "C37");
| 63,534 |
146 | // ConveyorMulticall/0xOsiris, 0xKitsune, Conveyor Labs/Optimized multicall execution contract. | contract ConveyorMulticall is GenericMulticall, UniswapV3Callback, UniswapV2Callback {
using SafeERC20 for IERC20;
address immutable CONVEYOR_SWAP_AGGREGATOR;
///@param conveyorRouterV1 Address of the ConveyorRouterV1 contract.
constructor(address conveyorRouterV1) {
CONVEYOR_SWAP_AGGREGATOR = conveyorRouterV1;
}
///@notice Executes a multicall.
///@param swapAggregatorMulticall Multicall to be executed.
///@param amountIn Amount of tokenIn to swap.
///@param recipient Recipient of the output tokens.
function executeMulticall(
ConveyorRouterV1.SwapAggregatorMulticall calldata swapAggregatorMulticall,
uint256 amountIn,
address payable recipient
) public {
///@notice Get the length of the calls array.
uint256 callsLength = swapAggregatorMulticall.calls.length;
///@notice Create a bytes array to store the calldata for v2 swaps.
bytes memory callData;
///@notice Cache the feeBitmap in memory.
uint128 feeBitmap = swapAggregatorMulticall.feeBitmap;
///@notice Iterate through the calls array.
for (uint256 i = 0; i < callsLength;) {
///@notice Get the call from the calls array.
ConveyorRouterV1.Call memory call = swapAggregatorMulticall.calls[i];
///@notice Get the zeroForOne value from the zeroForOneBitmap.
bool zeroForOne = deriveBoolFromBitmap(swapAggregatorMulticall.zeroForOneBitmap, i);
uint256 callType = deriveCallFromBitmap(swapAggregatorMulticall.callTypeBitmap, i);
///@notice Check if the call is a v2 swap.
if (callType == 0x0) {
///@notice Instantiate the receiver address for the v2 swap.
address receiver;
{
///@notice Get the toAddressBitPattern from the toAddressBitmap.
uint256 toAddressBitPattern = deriveToAddressFromBitmap(swapAggregatorMulticall.toAddressBitmap, i);
///@notice Set the receiver address based on the toAddressBitPattern.
if (toAddressBitPattern == 0x3) {
if (i == callsLength - 1) {
revert InvalidToAddressBits();
}
receiver = swapAggregatorMulticall.calls[i + 1].target;
} else if (toAddressBitPattern == 0x2) {
receiver = address(this);
} else if (toAddressBitPattern == 0x1) {
receiver = recipient;
} else {
receiver = CONVEYOR_SWAP_AGGREGATOR;
}
}
///@notice Construct the calldata for the v2 swap.
(callData, amountIn, feeBitmap) =
constructV2SwapCalldata(amountIn, zeroForOne, receiver, call.target, feeBitmap);
///@notice Execute the v2 swap.
(bool success,) = call.target.call(callData);
if (!success) {
revert V2SwapFailed();
}
} else if (callType == 0x1) {
///@notice Execute the v3 swap.
(bool success, bytes memory data) = call.target.call(call.callData);
if (!success) {
revert V3SwapFailed();
}
///@notice Decode the amountIn from the v3 swap.
(int256 amount0, int256 amount1) = abi.decode(data, (int256, int256));
amountIn = zeroForOne ? uint256(-amount1) : uint256(-amount0);
} else {
///@notice Execute generic call.
(bool success,) = call.target.call(call.callData);
if (!success) {
revert CallFailed();
}
}
unchecked {
++i;
}
}
}
///@notice Constructs the calldata for a v2 swap.
///@param amountIn - The amount of tokenIn to swap.
///@param zeroForOne - The direction of the swap.
///@param to - The address to send the swapped tokens to.
///@param pool - The address of the v2 liquidity pool.
///@param feeBitmap - The bitmap of fees to use for the swap.
///@return callData - The calldata for the v2 swap.
///@return amountOut - The amount of tokenOut received from the swap.
///@return updatedFeeBitmap - The updated feeBitmap.
function constructV2SwapCalldata(uint256 amountIn, bool zeroForOne, address to, address pool, uint128 feeBitmap)
internal
view
returns (bytes memory callData, uint256 amountOut, uint128 updatedFeeBitmap)
{
///@notice Get the reserves for the pool.
(uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pool).getReserves();
uint24 fee;
(fee, updatedFeeBitmap) = deriveFeeFromBitmap(feeBitmap);
///@notice Get the amountOut from the reserves.
amountOut = getAmountOut(amountIn, zeroForOne ? reserve0 : reserve1, zeroForOne ? reserve1 : reserve0, fee);
///@notice Encode the swap calldata.
callData = abi.encodeWithSignature(
"swap(uint256,uint256,address,bytes)",
zeroForOne ? 0 : amountOut,
zeroForOne ? amountOut : 0,
to,
new bytes(0)
);
}
//Note: In human readable format, this is read from right to left, with the right most binary digit being the first representation
//of tokenIsToken0 for the first pool in the route
///@notice Derives a boolean at a specific bit position from a bitmap.
///@param bitmap - The bitmap to derive the boolean from.
///@param position - The bit position.
function deriveBoolFromBitmap(uint64 bitmap, uint256 position) internal pure returns (bool) {
if ((2 ** position) & bitmap == 0) {
return false;
} else {
return true;
}
}
/// @notice Derives the call type from a bitmap.
/**
* @dev
* 0x0 - Uniswap v2 swap
* 0x1 - Uniswap v3 swap
* 0x2 - Generic call
*/
function deriveCallFromBitmap(uint40 bitmap, uint256 position) internal pure returns (uint256 callType) {
/// @solidity memory-safe-assembly
assembly {
let significantBits := shl(mul(position, 0x2), 0x3)
switch shr(mul(position, 0x2), and(bitmap, significantBits))
case 0x0 { callType := 0x0 }
case 0x1 { callType := 0x1 }
case 0x2 { callType := 0x2 }
}
}
//Note: In human readable format, this is read from right to left, with the right most binary digit being the first bit of the next fee to derive.
///@dev Each non standard fee is represented within exactly 10 bits (0-1024), if the fee is 300 then a single 0 bit is used.
///@notice Derives the fee from the feeBitmap.
///@param feeBitmap - The bitmap of fees to use for the swap.
///@return fee - The fee to use for the swap.
///@return updatedFeeBitmap - The updated feeBitmap.
function deriveFeeFromBitmap(uint128 feeBitmap) internal pure returns (uint24 fee, uint128 updatedFeeBitmap) {
/**
* @dev Retrieve the first 10 bits from the feeBitmap to get the fee, shift right to set the next
* fee in the first bit position.*
*/
fee = uint24(feeBitmap & 0x3FF);
updatedFeeBitmap = feeBitmap >> 10;
}
///@dev Bit Patterns: 01 => msg.sender, 10 => ConveyorSwapExecutor, 11 = next pool, 00 = ConveyorRouterV1
///@notice Derives the toAddress from the toAddressBitmap.
///@param toAddressBitmap - The bitmap of toAddresses to use for the swap.
///@param i - The index of the toAddress to derive.
///@return unsigned - 2 bit pattern representing the receiver of the current swap.
function deriveToAddressFromBitmap(uint128 toAddressBitmap, uint256 i) internal pure returns (uint256) {
if ((3 << (2 * i)) & toAddressBitmap == 3 << (2 * i)) {
return 0x3;
} else if ((2 << (2 * i)) & toAddressBitmap == 2 << (2 * i)) {
return 0x2;
} else if ((1 << (2 * i)) & toAddressBitmap == 1 << (2 * i)) {
return 0x1;
} else {
return 0x0;
}
}
///@notice Function to get the amountOut from a UniV2 lp.
///@param amountIn - AmountIn for the swap.
///@param reserveIn - tokenIn reserve for the swap.
///@param reserveOut - tokenOut reserve for the swap.
///@return amountOut - AmountOut from the given parameters.
function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut, uint24 fee)
internal
pure
returns (uint256 amountOut)
{
if (amountIn == 0) {
revert InsufficientInputAmount(0, 1);
}
if (reserveIn == 0) {
revert InsufficientLiquidity();
}
if (reserveOut == 0) {
revert InsufficientLiquidity();
}
/**
* Note: fee is specified in the callData as per the UniswapV2 variants specification.
* If this fee is not specified correctly the swap will likely fail, or yield unoptimal
* trade values.*
*/
uint256 amountInWithFee = amountIn * (100000 - fee);
uint256 numerator = amountInWithFee * reserveOut;
uint256 denominator = reserveIn * 100000 + (amountInWithFee);
amountOut = numerator / denominator;
}
}
| contract ConveyorMulticall is GenericMulticall, UniswapV3Callback, UniswapV2Callback {
using SafeERC20 for IERC20;
address immutable CONVEYOR_SWAP_AGGREGATOR;
///@param conveyorRouterV1 Address of the ConveyorRouterV1 contract.
constructor(address conveyorRouterV1) {
CONVEYOR_SWAP_AGGREGATOR = conveyorRouterV1;
}
///@notice Executes a multicall.
///@param swapAggregatorMulticall Multicall to be executed.
///@param amountIn Amount of tokenIn to swap.
///@param recipient Recipient of the output tokens.
function executeMulticall(
ConveyorRouterV1.SwapAggregatorMulticall calldata swapAggregatorMulticall,
uint256 amountIn,
address payable recipient
) public {
///@notice Get the length of the calls array.
uint256 callsLength = swapAggregatorMulticall.calls.length;
///@notice Create a bytes array to store the calldata for v2 swaps.
bytes memory callData;
///@notice Cache the feeBitmap in memory.
uint128 feeBitmap = swapAggregatorMulticall.feeBitmap;
///@notice Iterate through the calls array.
for (uint256 i = 0; i < callsLength;) {
///@notice Get the call from the calls array.
ConveyorRouterV1.Call memory call = swapAggregatorMulticall.calls[i];
///@notice Get the zeroForOne value from the zeroForOneBitmap.
bool zeroForOne = deriveBoolFromBitmap(swapAggregatorMulticall.zeroForOneBitmap, i);
uint256 callType = deriveCallFromBitmap(swapAggregatorMulticall.callTypeBitmap, i);
///@notice Check if the call is a v2 swap.
if (callType == 0x0) {
///@notice Instantiate the receiver address for the v2 swap.
address receiver;
{
///@notice Get the toAddressBitPattern from the toAddressBitmap.
uint256 toAddressBitPattern = deriveToAddressFromBitmap(swapAggregatorMulticall.toAddressBitmap, i);
///@notice Set the receiver address based on the toAddressBitPattern.
if (toAddressBitPattern == 0x3) {
if (i == callsLength - 1) {
revert InvalidToAddressBits();
}
receiver = swapAggregatorMulticall.calls[i + 1].target;
} else if (toAddressBitPattern == 0x2) {
receiver = address(this);
} else if (toAddressBitPattern == 0x1) {
receiver = recipient;
} else {
receiver = CONVEYOR_SWAP_AGGREGATOR;
}
}
///@notice Construct the calldata for the v2 swap.
(callData, amountIn, feeBitmap) =
constructV2SwapCalldata(amountIn, zeroForOne, receiver, call.target, feeBitmap);
///@notice Execute the v2 swap.
(bool success,) = call.target.call(callData);
if (!success) {
revert V2SwapFailed();
}
} else if (callType == 0x1) {
///@notice Execute the v3 swap.
(bool success, bytes memory data) = call.target.call(call.callData);
if (!success) {
revert V3SwapFailed();
}
///@notice Decode the amountIn from the v3 swap.
(int256 amount0, int256 amount1) = abi.decode(data, (int256, int256));
amountIn = zeroForOne ? uint256(-amount1) : uint256(-amount0);
} else {
///@notice Execute generic call.
(bool success,) = call.target.call(call.callData);
if (!success) {
revert CallFailed();
}
}
unchecked {
++i;
}
}
}
///@notice Constructs the calldata for a v2 swap.
///@param amountIn - The amount of tokenIn to swap.
///@param zeroForOne - The direction of the swap.
///@param to - The address to send the swapped tokens to.
///@param pool - The address of the v2 liquidity pool.
///@param feeBitmap - The bitmap of fees to use for the swap.
///@return callData - The calldata for the v2 swap.
///@return amountOut - The amount of tokenOut received from the swap.
///@return updatedFeeBitmap - The updated feeBitmap.
function constructV2SwapCalldata(uint256 amountIn, bool zeroForOne, address to, address pool, uint128 feeBitmap)
internal
view
returns (bytes memory callData, uint256 amountOut, uint128 updatedFeeBitmap)
{
///@notice Get the reserves for the pool.
(uint256 reserve0, uint256 reserve1,) = IUniswapV2Pair(pool).getReserves();
uint24 fee;
(fee, updatedFeeBitmap) = deriveFeeFromBitmap(feeBitmap);
///@notice Get the amountOut from the reserves.
amountOut = getAmountOut(amountIn, zeroForOne ? reserve0 : reserve1, zeroForOne ? reserve1 : reserve0, fee);
///@notice Encode the swap calldata.
callData = abi.encodeWithSignature(
"swap(uint256,uint256,address,bytes)",
zeroForOne ? 0 : amountOut,
zeroForOne ? amountOut : 0,
to,
new bytes(0)
);
}
//Note: In human readable format, this is read from right to left, with the right most binary digit being the first representation
//of tokenIsToken0 for the first pool in the route
///@notice Derives a boolean at a specific bit position from a bitmap.
///@param bitmap - The bitmap to derive the boolean from.
///@param position - The bit position.
function deriveBoolFromBitmap(uint64 bitmap, uint256 position) internal pure returns (bool) {
if ((2 ** position) & bitmap == 0) {
return false;
} else {
return true;
}
}
/// @notice Derives the call type from a bitmap.
/**
* @dev
* 0x0 - Uniswap v2 swap
* 0x1 - Uniswap v3 swap
* 0x2 - Generic call
*/
function deriveCallFromBitmap(uint40 bitmap, uint256 position) internal pure returns (uint256 callType) {
/// @solidity memory-safe-assembly
assembly {
let significantBits := shl(mul(position, 0x2), 0x3)
switch shr(mul(position, 0x2), and(bitmap, significantBits))
case 0x0 { callType := 0x0 }
case 0x1 { callType := 0x1 }
case 0x2 { callType := 0x2 }
}
}
//Note: In human readable format, this is read from right to left, with the right most binary digit being the first bit of the next fee to derive.
///@dev Each non standard fee is represented within exactly 10 bits (0-1024), if the fee is 300 then a single 0 bit is used.
///@notice Derives the fee from the feeBitmap.
///@param feeBitmap - The bitmap of fees to use for the swap.
///@return fee - The fee to use for the swap.
///@return updatedFeeBitmap - The updated feeBitmap.
function deriveFeeFromBitmap(uint128 feeBitmap) internal pure returns (uint24 fee, uint128 updatedFeeBitmap) {
/**
* @dev Retrieve the first 10 bits from the feeBitmap to get the fee, shift right to set the next
* fee in the first bit position.*
*/
fee = uint24(feeBitmap & 0x3FF);
updatedFeeBitmap = feeBitmap >> 10;
}
///@dev Bit Patterns: 01 => msg.sender, 10 => ConveyorSwapExecutor, 11 = next pool, 00 = ConveyorRouterV1
///@notice Derives the toAddress from the toAddressBitmap.
///@param toAddressBitmap - The bitmap of toAddresses to use for the swap.
///@param i - The index of the toAddress to derive.
///@return unsigned - 2 bit pattern representing the receiver of the current swap.
function deriveToAddressFromBitmap(uint128 toAddressBitmap, uint256 i) internal pure returns (uint256) {
if ((3 << (2 * i)) & toAddressBitmap == 3 << (2 * i)) {
return 0x3;
} else if ((2 << (2 * i)) & toAddressBitmap == 2 << (2 * i)) {
return 0x2;
} else if ((1 << (2 * i)) & toAddressBitmap == 1 << (2 * i)) {
return 0x1;
} else {
return 0x0;
}
}
///@notice Function to get the amountOut from a UniV2 lp.
///@param amountIn - AmountIn for the swap.
///@param reserveIn - tokenIn reserve for the swap.
///@param reserveOut - tokenOut reserve for the swap.
///@return amountOut - AmountOut from the given parameters.
function getAmountOut(uint256 amountIn, uint256 reserveIn, uint256 reserveOut, uint24 fee)
internal
pure
returns (uint256 amountOut)
{
if (amountIn == 0) {
revert InsufficientInputAmount(0, 1);
}
if (reserveIn == 0) {
revert InsufficientLiquidity();
}
if (reserveOut == 0) {
revert InsufficientLiquidity();
}
/**
* Note: fee is specified in the callData as per the UniswapV2 variants specification.
* If this fee is not specified correctly the swap will likely fail, or yield unoptimal
* trade values.*
*/
uint256 amountInWithFee = amountIn * (100000 - fee);
uint256 numerator = amountInWithFee * reserveOut;
uint256 denominator = reserveIn * 100000 + (amountInWithFee);
amountOut = numerator / denominator;
}
}
| 7,497 |
15 | // Obtain Art status for Token | function getArtStatus(uint256 _tokenid) public view returns (uint256) {
uint256 temp;
temp = artenabled[_tokenid];
return temp;
}
| function getArtStatus(uint256 _tokenid) public view returns (uint256) {
uint256 temp;
temp = artenabled[_tokenid];
return temp;
}
| 10,685 |
135 | // Returns the amount contributed so far by a specific beneficiary. beneficiary Address of contributorreturn Beneficiary contribution so far / | function getContribution(address beneficiary)
public
view
returns (uint256)
| function getContribution(address beneficiary)
public
view
returns (uint256)
| 24,471 |
71 | // return The result of safely dividing x and y. The return value is a highprecision decimal.y is divided after the product of x and the standard precision unitis evaluated, so the product of x and UNIT must be less than 2256. Asthis is an integer division, the result is always rounded down.This helps save on gas. Rounding is more expensive on gas. / | function divideDecimal(uint x, uint y) internal pure returns (uint) {
/* Reintroduce the UNIT factor that will be divided out by y. */
return x.mul(UNIT).div(y);
}
| function divideDecimal(uint x, uint y) internal pure returns (uint) {
/* Reintroduce the UNIT factor that will be divided out by y. */
return x.mul(UNIT).div(y);
}
| 10,011 |
30 | // All actions are allowed by default | LimitedToken memory _tokenIn = LimitedToken(ActionLib.allActions(), tokenIn);
return swapQuoter.getAmountOut(_tokenIn, tokenOut, amountIn);
| LimitedToken memory _tokenIn = LimitedToken(ActionLib.allActions(), tokenIn);
return swapQuoter.getAmountOut(_tokenIn, tokenOut, amountIn);
| 16,590 |
149 | // Sets `amount` as the allowance of `spender` over the `owner`s tokens./ | /// @dev Emits an {Approval} event.
///
/// This is internal function is equivalent to `approve`, and can be used to e.g. set automatic
/// allowances for certain subsystems, etc.
///
/// Requirements:
///
/// - `owner` cannot be the zero address.
/// - `spender` cannot be the zero address.
function approveInternal(
address owner,
address spender,
uint256 amount
) internal virtual {
if (owner == address(0)) {
revert Erc20__ApproveOwnerZeroAddress();
}
if (spender == address(0)) {
revert Erc20__ApproveSpenderZeroAddress();
}
allowance[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| /// @dev Emits an {Approval} event.
///
/// This is internal function is equivalent to `approve`, and can be used to e.g. set automatic
/// allowances for certain subsystems, etc.
///
/// Requirements:
///
/// - `owner` cannot be the zero address.
/// - `spender` cannot be the zero address.
function approveInternal(
address owner,
address spender,
uint256 amount
) internal virtual {
if (owner == address(0)) {
revert Erc20__ApproveOwnerZeroAddress();
}
if (spender == address(0)) {
revert Erc20__ApproveSpenderZeroAddress();
}
allowance[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
| 71,285 |
284 | // solhint-disable-next-line avoid-low-level-calls | (bool success, ) = payable(msg.sender).call{
gas: 2300,
value: address(this).balance
}("");
| (bool success, ) = payable(msg.sender).call{
gas: 2300,
value: address(this).balance
}("");
| 23,606 |
75 | // freeze account | selfFreeze(true, 24 * 3600);
maxAllowedAmount[_from] = 0;
return isTransfer;
| selfFreeze(true, 24 * 3600);
maxAllowedAmount[_from] = 0;
return isTransfer;
| 25,345 |
14 | // Training partition size | uint16 constant training_data_group_size = 400;
| uint16 constant training_data_group_size = 400;
| 53,437 |
32 | // decode current field number and wiretype | function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {
uint256 v = decVarint(buf);
tag = v / 8;
wiretype = WireType(v & 7);
}
| function decKey(Buffer memory buf) internal pure returns (uint256 tag, WireType wiretype) {
uint256 v = decVarint(buf);
tag = v / 8;
wiretype = WireType(v & 7);
}
| 11,912 |
127 | // Ensure individual and global consistency when decrementing collateral balances. Returns the change to the position. This function is similar to the _decrementCollateralBalances function except this function checks position GCR between the decrements. This ensures that collateral removal will not leave the position undercollateralized. | function _decrementCollateralBalancesCheckGCR(
PositionData storage positionData,
FixedPoint.Unsigned memory collateralAmount
| function _decrementCollateralBalancesCheckGCR(
PositionData storage positionData,
FixedPoint.Unsigned memory collateralAmount
| 30,058 |
83 | // If no xFat exists, mint it 1:1 to the amount put in | if (totalShares == 0 || totalFat == 0) {
_mint(msg.sender, _amount);
}
| if (totalShares == 0 || totalFat == 0) {
_mint(msg.sender, _amount);
}
| 20,918 |
58 | // Get the message to be signed in case of delegated transfer/approvals methodHash The method hash for which delegate action in to be performed token The unique token for each delegated function networkFee The fee that will be paid to relayer for gas fee he spends to The recipient or spender amount The amount to be approvedreturn Bool value / | function getProofApproval(bytes4 methodHash, bytes32 token, uint256 networkFee, address broadcaster, address to, uint256 amount)
public
view
returns (bytes32)
| function getProofApproval(bytes4 methodHash, bytes32 token, uint256 networkFee, address broadcaster, address to, uint256 amount)
public
view
returns (bytes32)
| 35,213 |
172 | // No previous checkpoint data - add current balance against checkpoint | if (_checkpoints.length == 0) {
_checkpoints.push(
Checkpoint({
checkpointId: currentCheckpointId,
value: _newValue
})
| if (_checkpoints.length == 0) {
_checkpoints.push(
Checkpoint({
checkpointId: currentCheckpointId,
value: _newValue
})
| 48,356 |
60 | // Template contract to use for new minion proxies | address payable public immutable safeMinionSingleton;
| address payable public immutable safeMinionSingleton;
| 16,660 |
15 | // Uniswap v3 pool interface | interface IUniV3_POOL {
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
}
| interface IUniV3_POOL {
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
}
| 25,675 |
4 | // Layer 0 info // Tx Info /uint16 _chainID, | uint256 _nonce,
| uint256 _nonce,
| 26,262 |
71 | // Set the leftover amount to the initial amount. | leftoverAmount = _amount;
| leftoverAmount = _amount;
| 9,454 |
24 | // Assign the created voter object to the array of voters | voters[_email] = Voter(votrSize, Library.bytes32ToStr(_email), false);
| voters[_email] = Voter(votrSize, Library.bytes32ToStr(_email), false);
| 1,642 |
2 | // Throw if called by any account other than the owner. / | modifier onlyOwner() {
require(_owner == msg.sender, "caller is not the owner");
_;
}
| modifier onlyOwner() {
require(_owner == msg.sender, "caller is not the owner");
_;
}
| 9,672 |
3 | // Event emitted when bank owner give credit for user. | event newApproveCredit(uint64 indexed id);
| event newApproveCredit(uint64 indexed id);
| 19,320 |
17 | // Return current balance of token0 (tender) in the poolreturn token0Balance current balance of the pooled tendertoken / | function getToken0Balance() external view returns (uint256 token0Balance);
| function getToken0Balance() external view returns (uint256 token0Balance);
| 29,052 |
119 | // Getter function for requestId based on timestamp_timestamp to check requestId return uint of requestId/ | function getRequestIdByTimestamp(TellorStorage.TellorStorageStruct storage self, uint256 _timestamp) internal view returns (uint256) {
return self.requestIdByTimestamp[_timestamp];
}
| function getRequestIdByTimestamp(TellorStorage.TellorStorageStruct storage self, uint256 _timestamp) internal view returns (uint256) {
return self.requestIdByTimestamp[_timestamp];
}
| 31,850 |
52 | // update dividends tracker | int256 _updatedPayouts = (int256) (tokenLedger[contractAddress].dividend * _collates + (_taxedToken * magnitude));
balanceLedger[_customerAddress][contractAddress].payOut -= _updatedPayouts;
| int256 _updatedPayouts = (int256) (tokenLedger[contractAddress].dividend * _collates + (_taxedToken * magnitude));
balanceLedger[_customerAddress][contractAddress].payOut -= _updatedPayouts;
| 11,873 |
10 | // calculates the next token ID based on value of _currentTokenIdreturn uint256 for the next token ID / | function _getNextTokenId(uint256 collection) private returns (uint256) {
Series storage coll = collections[collection];
uint pointer = coll.current++;
require(pointer < coll.supply, "No tokens available");
uint256 reply = coll.start + pointer;
return reply;
}
| function _getNextTokenId(uint256 collection) private returns (uint256) {
Series storage coll = collections[collection];
uint pointer = coll.current++;
require(pointer < coll.supply, "No tokens available");
uint256 reply = coll.start + pointer;
return reply;
}
| 4,087 |
36 | // Checks the amount of tokens left in the allowance.return Amount of tokens left in the allowance / | function remainingTokens() public view returns (uint256) {
return token.allowance(tokenWallet, this);
}
| function remainingTokens() public view returns (uint256) {
return token.allowance(tokenWallet, this);
}
| 40,535 |
14 | // Differentiate between sending to address(0) and creating a contract | if (_isCreation && _to != address(0)) {
revert NonZeroCreationTarget();
}
| if (_isCreation && _to != address(0)) {
revert NonZeroCreationTarget();
}
| 45,762 |
57 | // Allow contributions to this crowdfunding. | function invest() public payable stopInEmergency {
require(getState() == State.Funding);
require(msg.value > 0);
uint weiAmount = msg.value;
address investor = msg.sender;
if(investedAmountOf[investor] == 0) {
// A new investor
investorCount++;
}
uint multiplier = 10 ** decimals;
uint tokensAmount = (weiAmount * multiplier) / tokenPrice;
assert(tokensAmount > 0);
if(getCurrentMilestone().bonus > 0) {
tokensAmount += (tokensAmount * getCurrentMilestone().bonus) / 100;
}
assert(tokensForSale - tokensAmount >= 0);
tokensForSale -= tokensAmount;
investments.push(Investment(investor, tokensAmount));
investmentsCount++;
tokenAmountOf[investor] += tokensAmount;
// calculate online fee
uint onlineFeeAmount = (weiAmount * ETHERFUNDME_ONLINE_FEE) / 100;
Withdraw(feeReceiverWallet, onlineFeeAmount);
// send online fee
feeReceiverWallet.transfer(onlineFeeAmount);
uint investedAmount = weiAmount - onlineFeeAmount;
// Update investor
investedAmountOf[investor] += investedAmount;
// Tell us invest was success
Invested(investor, investedAmount);
}
| function invest() public payable stopInEmergency {
require(getState() == State.Funding);
require(msg.value > 0);
uint weiAmount = msg.value;
address investor = msg.sender;
if(investedAmountOf[investor] == 0) {
// A new investor
investorCount++;
}
uint multiplier = 10 ** decimals;
uint tokensAmount = (weiAmount * multiplier) / tokenPrice;
assert(tokensAmount > 0);
if(getCurrentMilestone().bonus > 0) {
tokensAmount += (tokensAmount * getCurrentMilestone().bonus) / 100;
}
assert(tokensForSale - tokensAmount >= 0);
tokensForSale -= tokensAmount;
investments.push(Investment(investor, tokensAmount));
investmentsCount++;
tokenAmountOf[investor] += tokensAmount;
// calculate online fee
uint onlineFeeAmount = (weiAmount * ETHERFUNDME_ONLINE_FEE) / 100;
Withdraw(feeReceiverWallet, onlineFeeAmount);
// send online fee
feeReceiverWallet.transfer(onlineFeeAmount);
uint investedAmount = weiAmount - onlineFeeAmount;
// Update investor
investedAmountOf[investor] += investedAmount;
// Tell us invest was success
Invested(investor, investedAmount);
}
| 50,340 |
19 | // find parent user whose level is toLevel for limited loop i | uint i = 0;
address parent = me;
bool found = false;
while(i++ < maxLoopTimes) {
parent = userTree[parent];
| uint i = 0;
address parent = me;
bool found = false;
while(i++ < maxLoopTimes) {
parent = userTree[parent];
| 12,348 |
11 | // SmartAccount -> TypeID | mapping(address => uint256) SmartAccountType;
mapping(uint256 => address) accountIDtoAddress;
event AddNewAccountType(uint256 accountTypeID, address acountProxyAddress);
event UpdateAccountType(uint256 accountTypeID, address acountProxyAddress);
event CreateAccount(address EOA, address account, uint256 accountTypeID);
| mapping(address => uint256) SmartAccountType;
mapping(uint256 => address) accountIDtoAddress;
event AddNewAccountType(uint256 accountTypeID, address acountProxyAddress);
event UpdateAccountType(uint256 accountTypeID, address acountProxyAddress);
event CreateAccount(address EOA, address account, uint256 accountTypeID);
| 7,177 |
6 | // The ERC721 Receiver interface | interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
| interface IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
| 43,574 |
4 | // cast address to payable | address payable addr = payable(address(recipient));
selfdestruct(addr);
| address payable addr = payable(address(recipient));
selfdestruct(addr);
| 8,904 |
12 | // Library for Math operations | library Math {
function safeToAdd(uint a, uint b)
public
pure
returns (bool)
{
return a + b >= a;
}
function safeToSub(uint a, uint b)
public
pure
returns (bool)
{
return a >= b;
}
function safeToMul(uint a, uint b)
public
pure
returns (bool)
{
return b == 0 || a * b / b == a;
}
function add(uint a, uint b)
public
pure
returns (uint)
{
require(safeToAdd(a, b));
return a + b;
}
function sub(uint a, uint b)
public
pure
returns (uint)
{
require(safeToSub(a, b));
return a - b;
}
function mul(uint a, uint b)
public
pure
returns (uint)
{
require(safeToMul(a, b));
return a * b;
}
function safeToAdd(int a, int b)
public
pure
returns (bool)
{
return (b >= 0 && a + b >= a) || (b < 0 && a + b < a);
}
function safeToSub(int a, int b)
public
pure
returns (bool)
{
return (b >= 0 && a - b <= a) || (b < 0 && a - b > a);
}
function safeToMul(int a, int b)
public
pure
returns (bool)
{
return (b == 0) || (a * b / b == a);
}
function add(int a, int b)
public
pure
returns (int)
{
require(safeToAdd(a, b));
return a + b;
}
function sub(int a, int b)
public
pure
returns (int)
{
require(safeToSub(a, b));
return a - b;
}
function mul(int a, int b)
public
pure
returns (int)
{
require(safeToMul(a, b));
return a * b;
}
}
| library Math {
function safeToAdd(uint a, uint b)
public
pure
returns (bool)
{
return a + b >= a;
}
function safeToSub(uint a, uint b)
public
pure
returns (bool)
{
return a >= b;
}
function safeToMul(uint a, uint b)
public
pure
returns (bool)
{
return b == 0 || a * b / b == a;
}
function add(uint a, uint b)
public
pure
returns (uint)
{
require(safeToAdd(a, b));
return a + b;
}
function sub(uint a, uint b)
public
pure
returns (uint)
{
require(safeToSub(a, b));
return a - b;
}
function mul(uint a, uint b)
public
pure
returns (uint)
{
require(safeToMul(a, b));
return a * b;
}
function safeToAdd(int a, int b)
public
pure
returns (bool)
{
return (b >= 0 && a + b >= a) || (b < 0 && a + b < a);
}
function safeToSub(int a, int b)
public
pure
returns (bool)
{
return (b >= 0 && a - b <= a) || (b < 0 && a - b > a);
}
function safeToMul(int a, int b)
public
pure
returns (bool)
{
return (b == 0) || (a * b / b == a);
}
function add(int a, int b)
public
pure
returns (int)
{
require(safeToAdd(a, b));
return a + b;
}
function sub(int a, int b)
public
pure
returns (int)
{
require(safeToSub(a, b));
return a - b;
}
function mul(int a, int b)
public
pure
returns (int)
{
require(safeToMul(a, b));
return a * b;
}
}
| 2,614 |
9 | // Decimals & precision | uint256 constant MILLION = 10 ** 6;
uint256 constant RAY = 10 ** 27;
uint256 constant RAD = 10 ** 45;
| uint256 constant MILLION = 10 ** 6;
uint256 constant RAY = 10 ** 27;
uint256 constant RAD = 10 ** 45;
| 11,718 |
106 | // cap debt to liquidate | uint256 amountToLiquidate = liquidationAmount < _debtToCover ? liquidationAmount : _debtToCover;
| uint256 amountToLiquidate = liquidationAmount < _debtToCover ? liquidationAmount : _debtToCover;
| 20,752 |
509 | // retrieve the size of the code at address `addr` | size := extcodesize(addr)
| size := extcodesize(addr)
| 11,462 |
5 | // This contract is vulnerable to having its funds stolen. Written for ECEN 4133 at the University of Colorado Boulder: https:ecen4133.org/ (Adapted from ECEN 5033 w19) Happy hacking, and play nice! :) | contract Vuln {
mapping(address => uint256) public balances;
function deposit() public payable {
// Increment their balance with whatever they pay
balances[msg.sender] += msg.value;
}
function withdraw() public {
// Refund their balance
msg.sender.call.value(balances[msg.sender])("");
// Set their balance to 0
balances[msg.sender] = 0;
}
} | contract Vuln {
mapping(address => uint256) public balances;
function deposit() public payable {
// Increment their balance with whatever they pay
balances[msg.sender] += msg.value;
}
function withdraw() public {
// Refund their balance
msg.sender.call.value(balances[msg.sender])("");
// Set their balance to 0
balances[msg.sender] = 0;
}
} | 22,095 |
242 | // Decodes the first pool in path/path The bytes encoded swap path/ return tokenA The first token of the given pool/ return tokenB The second token of the given pool/ return fee The fee level of the pool | function decodeFirstPool(bytes memory path)
internal
pure
returns (
address tokenA,
address tokenB,
uint24 fee
)
| function decodeFirstPool(bytes memory path)
internal
pure
returns (
address tokenA,
address tokenB,
uint24 fee
)
| 27,030 |
257 | // Get the referrer address that referred the user | function getReferrer(address _user) public view override returns (address) {
return referrers[_user];
}
| function getReferrer(address _user) public view override returns (address) {
return referrers[_user];
}
| 33,449 |
356 | // Used to mark the smart contract as upgraded when an upgrade happens._v2Address Upgraded version of the core contract. / | function setNewAddress(address _v2Address) external onlyCEO whenPaused {
// We'll announce if the upgrade is needed.
newContractAddress = _v2Address;
emit ContractUpgrade(_v2Address);
}
| function setNewAddress(address _v2Address) external onlyCEO whenPaused {
// We'll announce if the upgrade is needed.
newContractAddress = _v2Address;
emit ContractUpgrade(_v2Address);
}
| 17,459 |
33 | // Returns the number of decimals used for token display.return The number of decimals. / | function decimals() public view virtual override returns (uint8) {
return _decimals;
}
| function decimals() public view virtual override returns (uint8) {
return _decimals;
}
| 24,169 |
206 | // redeem lending profit from anXSushi to xSushi | _redeemUnderlying(lendingProfit());
| _redeemUnderlying(lendingProfit());
| 3,548 |
0 | // SPDX-License-Identifier: Unlicensed | contract timelock {
} | contract timelock {
} | 31,044 |
194 | // Returns a token ID owned by `owner` at a given `index` of its token list. | * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
| * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
| 368 |
19 | // new "memory end" including padding | mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
| mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
| 7,946 |
4 | // others | bool public isSalePaused = false;
| bool public isSalePaused = false;
| 41,214 |
595 | // Calculates derivative hash and gets margin/_derivative Derivative/ return margins uint256[2] left and right margin/ return derivativeHash bytes32 Hash of the derivative | function _calculateDerivativeAndGetMargin(Derivative memory _derivative) private returns (uint256[2] memory margins, bytes32 derivativeHash) {
// Calculate derivative related data for validation
derivativeHash = getDerivativeHash(_derivative);
// Get cached total margin required according to logic
// margins[0] - leftMargin
// margins[1] - rightMargin
(margins[0], margins[1]) = SyntheticAggregator(registry.getSyntheticAggregator()).getMargin(derivativeHash, _derivative);
// Check if it's not pool
require(!SyntheticAggregator(registry.getSyntheticAggregator()).isPool(derivativeHash, _derivative), "MATCH:CANT_BE_POOL");
}
| function _calculateDerivativeAndGetMargin(Derivative memory _derivative) private returns (uint256[2] memory margins, bytes32 derivativeHash) {
// Calculate derivative related data for validation
derivativeHash = getDerivativeHash(_derivative);
// Get cached total margin required according to logic
// margins[0] - leftMargin
// margins[1] - rightMargin
(margins[0], margins[1]) = SyntheticAggregator(registry.getSyntheticAggregator()).getMargin(derivativeHash, _derivative);
// Check if it's not pool
require(!SyntheticAggregator(registry.getSyntheticAggregator()).isPool(derivativeHash, _derivative), "MATCH:CANT_BE_POOL");
}
| 34,560 |
356 | // Gets the current votes balance for `account` / | function getVotes(address account) public view virtual override returns (uint256) {
uint256 pos = _checkpoints[account].length;
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
}
| function getVotes(address account) public view virtual override returns (uint256) {
uint256 pos = _checkpoints[account].length;
return pos == 0 ? 0 : _checkpoints[account][pos - 1].votes;
}
| 32,201 |
15 | // minter The address for which the minting allowance has been changed./newAllowance The new minting allowance for the address (does not include fees). | event MintingAllowanceChanged(address indexed minter, uint256 newAllowance);
| event MintingAllowanceChanged(address indexed minter, uint256 newAllowance);
| 19,510 |
4 | // Gets all the function selectors supported by a specific facet./_facet The facet address./ return facetFunctionSelectors_ | function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
| function facetFunctionSelectors(address _facet) external view returns (bytes4[] memory facetFunctionSelectors_);
| 12,382 |
5 | // written when we get funded | bytes8 utxoSizeBytes; // LE uint. the size of the deposit UTXO in satoshis
uint256 fundedAt; // timestamp when funding proof was received
bytes utxoOutpoint; // the 36-byte outpoint of the custodied UTXO
| bytes8 utxoSizeBytes; // LE uint. the size of the deposit UTXO in satoshis
uint256 fundedAt; // timestamp when funding proof was received
bytes utxoOutpoint; // the 36-byte outpoint of the custodied UTXO
| 48,865 |
47 | // Stake tokens for TRU rewards.Also claims any existing rewards. amount Amount of tokens to stake / | function stake(uint256 amount) external override update {
if (claimableReward[msg.sender] > 0) {
_claim();
}
staked[msg.sender] = staked[msg.sender].add(amount);
totalStaked = totalStaked.add(amount);
require(stakingToken.transferFrom(msg.sender, address(this), amount));
emit Stake(msg.sender, amount);
}
| function stake(uint256 amount) external override update {
if (claimableReward[msg.sender] > 0) {
_claim();
}
staked[msg.sender] = staked[msg.sender].add(amount);
totalStaked = totalStaked.add(amount);
require(stakingToken.transferFrom(msg.sender, address(this), amount));
emit Stake(msg.sender, amount);
}
| 37,895 |
2 | // Store the booking submissions | mapping(uint256 => Booking) public bookings;
| mapping(uint256 => Booking) public bookings;
| 21,977 |
23 | // start of stake time | uint256 public stakeStartTime = block.timestamp - 1;
| uint256 public stakeStartTime = block.timestamp - 1;
| 40,088 |
97 | // Withdraws the ether distributed to the sender./It emits a `DividendWithdrawn` event if the amount of withdrawn ether is greater than 0. | function withdrawDividend(address _rewardToken) external virtual override {
_withdrawDividendOfUser(payable(msg.sender), _rewardToken);
}
| function withdrawDividend(address _rewardToken) external virtual override {
_withdrawDividendOfUser(payable(msg.sender), _rewardToken);
}
| 1,899 |
23 | // raised when the address is already unblacklisted | error AddrAlreadyUnblacklisted(address addr);
| error AddrAlreadyUnblacklisted(address addr);
| 5,667 |
196 | // Set an asset to escrow locked status (6/50/56). / | function setEscrow(bytes32 _idxHash, uint8 _newAssetStatus) external;
| function setEscrow(bytes32 _idxHash, uint8 _newAssetStatus) external;
| 5,443 |
77 | // Delegate votes from `msg.sender` to `delegatee`delegatee The address to delegate votes to/ | function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
| function delegate(address delegatee) external {
return _delegate(msg.sender, delegatee);
}
| 1,039 |
0 | // bitmap The `uint256` representation of bits./index The index number to check whether 1 or 0 is set./ return Returns `true` if the bit is set at `index` on `bitmap`. | function hasBit(uint256 bitmap, uint8 index) pure returns (bool) {
uint256 bitValue = bitmap & (1 << index);
return bitValue > 0;
}
| function hasBit(uint256 bitmap, uint8 index) pure returns (bool) {
uint256 bitValue = bitmap & (1 << index);
return bitValue > 0;
}
| 8,309 |
1 | // mapping(address => ) |
event CategoryCreated(uint id, string name, string hash);
event PostCreated(uint id, string title, string hash);
event PostUpdated(uint id, string title, string hash, bool published);
event InitReviewCreated(uint id, string postHash, string revHash);
event FundingRequested(address user, ReqType reqType, uint reqId);
event FundingBidPosted(address user, address funder, uint amount, uint percent);
event BidsAccepted(address user, uint reqId, address[] funders);
|
event CategoryCreated(uint id, string name, string hash);
event PostCreated(uint id, string title, string hash);
event PostUpdated(uint id, string title, string hash, bool published);
event InitReviewCreated(uint id, string postHash, string revHash);
event FundingRequested(address user, ReqType reqType, uint reqId);
event FundingBidPosted(address user, address funder, uint amount, uint percent);
event BidsAccepted(address user, uint reqId, address[] funders);
| 22,347 |
10 | // Aprove the passed address to spend the specified amount of tokens on behalf of msg.sender when not paused._spender The address which will spend the funds._value The amount of tokens to be spent./ | function approve(address _spender, uint256 _value) public returns (bool) {
return super.approve(_spender, _value);
}
| function approve(address _spender, uint256 _value) public returns (bool) {
return super.approve(_spender, _value);
}
| 46,070 |
101 | // Hypersign identity token interface | IERC20 private hidToken;
| IERC20 private hidToken;
| 3,759 |
100 | // The address of Aladdin Treasury. | address public immutable treasury;
| address public immutable treasury;
| 35,627 |
176 | // Calculate WETH profit | if(_normalizedGain.add(interestGain) == 0){
return 0;
}
| if(_normalizedGain.add(interestGain) == 0){
return 0;
}
| 46,281 |
2 | // Return token to InstaPool. Payback borrowed flashloan. token Token Address. amt Token Amount. getId Get token amount at this ID from `InstaMemory` Contract. setId Set token amount at this ID in `InstaMemory` Contract./ | function flashPayback(
address token,
uint amt,
uint getId,
uint setId
| function flashPayback(
address token,
uint amt,
uint getId,
uint setId
| 5,926 |
2 | // basic operations | b++;
b += a;
| b++;
b += a;
| 2,193 |
6 | // Total liquidity pool holds | uint256 private _liquidity;
bool private _mutex;
| uint256 private _liquidity;
bool private _mutex;
| 59,670 |
48 | // --------distribute current xdai balance | last_epoch_rewards_amount = last_epoch_remaining_rewards + current_xdai_balance.mul(90).div(100.0); //put the holders balance in the epoch rewards
moderation_xdai_balance += current_xdai_balance.mul(5).div(100.0);
uint256 surplus_mod = 0;
if(moderation_xdai_balance > MODERATION_POOL_CAP) {
surplus_mod = moderation_xdai_balance - MODERATION_POOL_CAP;
moderation_xdai_balance = MODERATION_POOL_CAP;
}
| last_epoch_rewards_amount = last_epoch_remaining_rewards + current_xdai_balance.mul(90).div(100.0); //put the holders balance in the epoch rewards
moderation_xdai_balance += current_xdai_balance.mul(5).div(100.0);
uint256 surplus_mod = 0;
if(moderation_xdai_balance > MODERATION_POOL_CAP) {
surplus_mod = moderation_xdai_balance - MODERATION_POOL_CAP;
moderation_xdai_balance = MODERATION_POOL_CAP;
}
| 10,085 |
558 | // Claim reward/sender address. Address who have stake the token./recipient address. Address who receive the reward./ return totalNetReward Total net SDVD reward./ return totalTaxReward Total taxed SDVD reward./ return totalReward Total SDVD reward. | function _claimReward(address sender, address recipient) internal virtual returns(uint256 totalNetReward, uint256 totalTaxReward, uint256 totalReward) {
_checkHalving();
_updateReward(sender);
_updateBonusReward(sender);
_notifyController();
uint256 reward = accountInfos[sender].reward;
uint256 bonusReward = accountInfos[sender].bonusReward;
totalReward = reward.add(bonusReward);
require(totalReward > 0, 'No reward to claim');
if (reward > 0) {
// Reduce reward first
accountInfos[sender].reward = 0;
// Apply tax
uint256 tax = reward.div(claimRewardTaxDenominator());
uint256 net = reward.sub(tax);
// Mint SDVD as reward to recipient
sdvd.mint(recipient, net);
// Mint SDVD tax to pool treasury
sdvd.mint(address(poolTreasury), tax);
// Increase total
totalNetReward = totalNetReward.add(net);
totalTaxReward = totalTaxReward.add(tax);
// Set stats
totalRewardMinted = totalRewardMinted.add(reward);
}
if (bonusReward > 0) {
// Reduce bonus reward first
accountInfos[sender].bonusReward = 0;
// Get balance and check so we doesn't overrun
uint256 balance = sdvd.balanceOf(address(this));
if (bonusReward > balance) {
bonusReward = balance;
}
// Apply tax
uint256 tax = bonusReward.div(claimRewardTaxDenominator());
uint256 net = bonusReward.sub(tax);
// Send bonus reward to recipient
IERC20(sdvd).safeTransfer(recipient, net);
// Send tax to treasury
IERC20(sdvd).safeTransfer(address(poolTreasury), tax);
// Increase total
totalNetReward = totalNetReward.add(net);
totalTaxReward = totalTaxReward.add(tax);
}
if (totalReward > 0) {
emit Claimed(sender, recipient, totalNetReward, totalTaxReward, totalReward);
}
}
| function _claimReward(address sender, address recipient) internal virtual returns(uint256 totalNetReward, uint256 totalTaxReward, uint256 totalReward) {
_checkHalving();
_updateReward(sender);
_updateBonusReward(sender);
_notifyController();
uint256 reward = accountInfos[sender].reward;
uint256 bonusReward = accountInfos[sender].bonusReward;
totalReward = reward.add(bonusReward);
require(totalReward > 0, 'No reward to claim');
if (reward > 0) {
// Reduce reward first
accountInfos[sender].reward = 0;
// Apply tax
uint256 tax = reward.div(claimRewardTaxDenominator());
uint256 net = reward.sub(tax);
// Mint SDVD as reward to recipient
sdvd.mint(recipient, net);
// Mint SDVD tax to pool treasury
sdvd.mint(address(poolTreasury), tax);
// Increase total
totalNetReward = totalNetReward.add(net);
totalTaxReward = totalTaxReward.add(tax);
// Set stats
totalRewardMinted = totalRewardMinted.add(reward);
}
if (bonusReward > 0) {
// Reduce bonus reward first
accountInfos[sender].bonusReward = 0;
// Get balance and check so we doesn't overrun
uint256 balance = sdvd.balanceOf(address(this));
if (bonusReward > balance) {
bonusReward = balance;
}
// Apply tax
uint256 tax = bonusReward.div(claimRewardTaxDenominator());
uint256 net = bonusReward.sub(tax);
// Send bonus reward to recipient
IERC20(sdvd).safeTransfer(recipient, net);
// Send tax to treasury
IERC20(sdvd).safeTransfer(address(poolTreasury), tax);
// Increase total
totalNetReward = totalNetReward.add(net);
totalTaxReward = totalTaxReward.add(tax);
}
if (totalReward > 0) {
emit Claimed(sender, recipient, totalNetReward, totalTaxReward, totalReward);
}
}
| 80,899 |
245 | // if stake is big enough and can take into account the whole fee: | if(stakes[msg.sender][_stakeidxa].amount > _feeRemaining) {
stakes[msg.sender][_stakeidxa].amount = stakes[msg.sender][_stakeidxa].amount.sub(_feeRemaining);
stakesAmount[msg.sender] = stakesAmount[msg.sender].sub(_feeRemaining);
_feeRemaining = 0;
break;
}
| if(stakes[msg.sender][_stakeidxa].amount > _feeRemaining) {
stakes[msg.sender][_stakeidxa].amount = stakes[msg.sender][_stakeidxa].amount.sub(_feeRemaining);
stakesAmount[msg.sender] = stakesAmount[msg.sender].sub(_feeRemaining);
_feeRemaining = 0;
break;
}
| 33,602 |
33 | // off-chain hash | string public tokenDetails;
| string public tokenDetails;
| 47,972 |
23 | // Bankroll | address internal bankrollAddress;
| address internal bankrollAddress;
| 36,323 |
36 | // Increase the amount of tokens that an owner allowed to a spender.approve should be called when allowed_[_spender] == 0. To incrementallowed value is better to use this function to avoid 2 calls (and wait untilthe first transaction is mined)Emits an Approval event. spender The address which will spend the funds. value The amount of tokens to increase the allowance by. / | function increase_allowance(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowance[msg.sender][spender] = _allowance[msg.sender][spender].add(value);
emit Approval(msg.sender, spender, _allowance[msg.sender][spender]);
return true;
}
| function increase_allowance(address spender, uint256 value) public returns (bool) {
require(spender != address(0));
_allowance[msg.sender][spender] = _allowance[msg.sender][spender].add(value);
emit Approval(msg.sender, spender, _allowance[msg.sender][spender]);
return true;
}
| 6,180 |
8 | // _beforeTokenTransfer / | function _beforeTokenTransfer(
address, /* from */
address to,
uint256 /* amount */
| function _beforeTokenTransfer(
address, /* from */
address to,
uint256 /* amount */
| 21,359 |
5 | // Ether market price in USD | uint public constant USD_PER_ETH = 800; // approx 7 day average High Low as at 29th OCT 2017
| uint public constant USD_PER_ETH = 800; // approx 7 day average High Low as at 29th OCT 2017
| 910 |
77 | // Success finish of PreSale | function finishPreSale() public onlyOwner {
require(weiRaised >= softCap);
require(weiRaised >= hardCap || now > endTime);
if (now < endTime) {
endTime = now;
}
forwardFunds(this.balance);
token.transferOwnership(owner);
}
| function finishPreSale() public onlyOwner {
require(weiRaised >= softCap);
require(weiRaised >= hardCap || now > endTime);
if (now < endTime) {
endTime = now;
}
forwardFunds(this.balance);
token.transferOwnership(owner);
}
| 17,618 |
34 | // Function to guarantee that the contract will not receive ether. / | receive() external payable virtual {
revert();
}
| receive() external payable virtual {
revert();
}
| 35,674 |
97 | // Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp/To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing/ the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,/ you must call it with secondsAgos = [3600, 0]./The time weighted average tick represents the geometric time weighted average price of the pool, in/ log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a | function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
| function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
| 1,195 |
3 | // @inheritdoc IERC20MetadataUpgradeable / | function name() external view returns (string memory) {
return string.concat("Locked ", underlyingToken.name());
}
| function name() external view returns (string memory) {
return string.concat("Locked ", underlyingToken.name());
}
| 21,558 |
0 | // function returning tuples | function ReturnTuples() public pure returns(uint, uint, bool) {
return (3,6, false);
}
| function ReturnTuples() public pure returns(uint, uint, bool) {
return (3,6, false);
}
| 41,125 |
76 | // Withdraw Metapool LP from Curve DAO back to this contract | function withdrawFromGauge(uint256 _metapool_lp_out) external onlyByOwnGov {
gauge_frax3crv.withdraw(_metapool_lp_out);
}
| function withdrawFromGauge(uint256 _metapool_lp_out) external onlyByOwnGov {
gauge_frax3crv.withdraw(_metapool_lp_out);
}
| 36,200 |
106 | // return 0 if exp(x) is tiny, using MIN_POWER = int(mp.floor(mp.log(mpf(1) / ONE, 2)ONE)) | if (x < -1180591620717411303424)
return (0, 1);
| if (x < -1180591620717411303424)
return (0, 1);
| 49,056 |
17 | // The start time of the auction. | uint256 startTime;
| uint256 startTime;
| 10,430 |
1 | // 1200% patronage | mapping(uint256 => uint256) public patronageNumerator;
| mapping(uint256 => uint256) public patronageNumerator;
| 53,632 |
33 | // Returns the seconds since last accrualcurrentTimestamp in seconds lastAccrualTimestamp in secondsreturn secondsSinceLastAccrualreturn accrualTimestamp in seconds / | function getSecondsSinceLastAccrual(
uint256 currentTimestamp,
uint256 lastAccrualTimestamp
)
public
pure
returns (uint256 secondsSinceLastAccrual, uint256 accrualTimestamp)
| function getSecondsSinceLastAccrual(
uint256 currentTimestamp,
uint256 lastAccrualTimestamp
)
public
pure
returns (uint256 secondsSinceLastAccrual, uint256 accrualTimestamp)
| 34,439 |
27 | // Do common multisig verification for both eth sends and erc20token transferstoAddress the destination address to send an outgoing transaction operationHash see Data Formats signature see Data Formats expireTime the number of seconds since 1970 for which this transaction is valid orderId the unique order id obtainable from getNextorderIdreturns address that has created the signature / | function verifyMultiSig(
address toAddress,
bytes32 operationHash,
bytes signature,
uint expireTime,
uint orderId
| function verifyMultiSig(
address toAddress,
bytes32 operationHash,
bytes signature,
uint expireTime,
uint orderId
| 12,225 |
115 | // Returns an URI for a given token IDThrows if the token ID does not exist. May return an empty string. tokenId uint256 ID of the token to query / | function tokenURI(uint256 tokenId) public view returns (string) {
require(_exists(tokenId));
return _tokenURIs[tokenId];
}
| function tokenURI(uint256 tokenId) public view returns (string) {
require(_exists(tokenId));
return _tokenURIs[tokenId];
}
| 71,554 |
0 | // Kyber Network interface | interface KyberNetworkProxyInterface {
function getExpectedRate(
address src,
address dest,
uint256 srcQty
)
external
view
returns (uint256 expectedRate, uint256 slippageRate);
function trade(
address src,
uint srcAmount,
address dest,
address destAddress,
uint maxDestAmount,
uint minConversionRate,
address walletId
)
external
payable
returns (uint);
}
| interface KyberNetworkProxyInterface {
function getExpectedRate(
address src,
address dest,
uint256 srcQty
)
external
view
returns (uint256 expectedRate, uint256 slippageRate);
function trade(
address src,
uint srcAmount,
address dest,
address destAddress,
uint maxDestAmount,
uint minConversionRate,
address walletId
)
external
payable
returns (uint);
}
| 41,240 |
1 | // Computes the result of swapping some amount in, or amount out, given the parameters of the swap/The fee, plus the amount in, will never exceed the amount remaining if the swap's `amountSpecified` is positive/sqrtRatioCurrentX96 The current sqrt price of the pool/sqrtRatioTargetX96 The price that cannot be exceeded, from which the direction of the swap is inferred/liquidity The usable liquidity/amountRemaining How much input or output amount is remaining to be swapped in/out/feePips The fee taken from the input amount, expressed in hundredths of a bip/ return sqrtRatioNextX96 The price after swapping the amount in/out, not to exceed the price target/ return | function computeSwapStep(
uint160 sqrtRatioCurrentX96,
uint160 sqrtRatioTargetX96,
uint128 liquidity,
int256 amountRemaining,
uint24 feePips
)
external
pure
returns (
| function computeSwapStep(
uint160 sqrtRatioCurrentX96,
uint160 sqrtRatioTargetX96,
uint128 liquidity,
int256 amountRemaining,
uint24 feePips
)
external
pure
returns (
| 3,940 |
64 | // Available only if presale is running. | require(currentPhase == Phase.Running);
| require(currentPhase == Phase.Running);
| 64,650 |
55 | // Sender will be owner only if no have bidded on auction. | require(
IMintableToken(_mintableToken).ownerOf(tokenID) == msg.sender,
"You must be owner and Token should not have any bid"
);
_;
| require(
IMintableToken(_mintableToken).ownerOf(tokenID) == msg.sender,
"You must be owner and Token should not have any bid"
);
_;
| 14,575 |
60 | // launch buy fees | uint256 _buyMarketingFee = 0;
uint256 _buyLiquidityFee = 0;
uint256 _buyDevelopmentFee = 0;
uint256 _buyOperationsFee = 0;
| uint256 _buyMarketingFee = 0;
uint256 _buyLiquidityFee = 0;
uint256 _buyDevelopmentFee = 0;
uint256 _buyOperationsFee = 0;
| 26,863 |
285 | // DEPRECATED FOR V2 Mapping to store the scheduled withdrawals (address => withdrawAmount) | mapping(address => uint256) private scheduledWithdrawals;
| mapping(address => uint256) private scheduledWithdrawals;
| 54,433 |
11 | // A mapping from CarIDs to the price of the token. | mapping (uint256 => uint256) private carIndexToPrice;
| mapping (uint256 => uint256) private carIndexToPrice;
| 46,422 |
54 | // 提现,由管理员调用该方法对指定地址进行提现ballotAddress 用户地址 / | function withdrawTokenToAddress(address ballotAddress) public onlyOwner returns(bool res){
return _withdrawToken(ballotAddress);
}
| function withdrawTokenToAddress(address ballotAddress) public onlyOwner returns(bool res){
return _withdrawToken(ballotAddress);
}
| 35,928 |
122 | // Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. Tokens start existing when they are minted (`_mint`),and stop existing when they are burned (`_burn`). / | function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
| function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
| 280 |
4 | // Some string type variables to identify the token. | string public name = "My Hardhat Token";
string public symbol = "MHT";
| string public name = "My Hardhat Token";
string public symbol = "MHT";
| 5,448 |
23 | // Performs a single exact output swap return value = amountIn returned by swap + 1ExFee, is omitted to decrease gas usage | function exactOutputInternal(
uint256 amountOut,
address recipient,
uint160 sqrtPriceLimitX96,
SwapCallbackData memory data
| function exactOutputInternal(
uint256 amountOut,
address recipient,
uint160 sqrtPriceLimitX96,
SwapCallbackData memory data
| 13,500 |
5 | // Swap half earned to token0 | _safeSwap(
earnedAmt.div(2),
earnedToToken0Path,
address(this)
);
| _safeSwap(
earnedAmt.div(2),
earnedToToken0Path,
address(this)
);
| 34,905 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.