Problem
Only creditline-contract consistently calls extend_ttl() after persistent storage writes. The liquidity-pool and vendor-registry contracts write to persistent storage but never extend TTL, meaning their data will expire and the contract will appear to "lose" deposits or registered vendors.
Context
Soroban persistent entries expire if not refreshed. A sponsor's pool balance disappearing because of TTL would be catastrophic — funds become unrecoverable. This is a latent bug that only surfaces after weeks of inactivity on testnet but would be irrecoverable on mainnet.
Before Starting
Read these context files first:
- context/architecture-context.md
- context/code-standards.md
- context/progress-tracker.md
- contracts/liquidity-pool-contract/src/lib.rs
- contracts/vendor-registry-contract/src/lib.rs
What To Build
- Audit liquidity-pool: locate every
env.storage().persistent().set(...). After each, call env.storage().persistent().extend_ttl(&key, MIN_TTL, MAX_TTL) where MIN_TTL = 100_000, MAX_TTL = 1_000_000 (define in constants.rs).
- Same for vendor-registry: every
set(...) followed by extend_ttl().
- Centralize the constants in a shared
contracts/common/src/ttl.rs if not yet present; otherwise define locally per contract.
- Add a
storage::write_and_extend(env, key, value) helper to enforce the pattern at the source.
- Write a test per contract: deposit to pool, advance ledger by
MIN_TTL - 1, read — assert value still present.
- Update
code-standards.md to make the helper mandatory.
Files To Touch
contracts/liquidity-pool-contract/src/storage.rs
contracts/liquidity-pool-contract/src/lib.rs
contracts/vendor-registry-contract/src/storage.rs
contracts/vendor-registry-contract/src/lib.rs
contracts/liquidity-pool-contract/src/tests.rs
contracts/vendor-registry-contract/src/tests.rs
context/code-standards.md
Acceptance Criteria
Mandatory Checks Before PR
Problem
Only
creditline-contractconsistently callsextend_ttl()after persistent storage writes. The liquidity-pool and vendor-registry contracts write to persistent storage but never extend TTL, meaning their data will expire and the contract will appear to "lose" deposits or registered vendors.Context
Soroban persistent entries expire if not refreshed. A sponsor's pool balance disappearing because of TTL would be catastrophic — funds become unrecoverable. This is a latent bug that only surfaces after weeks of inactivity on testnet but would be irrecoverable on mainnet.
Before Starting
Read these context files first:
What To Build
env.storage().persistent().set(...). After each, callenv.storage().persistent().extend_ttl(&key, MIN_TTL, MAX_TTL)whereMIN_TTL = 100_000,MAX_TTL = 1_000_000(define inconstants.rs).set(...)followed byextend_ttl().contracts/common/src/ttl.rsif not yet present; otherwise define locally per contract.storage::write_and_extend(env, key, value)helper to enforce the pattern at the source.MIN_TTL - 1, read — assert value still present.code-standards.mdto make the helper mandatory.Files To Touch
contracts/liquidity-pool-contract/src/storage.rscontracts/liquidity-pool-contract/src/lib.rscontracts/vendor-registry-contract/src/storage.rscontracts/vendor-registry-contract/src/lib.rscontracts/liquidity-pool-contract/src/tests.rscontracts/vendor-registry-contract/src/tests.rscontext/code-standards.mdAcceptance Criteria
set()in both contracts is followed byextend_ttl()Mandatory Checks Before PR