forked from compound-finance/comet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone-multisig.ts
44 lines (36 loc) · 1.84 KB
/
clone-multisig.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import hre from 'hardhat';
import { DeploymentManager } from '../plugins/deployment_manager/DeploymentManager';
import { SafeFactory } from '@safe-global/safe-core-sdk';
import EthersAdapter from '@safe-global/safe-ethers-lib';
const SRC_NETWORK = process.env['SRC_NETWORK'] ?? 'mainnet';
const DST_NETWORK = process.env['DST_NETWORK'] ?? 'hardhat';
async function main() {
await hre.changeNetwork(SRC_NETWORK);
const dm = new DeploymentManager(SRC_NETWORK, 'usdc', hre);
const signer_ = await dm.getSigner();
const comet = await dm.contract('comet');
const guardian = await comet.pauseGuardian();
// Get owners and threshold from existing multisig
const GnosisABI = [
{"constant":true,"inputs":[],"name":"getOwners","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"payable":false,"stateMutability":"view","type":"function"},
{"constant":true,"inputs":[],"name":"getThreshold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},
];
const GnosisSafeContract = new hre.ethers.Contract(guardian, GnosisABI, hre.ethers.provider);
const owners = await GnosisSafeContract.getOwners();
const threshold = await GnosisSafeContract.getThreshold();
const safeAccountConfig = { owners: owners, threshold: threshold};
console.log(safeAccountConfig);
console.log(guardian);
await hre.changeNetwork(DST_NETWORK);
const signer = await hre.ethers.provider.getSigner(signer_.address);
const ethAdapter = new EthersAdapter({ ethers: hre.ethers, signerOrProvider: signer });
const safeFactory = await SafeFactory.create({ ethAdapter: ethAdapter });
const safeSdk = await safeFactory.deploySafe({ safeAccountConfig });
console.log(safeSdk);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});