Skip to content

Extend Soroban storage TTL on creator state during each trade to prevent active creator expiry #396

@Chucks1093

Description

@Chucks1093

Summary

Soroban persistent storage entries have a TTL measured in ledgers. If a creator's key goes untouched for long enough, their state entries can expire and be evicted from the ledger. A creator with an active community should never hit this — but one that has a quiet period followed by renewed interest will find their state gone and need to re-register, losing all historical supply and holder data. Every buy or sell should extend the TTL for that creator's storage so activity keeps the data alive automatically.

Scope

  • After every successful buy or sell for a creator, call `env.storage().persistent().extend_ttl()'\ on all storage keys associated with that creator (creator config, supply, holder map, fee config)
  • The extension target should be a named constant (e.g. CREATOR_TTL_LEDGERS) defined in a config module so it can be updated without touching the trade logic
  • Add a view function get_creator_ttl_remaining(creator_id) -> u32 that returns the ledgers remaining on the creator's primary storage key
  • Creator registration should also set the initial TTL to the same constant

Acceptance Criteria

  • Each successful buy extends all creator storage TTLs by CREATOR_TTL_LEDGERS
  • Each successful sell extends all creator storage TTLs by CREATOR_TTL_LEDGERS
  • A failed buy or sell (e.g. slippage exceeded) does not extend TTL
  • Creator registration sets the initial TTL to CREATOR_TTL_LEDGERS
  • get_creator_ttl_remaining returns a positive value for a live creator
  • CREATOR_TTL_LEDGERS is defined as a named constant, not a magic number
  • Unit tests confirm TTL is extended on buy and sell and unchanged on failed calls

Coordinate on Telegram

Metadata

Metadata

Assignees

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial CampaignCampaign: Official Campaign

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions