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

refactor: 0 price markets get full rewarded #61

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions contracts/liquidity/LiquidityPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ interface IERC20 {

contract LiquidityPool {
uint256 public constant DIVISOR = 10000;
uint256 private constant UINT_MAX = type(uint256).max;

bool public initialized;
IMarket public market;
Expand Down Expand Up @@ -175,7 +174,7 @@ contract LiquidityPool {

unchecked {
uint256 c = _a * _b;
return c / _a == _b ? c : UINT_MAX;
return c / _a == _b ? c : type(uint256).max;
}
}

Expand Down Expand Up @@ -204,10 +203,12 @@ contract LiquidityPool {
reward = (_totalPrize * cumWeigths) / (DIVISOR * sharedBetween);
}

function getMarketPaymentIfWon() public view returns (uint256 marketPayment) {
function getMarketPaymentIfWon() public view returns (uint256) {
if (market.price() == 0) return totalDeposits;

uint256 maxPayment = market.price() * market.nextTokenID();
maxPayment = mulCap(maxPayment, betMultiplier);
marketPayment = totalDeposits < maxPayment ? totalDeposits : maxPayment;
return totalDeposits < maxPayment ? totalDeposits : maxPayment;
}

receive() external payable {
Expand Down