Skip to content

Commit

Permalink
refreshed flatten
Browse files Browse the repository at this point in the history
  • Loading branch information
SolidityDrone committed Nov 1, 2024
1 parent ca4fbbe commit 8966170
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/flattened/MutiOutcomePredictionMarket.flattened.sol
Original file line number Diff line number Diff line change
Expand Up @@ -393,13 +393,9 @@ contract MultiOutcomePredictionMarket is IMultiOutcomePredictionMarket {
require(optionId < market.options.length, "Invalid option ID");
require(quantity > 0, "Quantity must be greater than zero");




uint256 currentShares = market.options[optionId].shares;
// If buying 1 share, return current price
if (quantity == 1) {
return 0;
}


// Calculate first share cost after theoretical first purchase
uint256 sumExp = 0;
Expand All @@ -417,8 +413,6 @@ contract MultiOutcomePredictionMarket is IMultiOutcomePredictionMarket {
uint256 weight = market.options[optionId].initialPrice + impact;
uint256 firstShareCost = (weight * TOTAL_PRICE) / sumExp;



// Calculate second share cost after theoretical first purchase
sumExp = 0;
for (uint256 i = 0; i < market.options.length; i++) {
Expand All @@ -431,8 +425,6 @@ contract MultiOutcomePredictionMarket is IMultiOutcomePredictionMarket {
sumExp += currWeight;
}



// Calculate price for second share
impact = calculateImpact((currentShares - quantity) + 1 );
weight = market.options[optionId].initialPrice + impact;
Expand All @@ -443,7 +435,6 @@ contract MultiOutcomePredictionMarket is IMultiOutcomePredictionMarket {
uint256 remainingShares = quantity - 1;
uint256 lastSharePrice = firstShareCost + (priceIncrement * remainingShares);



// First share + arithmetic mean of remaining shares prices * number of remaining shares
return firstShareCost + (remainingShares * (secondSharePrice + lastSharePrice) / 2);
Expand Down

0 comments on commit 8966170

Please sign in to comment.