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

chore: make paraswap ops optional for after-deploy #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
83 changes: 43 additions & 40 deletions tasks/misc/transfer-protocol-ownership.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import { POOL_ADMIN } from "./../../helpers/constants";
import { FORK } from "./../../helpers/hardhat-config-helpers";
import {
EMISSION_MANAGER_ID,
POOL_ADDRESSES_PROVIDER_ID,
} from "./../../helpers/deploy-ids";
import {
getACLManager,
getEmissionManager,
Expand All @@ -13,12 +9,8 @@ import {
getWrappedTokenGateway,
} from "./../../helpers/contract-getters";
import { task } from "hardhat/config";
import { getAddressFromJson, waitForTx } from "../../helpers/utilities/tx";
import { waitForTx } from "../../helpers/utilities/tx";
import { exit } from "process";
import {
GOVERNANCE_BRIDGE_EXECUTOR,
MULTISIG_ADDRESS,
} from "../../helpers/constants";

task(
`transfer-protocol-ownership`,
Expand Down Expand Up @@ -68,27 +60,12 @@ task(

const emissionManager = await getEmissionManager();
const currentOwner = await poolAddressesProvider.owner();
const paraswapSwapAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapLiquiditySwapAdapter")
).address
);
const paraswapRepayAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapRepayAdapter")
).address
);
const paraswapWithdrawSwapAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapWithdrawSwapAdapter")
).address
);

if (currentOwner === desiredAdmin) {
console.log(
"- This market already transferred the ownership to desired multisig"
);
exit(0);
return;
}
if (currentOwner !== poolAdmin) {
console.log(
Expand All @@ -101,28 +78,54 @@ task(
}

/** Start of Paraswap Helpers Ownership */
const isDeployerAdminParaswapRepayAdapter =
(await paraswapRepayAdapter.owner()) == deployer;

if (isDeployerAdminParaswapRepayAdapter) {
await paraswapRepayAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapRepayAdapter ownership");
const ParaswapRepayAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapRepayAdapter"
);
if (ParaswapRepayAdapterArtifact) {
const paraswapRepayAdapter = await getOwnableContract(
ParaswapRepayAdapterArtifact.address
);
const isDeployerAdminParaswapRepayAdapter =
(await paraswapRepayAdapter.owner()) == deployer;

if (isDeployerAdminParaswapRepayAdapter) {
await paraswapRepayAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapRepayAdapter ownership");
}
}

const isDeployerAdminParaswapSwapAdapter =
(await paraswapSwapAdapter.owner()) == deployer;
const paraswapSwapAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapLiquiditySwapAdapter"
);
if (paraswapSwapAdapterArtifact) {
const paraswapSwapAdapter = await getOwnableContract(
paraswapSwapAdapterArtifact.address
);
const isDeployerAdminParaswapSwapAdapter =
(await paraswapSwapAdapter.owner()) == deployer;

if (isDeployerAdminParaswapSwapAdapter) {
await paraswapSwapAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapSwapAdapter ownership");
if (isDeployerAdminParaswapSwapAdapter) {
await paraswapSwapAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapSwapAdapter ownership");
}
}

const isDeployerAdminParaswapWithdrawSwapAdapter =
(await paraswapWithdrawSwapAdapter.owner()) == deployer;
const paraSwapWithdrawSwapAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapWithdrawSwapAdapter"
);
if (paraSwapWithdrawSwapAdapterArtifact) {
const paraswapWithdrawSwapAdapter = await getOwnableContract(
paraSwapWithdrawSwapAdapterArtifact.address
);

const isDeployerAdminParaswapWithdrawSwapAdapter =
(await paraswapWithdrawSwapAdapter.owner()) == deployer;

if (isDeployerAdminParaswapWithdrawSwapAdapter) {
await paraswapWithdrawSwapAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapWithdrawSwapAdapter ownership");
if (isDeployerAdminParaswapWithdrawSwapAdapter) {
await paraswapWithdrawSwapAdapter.transferOwnership(desiredAdmin);
console.log("- Transferred ParaswapWithdrawSwapAdapter ownership");
}
}
/** End of Paraswap Helpers Ownership */

Expand Down
62 changes: 34 additions & 28 deletions tasks/misc/view-protocol-roles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,13 @@ import {
} from "./../../helpers/constants";
import {
AaveEcosystemReserveController,
EmissionManager,
WrappedTokenGatewayV3,
} from "./../../typechain";
import {
getEmissionManager,
getIncentivesV2,
getOwnableContract,
} from "./../../helpers/contract-getters";
import { EMISSION_MANAGER_ID } from "./../../helpers/deploy-ids";
import { FORK } from "../../helpers/hardhat-config-helpers";
import {
TREASURY_PROXY_ID,
Expand Down Expand Up @@ -64,9 +62,7 @@ task(
const emissionManager = await getEmissionManager();

console.log("--- Current deployer addresses ---");
console.table({
poolAdmin,
});
console.table({ poolAdmin });
console.log("--- Multisig and expected contract addresses ---");
console.table({
multisig: desiredAdmin,
Expand Down Expand Up @@ -121,22 +117,6 @@ task(
);
}

const paraswapSwapAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapLiquiditySwapAdapter")
).address
);
const paraswapRepayAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapRepayAdapter")
).address
);
const paraswapWithdrawSwapAdapter = await getOwnableContract(
await (
await hre.deployments.get("ParaSwapWithdrawSwapAdapter")
).address
);

/** Output of results*/
const result = [
{
Expand Down Expand Up @@ -242,22 +222,48 @@ task(
(await poolAddressesProvider.getAddress(incentivesControllerId)) ===
rewardsController.address,
},
{
];

const ParaswapRepayAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapRepayAdapter"
);
if (ParaswapRepayAdapterArtifact) {
const paraswapRepayAdapter = await getOwnableContract(
ParaswapRepayAdapterArtifact.address
);

result.push({
role: "ParaSwapRepayAdapter owner",
address: await paraswapRepayAdapter.owner(),
assert: (await paraswapRepayAdapter.owner()) == desiredAdmin,
},
{
});
}
const paraswapSwapAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapLiquiditySwapAdapter"
);
if (paraswapSwapAdapterArtifact) {
const paraswapSwapAdapter = await getOwnableContract(
paraswapSwapAdapterArtifact.address
);
result.push({
role: "ParaSwapSwapAdapter owner",
address: await paraswapSwapAdapter.owner(),
assert: (await paraswapSwapAdapter.owner()) == desiredAdmin,
},
{
});
}
const paraswapWithdrawSwapAdapterArtifact = await hre.deployments.getOrNull(
"ParaSwapWithdrawSwapAdapter"
);
if (paraswapWithdrawSwapAdapterArtifact) {
const paraswapWithdrawSwapAdapter = await getOwnableContract(
paraswapWithdrawSwapAdapterArtifact.address
);
result.push({
role: "ParaSwapWithdrawSwapAdapter owner",
address: await paraswapWithdrawSwapAdapter.owner(),
assert: (await paraswapWithdrawSwapAdapter.owner()) == desiredAdmin,
},
];
});
}

// Add emission manager check if 3.0.1v
try {
Expand Down