Skip to content

Commit

Permalink
update package version, formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brean0 committed Aug 21, 2024
1 parent a9c1f68 commit 3241f9c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 75 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@beanstalk/wells",
"version": "1.2.0-prerelease1",
"version": "1.2.0-prerelease2",
"description": "A [{Well}](/src/Well.sol) is a constant function AMM that allows the provisioning of liquidity into a single pooled on-chain liquidity position.",
"main": "index.js",
"directories": {
Expand Down
92 changes: 18 additions & 74 deletions test/WellUpgradeable.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,7 @@ contract WellUpgradeTest is Test, WellDeployer {
IWellFunction cp2 = new ConstantProduct2();
vm.label(address(cp2), "CP2");
wellFunctionAddress = address(cp2);
Call memory wellFunction = Call(
address(cp2),
abi.encode("beanstalkFunction")
);
Call memory wellFunction = Call(address(cp2), abi.encode("beanstalkFunction"));

// Pump
IPump mockPump = new MockPump();
Expand All @@ -70,14 +67,8 @@ contract WellUpgradeTest is Test, WellDeployer {
initialOwner = makeAddr("owner");

// Well
WellUpgradeable well = encodeAndBoreWellUpgradeable(
aquifer,
wellImplementation,
tokens,
wellFunction,
pumps,
bytes32(0)
);
WellUpgradeable well =
encodeAndBoreWellUpgradeable(aquifer, wellImplementation, tokens, wellFunction, pumps, bytes32(0));
wellAddress = address(well);
vm.label(wellAddress, "upgradeableWell");
// Sum up of what is going on here
Expand All @@ -102,10 +93,7 @@ contract WellUpgradeTest is Test, WellDeployer {
vm.startPrank(initialOwner);
ERC1967Proxy proxy = new ERC1967Proxy(
address(well), // implementation address
LibWellUpgradeableConstructor.encodeWellInitFunctionCall(
tokens,
wellFunction
) // init data
LibWellUpgradeableConstructor.encodeWellInitFunctionCall(tokens, wellFunction) // init data
);
vm.stopPrank();
proxyAddress = address(proxy);
Expand Down Expand Up @@ -140,12 +128,8 @@ contract WellUpgradeTest is Test, WellDeployer {
}

function testProxyGetWellFunction() public {
Call memory proxyWellFunction = WellUpgradeable(proxyAddress)
.wellFunction();
assertEq(
address(proxyWellFunction.target),
address(wellFunctionAddress)
);
Call memory proxyWellFunction = WellUpgradeable(proxyAddress).wellFunction();
assertEq(address(proxyWellFunction.target), address(wellFunctionAddress));
assertEq(proxyWellFunction.data, abi.encode("beanstalkFunction"));
}

Expand All @@ -160,10 +144,7 @@ contract WellUpgradeTest is Test, WellDeployer {

function testProxyNumTokens() public {
uint256 expectedNumTokens = 2;
assertEq(
expectedNumTokens,
WellUpgradeable(proxyAddress).numberOfTokens()
);
assertEq(expectedNumTokens, WellUpgradeable(proxyAddress).numberOfTokens());
}

///////////////// Interaction test //////////////////
Expand All @@ -173,18 +154,8 @@ contract WellUpgradeTest is Test, WellDeployer {
uint256[] memory amounts = new uint256[](2);
amounts[0] = 1000;
amounts[1] = 1000;
WellUpgradeable(wellAddress).addLiquidity(
amounts,
0,
user,
type(uint256).max
);
WellUpgradeable(proxyAddress).addLiquidity(
amounts,
0,
user,
type(uint256).max
);
WellUpgradeable(wellAddress).addLiquidity(amounts, 0, user, type(uint256).max);
WellUpgradeable(proxyAddress).addLiquidity(amounts, 0, user, type(uint256).max);
assertEq(amounts, WellUpgradeable(proxyAddress).getReserves());
vm.stopPrank();
}
Expand Down Expand Up @@ -217,24 +188,15 @@ contract WellUpgradeTest is Test, WellDeployer {
pumps[0] = Call(mockPumpAddress, abi.encode("2"));
// create new mock Well Implementation:
address wellImpl = address(new MockWellUpgradeable());
WellUpgradeable well2 = encodeAndBoreWellUpgradeable(
aquifer,
wellImpl,
tokens,
wellFunction,
pumps,
bytes32(abi.encode("2"))
);
WellUpgradeable well2 =
encodeAndBoreWellUpgradeable(aquifer, wellImpl, tokens, wellFunction, pumps, bytes32(abi.encode("2")));
vm.label(address(well2), "upgradeableWell2");
vm.startPrank(initialOwner);
WellUpgradeable proxy = WellUpgradeable(payable(proxyAddress));
proxy.upgradeTo(address(well2));
assertEq(initialOwner, MockWellUpgradeable(proxyAddress).owner());
// verify proxy was upgraded.
assertEq(
address(well2),
MockWellUpgradeable(proxyAddress).getImplementation()
);
assertEq(address(well2), MockWellUpgradeable(proxyAddress).getImplementation());
assertEq(1, MockWellUpgradeable(proxyAddress).getVersion());
assertEq(100, MockWellUpgradeable(proxyAddress).getVersion(100));
vm.stopPrank();
Expand All @@ -248,14 +210,8 @@ contract WellUpgradeTest is Test, WellDeployer {
pumps[0] = Call(mockPumpAddress, abi.encode("2"));
// create new mock Well Implementation:
address wellImpl = address(new MockWellUpgradeable());
WellUpgradeable well2 = encodeAndBoreWellUpgradeable(
aquifer,
wellImpl,
tokens,
wellFunction,
pumps,
bytes32(abi.encode("2"))
);
WellUpgradeable well2 =
encodeAndBoreWellUpgradeable(aquifer, wellImpl, tokens, wellFunction, pumps, bytes32(abi.encode("2")));
vm.label(address(well2), "upgradeableWell2");
// set caller to not be the owner
address notOwner = makeAddr("notOwner");
Expand All @@ -280,14 +236,8 @@ contract WellUpgradeTest is Test, WellDeployer {
// create new mock Well Implementation:
address wellImpl = address(new MockWellUpgradeable());
// bore new well with the different tokens
WellUpgradeable well2 = encodeAndBoreWellUpgradeable(
aquifer,
wellImpl,
newTokens,
wellFunction,
pumps,
bytes32(abi.encode("2"))
);
WellUpgradeable well2 =
encodeAndBoreWellUpgradeable(aquifer, wellImpl, newTokens, wellFunction, pumps, bytes32(abi.encode("2")));
vm.label(address(well2), "upgradeableWell2");
vm.startPrank(initialOwner);
WellUpgradeable proxy = WellUpgradeable(payable(proxyAddress));
Expand All @@ -308,14 +258,8 @@ contract WellUpgradeTest is Test, WellDeployer {
// create new mock Well Implementation:
address wellImpl = address(new MockWellUpgradeable());
// bore new well with the different tokens
WellUpgradeable well2 = encodeAndBoreWellUpgradeable(
aquifer,
wellImpl,
newTokens,
wellFunction,
pumps,
bytes32(abi.encode("2"))
);
WellUpgradeable well2 =
encodeAndBoreWellUpgradeable(aquifer, wellImpl, newTokens, wellFunction, pumps, bytes32(abi.encode("2")));
vm.label(address(well2), "upgradeableWell2");
vm.startPrank(initialOwner);
WellUpgradeable proxy = WellUpgradeable(payable(proxyAddress));
Expand Down

0 comments on commit 3241f9c

Please sign in to comment.