styling consistency

This commit is contained in:
tim
2025-10-15 11:19:36 -04:00
parent 7ac4cdc8f6
commit ead004d631
18 changed files with 275 additions and 281 deletions

View File

@@ -114,9 +114,9 @@ contract GasTest is Test {
uint256 constant internal INIT_BAL = 1_000_000; // initial token units for each token (internal==amount when base==1)
uint256 constant internal BASE = 1; // use base=1 so internal amounts correspond to raw integers (Q64.64 units)
/// @notice Helper function to create a pool with the specified number of tokens
/// @notice Helper function to create a pool with the specified number of _tokens
function createPool(uint256 numTokens) internal returns (PartyPool) {
// Deploy tokens dynamically
// Deploy _tokens dynamically
address[] memory tokens = new address[](numTokens);
uint256[] memory bases = new uint256[](numTokens);
@@ -139,7 +139,7 @@ contract GasTest is Test {
for (uint i = 0; i < tokens.length; i++) {
ierc20Tokens[i] = IERC20(tokens[i]);
}
// Compute kappa from slippage params and number of tokens, then construct pool with kappa
// Compute kappa from slippage params and number of _tokens, then construct pool with kappa
int128 computedKappa = LMSRStabilized.computeKappaFromSlippage(ierc20Tokens.length, tradeFrac, targetSlippage);
PartyPool newPool = Deploy.newPartyPool(poolName, poolName, ierc20Tokens, bases, computedKappa, feePpm, feePpm, false);
@@ -156,7 +156,7 @@ contract GasTest is Test {
/// @notice Helper to create a pool with the stable-pair optimization enabled
function createPoolStable(uint256 numTokens) internal returns (PartyPool) {
// Deploy tokens dynamically
// Deploy _tokens dynamically
address[] memory tokens = new address[](numTokens);
uint256[] memory bases = new uint256[](numTokens);
@@ -216,7 +216,7 @@ contract GasTest is Test {
// Deploy the borrower contract
borrower = new FlashBorrower(address(pool2));
// Mint tokens to alice to be used for repayments and approve borrower
// Mint _tokens to alice to be used for repayments and approve borrower
IERC20[] memory tokenAddresses = pool2.allTokens();
vm.startPrank(alice);
for (uint256 i = 0; i < tokenAddresses.length; i++) {
@@ -226,12 +226,12 @@ contract GasTest is Test {
vm.stopPrank();
}
/// @notice Helper function: perform 10 swaps back-and-forth between the first two tokens.
/// @notice Helper function: perform 10 swaps back-and-forth between the first two _tokens.
function _performSwapGasTest(PartyPool testPool) internal {
IERC20[] memory tokens = testPool.allTokens();
require(tokens.length >= 2, "Pool must have at least 2 tokens");
// Ensure alice approves pool for both tokens
// Ensure alice approves pool for both _tokens
vm.prank(alice);
TestERC20(address(tokens[0])).approve(address(testPool), type(uint256).max);
vm.prank(alice);
@@ -252,22 +252,22 @@ contract GasTest is Test {
}
}
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two tokens in the 2-token pool.
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 2-token pool.
function testSwapGasPair() public {
_performSwapGasTest(pool2);
}
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two tokens in the 10-token pool.
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 10-token pool.
function testSwapGasTen() public {
_performSwapGasTest(pool10);
}
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two tokens in the 20-token pool.
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 20-token pool.
function testSwapGasTwenty() public {
_performSwapGasTest(pool20);
}
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two tokens in the 100-token pool.
/// @notice Gas measurement: perform 10 swaps back-and-forth between first two _tokens in the 100-token pool.
function testSwapGasFifty() public {
_performSwapGasTest(pool50);
}
@@ -307,7 +307,7 @@ contract GasTest is Test {
uint256 minted = testPool.swapMint(alice, alice, 0, input, 0);
// If nothing minted (numerical edge), skip burn step
if (minted == 0) continue;
// Immediately burn the minted LP back to tokens, targeting the same token index
// Immediately burn the minted LP back to _tokens, targeting the same token index
testPool.burnSwap(alice, alice, minted, 0, 0, false);
}
@@ -343,7 +343,7 @@ contract GasTest is Test {
vm.startPrank(alice);
// Mint additional tokens to alice and approve pool to transfer tokens for proportional mint
// Mint additional _tokens to alice and approve pool to transfer _tokens for proportional mint
for (uint256 i = 0; i < poolTokens.length; i++) {
TestERC20(address(poolTokens[i])).mint(alice, iterations * input * 2);
TestERC20(address(poolTokens[i])).approve(address(testPool), type(uint256).max);

View File

@@ -61,7 +61,7 @@ contract NativeTest is Test {
vm.deal(alice, 100 ether);
vm.deal(bob, 100 ether);
// Deploy two regular ERC20 tokens
// Deploy two regular ERC20 _tokens
token0 = new TestERC20Native("T0", "T0", 0);
token1 = new TestERC20Native("T1", "T1", 0);
@@ -72,7 +72,7 @@ contract NativeTest is Test {
token0.mint(address(this), INIT_BAL);
token1.mint(address(this), INIT_BAL);
// For WETH, we deposit native currency to get wrapped tokens
// For WETH, we deposit native currency to get wrapped _tokens
weth.deposit{value: INIT_BAL}();
// Configure LMSR parameters
@@ -104,7 +104,7 @@ contract NativeTest is Test {
// Perform initial mint
pool.initialMint(address(this), 0);
// Mint tokens to alice and bob for testing
// Mint _tokens to alice and bob for testing
token0.mint(alice, INIT_BAL);
token1.mint(alice, INIT_BAL);
@@ -407,7 +407,7 @@ contract NativeTest is Test {
true // unwrap
);
// Bob should receive tokens and native currency
// Bob should receive _tokens and native currency
assertEq(token0.balanceOf(bob), bobToken0Before + withdraws[0], "Bob token0");
assertEq(token1.balanceOf(bob), bobToken1Before + withdraws[1], "Bob token1");
assertEq(bob.balance, bobEthBefore + withdraws[2], "Bob should receive ETH");
@@ -441,7 +441,7 @@ contract NativeTest is Test {
assertTrue(alice.balance <= aliceEthBefore, "Alice ETH should decrease");
assertTrue(aliceEthBefore - alice.balance <= maxIn, "Alice spent at most maxIn");
// Alice should receive LP tokens
// Alice should receive LP _tokens
assertTrue(pool.balanceOf(alice) >= aliceLpBefore + lpMinted, "Alice should receive LP");
vm.stopPrank();
@@ -567,7 +567,7 @@ contract NativeTest is Test {
vm.stopPrank();
}
/// @notice Test that unwrap=false with WETH actually transfers WETH tokens (not native)
/// @notice Test that unwrap=false with WETH actually transfers WETH _tokens (not native)
function testSwapWithWethNoUnwrap() public {
uint256 maxIn = 10_000;

View File

@@ -49,17 +49,17 @@ contract PartyPlannerTest is Test {
// Deploy PartyPlanner
planner = Deploy.newPartyPlanner();
// Deploy mock tokens
// Deploy mock _tokens
tokenA = new MockERC20("Token A", "TKNA", 18);
tokenB = new MockERC20("Token B", "TKNB", 18);
tokenC = new MockERC20("Token C", "TKNC", 6);
// Mint tokens to payer
// Mint _tokens to payer
tokenA.mint(payer, INITIAL_MINT_AMOUNT);
tokenB.mint(payer, INITIAL_MINT_AMOUNT);
tokenC.mint(payer, INITIAL_MINT_AMOUNT);
// Approve tokens for PartyPlanner
// Approve _tokens for PartyPlanner
vm.startPrank(payer);
tokenA.approve(address(planner), type(uint256).max);
tokenB.approve(address(planner), type(uint256).max);
@@ -156,7 +156,7 @@ contract PartyPlannerTest is Test {
}
assertTrue(poolInTokenB, "Pool should be indexed under tokenB");
// Verify LP tokens were minted to receiver
// Verify LP _tokens were minted to receiver
assertEq(pool.balanceOf(receiver), lpAmount, "Receiver should have LP tokens");
}

View File

@@ -130,7 +130,7 @@ contract PartyPoolTest is Test {
alice = address(0xA11ce);
bob = address(0xB0b);
// Deploy three ERC20 test tokens and mint initial supplies to this test contract for initial deposit
// Deploy three ERC20 test _tokens and mint initial supplies to this test contract for initial deposit
token0 = new TestERC20("T0", "T0", 0);
token1 = new TestERC20("T1", "T1", 0);
token2 = new TestERC20("T2", "T2", 0);
@@ -175,7 +175,7 @@ contract PartyPoolTest is Test {
int128 kappa3 = LMSRStabilized.computeKappaFromSlippage(tokens.length, tradeFrac, targetSlippage);
pool = Deploy.newPartyPool("LP", "LP", tokens, bases, kappa3, feePpm, feePpm, false);
// Transfer initial deposit amounts into pool before initial mint (pool expects tokens already in contract)
// Transfer initial deposit amounts into pool before initial mint (pool expects _tokens already in contract)
// We deposit equal amounts INIT_BAL for each token
token0.transfer(address(pool), INIT_BAL);
token1.transfer(address(pool), INIT_BAL);
@@ -184,7 +184,7 @@ contract PartyPoolTest is Test {
// Perform initial mint (initial deposit); receiver is this contract
pool.initialMint(address(this), 0);
// Set up pool10 with 10 tokens
// Set up pool10 with 10 _tokens
IERC20[] memory tokens10 = new IERC20[](10);
tokens10[0] = IERC20(address(token0));
tokens10[1] = IERC20(address(token1));
@@ -205,7 +205,7 @@ contract PartyPoolTest is Test {
int128 kappa10 = LMSRStabilized.computeKappaFromSlippage(tokens10.length, tradeFrac, targetSlippage);
pool10 = Deploy.newPartyPool("LP10", "LP10", tokens10, bases10, kappa10, feePpm, feePpm, false);
// Mint additional tokens for pool10 initial deposit
// Mint additional _tokens for pool10 initial deposit
token0.mint(address(this), INIT_BAL);
token1.mint(address(this), INIT_BAL);
token2.mint(address(this), INIT_BAL);
@@ -232,7 +232,7 @@ contract PartyPoolTest is Test {
// Perform initial mint for pool10
pool10.initialMint(address(this), 0);
// For later tests we will mint tokens to alice/bob as needed
// For later tests we will mint _tokens to alice/bob as needed
token0.mint(alice, INIT_BAL);
token1.mint(alice, INIT_BAL);
token2.mint(alice, INIT_BAL);
@@ -258,7 +258,7 @@ contract PartyPoolTest is Test {
viewer = Deploy.newViewer();
}
/// @notice Basic sanity: initial mint should have produced LP tokens for this contract and the pool holds tokens.
/// @notice Basic sanity: initial mint should have produced LP _tokens for this contract and the pool holds _tokens.
function testInitialMintAndLP() public view {
uint256 totalLp = pool.totalSupply();
assertTrue(totalLp > 0, "Initial LP supply should be > 0");
@@ -274,7 +274,7 @@ contract PartyPoolTest is Test {
function testProportionalMintZeroLpReverts() public {
// Attempt to request a tiny LP amount (1) and expect revert because calculated actualLpToMint will be zero
// Approve pool to transfer tokens on alice's behalf
// Approve pool to transfer _tokens on alice's behalf
vm.startPrank(alice);
token0.approve(address(pool), type(uint256).max);
token1.approve(address(pool), type(uint256).max);
@@ -290,7 +290,7 @@ contract PartyPoolTest is Test {
/// does not undercharge (no value extraction). This test verifies the request succeeds
/// and that computed deposits are at least the proportional floor (ceil >= floor).
function testProportionalMintOneWeiSucceedsAndProtectsPool() public {
// Request a tiny LP amount (1 wei). Approve pool to transfer tokens on alice's behalf.
// Request a tiny LP amount (1 wei). Approve pool to transfer _tokens on alice's behalf.
vm.startPrank(alice);
token0.approve(address(pool), type(uint256).max);
token1.approve(address(pool), type(uint256).max);
@@ -406,14 +406,14 @@ contract PartyPoolTest is Test {
assertTrue(withdrawAmounts[i] <= poolBal, "withdraw amount cannot exceed pool balance");
}
// Burn by sending LP tokens from this contract (which holds initial LP from setUp)
// Burn by sending LP _tokens from this contract (which holds initial LP from setUp)
// Call burn(payer=this, receiver=bob, lpAmount=totalLp)
pool.burn(address(this), bob, totalLp, 0, false);
// After burning entire pool, totalSupply should be zero or very small (we expect zero since we withdrew all)
assertEq(pool.totalSupply(), 0);
// Bob should have received the withdrawn tokens
// Bob should have received the withdrawn _tokens
for (uint i = 0; i < withdrawAmounts.length; i++) {
assertTrue(IERC20(pool.allTokens()[i]).balanceOf(bob) >= withdrawAmounts[i], "Bob should receive withdrawn tokens");
}
@@ -424,7 +424,7 @@ contract PartyPoolTest is Test {
// Use alice as payer and bob as receiver
uint256 maxIn = 10_000;
// Ensure alice has tokens and approves pool
// Ensure alice has _tokens and approves pool
vm.prank(alice);
token0.approve(address(pool), type(uint256).max);
@@ -503,7 +503,7 @@ contract PartyPoolTest is Test {
// Compute expected deposit amounts via view
uint256[] memory expected = viewer.mintAmounts(pool, req);
// Ensure alice has tokens and approve pool
// Ensure alice has _tokens and approve pool
vm.startPrank(alice);
token0.approve(address(pool), type(uint256).max);
token1.approve(address(pool), type(uint256).max);
@@ -548,7 +548,7 @@ contract PartyPoolTest is Test {
uint256[] memory expected = viewer.mintAmounts(pool10, req);
// Approve all tokens from alice
// Approve all _tokens from alice
vm.startPrank(alice);
token0.approve(address(pool10), type(uint256).max);
token1.approve(address(pool10), type(uint256).max);
@@ -614,7 +614,7 @@ contract PartyPoolTest is Test {
uint256 myLp = pool.balanceOf(address(this));
if (myLp < req) {
uint256 topUp = req - myLp;
// Have alice supply tokens to mint LP into this contract
// Have alice supply _tokens to mint LP into this contract
vm.startPrank(alice);
token0.approve(address(pool), type(uint256).max);
token1.approve(address(pool), type(uint256).max);
@@ -754,7 +754,7 @@ contract PartyPoolTest is Test {
// Very large input relative to pool
uint256 largeInput = 10_000_000_000; // intentionally large
// Ensure alice has sufficient tokens for this large test input (mint top-up)
// Ensure alice has sufficient _tokens for this large test input (mint top-up)
token0.mint(alice, largeInput);
vm.startPrank(alice);
@@ -818,12 +818,12 @@ contract PartyPoolTest is Test {
// Deploy the borrower contract
borrower = new FlashBorrower(address(pool));
// Mint tokens to alice to be used for repayments
// Mint _tokens to alice to be used for repayments
token0.mint(alice, INIT_BAL * 2);
token1.mint(alice, INIT_BAL * 2);
token2.mint(alice, INIT_BAL * 2);
// Alice approves borrower to transfer tokens on their behalf for repayment
// Alice approves borrower to transfer _tokens on their behalf for repayment
vm.startPrank(alice);
token0.approve(address(borrower), type(uint256).max);
token1.approve(address(borrower), type(uint256).max);
@@ -998,7 +998,7 @@ contract PartyPoolTest is Test {
int128 kappaCustom = LMSRStabilized.computeKappaFromSlippage(tokens.length, tradeFrac, targetSlippage);
PartyPool poolCustom = Deploy.newPartyPool("LP_CUSTOM", "LP_CUSTOM", tokens, bases, kappaCustom, feePpm, feePpm, false);
// Mint additional tokens for both pools
// Mint additional _tokens for both pools
token0.mint(address(this), INIT_BAL * 2);
token1.mint(address(this), INIT_BAL * 2);
token2.mint(address(this), INIT_BAL * 2);
@@ -1052,7 +1052,7 @@ contract PartyPoolTest is Test {
}
/// @notice Test that minting the same proportion in pools with different initial LP amounts
/// returns correctly scaled LP tokens
/// returns correctly scaled LP _tokens
function testProportionalMintingScaledByInitialAmount() public {
// Create two identical pools with different initial LP amounts
IERC20[] memory tokens = new IERC20[](3);
@@ -1072,7 +1072,7 @@ contract PartyPoolTest is Test {
int128 kappaCustom2 = LMSRStabilized.computeKappaFromSlippage(tokens.length, tradeFrac, targetSlippage);
PartyPool poolCustom = Deploy.newPartyPool("LP_CUSTOM", "LP_CUSTOM", tokens, bases, kappaCustom2, feePpm, feePpm, false);
// Mint additional tokens
// Mint additional _tokens
token0.mint(address(this), INIT_BAL * 4);
token1.mint(address(this), INIT_BAL * 4);
token2.mint(address(this), INIT_BAL * 4);
@@ -1108,7 +1108,7 @@ contract PartyPoolTest is Test {
vm.startPrank(alice);
// Approve tokens for both pools
// Approve _tokens for both pools
token0.approve(address(poolDefault), type(uint256).max);
token1.approve(address(poolDefault), type(uint256).max);
token2.approve(address(poolDefault), type(uint256).max);