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

Adding market with price logger; Integration into Futarchy oracle; #30

Merged
merged 23 commits into from
Aug 23, 2017

Conversation

Georgi87
Copy link
Contributor

No description provided.

@Georgi87 Georgi87 requested a review from cag August 16, 2017 17:40
@codecov-io
Copy link

codecov-io commented Aug 21, 2017

Codecov Report

Merging #30 into master will increase coverage by 6.48%.
The diff coverage is 82.35%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #30      +/-   ##
=========================================
+ Coverage   85.01%   91.5%   +6.48%     
=========================================
  Files          25      27       +2     
  Lines         634     671      +37     
  Branches      106     111       +5     
=========================================
+ Hits          539     614      +75     
+ Misses         95      57      -38
Impacted Files Coverage Δ
contracts/Markets/Campaign.sol 98% <ø> (ø) ⬆️
contracts/Markets/StandardMarket.sol 100% <100%> (ø) ⬆️
...s/Markets/StandardMarketWithPriceLoggerFactory.sol 100% <100%> (ø)
contracts/Markets/StandardMarketFactory.sol 100% <100%> (ø) ⬆️
contracts/Oracles/FutarchyOracleFactory.sol 100% <100%> (+50%) ⬆️
contracts/Markets/CampaignFactory.sol 100% <100%> (ø) ⬆️
contracts/Oracles/FutarchyOracle.sol 100% <100%> (+100%) ⬆️
...ontracts/Markets/StandardMarketWithPriceLogger.sol 72.72% <72.72%> (ø)
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 059adb7...056d8d5. Read the comment docs.

@cag cag force-pushed the std_market_w_price branch from 19ddba2 to a3e9908 Compare August 21, 2017 15:44
Copy link
Contributor

@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.

A few things to consider before merging

else
priceIntegral += price * (now - startDate);
lastTrade = now;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Should end date be taken into account?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah actually now I think this is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

endDate is set once the market is closed. Once the market is closed trading is not possible anymore and the logPrice function cannot be executed anymore. With the current implementation endDate is not used at all and should probably be removed.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah. I think it is worth noting that the final transaction that is executed on the market, as well as subsequent simultaneous transactions (like if somebody wrote a contract which combined transactions, thus causing a 0 time gap), do not count towards the final average.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is something we could change in the getAvgPrice function:

(priceIntegral + (marketMaker.calcMarginalPrice(this, LONG) * (now - lastTrade))) / (now - startDate);

We could also use the endDate instead of now in case endDate > 0

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's a possibility... I'm just worried about the cost. Might be good to cache the marginal price.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm yeah, its a tradeoff. Otherwise we would have to keep track of the last price after a trade.

)
public
{
// Deadline is in the future
require(_deadline > now);
require(_deadline > 0);
Copy link
Contributor

Choose a reason for hiding this comment

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

Should deadline be after start date or now?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, deadline typically refers to an absolute point in time. I recommend either renaming to trading period or restoring the original logic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agree the name is missleading. Is there an easy way to set the timestamp in testrpc to a future timestamp? I found only the wait command, which makes more sense if time-periods are used. Lets rename it to tradingPeriod.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good to me

@Georgi87 Georgi87 merged commit 64a5b62 into master Aug 23, 2017
@cag cag deleted the std_market_w_price branch August 23, 2017 22:05
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