Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Market maker review #3

Merged
merged 9 commits into from
May 31, 2017
Merged

Market maker review #3

merged 9 commits into from
May 31, 2017

Conversation

cag
Copy link
Contributor

@cag cag commented May 30, 2017

No description provided.

@Georgi87 Georgi87 merged commit 6c9c577 into master May 31, 2017
Copy link
Contributor Author

@cag cag left a comment

Choose a reason for hiding this comment

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

Some more stuff to do

require(outcomeTokenDistribution.length > 1);
uint[2] memory outcomeTokenRange = getOutcomeTokenRange(outcomeTokenDistribution);
uint invB = uint(Math.ln(outcomeTokenDistribution.length * ONE)) / 10000;
require(market.eventContract().getOutcomeCount() > 0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Change to > 1

public
returns(uint costs)
/// @return Returns costLevel
function calcCostFunction(uint logN, int[] netOutcomeTokensSold, uint funding)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rename to calcCostLevel

// Math.safeToSub(netOutcomeTokensSold[outcomeTokenIndex], outcomeTokenCount) &&
int(outcomeTokenCount) >= 0
);
netOutcomeTokensSold[outcomeTokenIndex] -= int(outcomeTokenCount);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replace with overloaded Math.sub

// Math.safeToAdd(netOutcomeTokensSold[outcomeTokenIndex], outcomeTokenCount) &&
int(outcomeTokenCount) >= 0
);
netOutcomeTokensSold[outcomeTokenIndex] += int(outcomeTokenCount);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replace with overloaded Math.add

Copy link
Contributor

Choose a reason for hiding this comment

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

line 71: self.assertFalse(self.math.safeToAdd(2**256 - 1, 1))
in utils/test_math.py fails because the test assumes unsigned integers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yes, this is going to be tricky... to be honest, I wasn't sure how the tests would handle overloading in ambiguous cases. I'm guessing the current behavior is to just pick one version and stick with it. There may be a way to test it, but I'm not sure if changes need to be made at the pyethereum level or the AbstractTestContracts level.

Do you mind pushing up a branch for me to look at?

Copy link
Contributor

Choose a reason for hiding this comment

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

This is an issue with pyethereum. I opened an issue for this long time ago: ethereum/pyethereum#418

How does truffle handle this? Do you know?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Truffle does handle this situation with Solidity tests. JS tests cause some Unspecified AssertionError

Copy link
Contributor

Choose a reason for hiding this comment

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

Lets comment out this assertion and add a comment, why this currently not works.

profits = (costsBefore - costsAfter) * (funding / 10000) * (100000 - 2) / 100000 / ONE;
require(costLevelBefore >= costLevelAfter);
// Take the floor
profits = uint(costLevelBefore - costLevelAfter) / ONE;
}

/// @dev Returns current price for given outcome token
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make this more accurate


require(
int(outcomeTokenCount) >= 0 &&
netOutcomeTokensSold[outcomeTokenIndex] + int(outcomeTokenCount) >= netOutcomeTokensSold[outcomeTokenIndex]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Factor into safeToAdd/add


require(
int(outcomeTokenCount) >= 0 &&
netOutcomeTokensSold[outcomeTokenIndex] - int(outcomeTokenCount) <= netOutcomeTokensSold[outcomeTokenIndex]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Factor into safeToSub/sub

return b * math.log(
sum([math.exp(share_count / b + token_count / b) for share_count in token_distribution]) -
sum([math.exp(share_count / b) for index, share_count in enumerate(token_distribution) if index != token_index])
) - token_distribution[token_index]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider putting back, but at least implement it down the line and test with gnosis.js

(10, 5),
(10*10**18, 5000),
(10*10**18, 5),
(10, 5 * 10 ** 18),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Use self.s.block.set_balance to make some extreme tests


for x in chain(
(MIN_POWER, -497882689251500345055, -1),
(random.randrange(MIN_POWER, 0) for _ in range(10)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could potentially factor these back up into the normal domain test cases

@cag
Copy link
Contributor Author

cag commented May 31, 2017 via email

@Georgi87 Georgi87 deleted the market-maker-review branch June 6, 2017 15: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