source_idx
stringlengths
1
5
contract_name
stringlengths
1
48
func_name
stringlengths
0
52
masked_contract
stringlengths
105
184k
func_body
stringlengths
0
324k
func_requirement
stringlengths
1
28.3k
85356
ERC20
totalSupply
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
return _totalSupply;
* * @dev Total number of tokens in existence
85356
ERC20
balanceOf
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
return _balances[owner];
* * @dev Gets the balance of the specified address. * @param owner The address to query the balance of. * @return An uint256 representing the amount owned by the passed address.
85356
ERC20
allowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
return _allowed[owner][spender];
* * @dev Function to check the amount of tokens that an owner allowed to a spender. * @param owner address The address which owns the funds. * @param spender address The address which will spend the funds. * @return A uint256 specifying the amount of tokens still available for the spender.
85356
ERC20
approve
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(spender != address(0)); _allowed[msg.sender][spender] = value; emit Approval(msg.sender, spender, value); return true;
* * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender. * Beware that changing an allowance with this method brings the risk that someone may use both the old * and the new allowance by unfortunate transaction ordering. One possible solution to mitigate thi...
85356
ERC20
transferFrom
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
_allowed[from][msg.sender] = _allowed[from][msg.sender].sub(value); _transfer(from, to, value); emit Approval(from, msg.sender, _allowed[from][msg.sender]); return true;
* * @dev Transfer tokens from one address to another. * Note that while this function emits an Approval event, this is not required as per the specification, * and other compliant implementations may not emit the event. * @param from address The address which you want to send tokens from *...
85356
ERC20
increaseAllowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].add(addedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true;
* * @dev Increase the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To increment * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol ...
85356
ERC20
decreaseAllowance
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(spender != address(0)); _allowed[msg.sender][spender] = _allowed[msg.sender][spender].sub(subtractedValue); emit Approval(msg.sender, spender, _allowed[msg.sender][spender]); return true;
* * @dev Decrease the amount of tokens that an owner allowed to a spender. * approve should be called when allowed_[_spender] == 0. To decrement * allowed value is better to use this function to avoid 2 calls (and wait until * the first transaction is mined) * From MonolithDAO Token.sol ...
85356
ERC20
transfer
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
_transfer(msg.sender, to, value); return true;
* * @dev Transfer token for a specified address * @param to The address to transfer to. * @param value The amount to be transferred.
85356
ERC20
_transfer
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(to != address(0)); require(from != address(0)); _balances[from] = _balances[from].sub(value); _balances[to] = _balances[to].add(value); emit Transfer(from, to, value);
* * @dev Transfer token for a specified addresses * @param from The address to transfer from. * @param to The address to transfer to. * @param value The amount to be transferred.
85356
ERC20
_burn
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(account != address(0)); _totalSupply = _totalSupply.sub(value); _balances[account] = _balances[account].sub(value); emit Transfer(account, address(0), value);
* * @dev Destroys `amount` tokens from the caller. * * See {ERC20-_burn}. * * @dev Internal function that burns an amount of the token of a given * account. * @param account The account whose tokens will be burnt. * @param value The amount that will be burnt.
85356
ERC20
_burnFrom
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
_allowed[account][msg.sender] = _allowed[account][msg.sender].sub(value); _burn(account, value); emit Approval(account, msg.sender, _allowed[account][msg.sender]);
* * @dev Internal function that burns an amount of the token of a given * account, deducting from the sender's allowance for said account. Uses the * internal burn function. * Emits an Approval event (reflecting the reduced allowance). * @param account The account whose tokens will be burn...
85356
ERC20
_mint
contract ERC20 is IERC20 { using SafeMath for uint256; mapping (address => uint256) internal _balances; mapping (address => mapping (address => uint256)) internal _allowed; uint256 private _totalSupply; /** * @dev Total number of tokens in existence */ function totalSuppl...
require(account != address(0)); _totalSupply = _totalSupply.add(value); _balances[account] = _balances[account].add(value); emit Transfer(address(0), account, value);
* * @dev Internal function that mints an amount of the token and assigns it to * an account. This encapsulates the modification of balances such that the * proper events are emitted. * @param account The account that will receive the created tokens. * @param value The amount that will be c...
85356
ERC20Detailed
name
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @retu...
return _name;
* * @return the name of the token.
85356
ERC20Detailed
symbol
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @retu...
return _symbol;
* * @return the symbol of the token.
85356
ERC20Detailed
decimals
contract ERC20Detailed is IERC20 { string private _name; string private _symbol; uint8 private _decimals; constructor (string memory name, string memory symbol, uint8 decimals) public { _name = name; _symbol = symbol; _decimals = decimals; } /** * @retu...
return _decimals;
* * @return the number of decimals of the token.
85358
DSExec
exec
contract DSExec { function tryExec( address target, bytes calldata, uint value) internal returns (bool call_ret) { return target.call.value(value)(calldata); } function exec( address target, bytes calldata, uint value) internal { if(!t...
exec(t, c, 0);
Convenience aliases
85358
DSGroup
getInfo
contract DSGroup is DSExec, DSNote { address[] public members; uint public quorum; uint public window; uint public actionCount; mapping (uint => Action) public actions; mapping (uint => mapping (address => bool)) public confirmedBy; mapp...
return (quorum, members.length, window, actionCount);
------------------------------------------------------------------ Legacy functions ------------------------------------------------------------------
85358
Asset
transfer
contract Asset is DSMath, ERC20Interface { // DATA STRUCTURES mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply; // PUBLIC METHODS /** * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Tra...
require(balances[msg.sender] >= _value); // sanity checks require(balances[_to] + _value >= balances[_to]); balances[msg.sender] = sub(balances[msg.sender], _value); balances[_to] = add(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; ...
PUBLIC METHODS * * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Transfers sender's tokens to a given address * @dev Similar to transfer(address, uint, bytes), but without _data parameter * @param _to Address of token receiver * @param _value Number of tokens to transfer ...
85358
Asset
transferFrom
contract Asset is DSMath, ERC20Interface { // DATA STRUCTURES mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply; // PUBLIC METHODS /** * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Tra...
require(_from != address(0)); require(_to != address(0)); require(_to != address(this)); require(balances[_from] >= _value); require(allowed[_from][msg.sender] >= _value); require(balances[_to] + _value >= balances[_to]); // require(_to == msg.sender); // ...
/ @notice Transfer `_value` tokens from `_from` to `_to` if `msg.sender` is allowed. / @notice Restriction: An account can only use this function to send to itself / @dev Allows for an approved third party to transfer tokens from one / address to another. Returns success. / @param _from Address from where tokens are wi...
85358
Asset
approve
contract Asset is DSMath, ERC20Interface { // DATA STRUCTURES mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply; // PUBLIC METHODS /** * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Tra...
require(_spender != address(0)); allowed[msg.sender][_spender] = _value; emit Approval(msg.sender, _spender, _value); return true;
/ @notice Allows `_spender` to transfer `_value` tokens from `msg.sender` to any address. / @dev Sets approved amount of tokens for spender. Returns success. / @param _spender Address of allowed account. / @param _value Number of approved tokens. / @return Returns success of function call.
85358
Asset
allowance
contract Asset is DSMath, ERC20Interface { // DATA STRUCTURES mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply; // PUBLIC METHODS /** * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Tra...
return allowed[_owner][_spender];
PUBLIC VIEW METHODS / @dev Returns number of allowed tokens that a spender can transfer on / behalf of a token owner. / @param _owner Address of token owner. / @param _spender Address of token spender. / @return Returns remaining allowance for spender.
85358
Asset
balanceOf
contract Asset is DSMath, ERC20Interface { // DATA STRUCTURES mapping (address => uint) balances; mapping (address => mapping (address => uint)) allowed; uint public _totalSupply; // PUBLIC METHODS /** * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Tra...
return balances[_owner];
/ @dev Returns number of tokens owned by the given address. / @param _owner Address of token owner. / @return Returns balance of owner.
85358
Shares
Shares
contract Shares is SharesInterface, Asset { // FIELDS // Constructor fields bytes32 public name; bytes8 public symbol; uint public decimal; uint public creationTime; // METHODS // CONSTRUCTOR /// @param _name Name these shares /// @param _symbol Symbol of shar...
name = _name; symbol = _symbol; decimal = _decimal; creationTime = _creationTime;
METHODS CONSTRUCTOR / @param _name Name these shares / @param _symbol Symbol of shares / @param _decimal Amount of decimals sharePrice is denominated in, defined to be equal as deciamls in REFERENCE_ASSET contract / @param _creationTime Timestamp of share creation
85358
Shares
transfer
contract Shares is SharesInterface, Asset { // FIELDS // Constructor fields bytes32 public name; bytes8 public symbol; uint public decimal; uint public creationTime; // METHODS // CONSTRUCTOR /// @param _name Name these shares /// @param _symbol Symbol of shar...
require(balances[msg.sender] >= _value); // sanity checks require(balances[_to] + _value >= balances[_to]); balances[msg.sender] = sub(balances[msg.sender], _value); balances[_to] = add(balances[_to], _value); emit Transfer(msg.sender, _to, _value); return true; ...
PUBLIC METHODS * * @notice Send `_value` tokens to `_to` from `msg.sender` * @dev Transfers sender's tokens to a given address * @dev Similar to transfer(address, uint, bytes), but without _data parameter * @param _to Address of token receiver * @param _value Number of tokens to transfer ...
85358
Shares
getName
contract Shares is SharesInterface, Asset { // FIELDS // Constructor fields bytes32 public name; bytes8 public symbol; uint public decimal; uint public creationTime; // METHODS // CONSTRUCTOR /// @param _name Name these shares /// @param _symbol Symbol of shar...
return name;
PUBLIC VIEW METHODS
85358
Shares
createShares
contract Shares is SharesInterface, Asset { // FIELDS // Constructor fields bytes32 public name; bytes8 public symbol; uint public decimal; uint public creationTime; // METHODS // CONSTRUCTOR /// @param _name Name these shares /// @param _symbol Symbol of shar...
_totalSupply = add(_totalSupply, shareQuantity); balances[recipient] = add(balances[recipient], shareQuantity); emit Created(msg.sender, now, shareQuantity); emit Transfer(address(0), recipient, shareQuantity);
INTERNAL METHODS / @param recipient Address the new shares should be sent to / @param shareQuantity Number of shares to be created
85358
Shares
annihilateShares
contract Shares is SharesInterface, Asset { // FIELDS // Constructor fields bytes32 public name; bytes8 public symbol; uint public decimal; uint public creationTime; // METHODS // CONSTRUCTOR /// @param _name Name these shares /// @param _symbol Symbol of shar...
_totalSupply = sub(_totalSupply, shareQuantity); balances[recipient] = sub(balances[recipient], shareQuantity); emit Annihilated(msg.sender, now, shareQuantity); emit Transfer(recipient, address(0), shareQuantity);
/ @param recipient Address the new shares should be taken from when destroyed / @param shareQuantity Number of shares to be annihilated
85358
Owned
Owned
contract Owned is DBC { // FIELDS address public owner; // NON-CONSTANT METHODS function Owned() {<FILL_FUNCTION_BODY>} function changeOwner(address ofNewOwner) pre_cond(isOwner()) { owner = ofNewOwner; } // PRE, POST, INVARIANT CONDITIONS function isOwner() internal ret...
owner = msg.sender;
NON-CONSTANT METHODS
85358
Owned
isOwner
contract Owned is DBC { // FIELDS address public owner; // NON-CONSTANT METHODS function Owned() { owner = msg.sender; } function changeOwner(address ofNewOwner) pre_cond(isOwner()) { owner = ofNewOwner; } // PRE, POST, INVARIANT CONDITIONS function isOwner() internal re...
return msg.sender == owner;
PRE, POST, INVARIANT CONDITIONS
85358
Fund
Fund
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
require(ofManagementFee < 10 ** 18); // Require management fee to be less than 100 percent require(ofPerformanceFee < 10 ** 18); // Require performance fee to be less than 100 percent isInvestAllowed[ofQuoteAsset] = true; owner = ofManager; MANAGEMENT_FEE_RATE = ofManagemen...
Mapping from asset to whether the asset is in a open make order as buy asset METHODS CONSTRUCTOR / @dev Should only be called via Version.setupFund(..) / @param withName human-readable descriptive name (not necessarily unique) / @param ofQuoteAsset Asset against which mgmt and performance fee is measured against and wh...
85358
Fund
enableInvestment
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
for (uint i = 0; i < ofAssets.length; ++i) { require(modules.pricefeed.assetIsRegistered(ofAssets[i])); isInvestAllowed[ofAssets[i]] = true; }
EXTERNAL METHODS EXTERNAL : ADMINISTRATION / @notice Enable investment in specified assets / @param ofAssets Array of assets to enable investment in
85358
Fund
disableInvestment
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
for (uint i = 0; i < ofAssets.length; ++i) { isInvestAllowed[ofAssets[i]] = false; }
/ @notice Disable investment in specified assets / @param ofAssets Array of assets to disable investment in
85358
Fund
requestInvestment
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
requests.push(Request({ participant: msg.sender, status: RequestStatus.active, requestAsset: investmentAsset, shareQuantity: shareQuantity, giveQuantity: giveQuantity, receiveQuantity: shareQuantity, timestamp: now, ...
EXTERNAL : PARTICIPATION / @notice Give melon tokens to receive shares of this fund / @dev Recommended to give some leeway in prices to account for possibly slightly changing prices / @param giveQuantity Quantity of Melon token times 10 ** 18 offered to receive shareQuantity / @param shareQuantity Quantity of shares ti...
85358
Fund
executeRequest
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
Request request = requests[id]; var (isRecent, , ) = modules.pricefeed.getPriceInfo(address(request.requestAsset)); require(isRecent); // sharePrice quoted in QUOTE_ASSET and multiplied by 10 ** fundDecimals uint costQuantity = toWholeShareUnit(mul(request.sh...
/ @notice Executes active investment and redemption requests, in a way that minimises information advantages of investor / @dev Distributes melon and shares according to the request / @param id Index of request to be executed / @dev Active investment or redemption request executed
85358
Fund
cancelRequest
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
requests[id].status = RequestStatus.cancelled;
/ @notice Cancels active investment and redemption requests / @param id Index of request to be executed
85358
Fund
redeemAllOwnedAssets
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
return emergencyRedeem(shareQuantity, ownedAssets);
/ @notice Redeems by allocating an ownership percentage of each asset to the participant / @dev Independent of running price feed! / @param shareQuantity Number of shares owned by the participant, which the participant would like to redeem for individual assets / @return Whether all assets sent to shareholder or not
85358
Fund
callOnExchange
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
require(modules.pricefeed.exchangeMethodIsAllowed( exchanges[exchangeIndex].exchange, method )); require((exchanges[exchangeIndex].exchangeAdapter).delegatecall( method, exchanges[exchangeIndex].exchange, orderAddresses, orderValues, identifier, v, r, s...
EXTERNAL : MANAGING / @notice Universal method for calling exchange functions through adapters / @notice See adapter contracts for parameters needed for each exchange / @param exchangeIndex Index of the exchange in the "exchanges" array / @param method Signature of the adapter method to call (as per ABI spec) / @param ...
85358
Fund
calcGav
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
// prices quoted in QUOTE_ASSET and multiplied by 10 ** assetDecimal uint[] memory allAssetHoldings = new uint[](ownedAssets.length); uint[] memory allAssetPrices = new uint[](ownedAssets.length); address[] memory tempOwnedAssets; tempOwnedAssets = ownedAssets; del...
PUBLIC METHODS PUBLIC METHODS : ACCOUNTING / @notice Calculates gross asset value of the fund / @dev Decimals in assets must be equal to decimals in PriceFeed for all entries in AssetRegistrar / @dev Assumes that module.pricefeed.getPriceInfo(..) returns recent prices / @return gav Gross asset value quoted in QUOTE_ASS...
85358
Fund
addAssetToOwnedAssets
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
isInOpenMakeOrder[ofAsset] = true; if (!isInAssetList[ofAsset]) { ownedAssets.push(ofAsset); isInAssetList[ofAsset] = true; }
/ @notice Add an asset to the list that this fund owns
85358
Fund
calcUnclaimedFees
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
// Management fee calculation uint timePassed = sub(now, atLastUnclaimedFeeAllocation.timestamp); uint gavPercentage = mul(timePassed, gav) / (1 years); managementFee = wmul(gavPercentage, MANAGEMENT_FEE_RATE); // Performance fee calculation // Handle potential d...
* @notice Calculates unclaimed fees of the fund manager @param gav Gross asset value in QUOTE_ASSET and multiplied by 10 ** shareDecimals @return { "managementFees": "A time (seconds) based fee in QUOTE_ASSET and multiplied by 10 ** shareDecimals", "performanceFees": "A performance (rise of...
85358
Fund
calcNav
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
nav = sub(gav, unclaimedFees);
/ @notice Calculates the Net asset value of this fund / @param gav Gross asset value of this fund in QUOTE_ASSET and multiplied by 10 ** shareDecimals / @param unclaimedFees The sum of both managementFee and performanceFee in QUOTE_ASSET and multiplied by 10 ** shareDecimals / @return nav Net asset value in QUOTE_ASSET...
85358
Fund
calcValuePerShare
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
valuePerShare = toSmallestShareUnit(totalValue) / numShares;
/ @notice Calculates the share price of the fund / @dev Convention for valuePerShare (== sharePrice) formatting: mul(totalValue / numShares, 10 ** decimal), to avoid floating numbers / @dev Non-zero share supply; value denominated in [base unit of melonAsset] / @param totalValue the total value in QUOTE_ASSET and multi...
85358
Fund
performCalculations
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
gav = calcGav(); // Reflects value independent of fees (managementFee, performanceFee, unclaimedFees) = calcUnclaimedFees(gav); nav = calcNav(gav, unclaimedFees); // The value of unclaimedFees measured in shares of this fund at current value feesShareQuantity = (gav == 0)...
* @notice Calculates essential fund metrics @return { "gav": "Gross asset value of this fund denominated in [base unit of melonAsset]", "managementFee": "A time (seconds) based fee", "performanceFee": "A performance (rise of sharePrice measured in QUOTE_ASSET) based fee", "unclaime...
85358
Fund
calcSharePriceAndAllocateFees
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
var ( gav, managementFee, performanceFee, unclaimedFees, feesShareQuantity, nav, sharePrice ) = performCalculations(); createShares(owner, feesShareQuantity); // Updates _totalSupply by creating shar...
/ @notice Converts unclaimed fees of the manager into fund shares / @return sharePrice Share price denominated in [base unit of melonAsset]
85358
Fund
emergencyRedeem
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
address ofAsset; uint[] memory ownershipQuantities = new uint[](requestedAssets.length); address[] memory redeemedAssets = new address[](requestedAssets.length); // Check whether enough assets held by fund for (uint i = 0; i < requestedAssets.length; ++i) { o...
PUBLIC : REDEEMING / @notice Redeems by allocating an ownership percentage only of requestedAssets to the participant / @dev This works, but with loops, so only up to a certain number of assets (right now the max is 4) / @dev Independent of running price feed! Note: if requestedAssets != ownedAssets then participant mi...
85358
Fund
quantityHeldInCustodyOfExchange
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
uint totalSellQuantity; // quantity in custody across exchanges uint totalSellQuantityInApprove; // quantity of asset in approve (allowance) but not custody of exchange for (uint i; i < exchanges.length; i++) { if (exchangesToOpenMakeOrders[exchanges[i].exchange][ofAsset].id...
PUBLIC : FEES / @dev Quantity of asset held in exchange according to associated order id / @param ofAsset Address of asset / @return Quantity of input asset held in exchange
85358
Fund
calcSharePrice
contract Fund is DSMath, DBC, Owned, Shares, FundInterface { event OrderUpdated(address exchange, bytes32 orderId, UpdateType updateType); // TYPES struct Modules { // Describes all modular parts, standardised through an interface CanonicalPriceFeed pricefeed; // Provides all external data...
(, , , , , sharePrice) = performCalculations(); return sharePrice;
PUBLIC VIEW METHODS / @notice Calculates sharePrice denominated in [base unit of melonAsset] / @return sharePrice Share price denominated in [base unit of melonAsset]
85358
CompetitionCompliance
CompetitionCompliance
contract CompetitionCompliance is ComplianceInterface, DBC, Owned { address public competitionAddress; // CONSTRUCTOR /// @dev Constructor /// @param ofCompetition Address of the competition contract function CompetitionCompliance(address ofCompetition) public {<FILL_FUNCTION_BODY>} ...
competitionAddress = ofCompetition;
CONSTRUCTOR / @dev Constructor / @param ofCompetition Address of the competition contract
85358
CompetitionCompliance
isInvestmentPermitted
contract CompetitionCompliance is ComplianceInterface, DBC, Owned { address public competitionAddress; // CONSTRUCTOR /// @dev Constructor /// @param ofCompetition Address of the competition contract function CompetitionCompliance(address ofCompetition) public { competitionAddres...
return competitionAddress == ofParticipant;
PUBLIC VIEW METHODS / @notice Checks whether investment is permitted for a participant / @param ofParticipant Address requesting to invest in a Melon fund / @param giveQuantity Quantity of Melon token times 10 ** 18 offered to receive shareQuantity / @param shareQuantity Quantity of shares times 10 ** 18 requested to b...
85358
CompetitionCompliance
isRedemptionPermitted
contract CompetitionCompliance is ComplianceInterface, DBC, Owned { address public competitionAddress; // CONSTRUCTOR /// @dev Constructor /// @param ofCompetition Address of the competition contract function CompetitionCompliance(address ofCompetition) public { competitionAddres...
return competitionAddress == ofParticipant;
/ @notice Checks whether redemption is permitted for a participant / @param ofParticipant Address requesting to redeem from a Melon fund / @param shareQuantity Quantity of shares times 10 ** 18 offered to redeem / @param receiveQuantity Quantity of Melon token times 10 ** 18 requested to receive for shareQuantity / @re...
85358
CompetitionCompliance
isCompetitionAllowed
contract CompetitionCompliance is ComplianceInterface, DBC, Owned { address public competitionAddress; // CONSTRUCTOR /// @dev Constructor /// @param ofCompetition Address of the competition contract function CompetitionCompliance(address ofCompetition) public { competitionAddres...
return CompetitionInterface(competitionAddress).isWhitelisted(x) && CompetitionInterface(competitionAddress).isCompetitionActive();
/ @notice Checks whether an address is whitelisted in the competition contract and competition is active / @param x Address / @return Whether the address is whitelisted
85358
CompetitionCompliance
changeCompetitionAddress
contract CompetitionCompliance is ComplianceInterface, DBC, Owned { address public competitionAddress; // CONSTRUCTOR /// @dev Constructor /// @param ofCompetition Address of the competition contract function CompetitionCompliance(address ofCompetition) public { competitionAddres...
competitionAddress = ofCompetition;
PUBLIC METHODS / @notice Changes the competition address / @param ofCompetition Address of the competition contract
85358
CanonicalRegistrar
registerAsset
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
assetInformation[ofAsset].exists = true; registeredAssets.push(ofAsset); updateAsset( ofAsset, inputName, inputSymbol, inputDecimals, inputUrl, inputIpfsHash, breakInBreakOut, inputStandar...
METHODS PUBLIC METHODS / @notice Registers an Asset information entry / @dev Pre: Only registrar owner should be able to register / @dev Post: Address ofAsset is registered / @param ofAsset Address of asset to be registered / @param inputName Human-readable name of the Asset as in ERC223 token standard / @param inputSy...
85358
CanonicalRegistrar
registerExchange
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
exchangeInformation[ofExchange].exists = true; registeredExchanges.push(ofExchange); updateExchange( ofExchange, ofExchangeAdapter, inputTakesCustody, inputFunctionSignatures ); assert(exchangeInformation[ofExchange].exist...
/ @notice Register an exchange information entry / @dev Pre: Only registrar owner should be able to register / @dev Post: Address ofExchange is registered / @param ofExchange Address of the exchange / @param ofExchangeAdapter Address of exchange adapter for this exchange / @param inputTakesCustody Whether this exchange...
85358
CanonicalRegistrar
updateAsset
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
Asset asset = assetInformation[ofAsset]; asset.name = inputName; asset.symbol = inputSymbol; asset.decimals = inputDecimals; asset.url = inputUrl; asset.ipfsHash = inputIpfsHash; asset.breakIn = ofBreakInBreakOut[0]; asset.breakOut = ofBreakInBrea...
/ @notice Updates description information of a registered Asset / @dev Pre: Owner can change an existing entry / @dev Post: Changed Name, Symbol, URL and/or IPFSHash / @param ofAsset Address of the asset to be updated / @param inputName Human-readable name of the Asset as in ERC223 token standard / @param inputSymbol H...
85358
CanonicalRegistrar
removeAsset
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
require(registeredAssets[assetIndex] == ofAsset); delete assetInformation[ofAsset]; // Sets exists boolean to false delete registeredAssets[assetIndex]; for (uint i = assetIndex; i < registeredAssets.length-1; i++) { registeredAssets[i] = registeredAssets[i+1]; ...
TODO: check max size of array before remaking this becomes untenable / @notice Deletes an existing entry / @dev Owner can delete an existing entry / @param ofAsset address for which specific information is requested
85358
CanonicalRegistrar
removeExchange
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
require(registeredExchanges[exchangeIndex] == ofExchange); delete exchangeInformation[ofExchange]; delete registeredExchanges[exchangeIndex]; for (uint i = exchangeIndex; i < registeredExchanges.length-1; i++) { registeredExchanges[i] = registeredExchanges[i+1]; ...
/ @notice Deletes an existing entry / @dev Owner can delete an existing entry / @param ofExchange address for which specific information is requested / @param exchangeIndex index of the exchange in array
85358
CanonicalRegistrar
getName
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
return assetInformation[ofAsset].name;
PUBLIC VIEW METHODS get asset specific information
85358
CanonicalRegistrar
exchangeIsRegistered
contract CanonicalRegistrar is DSThing, DBC { // TYPES struct Asset { bool exists; // True if asset is registered here bytes32 name; // Human-readable name of the Asset as in ERC223 token standard bytes8 symbol; // Human-readable symbol of the Asset as in ERC223 token standard ...
return exchangeInformation[ofExchange].exists;
get exchange-specific information
85358
SimplePriceFeed
SimplePriceFeed
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
registrar = CanonicalRegistrar(ofRegistrar); QUOTE_ASSET = ofQuoteAsset; superFeed = CanonicalPriceFeed(ofSuperFeed);
METHODS CONSTRUCTOR / @param ofQuoteAsset Address of quote asset / @param ofRegistrar Address of canonical registrar / @param ofSuperFeed Address of superfeed
85358
SimplePriceFeed
update
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
_updatePrices(ofAssets, newPrices);
EXTERNAL METHODS / @dev Only Owner; Same sized input arrays / @dev Updates price of asset relative to QUOTE_ASSET * Ex: * Let QUOTE_ASSET == MLN (base units), let asset == EUR-T, * let Value of 1 EUR-T := 1 EUR == 0.080456789 MLN, hence price 0.080456789 MLN / EUR-T * and let EUR-T decimals == 8. ...
85358
SimplePriceFeed
getQuoteAsset
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
return QUOTE_ASSET;
PUBLIC VIEW METHODS Get pricefeed specific information
85358
SimplePriceFeed
getPrice
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
Data data = assetsToPrices[ofAsset]; return (data.price, data.timestamp);
* @notice Gets price of an asset multiplied by ten to the power of assetDecimals @dev Asset has been registered @param ofAsset Asset for which price should be returned @return { "price": "Price formatting: mul(exchangePrice, 10 ** decimal), to avoid floating numbers", "timestamp": "Whe...
85358
SimplePriceFeed
getPrices
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
uint[] memory prices = new uint[](ofAssets.length); uint[] memory timestamps = new uint[](ofAssets.length); for (uint i; i < ofAssets.length; i++) { var (price, timestamp) = getPrice(ofAssets[i]); prices[i] = price; timestamps[i] = timestamp; }...
* @notice Price of a registered asset in format (bool areRecent, uint[] prices, uint[] decimals) @dev Convention for price formatting: mul(price, 10 ** decimal), to avoid floating numbers @param ofAssets Assets for which prices should be returned @return { "prices": "Array of prices",...
85358
SimplePriceFeed
_updatePrices
contract SimplePriceFeed is SimplePriceFeedInterface, DSThing, DBC { // TYPES struct Data { uint price; uint timestamp; } // FIELDS mapping(address => Data) public assetsToPrices; // Constructor fields address public QUOTE_ASSET; // Asset of a portfolio against...
updateId++; for (uint i = 0; i < ofAssets.length; ++i) { require(registrar.assetIsRegistered(ofAssets[i])); require(assetsToPrices[ofAssets[i]].timestamp != now); // prevent two updates in one block assetsToPrices[ofAssets[i]].timestamp = now; asset...
INTERNAL METHODS / @dev Internal so that feeds inheriting this one are not obligated to have an exposed update(...) method, but can still perform updates
85358
StakingPriceFeed
StakingPriceFeed
contract StakingPriceFeed is SimplePriceFeed { OperatorStaking public stakingContract; AssetInterface public stakingToken; // CONSTRUCTOR /// @param ofQuoteAsset Address of quote asset /// @param ofRegistrar Address of canonical registrar /// @param ofSuperFeed Address of superfeed ...
stakingContract = OperatorStaking(ofSuperFeed); // canonical feed *is* staking contract stakingToken = AssetInterface(stakingContract.stakingToken());
CONSTRUCTOR / @param ofQuoteAsset Address of quote asset / @param ofRegistrar Address of canonical registrar / @param ofSuperFeed Address of superfeed
85358
StakingPriceFeed
depositStake
contract StakingPriceFeed is SimplePriceFeed { OperatorStaking public stakingContract; AssetInterface public stakingToken; // CONSTRUCTOR /// @param ofQuoteAsset Address of quote asset /// @param ofRegistrar Address of canonical registrar /// @param ofSuperFeed Address of superfeed ...
require(stakingToken.transferFrom(msg.sender, address(this), amount)); require(stakingToken.approve(stakingContract, amount)); stakingContract.stake(amount, data);
EXTERNAL METHODS / @param amount Number of tokens to stake for this feed / @param data Data may be needed for some future applications (can be empty for now)
85358
StakingPriceFeed
unstake
contract StakingPriceFeed is SimplePriceFeed { OperatorStaking public stakingContract; AssetInterface public stakingToken; // CONSTRUCTOR /// @param ofQuoteAsset Address of quote asset /// @param ofRegistrar Address of canonical registrar /// @param ofSuperFeed Address of superfeed ...
stakingContract.unstake(amount, data);
/ @param amount Number of tokens to unstake for this feed / @param data Data may be needed for some future applications (can be empty for now)
85358
OperatorStaking
OperatorStaking
contract OperatorStaking is DBC { // EVENTS event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event StakeBurned(address indexed user, uint256 amount, bytes data); // TYPES ...
require(address(_stakingToken) != address(0)); stakingToken = _stakingToken; minimumStake = _minimumStake; numOperators = _numOperators; withdrawalDelay = _withdrawalDelay; StakeData memory temp = StakeData({ amount: 0, staker: address(0) }); stakeNodes.pu...
TODO: consider renaming "operator" depending on how this is implemented (i.e. is pricefeed staking itself?)
85358
OperatorStaking
stake
contract OperatorStaking is DBC { // EVENTS event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event StakeBurned(address indexed user, uint256 amount, bytes data); // TYPES ...
uint tailNodeId = stakeNodes[0].prev; stakedAmounts[msg.sender] += amount; updateStakerRanking(msg.sender); require(stakingToken.transferFrom(msg.sender, address(this), amount));
METHODS : STAKING
85358
OperatorStaking
isValidNode
contract OperatorStaking is DBC { // EVENTS event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event StakeBurned(address indexed user, uint256 amount, bytes data); // TYPES ...
// 0 is a sentinel and therefore invalid. // A valid node is the head or has a previous node. return id != 0 && (id == stakeNodes[0].next || stakeNodes[id].prev != 0);
VIEW FUNCTIONS
85358
OperatorStaking
insertNodeSorted
contract OperatorStaking is DBC { // EVENTS event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event StakeBurned(address indexed user, uint256 amount, bytes data); // TYPES ...
uint current = stakeNodes[0].next; if (current == 0) return insertNodeAfter(0, amount, staker); while (isValidNode(current)) { if (amount > stakeNodes[current].data.amount) { break; } current = stakeNodes[current].next; } ...
INTERNAL METHODS DOUBLY-LINKED LIST
85358
OperatorStaking
updateStakerRanking
contract OperatorStaking is DBC { // EVENTS event Staked(address indexed user, uint256 amount, uint256 total, bytes data); event Unstaked(address indexed user, uint256 amount, uint256 total, bytes data); event StakeBurned(address indexed user, uint256 amount, bytes data); // TYPES ...
uint newStakedAmount = stakedAmounts[_staker]; if (newStakedAmount == 0) { isRanked[_staker] = false; removeStakerFromArray(_staker); } else if (isRanked[_staker]) { removeStakerFromArray(_staker); insertNodeSorted(newStakedAmount, _staker)...
UPDATING OPERATORS
85358
CanonicalPriceFeed
CanonicalPriceFeed
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
registerAsset( ofQuoteAsset, quoteAssetName, quoteAssetSymbol, quoteAssetDecimals, quoteAssetUrl, quoteAssetIpfsHash, quoteAssetBreakInBreakOut, quoteAssetStandards, quoteAssetFunctionSignature...
METHODS CONSTRUCTOR / @dev Define and register a quote asset against which all prices are measured/based against / @param ofStakingAsset Address of staking asset (may or may not be quoteAsset) / @param ofQuoteAsset Address of quote asset / @param quoteAssetName Name of quote asset / @param quoteAssetSymbol Symbol for q...
85358
CanonicalPriceFeed
setupStakingPriceFeed
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
address ofStakingPriceFeed = new StakingPriceFeed( address(this), stakingToken, address(this) ); isStakingFeed[ofStakingPriceFeed] = true; StakingPriceFeed(ofStakingPriceFeed).setOwner(msg.sender); emit SetupPriceFeed(ofStakingPriceFee...
EXTERNAL METHODS / @notice Create a new StakingPriceFeed
85358
CanonicalPriceFeed
update
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
revert();
/ @dev override inherited update function to prevent manual update from authority
85358
CanonicalPriceFeed
burnStake
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
uint totalToBurn = add(stakedAmounts[user], stakeToWithdraw[user]); stakedAmounts[user] = 0; stakeToWithdraw[user] = 0; updateStakerRanking(user); emit StakeBurned(user, totalToBurn, "");
/ @dev Burn state for a pricefeed operator / @param user Address of pricefeed operator to burn the stake from
85358
CanonicalPriceFeed
stake
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
OperatorStaking.stake(amount, data);
PUBLIC METHODS STAKING
85358
CanonicalPriceFeed
collectAndUpdate
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
uint[] memory newPrices = pricesToCommit(ofAssets); priceHistory.push( HistoricalPrices({assets: ofAssets, prices: newPrices, timestamp: block.timestamp}) ); _updatePrices(ofAssets, newPrices);
function stakeFor( address user, uint amount, bytes data ) public pre_cond(isStakingFeed[user]) { OperatorStaking.stakeFor(user, amount, data); } AGGREGATION / @dev Only Owner; Same sized input arrays / @dev Updates price of asset relative to QUOTE_ASSET * Ex: * Let QUOTE_ASSET == MLN (base units), let asset == ...
85358
CanonicalPriceFeed
medianize
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
uint numValidEntries; for (uint i = 0; i < unsorted.length; i++) { if (unsorted[i] != 0) { numValidEntries++; } } if (numValidEntries < minimumPriceCount) { revert(); } uint counter; uint[] memory out...
/ @dev from MakerDao medianizer contract
85358
CanonicalPriceFeed
getQuoteAsset
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
return QUOTE_ASSET;
PUBLIC VIEW METHODS FEED INFORMATION
85358
CanonicalPriceFeed
hasRecentPrice
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
var ( , timestamp) = getPrice(ofAsset); return (sub(now, timestamp) <= VALIDITY);
PRICES / @notice Whether price of asset has been updated less than VALIDITY seconds ago / @param ofAsset Asset in registrar / @return isRecent Price information ofAsset is recent
85358
CanonicalPriceFeed
hasRecentPrices
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
for (uint i; i < ofAssets.length; i++) { if (!hasRecentPrice(ofAssets[i])) { return false; } } return true;
/ @notice Whether prices of assets have been updated less than VALIDITY seconds ago / @param ofAssets All assets in registrar / @return isRecent Price information ofAssets array is recent
85358
CanonicalPriceFeed
getInvertedPriceInfo
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
uint inputPrice; // inputPrice quoted in QUOTE_ASSET and multiplied by 10 ** assetDecimal (isRecent, inputPrice, assetDecimals) = getPriceInfo(ofAsset); // outputPrice based in QUOTE_ASSET and multiplied by 10 ** quoteDecimal uint quoteDecimals = getDecimals(QUOTE_ASSET);...
* @notice Gets inverted price of an asset @dev Asset has been initialised and its price is non-zero @dev Existing price ofAssets quoted in QUOTE_ASSET (convention) @param ofAsset Asset for which inverted price should be return @return { "isRecent": "Whether the price is fresh, given VA...
85358
CanonicalPriceFeed
getReferencePriceInfo
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
if (getQuoteAsset() == ofQuote) { (isRecent, referencePrice, decimal) = getPriceInfo(ofBase); } else if (getQuoteAsset() == ofBase) { (isRecent, referencePrice, decimal) = getInvertedPriceInfo(ofQuote); } else { revert(); // no suitable reference price ...
* @notice Gets reference price of an asset pair @dev One of the address is equal to quote asset @dev either ofBase == QUOTE_ASSET or ofQuote == QUOTE_ASSET @param ofBase Address of base asset @param ofQuote Address of quote asset @return { "isRecent": "Whether the price is fresh, ...
85358
CanonicalPriceFeed
getOrderPriceInfo
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
return mul(buyQuantity, 10 ** uint(getDecimals(sellAsset))) / sellQuantity;
/ @notice Gets price of Order / @param sellAsset Address of the asset to be sold / @param buyAsset Address of the asset to be bought / @param sellQuantity Quantity in base units being sold of sellAsset / @param buyQuantity Quantity in base units being bought of buyAsset / @return orderPrice Price as determined by an or...
85358
CanonicalPriceFeed
existsPriceOnAssetPair
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
return hasRecentPrice(sellAsset) && // Is tradable asset (TODO cleaner) and datafeed delivering data hasRecentPrice(buyAsset) && // Is tradable asset (TODO cleaner) and datafeed delivering data (buyAsset == QUOTE_ASSET || sellAsset == QUOTE_ASSET) && // One asset must be...
/ @notice Checks whether data exists for a given asset pair / @dev Prices are only upated against QUOTE_ASSET / @param sellAsset Asset for which check to be done if data exists / @param buyAsset Asset for which check to be done if data exists / @return Whether assets exist for given asset pair
85358
CanonicalPriceFeed
getPriceFeedsByOwner
contract CanonicalPriceFeed is OperatorStaking, SimplePriceFeed, CanonicalRegistrar { // EVENTS event SetupPriceFeed(address ofPriceFeed); struct HistoricalPrices { address[] assets; uint[] prices; uint timestamp; } // FIELDS bool public updatesAreAllowed =...
address[] memory ofPriceFeeds = new address[](numStakers); if (numStakers == 0) return ofPriceFeeds; uint current = stakeNodes[0].next; for (uint i; i < numStakers; i++) { StakingPriceFeed stakingFeed = StakingPriceFeed(stakeNodes[current].data.staker); if ...
/ @return Sparse array of addresses of owned pricefeeds
85358
Version
Version
contract Version is DBC, Owned, VersionInterface { // FIELDS bytes32 public constant TERMS_AND_CONDITIONS = 0xAA9C907B0D6B4890E7225C09CBC16A01CB97288840201AA7CDCB27F4ED7BF159; // Hashed terms and conditions as displayed on IPFS, decoded from base 58 // Constructor fields string public VERSION_NU...
VERSION_NUMBER = versionNumber; GOVERNANCE = ofGovernance; MELON_ASSET = ofMelonAsset; NATIVE_ASSET = ofNativeAsset; CANONICAL_PRICEFEED = ofCanonicalPriceFeed; COMPLIANCE = ofCompetitionCompliance;
METHODS CONSTRUCTOR / @param versionNumber SemVer of Melon protocol version / @param ofGovernance Address of Melon governance contract / @param ofMelonAsset Address of Melon asset contract
85358
Version
shutDown
contract Version is DBC, Owned, VersionInterface { // FIELDS bytes32 public constant TERMS_AND_CONDITIONS = 0xAA9C907B0D6B4890E7225C09CBC16A01CB97288840201AA7CDCB27F4ED7BF159; // Hashed terms and conditions as displayed on IPFS, decoded from base 58 // Constructor fields string public VERSION_NU...
isShutDown = true;
EXTERNAL METHODS
85358
Version
setupFund
contract Version is DBC, Owned, VersionInterface { // FIELDS bytes32 public constant TERMS_AND_CONDITIONS = 0xAA9C907B0D6B4890E7225C09CBC16A01CB97288840201AA7CDCB27F4ED7BF159; // Hashed terms and conditions as displayed on IPFS, decoded from base 58 // Constructor fields string public VERSION_NU...
require(!isShutDown); require(termsAndConditionsAreSigned(v, r, s)); require(CompetitionCompliance(COMPLIANCE).isCompetitionAllowed(msg.sender)); require(managerToFunds[msg.sender] == address(0)); // Add limitation for simpler migration process of shutting down and setting up fund ...
PUBLIC METHODS / @param ofFundName human-readable descriptive name (not necessarily unique) / @param ofQuoteAsset Asset against which performance fee is measured against / @param ofManagementFee A time based fee, given in a number which is divided by 10 ** 15 / @param ofPerformanceFee A time performance based fee, perf...
85358
Version
shutDownFund
contract Version is DBC, Owned, VersionInterface { // FIELDS bytes32 public constant TERMS_AND_CONDITIONS = 0xAA9C907B0D6B4890E7225C09CBC16A01CB97288840201AA7CDCB27F4ED7BF159; // Hashed terms and conditions as displayed on IPFS, decoded from base 58 // Constructor fields string public VERSION_NU...
Fund fund = Fund(ofFund); delete managerToFunds[msg.sender]; fund.shutDown(); emit FundUpdated(ofFund);
/ @dev Dereference Fund and shut it down / @param ofFund Address of the fund to be shut down
85358
Version
termsAndConditionsAreSigned
contract Version is DBC, Owned, VersionInterface { // FIELDS bytes32 public constant TERMS_AND_CONDITIONS = 0xAA9C907B0D6B4890E7225C09CBC16A01CB97288840201AA7CDCB27F4ED7BF159; // Hashed terms and conditions as displayed on IPFS, decoded from base 58 // Constructor fields string public VERSION_NU...
return ecrecover( // Parity does prepend \x19Ethereum Signed Message:\n{len(message)} before signing. // Signature order has also been changed in 1.6.7 and upcoming 1.7.x, // it will return rsv (same as geth; where v is [27, 28]). // Note that if you are u...
PUBLIC VIEW METHODS / @dev Proof that terms and conditions have been read and understood / @param v ellipitc curve parameter v / @param r ellipitc curve parameter r / @param s ellipitc curve parameter s / @return signed Whether or not terms and conditions have been read and understood
85359
Ownable
null
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() {<FILL_FUNCTION_BODY>} /** * @dev Throws if called by any account other than the owner. */ modi...
owner = msg.sender;
* * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account.
85359
Ownable
transferOwnership
contract Ownable { address public owner; /** * @dev The Ownable constructor sets the original `owner` of the contract to the sender * account. */ constructor() { owner = msg.sender; } /** * @dev Throws if called by any account other than the owner. ...
if (newOwner != address(0)) { owner = newOwner; }
* * @dev Allows the current owner to transfer control of the contract to a newOwner. * @param newOwner The address to transfer ownership to.
85359
Context
_msgSender
contract Context { constructor () { } // solhint-disable-previous-line no-empty-blocks function _msgSender() internal view returns (address payable) {<FILL_FUNCTION_BODY>} }
return msg.sender;
solhint-disable-previous-line no-empty-blocks
85359
HYPE_Finance
null
contract HYPE_Finance is ERC20, ERC20Detailed { using SafeERC20 for IERC20; using Address for address; using SafeMath for uint; //address public owner; constructor () ERC20Detailed("HYPE-Finance", "HYPE", 18) {<FILL_FUNCTION_BODY>} }
owner = msg.sender; _totalSupply = 10000 *(10**uint256(18)); _balances[msg.sender] = _totalSupply;
address public owner;
85361
HumanStandardToken
HumanStandardToken
contract HumanStandardToken is StandardToken { /* Public variables of the token */ string public name; //名称: eg Simon Bucks uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. I...
balances[msg.sender] = _initialAmount; // 初始token数量给予消息发送者 totalSupply = _initialAmount; // 设置初始总量 name = _tokenName; // token名称 decimals = _decimalUnits; // 小数位数 symbol = _tokenSymbol; // token简称
版本
85361
HumanStandardToken
approveAndCall
contract HumanStandardToken is StandardToken { /* Public variables of the token */ string public name; //名称: eg Simon Bucks uint8 public decimals; //最多的小数位数,How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. I...
allowed[msg.sender][_spender] = _value; Approval(msg.sender, _spender, _value); //call the receiveApproval function on the contract you want to be notified. This crafts the function signature manually so one doesn't have to include a contract in here just for this. //receiveApproval...
Approves and then calls the receiving contract
85362
CryptoTicketsICO
setRate
contract CryptoTicketsICO { using SafeMath for uint; uint public constant Tokens_For_Sale = 525000000*1e18; // Tokens for Sale without bonuses(HardCap) // Style: Caps should not be used for vars, only for consts! uint public Rate_Eth = 298; // Rate USD per ETH uint public Token_Price = 25 *...
Rate_Eth = _RateEth; Token_Price = 25*Rate_Eth;
function for changing rate of ETH and price of token