token-swap: later deposits can dilute LPs after fee growth
メンテナーはふだん 1 日以内に返信
@Bismithblde がすでに取り組んでいます。
2026年11月5日 から。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 45/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
- 領域
- blockchain, databases
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Rust
- スター
- 1.4k
- フォーク
- 559
- 平均マージ
- 20時間 9分
- マージ済み PR(30日)
- 17
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
solana-foundation/program-examples のほかの issue
-
Migrate deprecated .accounts() to .accountsPartial() in Anchor tests再び着手できるかも @ankittiwari-04 が 24 日前に担当しましたが、オープン中のプルリクエストはありません。 オープンaccepted
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
solana-foundation/program-examples#747 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
basics/pda-rent-payer: create_new_account has no caller check — worth a note for people copying it?対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
solana-foundation/program-examples#671 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
native/pinocchio examples: deploy script points at program.so, which the build never produces再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンaccepted
難易度 1/5 1時間未満 初心者へのやさしさ 35/100
solana-foundation/program-examples#787 ·
メンテナーはふだん 1 日以内に返信
-
token-2022/cpi-guard: add a Pinocchio version再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンaccepted
難易度 3/5 1〜2日 初心者へのやさしさ 20/100
solana-foundation/program-examples#786 ·
メンテナーはふだん 1 日以内に返信
-
token-2022/memo-transfer: add a Pinocchio version再び着手できるかも このイシューのプルリクエストはマージされずにクローズされました。 オープンaccepted
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
solana-foundation/program-examples#785 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
solana-foundation/program-examples の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RustCrypto/utils#1597 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
max-sixty/worktrunk#4727 · コメント 7 件 · リアクション 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
メンテナーはふだん 1 日以内に返信
-
follow-up
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
carrick-sh/carrick#1859 ·
メンテナーはふだん 1 日以内に返信