-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-it.js
143 lines (129 loc) · 4.36 KB
/
run-it.js
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
import {
assert,
simulateTransactionBundle
} from './utils';
import {
approveUSDCX,
upgradeUSDC,
setFlowrate,
increaseAutowrapAllowance,
cancelSuperfluidStream
} from './test-usdc-stream';
import {
approveENS,
createPlan,
cancelPlan
} from './test-ens-stream';
import {
SENDER_ADDR,
USDC_ADDR,
USDCX_ADDR,
SUPERFLUID_ADDR,
ENS_TOKEN_ADDR,
HEDGEY_BATCH_PLANNER_ADDR,
LOCKER_ADDR
} from './addresses';
import { init } from './utils';
const { foundry, impersonatedSigner } = await init();
assert(impersonatedSigner.address == SENDER_ADDR, "Impersonated signer is not the ENS DAO Wallet/Timelock");
//////////////////////////////
// USDC Stream Transactions //
//////////////////////////////
const approveUSDCXCalldata = await approveUSDCX();
const upgradeUSDCCalldata = await upgradeUSDC();
const setFlowrateCalldata = await setFlowrate();
const increaseAutowrapAllowanceCalldata = await increaseAutowrapAllowance();
const cancelSuperfluidStreamCalldata = await cancelSuperfluidStream();
// We don't need to create a new autowrap schedule for each stream.
// const createAutowrapCalldata = await createAutowrapSchedule();
console.log("------------------------------------------");
console.log("-------- CALL DATA FOR USDC STREAM --------")
console.log("------------------------------------------");
console.log("------------------------------------------");
console.log(approveUSDCXCalldata);
console.log("------------------------------------------");
console.log(upgradeUSDCCalldata);
console.log("------------------------------------------");
console.log(setFlowrateCalldata);
console.log("------------------------------------------");
console.log(increaseAutowrapAllowanceCalldata);
console.log("------------------------------------------");
console.log(cancelSuperfluidStreamCalldata);
console.log("------------------------------------------");
//////////////////////////////
// ENS Stream Transactions //
//////////////////////////////
const approveENSCalldata = await approveENS();
const [planId, createPlanCalldata] = await createPlan();
const cancelPlanCalldata = await cancelPlan(planId);
console.log("------------------------------------------");
console.log("-------- CALL DATA FOR ENS STREAM --------")
console.log("------------------------------------------");
console.log("------------------------------------------");
console.log(approveENSCalldata);
console.log("------------------------------------------");
console.log(createPlanCalldata);
console.log("------------------------------------------");
console.log(cancelPlanCalldata);
console.log("------------------------------------------");
//////////////////////////////
///// TENDERLY SIMULATION ////
//////////////////////////////
// Array of all our transactions to simulate with Tenderly
const transactions = [
// USDC Stream Transactions
{
from: SENDER_ADDR,
to: USDC_ADDR,
input: approveUSDCXCalldata,
},
{
from: SENDER_ADDR,
to: USDCX_ADDR,
input: upgradeUSDCCalldata,
},
{
from: SENDER_ADDR,
to: SUPERFLUID_ADDR,
input: setFlowrateCalldata,
},
{
from: SENDER_ADDR,
to: USDC_ADDR,
input: increaseAutowrapAllowanceCalldata,
},
{
from: SENDER_ADDR,
to: SUPERFLUID_ADDR,
input: cancelSuperfluidStreamCalldata,
},
// ENS Stream Transactions
{
from: SENDER_ADDR,
to: ENS_TOKEN_ADDR,
input: approveENSCalldata,
},
{
from: SENDER_ADDR,
to: HEDGEY_BATCH_PLANNER_ADDR,
input: createPlanCalldata,
},
{
from: SENDER_ADDR,
to: LOCKER_ADDR,
input: cancelPlanCalldata,
},
]
const defaults = {
network_id: '1',
save: true,
save_if_fails: true,
simulation_type: 'full',
};
const builtTransactions = transactions.map(item => ({ ...defaults, ...item }));
if (!process.env.TENDERLY_API_KEY || !process.env.TENDERLY_USERNAME || !process.env.TENDERLY_PROJECT) {
console.error("Please set TENDERLY_API_KEY/TENDERLY_USERNAME/TENDERLY_PROJECT in .env");
} else {
await simulateTransactionBundle(builtTransactions);
}
await foundry.shutdown();