@gooddollar/goodprotocol 1.0.0 → 1.0.2-beta.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 (93) hide show
  1. package/artifacts/contracts/DAOStackInterfaces.sol/Avatar.dbg.json +1 -1
  2. package/artifacts/contracts/DAOStackInterfaces.sol/Controller.dbg.json +1 -1
  3. package/artifacts/contracts/DAOStackInterfaces.sol/GlobalConstraintInterface.dbg.json +1 -1
  4. package/artifacts/contracts/DAOStackInterfaces.sol/IntVoteInterface.dbg.json +1 -1
  5. package/artifacts/contracts/DAOStackInterfaces.sol/ReputationInterface.dbg.json +1 -1
  6. package/artifacts/contracts/DAOStackInterfaces.sol/SchemeRegistrar.dbg.json +1 -1
  7. package/artifacts/contracts/Interfaces.sol/AggregatorV3Interface.dbg.json +1 -1
  8. package/artifacts/contracts/Interfaces.sol/ERC20.dbg.json +1 -1
  9. package/artifacts/contracts/Interfaces.sol/IAaveIncentivesController.dbg.json +1 -1
  10. package/artifacts/contracts/Interfaces.sol/IAdminWallet.dbg.json +1 -1
  11. package/artifacts/contracts/Interfaces.sol/IDonationStaking.dbg.json +1 -1
  12. package/artifacts/contracts/Interfaces.sol/IERC2917.dbg.json +1 -1
  13. package/artifacts/contracts/Interfaces.sol/IFirstClaimPool.dbg.json +1 -1
  14. package/artifacts/contracts/Interfaces.sol/IGoodDollar.dbg.json +1 -1
  15. package/artifacts/contracts/Interfaces.sol/IGoodStaking.dbg.json +1 -1
  16. package/artifacts/contracts/Interfaces.sol/IHasRouter.dbg.json +1 -1
  17. package/artifacts/contracts/Interfaces.sol/IIdentity.dbg.json +1 -1
  18. package/artifacts/contracts/Interfaces.sol/ILendingPool.dbg.json +1 -1
  19. package/artifacts/contracts/Interfaces.sol/INameService.dbg.json +1 -1
  20. package/artifacts/contracts/Interfaces.sol/IUBIScheme.dbg.json +1 -1
  21. package/artifacts/contracts/Interfaces.sol/ProxyAdmin.dbg.json +1 -1
  22. package/artifacts/contracts/Interfaces.sol/Reserve.dbg.json +1 -1
  23. package/artifacts/contracts/Interfaces.sol/Staking.dbg.json +1 -1
  24. package/artifacts/contracts/Interfaces.sol/Uniswap.dbg.json +1 -1
  25. package/artifacts/contracts/Interfaces.sol/UniswapFactory.dbg.json +1 -1
  26. package/artifacts/contracts/Interfaces.sol/UniswapPair.dbg.json +1 -1
  27. package/artifacts/contracts/Interfaces.sol/cERC20.dbg.json +1 -1
  28. package/artifacts/contracts/governance/ClaimersDistribution.sol/ClaimersDistribution.dbg.json +1 -1
  29. package/artifacts/contracts/governance/CompoundVotingMachine.sol/CompoundVotingMachine.dbg.json +1 -1
  30. package/artifacts/contracts/governance/GReputation.sol/GReputation.dbg.json +1 -1
  31. package/artifacts/contracts/governance/GovarnanceStaking.sol/GovernanceStaking.dbg.json +1 -1
  32. package/artifacts/contracts/governance/MultiBaseGovernanceShareField.sol/MultiBaseGovernanceShareField.dbg.json +1 -1
  33. package/artifacts/contracts/governance/Reputation.sol/Reputation.dbg.json +1 -1
  34. package/artifacts/contracts/governance/StakersDistribution.sol/StakersDistribution.dbg.json +1 -1
  35. package/artifacts/contracts/mocks/AaveMock.sol/AaveMock.dbg.json +1 -1
  36. package/artifacts/contracts/mocks/DAIMock.sol/DAIMock.dbg.json +1 -1
  37. package/artifacts/contracts/mocks/DecimalsMock.sol/DecimalsMock.dbg.json +1 -1
  38. package/artifacts/contracts/mocks/GoodCompoundStakingTest.sol/GoodCompoundStakingTest.dbg.json +1 -1
  39. package/artifacts/contracts/mocks/GoodFundManagerTest.sol/GoodFundManagerTest.dbg.json +1 -1
  40. package/artifacts/contracts/mocks/IncentiveControllerMock.sol/IncentiveControllerMock.dbg.json +1 -1
  41. package/artifacts/contracts/mocks/LendingPoolMock.sol/LendingPoolMock.dbg.json +1 -1
  42. package/artifacts/contracts/mocks/OverMintTester.sol/OverMintTester.dbg.json +1 -1
  43. package/artifacts/contracts/mocks/OverMintTesterRegularStake.sol/OverMintTesterRegularStake.dbg.json +1 -1
  44. package/artifacts/contracts/mocks/SixteenDecimalsTokenMock.sol/SixteenDecimalsTokenMock.dbg.json +1 -1
  45. package/artifacts/contracts/mocks/SwapHelperTest.sol/SwapHelperTest.dbg.json +1 -1
  46. package/artifacts/contracts/mocks/TwentyDecimalsTokenMock.sol/TwentyDecimalsTokenMock.dbg.json +1 -1
  47. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock.dbg.json +1 -1
  48. package/artifacts/contracts/mocks/UpgradableMocks.sol/UpgradableMock2.dbg.json +1 -1
  49. package/artifacts/contracts/mocks/UsdcMock.sol/USDCMock.dbg.json +1 -1
  50. package/artifacts/contracts/mocks/cBATMock.sol/cBATMock.dbg.json +1 -1
  51. package/artifacts/contracts/mocks/cDAILowWorthMock.sol/cDAILowWorthMock.dbg.json +1 -1
  52. package/artifacts/contracts/mocks/cDAIMock.sol/cDAIMock.dbg.json +1 -1
  53. package/artifacts/contracts/mocks/cDAINonMintableMock.sol/cDAINonMintableMock.dbg.json +1 -1
  54. package/artifacts/contracts/mocks/cDecimalsMock.sol/cDecimalsMock.dbg.json +1 -1
  55. package/artifacts/contracts/mocks/cSDTMock.sol/cSDTMock.dbg.json +1 -1
  56. package/artifacts/contracts/mocks/cUSDCMock.sol/cUSDCMock.dbg.json +1 -1
  57. package/artifacts/contracts/reserve/ExchangeHelper.sol/ExchangeHelper.dbg.json +1 -1
  58. package/artifacts/contracts/reserve/GoodMarketMaker.sol/GoodMarketMaker.dbg.json +1 -1
  59. package/artifacts/contracts/reserve/GoodReserveCDai.sol/ContributionCalc.dbg.json +1 -1
  60. package/artifacts/contracts/reserve/GoodReserveCDai.sol/GoodReserveCDai.dbg.json +1 -1
  61. package/artifacts/contracts/staking/BaseShareField.sol/BaseShareField.dbg.json +1 -1
  62. package/artifacts/contracts/staking/DonationsStaking.sol/DonationsStaking.dbg.json +1 -1
  63. package/artifacts/contracts/staking/GoodFundManager.sol/GoodFundManager.dbg.json +1 -1
  64. package/artifacts/contracts/staking/SimpleStaking.sol/SimpleStaking.dbg.json +1 -1
  65. package/artifacts/contracts/staking/UniswapV2SwapHelper.sol/UniswapV2SwapHelper.dbg.json +1 -1
  66. package/artifacts/contracts/staking/aave/AaveStakingFactory.sol/AaveStakingFactory.dbg.json +1 -1
  67. package/artifacts/contracts/staking/aave/GoodAaveStaking.sol/GoodAaveStaking.dbg.json +1 -1
  68. package/artifacts/contracts/staking/compound/CompoundStakingFactory.sol/CompoundStakingFactory.dbg.json +1 -1
  69. package/artifacts/contracts/staking/compound/GoodCompoundStaking.sol/GoodCompoundStaking.dbg.json +1 -1
  70. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.dbg.json +1 -1
  71. package/artifacts/contracts/ubi/UBIScheme.sol/UBIScheme.json +2 -2
  72. package/artifacts/contracts/unaudited-foundation/FuseFaucet.sol/FuseFaucet.dbg.json +1 -1
  73. package/artifacts/contracts/unaudited-foundation/InvitesV1.sol/InvitesV1.dbg.json +1 -1
  74. package/artifacts/contracts/utils/BancorFormula.sol/BancorFormula.dbg.json +1 -1
  75. package/artifacts/contracts/utils/DAOContract.sol/DAOContract.dbg.json +1 -1
  76. package/artifacts/contracts/utils/DAOUpgradeableContract.sol/DAOUpgradeableContract.dbg.json +1 -1
  77. package/artifacts/contracts/utils/DSMath.sol/DSMath.dbg.json +1 -1
  78. package/artifacts/contracts/utils/DataTypes.sol/DataTypes.dbg.json +1 -1
  79. package/artifacts/contracts/utils/NameService.sol/NameService.dbg.json +1 -1
  80. package/artifacts/contracts/utils/ProtocolUpgrade.sol/OldMarketMaker.dbg.json +1 -1
  81. package/artifacts/contracts/utils/ProtocolUpgrade.sol/ProtocolUpgrade.dbg.json +1 -1
  82. package/artifacts/contracts/utils/ProtocolUpgradeFuse.sol/ProtocolUpgradeFuse.dbg.json +1 -1
  83. package/artifacts/contracts/utils/ReputationTestHelper.sol/ReputationTestHelper.dbg.json +1 -1
  84. package/contracts/.DS_Store +0 -0
  85. package/contracts/ubi/UBIScheme.sol +4 -6
  86. package/hardhat.config.ts +7 -0
  87. package/package.json +2 -2
  88. package/releases/olddao.json +411 -1
  89. package/scripts/proofs/testStorageProof.ts +33 -0
  90. package/scripts/ubi/fish.ts +109 -0
  91. package/test/.DS_Store +0 -0
  92. package/test/ubi/UBISchemeCycle.test.ts +20 -59
  93. package/truffle-config.js +21 -3
@@ -23,14 +23,8 @@ describe("UBIScheme cycle", () => {
23
23
  ubiScheme: UBIScheme;
24
24
 
25
25
  before(async () => {
26
- [
27
- root,
28
- acct,
29
- claimer1,
30
- claimer2,
31
- claimer3,
32
- ...signers
33
- ] = await ethers.getSigners();
26
+ [root, acct, claimer1, claimer2, claimer3, ...signers] =
27
+ await ethers.getSigners();
34
28
 
35
29
  const deployedDAO = await createDAO();
36
30
  let {
@@ -149,7 +143,7 @@ describe("UBIScheme cycle", () => {
149
143
  expect(cycleEvent.args.dailyUBIPool).to.be.equal(117187); //pool balance: (1000000 - 62500 given to first claimer) divided by 8 days - only first claimer got 62500 in first cycle
150
144
  });
151
145
 
152
- it("should calculate cycle early if (currentBalance > 1.3 * openBalance[prevDay]) and currentBalance > 80% of current cycle starting balance", async () => {
146
+ it("should calculate cycle early if we can increase current daily pool", async () => {
153
147
  //increase ubi pool balance
154
148
  let encoded = goodDollar.interface.encodeFunctionData("mint", [
155
149
  ubiScheme.address,
@@ -158,73 +152,40 @@ describe("UBIScheme cycle", () => {
158
152
  await genericCall(goodDollar.address, encoded);
159
153
  let balance = await goodDollar.balanceOf(ubiScheme.address);
160
154
 
155
+ const cycleLength = await ubiScheme.cycleLength();
156
+ const curDailyPool = await ubiScheme.dailyCyclePool();
157
+ console.log({ balance, cycleLength, curDailyPool });
158
+
159
+ //verify new daily pool IS gonna be larger than current
160
+ expect(balance.div(cycleLength)).to.be.gt(curDailyPool);
161
+
161
162
  await increaseTime(ONE_DAY); //make sure
162
163
  let transaction = await (await ubiScheme.connect(claimer1).claim()).wait();
163
- let cycleLength = await ubiScheme.cycleLength();
164
- let currentCycle = await ubiScheme.currentCycleLength();
164
+
165
165
  const cycleEvent = transaction.events.find(
166
166
  e => e.event === "UBICycleCalculated"
167
167
  );
168
+
169
+ expect(cycleEvent).to.be.not.empty;
168
170
  expect(cycleEvent.args.day.toNumber()).to.be.a("number");
169
171
  expect(cycleEvent.args.pool).to.be.equal(balance);
170
172
  expect(cycleEvent.args.cycleLength).to.be.equal(cycleLength);
171
173
  expect(cycleEvent.args.dailyUBIPool).to.be.equal(balance.div(cycleLength));
172
174
  });
173
175
 
174
- it("should not calculate cycle early if only currentBalance > 80% of current cycle starting balanc", async () => {
175
- //increase ubi pool balance
176
- let encoded = goodDollar.interface.encodeFunctionData("mint", [
177
- ubiScheme.address,
178
- 100000
179
- ]);
180
- await genericCall(goodDollar.address, encoded);
181
- let balance = await goodDollar.balanceOf(ubiScheme.address);
182
- const curCycleLen = await ubiScheme.currentCycleLength();
183
- const curDailyUbi = await ubiScheme.dailyUbi();
184
- const cycleStartingBalance = curCycleLen.mul(curDailyUbi);
185
-
186
- //pass one condition
187
- expect(balance).to.be.gt(cycleStartingBalance.mul(80).div(100));
188
-
189
- //dont pass other condition
190
- const curCycle = await ubiScheme.dailyUBIHistory(
191
- await ubiScheme.currentDay()
192
- );
193
- expect(balance).to.be.lt(curCycle.openAmount.mul(130).div(100));
194
-
195
- await increaseTime(ONE_DAY); //make sure
196
- let transaction = await (await ubiScheme.connect(claimer1).claim()).wait();
197
- const cycleEvent = transaction.events.find(
198
- e => e.event === "UBICycleCalculated"
199
- );
200
- expect(cycleEvent).to.be.undefined;
201
- });
202
-
203
- it("should not calculate cycle early if only currentBalance > 1.3 * openBalance[prevDay])", async () => {
204
- for (let i = 0; i < 13; i++) {
205
- await increaseTime(ONE_DAY); //make sure
206
- await ubiScheme.connect(claimer1).claim();
207
- await ubiScheme.connect(claimer2).claim();
208
- }
176
+ it("should not calculate cycle early if not possible to increase daily ubi pool", async () => {
209
177
  //increase ubi pool balance
210
178
  let encoded = goodDollar.interface.encodeFunctionData("mint", [
211
179
  ubiScheme.address,
212
- 55000
180
+ 1000
213
181
  ]);
214
182
  await genericCall(goodDollar.address, encoded);
215
183
  let balance = await goodDollar.balanceOf(ubiScheme.address);
216
- const curCycle = await ubiScheme.dailyUBIHistory(
217
- await ubiScheme.currentDay()
218
- );
219
-
220
- //verify we pass 1 condition for early cycle
221
- expect(balance).to.be.gt(curCycle.openAmount.mul(130).div(100));
222
-
223
- //dont pass second condition
224
- const curCycleLen = await ubiScheme.currentCycleLength();
225
- const curDailyUbi = await ubiScheme.dailyUbi();
226
- const cycleStartingBalance = curCycleLen.mul(curDailyUbi);
227
- expect(balance).to.be.lt(cycleStartingBalance.mul(80).div(100));
184
+ const curCycleLen = await ubiScheme.cycleLength();
185
+ const curDailyPool = await ubiScheme.dailyCyclePool();
186
+ console.log({ balance, curCycleLen, curDailyPool });
187
+ //verify new daily pool is not gonna be larger than current
188
+ expect(balance.div(curCycleLen)).to.be.lt(curDailyPool);
228
189
 
229
190
  await increaseTime(ONE_DAY); //make sure
230
191
  let transaction = await (await ubiScheme.connect(claimer1).claim()).wait();
package/truffle-config.js CHANGED
@@ -69,7 +69,25 @@ module.exports = {
69
69
  confirmations: 2, // # of confs to wait between deployments. (default: 0)
70
70
  timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
71
71
  skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
72
+ },
73
+ fuse: {
74
+ provider: () => new HDWalletProvider(mnemonic, `https://rpc.fuse.io`),
75
+ network_id: 122, // Ropsten's id
76
+ gas: 8000000, // Ropsten has a lower block limit than mainnet
77
+ confirmations: 1, // # of confs to wait between deployments. (default: 0)
78
+ timeoutBlocks: 20, // # of blocks before a deployment times out (minimum/default: 50)
79
+ skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
80
+ },
81
+ fusespark: {
82
+ provider: () =>
83
+ new HDWalletProvider(mnemonic, `https://rpc.fusespark.io`),
84
+ network_id: 123, // Ropsten's id
85
+ gas: 8000000, // Ropsten has a lower block limit than mainnet
86
+ confirmations: 1, // # of confs to wait between deployments. (default: 0)
87
+ timeoutBlocks: 20, // # of blocks before a deployment times out (minimum/default: 50)
88
+ skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
72
89
  }
90
+
73
91
  // Useful for private networks
74
92
  // private: {
75
93
  // provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
@@ -86,12 +104,12 @@ module.exports = {
86
104
  // Configure your compilers
87
105
  compilers: {
88
106
  solc: {
89
- version: "0.8.3", // Fetch exact version from solc-bin (default: truffle's version)
107
+ version: "0.8.8", // Fetch exact version from solc-bin (default: truffle's version)
90
108
  settings: {
91
109
  // See the solidity docs for advice about optimization and evmVersion
92
110
  optimizer: {
93
111
  enabled: true,
94
- runs: 200
112
+ runs: 0
95
113
  }
96
114
  }
97
115
  }
@@ -109,5 +127,5 @@ module.exports = {
109
127
  api_keys: {
110
128
  etherscan: process.env.ETHERSCAN_KEY
111
129
  },
112
- plugins: ["truffle-plugin-verify"]
130
+ plugins: ["truffle-source-verify"]
113
131
  };