Skip to content

Commit

Permalink
Merge pull request #363 from liquity/zappers_to_deployment
Browse files Browse the repository at this point in the history
chore: Move zappers to deployment contract
  • Loading branch information
bingen authored Aug 26, 2024
2 parents 1cc2208 + c3f725f commit cef6d60
Show file tree
Hide file tree
Showing 16 changed files with 340 additions and 145 deletions.
4 changes: 4 additions & 0 deletions contracts/src/Zappers/Interfaces/ILeverageZapper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

pragma solidity ^0.8.0;

import "./IExchange.sol";

interface ILeverageZapper {
struct OpenLeveragedTroveParams {
address owner;
Expand Down Expand Up @@ -31,6 +33,8 @@ interface ILeverageZapper {
uint256 minBoldAmount;
}

function exchange() external returns (IExchange);

function openLeveragedTroveWithRawETH(OpenLeveragedTroveParams calldata _params) external payable;

function leverUpTrove(LeverUpTroveParams calldata _params) external;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;

interface IUniswapV3Factory {
/// @notice Emitted when the owner of the factory is changed
/// @param oldOwner The owner before the owner was changed
/// @param newOwner The owner after the owner was changed
event OwnerChanged(address indexed oldOwner, address indexed newOwner);

/// @notice Emitted when a pool is created
/// @param token0 The first token of the pool by address sort order
/// @param token1 The second token of the pool by address sort order
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks
/// @param pool The address of the created pool
event PoolCreated(
address indexed token0, address indexed token1, uint24 indexed fee, int24 tickSpacing, address pool
);

/// @notice Emitted when a new fee amount is enabled for pool creation via the factory
/// @param fee The enabled fee, denominated in hundredths of a bip
/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given fee
event FeeAmountEnabled(uint24 indexed fee, int24 indexed tickSpacing);

/// @notice Returns the current owner of the factory
/// @dev Can be changed by the current owner via setOwner
/// @return The address of the factory owner
function owner() external view returns (address);

/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled
/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context
/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee
/// @return The tick spacing
function feeAmountTickSpacing(uint24 fee) external view returns (int24);

/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist
/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order
/// @param tokenA The contract address of either token0 or token1
/// @param tokenB The contract address of the other token
/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip
/// @return pool The pool address
function getPool(address tokenA, address tokenB, uint24 fee) external view returns (address pool);

/// @notice Creates a pool for the given two tokens and fee
/// @param tokenA One of the two tokens in the desired pool
/// @param tokenB The other of the two tokens in the desired pool
/// @param fee The desired fee for the pool
/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved
/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments
/// are invalid.
/// @return pool The address of the newly created pool
function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool);

/// @notice Updates the owner of the factory
/// @dev Must be called by the current owner
/// @param _owner The new owner of the factory
function setOwner(address _owner) external;

/// @notice Enables a fee amount with the given tickSpacing
/// @dev Fee amounts may never be removed once enabled
/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)
/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amount
function enableFeeAmount(uint24 fee, int24 tickSpacing) external;
}
2 changes: 1 addition & 1 deletion contracts/src/test/Invariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ contract InvariantsTest is Logging, BaseInvariantTest, BaseMultiCollateralTest {

TestDeployer deployer = new TestDeployer();
Contracts memory contracts;
(contracts.branches, contracts.collateralRegistry, contracts.boldToken, contracts.hintHelpers,, contracts.weth)
(contracts.branches, contracts.collateralRegistry, contracts.boldToken, contracts.hintHelpers,, contracts.weth,)
= deployer.deployAndConnectContractsMultiColl(paramsList);
setupContracts(contracts);

Expand Down
9 changes: 3 additions & 6 deletions contracts/src/test/OracleMainnet.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,13 @@ contract OraclesMainnet is TestAccounts {
deal(address(contractsArray[j].collToken), accountsList[i], initialColl);
vm.startPrank(accountsList[i]);
// Approve all Borrower Ops to use the user's WETH funds
contractsArray[j].collToken.approve(address(contractsArray[j].borrowerOperations), initialColl);
contractsArray[0].collToken.approve(address(contractsArray[j].borrowerOperations), type(uint256).max);
// Approve Borrower Ops in LST branches to use the user's respective LST funds
contractsArray[j].collToken.approve(address(contractsArray[j].borrowerOperations), type(uint256).max);
vm.stopPrank();
}

// Approve Borrower Ops in LST branches to use the user's respective LST funds
vm.startPrank(accountsList[i]);
for (uint256 j = 0; j < numCollaterals; j++) {
contractsArray[1].collToken.approve(address(contractsArray[1].borrowerOperations), initialColl);
}
vm.stopPrank();
}

wethPriceFeed = IWETHPriceFeed(address(contractsArray[0].priceFeed));
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/test/SPInvariants.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ contract SPInvariantsTest is BaseInvariantTest {
super.setUp();

TestDeployer deployer = new TestDeployer();
(TestDeployer.LiquityContractsDev memory contracts,, IBoldToken boldToken, HintHelpers hintHelpers,,) =
(TestDeployer.LiquityContractsDev memory contracts,, IBoldToken boldToken, HintHelpers hintHelpers,,,) =
deployer.deployAndConnectContracts();
stabilityPool = contracts.stabilityPool;

Expand Down
7 changes: 7 additions & 0 deletions contracts/src/test/TestContracts/BaseTest.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import "./PriceFeedTestnet.sol";
import "../../Interfaces/IInterestRouter.sol";
import "../../GasPool.sol";
import "../../HintHelpers.sol";
import "../../Zappers/WETHZapper.sol";
import "../../Zappers/GasCompZapper.sol";
import "../../Zappers/LeverageLSTZapper.sol";
import {mulDivCeil} from "../Utils/Math.sol";
import {Logging} from "../Utils/Logging.sol";
import {StringFormatting} from "../Utils/StringFormatting.sol";
Expand Down Expand Up @@ -47,6 +50,10 @@ contract BaseTest is TestAccounts, Logging {
IERC20 collToken;
HintHelpers hintHelpers;
IWETH WETH; // used for gas compensation
WETHZapper wethZapper;
GasCompZapper gasCompZapper;
LeverageLSTZapper leverageZapperCurve;
LeverageLSTZapper leverageZapperUniV3;

// Structs for use in test where we need to bi-pass "stack-too-deep" errors
struct ABCDEF {
Expand Down
Loading

0 comments on commit cef6d60

Please sign in to comment.