removed state.nAssets
This commit is contained in:
@@ -192,7 +192,7 @@ contract LMSRStabilizedTest is Test {
|
||||
initAlmostBalanced();
|
||||
|
||||
// Verify basic state is still functional
|
||||
assertTrue(s.nAssets > 0, "State should still be initialized");
|
||||
assertTrue(s.qInternal.length > 0, "State should still be initialized");
|
||||
assertTrue(s.kappa > int128(0), "Kappa should still be positive");
|
||||
}
|
||||
|
||||
@@ -213,9 +213,10 @@ contract LMSRStabilizedTest is Test {
|
||||
int128 initialB = _computeB(initialQ);
|
||||
int128 initialKappa = s.kappa;
|
||||
|
||||
uint256 nAssets = s.qInternal.length;
|
||||
// Simulate a deposit by increasing all asset quantities by 50%
|
||||
int128[] memory newQ = new int128[](s.nAssets);
|
||||
for (uint i = 0; i < s.nAssets; i++) {
|
||||
int128[] memory newQ = new int128[](nAssets);
|
||||
for (uint i = 0; i < nAssets; i++) {
|
||||
// Increase by 50%
|
||||
newQ[i] = initialQ[i].mul(ABDKMath64x64.fromUInt(3).div(ABDKMath64x64.fromUInt(2))); // 1.5x
|
||||
}
|
||||
@@ -362,8 +363,9 @@ contract LMSRStabilizedTest is Test {
|
||||
int128 initialKappa = s.kappa;
|
||||
|
||||
// Simulate a withdrawal by decreasing all asset quantities by 30%
|
||||
int128[] memory newQ = new int128[](s.nAssets);
|
||||
for (uint i = 0; i < s.nAssets; i++) {
|
||||
uint256 nAssets = s.qInternal.length;
|
||||
int128[] memory newQ = new int128[](nAssets);
|
||||
for (uint i = 0; i < nAssets; i++) {
|
||||
// Decrease by 30%
|
||||
newQ[i] = initialQ[i].mul(ABDKMath64x64.fromUInt(7).div(ABDKMath64x64.fromUInt(10))); // 0.7x
|
||||
}
|
||||
@@ -408,7 +410,7 @@ contract LMSRStabilizedTest is Test {
|
||||
function testRecenterShiftTooLargeReverts() public {
|
||||
initAlmostBalanced();
|
||||
// Recentering has been removed, so this test now just verifies basic functionality
|
||||
assertTrue(s.nAssets > 0, "State should still be initialized");
|
||||
assertTrue(s.qInternal.length > 0, "State should still be initialized");
|
||||
}
|
||||
|
||||
/// @notice limitPrice <= current price should revert (no partial fill)
|
||||
@@ -431,25 +433,6 @@ contract LMSRStabilizedTest is Test {
|
||||
this.externalSwapAmountsForExactInput(0, 1, tradeAmount, ABDKMath64x64.fromInt(1));
|
||||
}
|
||||
|
||||
/// @notice If e_j == 0 we should revert early to avoid div-by-zero
|
||||
function testEJZeroReverts() public {
|
||||
initBalanced();
|
||||
|
||||
// Create mock qInternal where asset 1 has zero quantity
|
||||
int128[] memory mockQInternal = new int128[](3);
|
||||
mockQInternal[0] = ABDKMath64x64.fromUInt(1_000_000);
|
||||
mockQInternal[1] = int128(0); // Zero quantity for asset 1
|
||||
mockQInternal[2] = ABDKMath64x64.fromUInt(1_000_000);
|
||||
|
||||
// Update the state's cached qInternal
|
||||
_updateCachedQInternal(mockQInternal);
|
||||
|
||||
int128 tradeAmount = mockQInternal[0].mul(stdTradeSize);
|
||||
|
||||
vm.expectRevert(bytes("LMSR: e_j==0"));
|
||||
this.externalSwapAmountsForExactInput(0, 1, tradeAmount, 0);
|
||||
}
|
||||
|
||||
/// @notice swapAmountsForPriceLimit returns zero if limit equals current price
|
||||
function testSwapAmountsForPriceLimitZeroWhenLimitEqualsPrice() public {
|
||||
initBalanced();
|
||||
@@ -693,7 +676,8 @@ contract LMSRStabilizedTest is Test {
|
||||
initBalanced();
|
||||
|
||||
// Create initial quantities
|
||||
int128[] memory initialQValues = new int128[](s.nAssets);
|
||||
uint256 nAssets = s.qInternal.length;
|
||||
int128[] memory initialQValues = new int128[](nAssets);
|
||||
initialQValues[0] = ABDKMath64x64.fromUInt(1_000_000);
|
||||
initialQValues[1] = ABDKMath64x64.fromUInt(1_000_000);
|
||||
initialQValues[2] = ABDKMath64x64.fromUInt(1_000_000);
|
||||
@@ -705,8 +689,8 @@ contract LMSRStabilizedTest is Test {
|
||||
int128 directSwapAmount = initialQValues[0].mul(stdTradeSize);
|
||||
|
||||
// Store a backup of the original values to restore between swaps
|
||||
int128[] memory backupQ = new int128[](s.nAssets);
|
||||
for (uint i = 0; i < s.nAssets; i++) {
|
||||
int128[] memory backupQ = new int128[](nAssets);
|
||||
for (uint i = 0; i < nAssets; i++) {
|
||||
backupQ[i] = s.qInternal[i];
|
||||
}
|
||||
|
||||
@@ -798,8 +782,9 @@ contract LMSRStabilizedTest is Test {
|
||||
int128 tradeAmount1 = s.qInternal[1].mul(tradeSize);
|
||||
|
||||
// Store original state to restore between tests
|
||||
int128[] memory backupQ = new int128[](s.nAssets);
|
||||
for (uint i = 0; i < s.nAssets; i++) {
|
||||
uint256 nAssets = s.qInternal.length;
|
||||
int128[] memory backupQ = new int128[](nAssets);
|
||||
for (uint i = 0; i < nAssets; i++) {
|
||||
backupQ[i] = s.qInternal[i];
|
||||
}
|
||||
|
||||
|
||||
@@ -426,7 +426,7 @@ contract NativeTest is Test {
|
||||
uint256 aliceLpBefore = pool.balanceOf(alice);
|
||||
|
||||
// Call swapMint with native currency: deposit ETH as WETH (index 2)
|
||||
(, uint256 lpMinted, ) = pool.swapMint{value: maxIn}(
|
||||
(, uint256 lpMinted,) = pool.swapMint{value: maxIn}(
|
||||
alice, // payer
|
||||
alice, // receiver
|
||||
2, // inputTokenIndex (WETH)
|
||||
@@ -457,7 +457,7 @@ contract NativeTest is Test {
|
||||
uint256 aliceEthBefore = alice.balance;
|
||||
|
||||
// Send excess native currency
|
||||
(, uint256 lpMinted, ) = pool.swapMint{value: totalSent}(
|
||||
(, uint256 lpMinted,) = pool.swapMint{value: totalSent}(
|
||||
alice,
|
||||
alice,
|
||||
2, // WETH
|
||||
|
||||
Reference in New Issue
Block a user