Vaults: everyday actions
TL;DR
- A vault is your project’s NEAR account. The factory mints it, and we keep a live copy of its crucial fields in Firestore so dashboards update instantly.
- Every big move—requesting liquidity, funding, repaying, staking—has a matching hook and guide so you can go from idea to action quickly.
- If the data ever looks stale, hit Retry indexing and we refresh the vault straight from chain.
- Thinking about opening your first vault? Follow the checklist below before you mint anything.
Vault at a glance
- Identity:
vault-<number>.<factory_id>(auto-created by the factory contract). - State:
idle,pending,active, orclosedbased on liquidity status. - Mirror: Firestore stores
liquidity_request,accepted_offer, staking entries, and timestamps so the UI renders immediately.
New to vaults? Start with Mint a vault, register with the lending token, and keep a small NEAR buffer for follow-up transactions.
What you can do today
- Create a vault —
useCreateVaulthandles the mint + init flow (see Mint a vault). - Request liquidity —
useRequestLiquiditysendsrequest_liquiditywith a friendly form (see Open a liquidity request). - Accept as a lender —
useAcceptLiquidityRequestposts the funds and locks the offer (see Fund a liquidity request). - Repay the loan —
useRepayLoanpays principal + interest back to the lender (see Repay a loan). - Manage NEAR balances —
useDeposit,useWithdraw,useDelegate,useUndelegate,useClaimUnstaked. - Transfer ownership —
useTransferOwnershiplets you hand the vault to a new controller. - Force a refresh —
useIndexVault(client) orPOST /api/index_vault(server) re-fetches on-chain state and rewrites the Firestore copy.
Data that powers the UI
- Each factory becomes a Firestore collection; each vault is a document identified by its account ID.
- Key fields: overall
state, pending request details, active offer info, staking entries,current_epoch, and audit timestamps. - Full schema: Data model.
Keeping the view fresh
- Transactions settle on-chain instantly but Firestore might lag for a few seconds.
- The UI blocks actions that need up-to-the-minute data and shows a Retry indexing button. That hits
/api/index_vaultwhich:
- Calls
get_vault_state. - Transforms the response into a
VaultDocument. - Writes it back to Firestore.
- Operations deep dive: Indexing and consistency.
Where to look in the repo
hooks/— all the hooks listed above live here with typed responses and loading states.utils/indexing/service.ts— fetch-transform-save logic.utils/db/vaults.ts— shared Firestore helpers.app/api/index_vault/route.ts— manual indexing endpoint.
Related paths
- Viewer roles explain who can see or do what.
- Mint a vault.
- Open a liquidity request.
- Repay a loan.