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

Extreme do/undo amounts tests #846

Merged
merged 39 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
86b0f1c
add test swap with infinity bpt
elshan-eth Aug 6, 2024
4fe31fa
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Aug 6, 2024
6d4fa77
fix import
elshan-eth Aug 6, 2024
f9201d1
fix import
elshan-eth Aug 6, 2024
b80c988
fix import
elshan-eth Aug 6, 2024
ecdcf28
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Aug 14, 2024
04ccc54
add tests
elshan-eth Aug 16, 2024
9ac8d3c
fix errors
elshan-eth Aug 20, 2024
c49a78e
improve test
elshan-eth Aug 22, 2024
08d1969
add stable pool tests
elshan-eth Aug 22, 2024
6a8261c
small refactoring
elshan-eth Aug 23, 2024
1ebf93f
add flexible tests
elshan-eth Aug 28, 2024
91446e3
add temp logs
elshan-eth Aug 29, 2024
4ff80e8
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Aug 29, 2024
1f07b08
fix tests
elshan-eth Aug 29, 2024
2768b9c
fix min balance
elshan-eth Aug 29, 2024
f546f01
add fixes
elshan-eth Sep 3, 2024
843efa5
revert logging
elshan-eth Sep 3, 2024
101c173
revert logging
elshan-eth Sep 3, 2024
8fb730b
fix
elshan-eth Sep 3, 2024
bfd634d
small fixes
elshan-eth Sep 3, 2024
3540a45
fix tests
elshan-eth Sep 3, 2024
dfad3f7
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Sep 3, 2024
a41f6e2
remove import
elshan-eth Sep 3, 2024
9068dac
remove console.log
elshan-eth Sep 3, 2024
ca969e5
remove console.log
elshan-eth Sep 3, 2024
385efd2
fix
elshan-eth Sep 3, 2024
12e9181
Update pkg/vault/test/foundry/utils/BaseExtremeAmountsTest.sol
elshan-eth Sep 9, 2024
4916da8
Update pkg/vault/test/foundry/utils/BaseExtremeAmountsTest.sol
elshan-eth Sep 9, 2024
0c3f36c
add checking invariant
elshan-eth Sep 9, 2024
e2a016f
fix try/catch in test
elshan-eth Sep 9, 2024
f7a62d1
remove unused part
elshan-eth Sep 9, 2024
c010d06
Update pkg/vault/test/foundry/StablePoolExtremeAmounts.t.sol
elshan-eth Sep 12, 2024
a037335
Update pkg/vault/test/foundry/WeightedPoolExtremeAmounts.t.sol
elshan-eth Sep 12, 2024
c5192d4
small fix
elshan-eth Sep 12, 2024
9ce01fb
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Sep 12, 2024
dfc1fa5
fix array
elshan-eth Sep 12, 2024
ef3ac10
small fixes
elshan-eth Oct 1, 2024
cff9e57
Merge branch 'main' into extreme-swap-infinite-bpt-tests
elshan-eth Oct 1, 2024
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
28 changes: 28 additions & 0 deletions pkg/vault/test/foundry/LinearBaseExtremeAmounts.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.24;

import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { ArrayHelpers } from "@balancer-labs/v3-solidity-utils/contracts/test/ArrayHelpers.sol";
import { CastingHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/CastingHelpers.sol";

import { PoolMock } from "../../contracts/test/PoolMock.sol";
import { BaseExtremeAmountsTest } from "./utils/BaseExtremeAmountsTest.sol";

contract LinearBaseExtremeAmountsTest is BaseExtremeAmountsTest {
using ArrayHelpers for *;
using CastingHelpers for *;

function setUp() public virtual override {
BaseExtremeAmountsTest.setUp();
}

function _createPool(address[] memory tokens, string memory label) internal override returns (address) {
address newPool = address(new PoolMock(IVault(address(vault)), "ERC20 Pool - DAI/USDC", "ERC20_POOL_DAI_USDC"));
vm.label(newPool, label);

factoryMock.registerTestPool(newPool, vault.buildTokenConfig(tokens.asIERC20()), poolHooksContract, lp);
elshan-eth marked this conversation as resolved.
Show resolved Hide resolved

return address(newPool);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.24;

import { StablePoolFactory } from "@balancer-labs/v3-pool-stable/contracts/StablePoolFactory.sol";
import { StablePool } from "@balancer-labs/v3-pool-stable/contracts/StablePool.sol";

import { IBasePool } from "@balancer-labs/v3-interfaces/contracts/vault/IBasePool.sol";
import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { PoolRoleAccounts } from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
import { ArrayHelpers } from "@balancer-labs/v3-solidity-utils/contracts/test/ArrayHelpers.sol";
import { CastingHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/CastingHelpers.sol";
import { ProtocolFeeControllerMock } from "@balancer-labs/v3-vault/contracts/test/ProtocolFeeControllerMock.sol";

import { PoolMock } from "../../contracts/test/PoolMock.sol";
import { BaseExtremeAmountsTest } from "./utils/BaseExtremeAmountsTest.sol";

contract StablePoolExtremeAmountsWithMaxSwapFeeTest is BaseExtremeAmountsTest {
using ArrayHelpers for *;
using CastingHelpers for *;

uint256 internal constant DEFAULT_AMP_FACTOR = 200;

function setUp() public virtual override {
BaseExtremeAmountsTest.setUp();
}

function _initMaxBPTAmount() internal pure override returns (uint256) {
return 1e12 * 1e18;
}

function _createPool(address[] memory tokens, string memory label) internal override returns (address) {
StablePoolFactory factory = new StablePoolFactory(IVault(address(vault)), 365 days, "Factory v1", "Pool v1");

PoolRoleAccounts memory roleAccounts;

StablePool newPool = StablePool(
factory.create(
"Stable Pool",
"STABLE",
vault.buildTokenConfig(tokens.asIERC20()),
DEFAULT_AMP_FACTOR,
roleAccounts,
MAX_SWAP_FEE, // Set max swap fee
address(0),
false, // Do not enable donations
false, // Do not disable unbalanced add/remove liquidity
ZERO_BYTES32
)
);
vm.label(address(newPool), label);

return address(newPool);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.24;

import { StablePoolFactory } from "@balancer-labs/v3-pool-stable/contracts/StablePoolFactory.sol";
import { StablePool } from "@balancer-labs/v3-pool-stable/contracts/StablePool.sol";

import { IBasePool } from "@balancer-labs/v3-interfaces/contracts/vault/IBasePool.sol";
import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { PoolRoleAccounts } from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
import { ArrayHelpers } from "@balancer-labs/v3-solidity-utils/contracts/test/ArrayHelpers.sol";
import { CastingHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/CastingHelpers.sol";
import { ProtocolFeeControllerMock } from "@balancer-labs/v3-vault/contracts/test/ProtocolFeeControllerMock.sol";

import { PoolMock } from "../../contracts/test/PoolMock.sol";
import { BaseExtremeAmountsTest } from "./utils/BaseExtremeAmountsTest.sol";

contract StablePoolExtremeAmountsWithMinSwapFeeTest is BaseExtremeAmountsTest {
using ArrayHelpers for *;
using CastingHelpers for *;

uint256 internal constant DEFAULT_AMP_FACTOR = 200;

function setUp() public virtual override {
BaseExtremeAmountsTest.setUp();
}

function _initMaxBPTAmount() internal pure override returns (uint256) {
return 1e12 * 1e18;
}

function _createPool(address[] memory tokens, string memory label) internal override returns (address) {
StablePoolFactory factory = new StablePoolFactory(IVault(address(vault)), 365 days, "Factory v1", "Pool v1");

PoolRoleAccounts memory roleAccounts;

StablePool newPool = StablePool(
factory.create(
"Stable Pool",
"STABLE",
vault.buildTokenConfig(tokens.asIERC20()),
DEFAULT_AMP_FACTOR,
roleAccounts,
MIN_SWAP_FEE, // Set min swap fee
address(0),
false, // Do not enable donations
false, // Do not disable unbalanced add/remove liquidity
ZERO_BYTES32
)
);
vm.label(address(newPool), label);

return address(newPool);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.24;

import { WeightedPoolFactory } from "@balancer-labs/v3-pool-weighted/contracts/WeightedPoolFactory.sol";
import { WeightedPool } from "@balancer-labs/v3-pool-weighted/contracts/WeightedPool.sol";

import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { PoolRoleAccounts } from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
import { ArrayHelpers } from "@balancer-labs/v3-solidity-utils/contracts/test/ArrayHelpers.sol";
import { CastingHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/CastingHelpers.sol";
import { ProtocolFeeControllerMock } from "@balancer-labs/v3-vault/contracts/test/ProtocolFeeControllerMock.sol";

import { PoolMock } from "../../contracts/test/PoolMock.sol";
import { BaseExtremeAmountsTest } from "./utils/BaseExtremeAmountsTest.sol";

contract WeightedPoolExtremeAmountsWithMaxSwapFeeTest is BaseExtremeAmountsTest {
using ArrayHelpers for *;
using CastingHelpers for *;

function setUp() public virtual override {
BaseExtremeAmountsTest.setUp();
}

function _createPool(address[] memory tokens, string memory label) internal override returns (address) {
WeightedPoolFactory factory = new WeightedPoolFactory(
IVault(address(vault)),
365 days,
"Factory v1",
"Pool v1"
);
PoolRoleAccounts memory roleAccounts;

WeightedPool newPool = WeightedPool(
factory.create(
"50/50 Weighted Pool",
"50_50WP",
vault.buildTokenConfig(tokens.asIERC20()),
[uint256(50e16), uint256(50e16)].toMemoryArray(),
roleAccounts,
MAX_SWAP_FEE,
address(0),
false,
false,
bytes32(0)
)
);
vm.label(address(newPool), label);

return address(newPool);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity ^0.8.24;

import { WeightedPoolFactory } from "@balancer-labs/v3-pool-weighted/contracts/WeightedPoolFactory.sol";
import { WeightedPool } from "@balancer-labs/v3-pool-weighted/contracts/WeightedPool.sol";

import { IVault } from "@balancer-labs/v3-interfaces/contracts/vault/IVault.sol";
import { PoolRoleAccounts } from "@balancer-labs/v3-interfaces/contracts/vault/VaultTypes.sol";
import { ArrayHelpers } from "@balancer-labs/v3-solidity-utils/contracts/test/ArrayHelpers.sol";
import { CastingHelpers } from "@balancer-labs/v3-solidity-utils/contracts/helpers/CastingHelpers.sol";
import { ProtocolFeeControllerMock } from "@balancer-labs/v3-vault/contracts/test/ProtocolFeeControllerMock.sol";

import { PoolMock } from "../../contracts/test/PoolMock.sol";
import { BaseExtremeAmountsTest } from "./utils/BaseExtremeAmountsTest.sol";

contract WeightedPoolExtremeAmountsWithMinSwapFeeTest is BaseExtremeAmountsTest {
using ArrayHelpers for *;
using CastingHelpers for *;

function setUp() public virtual override {
BaseExtremeAmountsTest.setUp();
}

function _createPool(address[] memory tokens, string memory label) internal override returns (address) {
WeightedPoolFactory factory = new WeightedPoolFactory(
IVault(address(vault)),
365 days,
"Factory v1",
"Pool v1"
);
PoolRoleAccounts memory roleAccounts;

WeightedPool newPool = WeightedPool(
factory.create(
"50/50 Weighted Pool",
"50_50WP",
vault.buildTokenConfig(tokens.asIERC20()),
[uint256(50e16), uint256(50e16)].toMemoryArray(),
roleAccounts,
MIN_SWAP_FEE,
address(0),
false,
false,
bytes32(0)
)
);
vm.label(address(newPool), label);

return address(newPool);
}
}
Loading
Loading