socialpredict icon indicating copy to clipboard operation
socialpredict copied to clipboard

Handling Total Payouts Exceeding the Available Pool

Open pwdel opened this issue 1 year ago • 1 comments

re: after a series of transforms to distribute the share pools upon a sell, we have:

// AggregateUserPayouts aggregates YES and NO payouts for each user.
func AggregateUserPayoutsDBPM(bets []models.Bet, finalPayouts []int64) []MarketPosition {
	userPayouts := make(map[string]*MarketPosition)

	for i, bet := range bets {
		payout := finalPayouts[i]

		// Initialize the user's market position if it doesn't exist
		if _, exists := userPayouts[bet.Username]; !exists {
			userPayouts[bet.Username] = &MarketPosition{Username: bet.Username}
		}

		// Aggregate payouts based on the outcome
		if bet.Outcome == "YES" {
			userPayouts[bet.Username].YesSharesOwned += payout
		} else if bet.Outcome == "NO" {
			userPayouts[bet.Username].NoSharesOwned += payout
		}
	}

	// Convert map to slice for output
	var positions []MarketPosition
	for _, pos := range userPayouts {
		positions = append(positions, *pos)
	}

	return positions
}

When the total sum of the positions (payouts) exceeds the sum of the S_YES and S_NO available pools, it indicates an imbalance that needs to be corrected to maintain the integrity and financial stability of the market. Here are some strategies to deal with such a situation:

Proportional Scaling Down: Similar to how you might scale up payouts to fully utilize the pool, you can scale down payouts proportionally if the total demanded payouts exceed the pool size. This approach ensures that all participants receive a fair share of the pool relative to their stake, although it reduces the payout for each participant.

pwdel avatar Feb 08 '24 19:02 pwdel

This will have been solved when this is merged.

https://github.com/openpredictionmarkets/socialpredict/pull/61

pwdel avatar Feb 19 '24 15:02 pwdel

Was solved after merge.

pwdel avatar May 25 '24 13:05 pwdel