Skip to content

Final completed solution : will be interested to contribute more at star#1

Merged
Rahul-Prasad-07 merged 9 commits intomainfrom
bounty
Oct 11, 2025
Merged

Final completed solution : will be interested to contribute more at star#1
Rahul-Prasad-07 merged 9 commits intomainfrom
bounty

Conversation

@Rahul-Prasad-07
Copy link
Copy Markdown
Owner

No description provided.

Rahul-Prasad-07 and others added 9 commits October 7, 2025 13:20
…om the passing run:

CreateConfig & InitializePool (cp-amm program)

Payer funds the config, pool, and vault ATAs.
The cp-amm admin, mint accounts, and metadata are set up.
Pool is ready to host positions.
Honorary initialize_policy (honorary_lp program)

Policy PDA is derived off the pool; it records creator, fee splits (90% investors / 10% creator), min payout, daily cap, etc.
Progress PDA is created to track distribution cursors/time gates/dust.
Treasury ATA is created under the honorary authority PDA.
CPI to cp-amm creates the honorary LP position (full range in this test).
Fee claiming setup

Temporary ATAs are minted so the cp-amm position can accrue quote fees.
First claim_fees call (with zero fees) ensures the path works and enforces quote-only by checking the base amount is zero.
Fee accrual & second claim_fees

The test mints 1,000,000 quote units to the cp-amm fee vault, then claim_fees is called again.
The CPI into cp-amm pulls exactly the quote fees and transfers them into the honorary treasury ATA.
Treasury balance ends at 1,000,000 quote units.
distribute_fees crank

Reads current timestamp; since progress.cursor == 0, it resets progress for a new day (we’ll wire in the 24h gate soon).
Takes min(treasury_balance, daily_cap); here both are 1,000,000.
Calculates investor pool = 90% (900,000) and creator remainder = 100,000.
Loops over the two investors:
Investor A locked 60 units, gets 900,000 * 60 / 100 = 540,000.
Investor B locked 40 units, gets 360,000.
Transfers use transfer_checked with the honorary PDA signer.
Updates progress.cursor to 2, progress.day_distributed to 900,000.
Since all investors were processed this batch, it sends the remainder (100,000) to the creator.
Updates dust carry (zero) and totals.
Post-crank balances

Investor A ATA: 540,000 (from zero)
Investor B ATA: 360,000 (from zero)
Creator ATA: previous giant balance + 100,000 (delta logged)
Treasury ATA: drained back to zero
@Rahul-Prasad-07 Rahul-Prasad-07 merged commit ee5c00e into main Oct 11, 2025
1 check passed
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.

1 participant