Skip to content

feat(creator,keys): add graduated curve configuration endpoint - #890

Closed
TS-mfon wants to merge 1 commit into
accesslayerorg:mainfrom
TS-mfon:fix/issue-869-graduated-curve
Closed

TS-mfon wants to merge 1 commit into
accesslayerorg:mainfrom
TS-mfon:fix/issue-869-graduated-curve

Conversation

@TS-mfon

@TS-mfon TS-mfon commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements the graduated bonding curve configuration endpoints, allowing creator key owners to customize milestone tiers and curve exponents as supply grows, and allows public inspection of configured parameters.

Closes #869


Implementation Details

  • Endpoints:
    • POST /api/v1/creator/:keyId/curve: Creator-only endpoint to configure tiered supply milestones and exponents.
    • GET /api/v1/keys/:keyId/curve-config: Public endpoint to query active curve milestones and base exponent.
  • Validation:
    • Requires caller to be the key creator (requireKeyCreator('keyId')).
    • Maximum of 5 milestones allowed.
    • supplyThreshold must be positive and in strictly ascending order.
    • exponent must be an integer between 1 and 5 (enforcing Number.isInteger).
  • Contract Gateway & Audit:
    • Dispatches contract call through curveGateway.configureGraduatedCurve.
    • Persists milestones in CreatorProfile.curveMilestones.
    • Records GRADUATED_CURVE_CONFIGURED in Activity ledger.
  • Database Migration:
    • Added migration SQL in prisma/migrations/20260924_add_graduated_curve/migration.sql for existing database deployments.

Testing

  • Unit test suite added in src/modules/creator/__tests__/creator-curve.test.ts verifying:
    • 401 on unauthenticated calls.
    • 403 on non-creator JWT calls.
    • 422 on > 5 milestones, non-ascending thresholds, out-of-range exponents, or fractional exponents (e.g. 1.5).
    • 200 on valid inputs with contract dispatch and activity logging.
    • 404 on missing key for config query.
    • Public read of milestones and base exponent.
  • All 8 unit tests pass; TypeScript build passes cleanly.

…hema migration

Closes accesslayerorg#869

- Add POST /api/v1/creator/:keyId/curve with strict validation (1-5 milestones, ascending order, integer exponents 1-5)
- Invoke curveGateway.configureGraduatedCurve before persistence
- Add GET /api/v1/keys/:keyId/curve-config
- Add schema migration for curve_milestones, base_exponent, and GRADUATED_CURVE_CONFIGURED
- Log activity event on successful configuration
Copilot AI lite review requested due to automatic review settings September 24, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Critical migration and contract-dispatch issues, plus validation and consistency concerns, block approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Lite
Findings: 2 High severity · 1 Medium severity

Open (3)
What changed in this PR

Adds creator-only graduated curve configuration and public curve-config inspection endpoints.

Changes:

  • Adds milestone and exponent validation.
  • Persists configurations and records activity events.
  • Updates Prisma schema, migration, and tests.
File Description
src/​modules/​keys/​keys.routes.ts Public curve configuration endpoint
src/​modules/​creator/​creator.routes.ts Creator configuration endpoint and validation
src/​modules/​creator/​creator-curve.service.ts Curve gateway abstraction
src/​modules/​creator/​__tests__/​creator-curve.test.ts Endpoint tests
prisma/​schema/​creator.prisma Curve configuration fields
prisma/​schema/​activity.prisma Activity event type
prisma/​migrations/​20260924_add_graduated_curve/​migration.sql Database migration

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +1 to +6
-- AlterEnum
ALTER TYPE "ActivityType" ADD VALUE IF NOT EXISTS 'GRADUATED_CURVE_CONFIGURED';

-- AlterTable
ALTER TABLE "CreatorProfile" ADD COLUMN IF NOT EXISTS "curve_milestones" JSONB,
ADD COLUMN IF NOT EXISTS "base_exponent" INTEGER NOT NULL DEFAULT 1;
},
'Submitting configure_graduated_curve contract call'
);
return { transactionHash: undefined };
Comment on lines +145 to +148
typeof m.supplyThreshold !== 'number' ||
typeof m.exponent !== 'number' ||
isNaN(m.supplyThreshold) ||
isNaN(m.exponent)
@TS-mfon

TS-mfon commented Oct 1, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by #1007, which carries all four issues (#866, #869, #870, #872) on one branch rebased on latest main.

Splitting these four across separate PRs meant they collided with each other: all four touch src/modules/keys/keys.routes.ts, and #869/#872 both touch src/modules/creator/creator.routes.ts and the prisma schema, so whichever merged first would break the rest. #1007 also addresses the Copilot findings raised here — the migration moved to prisma/schema/migrations and non-finite milestone values are now rejected.

Closing this one in favour of #1007.

@TS-mfon TS-mfon closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a graduated curve configuration endpoint for creators to set supply milestone exponents

2 participants