@stabilitydao/stability 0.59.2 → 0.61.2

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.
package/out/os.js DELETED
@@ -1,726 +0,0 @@
1
- "use strict";
2
- /**
3
- Stability OS MVP prototype.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.DAOAction = exports.OS = exports.UnitComponentCategory = exports.UnitStatus = exports.UnitType = exports.FundingType = exports.LifecyclePhase = exports.STABILITY_OS_DESCRIPTION = void 0;
7
- const chains_1 = require("./chains");
8
- exports.STABILITY_OS_DESCRIPTION = "Operating System of Self-developing DAOs";
9
- /**
10
- Lifecycle phase represents DAO tokenomics stage.
11
- */
12
- var LifecyclePhase;
13
- (function (LifecyclePhase) {
14
- /** Created */
15
- LifecyclePhase["DRAFT"] = "DRAFT";
16
- /**
17
- Initial funding. DAO project passed requirements.
18
- Since SEED started a DAO become real DAO:
19
- - noncustodial
20
- - tokenized share holdings
21
- - collective management via voting
22
- */
23
- LifecyclePhase["SEED"] = "SEED";
24
- /** Seed was not success. Raised funds sent back to seeders. */
25
- LifecyclePhase["SEED_FAILED"] = "SEED_FAILED";
26
- /** Using SEED funds to launch MVP / Unit generating */
27
- LifecyclePhase["DEVELOPMENT"] = "DEVELOPMENT";
28
- /** TGE is funding event for token liquidity and DAO developments (optionally) */
29
- LifecyclePhase["TGE"] = "TGE";
30
- /** Delay before any vesting allocation started */
31
- LifecyclePhase["LIVE_CLIFF"] = "LIVE_CLIFF";
32
- /** Vesting period active */
33
- LifecyclePhase["LIVE_VESTING"] = "LIVE_VESTING";
34
- /** Vesting ended - token fully distributed */
35
- LifecyclePhase["LIVE"] = "LIVE";
36
- })(LifecyclePhase || (exports.LifecyclePhase = LifecyclePhase = {}));
37
- var FundingType;
38
- (function (FundingType) {
39
- FundingType["SEED"] = "SEED";
40
- FundingType["TGE"] = "TGE";
41
- })(FundingType || (exports.FundingType = FundingType = {}));
42
- /** Supported unit types */
43
- var UnitType;
44
- (function (UnitType) {
45
- /** VE-token early exit fees */
46
- UnitType["PVP"] = "PVP";
47
- /** Decentralized finance protocol */
48
- UnitType["DEFI_PROTOCOL"] = "DEFI_PROTOCOL";
49
- /** Maximum Extractable Value opportunities searcher and submitter. */
50
- UnitType["MEV_SEARCHER"] = "MEV_SEARCHER";
51
- /** Software as a Service business */
52
- //SAAS = "SAAS",
53
- })(UnitType || (exports.UnitType = UnitType = {}));
54
- /** Unit status can be changed automatically on DAO lifecycle phase changes or manually by DAO holders */
55
- var UnitStatus;
56
- (function (UnitStatus) {
57
- UnitStatus["RESEARCH"] = "RESEARCH";
58
- UnitStatus["BUILDING"] = "BUILDING";
59
- UnitStatus["LIVE"] = "LIVE";
60
- })(UnitStatus || (exports.UnitStatus = UnitStatus = {}));
61
- /** Supported categories of running units. */
62
- var UnitComponentCategory;
63
- (function (UnitComponentCategory) {
64
- UnitComponentCategory["CHAIN_SUPPORT"] = "CHAIN_SUPPORT";
65
- UnitComponentCategory["ENGINE_SUPPORT"] = "ENGINE_SUPPORT";
66
- UnitComponentCategory["DEFI_STRATEGY"] = "DEFI_STRATEGY";
67
- UnitComponentCategory["MEV_STRATEGY"] = "MEV_STRATEGY";
68
- })(UnitComponentCategory || (exports.UnitComponentCategory = UnitComponentCategory = {}));
69
- /**
70
- Typescript implementation of Stability Operating System
71
- Object of this class is OS instance deployed on a single blockchain.
72
-
73
- @class
74
- */
75
- class OS {
76
- constructor(chainId) {
77
- /** Chain block timestamp */
78
- this.blockTimestamp = Math.floor(new Date().getTime() / 1000);
79
- /** Local DAOs storage (in form of a mapping) */
80
- this.daos = {};
81
- /** Actual DAO symbols at all blockchains */
82
- this.usedSymbols = {};
83
- /** All emitted events */
84
- this.events = [];
85
- /** Governance proposals. Can be created only at initialChain of DAO. */
86
- this.proposals = {};
87
- /** Current user address */
88
- this.from = "0x00";
89
- this.settings = {
90
- priceDao: 1000,
91
- priceUnit: 1000,
92
- priceOracle: 1000,
93
- priceBridge: 1000,
94
- minNameLength: 1,
95
- maxNameLength: 20,
96
- minSymbolLength: 1,
97
- maxSymbolLength: 7,
98
- minVePeriod: 14,
99
- maxVePeriod: 365 * 4,
100
- minPvPFee: 10,
101
- maxPvPFee: 100,
102
- minFundingDuration: 1,
103
- maxFundingDuration: 180,
104
- };
105
- this.chainId = chainId;
106
- }
107
- static getTokensNaming(name, symbol) {
108
- return {
109
- seedName: `${name} SEED`,
110
- seedSymbol: `seed${symbol}`,
111
- tgeName: `${name} PRESALE`,
112
- tgeSymbol: `sale${symbol}`,
113
- tokenName: name,
114
- tokenSymbol: symbol,
115
- xName: `x${name}`,
116
- xSymbol: `x${symbol}`,
117
- daoName: `${name} DAO`,
118
- daoSymbol: `${symbol}_DAO`,
119
- };
120
- }
121
- static isLiveDAO(phase) {
122
- return [
123
- LifecyclePhase.LIVE_CLIFF,
124
- LifecyclePhase.LIVE_VESTING,
125
- LifecyclePhase.LIVE,
126
- ].includes(phase);
127
- }
128
- /**
129
- * Create new DAO
130
- * @throws Error
131
- */
132
- createDAO(name, symbol, activity, params, funding) {
133
- const dao = {
134
- phase: LifecyclePhase.DRAFT,
135
- name,
136
- symbol,
137
- activity,
138
- socials: [],
139
- images: {},
140
- deployments: {},
141
- units: [],
142
- agents: [],
143
- params,
144
- tokenomics: {
145
- initialChain: chains_1.chains[this.chainId].name,
146
- funding,
147
- },
148
- deployer: this.from,
149
- };
150
- this.validate(dao);
151
- this.daos[dao.symbol] = dao;
152
- this.usedSymbols[dao.symbol] = true;
153
- this._emit("DAO created");
154
- this._sendCrossChainMessage(CROSS_CHAIN_MESSAGE.NEW_DAO_SYMBOL, {
155
- symbol,
156
- });
157
- return dao;
158
- }
159
- /** Add live compatible DAO */
160
- addLiveDAO(dao) {
161
- // todo _onlyVerifier
162
- this.validate(dao);
163
- this.daos[dao.symbol] = dao;
164
- this.usedSymbols[dao.symbol] = true;
165
- this._emit("DAO created");
166
- this._sendCrossChainMessage(CROSS_CHAIN_MESSAGE.NEW_DAO_SYMBOL, {
167
- symbol: dao.symbol,
168
- });
169
- }
170
- /** Change lifecycle phase of a DAO */
171
- changePhase(symbol) {
172
- // anybody can call this
173
- const dao = this.getDao(symbol);
174
- const currentTasks = this.tasks(symbol);
175
- if (currentTasks.length > 0) {
176
- throw new Error("SolveTasksFirst");
177
- }
178
- if (dao.phase === LifecyclePhase.DRAFT) {
179
- const seed = dao.tokenomics.funding[this.getFundingIndex(symbol, FundingType.SEED)];
180
- if (seed.start > this.blockTimestamp) {
181
- throw new Error("WaitFundingStart");
182
- }
183
- // SEED can be started not later than 1 week after must start
184
- // todo settings.maxSeedStartDelay
185
- if (seed.start < this.blockTimestamp &&
186
- this.blockTimestamp - seed.start > 7 * 86400) {
187
- throw new Error("TooLateSoSetupFundingAgain");
188
- }
189
- /*// SEED can be started not later than 1 week before end
190
- if (seed.end - this.blockTimestamp < 7 * 86400) {
191
- throw new Error("TooLateSoSetupFundingAgain")
192
- }*/
193
- // deploy seedToken
194
- this.daos[symbol].deployments[this.chainId] = {
195
- seedToken: "0xProxyDeployed",
196
- };
197
- this.daos[symbol].phase = LifecyclePhase.SEED;
198
- }
199
- else if (dao.phase === LifecyclePhase.SEED) {
200
- const seed = dao.tokenomics.funding[this.getFundingIndex(symbol, FundingType.SEED)];
201
- if (seed.end > this.blockTimestamp) {
202
- throw new Error("WaitFundingEnd");
203
- }
204
- const sucess = seed.raised >= seed.minRaise;
205
- if (sucess) {
206
- this.daos[symbol].phase = LifecyclePhase.DEVELOPMENT;
207
- }
208
- else {
209
- // send all raised back to seeders
210
- this.daos[symbol].phase = LifecyclePhase.SEED_FAILED;
211
- }
212
- }
213
- else if (dao.phase === LifecyclePhase.DEVELOPMENT) {
214
- const tge = dao.tokenomics.funding[this.getFundingIndex(symbol, FundingType.TGE)];
215
- if (tge.start > this.blockTimestamp) {
216
- throw new Error("WaitFundingStart");
217
- }
218
- // deploy tgeToken
219
- this.daos[symbol].deployments[this.chainId].tgeToken =
220
- "0xProxyDeployedTge";
221
- this.daos[symbol].phase = LifecyclePhase.TGE;
222
- }
223
- else if (dao.phase === LifecyclePhase.TGE) {
224
- const tge = dao.tokenomics.funding[this.getFundingIndex(symbol, FundingType.TGE)];
225
- if (tge.end > this.blockTimestamp) {
226
- throw new Error("WaitFundingEnd");
227
- }
228
- const success = tge.raised >= tge.minRaise;
229
- if (success) {
230
- // deploy token, xToken, staking, daoToken
231
- this.daos[symbol].deployments[this.chainId].token = "0xProxyToken";
232
- this.daos[symbol].deployments[this.chainId].xToken = "0xProxyXToken";
233
- this.daos[symbol].deployments[this.chainId].staking = "0xProxyStaking";
234
- this.daos[symbol].deployments[this.chainId].daoToken =
235
- "0xProxyDAOToken";
236
- // todo deploy vesting contracts and allocate token
237
- // todo seedToken holders became xToken holders by predefined rate
238
- // todo deploy v2 liquidity from TGE funds at predefined price
239
- this.daos[symbol].phase = LifecyclePhase.LIVE_CLIFF;
240
- }
241
- else {
242
- // send all raised TGE funds back to funders
243
- this.daos[symbol].phase = LifecyclePhase.DEVELOPMENT;
244
- }
245
- }
246
- else if (dao.phase === LifecyclePhase.LIVE_CLIFF) {
247
- // if any vesting started then phase changed
248
- const isVestingStarted = !!dao.tokenomics.vesting?.filter((v) => v.start < this.blockTimestamp).length;
249
- if (!isVestingStarted) {
250
- throw new Error("WaitVestingStart");
251
- }
252
- this.daos[symbol].phase = LifecyclePhase.LIVE_VESTING;
253
- }
254
- else if (dao.phase === LifecyclePhase.LIVE_VESTING) {
255
- // if any vesting started then phase changed
256
- const isVestingEnded = !dao.tokenomics.vesting?.filter((v) => v.end > this.blockTimestamp).length;
257
- if (!isVestingEnded) {
258
- throw new Error("WaitVestingEnd");
259
- }
260
- this.daos[symbol].phase = LifecyclePhase.LIVE;
261
- }
262
- }
263
- /** @throws Error */
264
- updateImages(symbol, images) {
265
- // check DAO symbol
266
- const dao = this.getDao(symbol);
267
- // instant execute for DRAFT
268
- if (dao.phase === LifecyclePhase.DRAFT) {
269
- this._onlyOwnerOf(symbol);
270
- this._updateImages(symbol, images);
271
- return true;
272
- }
273
- // create proposal for other phases
274
- return this._proposeAction(symbol, DAOAction.UPDATE_IMAGES, {
275
- images,
276
- });
277
- }
278
- _updateImages(symbol, images) {
279
- this.daos[symbol].images = images;
280
- this._emit(`Action ${DAOAction.UPDATE_IMAGES}`);
281
- }
282
- /** @throws Error */
283
- updateSocials(symbol, socials) {
284
- // check DAO symbol
285
- const dao = this.getDao(symbol);
286
- // instant execute for DRAFT
287
- if (dao.phase === LifecyclePhase.DRAFT) {
288
- this._onlyOwnerOf(symbol);
289
- this._updateSocials(symbol, socials);
290
- return true;
291
- }
292
- // create proposal for other phases
293
- return this._proposeAction(symbol, DAOAction.UPDATE_SOCIALS, {
294
- socials,
295
- });
296
- }
297
- _updateSocials(symbol, socials) {
298
- this.daos[symbol].socials = socials;
299
- this._emit(`Action ${DAOAction.UPDATE_SOCIALS}`);
300
- }
301
- /** @throws Error */
302
- updateUnits(symbol, units) {
303
- // check DAO symbol
304
- const dao = this.getDao(symbol);
305
- // instant execute for DRAFT
306
- if (dao.phase === LifecyclePhase.DRAFT) {
307
- this._onlyOwnerOf(symbol);
308
- this._updateUnits(symbol, units);
309
- return true;
310
- }
311
- // create proposal for other phases
312
- return this._proposeAction(symbol, DAOAction.UPDATE_UNITS, {
313
- units,
314
- });
315
- }
316
- _updateUnits(symbol, units) {
317
- this.daos[symbol].units = units;
318
- this._emit(`Action ${DAOAction.UPDATE_UNITS}`);
319
- }
320
- /** @throws Error */
321
- updateFunding(symbol, funding) {
322
- // check DAO symbol
323
- const dao = this.getDao(symbol);
324
- // validate payload
325
- this._validateFunding(dao.phase, [funding]);
326
- // instant execute for DRAFT
327
- if (dao.phase === LifecyclePhase.DRAFT) {
328
- this._onlyOwnerOf(symbol);
329
- this._updateFunding(symbol, funding);
330
- return true;
331
- }
332
- // create proposal for other phases
333
- return this._proposeAction(symbol, DAOAction.UPDATE_FUNDING, {
334
- funding,
335
- });
336
- }
337
- _updateFunding(symbol, funding) {
338
- const dao = this.getDao(symbol);
339
- const fundingExist = dao.tokenomics.funding.filter((f) => f.type === funding.type).length ===
340
- 1;
341
- if (fundingExist) {
342
- const fundingIndex = this.getFundingIndex(symbol, funding.type);
343
- this.daos[symbol].tokenomics.funding[fundingIndex] = funding;
344
- }
345
- else {
346
- this.daos[symbol].tokenomics.funding.push(funding);
347
- }
348
- this._emit(`Action ${DAOAction.UPDATE_FUNDING}`);
349
- }
350
- updateVesting(symbol, vestings) {
351
- // check DAO symbol
352
- const dao = this.getDao(symbol);
353
- // validate
354
- this._validateVesting(dao.phase, vestings);
355
- // instant execute for DRAFT
356
- if (dao.phase === LifecyclePhase.DRAFT) {
357
- this._onlyOwnerOf(symbol);
358
- this._updateVesting(symbol, vestings);
359
- return true;
360
- }
361
- // create proposal for other phases
362
- return this._proposeAction(symbol, DAOAction.UPDATE_VESTING, {
363
- vestings,
364
- });
365
- }
366
- _updateVesting(symbol, vestings) {
367
- this.daos[symbol].tokenomics.vesting = vestings;
368
- this._emit(`Action ${DAOAction.UPDATE_VESTING}`);
369
- }
370
- fund(symbol, amount) {
371
- // todo settings.minFunding
372
- const dao = this.getDao(symbol);
373
- if (dao.phase === LifecyclePhase.SEED) {
374
- const seedIndex = this.getFundingIndex(symbol, FundingType.SEED);
375
- const seed = dao.tokenomics.funding[seedIndex];
376
- if (seed.raised + amount >= seed.maxRaise) {
377
- throw new Error("RaiseMaxExceed");
378
- }
379
- // transfer amount of exchangeAsset to seedToken contract
380
- this.daos[symbol].tokenomics.funding[seedIndex].raised += amount;
381
- // mint seedToken to user
382
- return;
383
- }
384
- if (dao.phase === LifecyclePhase.TGE) {
385
- const tgeIndex = this.getFundingIndex(symbol, FundingType.TGE);
386
- const tge = dao.tokenomics.funding[tgeIndex];
387
- if (tge.raised + amount >= tge.maxRaise) {
388
- throw new Error("RaiseMaxExceed");
389
- }
390
- // transfer amount of exchangeAsset to tgeToken contract
391
- this.daos[symbol].tokenomics.funding[tgeIndex].raised += amount;
392
- // mint tgeToken to user
393
- return;
394
- }
395
- throw new Error("NotFundingPhase");
396
- }
397
- _proposeAction(symbol, action, payload) {
398
- const dao = this.getDao(symbol);
399
- // todo check for initial chain
400
- // todo get user power
401
- // todo check proposalThreshold
402
- // todo validate payload
403
- const proposalId = Math.round(Math.random() * Math.random()).toString();
404
- this.proposals[proposalId] = {
405
- id: proposalId,
406
- created: this.blockTimestamp,
407
- action,
408
- symbol,
409
- payload,
410
- status: VotingStatus.VOTING,
411
- };
412
- return proposalId;
413
- }
414
- receiveVotingResults(proposalId, succeed) {
415
- const proposal = this.proposals[proposalId];
416
- if (!proposal) {
417
- throw new Error("IncorrectProposal");
418
- }
419
- if (proposal.status !== VotingStatus.VOTING) {
420
- throw new Error("AlreadyReceived");
421
- }
422
- this.proposals[proposalId].status = succeed
423
- ? VotingStatus.APPROVED
424
- : VotingStatus.REJECTED;
425
- if (succeed) {
426
- if (proposal.action === DAOAction.UPDATE_IMAGES) {
427
- this._updateImages(proposal.symbol, proposal.payload.images);
428
- }
429
- if (proposal.action === DAOAction.UPDATE_SOCIALS) {
430
- this._updateSocials(proposal.symbol, proposal.payload.socials);
431
- }
432
- if (proposal.action === DAOAction.UPDATE_UNITS) {
433
- this._updateUnits(proposal.symbol, proposal.payload.units);
434
- }
435
- if (proposal.action === DAOAction.UPDATE_FUNDING) {
436
- this._updateFunding(proposal.symbol, proposal.payload.funding);
437
- }
438
- if (proposal.action === DAOAction.UPDATE_VESTING) {
439
- this._updateVesting(proposal.symbol, proposal.payload.vestings);
440
- }
441
- // todo other actions
442
- }
443
- }
444
- /** OFF-CHAIN only **/
445
- /** @throws Error */
446
- roadmap(symbol) {
447
- const dao = this.getDao(symbol);
448
- const r = [];
449
- let tgeRun = 0;
450
- for (const funding of dao.tokenomics.funding) {
451
- if (funding.type === FundingType.SEED) {
452
- r.push({
453
- phase: LifecyclePhase.SEED,
454
- start: funding.start,
455
- end: funding.end,
456
- });
457
- }
458
- if (funding.type === FundingType.TGE) {
459
- // if SEED was done
460
- if (r.length > 0) {
461
- r.push({
462
- phase: LifecyclePhase.DEVELOPMENT,
463
- start: r[0].end + 1,
464
- end: funding.start - 1,
465
- });
466
- }
467
- tgeRun = funding.claim || funding.end;
468
- r.push({
469
- phase: LifecyclePhase.TGE,
470
- start: funding.start,
471
- end: tgeRun,
472
- });
473
- }
474
- }
475
- if (dao.tokenomics.vesting) {
476
- let vestingStart = this.blockTimestamp;
477
- let vestingEnd = this.blockTimestamp;
478
- for (const vesting of dao.tokenomics.vesting) {
479
- if (vesting.start < vestingStart) {
480
- vestingStart = vesting.start;
481
- }
482
- if (vesting.end > vestingEnd) {
483
- vestingEnd = vesting.end;
484
- }
485
- }
486
- r.push({
487
- phase: LifecyclePhase.LIVE_CLIFF,
488
- start: tgeRun + 1,
489
- end: vestingStart - 1,
490
- });
491
- r.push({
492
- phase: LifecyclePhase.LIVE_VESTING,
493
- start: vestingStart,
494
- end: vestingEnd,
495
- });
496
- r.push({
497
- phase: LifecyclePhase.LIVE,
498
- start: vestingEnd + 1,
499
- });
500
- }
501
- return r;
502
- }
503
- /** @throws Error */
504
- tasks(symbol) {
505
- const dao = this.getDao(symbol);
506
- const r = [];
507
- if (dao.phase === LifecyclePhase.DRAFT) {
508
- // images
509
- if (!dao.images.seedToken || !dao.images.token) {
510
- r.push({
511
- name: "Need images of token and seedToken",
512
- });
513
- }
514
- // socials
515
- if (dao.socials.length < 2) {
516
- r.push({
517
- name: "Need at least 2 socials",
518
- });
519
- }
520
- // units projected
521
- if (dao.units.length === 0) {
522
- r.push({
523
- name: "Need at least 1 projected unit",
524
- });
525
- }
526
- }
527
- else if (dao.phase === LifecyclePhase.SEED) {
528
- const seedIndex = this.getFundingIndex(symbol, FundingType.SEED);
529
- if (dao.tokenomics.funding[seedIndex].raised <
530
- dao.tokenomics.funding[seedIndex].minRaise &&
531
- dao.tokenomics.funding[seedIndex].end > this.blockTimestamp) {
532
- r.push({
533
- name: "Need attract minimal seed funding",
534
- });
535
- }
536
- }
537
- else if (dao.phase === LifecyclePhase.DEVELOPMENT) {
538
- // check funding
539
- const tgeExist = dao.tokenomics.funding.filter((f) => f.type === FundingType.TGE)
540
- .length === 1;
541
- if (!tgeExist) {
542
- r.push({
543
- name: "Need add pre-TGE funding",
544
- });
545
- }
546
- // images
547
- if (!dao.images.tgeToken || !dao.images.xToken || !dao.images.daoToken) {
548
- r.push({
549
- name: "Need images of all DAO tokens",
550
- });
551
- }
552
- // setup vesting allocations
553
- if (!dao.tokenomics.vesting?.length) {
554
- r.push({
555
- name: "Need vesting allocations",
556
- });
557
- }
558
- if (dao.units.filter((u) => u.status === UnitStatus.LIVE).length === 0) {
559
- r.push({
560
- name: "Run revenue generating units",
561
- });
562
- }
563
- }
564
- else if (dao.phase === LifecyclePhase.TGE) {
565
- const tgeIndex = this.getFundingIndex(symbol, FundingType.TGE);
566
- if (dao.tokenomics.funding[tgeIndex].raised <
567
- dao.tokenomics.funding[tgeIndex].minRaise &&
568
- dao.tokenomics.funding[tgeIndex].end > this.blockTimestamp) {
569
- r.push({
570
- name: "Need attract minimal TGE funding",
571
- });
572
- }
573
- }
574
- else if (dao.phase === LifecyclePhase.LIVE_CLIFF) {
575
- // establish and improve
576
- // build money markets
577
- // bridge to chains
578
- }
579
- else if (dao.phase === LifecyclePhase.LIVE_VESTING) {
580
- // distribute vesting funds to leverage token
581
- }
582
- else if (dao.phase === LifecyclePhase.LIVE) {
583
- // lifetime revenue generating for DAO holders (till ABSORBED proposed feature)
584
- }
585
- return r;
586
- }
587
- /** Strict on-chain validation */
588
- /** @throws Error */
589
- validate(dao) {
590
- this._validateName(dao.name);
591
- this._validateSymbol(dao.symbol);
592
- if (dao.params.vePeriod < this.settings.minVePeriod ||
593
- dao.params.vePeriod > this.settings.maxVePeriod) {
594
- throw new Error(`VePeriod(${dao.params.vePeriod})`);
595
- }
596
- this._validatePvpFee(dao.params.pvpFee);
597
- if (!dao.tokenomics.funding.length) {
598
- throw new Error("NeedFunding");
599
- }
600
- // todo: check activity are correct
601
- // todo: check funding array has unique funding types
602
- // todo: check funding dates
603
- // todo: check funding raise goals
604
- }
605
- /** @throws Error */
606
- getDao(symbol) {
607
- if (this.daos[symbol]) {
608
- return this.daos[symbol];
609
- }
610
- throw new Error("DAONotFound");
611
- }
612
- getDaoOwner(symbol) {
613
- const dao = this.getDao(symbol);
614
- if (dao.phase === LifecyclePhase.DRAFT) {
615
- return dao.deployer;
616
- }
617
- if ([
618
- LifecyclePhase.SEED,
619
- LifecyclePhase.DEVELOPMENT,
620
- LifecyclePhase.TGE,
621
- ].includes(dao.phase)) {
622
- return dao.deployments[(0, chains_1.getChainByName)(dao.tokenomics.initialChain).chainId].seedToken;
623
- }
624
- return dao.deployments[this.chainId]?.daoToken;
625
- }
626
- getFundingIndex(symbol, type) {
627
- const dao = this.getDao(symbol);
628
- for (let i = 0; i < dao.tokenomics.funding.length; i++) {
629
- if (type === dao.tokenomics.funding[i].type) {
630
- return i;
631
- }
632
- }
633
- throw new Error("FundingNotFound");
634
- }
635
- warpDays(days = 7) {
636
- this.blockTimestamp += days * 86400;
637
- }
638
- /** @throws Error */
639
- _onlyOwnerOf(symbol) {
640
- if (this.from != this.getDaoOwner(symbol)) {
641
- throw new Error(`YouAreNotOwnerOf(${symbol})`);
642
- }
643
- }
644
- _emit(event) {
645
- this.events.push(event);
646
- }
647
- _validateName(name) {
648
- if (name.length < this.settings.minNameLength ||
649
- name.length > this.settings.maxNameLength) {
650
- throw new Error(`NameLength(${name.length})`);
651
- }
652
- }
653
- _validateSymbol(symbol) {
654
- if (symbol.length < this.settings.minSymbolLength ||
655
- symbol.length > this.settings.maxSymbolLength) {
656
- throw new Error(`SymbolLength(${symbol.length})`);
657
- }
658
- if (this.usedSymbols[symbol]) {
659
- throw new Error(`SymbolNotUnique(${symbol})`);
660
- }
661
- }
662
- _validatePvpFee(pvpFee) {
663
- if (pvpFee < this.settings.minPvPFee || pvpFee > this.settings.maxPvPFee) {
664
- throw new Error(`PvPFee(${pvpFee})`);
665
- }
666
- }
667
- _validateFunding(daoPhase, fundings) {
668
- for (const funding of fundings) {
669
- if (funding.type === FundingType.SEED &&
670
- daoPhase !== LifecyclePhase.DRAFT) {
671
- throw new Error("TooLateToUpdateSuchFunding");
672
- }
673
- if (funding.type === FundingType.TGE &&
674
- ![
675
- LifecyclePhase.DRAFT,
676
- LifecyclePhase.SEED,
677
- LifecyclePhase.DEVELOPMENT,
678
- ].includes(daoPhase)) {
679
- throw new Error("TooLateToUpdateSuchFunding");
680
- }
681
- // todo check min round duration
682
- // todo check max round duration
683
- // todo check start date delay
684
- // todo check min amount
685
- // todo check max amount
686
- }
687
- }
688
- _validateVesting(daoPhase, vestings) {
689
- if ([
690
- LifecyclePhase.LIVE_CLIFF,
691
- LifecyclePhase.LIVE_VESTING,
692
- LifecyclePhase.LIVE,
693
- ].includes(daoPhase)) {
694
- throw new Error("TooLateToUpdateVesting");
695
- }
696
- for (const vesting of vestings) {
697
- // todo check vesting consistency
698
- }
699
- }
700
- _sendCrossChainMessage(type, payload) {
701
- // todo some stub
702
- }
703
- }
704
- exports.OS = OS;
705
- var DAOAction;
706
- (function (DAOAction) {
707
- DAOAction[DAOAction["UPDATE_IMAGES"] = 0] = "UPDATE_IMAGES";
708
- DAOAction[DAOAction["UPDATE_SOCIALS"] = 1] = "UPDATE_SOCIALS";
709
- DAOAction[DAOAction["UPDATE_NAMING"] = 2] = "UPDATE_NAMING";
710
- DAOAction[DAOAction["UPDATE_UNITS"] = 3] = "UPDATE_UNITS";
711
- DAOAction[DAOAction["UPDATE_FUNDING"] = 4] = "UPDATE_FUNDING";
712
- DAOAction[DAOAction["UPDATE_VESTING"] = 5] = "UPDATE_VESTING";
713
- })(DAOAction || (exports.DAOAction = DAOAction = {}));
714
- var VotingStatus;
715
- (function (VotingStatus) {
716
- VotingStatus[VotingStatus["VOTING"] = 0] = "VOTING";
717
- VotingStatus[VotingStatus["APPROVED"] = 1] = "APPROVED";
718
- VotingStatus[VotingStatus["REJECTED"] = 2] = "REJECTED";
719
- })(VotingStatus || (VotingStatus = {}));
720
- var CROSS_CHAIN_MESSAGE;
721
- (function (CROSS_CHAIN_MESSAGE) {
722
- CROSS_CHAIN_MESSAGE[CROSS_CHAIN_MESSAGE["NEW_DAO_SYMBOL"] = 0] = "NEW_DAO_SYMBOL";
723
- CROSS_CHAIN_MESSAGE[CROSS_CHAIN_MESSAGE["DAO_RENAME_SYMBOL"] = 1] = "DAO_RENAME_SYMBOL";
724
- CROSS_CHAIN_MESSAGE[CROSS_CHAIN_MESSAGE["DAO_BRIDGED"] = 2] = "DAO_BRIDGED";
725
- })(CROSS_CHAIN_MESSAGE || (CROSS_CHAIN_MESSAGE = {}));
726
- //# sourceMappingURL=os.js.map