Skip to content

DSR#2128

Closed
nuevoalex wants to merge 9 commits into
masterfrom
dsr_dai
Closed

DSR#2128
nuevoalex wants to merge 9 commits into
masterfrom
dsr_dai

Conversation

@nuevoalex
Copy link
Copy Markdown
Contributor

Integrates the DSR with our escrowed funds.

Funds are now escrowed on a Universe basis. If DSR is on funds are saved in the daiPot and if not they are simply kept as DAI (Cash).

The DSR can be toggled on or off when it crosses a threshold determined by the maximum movement in the DSR (TODO currently on getting that value from the actual MDAI contracts). Toggling awards the tx sender minted REP.

When funds are needed in Dai we exit only the amount required from the pot. Some rounding correction is required for that part of the code.

At any time anyone may sweep excess funds acquired through interest into the next dispute window using the sweepInterest function on the Universe.

These changes required some additional refactoring to get the Universe creation gas costs down and to get the Market contract byte size sown.

@nuevoalex nuevoalex requested a review from adrake33 May 10, 2019 18:47
@nuevoalex nuevoalex requested a review from MicahZoltu May 10, 2019 18:55
@adrake33
Copy link
Copy Markdown
Contributor

CI is currently failing: /augur/packages/augur-core/source/contracts/TestNetDaiPot.sol:32:42: error: Syntax error: unexpected token { []

Copy link
Copy Markdown
Contributor

@adrake33 adrake33 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, but did have some questions/suggestions.

event Mint(address indexed target, uint256 value);
event Burn(address indexed target, uint256 value);

mapping (address => uint) public wards;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: recommend using uint256 instead of uint in this code since we use uint256 explicitly throughout the rest of the code.

uint256 public supply;
mapping(address => mapping(address => uint256)) internal allowed;

uint8 constant public decimals = 18;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this variable is unused and can be removed.

function getTypeName() public view returns (bytes32) {
return "Cash";
function sub(uint x, uint y) internal pure returns (uint z) {
require((z = x - y) <= x, "math-sub-underflow");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like this and the other math functions below should be merged with SafeMathUint256.sol. Is there a reason to keep them separate?

string constant public name = "Cash";
string constant public symbol = "CASH";

uint256 constant public DAI_ONE = 10 ** 27;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is 10 ^ 27 used? Isn't Dai precision 18 digits?

balances[_target] = balances[_target].sub(_amount);
supply = supply.sub(_amount);

emit Burn(_target, _amount);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we want to emit a Transfer event here since this is done in the mint function?

@@ -1,9 +1,13 @@
import * as path from 'path';
import { join } from 'bluebird';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This import looks like it can be removed.

require((z = x - y) <= x);
}

function hope(address usr) public { can[msg.sender][usr] = 1; }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming can, hope, nope, wish, & suck are Dai terminology? Recommend adding more comments to the Dai-related contracts to improve clarity.

function migrateMarketOut(IUniverse _destinationUniverse) public returns (bool) {
IMarket _market = IMarket(msg.sender);
require(isContainerForMarket(_market));
markets[msg.sender] = false;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

msg.sender should probably be cast as an address here.

markets[msg.sender] = false;
uint256 _cashBalance = marketBalance[address(msg.sender)];
uint256 _marketOI = _market.getShareToken(0).totalSupply().mul(_market.getNumTicks());
withdraw(address(this), _cashBalance, msg.sender);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here too.

return bit == usr || can[bit][usr] == 1;
}

function suck(address, address v, uint rad) public {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of the first param? It doesn't seem to be used.

return mint(usr, wad);
}

function joinBurn(address usr, uint wad) public returns (bool) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two functions don't follow variable naming convention. Both in their word choice and in the _ prefix.

event Mint(address indexed target, uint256 value);
event Burn(address indexed target, uint256 value);

mapping (address => uint) public wards;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Recommend against copying Maker's naming convention (wards).

@nuevoalex nuevoalex closed this Jul 17, 2019
@nuevoalex nuevoalex deleted the dsr_dai branch July 17, 2019 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants