Skip to content

Implement deposit (lock assets) flow with Freighter signing and simulation #19

Description

@prodbycorne

Problem

The farm page has no deposit / lock-assets button. Users can see pool rows and attempt to unlock, but there is no way to actually stake assets into a pool. The sorobanService has a lockAssets method skeleton but there is no UI flow to invoke it.

Expected Behaviour

A Deposit modal (or inline form) allows a connected user to enter an amount, preview the transaction fee via Soroban simulation, and sign + submit the lock_assets call through Freighter. On success the pool row updates to show the new stake and a lockdown countdown begins.

Acceptance Criteria

  • A "+ Deposit" button appears on each pool row in src/app/farm/page.tsx (visible when wallet is connected)
  • Clicking opens a modal with:
    • Amount input validated against the user's on-chain Stellar balance (fetched from Horizon)
    • Fee preview obtained via rpcServer.simulateTransaction before the user signs
    • A clear display of the minimum lock period so users know when they can unlock
  • Transaction is built using TransactionBuilder, simulated, and signed via walletApi.signTransaction; the signed XDR is then submitted through rpcServer.sendTransaction
  • Transaction status is polled via rpcServer.getTransaction until SUCCESS or FAILED; the UI shows a progress spinner with hash link during polling
  • On success, React Query cache for userPosition and pools is invalidated so balances refresh automatically
  • Input is disabled and shows a spinner while the transaction is in-flight to prevent double submission
  • A Vitest test mocks rpcServer and asserts the correct Soroban operation is built with the right contract address and argument encoding

Relevant Files

  • src/app/farm/page.tsx — add deposit button to EarningRow
  • src/lib/soroban.tslockAssets method (implement the actual contract call)
  • src/hooks/useSorobanQuery.ts — add useLockAssets mutation
  • src/config/index.tspoolContractId, networkPassphrase

Metadata

Metadata

Assignees

Labels

Official CampaignCampaign: Official CampaignfarmFarming/staking flow — deposit, lock, unlock, creditshardRequires deep domain knowledge — Soroban, Stellar SDK, or complex statesorobanSoroban smart-contract integration (XDR, RPC, transaction building)walletFreighter wallet integration, session, and network switching

Type

No type

Fields

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