@zemyth/raise-sdk 0.1.1 → 0.1.3

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 (47) hide show
  1. package/README.md +11 -9
  2. package/dist/accounts/index.cjs +531 -3
  3. package/dist/accounts/index.cjs.map +1 -1
  4. package/dist/accounts/index.d.cts +307 -2
  5. package/dist/accounts/index.d.ts +307 -2
  6. package/dist/accounts/index.js +503 -4
  7. package/dist/accounts/index.js.map +1 -1
  8. package/dist/constants/index.cjs +41 -3
  9. package/dist/constants/index.cjs.map +1 -1
  10. package/dist/constants/index.d.cts +38 -3
  11. package/dist/constants/index.d.ts +38 -3
  12. package/dist/constants/index.js +40 -4
  13. package/dist/constants/index.js.map +1 -1
  14. package/dist/index.cjs +2297 -361
  15. package/dist/index.cjs.map +1 -1
  16. package/dist/index.d.cts +566 -7
  17. package/dist/index.d.ts +566 -7
  18. package/dist/index.js +2279 -379
  19. package/dist/index.js.map +1 -1
  20. package/dist/instructions/index.cjs +783 -40
  21. package/dist/instructions/index.cjs.map +1 -1
  22. package/dist/instructions/index.d.cts +492 -6
  23. package/dist/instructions/index.d.ts +492 -6
  24. package/dist/instructions/index.js +762 -42
  25. package/dist/instructions/index.js.map +1 -1
  26. package/dist/pdas/index.cjs +163 -1
  27. package/dist/pdas/index.cjs.map +1 -1
  28. package/dist/pdas/index.d.cts +131 -1
  29. package/dist/pdas/index.d.ts +131 -1
  30. package/dist/pdas/index.js +151 -2
  31. package/dist/pdas/index.js.map +1 -1
  32. package/dist/types/index.cjs +9 -0
  33. package/dist/types/index.cjs.map +1 -1
  34. package/dist/types/index.d.cts +586 -3
  35. package/dist/types/index.d.ts +586 -3
  36. package/dist/types/index.js +9 -1
  37. package/dist/types/index.js.map +1 -1
  38. package/package.json +5 -3
  39. package/src/__tests__/dynamic-tokenomics.test.ts +358 -0
  40. package/src/accounts/index.ts +852 -1
  41. package/src/client.ts +1130 -1
  42. package/src/constants/index.ts +48 -2
  43. package/src/index.ts +58 -0
  44. package/src/instructions/index.ts +1383 -40
  45. package/src/pdas/index.ts +346 -0
  46. package/src/types/index.ts +698 -2
  47. package/src/utils/index.ts +90 -0
@@ -275,3 +275,93 @@ export function shortenPublicKey(pubkey: PublicKey | string, chars: number = 4):
275
275
  if (str.length <= chars * 2 + 3) return str;
276
276
  return `${str.slice(0, chars)}...${str.slice(-chars)}`;
277
277
  }
278
+
279
+ // =============================================================================
280
+ // Preserve Pivot Vesting Rights Utilities
281
+ // =============================================================================
282
+
283
+ /**
284
+ * Check if an investor can claim vesting for a specific milestone
285
+ * Investors who refunded have their vesting frozen at a specific milestone index.
286
+ * They can only claim vesting from milestones at or before that index.
287
+ *
288
+ * @param vestingFrozenAtMilestone - The milestone index at which vesting was frozen (null if not frozen)
289
+ * @param milestoneIndex - The milestone index to check
290
+ * @returns True if investor can claim vesting for this milestone
291
+ */
292
+ export function canClaimVestingForMilestone(
293
+ vestingFrozenAtMilestone: number | null,
294
+ milestoneIndex: number
295
+ ): boolean {
296
+ // If vesting is not frozen, investor can claim from any milestone
297
+ if (vestingFrozenAtMilestone === null) {
298
+ return true;
299
+ }
300
+ // If vesting is frozen, investor can only claim from milestones at or before the freeze point
301
+ return milestoneIndex <= vestingFrozenAtMilestone;
302
+ }
303
+
304
+ /**
305
+ * Check if an investment is refunded (any type of refund)
306
+ *
307
+ * @param investment - Investment account
308
+ * @returns True if investment is refunded
309
+ */
310
+ export function isInvestmentRefunded(investment: {
311
+ withdrawnFromPivot?: boolean;
312
+ refundClaimed?: boolean;
313
+ refundedFromAbandon?: boolean;
314
+ refundedFromExitWindow?: boolean;
315
+ refundedFromShutdown?: boolean;
316
+ vestingFrozenAtMilestone?: number | null;
317
+ }): boolean {
318
+ return (
319
+ investment.withdrawnFromPivot ||
320
+ investment.refundClaimed ||
321
+ investment.refundedFromAbandon ||
322
+ investment.refundedFromExitWindow ||
323
+ investment.refundedFromShutdown ||
324
+ investment.vestingFrozenAtMilestone !== null
325
+ );
326
+ }
327
+
328
+ /**
329
+ * Check if a project has available investment slots due to refunds
330
+ * Slots become available when investors refund, allowing succession.
331
+ *
332
+ * @param tiers - Array of tier objects with filledLots and maxLots
333
+ * @param tierCount - Number of active tiers
334
+ * @returns True if any tier has available slots
335
+ */
336
+ export function hasAvailableSlots(
337
+ tiers: Array<{ filledLots: number; maxLots: number }>,
338
+ tierCount: number
339
+ ): boolean {
340
+ const activeTiers = tiers.slice(0, tierCount);
341
+ return activeTiers.some((tier) => tier.filledLots < tier.maxLots);
342
+ }
343
+
344
+ /**
345
+ * Get available slots count for a specific tier
346
+ *
347
+ * @param tier - Tier object with filledLots and maxLots
348
+ * @returns Number of available slots
349
+ */
350
+ export function getAvailableSlotsForTier(tier: { filledLots: number; maxLots: number }): number {
351
+ return Math.max(0, tier.maxLots - tier.filledLots);
352
+ }
353
+
354
+ /**
355
+ * Get total available slots across all tiers
356
+ *
357
+ * @param tiers - Array of tier objects with filledLots and maxLots
358
+ * @param tierCount - Number of active tiers
359
+ * @returns Total number of available slots
360
+ */
361
+ export function getTotalAvailableSlots(
362
+ tiers: Array<{ filledLots: number; maxLots: number }>,
363
+ tierCount: number
364
+ ): number {
365
+ const activeTiers = tiers.slice(0, tierCount);
366
+ return activeTiers.reduce((total, tier) => total + getAvailableSlotsForTier(tier), 0);
367
+ }