Skip to content

Commit ca381df

Browse files
authored
Merge pull request #180 from cryptexfinance/chore/cip-38-script
chore: add cip 38
2 parents 3e2266c + 5b50f8b commit ca381df

3 files changed

Lines changed: 4430 additions & 2938 deletions

File tree

hardhat.config.ts

Lines changed: 84 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -17,91 +17,91 @@ const mnemonic = process.env.DEPLOYER_MNEMONIC as string;
1717
const ganacheMnemonic = process.env.GANACHE_MNEMONIC as string;
1818

1919
const config: HardhatUserConfig = {
20-
//@ts-ignore
21-
namedAccounts: {
22-
deployer: {
23-
default: 0, // here this will by default take the first account as deployer
24-
},
25-
},
26-
solidity: {
27-
compilers: [
28-
{
29-
version: "0.7.5",
30-
settings: { optimizer: { enabled: true, runs: 200 } },
31-
},
32-
{
33-
version: "0.8.26",
34-
settings: { viaIR: true, optimizer: { enabled: true, runs: 200 } },
35-
},
36-
]
37-
},
38-
networks: {
39-
hardhat: {
40-
forking: {
41-
url: process.env.MAINNET_API_URL as string,
42-
},
43-
},
44-
mainnet: {
45-
url: process.env.MAINNET_API_URL,
46-
accounts: { mnemonic: mnemonic },
47-
},
48-
polygon: {
49-
url: process.env.POLYGON_API_URL,
50-
accounts: { mnemonic: mnemonic },
51-
},
52-
ganache: {
53-
url: "http://127.0.0.1:8545",
54-
accounts: { mnemonic: ganacheMnemonic },
55-
},
56-
ropsten: {
57-
url: process.env.ROPSTEN_API_URL,
58-
accounts: { mnemonic: mnemonic },
59-
},
60-
rinkeby: {
61-
url: process.env.RINKEBY_API_URL,
62-
accounts: { mnemonic: mnemonic },
63-
},
64-
goerli: {
65-
url: process.env.GOERLI_API_URL,
66-
accounts: { mnemonic: mnemonic },
67-
},
68-
kovan: {
69-
url: process.env.KOVAN_API_URL,
70-
accounts: { mnemonic: mnemonic },
71-
},
72-
optimismKovan: {
73-
url: process.env.OPTIMISM_KOVAN_API_URL,
74-
accounts: { mnemonic: mnemonic },
75-
},
76-
optimism: {
77-
url: process.env.OPTIMISM_API_URL,
78-
accounts: { mnemonic: mnemonic },
79-
},
80-
mumbai: {
81-
url: process.env.MUMBAI_API_URL,
82-
accounts: { mnemonic: mnemonic },
83-
},
84-
arbitrumGoerli: {
85-
url: process.env.ARBITRUM_GOERLI_API_URL,
86-
accounts: { mnemonic: mnemonic },
87-
},
20+
//@ts-ignore
21+
namedAccounts: {
22+
deployer: {
23+
default: 0, // here this will by default take the first account as deployer
24+
},
25+
},
26+
solidity: {
27+
compilers: [
28+
{
29+
version: "0.7.5",
30+
settings: { optimizer: { enabled: true, runs: 200 } },
31+
},
32+
{
33+
version: "0.8.26",
34+
settings: { viaIR: true, optimizer: { enabled: true, runs: 200 } },
35+
},
36+
]
37+
},
38+
networks: {
39+
hardhat: {
40+
},
41+
anvil: {
42+
url: "http://127.0.0.1:8545",
43+
},
44+
mainnet: {
45+
url: process.env.MAINNET_API_URL,
46+
accounts: { mnemonic: mnemonic },
47+
},
48+
polygon: {
49+
url: process.env.POLYGON_API_URL,
50+
accounts: { mnemonic: mnemonic },
51+
},
52+
ganache: {
53+
url: "http://127.0.0.1:8545",
54+
accounts: { mnemonic: ganacheMnemonic },
55+
},
56+
ropsten: {
57+
url: process.env.ROPSTEN_API_URL,
58+
accounts: { mnemonic: mnemonic },
59+
},
60+
rinkeby: {
61+
url: process.env.RINKEBY_API_URL,
62+
accounts: { mnemonic: mnemonic },
63+
},
64+
goerli: {
65+
url: process.env.GOERLI_API_URL,
66+
accounts: { mnemonic: mnemonic },
67+
},
68+
kovan: {
69+
url: process.env.KOVAN_API_URL,
70+
accounts: { mnemonic: mnemonic },
71+
},
72+
optimismKovan: {
73+
url: process.env.OPTIMISM_KOVAN_API_URL,
74+
accounts: { mnemonic: mnemonic },
75+
},
76+
optimism: {
77+
url: process.env.OPTIMISM_API_URL,
78+
accounts: { mnemonic: mnemonic },
79+
},
80+
mumbai: {
81+
url: process.env.MUMBAI_API_URL,
82+
accounts: { mnemonic: mnemonic },
83+
},
84+
arbitrumGoerli: {
85+
url: process.env.ARBITRUM_GOERLI_API_URL,
86+
accounts: { mnemonic: mnemonic },
87+
},
8888
arbitrum: {
89-
url: process.env.ARBITRUM_API_URL,
90-
accounts: { mnemonic: mnemonic },
91-
}
92-
},
93-
etherscan: {
94-
apiKey: process.env.ETHERSCAN_API_KEY as string,
95-
},
96-
gasReporter: {
97-
enabled: process.env.REPORT_GAS == "true",
98-
currency: "USD",
99-
gasPrice: 152,
100-
coinmarketcap: process.env.COIN_API as string,
101-
},
102-
mocha: {
103-
timeout: 100000,
104-
},
89+
url: process.env.ARBITRUM_API_URL,
90+
accounts: { mnemonic: mnemonic },
91+
}
92+
},
93+
etherscan: {
94+
apiKey: process.env.ETHERSCAN_API_KEY as string,
95+
},
96+
gasReporter: {
97+
enabled: process.env.REPORT_GAS == "true",
98+
currency: "USD",
99+
gasPrice: 152,
100+
coinmarketcap: process.env.COIN_API as string,
101+
},
102+
mocha: {
103+
timeout: 100000,
104+
},
105105
verify: {
106106
etherscan: {
107107
apiKey: process.env.ETHERSCAN_API_KEY as string,

scripts/CIP-38.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// run with
2+
// npx hardhat run ./scripts/CIP-38.ts --network hardhat
3+
import hre, { deployments, network, hardhatArguments } from "hardhat";
4+
import {
5+
castVote,
6+
createProposal,
7+
executeProposal,
8+
fundMultisign,
9+
queueProposal,
10+
} from "./utils";
11+
import { BigNumber } from "ethers";
12+
13+
async function main() {
14+
const ethers = hre.ethers;
15+
let davinciWallet = "0x55981Be98EEaF4E57aC466BE72C6323F2Cc659Aa";
16+
let ctxAmount = ethers.utils.parseEther("300000");
17+
let ctx = await deployments.get("Ctx");
18+
let ctxContract = await ethers.getContractAt("Ctx", ctx.address);
19+
20+
const abi = new ethers.utils.AbiCoder();
21+
const targets = [ctx.address];
22+
const values = [BigNumber.from(0)];
23+
const signatures = ["transfer(address,uint256)"];
24+
const calldatas = [
25+
abi.encode(["address", "uint256"], [davinciWallet, ctxAmount]),
26+
];
27+
const description =
28+
"CIP-38: Renew Market Making Agreement with DaVinci Trading";
29+
console.log(targets);
30+
console.log(values.toString());
31+
console.log(signatures);
32+
console.log(calldatas);
33+
console.log(description);
34+
35+
let ctxbalance = await ctxContract.balanceOf(davinciWallet);
36+
console.log("davinci old CTX balance", ethers.utils.formatEther(ctxbalance));
37+
38+
if (hardhatArguments.network === "hardhat") {
39+
//Fund Multisign with ETH
40+
await fundMultisign("10000000000000000000");
41+
42+
// Create Proposal
43+
await createProposal(targets, values, signatures, calldatas, description);
44+
45+
// Vote
46+
await castVote(17, true);
47+
48+
// Wait to queue
49+
await queueProposal(17);
50+
51+
// Execute transaction
52+
await executeProposal(17);
53+
54+
// Validate Results
55+
console.log("==================Check Results==================");
56+
57+
ctxbalance = await ctxContract.balanceOf(davinciWallet);
58+
console.log(
59+
"davinci new CTX balance",
60+
ethers.utils.formatEther(ctxbalance)
61+
);
62+
}
63+
}
64+
65+
main()
66+
.then(() => process.exit(0))
67+
.catch((error) => {
68+
console.error(error);
69+
process.exit(1);
70+
});

0 commit comments

Comments
 (0)