Skip to content

onchain storage#8

Merged
aayusha59 merged 1 commit into
mainfrom
feature/on-chain-position-storage
Jan 18, 2026
Merged

onchain storage#8
aayusha59 merged 1 commit into
mainfrom
feature/on-chain-position-storage

Conversation

@aayusha59
Copy link
Copy Markdown
Owner

@aayusha59 aayusha59 commented Jan 18, 2026

Summary by CodeRabbit

  • New Features
    • Deposit requests now include market question and expiry information for complete transaction context.
    • Position tracking migrated to real-time on-chain synchronization with automatic 15-second refresh cycles, replacing local storage.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
v0-skal-ventures-template-hm Error Error Jan 18, 2026 2:29am

@aayusha59 aayusha59 merged commit c8c8a13 into main Jan 18, 2026
1 of 2 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 18, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

The changes extend the deposit flow to accept market question and expiry parameters, integrate on-chain Memo instruction storage for deposit context, and refactor position loading from localStorage to on-chain history fetching via transaction signature polling.

Changes

Cohort / File(s) Change Summary
Deposit API Signature Extension
hooks/use-deposit.ts
Updated deposit function and UseDepositReturn interface to accept marketQuestion (string) and expiry (number) parameters, forwarding them through to the transaction builder.
On-Chain Deposit Persistence
lib/solana/deposit.ts
Introduced MEMO_PROGRAM_ID constant and extended DepositParams with marketQuestion and expiry fields. Added Memo instruction to deposit transactions to persist deposit context (marketId, question, position, amount, expiry, timestamp) on-chain.
Position Loading Refactoring
hooks/use-positions.ts
Replaced localStorage-based position storage with on-chain history fetching: queries last 20 user signatures, parses transactions to extract Memo instruction data, reconstructs UserPosition entries from payloads, implements 15-second polling refresh cycle, and removes localStorage persistence from position additions.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant Hook as useDeposit Hook
    participant TxBuilder as Deposit TX Builder
    participant Solana as Solana Network
    participant Memo as Memo Program
    participant Token as Token Program

    User->>Hook: deposit(amount, marketId, marketQuestion, expiry, position)
    Hook->>TxBuilder: buildDepositTransaction(params with marketQuestion, expiry)
    TxBuilder->>TxBuilder: Create Memo instruction with deposit context
    TxBuilder->>Solana: Send transaction with Memo + Token instructions
    Solana->>Memo: Execute Memo instruction (store context)
    Solana->>Token: Execute USDC transfer
    Memo->>Solana: ✓ On-chain storage confirmed
    Token->>Solana: ✓ Transfer confirmed
    Solana->>Hook: Transaction signature
    Hook->>User: Return signature / success
Loading
sequenceDiagram
    actor User
    participant Hook as usePositions Hook
    participant Wallet as Wallet Adapter
    participant RPC as Solana RPC
    participant Parser as Memo Parser

    User->>Hook: Load/Poll positions
    Hook->>Wallet: Get user public key
    Wallet->>Hook: Public key
    Hook->>RPC: Fetch last 20 signatures
    RPC->>Hook: Transaction signatures
    Hook->>RPC: Fetch parsed transactions
    RPC->>Hook: Transaction details with Memo instructions
    Hook->>Parser: Extract & parse Memo payloads
    Parser->>Hook: UserPosition objects
    Hook->>Hook: Update state & recalculate totals
    Hook->>User: Positions ready
    Note over Hook: Repeat poll every 15 seconds
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 From storage shelves we leap away,
With memos woven on-chain to stay,
Market questions dance with time,
Positions synced in rhythmic rhyme,
Fifteen seconds, polling sweet—
The chain and wallet waltz complete! ✨

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant