Skip to content

Commit

Permalink
Merge pull request #423 from liquity/testnet_zappers_1
Browse files Browse the repository at this point in the history
chore: Add WETH and Gas Comp zappers to testnet deployment script
  • Loading branch information
bingen authored Sep 14, 2024
2 parents 70bf6d9 + 89ede86 commit a5049ab
Show file tree
Hide file tree
Showing 5 changed files with 5,232 additions and 1,601 deletions.
3,487 changes: 3,487 additions & 0 deletions contracts/broadcast/DeployLiquity2.s.sol/11155111/run-1726241571.json

Large diffs are not rendered by default.

3,300 changes: 1,700 additions & 1,600 deletions contracts/broadcast/DeployLiquity2.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions contracts/src/scripts/DeployLiquity2.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ import "../CollateralRegistry.sol";
import "../MockInterestRouter.sol";
import "../test/TestContracts/PriceFeedTestnet.sol";
import "../test/TestContracts/MetadataDeployment.sol";
import "../Zappers/WETHZapper.sol";
import "../Zappers/GasCompZapper.sol";
import {WETHTester} from "../test/TestContracts/WETHTester.sol";
import {Strings} from "openzeppelin-contracts/contracts/utils/Strings.sol";
import "forge-std/console.sol";
Expand All @@ -54,6 +56,8 @@ contract DeployLiquity2Script is Script, StdCheats, MetadataDeployment {
GasPool gasPool;
IInterestRouter interestRouter;
IERC20Metadata collToken;
WETHZapper wethZapper;
GasCompZapper gasCompZapper;
}

struct LiquityContractAddresses {
Expand All @@ -71,6 +75,11 @@ contract DeployLiquity2Script is Script, StdCheats, MetadataDeployment {
address interestRouter;
}

struct Zappers {
WETHZapper wethZapper;
GasCompZapper gasCompZapper;
}

struct TroveManagerParams {
uint256 CCR;
uint256 MCR;
Expand Down Expand Up @@ -128,6 +137,8 @@ contract DeployLiquity2Script is Script, StdCheats, MetadataDeployment {
string.concat('"priceFeed":"', address(c.priceFeed).toHexString(), '",'),
string.concat('"gasPool":"', address(c.gasPool).toHexString(), '",'),
string.concat('"interestRouter":"', address(c.interestRouter).toHexString(), '",'),
string.concat('"wethZapper":"', address(c.wethZapper).toHexString(), '",'),
string.concat('"gasCompZapper":"', address(c.gasCompZapper).toHexString(), '",'),
string.concat('"collToken":"', address(c.collToken).toHexString(), '"') // no comma
)
),
Expand Down Expand Up @@ -464,6 +475,31 @@ contract DeployLiquity2Script is Script, StdCheats, MetadataDeployment {
address(contracts.borrowerOperations),
address(contracts.activePool)
);

// deploy zappers
(contracts.gasCompZapper, contracts.wethZapper) =
_deployZappers(contracts.addressesRegistry, contracts.collToken, _weth);
}

function _deployZappers(
IAddressesRegistry _addressesRegistry,
IERC20 _collToken,
IWETH _weth
)
internal
returns (
GasCompZapper gasCompZapper,
WETHZapper wethZapper
)
{
bool lst = _collToken != _weth;
if (lst) {
gasCompZapper = new GasCompZapper(_addressesRegistry);
} else {
wethZapper = new WETHZapper(_addressesRegistry);
}

return (gasCompZapper, wethZapper);
}

function formatAmount(uint256 amount, uint256 decimals, uint256 digits) internal pure returns (string memory) {
Expand Down
4 changes: 3 additions & 1 deletion contracts/utils/deploy-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,20 +209,22 @@ Deploying Liquity contracts with the following settings:
const { deployer, ...safeOptions } = options;

const protocolContracts = {
WETHTester: deploymentManifest.branches[0].collToken as string,
BoldToken: deploymentManifest.boldToken as string,
CollateralRegistry: deploymentManifest.collateralRegistry as string,
HintHelpers: deploymentManifest.hintHelpers as string,
MultiTroveGetter: deploymentManifest.multiTroveGetter as string,
WETHTester: deploymentManifest.branches[0].collToken as string,
};

const collateralContracts = (deploymentManifest.branches as any[]).map((branch) => ({
activePool: branch.activePool as string,
borrowerOperations: branch.borrowerOperations as string,
gasCompZapper: branch.gasCompZapper as string,
sortedTroves: branch.sortedTroves as string,
stabilityPool: branch.stabilityPool as string,
token: branch.collToken as string,
troveManager: branch.troveManager as string,
wethZapper: branch.wethZapper as string,
}));

// write env file
Expand Down
6 changes: 6 additions & 0 deletions contracts/utils/deployment-artifacts-to-app-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,12 @@ const ZDeploymentContext = z.object({
z.object({
activePool: ZAddress,
borrowerOperations: ZAddress,
gasCompZapper: ZAddress,
sortedTroves: ZAddress,
stabilityPool: ZAddress,
token: ZAddress,
troveManager: ZAddress,
wethZapper: ZAddress,
}),
),
protocolContracts: z.object({
Expand Down Expand Up @@ -169,6 +171,10 @@ function contractNameToAppEnvVariable(contractName: string, prefix: string = "")
return `${prefix}_TOKEN`;
case "troveManager":
return `${prefix}_TROVE_MANAGER`;
case "wethZapper":
return `${prefix}_WETH_ZAPPER`;
case "gasCompZapper":
return `${prefix}_GAS_COMP_ZAPPER`;
}
return null;
}
Expand Down

0 comments on commit a5049ab

Please sign in to comment.