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
|
---|---|---|---|---|
13 | // Note: messageHash is a string, that is 66-bytes long, to sign the binary value, we must convert it to the 32 byte Array that the string represents i.e.66-byte string "0x592fa743889fc7f92ac2a37bb1f5ba1daf2a5c84741ca0e0061d243a2e6707ba" ... vs ... 32 entry Uint8Array[ 89, 47, 167, 67, 136, 159, 199, 249, 42, 194, 163,123, 177, 245, 186, 29, 175, 42, 92, 132, 116, 28,160, 224, 6, 29, 36, 58, 46, 103, 7, 186] |
let messageHashBytes = ethers.utils.arrayify(messageHash)
|
let messageHashBytes = ethers.utils.arrayify(messageHash)
| 32,140 |
173 | // Validate pToken address see: https:github.com/element-fi/elf-contracts/blob/main/contracts/factories/TrancheFactory.solL58 | address predictedAddress = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xff),
trancheFactory,
keccak256(abi.encodePacked(wrappedPosition, _maturity_)),
ITrancheFactory(trancheFactory).TRANCHE_CREATION_HASH()
)
| address predictedAddress = address(
uint160(
uint256(
keccak256(
abi.encodePacked(
bytes1(0xff),
trancheFactory,
keccak256(abi.encodePacked(wrappedPosition, _maturity_)),
ITrancheFactory(trancheFactory).TRANCHE_CREATION_HASH()
)
| 33,482 |
19 | // Pass the token ID and get the nft Information / | {
nft memory myNft = nfts[_tokenId];
return (
myNft.id,
myNft.title,
myNft.description,
myNft.price,
myNft.status,
myNft.date,
myNft.authorName,
myNft.author,
myNft.owner,
myNft.image,
myNft._baseURIextended
);
}
| {
nft memory myNft = nfts[_tokenId];
return (
myNft.id,
myNft.title,
myNft.description,
myNft.price,
myNft.status,
myNft.date,
myNft.authorName,
myNft.author,
myNft.owner,
myNft.image,
myNft._baseURIextended
);
}
| 6,044 |
93 | // Returns the fractional part of a fixed point number.In the case of a negative number the fractional is also negative.Test fractional(0) returns 0Test fractional(fixed1()) returns 0Test fractional(fixed1()-1) returns 10^24-1Test fractional(-fixed1()) returns 0Test fractional(-fixed1()+1) returns -10^24-1 / | function fractional(int256 x) public pure returns (int256) {
return x - (x / fixed1()) * fixed1(); // Can't overflow
}
| function fractional(int256 x) public pure returns (int256) {
return x - (x / fixed1()) * fixed1(); // Can't overflow
}
| 755 |
30 | // A dummy constructor, which deos not initialize any storage variablesA template will be deployed with no initialization and real pool will be clonedfrom this template (same as create_forwarder_to mechanism in Vyper),and use `initialize` to initialize all storage variables / | constructor () {}
/**
* @dev See {IPerpetualPool}.{initialize}
*/
function initialize(
string memory symbol_,
address[5] calldata addresses_,
uint256[12] calldata parameters_
) public override {
require(bytes(_symbol).length == 0 && _controller == address(0), "PerpetualPool: already initialized");
_controller = msg.sender;
_symbol = symbol_;
_bToken = IERC20(addresses_[0]);
_bDecimals = _bToken.decimals();
_pToken = IPToken(addresses_[1]);
_lToken = ILToken(addresses_[2]);
_oracle = IOracle(addresses_[3]);
_isContractOracle = _isContract(address(_oracle));
_liquidatorQualifier = ILiquidatorQualifier(addresses_[4]);
_multiplier = parameters_[0];
_feeRatio = parameters_[1];
_minPoolMarginRatio = parameters_[2];
_minInitialMarginRatio = parameters_[3];
_minMaintenanceMarginRatio = parameters_[4];
_minAddLiquidity = parameters_[5];
_redemptionFeeRatio = parameters_[6];
_fundingRateCoefficient = parameters_[7];
_minLiquidationReward = parameters_[8];
_maxLiquidationReward = parameters_[9];
_liquidationCutRatio = parameters_[10];
_priceDelayAllowance = parameters_[11];
}
| constructor () {}
/**
* @dev See {IPerpetualPool}.{initialize}
*/
function initialize(
string memory symbol_,
address[5] calldata addresses_,
uint256[12] calldata parameters_
) public override {
require(bytes(_symbol).length == 0 && _controller == address(0), "PerpetualPool: already initialized");
_controller = msg.sender;
_symbol = symbol_;
_bToken = IERC20(addresses_[0]);
_bDecimals = _bToken.decimals();
_pToken = IPToken(addresses_[1]);
_lToken = ILToken(addresses_[2]);
_oracle = IOracle(addresses_[3]);
_isContractOracle = _isContract(address(_oracle));
_liquidatorQualifier = ILiquidatorQualifier(addresses_[4]);
_multiplier = parameters_[0];
_feeRatio = parameters_[1];
_minPoolMarginRatio = parameters_[2];
_minInitialMarginRatio = parameters_[3];
_minMaintenanceMarginRatio = parameters_[4];
_minAddLiquidity = parameters_[5];
_redemptionFeeRatio = parameters_[6];
_fundingRateCoefficient = parameters_[7];
_minLiquidationReward = parameters_[8];
_maxLiquidationReward = parameters_[9];
_liquidationCutRatio = parameters_[10];
_priceDelayAllowance = parameters_[11];
}
| 76,147 |
40 | // Current number of votes for abstaining for this proposal | uint abstainVotes;
| uint abstainVotes;
| 1,880 |
4 | // Change the owner. Can only be called by the current owner. account New owner's address / | function changeOwner(address account) external onlyOwner {
_changeOwner(account);
}
| function changeOwner(address account) external onlyOwner {
_changeOwner(account);
}
| 9,674 |
79 | // Override to extend the way in which ether is converted to tokens. weiAmount Value in wei to be converted into tokensreturn Number of tokens that can be purchased with the specified _weiAmount / | function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
return weiAmount.mul(_rate);
}
| function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
return weiAmount.mul(_rate);
}
| 35,888 |
6 | // adopted from https:github.com/lexDAO/Kali/blob/main/contracts/libraries/SafeTransferLib.sol | error TransferFailed();
| error TransferFailed();
| 13,906 |
45 | // possibility to change burn rate by the owneronly after community vote | function changeBurnRate(uint8 newRate) external onlyOwner {
basePercentage = newRate;
}
| function changeBurnRate(uint8 newRate) external onlyOwner {
basePercentage = newRate;
}
| 2,355 |
10 | // Remove stake from balance | IStructs.StoredBalance memory balance = _loadCurrentBalance(balancePtr);
balance.nextEpochBalance = uint256(balance.nextEpochBalance).safeAdd(amount).downcastToUint96();
balance.currentEpochBalance = uint256(balance.currentEpochBalance).safeAdd(amount).downcastToUint96();
| IStructs.StoredBalance memory balance = _loadCurrentBalance(balancePtr);
balance.nextEpochBalance = uint256(balance.nextEpochBalance).safeAdd(amount).downcastToUint96();
balance.currentEpochBalance = uint256(balance.currentEpochBalance).safeAdd(amount).downcastToUint96();
| 40,205 |
54 | // transfer() doesn't have a return value | success = true;
| success = true;
| 13,588 |
31 | // SupportsInterfaceWithLookup Matt Condon (@shrugs) Implements ERC165 using a lookup table. / | contract SupportsInterfaceWithLookup is ERC165 {
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
constructor()
public
{
_registerInterface(InterfaceId_ERC165);
}
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool)
{
return supportedInterfaces[_interfaceId];
}
/**
* @dev private method for registering an interface
*/
function _registerInterface(bytes4 _interfaceId)
internal
{
require(_interfaceId != 0xffffffff);
supportedInterfaces[_interfaceId] = true;
}
}
| contract SupportsInterfaceWithLookup is ERC165 {
bytes4 public constant InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) internal supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
constructor()
public
{
_registerInterface(InterfaceId_ERC165);
}
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 _interfaceId)
external
view
returns (bool)
{
return supportedInterfaces[_interfaceId];
}
/**
* @dev private method for registering an interface
*/
function _registerInterface(bytes4 _interfaceId)
internal
{
require(_interfaceId != 0xffffffff);
supportedInterfaces[_interfaceId] = true;
}
}
| 18,947 |
23 | // Set the migrator contract. Can only be called by the owner. | function setMigrator(IMigratorLady _migrator) public onlyOwner {
migrator = _migrator;
}
| function setMigrator(IMigratorLady _migrator) public onlyOwner {
migrator = _migrator;
}
| 48,665 |
26 | // add a role to an address addr address roleName the name of the role / | function adminAddRole(address addr, string roleName)
onlyAdmin
public
| function adminAddRole(address addr, string roleName)
onlyAdmin
public
| 22,061 |
132 | // Approve the spending of all assets by their corresponding cToken, if for some reason is it necessary. Only callable through Governance. / | function safeApproveAllTokens() external {
uint256 assetCount = assetsMapped.length;
for (uint256 i = 0; i < assetCount; i++) {
address asset = assetsMapped[i];
address cToken = assetToPToken[asset];
// Safe approval
IERC20(asset).safeApprove(cToken, 0);
IERC20(asset).safeApprove(cToken, uint256(-1));
}
}
| function safeApproveAllTokens() external {
uint256 assetCount = assetsMapped.length;
for (uint256 i = 0; i < assetCount; i++) {
address asset = assetsMapped[i];
address cToken = assetToPToken[asset];
// Safe approval
IERC20(asset).safeApprove(cToken, 0);
IERC20(asset).safeApprove(cToken, uint256(-1));
}
}
| 26,093 |
94 | // Encode length-delimited field./b Bytes/ return Marshaled bytes | function encode_length_delimited(bytes memory b)
internal
pure
returns (bytes memory)
| function encode_length_delimited(bytes memory b)
internal
pure
returns (bytes memory)
| 28,354 |
0 | // GeneralERC20 Set Protocol Interface for using ERC20 Tokens. This interface is needed to interact with tokens that are notfully ERC20 compliant and return something other than true on successful transfers. / | interface IERC20 {
function balanceOf(
address _owner
)
external
view
returns (uint256);
function allowance(
address _owner,
address _spender
)
external
view
returns (uint256);
function transfer(
address _to,
uint256 _quantity
)
external
returns (bool);
function transferFrom(
address _from,
address _to,
uint256 _quantity
)
external
returns (bool);
function approve(
address _spender,
uint256 _quantity
)
external
returns (bool);
}
| interface IERC20 {
function balanceOf(
address _owner
)
external
view
returns (uint256);
function allowance(
address _owner,
address _spender
)
external
view
returns (uint256);
function transfer(
address _to,
uint256 _quantity
)
external
returns (bool);
function transferFrom(
address _from,
address _to,
uint256 _quantity
)
external
returns (bool);
function approve(
address _spender,
uint256 _quantity
)
external
returns (bool);
}
| 47,391 |
243 | // Load poseidon smart contract _poseidon2Elements Poseidon contract address for 2 elements _poseidon3Elements Poseidon contract address for 3 elements _poseidon4Elements Poseidon contract address for 4 elements / | function _initializeHelpers(
address _poseidon2Elements,
address _poseidon3Elements,
address _poseidon4Elements
| function _initializeHelpers(
address _poseidon2Elements,
address _poseidon3Elements,
address _poseidon4Elements
| 61,132 |
2 | // Dex Factory contract interface | interface IdexFacotry {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
| interface IdexFacotry {
function createPair(address tokenA, address tokenB)
external
returns (address pair);
}
| 867 |
7 | // returns AccountInfo | function getAccountInfo(DToken dToken, address payable account) public returns (AccountInfo memory) {
AccountInfo memory accountInfo;
address underlyingAssetAddress;
address contractAddress = address(dToken);
bool isETH = compareStrings(dToken.symbol(), mainDTokenSymbol);
if (isETH) {
underlyingAssetAddress = address(0);
} else {
DErc20 dErc20 = DErc20(address(dToken));
underlyingAssetAddress = dErc20.underlying();
}
accountInfo.mySuppliedBalance = dToken.balanceOfUnderlying(account);
accountInfo.myBorrowedBalance = dToken.borrowBalanceStored(account);
accountInfo.mySupplyPrincipalBalance = dToken.supplyPrincipal(account);
accountInfo.myBorrowPrincipalBalance = dToken.borrowPrincipal(account);
accountInfo.myRealTokenBalance = isETH ? account.balance : IERC20(underlyingAssetAddress).balanceOf(account);
accountInfo.donkeySupplierIndex = controller.donkeySupplierIndex(contractAddress, account);
accountInfo.donkeyBorrowerIndex = controller.donkeyBorrowerIndex(contractAddress, account);
return accountInfo;
}
| function getAccountInfo(DToken dToken, address payable account) public returns (AccountInfo memory) {
AccountInfo memory accountInfo;
address underlyingAssetAddress;
address contractAddress = address(dToken);
bool isETH = compareStrings(dToken.symbol(), mainDTokenSymbol);
if (isETH) {
underlyingAssetAddress = address(0);
} else {
DErc20 dErc20 = DErc20(address(dToken));
underlyingAssetAddress = dErc20.underlying();
}
accountInfo.mySuppliedBalance = dToken.balanceOfUnderlying(account);
accountInfo.myBorrowedBalance = dToken.borrowBalanceStored(account);
accountInfo.mySupplyPrincipalBalance = dToken.supplyPrincipal(account);
accountInfo.myBorrowPrincipalBalance = dToken.borrowPrincipal(account);
accountInfo.myRealTokenBalance = isETH ? account.balance : IERC20(underlyingAssetAddress).balanceOf(account);
accountInfo.donkeySupplierIndex = controller.donkeySupplierIndex(contractAddress, account);
accountInfo.donkeyBorrowerIndex = controller.donkeyBorrowerIndex(contractAddress, account);
return accountInfo;
}
| 2,546 |
147 | // get call options total collateral occupied value. / | function getCallTotalOccupiedCollateral() public view returns (uint256) {
delegateToViewAndReturn();
}
| function getCallTotalOccupiedCollateral() public view returns (uint256) {
delegateToViewAndReturn();
}
| 78,045 |
32 | // ShibaSwapWrappedLp / | contract WrappedShibaSwapLp is IWrappedAsset, Auth2, ERC20, ReentrancyGuard {
import "../../interfaces/IVault.sol";
import "../../interfaces/IERC20WithOptional.sol";
import "../../interfaces/wrapped-assets/IWrappedAsset.sol";
import "../../interfaces/wrapped-assets/ITopDog.sol";
import "../../interfaces/wrapped-assets/ISushiSwapLpToken.sol";
using SafeMath for uint256;
bytes32 public constant override isUnitProtocolWrappedAsset = keccak256("UnitProtocolWrappedAsset");
IVault public immutable vault;
ITopDog public immutable topDog;
uint256 public immutable topDogPoolId;
IERC20 public immutable boneToken;
address public immutable userProxyImplementation;
mapping(address => WSSLPUserProxy) public usersProxies;
mapping (address => mapping (bytes4 => bool)) allowedBoneLockersSelectors;
address public feeReceiver;
uint8 public feePercent = 10;
constructor(
address _vaultParameters,
ITopDog _topDog,
uint256 _topDogPoolId,
address _feeReceiver
)
Auth2(_vaultParameters)
ERC20(
string(
abi.encodePacked(
"Wrapped by Unit ",
getSsLpTokenName(_topDog, _topDogPoolId),
" ",
getSsLpTokenToken0Symbol(_topDog, _topDogPoolId),
"-",
getSsLpTokenToken1Symbol(_topDog, _topDogPoolId)
)
),
string(
abi.encodePacked(
"wu",
getSsLpTokenSymbol(_topDog, _topDogPoolId),
getSsLpTokenToken0Symbol(_topDog, _topDogPoolId),
getSsLpTokenToken1Symbol(_topDog, _topDogPoolId)
)
)
)
{
boneToken = _topDog.bone();
topDog = _topDog;
topDogPoolId = _topDogPoolId;
vault = IVault(VaultParameters(_vaultParameters).vault());
_setupDecimals(IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).decimals());
feeReceiver = _feeReceiver;
userProxyImplementation = address(new WSSLPUserProxy(_topDog, _topDogPoolId));
}
function setFeeReceiver(address _feeReceiver) public onlyManager {
feeReceiver = _feeReceiver;
emit FeeReceiverChanged(_feeReceiver);
}
function setFee(uint8 _feePercent) public onlyManager {
require(_feePercent <= 50, "Unit Protocol Wrapped Assets: INVALID_FEE");
feePercent = _feePercent;
emit FeeChanged(_feePercent);
}
/**
* @dev in case of change bone locker to unsupported by current methods one
*/
function setAllowedBoneLockerSelector(address _boneLocker, bytes4 _selector, bool _isAllowed) public onlyManager {
allowedBoneLockersSelectors[_boneLocker][_selector] = _isAllowed;
if (_isAllowed) {
emit AllowedBoneLockerSelectorAdded(_boneLocker, _selector);
} else {
emit AllowedBoneLockerSelectorRemoved(_boneLocker, _selector);
}
}
/**
* @notice Approve sslp token to spend from user proxy (in case of change sslp)
*/
function approveSslpToTopDog() public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
IERC20 sslpToken = getUnderlyingToken();
userProxy.approveSslpToTopDog(sslpToken);
}
/**
* @notice Get tokens from user, send them to TopDog, sent to user wrapped tokens
* @dev only user or CDPManager could call this method
*/
function deposit(address _user, uint256 _amount) public override nonReentrant {
require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT");
require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED");
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userProxy = _getOrCreateUserProxy(_user, sslpToken);
// get tokens from user, need approve of sslp tokens to pool
TransferHelper.safeTransferFrom(address(sslpToken), _user, address(userProxy), _amount);
// deposit them to TopDog
userProxy.deposit(_amount);
// wrapped tokens to user
_mint(_user, _amount);
emit Deposit(_user, _amount);
}
/**
* @notice Unwrap tokens, withdraw from TopDog and send them to user
* @dev only user or CDPManager could call this method
*/
function withdraw(address _user, uint256 _amount) public override nonReentrant {
require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT");
require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED");
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userProxy = _requireUserProxy(_user);
// get wrapped tokens from user
_burn(_user, _amount);
// withdraw funds from TopDog
userProxy.withdraw(sslpToken, _amount, _user);
emit Withdraw(_user, _amount);
}
/**
* @notice Manually move position (or its part) to another user (for example in case of liquidation)
* @dev Important! Use only with additional token transferring outside this function (example: liquidation - tokens are in vault and transferred by vault)
* @dev only CDPManager could call this method
*/
function movePosition(address _userFrom, address _userTo, uint256 _amount) public override nonReentrant hasVaultAccess {
require(_userFrom != address(vault) && _userTo != address(vault), "Unit Protocol Wrapped Assets: NOT_ALLOWED_FOR_VAULT");
if (_userFrom == _userTo || _amount == 0) {
return;
}
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userFromProxy = _requireUserProxy(_userFrom);
WSSLPUserProxy userToProxy = _getOrCreateUserProxy(_userTo, sslpToken);
userFromProxy.withdraw(sslpToken, _amount, address(userToProxy));
userToProxy.deposit(_amount);
emit Withdraw(_userFrom, _amount);
emit Deposit(_userTo, _amount);
emit PositionMoved(_userFrom, _userTo, _amount);
}
/**
* @notice Calculates pending reward for user. Not taken into account unclaimed reward from BoneLockers.
* @notice Use getClaimableRewardFromBoneLocker to calculate unclaimed reward from BoneLockers
*/
function pendingReward(address _user) public override view returns (uint256) {
WSSLPUserProxy userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
return 0;
}
return userProxy.pendingReward(feeReceiver, feePercent);
}
/**
* @notice Claim pending direct reward for user.
* @notice Use claimRewardFromBoneLockers claim reward from BoneLockers
*/
function claimReward(address _user) public override nonReentrant {
require(_user == msg.sender, "Unit Protocol Wrapped Assets: AUTH_FAILED");
WSSLPUserProxy userProxy = _requireUserProxy(_user);
userProxy.claimReward(_user, feeReceiver, feePercent);
}
/**
* @notice Get claimable amount from BoneLocker
* @param _user user address
* @param _boneLocker BoneLocker to check, pass zero address to check current
*/
function getClaimableRewardFromBoneLocker(address _user, IBoneLocker _boneLocker) public view returns (uint256) {
WSSLPUserProxy userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
return 0;
}
return userProxy.getClaimableRewardFromBoneLocker(_boneLocker, feeReceiver, feePercent);
}
/**
* @notice Claim bones from BoneLockers
* @notice Since it could be a lot of pending rewards items parameters are used limit tx size
* @param _boneLocker BoneLocker to claim, pass zero address to claim from current
* @param _maxBoneLockerRewardsAtOneClaim max amount of rewards items to claim from BoneLocker, pass 0 to claim all rewards
*/
function claimRewardFromBoneLocker(IBoneLocker _boneLocker, uint256 _maxBoneLockerRewardsAtOneClaim) public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
userProxy.claimRewardFromBoneLocker(msg.sender, _boneLocker, _maxBoneLockerRewardsAtOneClaim, feeReceiver, feePercent);
}
/**
* @notice get SSLP token
* @dev not immutable since it could be changed in TopDog
*/
function getUnderlyingToken() public override view returns (IERC20) {
(IERC20 _sslpToken,,,) = topDog.poolInfo(topDogPoolId);
return _sslpToken;
}
/**
* @notice Withdraw tokens from topdog to user proxy without caring about rewards. EMERGENCY ONLY.
* @notice To withdraw tokens from user proxy to user use `withdrawToken`
*/
function emergencyWithdraw() public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
uint amount = userProxy.getDepositedAmount();
_burn(msg.sender, amount);
assert(balanceOf(msg.sender) == 0);
userProxy.emergencyWithdraw();
emit EmergencyWithdraw(msg.sender, amount);
}
function withdrawToken(address _token, uint _amount) public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
userProxy.withdrawToken(_token, msg.sender, _amount, feeReceiver, feePercent);
emit TokenWithdraw(msg.sender, _token, _amount);
}
function readBoneLocker(address _user, address _boneLocker, bytes calldata _callData) public view returns (bool success, bytes memory data) {
WSSLPUserProxy userProxy = _requireUserProxy(_user);
(success, data) = userProxy.readBoneLocker(_boneLocker, _callData);
}
function callBoneLocker(address _boneLocker, bytes calldata _callData) public nonReentrant returns (bool success, bytes memory data) {
bytes4 selector;
assembly {
selector := calldataload(_callData.offset)
}
require(allowedBoneLockersSelectors[_boneLocker][selector], "Unit Protocol Wrapped Assets: UNSUPPORTED_SELECTOR");
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
(success, data) = userProxy.callBoneLocker(_boneLocker, _callData);
}
/**
* @dev Get sslp token for using in constructor
*/
function getSsLpToken(ITopDog _topDog, uint256 _topDogPoolId) private view returns (address) {
(IERC20 _sslpToken,,,) = _topDog.poolInfo(_topDogPoolId);
return address(_sslpToken);
}
/**
* @dev Get symbol of sslp token for using in constructor
*/
function getSsLpTokenSymbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).symbol();
}
/**
* @dev Get name of sslp token for using in constructor
*/
function getSsLpTokenName(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).name();
}
/**
* @dev Get token0 symbol of sslp token for using in constructor
*/
function getSsLpTokenToken0Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token0())).symbol();
}
/**
* @dev Get token1 symbol of sslp token for using in constructor
*/
function getSsLpTokenToken1Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token1())).symbol();
}
/**
* @dev No direct transfers between users allowed since we store positions info in userInfo.
*/
function _transfer(address sender, address recipient, uint256 amount) internal override onlyVault {
require(sender == address(vault) || recipient == address(vault), "Unit Protocol Wrapped Assets: AUTH_FAILED");
super._transfer(sender, recipient, amount);
}
function _requireUserProxy(address _user) internal view returns (WSSLPUserProxy userProxy) {
userProxy = usersProxies[_user];
require(address(userProxy) != address(0), "Unit Protocol Wrapped Assets: NO_DEPOSIT");
}
function _getOrCreateUserProxy(address _user, IERC20 sslpToken) internal returns (WSSLPUserProxy userProxy) {
userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
// create new
userProxy = WSSLPUserProxy(createClone(userProxyImplementation));
userProxy.approveSslpToTopDog(sslpToken);
usersProxies[_user] = userProxy;
}
}
/**
* @dev see https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol
*/
function createClone(address target) internal returns (address result) {
bytes20 targetBytes = bytes20(target);
assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
result := create(0, clone, 0x37)
}
}
}
| contract WrappedShibaSwapLp is IWrappedAsset, Auth2, ERC20, ReentrancyGuard {
import "../../interfaces/IVault.sol";
import "../../interfaces/IERC20WithOptional.sol";
import "../../interfaces/wrapped-assets/IWrappedAsset.sol";
import "../../interfaces/wrapped-assets/ITopDog.sol";
import "../../interfaces/wrapped-assets/ISushiSwapLpToken.sol";
using SafeMath for uint256;
bytes32 public constant override isUnitProtocolWrappedAsset = keccak256("UnitProtocolWrappedAsset");
IVault public immutable vault;
ITopDog public immutable topDog;
uint256 public immutable topDogPoolId;
IERC20 public immutable boneToken;
address public immutable userProxyImplementation;
mapping(address => WSSLPUserProxy) public usersProxies;
mapping (address => mapping (bytes4 => bool)) allowedBoneLockersSelectors;
address public feeReceiver;
uint8 public feePercent = 10;
constructor(
address _vaultParameters,
ITopDog _topDog,
uint256 _topDogPoolId,
address _feeReceiver
)
Auth2(_vaultParameters)
ERC20(
string(
abi.encodePacked(
"Wrapped by Unit ",
getSsLpTokenName(_topDog, _topDogPoolId),
" ",
getSsLpTokenToken0Symbol(_topDog, _topDogPoolId),
"-",
getSsLpTokenToken1Symbol(_topDog, _topDogPoolId)
)
),
string(
abi.encodePacked(
"wu",
getSsLpTokenSymbol(_topDog, _topDogPoolId),
getSsLpTokenToken0Symbol(_topDog, _topDogPoolId),
getSsLpTokenToken1Symbol(_topDog, _topDogPoolId)
)
)
)
{
boneToken = _topDog.bone();
topDog = _topDog;
topDogPoolId = _topDogPoolId;
vault = IVault(VaultParameters(_vaultParameters).vault());
_setupDecimals(IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).decimals());
feeReceiver = _feeReceiver;
userProxyImplementation = address(new WSSLPUserProxy(_topDog, _topDogPoolId));
}
function setFeeReceiver(address _feeReceiver) public onlyManager {
feeReceiver = _feeReceiver;
emit FeeReceiverChanged(_feeReceiver);
}
function setFee(uint8 _feePercent) public onlyManager {
require(_feePercent <= 50, "Unit Protocol Wrapped Assets: INVALID_FEE");
feePercent = _feePercent;
emit FeeChanged(_feePercent);
}
/**
* @dev in case of change bone locker to unsupported by current methods one
*/
function setAllowedBoneLockerSelector(address _boneLocker, bytes4 _selector, bool _isAllowed) public onlyManager {
allowedBoneLockersSelectors[_boneLocker][_selector] = _isAllowed;
if (_isAllowed) {
emit AllowedBoneLockerSelectorAdded(_boneLocker, _selector);
} else {
emit AllowedBoneLockerSelectorRemoved(_boneLocker, _selector);
}
}
/**
* @notice Approve sslp token to spend from user proxy (in case of change sslp)
*/
function approveSslpToTopDog() public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
IERC20 sslpToken = getUnderlyingToken();
userProxy.approveSslpToTopDog(sslpToken);
}
/**
* @notice Get tokens from user, send them to TopDog, sent to user wrapped tokens
* @dev only user or CDPManager could call this method
*/
function deposit(address _user, uint256 _amount) public override nonReentrant {
require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT");
require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED");
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userProxy = _getOrCreateUserProxy(_user, sslpToken);
// get tokens from user, need approve of sslp tokens to pool
TransferHelper.safeTransferFrom(address(sslpToken), _user, address(userProxy), _amount);
// deposit them to TopDog
userProxy.deposit(_amount);
// wrapped tokens to user
_mint(_user, _amount);
emit Deposit(_user, _amount);
}
/**
* @notice Unwrap tokens, withdraw from TopDog and send them to user
* @dev only user or CDPManager could call this method
*/
function withdraw(address _user, uint256 _amount) public override nonReentrant {
require(_amount > 0, "Unit Protocol Wrapped Assets: INVALID_AMOUNT");
require(msg.sender == _user || vaultParameters.canModifyVault(msg.sender), "Unit Protocol Wrapped Assets: AUTH_FAILED");
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userProxy = _requireUserProxy(_user);
// get wrapped tokens from user
_burn(_user, _amount);
// withdraw funds from TopDog
userProxy.withdraw(sslpToken, _amount, _user);
emit Withdraw(_user, _amount);
}
/**
* @notice Manually move position (or its part) to another user (for example in case of liquidation)
* @dev Important! Use only with additional token transferring outside this function (example: liquidation - tokens are in vault and transferred by vault)
* @dev only CDPManager could call this method
*/
function movePosition(address _userFrom, address _userTo, uint256 _amount) public override nonReentrant hasVaultAccess {
require(_userFrom != address(vault) && _userTo != address(vault), "Unit Protocol Wrapped Assets: NOT_ALLOWED_FOR_VAULT");
if (_userFrom == _userTo || _amount == 0) {
return;
}
IERC20 sslpToken = getUnderlyingToken();
WSSLPUserProxy userFromProxy = _requireUserProxy(_userFrom);
WSSLPUserProxy userToProxy = _getOrCreateUserProxy(_userTo, sslpToken);
userFromProxy.withdraw(sslpToken, _amount, address(userToProxy));
userToProxy.deposit(_amount);
emit Withdraw(_userFrom, _amount);
emit Deposit(_userTo, _amount);
emit PositionMoved(_userFrom, _userTo, _amount);
}
/**
* @notice Calculates pending reward for user. Not taken into account unclaimed reward from BoneLockers.
* @notice Use getClaimableRewardFromBoneLocker to calculate unclaimed reward from BoneLockers
*/
function pendingReward(address _user) public override view returns (uint256) {
WSSLPUserProxy userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
return 0;
}
return userProxy.pendingReward(feeReceiver, feePercent);
}
/**
* @notice Claim pending direct reward for user.
* @notice Use claimRewardFromBoneLockers claim reward from BoneLockers
*/
function claimReward(address _user) public override nonReentrant {
require(_user == msg.sender, "Unit Protocol Wrapped Assets: AUTH_FAILED");
WSSLPUserProxy userProxy = _requireUserProxy(_user);
userProxy.claimReward(_user, feeReceiver, feePercent);
}
/**
* @notice Get claimable amount from BoneLocker
* @param _user user address
* @param _boneLocker BoneLocker to check, pass zero address to check current
*/
function getClaimableRewardFromBoneLocker(address _user, IBoneLocker _boneLocker) public view returns (uint256) {
WSSLPUserProxy userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
return 0;
}
return userProxy.getClaimableRewardFromBoneLocker(_boneLocker, feeReceiver, feePercent);
}
/**
* @notice Claim bones from BoneLockers
* @notice Since it could be a lot of pending rewards items parameters are used limit tx size
* @param _boneLocker BoneLocker to claim, pass zero address to claim from current
* @param _maxBoneLockerRewardsAtOneClaim max amount of rewards items to claim from BoneLocker, pass 0 to claim all rewards
*/
function claimRewardFromBoneLocker(IBoneLocker _boneLocker, uint256 _maxBoneLockerRewardsAtOneClaim) public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
userProxy.claimRewardFromBoneLocker(msg.sender, _boneLocker, _maxBoneLockerRewardsAtOneClaim, feeReceiver, feePercent);
}
/**
* @notice get SSLP token
* @dev not immutable since it could be changed in TopDog
*/
function getUnderlyingToken() public override view returns (IERC20) {
(IERC20 _sslpToken,,,) = topDog.poolInfo(topDogPoolId);
return _sslpToken;
}
/**
* @notice Withdraw tokens from topdog to user proxy without caring about rewards. EMERGENCY ONLY.
* @notice To withdraw tokens from user proxy to user use `withdrawToken`
*/
function emergencyWithdraw() public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
uint amount = userProxy.getDepositedAmount();
_burn(msg.sender, amount);
assert(balanceOf(msg.sender) == 0);
userProxy.emergencyWithdraw();
emit EmergencyWithdraw(msg.sender, amount);
}
function withdrawToken(address _token, uint _amount) public nonReentrant {
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
userProxy.withdrawToken(_token, msg.sender, _amount, feeReceiver, feePercent);
emit TokenWithdraw(msg.sender, _token, _amount);
}
function readBoneLocker(address _user, address _boneLocker, bytes calldata _callData) public view returns (bool success, bytes memory data) {
WSSLPUserProxy userProxy = _requireUserProxy(_user);
(success, data) = userProxy.readBoneLocker(_boneLocker, _callData);
}
function callBoneLocker(address _boneLocker, bytes calldata _callData) public nonReentrant returns (bool success, bytes memory data) {
bytes4 selector;
assembly {
selector := calldataload(_callData.offset)
}
require(allowedBoneLockersSelectors[_boneLocker][selector], "Unit Protocol Wrapped Assets: UNSUPPORTED_SELECTOR");
WSSLPUserProxy userProxy = _requireUserProxy(msg.sender);
(success, data) = userProxy.callBoneLocker(_boneLocker, _callData);
}
/**
* @dev Get sslp token for using in constructor
*/
function getSsLpToken(ITopDog _topDog, uint256 _topDogPoolId) private view returns (address) {
(IERC20 _sslpToken,,,) = _topDog.poolInfo(_topDogPoolId);
return address(_sslpToken);
}
/**
* @dev Get symbol of sslp token for using in constructor
*/
function getSsLpTokenSymbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).symbol();
}
/**
* @dev Get name of sslp token for using in constructor
*/
function getSsLpTokenName(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(getSsLpToken(_topDog, _topDogPoolId)).name();
}
/**
* @dev Get token0 symbol of sslp token for using in constructor
*/
function getSsLpTokenToken0Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token0())).symbol();
}
/**
* @dev Get token1 symbol of sslp token for using in constructor
*/
function getSsLpTokenToken1Symbol(ITopDog _topDog, uint256 _topDogPoolId) private view returns (string memory) {
return IERC20WithOptional(address(ISushiSwapLpToken(getSsLpToken(_topDog, _topDogPoolId)).token1())).symbol();
}
/**
* @dev No direct transfers between users allowed since we store positions info in userInfo.
*/
function _transfer(address sender, address recipient, uint256 amount) internal override onlyVault {
require(sender == address(vault) || recipient == address(vault), "Unit Protocol Wrapped Assets: AUTH_FAILED");
super._transfer(sender, recipient, amount);
}
function _requireUserProxy(address _user) internal view returns (WSSLPUserProxy userProxy) {
userProxy = usersProxies[_user];
require(address(userProxy) != address(0), "Unit Protocol Wrapped Assets: NO_DEPOSIT");
}
function _getOrCreateUserProxy(address _user, IERC20 sslpToken) internal returns (WSSLPUserProxy userProxy) {
userProxy = usersProxies[_user];
if (address(userProxy) == address(0)) {
// create new
userProxy = WSSLPUserProxy(createClone(userProxyImplementation));
userProxy.approveSslpToTopDog(sslpToken);
usersProxies[_user] = userProxy;
}
}
/**
* @dev see https://github.com/optionality/clone-factory/blob/master/contracts/CloneFactory.sol
*/
function createClone(address target) internal returns (address result) {
bytes20 targetBytes = bytes20(target);
assembly {
let clone := mload(0x40)
mstore(clone, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000000000000000000000)
mstore(add(clone, 0x14), targetBytes)
mstore(add(clone, 0x28), 0x5af43d82803e903d91602b57fd5bf30000000000000000000000000000000000)
result := create(0, clone, 0x37)
}
}
}
| 79,097 |
5 | // accumulated fees for workers and treasury | mapping(address worker => uint) public fees;
event ExecutorFeePaid(address executor, uint fee);
event TreasurySet(address treasury);
| mapping(address worker => uint) public fees;
event ExecutorFeePaid(address executor, uint fee);
event TreasurySet(address treasury);
| 19,764 |
15 | // Check if locked amount decreased | require(
lockedAndClaimable(_tokenId) >= tokenIdLockedAmount[_tokenId],
"Locked amount decreased"
);
| require(
lockedAndClaimable(_tokenId) >= tokenIdLockedAmount[_tokenId],
"Locked amount decreased"
);
| 11,208 |
76 | // Whether or not a domain specific by an id is available. | function isAvailable(uint256 id) external view returns (bool);
| function isAvailable(uint256 id) external view returns (bool);
| 36,863 |
53 | // Accept a contribution if KYC passed. | function acceptContribution(bytes32 transactionHash) public onlyOwner {
Contribution storage c = contributions[transactionHash];
require(!c.resolved);
c.resolved = true;
c.success = true;
balances[c.recipient] = balances[c.recipient].add(c.tokens);
assert(multisig.send(c.ethWei));
Transfer(this, c.recipient, c.tokens);
ContributionResolved(transactionHash, true, c.contributor, c.recipient, c.ethWei,
c.tokens);
}
| function acceptContribution(bytes32 transactionHash) public onlyOwner {
Contribution storage c = contributions[transactionHash];
require(!c.resolved);
c.resolved = true;
c.success = true;
balances[c.recipient] = balances[c.recipient].add(c.tokens);
assert(multisig.send(c.ethWei));
Transfer(this, c.recipient, c.tokens);
ContributionResolved(transactionHash, true, c.contributor, c.recipient, c.ethWei,
c.tokens);
}
| 6,200 |
24 | // Helper function to know if an address is a contract, extcodesize returns the size of the code of a smartcontract in a specific address | function isContract(address addr) internal returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
| function isContract(address addr) internal returns (bool) {
uint size;
assembly { size := extcodesize(addr) }
return size > 0;
}
| 9,863 |
75 | // Find no.of tokens to be purchased | uint256 purchaseTokens = inCents.mul(10 ** uint256(decimals)).div(lotsInfo[currLot].rateInCents);
| uint256 purchaseTokens = inCents.mul(10 ** uint256(decimals)).div(lotsInfo[currLot].rateInCents);
| 50,022 |
39 | // |/ Will reimburse tx.origin or fee recipient for the gas spent execution a transactionCan reimbuse in any ERC-20 or ERC-1155 token _fromAddress from which the payment will be made from _g GasReceipt object that contains gas reimbursement information / | function _transferGasFee(address _from, GasReceipt memory _g)
internal
| function _transferGasFee(address _from, GasReceipt memory _g)
internal
| 20,204 |
77 | // a struct used to keep track of each contributoors address and contribution amount | struct Contribution {
address addr;
uint256 amount;
}
| struct Contribution {
address addr;
uint256 amount;
}
| 8,865 |
387 | // "Private" profile. Access controlled by Permissions.sol. Nothing is really private on the blockchain, so data should be encrypted on symetric key. | struct PrivateProfile {
// Private email.
bytes email;
// Mobile number.
bytes mobile;
}
| struct PrivateProfile {
// Private email.
bytes email;
// Mobile number.
bytes mobile;
}
| 13,555 |
115 | // number of decimals of the token | uint8 private immutable _decimals;
| uint8 private immutable _decimals;
| 32,166 |
20 | // Internal function calculating receive amount for the caller.paybackIncentive is set to 5E16 => 5% incentive for paying back bad debt. / | function getReceivingToken(
address _paybackToken,
address _receivingToken,
uint256 _paybackAmount
)
public
view
returns (uint256 receivingAmount)
| function getReceivingToken(
address _paybackToken,
address _receivingToken,
uint256 _paybackAmount
)
public
view
returns (uint256 receivingAmount)
| 1,335 |
39 | // ERC-173 Contract Ownership Standard/See https:github.com/ethereum/EIPs/blob/master/EIPS/eip-173.md/Note: the ERC-165 identifier for this interface is 0x7f5828d0 | contract IERC173 {
/// @dev This emits when ownership of a contract changes.
event OwnershipTransferred(address indexed _previousOwner, address indexed _newOwner);
/// @notice Get the address of the owner
/// @return The address of the owner.
//// function owner() external view returns (address);
/// @notice Set the address of the new owner of the contract
/// @param _newOwner The address of the new owner of the contract
function transferOwnership(address _newOwner) external;
}
| contract IERC173 {
/// @dev This emits when ownership of a contract changes.
event OwnershipTransferred(address indexed _previousOwner, address indexed _newOwner);
/// @notice Get the address of the owner
/// @return The address of the owner.
//// function owner() external view returns (address);
/// @notice Set the address of the new owner of the contract
/// @param _newOwner The address of the new owner of the contract
function transferOwnership(address _newOwner) external;
}
| 5,557 |
6 | // if royaltyFeeByID > 0 and0 < additionalPayeePercentage < 100 | } else if (additionalPayeePercentage > 0 && additionalPayeePercentage < 100) {
| } else if (additionalPayeePercentage > 0 && additionalPayeePercentage < 100) {
| 7,024 |
25 | // Check that the token id has not already been redeemed. | if (redeemedTokenIds[tokenId]) {
revert TokenGatedTokenAlreadyRedeemed();
}
| if (redeemedTokenIds[tokenId]) {
revert TokenGatedTokenAlreadyRedeemed();
}
| 30,976 |
4 | // ! eft.sol | (c) 2018 Develop by BelovITLab LLC (smartcontract.ru), author @stupidlovejoy | License: MIT / | library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns(uint256) {
if(a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns(uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns(uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns(uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
| library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns(uint256) {
if(a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns(uint256) {
uint256 c = a / b;
return c;
}
function sub(uint256 a, uint256 b) internal pure returns(uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns(uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
| 28,471 |
51 | // Requre that the user had a balance >0 at time/blockNumber the disupte began | require(voteWeight != 0, "User balance is 0");
| require(voteWeight != 0, "User balance is 0");
| 7,566 |
195 | // map control token ID to its buy price | mapping(uint256 => uint256) public buyPrices;
| mapping(uint256 => uint256) public buyPrices;
| 15,242 |
115 | // When burning | _removeTokenFromOwnerEnumeration(from, tokenId);
| _removeTokenFromOwnerEnumeration(from, tokenId);
| 11,434 |
32 | // Subtract the vesting balance from total supply. | _vestingTotalSupply = _vestingTotalSupply.sub(vestingBalance);
| _vestingTotalSupply = _vestingTotalSupply.sub(vestingBalance);
| 47,249 |
97 | // GOVERNANCE FUNCTION: Add new oracle adapter._adapter Address of new adapter / | function addAdapter(address _adapter) external onlyOwner {
require(
!adapters.contains(_adapter),
"PriceOracle.addAdapter: Adapter already exists."
);
adapters.push(_adapter);
emit AdapterAdded(_adapter);
}
| function addAdapter(address _adapter) external onlyOwner {
require(
!adapters.contains(_adapter),
"PriceOracle.addAdapter: Adapter already exists."
);
adapters.push(_adapter);
emit AdapterAdded(_adapter);
}
| 7,442 |
273 | // Helper to swap many assets to a single target asset./ The intermediary asset will generally be WETH, and though we could make it per-outgoing asset, seems like overkill until there is a need. | function __uniswapV2SwapManyToOne(
address _recipient,
address[] memory _outgoingAssets,
uint256[] memory _outgoingAssetAmounts,
address _incomingAsset,
address _intermediaryAsset
| function __uniswapV2SwapManyToOne(
address _recipient,
address[] memory _outgoingAssets,
uint256[] memory _outgoingAssetAmounts,
address _incomingAsset,
address _intermediaryAsset
| 25,405 |
164 | // cost ether(wei) | require(msg.value == iCostNum);
AddBonus(BONUS_PERCENT_PURCHASE);
| require(msg.value == iCostNum);
AddBonus(BONUS_PERCENT_PURCHASE);
| 41,944 |
8 | // / create new contract send 0 Ether code starts at pointer stored in "clone" code size 0x37 (55 bytes) | result := create(0, clone, 0x37)
| result := create(0, clone, 0x37)
| 22,473 |
145 | // Initialize the auction house and base contracts,populate configuration values, and pause the contract. This function can only be called once. / | function initialize(
IAxons _axons,
IAxonsVoting _axonsVoting,
address _axonsToken,
uint256 _timeBuffer,
uint256 _reservePrice,
uint8 _minBidIncrementPercentage,
uint256 _duration
| function initialize(
IAxons _axons,
IAxonsVoting _axonsVoting,
address _axonsToken,
uint256 _timeBuffer,
uint256 _reservePrice,
uint8 _minBidIncrementPercentage,
uint256 _duration
| 15,761 |
12 | // This is the seed passed to VRFCoordinator. The oracle will mix this with the hash of the block containing this request to obtain the seed/input which is finally passed to the VRF cryptographic machinery. | uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]);
| uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]);
| 21,074 |
47 | // Withdraw ether from this contract (Callable by owner) / | function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
msg.sender.transfer(balance);
}
| function withdraw() public onlyOwner {
uint256 balance = address(this).balance;
msg.sender.transfer(balance);
}
| 5,399 |
2 | // add a new participant to array | uint total_inv = benefactor.length;
benefactor.length += 1;
benefactor[total_inv].etherAddress = msg.sender;
benefactor[total_inv].amount = msg.value;
balance += msg.value; //keep track of amount available
| uint total_inv = benefactor.length;
benefactor.length += 1;
benefactor[total_inv].etherAddress = msg.sender;
benefactor[total_inv].amount = msg.value;
balance += msg.value; //keep track of amount available
| 39,006 |
8 | // Variant name not found. | string constant VAR_NAME_NOT_FOUND = "E8";
| string constant VAR_NAME_NOT_FOUND = "E8";
| 22,971 |
30 | // Revert with an error if supplied signed end time is greater than the maximum specified. / | error InvalidSignedEndTime(uint256 got, uint256 maximum);
| error InvalidSignedEndTime(uint256 got, uint256 maximum);
| 27,026 |
39 | // if_succeeds {:msg "Can only be called by account holder"} old(creditAccounts[msg.sender]) != address(0x0);/ if_succeeds {:msg "If this succeeded the pool gets paid at least borrowed + interest"}/ let minAmountOwedToPool := old(borrowedPlusInterest(creditAccounts[msg.sender])) in/ IERC20(underlyingToken).balanceOf(poolService) >= old(IERC20(underlyingToken).balanceOf(poolService)).add(minAmountOwedToPool); | function repayCreditAccount(address to)
external
override
whenNotPaused // T:[CM-39]
nonReentrant
{
_repayCreditAccountImpl(msg.sender, to); // T:[CM-17]
}
| function repayCreditAccount(address to)
external
override
whenNotPaused // T:[CM-39]
nonReentrant
{
_repayCreditAccountImpl(msg.sender, to); // T:[CM-17]
}
| 6,935 |
113 | // Transfers tokens from a user to the exchange. This function will/be called when a user deposits funds to the exchange./In a simple implementation the funds are simply stored inside the/deposit contract directly. More advanced implementations may store the funds/in some DeFi application to earn interest, so this function could directly/call the necessary functions to store the funds there.//This function needs to throw when an error occurred!//This function can only be called by the exchange.//from The address of the account that sends the tokens./token The address of the token to transfer (`0x0` for ETH)./amount The amount of tokens to transfer./extraData Opaque | function deposit(
address from,
address token,
uint96 amount,
bytes calldata extraData
)
external
payable
returns (uint96 amountReceived);
| function deposit(
address from,
address token,
uint96 amount,
bytes calldata extraData
)
external
payable
returns (uint96 amountReceived);
| 23,950 |
27 | // Emits a {EmergencySet} event. / | function flipEmergencyPool(uint256 poolId) external onlyOwner {
_emergency[poolId] = !_emergency[poolId];
emit EmergencySet(poolId, _emergency[poolId]);
}
| function flipEmergencyPool(uint256 poolId) external onlyOwner {
_emergency[poolId] = !_emergency[poolId];
emit EmergencySet(poolId, _emergency[poolId]);
}
| 30,340 |
7 | // Bouncer will be a hot wallet in our backend without any critical access (e.g: access to funds) If the hot wallet gets compromised, the owner can just change the bouncer without any critical issues. | function setBouncer(address _bouncer) external onlyOwner {
bouncer = _bouncer;
}
| function setBouncer(address _bouncer) external onlyOwner {
bouncer = _bouncer;
}
| 64,009 |
144 | // Token supply - 50 Billion Tokens, with 18 decimal precision | uint256 constant BILLION = 1000000000;
uint256 constant TOKEN_SUPPLY = 50 * BILLION * (10 ** uint256(TOKEN_DECIMALS));
| uint256 constant BILLION = 1000000000;
uint256 constant TOKEN_SUPPLY = 50 * BILLION * (10 ** uint256(TOKEN_DECIMALS));
| 22,125 |
34 | // We don't care about overflow of the addition, because it would require a list larger than any feasible computer's memory. | int256 pivot = list[(lo + hi) / 2];
lo -= 1; // this can underflow. that's intentional.
hi += 1;
while (true) {
do {
lo += 1;
} while (list[lo] < pivot);
| int256 pivot = list[(lo + hi) / 2];
lo -= 1; // this can underflow. that's intentional.
hi += 1;
while (true) {
do {
lo += 1;
} while (list[lo] < pivot);
| 65,832 |
6 | // 80% | borrowCapFactorMantissa = 0.8e18;
| borrowCapFactorMantissa = 0.8e18;
| 20,769 |
0 | // numCoefficients = totalChunks(degree + 1)NOTE: degree + 1 is the number of coefficients | numCoefficients := mul(totalChunks, add(shr(BIT_SHIFT_degree, calldataload(add(header.offset, HEADER_OFFSET_degree))), 1))
| numCoefficients := mul(totalChunks, add(shr(BIT_SHIFT_degree, calldataload(add(header.offset, HEADER_OFFSET_degree))), 1))
| 1,925 |
82 | // Handle the receipt of multiple ERC1155 token types An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updatedThis function MAY throw to revert and reject the transferReturn of other amount than the magic value WILL result in the transaction being revertedNote: The token contract address is always the message sender _operatorThe address which called the `safeBatchTransferFrom` function _fromThe address which previously owned the token _ids An array containing ids of each token being transferred _amounts An array containing amounts of each token being transferred _dataAdditional | function onERC1155BatchReceived(
address _operator,
| function onERC1155BatchReceived(
address _operator,
| 77,417 |
4 | // if the request contains project proposal. | int hasProjectProposal=0;
| int hasProjectProposal=0;
| 12,278 |
49 | // Dungeon run not started yet. | _heroHealth = _heroInitialHealth;
_monsterLevel = 1;
_monsterInitialHealth = monsterHealth;
_monsterHealth = _monsterInitialHealth;
_gameState = 0;
| _heroHealth = _heroInitialHealth;
_monsterLevel = 1;
_monsterInitialHealth = monsterHealth;
_monsterHealth = _monsterInitialHealth;
_gameState = 0;
| 26,464 |
162 | // Maximum number of tokens in the pool | uint public constant MAX_BOUND_TOKENS = 9;
| uint public constant MAX_BOUND_TOKENS = 9;
| 10,308 |
209 | // bytes4(keccak256('name()')) == 0x06fdde03bytes4(keccak256('symbol()')) == 0x95d89b41bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f / | bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
| bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
| 1,099 |
237 | // fire when seller want to update order price, selling method, fee | event OrderUpdate(address operator, uint128 indexed orderId);
| event OrderUpdate(address operator, uint128 indexed orderId);
| 14,776 |
32 | // Returns the symbol of the token, usually a shorter version of thename. / | function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| function symbol() public view virtual override returns (string memory) {
return _symbol;
}
| 139 |
22 | // To facilitate the process of constructing salary system, we need an address that could execute `newPacakge`._helperAddress the address that is to be assigned as a helper/ | function setHelper(address _helperAddress) external onlyAdmin {
helperAddressTable[_helperAddress] = true;
}
| function setHelper(address _helperAddress) external onlyAdmin {
helperAddressTable[_helperAddress] = true;
}
| 18,889 |
12 | // subscription queue size: should be power of 10 / | uint constant QMAX = 1000;
| uint constant QMAX = 1000;
| 44,758 |
93 | // Pause submitting loans for rating status Flag of the status / | function pauseSubmissions(bool status) public onlyOwner {
submissionPauseStatus = status;
emit SubmissionPauseStatusChanged(status);
}
| function pauseSubmissions(bool status) public onlyOwner {
submissionPauseStatus = status;
emit SubmissionPauseStatusChanged(status);
}
| 17,544 |
168 | // Approve the metapool LP tokens for the vault contract | metapool_token.approve(tc_address, metapool_lp_in);
| metapool_token.approve(tc_address, metapool_lp_in);
| 57,713 |
93 | // Order must have a maker. / | if (order.maker == address(0)) {
return false;
}
| if (order.maker == address(0)) {
return false;
}
| 41,952 |
104 | // See {ERC20-_burn} and {ERC20-allowance}. Requirements: - the caller must have allowance for `accounts`'s tokens of at least`amount`. / | function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
| function burnFrom(address account, uint256 amount) public virtual {
uint256 decreasedAllowance = allowance(account, _msgSender()).sub(amount, "ERC20: burn amount exceeds allowance");
_approve(account, _msgSender(), decreasedAllowance);
_burn(account, amount);
}
| 9,820 |
95 | // Owner events |
event SetOperator(address operator, bool enable);
event SetMiningFactor(uint8 miningFactor);
event SetTreasury(address treasury);
event SetLonStaking(address lonStaking);
event SetMiningTreasury(address miningTreasury);
event SetFeeTokenRecipient(address feeTokenRecipient);
|
event SetOperator(address operator, bool enable);
event SetMiningFactor(uint8 miningFactor);
event SetTreasury(address treasury);
event SetLonStaking(address lonStaking);
event SetMiningTreasury(address miningTreasury);
event SetFeeTokenRecipient(address feeTokenRecipient);
| 382 |
74 | // Migrates initial list of transfer agents transferAgents List of addresses to grant TRANSFER_AGENT role to | * @dev - Emits {RoleGranted} events
*
* Can only be called:
* - by ScalingFunds agents
* - BEFORE token has launched
*/
function migrateTransferAgents(address[] calldata transferAgents)
external
onlyScalingFundsAgent
onlyBeforeLaunch
{
for (uint256 i = 0; i < transferAgents.length; i++) {
super._setupRole(TRANSFER_AGENT, transferAgents[i]);
}
}
| * @dev - Emits {RoleGranted} events
*
* Can only be called:
* - by ScalingFunds agents
* - BEFORE token has launched
*/
function migrateTransferAgents(address[] calldata transferAgents)
external
onlyScalingFundsAgent
onlyBeforeLaunch
{
for (uint256 i = 0; i < transferAgents.length; i++) {
super._setupRole(TRANSFER_AGENT, transferAgents[i]);
}
}
| 14,501 |
41 | // Aqua Sale Smart contract | contract AquaSale is Owned {
using SafeMath for uint256;
uint256 constant ONE_HUNDRED = 100;
//Internal state
mapping (address => uint) internal buyerBalances;
//Public interface
///Team trust account address
address public teamTrustAccount;
///Team share of total token supply after successful completion of the
///crowdsale expressed as whole percentage number (0-100)
uint public teamSharePercent;
///Low funding goal (Soft Cap) in number of tokens
uint public lowTokensToSellGoal;
///High funding goal (Hard Cap) in number of tokens
uint public highTokensToSellGoal;
///Number of tokens sold
uint public soldTokens;
///Crowdsale start time (in seconds since unix epoch)
uint public startTime;
///Crowdsale end time (in seconds since unix epoch)
uint public deadline;
///Address of Aqua Token used as a reward for Ether contributions
Token public tokenReward;
///Aqua Token price oracle contract address
AquaPriceOracle public tokenPriceOracle;
///Indicates if funding goal is reached (crowdsale is successful)
bool public fundingGoalReached = false;
///Indicates if high funding goal (Hard Cap) is reached.
bool public highFundingGoalReached = false;
///Event is triggered when funding goal is reached
///@param amntRaisedWei Amount raised in Wei
///@param isHigherGoal True if Hard Cap is reached. False if Soft Cap is reached
event GoalReached(uint amntRaisedWei, bool isHigherGoal);
///Event is triggered when crowdsale contract processes funds transfer
///(contribution or withdrawal)
///@param backer Account address that sends (in case of contribution) or receives (in case of refund or withdrawal) funds
///@param isContribution True in case funds transfer is a contribution. False in case funds transfer is a refund or a withdrawal.
event FundsTransfer(address backer, uint amount, bool isContribution);
///Constructor initializes Aqua Sale contract
///@param ifSuccessfulSendTo Beneficiary address – account address that can withdraw raised funds in case crowdsale succeeds
///@param _lowTokensToSellGoal Low funding goal (Soft Cap) as number of tokens to sell
///@param _highTokensToSellGoal High funding goal (Hard Cap) as number of tokens to sell
///@param startAfterMinutes Crowdsale start time as the number of minutes since contract deployment time
///@param durationInMinutes Duration of the crowdsale in minutes
///@param addressOfTokenUsedAsReward Aqua Token smart contract address
///@param addressOfTokenPriceOracle Aqua Price oracle smart contract address
///@param addressOfTeamTrusAccount Account address that receives team share of tokens upon successful completion of crowdsale
///@param _teamSharePercent Team share of total token supply after successful completion of the crowdsale expressed as whole percentage number (0-100)
function AquaSale(
address ifSuccessfulSendTo,
uint _lowTokensToSellGoal,
uint _highTokensToSellGoal,
uint startAfterMinutes,
uint durationInMinutes,
address addressOfTokenUsedAsReward,
address addressOfTokenPriceOracle,
address addressOfTeamTrusAccount,
uint _teamSharePercent
) public {
owner = ifSuccessfulSendTo;
lowTokensToSellGoal = _lowTokensToSellGoal;
highTokensToSellGoal = _highTokensToSellGoal;
startTime = now.add(startAfterMinutes.mul(1 minutes));
deadline = startTime.add(durationInMinutes.mul(1 minutes));
tokenReward = Token(addressOfTokenUsedAsReward);
tokenPriceOracle = AquaPriceOracle(addressOfTokenPriceOracle);
teamTrustAccount = addressOfTeamTrusAccount;
teamSharePercent = _teamSharePercent;
}
///Returns balance of the buyer
///@param _buyer address of crowdsale participant
///@return Buyer balance in wei
function buyerBalance(address _buyer) public constant returns(uint) {
return buyerBalances[_buyer];
}
///Fallback function expects that the sent amount is payment for tokens
function () public payable {
purchaseTokens();
}
///function accepts Ether and allocates Aqua Tokens to the sender
function purchaseTokens() public payable {
require(!highFundingGoalReached && now >= startTime );
uint amount = msg.value;
uint noTokens = amount.div(
tokenPriceOracle.getAquaTokenAudCentsPrice().mul(tokenPriceOracle.getAudCentWeiPrice())
);
buyerBalances[msg.sender] = buyerBalances[msg.sender].add(amount);
soldTokens = soldTokens.add(noTokens);
checkGoalsReached();
tokenReward.transfer(msg.sender, noTokens);
FundsTransfer(msg.sender, amount, true);
}
///Investors should call this function in order to receive refund in
///case crowdsale is not successful.
///The sending address should be the same address that was used to
///participate in crowdsale. The amount will be refunded to this address
function refund() public {
require(!fundingGoalReached && buyerBalances[msg.sender] > 0
&& now >= deadline);
uint amount = buyerBalances[msg.sender];
buyerBalances[msg.sender] = 0;
msg.sender.transfer(amount);
FundsTransfer(msg.sender, amount, false);
}
///iAqua authorized sttaff will call this function to withdraw contributed
///amount (only in case crowdsale is successful)
function withdraw() onlyOwner public {
require( (fundingGoalReached && now >= deadline) || highFundingGoalReached );
uint raisedFunds = this.balance;
uint teamTokens = soldTokens.mul(teamSharePercent).div(ONE_HUNDRED.sub(teamSharePercent));
uint totalTokens = tokenReward.totalSupply();
if (totalTokens < teamTokens.add(soldTokens)) {
teamTokens = totalTokens.sub(soldTokens);
}
tokenReward.transfer(teamTrustAccount, teamTokens);
uint distributedTokens = teamTokens.add(soldTokens);
if (totalTokens > distributedTokens) {
tokenReward.burn(totalTokens.sub(distributedTokens));
}
tokenReward.startTrading();
Owned(address(tokenReward)).transferOwnership(owner);
owner.transfer(raisedFunds);
FundsTransfer(owner, raisedFunds, false);
}
//Internal functions
function checkGoalsReached() internal {
if (fundingGoalReached) {
if (highFundingGoalReached) {
return;
}
if (soldTokens >= highTokensToSellGoal) {
highFundingGoalReached = true;
GoalReached(this.balance, true);
return;
}
}
else {
if (soldTokens >= lowTokensToSellGoal) {
fundingGoalReached = true;
GoalReached(this.balance, false);
}
if (soldTokens >= highTokensToSellGoal) {
highFundingGoalReached = true;
GoalReached(this.balance, true);
return;
}
}
}
} | contract AquaSale is Owned {
using SafeMath for uint256;
uint256 constant ONE_HUNDRED = 100;
//Internal state
mapping (address => uint) internal buyerBalances;
//Public interface
///Team trust account address
address public teamTrustAccount;
///Team share of total token supply after successful completion of the
///crowdsale expressed as whole percentage number (0-100)
uint public teamSharePercent;
///Low funding goal (Soft Cap) in number of tokens
uint public lowTokensToSellGoal;
///High funding goal (Hard Cap) in number of tokens
uint public highTokensToSellGoal;
///Number of tokens sold
uint public soldTokens;
///Crowdsale start time (in seconds since unix epoch)
uint public startTime;
///Crowdsale end time (in seconds since unix epoch)
uint public deadline;
///Address of Aqua Token used as a reward for Ether contributions
Token public tokenReward;
///Aqua Token price oracle contract address
AquaPriceOracle public tokenPriceOracle;
///Indicates if funding goal is reached (crowdsale is successful)
bool public fundingGoalReached = false;
///Indicates if high funding goal (Hard Cap) is reached.
bool public highFundingGoalReached = false;
///Event is triggered when funding goal is reached
///@param amntRaisedWei Amount raised in Wei
///@param isHigherGoal True if Hard Cap is reached. False if Soft Cap is reached
event GoalReached(uint amntRaisedWei, bool isHigherGoal);
///Event is triggered when crowdsale contract processes funds transfer
///(contribution or withdrawal)
///@param backer Account address that sends (in case of contribution) or receives (in case of refund or withdrawal) funds
///@param isContribution True in case funds transfer is a contribution. False in case funds transfer is a refund or a withdrawal.
event FundsTransfer(address backer, uint amount, bool isContribution);
///Constructor initializes Aqua Sale contract
///@param ifSuccessfulSendTo Beneficiary address – account address that can withdraw raised funds in case crowdsale succeeds
///@param _lowTokensToSellGoal Low funding goal (Soft Cap) as number of tokens to sell
///@param _highTokensToSellGoal High funding goal (Hard Cap) as number of tokens to sell
///@param startAfterMinutes Crowdsale start time as the number of minutes since contract deployment time
///@param durationInMinutes Duration of the crowdsale in minutes
///@param addressOfTokenUsedAsReward Aqua Token smart contract address
///@param addressOfTokenPriceOracle Aqua Price oracle smart contract address
///@param addressOfTeamTrusAccount Account address that receives team share of tokens upon successful completion of crowdsale
///@param _teamSharePercent Team share of total token supply after successful completion of the crowdsale expressed as whole percentage number (0-100)
function AquaSale(
address ifSuccessfulSendTo,
uint _lowTokensToSellGoal,
uint _highTokensToSellGoal,
uint startAfterMinutes,
uint durationInMinutes,
address addressOfTokenUsedAsReward,
address addressOfTokenPriceOracle,
address addressOfTeamTrusAccount,
uint _teamSharePercent
) public {
owner = ifSuccessfulSendTo;
lowTokensToSellGoal = _lowTokensToSellGoal;
highTokensToSellGoal = _highTokensToSellGoal;
startTime = now.add(startAfterMinutes.mul(1 minutes));
deadline = startTime.add(durationInMinutes.mul(1 minutes));
tokenReward = Token(addressOfTokenUsedAsReward);
tokenPriceOracle = AquaPriceOracle(addressOfTokenPriceOracle);
teamTrustAccount = addressOfTeamTrusAccount;
teamSharePercent = _teamSharePercent;
}
///Returns balance of the buyer
///@param _buyer address of crowdsale participant
///@return Buyer balance in wei
function buyerBalance(address _buyer) public constant returns(uint) {
return buyerBalances[_buyer];
}
///Fallback function expects that the sent amount is payment for tokens
function () public payable {
purchaseTokens();
}
///function accepts Ether and allocates Aqua Tokens to the sender
function purchaseTokens() public payable {
require(!highFundingGoalReached && now >= startTime );
uint amount = msg.value;
uint noTokens = amount.div(
tokenPriceOracle.getAquaTokenAudCentsPrice().mul(tokenPriceOracle.getAudCentWeiPrice())
);
buyerBalances[msg.sender] = buyerBalances[msg.sender].add(amount);
soldTokens = soldTokens.add(noTokens);
checkGoalsReached();
tokenReward.transfer(msg.sender, noTokens);
FundsTransfer(msg.sender, amount, true);
}
///Investors should call this function in order to receive refund in
///case crowdsale is not successful.
///The sending address should be the same address that was used to
///participate in crowdsale. The amount will be refunded to this address
function refund() public {
require(!fundingGoalReached && buyerBalances[msg.sender] > 0
&& now >= deadline);
uint amount = buyerBalances[msg.sender];
buyerBalances[msg.sender] = 0;
msg.sender.transfer(amount);
FundsTransfer(msg.sender, amount, false);
}
///iAqua authorized sttaff will call this function to withdraw contributed
///amount (only in case crowdsale is successful)
function withdraw() onlyOwner public {
require( (fundingGoalReached && now >= deadline) || highFundingGoalReached );
uint raisedFunds = this.balance;
uint teamTokens = soldTokens.mul(teamSharePercent).div(ONE_HUNDRED.sub(teamSharePercent));
uint totalTokens = tokenReward.totalSupply();
if (totalTokens < teamTokens.add(soldTokens)) {
teamTokens = totalTokens.sub(soldTokens);
}
tokenReward.transfer(teamTrustAccount, teamTokens);
uint distributedTokens = teamTokens.add(soldTokens);
if (totalTokens > distributedTokens) {
tokenReward.burn(totalTokens.sub(distributedTokens));
}
tokenReward.startTrading();
Owned(address(tokenReward)).transferOwnership(owner);
owner.transfer(raisedFunds);
FundsTransfer(owner, raisedFunds, false);
}
//Internal functions
function checkGoalsReached() internal {
if (fundingGoalReached) {
if (highFundingGoalReached) {
return;
}
if (soldTokens >= highTokensToSellGoal) {
highFundingGoalReached = true;
GoalReached(this.balance, true);
return;
}
}
else {
if (soldTokens >= lowTokensToSellGoal) {
fundingGoalReached = true;
GoalReached(this.balance, false);
}
if (soldTokens >= highTokensToSellGoal) {
highFundingGoalReached = true;
GoalReached(this.balance, true);
return;
}
}
}
} | 51,199 |
31 | // Determine asset supplied (use Etherizer for Ether) and ether value. | ERC20Interface assetToSupply;
uint256 etherValue;
if (args.assetToSupply == address(0)) {
assetToSupply = _ETHERIZER;
etherValue = executionArgs.amountToSupply;
} else {
| ERC20Interface assetToSupply;
uint256 etherValue;
if (args.assetToSupply == address(0)) {
assetToSupply = _ETHERIZER;
etherValue = executionArgs.amountToSupply;
} else {
| 34,595 |
7 | // A record of voting checkpoints for each account, by index. | mapping(address => mapping(uint256 => Checkpoint)) public checkpoints;
| mapping(address => mapping(uint256 => Checkpoint)) public checkpoints;
| 79,595 |
27 | // Reset values of pending (Transaction object) / | function abortTransaction() external onlyAdmin{
ResetTransferState();
}
| function abortTransaction() external onlyAdmin{
ResetTransferState();
}
| 46,750 |
169 | // Proposed flash mint fee percentage is too big./feePercentage Proposed flash mint fee percentage. | error FlashFeePercentageTooBig(uint256 feePercentage);
| error FlashFeePercentageTooBig(uint256 feePercentage);
| 20,034 |
1 | // These are all the places you can go search for loot | enum Places {
TOWN, DUNGEON, CRYPT, CASTLE, DRAGONS_LAIR, THE_ETHER,
TAINTED_KINGDOM, OOZING_DEN, ANCIENT_CHAMBER, ORC_GODS
}
| enum Places {
TOWN, DUNGEON, CRYPT, CASTLE, DRAGONS_LAIR, THE_ETHER,
TAINTED_KINGDOM, OOZING_DEN, ANCIENT_CHAMBER, ORC_GODS
}
| 13,555 |
6 | // MODIFIER requires the contract to be not paused | modifier isPaused() {
require(!statusPause, "Contract has been paused");
_;
}
| modifier isPaused() {
require(!statusPause, "Contract has been paused");
_;
}
| 13,271 |
43 | // Returns the admin role that controls `role`. See {grantRole} and{revokeRole}. To change a role's admin, use {_setRoleAdmin}. / | function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
| function getRoleAdmin(bytes32 role) public view returns (bytes32) {
return _roles[role].adminRole;
}
| 874 |
106 | // First withdraw all rewards, than withdarw it all, then stake back the remaining. / | function withdraw(uint256 amount) external override virtual returns (bool) {
address _staker = msg.sender;
return _withdraw(_staker, amount);
}
| function withdraw(uint256 amount) external override virtual returns (bool) {
address _staker = msg.sender;
return _withdraw(_staker, amount);
}
| 73,017 |
209 | // Set the referrer. | burnupHolding.setReferrer(msg.sender, referrerAddress);
| burnupHolding.setReferrer(msg.sender, referrerAddress);
| 14,165 |
212 | // Withdraw tokens amount_ amount of internal token to burn / | function _withdraw (
uint256 amount_,
uint256[N_TOKENS] memory outAmounts_
)
internal
| function _withdraw (
uint256 amount_,
uint256[N_TOKENS] memory outAmounts_
)
internal
| 31,369 |
123 | // Emits a {UnlockLP} event. Parameters:- `isInvestor` whether caller is project party or investor Returns:- `availableTimes` is frequency times to unlock- `amount` is lp amount to unlock/ | function getUnlockLPAmount(bool isInvestor, address user) public view returns (uint256 availableTimes, uint256 amount) {
require(lpUnlockStartTimestamp > 0, "add liquidity not finished");
uint256 totalTimes = 0;
if (block.timestamp > lpUnlockStartTimestamp.add(lpLockPeriod)){
totalTimes = lpLockPeriod.div(lpUnlockFrequency);
}else{
| function getUnlockLPAmount(bool isInvestor, address user) public view returns (uint256 availableTimes, uint256 amount) {
require(lpUnlockStartTimestamp > 0, "add liquidity not finished");
uint256 totalTimes = 0;
if (block.timestamp > lpUnlockStartTimestamp.add(lpLockPeriod)){
totalTimes = lpLockPeriod.div(lpUnlockFrequency);
}else{
| 41,729 |
1 | // no decimals, ensure we preserve all trailing zeros | params.sigfigs = number / tenPowDecimals;
params.sigfigIndex = digits - decimals;
params.bufferLength = params.sigfigIndex;
| params.sigfigs = number / tenPowDecimals;
params.sigfigIndex = digits - decimals;
params.bufferLength = params.sigfigIndex;
| 8,030 |
32 | // Resets the list of Tokens on the allowlist / | function unsetTokenAllowlist() external adminRequired {
delete allowedTokens;
}
| function unsetTokenAllowlist() external adminRequired {
delete allowedTokens;
}
| 18,811 |
222 | // remove dust | if (address(this).balance > 0) {
etherPools[0].transfer(address(this).balance);
}
| if (address(this).balance > 0) {
etherPools[0].transfer(address(this).balance);
}
| 7,104 |
107 | // Step 2 | function setUpPoolPair(
address addressOfProjectToken,
string memory tokenName_,
string memory tokenSymbol_,
uint totalTokenSupply_,
uint48 startTime_,
uint48 endTime_
| function setUpPoolPair(
address addressOfProjectToken,
string memory tokenName_,
string memory tokenSymbol_,
uint totalTokenSupply_,
uint48 startTime_,
uint48 endTime_
| 21,897 |
0 | // Data for migration--------------------------------- main storage contract (for current version queue style) that stores checkpoints | StorageCheckpointRegistryV2 public v2storage;
| StorageCheckpointRegistryV2 public v2storage;
| 15,429 |
25 | // Make sure the coin exists |
confirmTokenExists(_tokenId);
|
confirmTokenExists(_tokenId);
| 49,552 |
46 | // allows withdrawal of ETH in case it was sent by accident _beneficiary address where to send the eth. / | function drainEth(address payable _beneficiary) external;
| function drainEth(address payable _beneficiary) external;
| 18,160 |
51 | // substr with length / | contract TestBytesSubstrWithLen is BytesTest {
function testImpl() internal {
bytes memory bts = hex"8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeffaabb";
var cpy = bts.substr(7, 12);
var sdp = Memory.dataPtr(bts);
var cdp = Memory.dataPtr(cpy);
assert(cpy.length == 12);
assert(Memory.equals(sdp + 7, cdp, 12));
}
}
| contract TestBytesSubstrWithLen is BytesTest {
function testImpl() internal {
bytes memory bts = hex"8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeff8899aabbccddeeffaabb";
var cpy = bts.substr(7, 12);
var sdp = Memory.dataPtr(bts);
var cdp = Memory.dataPtr(cpy);
assert(cpy.length == 12);
assert(Memory.equals(sdp + 7, cdp, 12));
}
}
| 43,267 |
0 | // Transfers a token and returns if it was a success/token Token that should be transferred/receiver Receiver to whom the token should be transferred/amount The amount of tokens that should be transferred | function transferToken(
address token,
address receiver,
uint256 amount
| function transferToken(
address token,
address receiver,
uint256 amount
| 20,381 |
61 | // Modifier to make a function callable only when the contract is paused./ | modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
| modifier whenPaused() {
require(_paused, "Pausable: not paused");
_;
}
| 31,070 |
2 | // Triggers stopped state. / | function pause() external onlyRole(ADMIN_ROLE) {
_pause();
}
| function pause() external onlyRole(ADMIN_ROLE) {
_pause();
}
| 22,920 |
56 | // Calculate the amount of FPI needed to be sold in order to reach the target FPI price | fpi_to_use = getTwammToPegAmt(true);
| fpi_to_use = getTwammToPegAmt(true);
| 41,620 |
170 | // Array position not initialized, so use position | indices[index] = totalSize - 1;
| indices[index] = totalSize - 1;
| 19,529 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.