Final completed solution : will be interested to contribute more at star#1
Merged
Rahul-Prasad-07 merged 9 commits intomainfrom Oct 11, 2025
Merged
Final completed solution : will be interested to contribute more at star#1Rahul-Prasad-07 merged 9 commits intomainfrom
Rahul-Prasad-07 merged 9 commits intomainfrom
Conversation
…fees and distribution
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.