Skip to content

feat(lp-pool): automated storage TTL extension for active LP pool accounts - #897

Merged
Sadeequ merged 2 commits into
StellarFlow-Network:mainfrom
milah-247:fix/issue-768-lp-pool-ttl-extension
Sep 2, 2026
Merged

Sadeequ merged 2 commits into
StellarFlow-Network:mainfrom
milah-247:fix/issue-768-lp-pool-ttl-extension

Conversation

@milah-247

Copy link
Copy Markdown
Contributor

Closes #768

What

There was no LP pool contract in this repo yet, so this adds a minimal, self-contained constant-product (x*y=k) two-asset pool at contracts/lp-pool/ (initialize/deposit/withdraw/swap + read-only getters) — just enough surface area to meaningfully implement and test the issue's actual deliverable: active pool reserves and user share records must never drift into Soroban's archived storage state.

How

  • bump_pool_ttl / bump_user_ttl run at the top of swap(), deposit(), and withdraw() — before any pool/user state is read — and call extend_ttl on the relevant persistent entries whenever their remaining TTL drops below BUMP_THRESHOLD (~30 days), extending out to BUMP_AMOUNT (~60 days). Both are no-ops (zero extra cost) when an entry is already healthy, per the issue's "zero disruption" requirement.
  • No fee tiers, no separate LP token contract, no oracle integration — kept deliberately scoped to the TTL requirement plus the bare AMM mechanics needed to exercise it.

Testing

cargo test -p lp-pool: 14/14 passing, covering core AMM correctness (deposit/withdraw/swap invariants, slippage guard, insufficient shares/liquidity, zero-amount and not-initialized guards) and the TTL deliverable itself — persistent entries that would have expired under the sandbox's default 4096-ledger TTL survive and stay fully usable because the contract proactively extends them.

cargo build -p lp-pool --target wasm32-unknown-unknown --release: succeeds.

Note: this workspace pins soroban-sdk = "20.0.0" (resolving to 20.5.0/soroban-env-host 20.3.0). That generation's SDK has no get_ttl reader on persistent storage (added later), so the TTL tests prove the extension behaviorally — jumping the ledger to one tick before a never-bumped entry's TTL would expire and asserting the next call still succeeds — rather than by reading the raw counter.

ellaevans2323-pixel and others added 2 commits September 1, 2026 08:23
…ounts

Adds a minimal, self-contained constant-product (x*y=k) two-asset
liquidity pool contract (initialize/deposit/withdraw/swap + getters)
whose sole purpose is to demonstrate and test issue StellarFlow-Network#768's requirement:
active pool reserves and user share records must never drift into
Soroban's archived storage state.

- bump_pool_ttl / bump_user_ttl are called at the top of swap(),
  deposit(), and withdraw() — before any pool/user state is read — and
  extend the relevant persistent entries' TTL out to BUMP_AMOUNT
  whenever the remaining TTL drops below BUMP_THRESHOLD. Both are
  no-ops (zero extra cost) when an entry is already healthy.
- 14 unit tests cover core AMM mechanics (deposit/withdraw/swap
  invariants, slippage, insufficient shares/liquidity, zero-amount and
  not-initialized guards) plus the TTL deliverable itself: entries that
  would have expired under the sandbox's default 4096-ledger TTL
  survive and stay usable because the contract proactively bumped them.

Closes StellarFlow-Network#768
@drips-wave

drips-wave Bot commented Sep 2, 2026

Copy link
Copy Markdown

@milah-247 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Sadeequ
Sadeequ merged commit 6ce5f2c into StellarFlow-Network:main Sep 2, 2026
0 of 2 checks 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.

Implement Automated Storage TTL Extension for Active LP Pool Accounts

2 participants