|
1 | 1 | const truffleContract = require("@truffle/contract") |
2 | 2 | const clc = require("cli-color") |
3 | 3 |
|
| 4 | +const contractHelper = require("./lib/contract-helper") |
| 5 | + |
4 | 6 | const KeepTokenJson = require("@keep-network/keep-core/artifacts/KeepToken.json") |
5 | 7 | const TokenStakingJson = require("@keep-network/keep-core/artifacts/TokenStaking.json") |
6 | 8 | const KeepBondingJson = require("@keep-network/keep-ecdsa/artifacts/KeepBonding.json") |
@@ -41,6 +43,11 @@ module.exports = async function () { |
41 | 43 | const keepBonding = await KeepBonding.deployed() |
42 | 44 | const tbtcSystem = await TBTCSystem.deployed() |
43 | 45 |
|
| 46 | + const deploymentBlock = await contractHelper.getDeploymentBlockNumber( |
| 47 | + KeepBondingJson, |
| 48 | + web3, |
| 49 | + ) |
| 50 | + |
44 | 51 | console.log(clc.yellow(`*** Contract Addresses ***`)) |
45 | 52 | console.log(`KeepToken: ${keepToken.address}`) |
46 | 53 | console.log(`TokenStaking: ${tokenStaking.address}`) |
@@ -102,9 +109,36 @@ module.exports = async function () { |
102 | 109 | ) |
103 | 110 | console.log(``) |
104 | 111 |
|
| 112 | + const bondCreatedEvents = await keepBonding.getPastEvents("BondCreated", { |
| 113 | + fromBlock: deploymentBlock, |
| 114 | + toBlock: "latest", |
| 115 | + }) |
| 116 | + |
| 117 | + const totalOperatorBondsAmount = {} |
| 118 | + const totalBondedAmount = web3.utils.toBN(0) |
| 119 | + |
| 120 | + for (let i = 0; i < bondCreatedEvents.length; i++) { |
| 121 | + const event = bondCreatedEvents[i] |
| 122 | + |
| 123 | + const operator = event.args.operator.toLowerCase() |
| 124 | + const bondAmount = web3.utils.toBN(event.args.amount) |
| 125 | + |
| 126 | + totalBondedAmount.iadd(bondAmount) |
| 127 | + |
| 128 | + if (totalOperatorBondsAmount[operator] === undefined) { |
| 129 | + totalOperatorBondsAmount[operator] = bondAmount |
| 130 | + } else { |
| 131 | + totalOperatorBondsAmount[operator].iadd(bondAmount) |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + console.log( |
| 136 | + `Total bonded ETH: ${web3.utils.fromWei(totalBondedAmount).toString()}`, |
| 137 | + ) |
| 138 | + |
105 | 139 | const ecdsaSummary = [] |
106 | 140 | for (let i = 0; i < ecdsaOperators.length; i++) { |
107 | | - const operator = ecdsaOperators[i] |
| 141 | + const operator = ecdsaOperators[i].toLowerCase() |
108 | 142 |
|
109 | 143 | const eligibleStake = await tokenStaking.eligibleStake( |
110 | 144 | operator, |
@@ -133,17 +167,23 @@ module.exports = async function () { |
133 | 167 | isUpToDateInTbtcPool = "N/A" |
134 | 168 | } |
135 | 169 |
|
| 170 | + const bondsAmountEth = web3.utils.fromWei( |
| 171 | + web3.utils.toBN(totalOperatorBondsAmount[operator] || 0), |
| 172 | + ) |
| 173 | + |
136 | 174 | ecdsaSummary.push({ |
137 | 175 | address: operator, |
138 | 176 | eligibleStakeKeep: eligibleStakeKeep.toString(), |
139 | 177 | operatorBalanceEth: operatorBalanceEth.toString(), |
140 | 178 | unbondedValueEth: unbondedValueEth.toString(), |
| 179 | + bondsAmountEth: bondsAmountEth.toString(), |
141 | 180 | isRegisteredInTbtcPool: isRegisteredInTbtcPool, |
142 | 181 | isUpToDateInTbtcPool: isUpToDateInTbtcPool, |
143 | 182 | }) |
144 | 183 | } |
145 | 184 |
|
146 | 185 | console.log(clc.yellow(`*** ECDSA Operators ***`)) |
| 186 | + |
147 | 187 | if (process.env.OUTPUT_MODE === "text") { |
148 | 188 | ecdsaSummary.forEach((s) => |
149 | 189 | console.log( |
|
0 commit comments