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
|
|---|---|---|---|---|
434
|
// Withdraw underlying asset/Only vault contract can withdraw underlying asset/to Withdraw address/scale Withdraw percentage
|
function withdrawOfUnderlying(address to, uint256 scale) external onlyVault {
uint256 length = underlyings.length();
uint256[] memory balances = new uint256[](length);
uint256[] memory withdrawAmounts = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
balances[i] = balance;
withdrawAmounts[i] = balance.mul(scale).div(1e18);
}
_decreaseLiquidityByScale(scale);
for (uint256 i = 0; i < length; i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
uint256 decreaseAmount = balance.sub(balances[i]);
uint256 addAmount = decreaseAmount.mul(scale).div(1e18);
uint256 transferAmount = withdrawAmounts[i].add(addAmount);
IERC20(token).safeTransfer(to, transferAmount);
}
}
|
function withdrawOfUnderlying(address to, uint256 scale) external onlyVault {
uint256 length = underlyings.length();
uint256[] memory balances = new uint256[](length);
uint256[] memory withdrawAmounts = new uint256[](length);
for (uint256 i = 0; i < length; i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
balances[i] = balance;
withdrawAmounts[i] = balance.mul(scale).div(1e18);
}
_decreaseLiquidityByScale(scale);
for (uint256 i = 0; i < length; i++) {
address token = underlyings.at(i);
uint256 balance = IERC20(token).balanceOf(address(this));
uint256 decreaseAmount = balance.sub(balances[i]);
uint256 addAmount = decreaseAmount.mul(scale).div(1e18);
uint256 transferAmount = withdrawAmounts[i].add(addAmount);
IERC20(token).safeTransfer(to, transferAmount);
}
}
| 10,703
|
15
|
// authorizers[_addr] = false;
|
delete authorizers[_addr];
|
delete authorizers[_addr];
| 32,390
|
25
|
// This is a hot address with a current record - add on the balances held natively by this address and the cold:
|
balance_ += (IERC721(tokenContract_).balanceOf(queryAddress_));
address cold = hotToRecord[queryAddress_].cold;
balance_ += IERC721(tokenContract_).balanceOf(cold);
|
balance_ += (IERC721(tokenContract_).balanceOf(queryAddress_));
address cold = hotToRecord[queryAddress_].cold;
balance_ += IERC721(tokenContract_).balanceOf(cold);
| 8,133
|
15
|
// No backward transition, only AskIssuer or Revoked
|
if (status > value.status) {
if (status == Status.AskIssuer || status == Status.Revoked) {
value.exists = true;
value.status = status;
emit IssuerCredentialRevoked(issuerCredentialHash, status);
}
|
if (status > value.status) {
if (status == Status.AskIssuer || status == Status.Revoked) {
value.exists = true;
value.status = status;
emit IssuerCredentialRevoked(issuerCredentialHash, status);
}
| 39,397
|
71
|
// Add logic to create metadata here.
|
_totalSupply += 1;
_safeMint(to, _totalSupply);
generateMetadata(to, _totalSupply, password); //Using password for metadata seed can add more fairness.
|
_totalSupply += 1;
_safeMint(to, _totalSupply);
generateMetadata(to, _totalSupply, password); //Using password for metadata seed can add more fairness.
| 15,754
|
1,206
|
// are only specific to this lottery type.
|
uint32 constant MIN_MINER_PROFITS = 1 * PERCENT;
uint32 constant MAX_MINER_PROFITS = 10 * PERCENT;
|
uint32 constant MIN_MINER_PROFITS = 1 * PERCENT;
uint32 constant MAX_MINER_PROFITS = 10 * PERCENT;
| 4,806
|
0
|
// DomainManager creator gets full access by default
|
__erc721.setApprovalForAll(msg.sender, true);
|
__erc721.setApprovalForAll(msg.sender, true);
| 48,282
|
130
|
// The number One in precise units.
|
uint256 constant internal PRECISE_UNIT = 10 ** 18;
int256 constant internal PRECISE_UNIT_INT = 10 ** 18;
|
uint256 constant internal PRECISE_UNIT = 10 ** 18;
int256 constant internal PRECISE_UNIT_INT = 10 ** 18;
| 10,379
|
19
|
// Transfers multiple amounts of tokens from an account to multiple recipients.
|
/// @dev Note: This function implements {ERC20BatchTransfers-batchTransfer(address[],uint256[])}.
/// @dev Reverts if `recipients` and `values` have different lengths.
/// @dev Reverts if one of `recipients` is the zero address.
/// @dev Reverts if `from` does not have at least `sum(values)` of balance.
/// @dev Emits a {Transfer} event for each transfer.
/// @param from The account transferring the tokens.
/// @param recipients The list of accounts to transfer the tokens to.
/// @param values The list of amounts of tokens to transfer to each of `recipients`.
function batchTransfer(Layout storage s, address from, address[] calldata recipients, uint256[] calldata values) internal {
uint256 length = recipients.length;
require(length == values.length, "ERC20: inconsistent arrays");
if (length == 0) return;
uint256 balance = s.balances[from];
uint256 totalValue;
uint256 selfTransferTotalValue;
unchecked {
for (uint256 i; i != length; ++i) {
address to = recipients[i];
require(to != address(0), "ERC20: transfer to address(0)");
uint256 value = values[i];
if (value != 0) {
uint256 newTotalValue = totalValue + value;
require(newTotalValue > totalValue, "ERC20: values overflow");
totalValue = newTotalValue;
if (from != to) {
s.balances[to] += value;
} else {
require(value <= balance, "ERC20: insufficient balance");
selfTransferTotalValue += value; // cannot overflow as 'selfTransferTotalValue <= totalValue' is always true
}
}
emit Transfer(from, to, value);
}
if (totalValue != 0 && totalValue != selfTransferTotalValue) {
uint256 newBalance = balance - totalValue;
require(newBalance < balance, "ERC20: insufficient balance"); // balance must be sufficient, including self-transfers
s.balances[from] = newBalance + selfTransferTotalValue; // do not deduct self-transfers from the sender balance
}
}
}
|
/// @dev Note: This function implements {ERC20BatchTransfers-batchTransfer(address[],uint256[])}.
/// @dev Reverts if `recipients` and `values` have different lengths.
/// @dev Reverts if one of `recipients` is the zero address.
/// @dev Reverts if `from` does not have at least `sum(values)` of balance.
/// @dev Emits a {Transfer} event for each transfer.
/// @param from The account transferring the tokens.
/// @param recipients The list of accounts to transfer the tokens to.
/// @param values The list of amounts of tokens to transfer to each of `recipients`.
function batchTransfer(Layout storage s, address from, address[] calldata recipients, uint256[] calldata values) internal {
uint256 length = recipients.length;
require(length == values.length, "ERC20: inconsistent arrays");
if (length == 0) return;
uint256 balance = s.balances[from];
uint256 totalValue;
uint256 selfTransferTotalValue;
unchecked {
for (uint256 i; i != length; ++i) {
address to = recipients[i];
require(to != address(0), "ERC20: transfer to address(0)");
uint256 value = values[i];
if (value != 0) {
uint256 newTotalValue = totalValue + value;
require(newTotalValue > totalValue, "ERC20: values overflow");
totalValue = newTotalValue;
if (from != to) {
s.balances[to] += value;
} else {
require(value <= balance, "ERC20: insufficient balance");
selfTransferTotalValue += value; // cannot overflow as 'selfTransferTotalValue <= totalValue' is always true
}
}
emit Transfer(from, to, value);
}
if (totalValue != 0 && totalValue != selfTransferTotalValue) {
uint256 newBalance = balance - totalValue;
require(newBalance < balance, "ERC20: insufficient balance"); // balance must be sufficient, including self-transfers
s.balances[from] = newBalance + selfTransferTotalValue; // do not deduct self-transfers from the sender balance
}
}
}
| 42,000
|
15
|
// Interface of the registry of verified users. /
|
interface IUserRegistry {
function isVerifiedUser(address _user) external view returns (bool);
}
|
interface IUserRegistry {
function isVerifiedUser(address _user) external view returns (bool);
}
| 53,202
|
78
|
// Allows owner, factory or permissioned delegate
|
modifier withPerm(bytes32 _perm) {
bool isOwner = msg.sender == ISecurityToken(securityToken).owner();
bool isFactory = msg.sender == factory;
require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed");
_;
}
|
modifier withPerm(bytes32 _perm) {
bool isOwner = msg.sender == ISecurityToken(securityToken).owner();
bool isFactory = msg.sender == factory;
require(isOwner||isFactory||ISecurityToken(securityToken).checkPermission(msg.sender, address(this), _perm), "Permission check failed");
_;
}
| 38,402
|
75
|
// Withdraw assets./ @inheritdoc IStrategy
|
function withdraw(uint256 amount) external override onlyBentobox returns (uint256 actualAmount) {
// Convert enough cToken to take out 'amount' tokens
require(cToken.redeemUnderlying(amount) == 0, "CompoundStrategy: redeem fail");
// Make sure we send and report the exact same amount of tokens by using balanceOf
actualAmount = token.balanceOf(address(this));
token.safeTransfer(bentobox, actualAmount);
}
|
function withdraw(uint256 amount) external override onlyBentobox returns (uint256 actualAmount) {
// Convert enough cToken to take out 'amount' tokens
require(cToken.redeemUnderlying(amount) == 0, "CompoundStrategy: redeem fail");
// Make sure we send and report the exact same amount of tokens by using balanceOf
actualAmount = token.balanceOf(address(this));
token.safeTransfer(bentobox, actualAmount);
}
| 20,851
|
101
|
// Low level withdraw function
|
function _withdraw(
uint256 _pid,
uint256 _amount,
address from,
address to
|
function _withdraw(
uint256 _pid,
uint256 _amount,
address from,
address to
| 45,337
|
100
|
// record new holder to auxiliary structure
|
if (0 == balances[_to]) {
m_holders.push(_to);
}
|
if (0 == balances[_to]) {
m_holders.push(_to);
}
| 25,995
|
4
|
// Daddy can grant and revoke access to the setter
|
address internal constant gov = 0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52;
|
address internal constant gov = 0xFEB4acf3df3cDEA7399794D0869ef76A6EfAff52;
| 65,984
|
760
|
// LIQUIDATION FUNCTIONS// Liquidates the sponsor's position if the caller has enoughsynthetic tokens to retire the position's outstanding tokens. Liquidations abovea minimum size also reset an ongoing "slow withdrawal"'s liveness. This method generates an ID that will uniquely identify liquidation for the sponsor. This contract must beapproved to spend at least `tokensLiquidated` of `tokenCurrency` and at least `finalFeeBond` of `collateralCurrency`. This contract must have the Burner role for the `tokenCurrency`. sponsor address of the sponsor to liquidate. minCollateralPerToken abort the liquidation if the position's collateral per token is below this value. maxCollateralPerToken abort the liquidation if the position's collateral per token
|
function createLiquidation(
address sponsor,
FixedPoint.Unsigned calldata minCollateralPerToken,
FixedPoint.Unsigned calldata maxCollateralPerToken,
FixedPoint.Unsigned calldata maxTokensToLiquidate,
uint256 deadline
)
external
fees()
onlyPreExpiration()
|
function createLiquidation(
address sponsor,
FixedPoint.Unsigned calldata minCollateralPerToken,
FixedPoint.Unsigned calldata maxCollateralPerToken,
FixedPoint.Unsigned calldata maxTokensToLiquidate,
uint256 deadline
)
external
fees()
onlyPreExpiration()
| 17,537
|
8
|
// confirm block is deep enough in blockchain on bridge
|
bytes32 hash;
uint24 depth;
(hash, depth) = bridge.getBlockByNumber(blockNumber);
require(hash == blockHash, "block hash didn't match block for number");
require(depth >= BLOCK_DEPTH_REQUIRED, "block not deep enough in chain");
|
bytes32 hash;
uint24 depth;
(hash, depth) = bridge.getBlockByNumber(blockNumber);
require(hash == blockHash, "block hash didn't match block for number");
require(depth >= BLOCK_DEPTH_REQUIRED, "block not deep enough in chain");
| 14,846
|
376
|
// same interface for uniswap and sushiswap
|
(, , lpTokens) = investB(
address(usdc),
address(bond),
usdcAmount,
bondAmount
);
|
(, , lpTokens) = investB(
address(usdc),
address(bond),
usdcAmount,
bondAmount
);
| 42,006
|
150
|
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but we allocate 0x80 bytes to keep the free memory pointer 32-byte word aliged. We will need 1 32-byte word to store the length, and 3 32-byte words to store a maximum of 78 digits. Total: 0x20 + 30x20 = 0x80.
|
str := add(mload(0x40), 0x80)
|
str := add(mload(0x40), 0x80)
| 18,333
|
40
|
// Claimable Ex Extension for the Claimable contract, where the ownership transfer can be canceled. /
|
contract ClaimableEx is Claimable {
/*
* @dev Cancels the ownership transfer.
*/
function cancelOwnershipTransfer() onlyOwner public {
pendingOwner = owner;
}
}
|
contract ClaimableEx is Claimable {
/*
* @dev Cancels the ownership transfer.
*/
function cancelOwnershipTransfer() onlyOwner public {
pendingOwner = owner;
}
}
| 10,909
|
6
|
// Map address to Voter/
|
mapping(address => Voter) voters;
|
mapping(address => Voter) voters;
| 29,738
|
37
|
// Converts a given reserve amount to the regular (staked) number space. reserveAmount The specified reserve amountreturn uint256 The reserve amount in terms of its staked number space /
|
function convertToStaked(uint256 reserveAmount) public view override returns (uint256) {
uint256 currentRate = eternalStorage.getUint(entity, reserveStakedBalances) / eternalStorage.getUint(entity, totalStakedBalances);
return reserveAmount / currentRate;
}
|
function convertToStaked(uint256 reserveAmount) public view override returns (uint256) {
uint256 currentRate = eternalStorage.getUint(entity, reserveStakedBalances) / eternalStorage.getUint(entity, totalStakedBalances);
return reserveAmount / currentRate;
}
| 7,251
|
2
|
// [0] creator, [1] operator, [2] transferringOperator, [3] governor, [4] shareToken, [5] collateralToken, [6] vault,
|
address[7] memory addresses,
|
address[7] memory addresses,
| 16,701
|
10
|
// Update process state and emit an event
|
process.state = State.AWAITING_TERMINATION;
emit Deposit(sender, process.service, process.productId, msg.value);
|
process.state = State.AWAITING_TERMINATION;
emit Deposit(sender, process.service, process.productId, msg.value);
| 24,695
|
150
|
// Public Admin Functions//Actvates, or 'starts', the contract. Emits the `Started` event. Emits the `Unpaused` event. Reverts if called by any other than the contract owner. Reverts if the contract has already been started. Reverts if the contract is not paused. /
|
function start() public virtual onlyOwner {
_start();
_unpause();
}
|
function start() public virtual onlyOwner {
_start();
_unpause();
}
| 44,613
|
216
|
// Create SDVD ETH pair
|
sdvdEthPairAddress = IUniswapV2Factory(uniswapRouter.factory()).createPair(sdvd, weth);
|
sdvdEthPairAddress = IUniswapV2Factory(uniswapRouter.factory()).createPair(sdvd, weth);
| 80,697
|
19
|
// Structure of a buy request done by a user for buying a product from a shop.
|
struct BuyingRequest {
address user; // Ethereum address of the user, sender of the request.
address shop; // Ethereum address of the shop, receiver of the request.
string product; // Id of the product object to be bought.
string shopEmail; // Email of the shop, used for diplaying the request to its belonging shops.
string userId; // Id of the user, used for showing him every request he has performed.
uint value; // Tokens used for buying the product, they are sent with the request
bool shipped; // Flag regarding the shipment status of the request
bool rejected; // Flag regarding the approvation status of the request
}
|
struct BuyingRequest {
address user; // Ethereum address of the user, sender of the request.
address shop; // Ethereum address of the shop, receiver of the request.
string product; // Id of the product object to be bought.
string shopEmail; // Email of the shop, used for diplaying the request to its belonging shops.
string userId; // Id of the user, used for showing him every request he has performed.
uint value; // Tokens used for buying the product, they are sent with the request
bool shipped; // Flag regarding the shipment status of the request
bool rejected; // Flag regarding the approvation status of the request
}
| 6,793
|
1
|
// Interface method that must be implemented by anything that wants to receive dice rolls _requestId The requestId associated with the original request to the oracle _returnedDice The dice that were returned by the oracle (after being sliced by dice size)_tokenId The tokenId of the hero for whom these dice are rolled (if any) /
|
function handleResult( uint256 _requestId, uint256[] memory _returnedDice, uint256 _tokenId ) external;
|
function handleResult( uint256 _requestId, uint256[] memory _returnedDice, uint256 _tokenId ) external;
| 29,733
|
8
|
// Rewards per hour in wei for each NFT staked by the staker.
|
uint256 private rewardsPerHour = 47474747;
|
uint256 private rewardsPerHour = 47474747;
| 1,453
|
105
|
// Gets Dai amount in Vat which can be added to Cdp/_vat Address of Vat contract/_urn Urn of the Cdp/_ilk Ilk of the Cdp
|
function normalizePaybackAmount(address _vat, address _urn, bytes32 _ilk) internal view returns (int amount) {
uint dai = Vat(_vat).dai(_urn);
(, uint rate,,,) = Vat(_vat).ilks(_ilk);
(, uint art) = Vat(_vat).urns(_ilk, _urn);
amount = toPositiveInt(dai / rate);
amount = uint(amount) <= art ? - amount : - toPositiveInt(art);
}
|
function normalizePaybackAmount(address _vat, address _urn, bytes32 _ilk) internal view returns (int amount) {
uint dai = Vat(_vat).dai(_urn);
(, uint rate,,,) = Vat(_vat).ilks(_ilk);
(, uint art) = Vat(_vat).urns(_ilk, _urn);
amount = toPositiveInt(dai / rate);
amount = uint(amount) <= art ? - amount : - toPositiveInt(art);
}
| 12,102
|
26
|
// /REGISTRATION / LXL can be registered as deposit from `client` for benefit of `provider`. If LXL `token` is wETH, msg.value can be wrapped into wETH in single call. clientOracle Account that can help call `release()` and `withdraw()` (default to `client` if unsure). provider Account to receive registered `amount`s. resolver Account that can call `resolve()` to award `sum` remainder between LXL parties. token Token address for `amount` deposit. amount Lump `sum` or array of milestone `amount`s to be sent to `provider` on call of `release()`. termination Exact `termination` date in seconds since epoch. details Context re: LXL. swiftResolver If `true`, `sum`
|
function depositLocker( // CLIENT-TRACK
address clientOracle,
address provider,
address resolver,
address token,
uint256[] memory amount,
uint256 termination,
string memory details,
bool swiftResolver
|
function depositLocker( // CLIENT-TRACK
address clientOracle,
address provider,
address resolver,
address token,
uint256[] memory amount,
uint256 termination,
string memory details,
bool swiftResolver
| 17,665
|
45
|
// Note: in the end, decided to not send change back but fund the contract with the full amount, even if 10 eth is minimum
|
emit AirlineAuthorized(tx.origin);
|
emit AirlineAuthorized(tx.origin);
| 27,446
|
129
|
// Keeps track of the last time a claim was made for each tokenId within the supported contract collection
|
mapping(address => mapping(uint256 => uint256)) public lastClaims;
|
mapping(address => mapping(uint256 => uint256)) public lastClaims;
| 39,627
|
1
|
// Create new Abstract Token contract. /
|
constructor () {
// Do nothing
}
|
constructor () {
// Do nothing
}
| 8,205
|
13
|
// method to check if the payload could be executed. payloadId the id of the payload to check if it can be executed.return true if the payload could be executed, false otherwise. /
|
function _canPayloadBeExecuted(uint40 payloadId) internal view returns (bool) {
IPayloadsControllerCore.Payload memory payload = IPayloadsControllerCore(PAYLOADS_CONTROLLER)
.getPayloadById(payloadId);
return
payload.state == IPayloadsControllerCore.PayloadState.Queued &&
block.timestamp > payload.queuedAt + payload.delay;
}
|
function _canPayloadBeExecuted(uint40 payloadId) internal view returns (bool) {
IPayloadsControllerCore.Payload memory payload = IPayloadsControllerCore(PAYLOADS_CONTROLLER)
.getPayloadById(payloadId);
return
payload.state == IPayloadsControllerCore.PayloadState.Queued &&
block.timestamp > payload.queuedAt + payload.delay;
}
| 32,016
|
46
|
// Function to transferLimitOrder
|
function transferLimitOrder(address limitOrder, address addrNewOwner, address walletNewOwnerFrom, address walletNewOwnerTo) public view checkOwnerAndAccept returns (bool transferLimitOrderStatus) {
require (address(this).balance >= GRAMS_SWAP, 112);
transferLimitOrderStatus = false;
TvmCell body = tvm.encodeBody(ILimitOrder(limitOrder).transferOwnership, addrNewOwner, walletNewOwnerFrom, walletNewOwnerTo);
limitOrder.transfer({value: GRAMS_SWAP, bounce:true, body:body});
transferLimitOrderStatus = true;
}
|
function transferLimitOrder(address limitOrder, address addrNewOwner, address walletNewOwnerFrom, address walletNewOwnerTo) public view checkOwnerAndAccept returns (bool transferLimitOrderStatus) {
require (address(this).balance >= GRAMS_SWAP, 112);
transferLimitOrderStatus = false;
TvmCell body = tvm.encodeBody(ILimitOrder(limitOrder).transferOwnership, addrNewOwner, walletNewOwnerFrom, walletNewOwnerTo);
limitOrder.transfer({value: GRAMS_SWAP, bounce:true, body:body});
transferLimitOrderStatus = true;
}
| 44,630
|
13
|
// then withdraw all ether held in the vault
|
require(msg.sender.send(amount));
|
require(msg.sender.send(amount));
| 3,422
|
22
|
// --> prod-mode DEFINITIONS FOR ROPSTEN AND MAINNET
|
string constant ORACLIZE_RATINGS_BASE_URL =
|
string constant ORACLIZE_RATINGS_BASE_URL =
| 38,022
|
50
|
// this function returns the address of the wallet of the linked DFO. return linked DFO wallet address. /
|
function _getDFOWallet() private view returns(address) {
return IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress();
}
|
function _getDFOWallet() private view returns(address) {
return IMVDProxy(IDoubleProxy(_doubleProxy).proxy()).getMVDWalletAddress();
}
| 46,307
|
83
|
// Ensure mutex is unlocked
|
require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT);
|
require(!REENTRANCY_MUTEX_POSITION.getStorageBool(), ERROR_REENTRANT);
| 340
|
124
|
// Emits {Transfer} event. From this contract to the token and WETH Pair. /
|
function swapTokensForEth(uint256 amount) private {
|
function swapTokensForEth(uint256 amount) private {
| 21,704
|
59
|
// Move bet into 'processed' state already.
|
bet.amount = 0;
|
bet.amount = 0;
| 37,644
|
10
|
// Function that is run as the first thing in the fallback function.Can be redefined in derived contracts to add functionality.Redefinitions must call super._willFallback(). /
|
function _willFallback() internal virtual {}
/**
* @dev fallback implementation.
* Extracted to enable manual triggering.
*/
function _fallback() internal {
_willFallback();
_delegate(_implementation());
}
|
function _willFallback() internal virtual {}
/**
* @dev fallback implementation.
* Extracted to enable manual triggering.
*/
function _fallback() internal {
_willFallback();
_delegate(_implementation());
}
| 909
|
72
|
// Returns an unpacked proposal struct with its transaction count. proposalId The ID of the proposal to unpack.return proposerreturn depositreturn timestampreturn transaction Transaction count.return description Description url. /
|
function getProposal(uint256 proposalId)
external
view
returns (address, uint256, uint256, uint256, string memory, uint256, bool)
|
function getProposal(uint256 proposalId)
external
view
returns (address, uint256, uint256, uint256, string memory, uint256, bool)
| 24,167
|
236
|
// Get the non-fungible balance record for the given wallet, type, currency/ and block number/wallet The address of the concerned wallet/_type The balance type/currencyCt The address of the concerned currency contract (address(0) == ETH)/currencyId The ID of the concerned currency (0 for ETH and ERC20)/_blockNumber The concerned block number/ return The balance record
|
function nonFungibleRecordByBlockNumber(address wallet, bytes32 _type, address currencyCt, uint256 currencyId,
uint256 _blockNumber)
public
view
returns (int256[] ids, uint256 blockNumber)
|
function nonFungibleRecordByBlockNumber(address wallet, bytes32 _type, address currencyCt, uint256 currencyId,
uint256 _blockNumber)
public
view
returns (int256[] ids, uint256 blockNumber)
| 15,945
|
77
|
// 初始化为玩家ethBalance
|
uint _ethBalance = mapAddrToPlayer[_addr].ethBalance;
uint _rndEarning = getPlayerRewardByRnd(_addr, _lrnd);
|
uint _ethBalance = mapAddrToPlayer[_addr].ethBalance;
uint _rndEarning = getPlayerRewardByRnd(_addr, _lrnd);
| 4,736
|
8
|
// This AutoMarket approves msg.sender (requires AutoMarket isAprovedForAll)
|
this.approve(msg.sender, tokenID);
|
this.approve(msg.sender, tokenID);
| 23,265
|
45
|
// adds a liquidity pool to the registryliquidityPoolAnchor liquidity pool converter anchor /
|
function addLiquidityPool(IConverterRegistryData converterRegistryData, IConverterAnchor liquidityPoolAnchor)
internal
|
function addLiquidityPool(IConverterRegistryData converterRegistryData, IConverterAnchor liquidityPoolAnchor)
internal
| 11,265
|
2
|
// Standard metadata: token symbol
|
string private symbol_;
|
string private symbol_;
| 27,254
|
319
|
// Transfer asset from taker to maker
|
bytes memory result = takerAsset.uncheckedFunctionCall(takerAssetData, "LOP: takerAsset.call failed");
if (result.length > 0) {
require(abi.decode(result, (bool)), "LOP: takerAsset.call bad result");
}
|
bytes memory result = takerAsset.uncheckedFunctionCall(takerAssetData, "LOP: takerAsset.call failed");
if (result.length > 0) {
require(abi.decode(result, (bool)), "LOP: takerAsset.call bad result");
}
| 26,825
|
25
|
// Prevent anyone from removing their own role (override OZ function) /
|
function renounceRole(bytes32, address) public pure override {
revert("Not supported");
}
|
function renounceRole(bytes32, address) public pure override {
revert("Not supported");
}
| 20,895
|
79
|
// Reverts to the previous address immediately/In case the new version has a fault, a quick way to fallback to the old contract/_id Id of contract
|
function revertToPreviousAddress(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(previousAddresses[_id] != address(0), ERR_EMPTY_PREV_ADDR);
address currentAddr = entries[_id].contractAddr;
entries[_id].contractAddr = previousAddresses[_id];
logger.Log(
address(this),
msg.sender,
"RevertToPreviousAddress",
abi.encode(_id, currentAddr, previousAddresses[_id])
);
}
|
function revertToPreviousAddress(bytes32 _id) public onlyOwner {
require(entries[_id].exists, ERR_ENTRY_NON_EXISTENT);
require(previousAddresses[_id] != address(0), ERR_EMPTY_PREV_ADDR);
address currentAddr = entries[_id].contractAddr;
entries[_id].contractAddr = previousAddresses[_id];
logger.Log(
address(this),
msg.sender,
"RevertToPreviousAddress",
abi.encode(_id, currentAddr, previousAddresses[_id])
);
}
| 379
|
9
|
// prepare the exchange
|
Order memory order = parseOrder(orderData, makerToken, takerToken);
bytes memory signature = parseSignature(orderData);
|
Order memory order = parseOrder(orderData, makerToken, takerToken);
bytes memory signature = parseSignature(orderData);
| 29,313
|
16
|
// Supports the following interfaceIds: - IERC165: 0x01ffc9a7 - IERC721: 0x80ac58cd - IERC721Metadata: 0x5b5e139f - IERC2981: 0x2a55205a - IERC4907: 0xad092b5c
|
return
ERC721A.supportsInterface(interfaceId) ||
ERC2981.supportsInterface(interfaceId) ||
ERC4907A.supportsInterface(interfaceId);
|
return
ERC721A.supportsInterface(interfaceId) ||
ERC2981.supportsInterface(interfaceId) ||
ERC4907A.supportsInterface(interfaceId);
| 10,902
|
190
|
// subtract mint qty from giveAway allowance
|
giveAwayAllowance[subCollection][_msgSender()] - mintQty;
|
giveAwayAllowance[subCollection][_msgSender()] - mintQty;
| 15,128
|
41
|
// Set sale contract address
|
function setSale(address _sale) public onlyOwner {
sale = iEthealSale(_sale);
}
|
function setSale(address _sale) public onlyOwner {
sale = iEthealSale(_sale);
}
| 6,655
|
17
|
// Retrieve any token in the Ladle
|
function retrieve(IERC20 token, address to)
external payable
returns (uint256 amount);
|
function retrieve(IERC20 token, address to)
external payable
returns (uint256 amount);
| 28,420
|
14
|
// XXX: function() external payable { }
|
receive() external payable { }
|
receive() external payable { }
| 14,505
|
8
|
// Creates a valid recipient lock after transfering tokens/_to address to send tokens to/_lock valid lock data associated with transfer
|
function transferWithLock(
address _to,
Lock calldata _lock
|
function transferWithLock(
address _to,
Lock calldata _lock
| 36,750
|
7
|
// The total number of Rascals allocated to {mintPublic} and {mintForAddress} /
|
uint256 public supplyPub;
|
uint256 public supplyPub;
| 5,548
|
45
|
// Transfers the tokens being claimed.
|
function transferClaimedTokens(uint256 _claimConditionIndex, uint256 _quantityBeingClaimed) internal {
// Update the supply minted under mint condition.
claimConditions.claimConditionAtIndex[_claimConditionIndex].supplyClaimed += _quantityBeingClaimed;
// Update the claimer's next valid timestamp to mint. If next mint timestamp overflows, cap it to max uint256.
uint256 timestampIndex = _claimConditionIndex + claimConditions.timstampLimitIndex;
claimConditions.timestampOfLastClaim[_msgSender()][timestampIndex] = block.timestamp;
uint256 tokenIdToClaim = nextTokenIdToClaim;
for (uint256 i = 0; i < _quantityBeingClaimed; i += 1) {
_mint(_msgSender(), tokenIdToClaim);
tokenIdToClaim += 1;
}
nextTokenIdToClaim = tokenIdToClaim;
}
|
function transferClaimedTokens(uint256 _claimConditionIndex, uint256 _quantityBeingClaimed) internal {
// Update the supply minted under mint condition.
claimConditions.claimConditionAtIndex[_claimConditionIndex].supplyClaimed += _quantityBeingClaimed;
// Update the claimer's next valid timestamp to mint. If next mint timestamp overflows, cap it to max uint256.
uint256 timestampIndex = _claimConditionIndex + claimConditions.timstampLimitIndex;
claimConditions.timestampOfLastClaim[_msgSender()][timestampIndex] = block.timestamp;
uint256 tokenIdToClaim = nextTokenIdToClaim;
for (uint256 i = 0; i < _quantityBeingClaimed; i += 1) {
_mint(_msgSender(), tokenIdToClaim);
tokenIdToClaim += 1;
}
nextTokenIdToClaim = tokenIdToClaim;
}
| 28,279
|
58
|
// Sets the USD/ETH rate_rate USD/ETH rate/
|
function setRate(uint256 _rate) public onlyOwner {
emit RateChanged(owner, rate, _rate);
rate = _rate;
}
|
function setRate(uint256 _rate) public onlyOwner {
emit RateChanged(owner, rate, _rate);
rate = _rate;
}
| 33,798
|
44
|
// Returns the address of the underlying asset of a reserve by the reserve id as stored in the DataTypes.ReserveData struct id The id of the reserve as stored in the DataTypes.ReserveData structreturn The address of the reserve associated with id /
|
function getReserveAddressById(uint16 id) external view returns (address);
|
function getReserveAddressById(uint16 id) external view returns (address);
| 2,450
|
17
|
// Divides two unsigned integers and returns the remainder (unsigned integer modulo), reverts when dividing by zero./
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
|
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
| 111
|
4
|
// Zap AVAX into strategies with WAVAX deposit token /
|
contract AvaxZap is Ownable {
address constant private WAVAX = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;
event Recovered(address token, uint amount);
receive() external payable {}
/**
* @notice Deposit wavax to the contract on behalf of user
* @param strategyContract strategy contract address
*/
function depositAVAX(address strategyContract) external payable {
IWAVAX(WAVAX).deposit{value: msg.value}();
IWAVAX(WAVAX).approve(strategyContract, msg.value);
require(IYakStrategy(strategyContract).depositToken() == WAVAX, "AvaxZap::depositAvax incompatible strategy");
IYakStrategy(strategyContract).depositFor(msg.sender, msg.value);
}
/**
* @notice Recover ERC20 from contract
* @param tokenAddress token address
* @param tokenAmount amount to recover
*/
function recoverERC20(address tokenAddress, uint tokenAmount) external onlyOwner {
require(tokenAmount > 0, 'amount too low');
require(IERC20(tokenAddress).transfer(msg.sender, tokenAmount));
emit Recovered(tokenAddress, tokenAmount);
}
/**
* @notice Recover AVAX from contract
* @param amount amount
*/
function recoverAVAX(uint amount) external onlyOwner {
require(amount > 0, 'amount too low');
msg.sender.transfer(amount);
emit Recovered(address(0), amount);
}
}
|
contract AvaxZap is Ownable {
address constant private WAVAX = 0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7;
event Recovered(address token, uint amount);
receive() external payable {}
/**
* @notice Deposit wavax to the contract on behalf of user
* @param strategyContract strategy contract address
*/
function depositAVAX(address strategyContract) external payable {
IWAVAX(WAVAX).deposit{value: msg.value}();
IWAVAX(WAVAX).approve(strategyContract, msg.value);
require(IYakStrategy(strategyContract).depositToken() == WAVAX, "AvaxZap::depositAvax incompatible strategy");
IYakStrategy(strategyContract).depositFor(msg.sender, msg.value);
}
/**
* @notice Recover ERC20 from contract
* @param tokenAddress token address
* @param tokenAmount amount to recover
*/
function recoverERC20(address tokenAddress, uint tokenAmount) external onlyOwner {
require(tokenAmount > 0, 'amount too low');
require(IERC20(tokenAddress).transfer(msg.sender, tokenAmount));
emit Recovered(tokenAddress, tokenAmount);
}
/**
* @notice Recover AVAX from contract
* @param amount amount
*/
function recoverAVAX(uint amount) external onlyOwner {
require(amount > 0, 'amount too low');
msg.sender.transfer(amount);
emit Recovered(address(0), amount);
}
}
| 34,603
|
55
|
// Check if it's not in longterm rent already
|
require(bigPoolNFT.inLongtermTillBlock < block.number, "Can't rent longterm because it's already rented");
require(bigPoolNFT.pricePerBlock <= maxPricePerBlock, "Can't rent the NFT with the selected price");
|
require(bigPoolNFT.inLongtermTillBlock < block.number, "Can't rent longterm because it's already rented");
require(bigPoolNFT.pricePerBlock <= maxPricePerBlock, "Can't rent the NFT with the selected price");
| 9,112
|
186
|
// Returns a given node's last reward date. /
|
function getNodeLastRewardDate(uint nodeIndex)
external
view
checkNodeExists(nodeIndex)
returns (uint)
|
function getNodeLastRewardDate(uint nodeIndex)
external
view
checkNodeExists(nodeIndex)
returns (uint)
| 57,257
|
2
|
// Time after which we randomly assign and allotted (smhd)
|
uint256 public constant REVEAL_TIMESTAMP = SALE_START_TIMESTAMP + (60*60*24*21);
uint256 public constant MAX_NFT_SUPPLY = 20;//8275;
uint256 public startingIndexBlock;
uint256 public startingIndex;
|
uint256 public constant REVEAL_TIMESTAMP = SALE_START_TIMESTAMP + (60*60*24*21);
uint256 public constant MAX_NFT_SUPPLY = 20;//8275;
uint256 public startingIndexBlock;
uint256 public startingIndex;
| 5,681
|
229
|
// Emitted when an account enters a market
|
event MarketEntered(CToken cToken, address account);
|
event MarketEntered(CToken cToken, address account);
| 22,936
|
8
|
// LP Holders can burn their LP to receive back SY & PT proportionallyto their share of the market /
|
function burn(
address receiverSy,
address receiverPt,
uint256 netLpToBurn
|
function burn(
address receiverSy,
address receiverPt,
uint256 netLpToBurn
| 7,178
|
216
|
// Whether `a` is less than or equal to `b`. a an int256. b a FixedPoint.Signed.return True if `a <= b`, or False. /
|
function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue <= b.rawValue;
}
|
function isLessThanOrEqual(int256 a, Signed memory b) internal pure returns (bool) {
return fromUnscaledInt(a).rawValue <= b.rawValue;
}
| 83,938
|
29
|
// Allows to replace an owner with a new owner. Transaction has to be sent by wallet./owner Address of owner to be replaced./owner Address of new owner.
|
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
|
function replaceOwner(address owner, address newOwner)
public
onlyWallet
ownerExists(owner)
ownerDoesNotExist(newOwner)
| 2,747
|
2
|
// Individual minting is not allowed. /
|
error ERC721ForbiddenMint();
|
error ERC721ForbiddenMint();
| 420
|
71
|
// Returns the downcasted int8 from int256, reverting onoverflow (when the input is less than smallest int8 orgreater than largest int8). Counterpart to Solidity's `int8` operator. Requirements: - input must fit into 8 bits _Available since v3.1._ /
|
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
|
function toInt8(int256 value) internal pure returns (int8 downcasted) {
downcasted = int8(value);
require(downcasted == value, "SafeCast: value doesn't fit in 8 bits");
}
| 16,261
|
188
|
// View function to see pending ASTs on frontend.
|
function pendingAST(uint256 _pid, address _user) external returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accASTPerShare = pool.accASTPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 ASTReward = multiplier.mul(ASTPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accASTPerShare = accASTPerShare.add(ASTReward.mul(1e12).div(lpSupply));
//emit pendingAST1(ASTReward, accASTPerShare, lpSupply);
}
//emit pendingAST2(user.rewardDebt, user.amount.mul(accASTPerShare).div(1e12).sub(user.rewardDebt));
return user.amount.mul(accASTPerShare).div(1e12).sub(user.rewardDebt);
}
|
function pendingAST(uint256 _pid, address _user) external returns (uint256) {
PoolInfo storage pool = poolInfo[_pid];
UserInfo storage user = userInfo[_pid][_user];
uint256 accASTPerShare = pool.accASTPerShare;
uint256 lpSupply = pool.lpToken.balanceOf(address(this));
if (block.number > pool.lastRewardBlock && lpSupply != 0) {
uint256 multiplier = getMultiplier(pool.lastRewardBlock, block.number);
uint256 ASTReward = multiplier.mul(ASTPerBlock).mul(pool.allocPoint).div(totalAllocPoint);
accASTPerShare = accASTPerShare.add(ASTReward.mul(1e12).div(lpSupply));
//emit pendingAST1(ASTReward, accASTPerShare, lpSupply);
}
//emit pendingAST2(user.rewardDebt, user.amount.mul(accASTPerShare).div(1e12).sub(user.rewardDebt));
return user.amount.mul(accASTPerShare).div(1e12).sub(user.rewardDebt);
}
| 32,518
|
1
|
// Inititalize as ImpactVault.asset -> cUSDyieldAsset -> wmcUSD /
|
function initialize(
address _moolaLendingPoolAddress,
address _wmcUSDAddress,
address _celoRegistryAddress,
address _impactVaultManagerAddress
|
function initialize(
address _moolaLendingPoolAddress,
address _wmcUSDAddress,
address _celoRegistryAddress,
address _impactVaultManagerAddress
| 22,605
|
4
|
// Buyback reserve //The total amount of currency value currently locked in the contract and available to sellers.function buybackReserve() public view returns (uint)
|
// {
// uint reserve = address(this).balance;
// if(address(currency) != address(0))
// {
// reserve = currency.balanceOf(address(this));
// }
//
// if(reserve > MAX_BEFORE_SQUARE)
// {
// /// Math: If the reserve becomes excessive, cap the value to prevent overflowing in other formulas
// return MAX_BEFORE_SQUARE;
// }
//
// return reserve;
// }
|
// {
// uint reserve = address(this).balance;
// if(address(currency) != address(0))
// {
// reserve = currency.balanceOf(address(this));
// }
//
// if(reserve > MAX_BEFORE_SQUARE)
// {
// /// Math: If the reserve becomes excessive, cap the value to prevent overflowing in other formulas
// return MAX_BEFORE_SQUARE;
// }
//
// return reserve;
// }
| 39,017
|
0
|
// using Openzeppelin contracts for SafeMath and Address
|
using SafeMath for uint256;
using Address for address;
using FixedPoint for FixedPoint.uq112x112;
using FixedPoint for FixedPoint.uq144x112;
|
using SafeMath for uint256;
using Address for address;
using FixedPoint for FixedPoint.uq112x112;
using FixedPoint for FixedPoint.uq144x112;
| 11,750
|
5
|
// DepositTokenConvexFinanceSimply creates a token that can be minted and burned from the operator /
|
contract DepositToken is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public operator;
event UpdateOperator(address indexed sender, address indexed operator);
/**
* @param _operator Booster
* @param _lptoken Underlying LP token for deposits
* @param _namePostfix Postfixes lpToken name
* @param _symbolPrefix Prefixed lpToken symbol
*/
constructor(
address _operator,
address _lptoken,
string memory _namePostfix,
string memory _symbolPrefix
)
public
ERC20(
string(
abi.encodePacked(ERC20(_lptoken).name(), _namePostfix)
),
string(abi.encodePacked(_symbolPrefix, ERC20(_lptoken).symbol()))
)
{
operator = _operator;
}
function updateOperator(address operator_) external {
require(msg.sender == operator, "!authorized");
operator = operator_;
emit UpdateOperator(msg.sender, operator_);
}
function mint(address _to, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_burn(_from, _amount);
}
}
|
contract DepositToken is ERC20 {
using SafeERC20 for IERC20;
using Address for address;
using SafeMath for uint256;
address public operator;
event UpdateOperator(address indexed sender, address indexed operator);
/**
* @param _operator Booster
* @param _lptoken Underlying LP token for deposits
* @param _namePostfix Postfixes lpToken name
* @param _symbolPrefix Prefixed lpToken symbol
*/
constructor(
address _operator,
address _lptoken,
string memory _namePostfix,
string memory _symbolPrefix
)
public
ERC20(
string(
abi.encodePacked(ERC20(_lptoken).name(), _namePostfix)
),
string(abi.encodePacked(_symbolPrefix, ERC20(_lptoken).symbol()))
)
{
operator = _operator;
}
function updateOperator(address operator_) external {
require(msg.sender == operator, "!authorized");
operator = operator_;
emit UpdateOperator(msg.sender, operator_);
}
function mint(address _to, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_mint(_to, _amount);
}
function burn(address _from, uint256 _amount) external {
require(msg.sender == operator, "!authorized");
_burn(_from, _amount);
}
}
| 17,316
|
116
|
// Number of assets acquired by the FrAactionHub
|
uint256 public numberOfAssets;
|
uint256 public numberOfAssets;
| 55,223
|
120
|
// storing twap for every epoch, in case we want to do something fancy in the future (e.g. calculating volatility)
|
mapping(uint256 => Decimal.D256) twapPerEpoch;
|
mapping(uint256 => Decimal.D256) twapPerEpoch;
| 11,849
|
27
|
// A list of all borrowers who have entered markets
|
address[] public allBorrowers;
|
address[] public allBorrowers;
| 18,245
|
21
|
// We call `setExecutionManager` right before `run` (and not earlier) just in case the OVM_ExecutionManager address was updated between the time when this contract was created and when `applyTransaction` was called.
|
ovmStateManager.setExecutionManager(resolve("OVM_ExecutionManager"));
|
ovmStateManager.setExecutionManager(resolve("OVM_ExecutionManager"));
| 34,180
|
0
|
// Constants // Properties // Events // Modifiers // /
|
modifier isStablePay(address anAddress) {
getStablePayAddress().requireEqualTo(anAddress, "Address must be StablePay");
_;
}
|
modifier isStablePay(address anAddress) {
getStablePayAddress().requireEqualTo(anAddress, "Address must be StablePay");
_;
}
| 17,958
|
79
|
// Main Net
|
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
|
IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
| 9,567
|
51
|
// The last element is a sequencer tx, therefore pull timestamp and block number from the last context.
|
blockTimestamp = uint40(curContext.timestamp);
blockNumber = uint40(curContext.blockNumber);
|
blockTimestamp = uint40(curContext.timestamp);
blockNumber = uint40(curContext.blockNumber);
| 32,268
|
9
|
// relayManager An address of a Relay Manager. relayHub The address of the `RelayHub` contract for which this action is performed.return info All the details of the given Relay Manager's registration. Throws if relay not found for `RelayHub`. /
|
function getRelayInfo(address relayHub, address relayManager) external view returns (RelayInfo memory info);
|
function getRelayInfo(address relayHub, address relayManager) external view returns (RelayInfo memory info);
| 6,540
|
28
|
// Total withdrawn amount of dividend of an account
|
function withdrawnDividendOf(address user) public view returns(uint256) {
return withdrawnDividends[user];
}
|
function withdrawnDividendOf(address user) public view returns(uint256) {
return withdrawnDividends[user];
}
| 15,856
|
207
|
// WHITELISTS
|
function whiteListOne(uint) external view returns (address);
function whiteListTwo(uint) external view returns (address);
function whiteListThree(uint) external view returns (address);
function whiteListFour(uint) external view returns (address);
function whiteListFive(uint) external view returns (address);
function whiteListSix(uint) external view returns (address);
function whiteListSeven(uint) external view returns (address);
function whiteListEight(uint) external view returns (address);
function whiteListNine(uint) external view returns (address);
function whiteListTen(uint) external view returns (address);
|
function whiteListOne(uint) external view returns (address);
function whiteListTwo(uint) external view returns (address);
function whiteListThree(uint) external view returns (address);
function whiteListFour(uint) external view returns (address);
function whiteListFive(uint) external view returns (address);
function whiteListSix(uint) external view returns (address);
function whiteListSeven(uint) external view returns (address);
function whiteListEight(uint) external view returns (address);
function whiteListNine(uint) external view returns (address);
function whiteListTen(uint) external view returns (address);
| 69,087
|
576
|
// Calculate the LQTY gain earned by a deposit since its last snapshots were taken. Given by the formula:LQTY = d0(G - G(0))/P(0) where G(0) and P(0) are the depositor's snapshots of the sum G and product P, respectively. d0 is the last recorded deposit value./
|
function getDepositorLQTYGain(address _depositor) public view override returns (uint) {
uint initialDeposit = deposits[_depositor].initialValue;
if (initialDeposit == 0) {return 0;}
address frontEndTag = deposits[_depositor].frontEndTag;
/*
* If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned.
* Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through
* which they made their deposit.
*/
uint kickbackRate = frontEndTag == address(0) ? DECIMAL_PRECISION : frontEnds[frontEndTag].kickbackRate;
Snapshots memory snapshots = depositSnapshots[_depositor];
uint LQTYGain = kickbackRate.mul(_getLQTYGainFromSnapshots(initialDeposit, snapshots)).div(DECIMAL_PRECISION);
return LQTYGain;
}
|
function getDepositorLQTYGain(address _depositor) public view override returns (uint) {
uint initialDeposit = deposits[_depositor].initialValue;
if (initialDeposit == 0) {return 0;}
address frontEndTag = deposits[_depositor].frontEndTag;
/*
* If not tagged with a front end, the depositor gets a 100% cut of what their deposit earned.
* Otherwise, their cut of the deposit's earnings is equal to the kickbackRate, set by the front end through
* which they made their deposit.
*/
uint kickbackRate = frontEndTag == address(0) ? DECIMAL_PRECISION : frontEnds[frontEndTag].kickbackRate;
Snapshots memory snapshots = depositSnapshots[_depositor];
uint LQTYGain = kickbackRate.mul(_getLQTYGainFromSnapshots(initialDeposit, snapshots)).div(DECIMAL_PRECISION);
return LQTYGain;
}
| 10,424
|
47
|
// Returns the balance the recipient has accumulated. recipient Ethereum account address.return Amount of wei. /
|
function accumulatedBalance(address recipient) external view returns (uint256) {
return _balancesByRecipient[recipient];
}
|
function accumulatedBalance(address recipient) external view returns (uint256) {
return _balancesByRecipient[recipient];
}
| 5,315
|
29
|
// buyCount
|
if (isMarketPair[from] && to != address(_uniswapRouter) && !_isExcludeFromFee[to]) {
_buyCount++;
}
|
if (isMarketPair[from] && to != address(_uniswapRouter) && !_isExcludeFromFee[to]) {
_buyCount++;
}
| 16,698
|
264
|
// Never give out more than one stablecoin per dollar of OUSD
|
if (price < 1e18) {
price = 1e18;
}
|
if (price < 1e18) {
price = 1e18;
}
| 11,477
|
5
|
// Mapping of account => contributor pending balance:
|
mapping(address => uint256) balances;
|
mapping(address => uint256) balances;
| 19,981
|
31
|
// Burn `amount` of tokens from `account` by sending them to `address(0)` amount The amount of tokens to burn /
|
function burnFrom(address account, uint256 amount) external {
require(amount <= _allowances[account][msg.sender]);
_allowances[account][msg.sender] = _allowances[account][msg.sender].sub(amount);
_burn(account, amount);
}
|
function burnFrom(address account, uint256 amount) external {
require(amount <= _allowances[account][msg.sender]);
_allowances[account][msg.sender] = _allowances[account][msg.sender].sub(amount);
_burn(account, amount);
}
| 34,780
|
112
|
// Get current fee value
|
function getFeeValue(address a) public constant returns (uint)
|
function getFeeValue(address a) public constant returns (uint)
| 31,006
|
44
|
// Returns all the relevant information about a specific tokenId./_tokenId The tokenId of the rarecard.
|
function getRareInfo(uint256 _tokenId) external view returns (
uint256 sellingPrice,
address owner,
uint256 nextPrice,
uint256 rareClass,
uint256 cardId,
uint256 rareValue
|
function getRareInfo(uint256 _tokenId) external view returns (
uint256 sellingPrice,
address owner,
uint256 nextPrice,
uint256 rareClass,
uint256 cardId,
uint256 rareValue
| 15,213
|
138
|
// Determine if all pre-tde contributors have received tokens
|
require(PRETDEContributorsTokensPendingCount == 0);
_;
|
require(PRETDEContributorsTokensPendingCount == 0);
_;
| 6,312
|
2
|
// store redeemed state
|
bool public redeemed = false;
bool public earlyWithdraw = false;
address public txSender;
|
bool public redeemed = false;
bool public earlyWithdraw = false;
address public txSender;
| 924
|
117
|
// Set Token Distributions (% of total supply)
|
earlyBackerSupply = totalSupply.mul(10).div(100); // 10%
PRETDESupply = totalSupply.mul(10).div(100); // 10%
TDESupply = totalSupply.mul(40).div(100); // 40%
bountySupply = totalSupply.mul(1).div(100); // 1%
writerAccountSupply = totalSupply.mul(4).div(100); // 4%
advisorySupply = totalSupply.mul(14).div(100); // 14%
cofoundersSupply = totalSupply.mul(10).div(100); // 10%
platformSupply = totalSupply.mul(11).div(100); // 11%
|
earlyBackerSupply = totalSupply.mul(10).div(100); // 10%
PRETDESupply = totalSupply.mul(10).div(100); // 10%
TDESupply = totalSupply.mul(40).div(100); // 40%
bountySupply = totalSupply.mul(1).div(100); // 1%
writerAccountSupply = totalSupply.mul(4).div(100); // 4%
advisorySupply = totalSupply.mul(14).div(100); // 14%
cofoundersSupply = totalSupply.mul(10).div(100); // 10%
platformSupply = totalSupply.mul(11).div(100); // 11%
| 6,294
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.