@gooddollar/goodprotocol 2.0.34-beta.4 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/artifacts/abis/Faucet.min.json +1 -1
  2. package/artifacts/abis/FuseFaucetV2.min.json +1 -1
  3. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.dbg.json +1 -1
  4. package/artifacts/contracts/fuseFaucet/Faucet.sol/Faucet.json +34 -2
  5. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.dbg.json +1 -1
  6. package/artifacts/contracts/fuseFaucet/FuseFaucetV2.sol/FuseFaucetV2.json +34 -2
  7. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.dbg.json +1 -1
  8. package/artifacts/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy.json +2 -2
  9. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.dbg.json +1 -1
  10. package/artifacts/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967.json +2 -2
  11. package/contracts/fuseFaucet/Faucet.sol +6 -0
  12. package/contracts/fuseFaucet/FuseFaucetV2.sol +10 -0
  13. package/contracts/utils/ProxyFactory1967.sol +1 -0
  14. package/hardhat.config.ts +25 -20
  15. package/package.json +1 -1
  16. package/releases/olddao.json +1 -1
  17. package/scripts/fv.ts +0 -2
  18. package/scripts/multichain-deploy/fulldeploy.sh +17 -17
  19. package/scripts/proposals/gip-25-xdc-upgrade-ubi.ts +443 -0
  20. package/scripts/upgrades/upgradeFaucet.ts +46 -0
  21. package/types/contracts/fuseFaucet/Faucet.ts +43 -0
  22. package/types/contracts/fuseFaucet/FuseFaucetV2.ts +43 -0
  23. package/types/factories/contracts/fuseFaucet/Faucet__factory.ts +33 -1
  24. package/types/factories/contracts/fuseFaucet/FuseFaucetV2__factory.ts +33 -1
  25. package/types/factories/contracts/utils/ProxyFactory1967.sol/ERC1967Proxy__factory.ts +1 -1
  26. package/types/factories/contracts/utils/ProxyFactory1967.sol/ProxyFactory1967__factory.ts +1 -1
  27. package/contracts/IQuoter.sol +0 -108
  28. package/scripts/multichain-deploy/verify.ts +0 -41
  29. package/scripts/proposals/gip-25-xdc-upgrade.ts +0 -438
@@ -1,108 +0,0 @@
1
- // SPDX-License-Identifier: GPL-2.0-or-later
2
- pragma solidity >=0.7.5;
3
- pragma abicoder v2;
4
-
5
- /// @title QuoterV2 Interface
6
- /// @notice Supports quoting the calculated amounts from exact input or exact output swaps.
7
- /// @notice For each pool also tells you the number of initialized ticks crossed and the sqrt price of the pool after the swap.
8
- /// @dev These functions are not marked view because they rely on calling non-view functions and reverting
9
- /// to compute the result. They are also not gas efficient and should not be called on-chain.
10
- interface IQuoterV2 {
11
- /// @notice Returns the amount out received for a given exact input swap without executing the swap
12
- /// @param path The path of the swap, i.e. each token pair and the pool fee
13
- /// @param amountIn The amount of the first token to swap
14
- /// @return amountOut The amount of the last token that would be received
15
- /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path
16
- /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path
17
- /// @return gasEstimate The estimate of the gas that the swap consumes
18
- function quoteExactInput(
19
- bytes memory path,
20
- uint256 amountIn
21
- )
22
- external
23
- returns (
24
- uint256 amountOut,
25
- uint160[] memory sqrtPriceX96AfterList,
26
- uint32[] memory initializedTicksCrossedList,
27
- uint256 gasEstimate
28
- );
29
-
30
- struct QuoteExactInputSingleParams {
31
- address tokenIn;
32
- address tokenOut;
33
- uint256 amountIn;
34
- uint24 fee;
35
- uint160 sqrtPriceLimitX96;
36
- }
37
-
38
- /// @notice Returns the amount out received for a given exact input but for a swap of a single pool
39
- /// @param params The params for the quote, encoded as `QuoteExactInputSingleParams`
40
- /// tokenIn The token being swapped in
41
- /// tokenOut The token being swapped out
42
- /// fee The fee of the token pool to consider for the pair
43
- /// amountIn The desired input amount
44
- /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
45
- /// @return amountOut The amount of `tokenOut` that would be received
46
- /// @return sqrtPriceX96After The sqrt price of the pool after the swap
47
- /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed
48
- /// @return gasEstimate The estimate of the gas that the swap consumes
49
- function quoteExactInputSingle(
50
- QuoteExactInputSingleParams memory params
51
- )
52
- external
53
- returns (
54
- uint256 amountOut,
55
- uint160 sqrtPriceX96After,
56
- uint32 initializedTicksCrossed,
57
- uint256 gasEstimate
58
- );
59
-
60
- /// @notice Returns the amount in required for a given exact output swap without executing the swap
61
- /// @param path The path of the swap, i.e. each token pair and the pool fee. Path must be provided in reverse order
62
- /// @param amountOut The amount of the last token to receive
63
- /// @return amountIn The amount of first token required to be paid
64
- /// @return sqrtPriceX96AfterList List of the sqrt price after the swap for each pool in the path
65
- /// @return initializedTicksCrossedList List of the initialized ticks that the swap crossed for each pool in the path
66
- /// @return gasEstimate The estimate of the gas that the swap consumes
67
- function quoteExactOutput(
68
- bytes memory path,
69
- uint256 amountOut
70
- )
71
- external
72
- returns (
73
- uint256 amountIn,
74
- uint160[] memory sqrtPriceX96AfterList,
75
- uint32[] memory initializedTicksCrossedList,
76
- uint256 gasEstimate
77
- );
78
-
79
- struct QuoteExactOutputSingleParams {
80
- address tokenIn;
81
- address tokenOut;
82
- uint256 amount;
83
- uint24 fee;
84
- uint160 sqrtPriceLimitX96;
85
- }
86
-
87
- /// @notice Returns the amount in required to receive the given exact output amount but for a swap of a single pool
88
- /// @param params The params for the quote, encoded as `QuoteExactOutputSingleParams`
89
- /// tokenIn The token being swapped in
90
- /// tokenOut The token being swapped out
91
- /// fee The fee of the token pool to consider for the pair
92
- /// amountOut The desired output amount
93
- /// sqrtPriceLimitX96 The price limit of the pool that cannot be exceeded by the swap
94
- /// @return amountIn The amount required as the input for the swap in order to receive `amountOut`
95
- /// @return sqrtPriceX96After The sqrt price of the pool after the swap
96
- /// @return initializedTicksCrossed The number of initialized ticks that the swap crossed
97
- /// @return gasEstimate The estimate of the gas that the swap consumes
98
- function quoteExactOutputSingle(
99
- QuoteExactOutputSingleParams memory params
100
- )
101
- external
102
- returns (
103
- uint256 amountIn,
104
- uint160 sqrtPriceX96After,
105
- uint32 initializedTicksCrossed,
106
- uint256 gasEstimate
107
- );
108
- }
@@ -1,41 +0,0 @@
1
- import { network, ethers, upgrades, run } from "hardhat";
2
-
3
- import {
4
- deployDeterministic,
5
- deploySuperGoodDollar,
6
- verifyProductionSigner,
7
- verifyContract,
8
- verifyOnEtherscan
9
- } from "./helpers";
10
- import releaser from "../releaser";
11
- import ProtocolSettings from "../../releases/deploy-settings.json";
12
- import dao from "../../releases/deployment.json";
13
- import { getImplementationAddress } from "@openzeppelin/upgrades-core";
14
-
15
- const main = async () => {
16
- const release = dao[network.name] || {};
17
- console.log("verifying network:", network.name, release);
18
- const protocolSettings = ProtocolSettings[network.name] || ProtocolSettings["default"];
19
- // await verifyContract(release.ProxyFactory, "contracts/utils/ProxyFactory1967.sol:ProxyFactory1967");
20
- // await verifyContract(release.Identity, "contracts/utils/ProxyFactory1967.sol:ERC1967Proxy", false);
21
- // await verifyContract(release.Identity, "contracts/identity/IdentityV3.sol:IdentityV3", network.name);
22
- // await verifyContract(release.NameService, "contracts/utils/NameService.sol:NameService", network.name);
23
- // if (protocolSettings.superfluidHost) {
24
- // await verifyContract(release.GoodDollar, "contracts/token/superfluid/UUPSProxy.sol:UUPSProxy", network.name, false);
25
- // await verifyContract(
26
- // release.GoodDollar,
27
- // "contracts/token/superfluid/SuperGoodDollar.sol:SuperGoodDollar",
28
- // network.name,
29
- // true,
30
- // ethers.constants.AddressZero
31
- // );
32
- // } else {
33
- // await verifyContract(release.GoodDollar, "contracts/token/GoodDollar.sol:GoodDollar", network.name);
34
- // }
35
-
36
- // await verifyContract(release.AdminWallet, "contracts/utils/AdminWallet.sol:AdminWallet", network.name);
37
- // await verifyContract(release.Faucet, "contracts/fuseFaucet/Faucet.sol:Faucet", network.name);
38
- // await verifyContract(release.Invites, "contracts/invite/InvitesV2.sol:InvitesV2", network.name);
39
- await verifyContract(release.UBIScheme, "contracts/ubi/UBISchemeV2.sol:UBISchemeV2", network.name);
40
- };
41
- main();
@@ -1,438 +0,0 @@
1
- // Part 1 UBI+Bridge
2
- // deploy dao to xdc - Done
3
- // deploy bridge to xdc - Done
4
- // give minting rights to xdc bridge
5
- // upgrade to improved identity + ubischeme on celo + fuse
6
- // upgrade bridge on celo/ethereum/fuse - make sure they include xdc
7
- // burn celo bridge locked supply (now each chain has its own supply and all bridges are mint/burn)
8
-
9
- // Part 2 Reserve
10
- // create uniswap pools on xdc
11
- // calculate how much G$s each reserve is backing
12
- // deploy mento reserve to xdc with calculated parameters
13
- // give mento broker minting rights on xdc
14
- // deploy distribution helper
15
- // transfer usdc to xdc reserve
16
- // update celo reserve parameters accordingly
17
-
18
- import { network, ethers, upgrades } from "hardhat";
19
- import { reset } from "@nomicfoundation/hardhat-network-helpers";
20
- import { defaultsDeep, last } from "lodash";
21
- import prompt from "prompt";
22
-
23
- import { executeViaGuardian, executeViaSafe, verifyProductionSigner } from "../multichain-deploy/helpers";
24
-
25
- import ProtocolSettings from "../../releases/deploy-settings.json";
26
-
27
- import dao from "../../releases/deployment.json";
28
- import {
29
- CeloDistributionHelper,
30
- Controller,
31
- FuseOldBridgeKill,
32
- GoodMarketMaker,
33
- IBancorExchangeProvider,
34
- IBroker,
35
- IGoodDollar,
36
- IGoodDollarExchangeProvider,
37
- IGoodDollarExpansionController,
38
- IMentoReserve,
39
- ProtocolUpgradeV4Mento
40
- } from "../../types";
41
- import releaser from "../releaser";
42
- let { name: networkName } = network;
43
- const isSimulation = network.name === "hardhat" || network.name === "fork" || network.name === "localhost";
44
-
45
- export const upgradeCelo = async (network, checksOnly) => {
46
- let [root] = await ethers.getSigners();
47
-
48
- const isProduction = networkName.includes("production");
49
-
50
- if (isProduction) verifyProductionSigner(root);
51
-
52
- let networkEnv = networkName;
53
- if (isSimulation) networkEnv = network;
54
-
55
- let release: { [key: string]: any } = dao[networkEnv];
56
-
57
- let guardian = root;
58
- console.log("signer:", root.address, { networkEnv, isSimulation, isProduction, release });
59
-
60
- const cusd = await ethers.getContractAt("IERC20", release.CUSD);
61
- const gd = await ethers.getContractAt("GoodDollar", release.GoodDollar);
62
- const mentoReserve = (await ethers.getContractAt("IMentoReserve", release.MentoReserve)) as IMentoReserve;
63
-
64
- const ubiImpl = await ethers.deployContract("UBISchemeV2");
65
- const identityImpl = await ethers.deployContract("IdentityV3");
66
-
67
- console.log("deployed new impls", { ubiImpl: ubiImpl.address, identityImpl: identityImpl.address });
68
-
69
- const proposalActions = [
70
- [release.UBIScheme, "upgradeTo(address)", ethers.utils.defaultAbiCoder.encode(["address"], [ubiImpl.address]), "0"], //upgrade ubi
71
- [
72
- release.Identity,
73
- "upgradeTo(address)",
74
- ethers.utils.defaultAbiCoder.encode(["address"], [identityImpl.address]),
75
- "0"
76
- ] //upgrade identity
77
- ];
78
- const mentoExchange = (await ethers.getContractAt(
79
- "IBancorExchangeProvider",
80
- release.MentoExchangeProvider
81
- )) as IBancorExchangeProvider;
82
-
83
- //simulate on fork, make sure safe has enough eth to simulate txs
84
- let DIST_HELPER_MIN_CELO_BALANCE = ethers.utils.parseEther("2");
85
-
86
- if (isSimulation && !checksOnly) {
87
- DIST_HELPER_MIN_CELO_BALANCE = ethers.utils.parseEther("0.1");
88
- // await reset("https://rpc.ankr.com/celo");
89
- await root.sendTransaction({ value: ethers.utils.parseEther("0.5"), to: release.Avatar });
90
-
91
- const avatar = await ethers.getImpersonatedSigner(release.Avatar);
92
- const reserveOwner = await ethers.getImpersonatedSigner(await mentoReserve.owner());
93
- const eids = await mentoExchange.getExchangeIds();
94
- if (eids.length > 0) {
95
- await mentoExchange.connect(avatar).destroyExchange(eids[0], 0);
96
- }
97
-
98
- const devCUSD = await ethers.getContractAt(
99
- [
100
- "function mint(address,uint) external returns (uint)",
101
- "function setValidators(address) external",
102
- "function owner() view returns(address)"
103
- ],
104
- release.CUSD
105
- );
106
-
107
- console.log("minting devCUSD");
108
- const cusdOwner = await ethers.getImpersonatedSigner(await devCUSD.owner());
109
- await root.sendTransaction({ value: ethers.utils.parseEther("0.5"), to: cusdOwner.address });
110
- await devCUSD.connect(cusdOwner).setValidators(release.Avatar).catch(console.log);
111
- await devCUSD.connect(avatar).mint(root.address, ethers.utils.parseEther("2000000")).catch(console.log);
112
-
113
- console.log("transfering cusd to reserve");
114
- await cusd.connect(root).transfer(release.MentoReserve, ethers.utils.parseEther("200000"));
115
-
116
- guardian = await ethers.getImpersonatedSigner(release.GuardiansSafe);
117
- await root.sendTransaction({ value: ethers.utils.parseEther("0.5"), to: guardian.address });
118
- } else if (!isProduction && !checksOnly) {
119
- DIST_HELPER_MIN_CELO_BALANCE = ethers.utils.parseEther("0.1");
120
- const mentoReserve = (await ethers.getContractAt("IMentoReserve", release.MentoReserve)) as IMentoReserve;
121
- const ctrl = (await ethers.getContractAt("Controller", release.Controller)) as Controller;
122
-
123
- const eids = await mentoExchange.getExchangeIds();
124
- if (eids.length > 0) {
125
- await (
126
- await ctrl.genericCall(
127
- mentoExchange.address,
128
- mentoExchange.interface.encodeFunctionData("destroyExchange", [eids[0], 0]),
129
- release.Avatar,
130
- 0
131
- )
132
- ).wait();
133
- }
134
-
135
- const devCUSD = await ethers.getContractAt(
136
- ["function mint(address,uint) external returns (uint)", "function setValidators(address) external"],
137
- release.CUSD
138
- );
139
- await (
140
- await ctrl.genericCall(
141
- devCUSD.address,
142
- devCUSD.interface.encodeFunctionData("setValidators", [release.Avatar]),
143
- release.Avatar,
144
- 0
145
- )
146
- ).wait();
147
- await (
148
- await ctrl.genericCall(
149
- devCUSD.address,
150
- devCUSD.interface.encodeFunctionData("mint", [root.address, ethers.utils.parseEther("2000000")]),
151
- release.Avatar,
152
- 0
153
- )
154
- ).wait();
155
-
156
- if ((await cusd.balanceOf(release.MentoReserve)).lt(ethers.utils.parseEther("200000"))) {
157
- await cusd.transfer(release.MentoReserve, ethers.utils.parseEther("200000"));
158
- }
159
- }
160
-
161
- const mpbImplementation = mpbDeployments["42220"].find(_ => _.name === "celo")["MessagePassingBridge_Implementation"]
162
- .address;
163
- const bridgeLocked = ["0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5", "0xD5D11eE582c8931F336fbcd135e98CEE4DB8CCB0"];
164
- const locked = [
165
- "0xD17652350Cfd2A37bA2f947C910987a3B1A1c60d",
166
- "0xeC577447D314cf1e443e9f4488216651450DBE7c",
167
- "0x6738fA889fF31F82d9Fe8862ec025dbE318f3Fde"
168
- ];
169
-
170
- const ethprovider = new ethers.providers.JsonRpcProvider("https://rpc.flashbots.net");
171
- const fuseprovider = new ethers.providers.JsonRpcProvider("https://rpc.fuse.io");
172
- const TOTAL_LOCKED = (
173
- await Promise.all(
174
- locked
175
- .concat(bridgeLocked)
176
- .map(_ => gd.connect(ethprovider).attach(dao["production-mainnet"].GoodDollar).balanceOf(_))
177
- )
178
- ).reduce((prev, cur) => prev.add(cur), ethers.constants.Zero);
179
- const TOTAL_SUPPLY_ETH = await gd.connect(ethprovider).attach(dao["production-mainnet"].GoodDollar).totalSupply();
180
- const TOTAL_SUPPLY_FUSE = await gd.connect(fuseprovider).attach(dao["production"].GoodDollar).totalSupply();
181
- const TOTAL_SUPPLY_CELO = await gd.totalSupply();
182
- const TOTAL_GLOBAL_SUPPLY = TOTAL_SUPPLY_ETH.add(TOTAL_SUPPLY_FUSE)
183
- .sub(TOTAL_LOCKED)
184
- .mul(ethers.BigNumber.from("10000000000000000")) //convert to 18 decimals
185
- .add(TOTAL_SUPPLY_CELO);
186
-
187
- const exchangeParams = [release.CUSD, release.GoodDollar, 0, 0, 0, 0]; //address reserveAsset;address tokenAddress;uint256 tokenSupply;uint256 reserveBalance;uint32 reserveRatio;uint32 exitConribution;
188
-
189
- console.log({
190
- networkEnv,
191
- mpbImplementation,
192
- guardian: guardian.address,
193
- isSimulation,
194
- isProduction,
195
- release,
196
- TOTAL_GLOBAL_SUPPLY
197
- });
198
-
199
- const mentoUpgrade = release.MentoUpgradeHelper
200
- ? ((await ethers.getContractAt("ProtocolUpgradeV4Mento", release.MentoUpgradeHelper)) as ProtocolUpgradeV4Mento)
201
- : await ethers.deployContract("ProtocolUpgradeV4Mento", [release.Avatar]);
202
- let distHelper = release.CeloDistributionHelper
203
- ? ((await ethers.getContractAt("CeloDistributionHelper", release.CeloDistributionHelper)) as CeloDistributionHelper)
204
- : ((await upgrades.deployProxy(
205
- await ethers.getContractFactory("CeloDistributionHelper"),
206
- [release.NameService, "0x00851A91a3c4E9a4c1B48df827Bacc1f884bdE28"], //static oracle for uniswap
207
- { initializer: "initialize" }
208
- )) as CeloDistributionHelper);
209
-
210
- release.MentoUpgradeHelper = mentoUpgrade.address;
211
- release.CeloDistributionHelper = distHelper.address;
212
- if (!isSimulation) {
213
- releaser(release, networkEnv);
214
- }
215
- console.log("deployed mentoUpgrade", {
216
- distribuitonHelper: distHelper.address,
217
- mentoUpgrade: mentoUpgrade.address,
218
- distHelperAvatar: await distHelper.avatar()
219
- });
220
-
221
- const proposalContracts = [
222
- release.CeloDistributionHelper, //set fee settings
223
- release.CeloDistributionHelper, //add ubi recipient
224
- release.CeloDistributionHelper, //add community treasury recipient
225
- release.MpbBridge, // upgrade
226
- release.MpbBridge && release.GoodDollarMintBurnWrapper, // remove minting rights from bridge
227
- release.GoodDollar, // set mento broker as minter
228
- release.GoodDollar, // set reserve expansion controller as minter
229
- release.Controller, // register upgrade contract
230
- mentoUpgrade.address // create the exchange + set expansion rate
231
- ];
232
-
233
- const proposalEthValues = proposalContracts.map(_ => 0);
234
-
235
- const proposalFunctionSignatures = [
236
- "setFeeSettings((uint128,uint128,uint8,uint8))",
237
- "addOrUpdateRecipient((uint32,uint32,address,uint8))",
238
- "addOrUpdateRecipient((uint32,uint32,address,uint8))",
239
- "upgradeTo(address)",
240
- "revokeRole(bytes32,address)", // mpb is now lock/unlock doesnt need minting
241
- "addMinter(address)",
242
- "addMinter(address)",
243
- "registerScheme(address,bytes32,bytes4,address)",
244
- "upgrade(address,(address,address,uint256,uint256,uint32,uint32),address,address,address,uint256)" //Controller _controller,PoolExchange memory _exchange,address _mentoExchange,address _mentoController, address _distHelper
245
- ];
246
-
247
- console.log("preparing inputs...");
248
- const proposalFunctionInputs = [
249
- //uint128 maxFee;uint128 minBalanceForFees;uint8 percentageToSellForFee;
250
- //2 celo max fee for lz bridge, min balance 2 celo, max percentage to sell 1%, max slippage 5%
251
- ethers.utils.defaultAbiCoder.encode(
252
- ["uint128", "uint128", "uint8", "uint8"],
253
- [ethers.utils.parseEther("2"), DIST_HELPER_MIN_CELO_BALANCE, "1", "5"]
254
- ),
255
- ethers.utils.defaultAbiCoder.encode(["uint32", "uint32", "address", "uint8"], [9000, 42220, release.UBIScheme, 1]), // ubi pool recipient
256
- ethers.utils.defaultAbiCoder.encode(
257
- ["uint32", "uint32", "address", "uint8"],
258
- [1000, 42220, release.CommunitySafe, 1]
259
- ), //community treasury recipient
260
- ethers.utils.defaultAbiCoder.encode(["address"], [mpbImplementation]),
261
- release.MpbBridge &&
262
- ethers.utils.defaultAbiCoder.encode(
263
- ["bytes32", "address"],
264
- [ethers.utils.keccak256(ethers.utils.toUtf8Bytes("MINTER_ROLE")), release.MpbBridge]
265
- ),
266
- ethers.utils.defaultAbiCoder.encode(["address"], [release.MentoBroker]),
267
- ethers.utils.defaultAbiCoder.encode(["address"], [release.MentoExpansionController]),
268
- ethers.utils.defaultAbiCoder.encode(
269
- ["address", "bytes32", "bytes4", "address"],
270
- [mentoUpgrade.address, ethers.constants.HashZero, "0x0000001f", release.Avatar]
271
- ),
272
- ethers.utils.defaultAbiCoder.encode(
273
- ["address", "(address,address,uint256,uint256,uint32,uint32)", "address", "address", "address", "uint256"],
274
- [
275
- release.Controller,
276
- exchangeParams,
277
- release.MentoExchangeProvider,
278
- release.MentoExpansionController,
279
- release.CeloDistributionHelper,
280
- TOTAL_GLOBAL_SUPPLY
281
- ]
282
- )
283
- ];
284
-
285
- console.log({ exchangeParams, mentoExchange: release.MentoExchangeProvider });
286
- console.log("executing upgrade...", { proposalContracts, proposalFunctionInputs, proposalFunctionSignatures });
287
-
288
- if (isProduction && !checksOnly) {
289
- await executeViaSafe(
290
- proposalContracts,
291
- proposalEthValues,
292
- proposalFunctionSignatures,
293
- proposalFunctionInputs,
294
- release.GuardiansSafe,
295
- "celo"
296
- );
297
- } else if (!checksOnly) {
298
- await executeViaGuardian(
299
- proposalContracts,
300
- proposalEthValues,
301
- proposalFunctionSignatures,
302
- proposalFunctionInputs,
303
- guardian,
304
- networkEnv
305
- );
306
- }
307
-
308
- if (isSimulation || !isProduction) {
309
- const swapper = networkEnv.includes("production")
310
- ? await ethers.getImpersonatedSigner("0x66582D24FEaD72555adaC681Cc621caCbB208324")
311
- : root;
312
- const supplyAfter = await (await ethers.getContractAt("IGoodDollar", release.GoodDollar)).totalSupply();
313
- console.log("Supply after upgrade:", { supplyAfter, TOTAL_GLOBAL_SUPPLY });
314
-
315
- const isBrokerMinter = await gd.isMinter(release.MentoBroker);
316
- const isExpansionMinter = await gd.isMinter(release.MentoExpansionController);
317
- const mentoExchange = await ethers.getContractAt("IBancorExchangeProvider", release.MentoExchangeProvider);
318
- const mentoBroker = (await ethers.getContractAt("IBroker", release.MentoBroker)) as IBroker;
319
- const eids = await mentoExchange.getExchangeIds();
320
- const exchange = await mentoExchange.getPoolExchange(eids[0]);
321
- const price = (await mentoExchange.currentPrice(eids[0])) / 1e18;
322
- console.log("current price:", price);
323
- console.log("Exchange:", exchange, eids[0]);
324
-
325
- console.log("Broker minter check:", isBrokerMinter ? "Success" : "Failed");
326
- console.log("Expansion minter check:", isExpansionMinter ? "Success" : "Failed");
327
-
328
- console.log("balance before swap:", await gd.balanceOf(swapper.address), await cusd.balanceOf(swapper.address));
329
- await cusd.connect(swapper).approve(release.MentoBroker, ethers.utils.parseEther("1000"));
330
- await mentoBroker
331
- .connect(swapper)
332
- .swapIn(mentoExchange.address, eids[0], cusd.address, gd.address, ethers.utils.parseEther("1000"), 0)
333
- .then(_ => _.wait());
334
- console.log(
335
- "Balance after swap:",
336
- swapper.address,
337
- await gd.balanceOf(swapper.address),
338
- await cusd.balanceOf(swapper.address)
339
- );
340
- const mentomint = (await ethers.getContractAt(
341
- "IGoodDollarExpansionController",
342
- release.MentoExpansionController
343
- )) as IGoodDollarExpansionController;
344
- await cusd.connect(swapper).approve(mentomint.address, ethers.utils.parseEther("1000"));
345
- const tx = await (
346
- await mentomint.connect(swapper).mintUBIFromInterest(eids[0], ethers.utils.parseEther("1000"))
347
- ).wait();
348
- console.log(
349
- "mint from interest:",
350
- tx.events.find(_ => _.event === "InterestUBIMinted").args.amount.toString() / 1e18
351
- );
352
- console.log("price after interest mint:", (await mentoExchange.currentPrice(eids[0])) / 1e18);
353
- const distTx = await (await distHelper.onDistribution(0, { gasLimit: 2000000 })).wait();
354
- const { distributionRecipients, distributed } = distTx.events.find(_ => _.event === "Distribution").args;
355
- console.log("Distribution events:", distributionRecipients, distributed, distTx.events.length);
356
- const bridgeBalance = await gd.balanceOf("0xa3247276DbCC76Dd7705273f766eB3E8a5ecF4a5");
357
- console.log("Brigde balance should equal other chains total supply:", {
358
- bridgeBalance,
359
- isEqual: bridgeBalance.eq(TOTAL_GLOBAL_SUPPLY.sub(TOTAL_SUPPLY_CELO))
360
- });
361
- }
362
- };
363
-
364
- const calculateReserveParams = async () => {
365
- const celoProvider = new ethers.providers.JsonRpcProvider("https://forno.celo.org");
366
- const gd = await ethers.getContractAt("GoodDollar", dao["production-celo"].GoodDollar);
367
- const celoCusd = (await ethers.getContractAt("IERC20", dao["production-celo"].CUSD)).connect(celoProvider);
368
- const gdCelo = gd.connect(celoProvider);
369
- const totalSupplyCelo = await gdCelo.totalSupply();
370
- const reserveBalance = await celoCusd.balanceOf(dao["production-celo"].MentoReserve);
371
- const xdcReserveBalance = ethers.utils.parseUnits("200000", 18); //200k in xdc
372
- const totalUSD = reserveBalance.add(xdcReserveBalance); //reserve + 200k in xdc
373
- const xdcSupplyShare = xdcReserveBalance.mul(1e8).div(totalUSD);
374
- const xdcGdSupplyEquivalent = totalSupplyCelo.mul(xdcSupplyShare).div(1e8);
375
- const price = ethers.utils.parseUnits("0.00013", 8);
376
- const celoGdSupplyEquivalent = totalSupplyCelo.sub(xdcGdSupplyEquivalent);
377
-
378
- console.log({
379
- totalSupplyCelo,
380
- reserveBalance,
381
- totalUSD,
382
- xdcSupplyShare,
383
- xdcGdSupplyEquivalent,
384
- celoGdSupplyEquivalent
385
- });
386
-
387
- // uint32 reserveRatio = uint32(
388
- // (cUSDBalance * 1e18 * 1e8) / (price * totalGlobalSupply)
389
- // );
390
- //calculate reserve ratio
391
- const reserveRatioXdc = xdcReserveBalance
392
- .mul(ethers.BigNumber.from("100000000")) //1e8
393
- .mul(ethers.BigNumber.from("1000000000000000000")) //1e18
394
- .div(xdcGdSupplyEquivalent.mul(price));
395
- console.log(
396
- "recommended reserve ratio for xdc:",
397
- reserveRatioXdc.toString(),
398
- reserveRatioXdc.div("10000000000").toNumber() / 1e8
399
- );
400
-
401
- //calcualte reserve ratio for celo
402
- const reserveRatioCelo = reserveBalance
403
- .mul(ethers.BigNumber.from("100000000")) //1e8
404
- .mul(ethers.BigNumber.from("1000000000000000000")) //1e18
405
- .div(celoGdSupplyEquivalent.mul(price));
406
-
407
- console.log(
408
- "recommended reserve ratio for celo:",
409
- reserveRatioCelo.toString(),
410
- reserveRatioCelo.div("10000000000").toNumber() / 1e8
411
- );
412
- };
413
-
414
- export const main = async () => {
415
- await calculateReserveParams();
416
- return;
417
- prompt.start();
418
- const { network } = await prompt.get(["network"]);
419
-
420
- console.log("running step:", { network });
421
- const chain = last(network.split("-"));
422
- switch (chain) {
423
- case "mainnet":
424
- // await upgradeMainnet(network, true);
425
-
426
- break;
427
- case "fuse":
428
- // await upgradeFuse(network);
429
-
430
- break;
431
- case "celo":
432
- await upgradeCelo(network, true);
433
-
434
- break;
435
- }
436
- };
437
-
438
- main().catch(console.log);