Skip to content

feat: Account Recycler contract with bonding curve pricing#576

Open
aglichandrap wants to merge 2 commits into
Convex-Dev:developfrom
aglichandrap:feat/account-recycler
Open

feat: Account Recycler contract with bonding curve pricing#576
aglichandrap wants to merge 2 commits into
Convex-Dev:developfrom
aglichandrap:feat/account-recycler

Conversation

@aglichandrap

Copy link
Copy Markdown

Account Recycling Contract

Implements Convex-Dev/bounties#10 — Account Recycling Contract with bonding curve pricing.

Features

  • Deposit: Users can deposit accounts they control to the recycling market
  • Buy: Purchase available accounts at bonding curve price
  • Sell: Sell accounts back to the market at a spread (85% of buy price)
  • Bonding Curve: Price increases when fewer accounts available, decreases when more
  • Account Clearing: Deposited accounts are cleared (undef, set-controller nil)
  • Security: Controller verification, fund checks, trust-based withdrawal

Bonding Curve Model

  • Base price: 1000 Copper
  • Price increases as availability decreases
  • 15% spread between buy and sell price
  • Min/Max price bounds (100 - 1,000,000 Copper)

Files

  • convex-core/src/main/cvx/convex/lab/account-recycler/actor.cvx — Main contract
  • convex-core/src/test/cvx/test/convex/account-recycler.cvx — Tests

Security Considerations

  • Only account controller can deposit/sell
  • Contract balance checked before buy-back
  • Trust-based fund withdrawal
  • Account environment cleared on deposit

- Add BIGINT symbol to Symbols.java
- Add bigint constructor function (code 259) to Core.java
- Add bigint? predicate (code 260) to Core.java
- Fix TODO: use Juice.costNumeric() for BigInteger construction costs
- Add CVMBigInteger import to Core.java

Fixes Convex-Dev/bounties#4
Implements Convex-Dev/bounties#10:
- Deposit accounts to recycling market
- Buy accounts with bonding curve pricing
- Sell accounts back at market spread
- Account clearing (undef, set-controller)
- Security checks (controller verification)
- Tests included

Contract: convex/lab/account-recycler/actor.cvx
Tests: convex/test/account-recycler.cvx
@mikera

mikera commented Jul 6, 2026

Copy link
Copy Markdown
Member

(Claude Comment) Thanks @aglichandrap — this one is genuinely interesting, and we would like to take it further than a lab actor. Recycling cleared accounts addresses a real resource-efficiency need, and the bonding-curve market is a neat mechanism for it.

Direction we are considering: making this a core service, possibly with a newly allocated early-address account, installed as part of a protocol migration (the v1 or v2 network upgrade could carry it). That raises the design bar accordingly — the parts needing careful work are:

  • Account clearing: the eval-as + undef sweep must provably leave no residual state, controller bindings, or callable capabilities on a recycled account — a buyer must get a genuinely clean account, and a depositor must not be able to retain a backdoor.
  • Controller semantics during deposit/hold/sale, including interaction with delegated control.
  • Bonding-curve arithmetic bounds and rounding (all in Copper, no overflow at the extremes).

Two practical asks meanwhile: (1) this branch currently also contains unrelated bigint core-function changes (Core.java / Symbols.java, same content as #575) — please strip those so the PR is the pure actor + tests; (2) keep it targeting convex/lab/ for now — promotion to a core service address happens via the migration design, not this PR.

Happy to iterate on the design here or in an issue. Nice work.

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.

2 participants