This commit is contained in:
tim
2025-09-15 14:44:40 -04:00
parent 5fb2b17b2e
commit 77784644ad
4 changed files with 20 additions and 43 deletions

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.30;
import "forge-std/console2.sol";
import "@abdk/ABDKMath64x64.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
@@ -174,6 +175,7 @@ contract PartyPool is IPartyPool, ERC20, ReentrancyGuard {
bool isInitialDeposit = totalSupply() == 0 || lmsr.nAssets == 0;
require(lpTokenAmount > 0 || isInitialDeposit, "mint: zero LP amount");
console2.log('mint is init?', isInitialDeposit);
// Capture old pool size metric (scaled) by computing from current balances
uint256 oldScaled = 0;
@@ -199,22 +201,31 @@ contract PartyPool is IPartyPool, ERC20, ReentrancyGuard {
}
// Update cached balances for all assets
console2.log('updating balances');
int128[] memory newQInternal = new int128[](n);
for (uint i = 0; i < n; ) {
console2.log(i);
uint256 bal = IERC20(tokens[i]).balanceOf(address(this));
cachedUintBalances[i] = bal;
console2.log('floor');
console2.log(bal);
console2.log(bases[i]);
newQInternal[i] = _uintToInternalFloor(bal, bases[i]);
console2.log('internal');
// For initial deposit, record the actual deposited amounts
if (isInitialDeposit) {
depositAmounts[i] = bal;
}
console2.log('inc');
unchecked { i++; }
}
console2.log('balances updated');
// If first time, call init, otherwise update proportional change.
if (isInitialDeposit) {
console2.log('init lmsr');
// Initialize the stabilized LMSR state
lmsr.init(newQInternal, tradeFrac, targetSlippage);
} else {
@@ -231,6 +242,7 @@ contract PartyPool is IPartyPool, ERC20, ReentrancyGuard {
if (isInitialDeposit) {
// Initial provisioning: mint newScaled (as LP units)
actualLpToMint = newScaled;
console2.log('initial mint', actualLpToMint);
} else {
require(oldScaled > 0, "mint: oldScaled zero");
uint256 delta = (newScaled > oldScaled) ? (newScaled - oldScaled) : 0;