Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/nicka/lp' into clement/testnet-d…
Browse files Browse the repository at this point in the history
…etector
  • Loading branch information
clement-ux committed Sep 30, 2024
2 parents 06a02e6 + c4c0c86 commit 0889c60
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ deploy-testnet:
@forge script script/deploy/DeployManager.sol --rpc-url $(TESTNET_URL) --broadcast --slow --unlocked -vvvv

deploy-holesky:
@forge script script/deploy/DeployManager.sol --rpc-url $(HOLESKY_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvvv
@forge script script/deploy/DeployManager.sol --rpc-url $(HOLESKY_URL) --private-key ${DEPLOYER_PRIVATE_KEY} --broadcast --slow --verify -vvv

# Override default `test` and `coverage` targets
.PHONY: test coverage
13 changes: 11 additions & 2 deletions script/deploy/mainnet/003_UpgradeLidoARMScript.sol
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
// 7. Transfer ownership of LiquidityProviderController to the mainnet 5/8 multisig
lpcProxy.setOwner(Mainnet.GOV_MULTISIG);

console.log("Finished deploying", DEPLOY_NAME);

// Post deploy
// 1. The Lido ARM multisig needs to set the owner to the mainnet 5/8 multisig
// 1. The mainnet 5/8 multisig needs to upgrade and call initialize on the Lido ARM
Expand All @@ -71,7 +73,8 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
if (tenderlyTestnet) {
vm.startBroadcast(Mainnet.ARM_MULTISIG);
} else {
vm.startPrank(Mainnet.ARM_MULTISIG);
console.log("Broadcasting fork script to Tenderly as: %s", Mainnet.ARM_MULTISIG);
vm.startBroadcast(Mainnet.ARM_MULTISIG);
}

if (lidoARMProxy == Proxy(0x0000000000000000000000000000000000000000)) {
Expand Down Expand Up @@ -122,6 +125,12 @@ contract UpgradeLidoARMMainnetScript is AbstractDeployScript {
// transfer ownership of the Lido ARM proxy to the mainnet 5/8 multisig
lidoARMProxy.setOwner(Mainnet.GOV_MULTISIG);

vm.stopPrank();
console.log("Finished running initializing Lido ARM as ARM_MULTISIG");

if (tenderlyTestnet) {
vm.stopBroadcast();
} else {
vm.stopPrank();
}
}
}
8 changes: 1 addition & 7 deletions src/contracts/utils/Addresses.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ library Mainnet {
address public constant GOVERNOR_FIVE = 0x3cdD07c16614059e66344a7b579DAB4f9516C0b6;
address public constant GOVERNOR_SIX = 0x1D3Fbd4d129Ddd2372EA85c5Fa00b2682081c9EC;
address public constant STRATEGIST = 0xF14BBdf064E3F67f51cd9BD646aE3716aD938FDC;
address public constant TREASURY = 0x0000000000000000000000000000000000000001;
address public constant TREASURY = 0x6E3fddab68Bf1EBaf9daCF9F7907c7Bc0951D1dc;

// Multisig and EOAs
address public constant INITIAL_DEPLOYER = address(0x1001);
address public constant GOV_MULTISIG = 0xbe2AB3d3d8F6a32b96414ebbd865dBD276d3d899;
address public constant ARM_MULTISIG = 0xC8F2cF4742C86295653f893214725813B16f7410;
address public constant OETH_RELAYER = 0x4b91827516f79d6F6a1F292eD99671663b09169a;
Expand All @@ -40,7 +39,6 @@ library Mainnet {

library Holesky {
// Multisig and EOAs
address public constant INITIAL_DEPLOYER = 0x1b94CA50D3Ad9f8368851F8526132272d1a5028C;
address public constant RELAYER = 0x3C6B0c7835a2E2E0A45889F64DcE4ee14c1D5CB4;

// Tokens
Expand Down Expand Up @@ -84,7 +82,6 @@ contract AddressResolver {
resolver[MAINNET]["LIDO_ARM"] = Mainnet.LIDO_ARM;

// Test accounts
resolver[MAINNET]["INITIAL_DEPLOYER"] = address(0x1001);
resolver[MAINNET]["WHALE_OETH"] = 0x8E02247D3eE0E6153495c971FFd45Aa131f4D7cB;

///// Holesky //////
Expand All @@ -99,9 +96,6 @@ contract AddressResolver {
// Contracts
resolver[HOLESKY]["OETH_VAULT"] = Holesky.OETH_VAULT;
resolver[HOLESKY]["OETH_ARM"] = Mainnet.OETH_ARM;

// Test accounts
resolver[HOLESKY]["INITIAL_DEPLOYER"] = Holesky.INITIAL_DEPLOYER;
}

function resolve(string memory name) public view returns (address resolved) {
Expand Down
66 changes: 66 additions & 0 deletions src/js/tasks/liquidityProvider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const { parseUnits } = require("ethers");

const { getSigner } = require("../utils/signers");
const { parseDeployedAddress } = require("../utils/addressParser");
const { logTxDetails } = require("../utils/txLogger");

const log = require("../utils/logger")("task:lpCap");

async function lpDeposit({ amount }) {
const signer = await getSigner();

const amountBn = parseUnits(amount.toString());

const lidArmAddress = await parseDeployedAddress("LIDO_ARM");
const lidoARM = await ethers.getContractAt("LidoARM", lidArmAddress);

log(`About to deposit ${amount} WETH to the Lido ARM`);
const tx = await lidoARM.connect(signer).deposit(amountBn);
await logTxDetails(tx, "deposit");
}

async function setLiquidityProviderCaps({ accounts, cap }) {
const signer = await getSigner();

const capBn = parseUnits(cap.toString());

const liquidityProviders = accounts.split(",");

const lpcAddress = await parseDeployedAddress("LIDO_ARM_LPC");
const liquidityProviderController = await ethers.getContractAt(
"LiquidityProviderController",
lpcAddress
);

log(
`About to set deposit cap of ${cap} WETH for liquidity providers ${liquidityProviders}`
);
const tx = await liquidityProviderController
.connect(signer)
.setLiquidityProviderCaps(liquidityProviders, capBn);
await logTxDetails(tx, "setLiquidityProviderCaps");
}

async function setTotalAssetsCap({ cap }) {
const signer = await getSigner();

const capBn = parseUnits(cap.toString());

const lpcAddress = await parseDeployedAddress("LIDO_ARM_LPC");
const liquidityProviderController = await ethers.getContractAt(
"LiquidityProviderController",
lpcAddress
);

log(`About to set total asset cap of ${cap} WETH`);
const tx = await liquidityProviderController
.connect(signer)
.setTotalAssetsCap(capBn);
await logTxDetails(tx, "setTotalAssetsCap");
}

module.exports = {
lpDeposit,
setLiquidityProviderCaps,
setTotalAssetsCap,
};
74 changes: 63 additions & 11 deletions src/js/tasks/tasks.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { subtask, task, types } = require("hardhat/config");
const { formatUnits, parseUnits } = require("ethers");

const { parseAddress } = require("../utils/addressParser");
const {
parseAddress,
parseDeployedAddress,
} = require("../utils/addressParser");
const { setAutotaskVars } = require("./autotask");
const { setActionVars } = require("./defender");
const {
Expand All @@ -12,6 +15,11 @@ const {
logLiquidity,
withdrawRequestStatus,
} = require("./liquidity");
const {
lpDeposit,
setLiquidityProviderCaps,
setTotalAssetsCap,
} = require("./liquidityProvider");
const { swap } = require("./swap");
const {
tokenAllowance,
Expand Down Expand Up @@ -419,6 +427,50 @@ task("redeemAll").setAction(async (_, __, runSuper) => {
return runSuper();
});

// ARM Liquidity Provider Functions

subtask("lpDeposit", "Set total assets cap")
.addParam(
"amount",
"Amount of WETH not scaled to 18 decimals",
undefined,
types.float
)
.setAction(lpDeposit);
task("lpDeposit").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask("setLiquidityProviderCaps", "Set deposit cap for liquidity providers")
.addParam(
"cap",
"Amount of WETH not scaled to 18 decimals",
undefined,
types.float
)
.addParam(
"accounts",
"Comma separated list of addresses",
undefined,
types.string
)
.setAction(setLiquidityProviderCaps);
task("setLiquidityProviderCaps").setAction(async (_, __, runSuper) => {
return runSuper();
});

subtask("setTotalAssetsCap", "Set total assets cap")
.addParam(
"cap",
"Amount of WETH not scaled to 18 decimals",
undefined,
types.float
)
.setAction(setTotalAssetsCap);
task("setTotalAssetsCap").setAction(async (_, __, runSuper) => {
return runSuper();
});

// Proxies

subtask("upgradeProxy", "Upgrade a proxy contract to a new implementation")
Expand Down Expand Up @@ -457,16 +509,18 @@ subtask(

const wethAddress = await parseAddress("WETH");
const stethAddress = await parseAddress("STETH");
const lidoArmAddress = await parseAddress("LIDO_ARM");
const lidoArmAddress = await parseDeployedAddress("LIDO_ARM");
const lidoArmImpl = parseDeployedAddress("LIDO_ARM_IMPL");
const relayerAddress = await parseAddress("ARM_RELAYER");
const liquidityProviderController = await parseDeployedAddress(
"LIDO_ARM_LPC"
);
const feeCollector = await parseAddress("ARM_BUYBACK");

const weth = await ethers.getContractAt("IWETH", wethAddress);
const steth = await ethers.getContractAt("IWETH", stethAddress);
const legacyAMM = await ethers.getContractAt("LegacyAMM", lidoArmAddress);
const lidoARM = await ethers.getContractAt(
"LidoFixedPriceMultiLpARM",
lidoArmAddress
);
const lidoARM = await ethers.getContractAt("LidoARM", lidoArmAddress);
const lidoProxy = await ethers.getContractAt("Proxy", lidoArmAddress);

const wethBalance = await weth.balanceOf(lidoArmAddress);
Expand Down Expand Up @@ -495,20 +549,18 @@ subtask(
"ARM-ST",
relayerAddress,
1500, // 15% performance fee
// TODO set to Buyback contract
relayerAddress,
"0x187FfF686a5f42ACaaF56469FcCF8e6Feca18248",
liquidityProviderController,
feeCollector,
]
);

const lidoArmImpl = "0x3d724176c8f1F965eF4020CB5DA5ad1a891BEEf1";
console.log(`Amount to upgradeToAndCall the Lido ARM`);
await lidoProxy.connect(signer).upgradeToAndCall(lidoArmImpl, initData);

console.log(`Amount to setPrices on the Lido ARM`);
await lidoARM
.connect(signer)
.setPrices(parseUnits("9994", 32), parseUnits("1", 36));
.setPrices(parseUnits("9994", 32), parseUnits("9999", 32));

console.log(`Amount to setOwner on the Lido ARM`);
await lidoProxy.connect(signer).setOwner(await parseAddress("GOV_MULTISIG"));
Expand Down
28 changes: 28 additions & 0 deletions src/js/utils/addressParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ const { readFileSync } = require("fs");

const log = require("./logger")("utils:addressParser");

const parseDeployedAddress = async (name) => {
const network = await ethers.provider.getNetwork();
const chainId = network.chainId;

const fileName = `./build/deployments-${chainId}.json`;
log(`Parsing deployed contract ${name} from ${fileName}.`);
try {
const data = await readFileSync(fileName, "utf-8");

// Parse the JSON data
const deploymentData = JSON.parse(data);

if (!deploymentData?.contracts[name]) {
throw new Error(`Failed to find deployed address for ${name}.`);
}

return deploymentData.contracts[name];
} catch (err) {
throw new Error(
`Failed to parse deployed contract "${name}" from "${fileName}".`,
{
cause: err,
}
);
}
};

// Parse an address from the Solidity Addresses file
const parseAddress = async (name) => {
// parse from Addresses.sol file
Expand Down Expand Up @@ -57,4 +84,5 @@ const parseAddress = async (name) => {

module.exports = {
parseAddress,
parseDeployedAddress,
};

0 comments on commit 0889c60

Please sign in to comment.