token-swap: later deposits can dilute LPs after fee growth
Maintainer thường phản hồi trong vòng 1 ngày
@Bismithblde đang làm issue này rồi.
Từ ngày 5/11/2026.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- rust
- Lĩnh vực
- blockchain, databases
Hướng nghiên cứu
Find the token-swap example and its existing LiteSVM harness, then read the deposit share calculation and the test setup. Reproduce the sequence with separate liquidity providers and compare the second provider’s minted shares against the proportional limit. Done means later deposits use the stated proportional calculation, zero-share deposits are rejected, and a LiteSVM regression test covers the dilution case.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
The Anchor token-swap example calculates LP shares as sqrt(amount_a * amount_b) for every deposit. Once swap fees increase the reserves, that calculation ignores the existing LP supply and can give a later depositor too large a share of the pool, diluting existing providers.
Reproduction
In the existing LiteSVM harness:
- Create a pool with a 5% swap fee and deposit 4,000,000 units of each token.
- Swap 2,000,000 units of token A for B, growing the pool's reserves through the fee.
- Have a second provider deposit up to 1,000,000 units of each token.
The second provider receives 672,292 LP tokens. Based on the actual deposited amounts and the effective existing supply (minted LP supply plus the locked minimum), a proportional deposit supports at most 666,665 LP tokens. The difference reduces the first provider's share of the reserves.
Suggested fix
Keep the geometric-mean calculation for the first deposit. For later deposits, calculate proportional shares from each actual deposited amount and its pre-deposit reserve, using the effective LP supply, and mint the smaller result rounded down. Reject deposits that mint no shares. Add a LiteSVM regression test using separate liquidity providers.
This concerns the educational example's accounting, not a claim about a deployed protocol. I have a tested patch and would like to contribute it.
- Ngôn ngữ chính
- Rust
- Star
- 1.4k
- Fork
- 559
- Merge trung bình
- 20 giờ 9 phút
- Pull request đã merge (30 ngày)
- 17
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solana-foundation/program-examples
-
Migrate deprecated .accounts() to .accountsPartial() in Anchor testsCó thể làm lại được @ankittiwari-04 đã nhận 24 ngày trước và không có pull request nào đang mở. Đang mởaccepted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
solana-foundation/program-examples#747 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
basics/pda-rent-payer: create_new_account has no caller check — worth a note for people copying it?Có thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
solana-foundation/program-examples#671 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
native/pinocchio examples: deploy script points at program.so, which the build never producesCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 35/100
solana-foundation/program-examples#787 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
token-2022/cpi-guard: add a Pinocchio versionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 20/100
solana-foundation/program-examples#786 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
token-2022/memo-transfer: add a Pinocchio versionCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởaccepted
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 30/100
solana-foundation/program-examples#785 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solana-foundation/program-examples
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
RustCrypto/utils#1597 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Non-`main` default branchesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
max-sixty/worktrunk#4727 · 7 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày
-
follow-up
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 73/100
carrick-sh/carrick#1859 ·
Maintainer thường phản hồi trong vòng 1 ngày