/*...*/contractTetherTokenisPausable, StandardToken, BlackList {stringpublic name;stringpublic symbol;uintpublic decimals;addresspublic upgradedAddress;boolpublic deprecated;// The contract can be initialized with a number of tokens// All the tokens are deposited to the owner address//// @param _balance Initial supply of the contract// @param _name Token Name// @param _symbol Token symbol// @param _decimals Token decimalsfunctionTetherToken(uint_initialSupply,string_name,string_symbol,uint_decimals) public { _totalSupply = _initialSupply; name = _name; symbol = _symbol; decimals = _decimals; balances[owner] = _initialSupply; deprecated =false; }// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctiontransfer(address_to,uint_value) publicwhenNotPaused {require(!isBlackListed[msg.sender]);if (deprecated) {returnUpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else {return super.transfer(_to, _value); } }// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctiontransferFrom(address_from,address_to,uint_value) publicwhenNotPaused {require(!isBlackListed[_from]);if (deprecated) {returnUpgradedStandardToken(upgradedAddress).transferFromByLegacy(msg.sender, _from, _to, _value); } else {return super.transferFrom(_from, _to, _value); } }// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctionbalanceOf(address who) publicconstantreturns (uint) {if (deprecated) {returnUpgradedStandardToken(upgradedAddress).balanceOf(who); } else {return super.balanceOf(who); } }// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctionapprove(address_spender,uint_value) publiconlyPayloadSize(2 * 32) {if (deprecated) {returnUpgradedStandardToken(upgradedAddress).approveByLegacy(msg.sender, _spender, _value); } else {return super.approve(_spender, _value); } }// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctionallowance(address_owner,address_spender) publicconstantreturns (uint remaining) {if (deprecated) {returnStandardToken(upgradedAddress).allowance(_owner, _spender); } else {return super.allowance(_owner, _spender); } }// deprecate current contract in favour of a new onefunctiondeprecate(address_upgradedAddress) publiconlyOwner { deprecated =true; upgradedAddress = _upgradedAddress;Deprecate(_upgradedAddress); }// deprecate current contract if favour of a new onefunctiontotalSupply() publicconstantreturns (uint) {if (deprecated) {returnStandardToken(upgradedAddress).totalSupply(); } else {return _totalSupply; } }// Issue a new amount of tokens// these tokens are deposited into the owner address//// @param _amount Number of tokens to be issuedfunctionissue(uint amount) publiconlyOwner {require(_totalSupply + amount > _totalSupply);require(balances[owner] + amount > balances[owner]); balances[owner] += amount; _totalSupply += amount;Issue(amount); }// Redeem tokens.// These tokens are withdrawn from the owner address// if the balance must be enough to cover the redeem// or the call will fail.// @param _amount Number of tokens to be issuedfunctionredeem(uint amount) publiconlyOwner {require(_totalSupply >= amount);require(balances[owner] >= amount); _totalSupply -= amount; balances[owner] -= amount;Redeem(amount); }functionsetParams(uint newBasisPoints,uint newMaxFee) publiconlyOwner {// Ensure transparency by hardcoding limit beyond which fees can never be addedrequire(newBasisPoints <20);require(newMaxFee <50); basisPointsRate = newBasisPoints; maximumFee = newMaxFee.mul(10**decimals);Params(basisPointsRate, maximumFee); }// Called when new token are issuedeventIssue(uint amount);// Called when tokens are redeemedeventRedeem(uint amount);// Called when contract is deprecatedeventDeprecate(address newAddress);// Called if contract ever adds feeseventParams(uint feeBasisPoints, uint maxFee);}
For everything in the contract code (except comment sections), there is at least one entity that represents it in the Glider engine and allows the filtering and analysis of that data.
Contracts
In Glider, every contract, interface, and library is represented by the Contract class.
A set of contracts is represented by Contracts class.
There are special flags and methods to distinguish or filter them.
In USDT the TetherToken will have a contract object for:
contract TetherToken
Contract objects can be used to obtain full information about the contract, such as the deployed address, compiler versions/pragmas, state variables, base and derived contracts, etc.
That said, the libraries, interfaces, and base contracts used in USDT code will also have a Contract object representing them:
As one address (one main contract) can have multiple interfaces, libraries, contracts declared or even derived, built in a complex folder structure, Glider will generate Contract objects for all of them, though the address will be the same, and only one contract will be considered to be the main.
For the contract that is "main", meaning that its functions are being executed if a transaction is called, the engine marks this contract as "main" to distinguish it from others on the same address; see Contract.is_main().
While the Contract class is used to obtain information about a single contract, the Contracts class is used to query and/or filter contracts from a set or the whole database.
Contracts contain references to other entities that belong to those contracts:
Each function in the contract code is represented by a Function object.
The set of functions is represented by the Functions object.
E.g transfer function in the TetherToken contract
// Forward ERC20 methods to upgraded contract if this one is deprecatedfunctiontransfer(address_to,uint_value) publicwhenNotPaused {require(!isBlackListed[msg.sender]);if (deprecated) {returnUpgradedStandardToken(upgradedAddress).transferByLegacy(msg.sender, _to, _value); } else {return super.transfer(_to, _value); } }
Or any other function, for example mul, div, sub, add functions in the SafeMath library:
librarySafeMath {functionmul(uint256 a,uint256 b) internalpurereturns (uint256) {if (a ==0) {return0; }uint256 c = a * b;assert(c / a == b);return c; }functiondiv(uint256 a,uint256 b) internalpurereturns (uint256) {// assert(b > 0); // Solidity automatically throws when dividing by 0uint256 c = a / b;// assert(a == b * c + a % b); // There is no case in which this doesn't holdreturn c; }functionsub(uint256 a,uint256 b) internalpurereturns (uint256) {assert(b <= a);return a - b; }functionadd(uint256 a,uint256 b) internalpurereturns (uint256) {uint256 c = a + b;assert(c >= a);return c; }}
Modifiers
Each modifier is represented by a Modifier object.
The set of modifiers is represented by a Modifiers object.
And whenNotPaused and whenPaused modifiers in Pauable:
modifierwhenNotPaused() {require(!paused); _; }/** * @dev Modifier to make a function callable only when the contract is paused. */modifierwhenPaused() {require(paused); _; }
Function and Modifier objects can be used to obtain data about a specific object, while Functions and Modifiers objects are used to query and/or filter functions/modifiers by specific properties from a set or the whole database.
Functions have references to the modifiers that are being used in the function and vice versa.
One of the most important references that functions/modifiers have is their reference to their instructions.
Instructions
An easy way to think of an instruction is anything that ends with a semicolon ';' in the code. However, this is not always the case, as with some instructions like if-statements, don't use semicolons.
The constructors are also considered functions; special methods can be used to query and check that a function is a constructor.
As with other entities, the Instruction object is used to obtain data and analyze one specific instruction, and the Instructions object is used to query/filter instructions in a set or in a whole database.
An instruction on its own usually consists of different parts, for example:
require(!paused);
This instruction consists of a require() call, a boolean expression !paused
In Glider, the "parts" of the instruction are called values.
Value
The Value object represents a "part" of the instruction. Value by itself is a base class for different types of values such as Call, Var, Literal etc.
E.g. in the instruction
require(paused);<-Var-><----Call----->
The "part" representing the require call, will be of type Call (class derived from Value), and the value paused will be of type Var (class derived from Value) as it represents a variable.
Arguments
The Argument and Arguments object are mainly used in context of functions and modifiers (as they are the ones having arguments).
The newBasisPoints and newMaxFee are arguments of the function, and an Argument object will be used to represent each of them.
The Argument class is used to represent a single argument of the function/modifier (callable), while the Arguments class is used to represent a set of arguments.
StateVariables
The contracts also have state (storage) variables defined; Glider allows the users to query, filter and analyze them as well.
mapping(address=>uint) public balances;// additional variables for use if transaction fees ever became necessaryuintpublic basisPointsRate =0;uintpublic maximumFee =0;
These state variables will be represented by a StateVariable object each or a StateVariables object for a set (or whole database).