Skip to content
This repository was archived by the owner on Feb 18, 2020. It is now read-only.

Contract interfaces #80

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .soliumignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
docs
22 changes: 22 additions & 0 deletions .soliumrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"extends": "solium:all",
"plugins": [
"security"
],
"rules": {
"quotes": [
"error",
"double"
],
"indentation": [
"error",
4
],
"arg-overflow": [
"warning",
5
],
"error-reason": 0,
"security/no-assign-params": 0
}
}
1,336 changes: 692 additions & 644 deletions contracts/DutchExchange.sol

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions contracts/DutchExchangeProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.5.2;

import "@gnosis.pm/util-contracts/contracts/Proxy.sol";


contract DutchExchangeProxy is Proxy {
constructor(address _masterCopy) public Proxy(_masterCopy) {}
}
1 change: 1 addition & 0 deletions contracts/DxDevDependencies.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ import "./TokenFRTProxy.sol";
import "./DutchExchange.sol";
import "./DutchExchangeProxy.sol";


contract DxDevDependencies {}
25 changes: 17 additions & 8 deletions contracts/ForTestingOnly/InternalTests.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@ pragma solidity ^0.5.2;

import "../DutchExchange.sol";

contract InternalTests is DutchExchange {
function settleFeePub(address primaryToken, address secondaryToken, uint auctionIndex, address user, uint amount)
public
returns (uint)
{
return super.settleFee(primaryToken, secondaryToken, auctionIndex, amount);
}

contract InternalTests is DutchExchange {
constructor(
TokenFRT _FRT,
TokenOWL _OWL,
Expand All @@ -19,7 +13,22 @@ contract InternalTests is DutchExchange {
uint _thresholdNewTokenPair,
uint _thresholdNewAuction
) public {
setupDutchExchange(_FRT, _OWL, _owner, _ETH, _ETHUSDOracle, _thresholdNewTokenPair, _thresholdNewAuction);
setupDutchExchange(
_FRT,
_OWL,
_owner,
_ETH,
_ETHUSDOracle,
_thresholdNewTokenPair,
_thresholdNewAuction
);
}

function settleFeePub(address primaryToken, address secondaryToken, uint auctionIndex, address user, uint amount)
public
returns (uint)
{
return super.settleFee(primaryToken, secondaryToken, auctionIndex, amount);
}

function getFeeRatioForJS(address user) public view returns (uint feeRatioNum, uint feeRatioDen) {
Expand Down
1 change: 1 addition & 0 deletions contracts/ForTestingOnly/TokenOMG.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.5.2;

import "@gnosis.pm/util-contracts/contracts/GnosisStandardToken.sol";


contract TokenOMG is GnosisStandardToken {
string public constant symbol = "OMG";
string public constant name = "OMG Test Token";
Expand Down
1 change: 1 addition & 0 deletions contracts/ForTestingOnly/TokenRDN.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.5.2;

import "@gnosis.pm/util-contracts/contracts/GnosisStandardToken.sol";


contract TokenRDN is GnosisStandardToken {
string public constant symbol = "RDN";
string public constant name = "Raiden network tokens";
Expand Down
4 changes: 3 additions & 1 deletion contracts/Migrations.sol
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
pragma solidity ^0.5.2;


contract Migrations {
address public owner;
uint public last_completed_migration;

modifier restricted() {
if (msg.sender == owner) _;
if (msg.sender == owner)
_;
}

constructor() public {
Expand Down
3 changes: 3 additions & 0 deletions contracts/Oracle/DSAuth.sol
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
pragma solidity ^0.5.2;


contract DSAuthority {
function canCall(address src, address dst, bytes4 sig) public view returns (bool);
}


contract DSAuthEvents {
event LogSetAuthority(address indexed authority);
event LogSetOwner(address indexed owner);
}


contract DSAuth is DSAuthEvents {
DSAuthority public authority;
address public owner;
Expand Down
6 changes: 6 additions & 0 deletions contracts/Oracle/DSMath.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.5.2;


contract DSMath {
/*
standard uint256 functions
Expand All @@ -24,6 +25,7 @@ contract DSMath {
function min(uint256 x, uint256 y) internal pure returns (uint256 z) {
return x <= y ? x : y;
}

function max(uint256 x, uint256 y) internal pure returns (uint256 z) {
return x >= y ? x : y;
}
Expand Down Expand Up @@ -51,6 +53,7 @@ contract DSMath {
function hmin(uint128 x, uint128 y) internal pure returns (uint128 z) {
return x <= y ? x : y;
}

function hmax(uint128 x, uint128 y) internal pure returns (uint128 z) {
return x >= y ? x : y;
}
Expand All @@ -62,6 +65,7 @@ contract DSMath {
function imin(int256 x, int256 y) internal pure returns (int256 z) {
return x <= y ? x : y;
}

function imax(int256 x, int256 y) internal pure returns (int256 z) {
return x >= y ? x : y;
}
Expand Down Expand Up @@ -91,6 +95,7 @@ contract DSMath {
function wmin(uint128 x, uint128 y) internal pure returns (uint128) {
return hmin(x, y);
}

function wmax(uint128 x, uint128 y) internal pure returns (uint128) {
return hmax(x, y);
}
Expand Down Expand Up @@ -147,6 +152,7 @@ contract DSMath {
function rmin(uint128 x, uint128 y) internal pure returns (uint128) {
return hmin(x, y);
}

function rmax(uint128 x, uint128 y) internal pure returns (uint128) {
return hmax(x, y);
}
Expand Down
21 changes: 18 additions & 3 deletions contracts/Oracle/DSNote.sol
Original file line number Diff line number Diff line change
@@ -1,18 +1,33 @@
pragma solidity ^0.5.2;


contract DSNote {
event LogNote(bytes4 indexed sig, address indexed guy, bytes32 indexed foo, bytes32 bar, uint wad, bytes fax);
event LogNote(
bytes4 indexed sig,
address indexed guy,
bytes32 indexed foo,
bytes32 bar,
uint wad,
bytes fax
);

modifier note {
bytes32 foo;
bytes32 bar;

// solium-disable-next-line security/no-inline-assembly
assembly {
foo := calldataload(4)
bar := calldataload(36)
}

emit LogNote(msg.sig, msg.sender, foo, bar, msg.value, msg.data);
emit LogNote(
msg.sig,
msg.sender,
foo,
bar,
msg.value,
msg.data
);

_;
}
Expand Down
1 change: 1 addition & 0 deletions contracts/Oracle/DSThing.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ import "../Oracle/DSMath.sol";
import "../Oracle/DSAuth.sol";
import "../Oracle/DSNote.sol";


contract DSThing is DSAuth, DSNote, DSMath {}
4 changes: 4 additions & 0 deletions contracts/Oracle/DSValue.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,25 @@ pragma solidity ^0.5.2;

import "../Oracle/DSThing.sol";


contract DSValue is DSThing {
bool has;
bytes32 val;
function peek() public view returns (bytes32, bool) {
return (val, has);
}

function read() public view returns (bytes32) {
(bytes32 wut, bool _has) = peek();
assert(_has);
return wut;
}

function poke(bytes32 wut) public payable note auth {
val = wut;
has = true;
}

function void() public payable note auth {
// unset the value
has = false;
Expand Down
4 changes: 3 additions & 1 deletion contracts/Oracle/Medianizer.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pragma solidity ^0.5.2;

import "./DSValue.sol";


contract Medianizer is DSValue {
mapping(bytes12 => address) public values;
mapping(address => bytes12) public indexes;
Expand Down Expand Up @@ -78,7 +79,8 @@ contract Medianizer is DSValue {
}
}

if (ctr < minimun) return (val, false);
if (ctr < minimun)
return (val, false);

bytes32 value;
if (ctr % 2 == 0) {
Expand Down
1 change: 1 addition & 0 deletions contracts/Oracle/PriceFeed.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pragma solidity ^0.5.2;

import "../Oracle/DSThing.sol";


contract PriceFeed is DSThing {
uint128 val;
uint32 public zzz;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ This contract is the interface between the MakerDAO priceFeed and our DX platfor

import "../Oracle/PriceFeed.sol";
import "../Oracle/Medianizer.sol";
import "../interfaces/PriceOracleInterface.sol";

contract PriceOracleInterface {

contract PriceOracle is PriceOracleInterface {
address public priceFeedSource;
address public owner;
bool public emergencyMode;
Expand All @@ -24,6 +26,7 @@ contract PriceOracleInterface {
owner = _owner;
priceFeedSource = _priceFeedSource;
}

/// @dev gives the owner the possibility to put the Interface into an emergencyMode, which will
/// output always a price of 600 USD. This gives everyone time to set up a new pricefeed.
function raiseEmergency(bool _emergencyMode) public onlyOwner {
Expand Down
12 changes: 8 additions & 4 deletions contracts/TokenFRT.sol
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
pragma solidity ^0.5.2;

import "./interfaces/TokenFRTInterface.sol";

import "@gnosis.pm/util-contracts/contracts/Proxy.sol";
import "@gnosis.pm/util-contracts/contracts/GnosisStandardToken.sol";


/// @title Standard token contract with overflow protection
contract TokenFRT is Proxied, GnosisStandardToken {
contract TokenFRT is Proxied, GnosisStandardToken, TokenFRTInterface {
address public owner;

string public constant symbol = "MGN";
string public constant name = "Magnolia Token";
uint8 public constant decimals = 18;

struct unlockedToken {
struct UnlockedToken {
uint amountUnlocked;
uint withdrawalTime;
}
Expand All @@ -21,8 +24,8 @@ contract TokenFRT is Proxied, GnosisStandardToken {
*/
address public minter;

// user => unlockedToken
mapping(address => unlockedToken) public unlockedTokens;
// user => UnlockedToken
mapping(address => UnlockedToken) public unlockedTokens;

// user => amount
mapping(address => uint) public lockedTokenBalances;
Expand Down Expand Up @@ -97,6 +100,7 @@ contract TokenFRT is Proxied, GnosisStandardToken {
return b;
}
}

/// @dev Returns whether an add operation causes an overflow
/// @param a First addend
/// @param b Second addend
Expand Down
1 change: 1 addition & 0 deletions contracts/TokenFRTProxy.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ pragma solidity ^0.5.2;
import "@gnosis.pm/util-contracts/contracts/Proxy.sol";
import "@gnosis.pm/util-contracts/contracts/GnosisStandardToken.sol";


contract TokenFRTProxy is Proxy, GnosisStandardToken {
/// @dev State variables remain for Blockchain exploring Proxied Token contracts
address public owner;
Expand Down
1 change: 1 addition & 0 deletions contracts/base/AuctioneerManaged.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.5.2;


contract AuctioneerManaged {
// auctioneer has the power to manage some variables
address public auctioneer;
Expand Down
2 changes: 2 additions & 0 deletions contracts/base/DxMath.sol
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pragma solidity ^0.5.2;


contract DxMath {
// > Math fns
function min(uint a, uint b) public pure returns (uint) {
Expand All @@ -17,6 +18,7 @@ contract DxMath {
return uint(a);
}
}

/// @dev Returns whether an add operation causes an overflow
/// @param a First addend
/// @param b Second addend
Expand Down
1 change: 1 addition & 0 deletions contracts/base/DxUpgrade.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "./DxMath.sol";
import "./AuctioneerManaged.sol";
import "@gnosis.pm/util-contracts/contracts/Proxy.sol";


contract DxUpgrade is Proxied, AuctioneerManaged, DxMath {
uint constant WAITING_PERIOD_CHANGE_MASTERCOPY = 30 days;

Expand Down
3 changes: 2 additions & 1 deletion contracts/base/EthOracle.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
pragma solidity ^0.5.2;

import "../Oracle/PriceOracleInterface.sol";
import "../interfaces/PriceOracleInterface.sol";
import "./AuctioneerManaged.sol";
import "./DxMath.sol";


contract EthOracle is AuctioneerManaged, DxMath {
uint constant WAITING_PERIOD_CHANGE_ORACLE = 30 days;

Expand Down
Loading