Developers

Integrate deposits

How-to guide5 min readContent reviewed
Markdown ↓
On this page

Use this guide to choose a deposit route and build its transaction flow. For a working server-side data read, start with the API tutorial; for Web3 transaction fragments, use the detailed Web3 guide.

1. Resolve the deployment and caller#

Resolve the vault record, chain, underlying token, and token decimals. Verify the vault proxy and implementation, then read token(), AATranche(), BBTranche(), and strategy() from that deployment. Match each queue's idleCDOEpoch(), strategy(), underlying() and tranche() to the selected vault and tranche. API metadata helps discovery; use the deployment verification record for your supported transaction routes.

Evaluate isWalletAllowed(actualCaller). A wallet UI usually calls as the lender; a router or custody contract calls as that contract. Complete the applicable onboarding and document process separately. A positive eligibility result does not override pause, capacity, or route restrictions.

2. Select a route and spender#

For new subscriptions, this guide uses a nonzero epochDuration() as an application guard for an open pool. The ordinary deposit method does not implement that duration check as a separate explicit gate; do not interpret the guard as a guaranteed revert reason.

Situation Method Underlying-token spender Completion
Between epochs; vault unpaused and epochDuration() != 0 Vault depositAA(amount), or enabled depositBB(amount) Vault proxy Tranche tokens minted to caller in the transaction.
Running epoch with an eligible configured queue Queue requestDeposit(amount) Selected deposit queue Queued request; tranche issuance and claim happen later.
Running epoch with direct mid-epoch deposits enabled Vault depositDuringEpoch(amount,tranche) Vault proxy Tranche tokens minted; underlying sent to borrower immediately.

For direct mid-epoch deposits, read the supported isDepositDuringEpochDisabled, isProgrammableBorrower, epochEndDate and BB-enable getters, and the selected tranche's supply. The skipDefaultCheck and isAYSActive fields have no public getters in the interfaces described here; assess those mode restrictions through verified configuration/source evidence and simulate the exact call. The reviewed source rejects disabled, emergency, programmable-borrower, AYS, expired, ineligible, and empty-tranche cases. Each route has its own live checks. The strategy counter advances through settlement.

Before enabling standard queued subscriptions for an empty tranche, initialize it with a direct deposit that quotes more than 1,000 gross share base units. Verify shares were received. A standard queue prices first-issuance claims from gross shares, which can exceed the actual shares it receives. Queue submission checks the lender, while the queue address must pass the applicable vault gates when the operator processes it.

3. Approve, simulate, and send#

Convert the intended amount to integer base units using the underlying token's decimals. Check the caller's underlying balance and allowance(caller,selectedSpender). Approve the selected spender using the token's supported approval behavior, then simulate the deposit from the actual caller with the intended amount and tranche.

Show the selected chain, asset, amount, spender, and route before signing. For direct deposits, label simulated tranche output as gross shares. On first mint, address(1) receives 1,000 share base units and the caller receives the remainder. Verify the caller's actual balance increase before crediting the position. For queued deposits, show a pending subscription rather than an immediately invested tranche balance. Track the mined transaction and refresh state before marking success. Handle rejected signatures, failed approvals, reverts, and changed epoch state as separate outcomes.

Give the deposit a stable submission ID and reuse it when the lender reopens the flow. Before broadcasting, wait for the intent store to confirm it durably created the record. If the write fails or the record already exists, stop before sending. Start saving the hash under that ID as soon as Web3 emits it. Wait for durable confirmation before reporting the receipt outcome. If the save fails, show the hash, keep the deposit unresolved and retry the storage write for the same submission.

After a lost RPC response, keep a hashless intent unknown and keep another send disabled across restarts. The deposit can still be mined while wallet history is empty and the pending count is unchanged. An older deposit can also have the same target, route and amount. Adopt a hash only from evidence tied to the original request on its chain, such as the wallet's signing record for that request. A positive confirmation that the wallet rejected this specific request before broadcast, such as EIP-1193 code 4001 from the original send, permits a fresh attempt. Without either kind of evidence, leave the intent open.

After a hash exists, the send can still reject, for example on a receipt timeout, while the transaction is mined. The receipt decides the outcome. Report reconciliation as pending while the raw receipt is missing, has no status, or a read fails, and repeat the lookup by hash. A mined receipt with a failed status means the deposit did not complete. When the lookup is unavailable, a failed mined receipt carried by the send error counts if it has the same hash and a block number. Do not send another deposit for the same intent while the first transaction can still be mined. Credit shares only from a successful mined receipt. The Web3 example shows the bounded retry.

4. Complete a queued deposit#

A standard queue assigns a request to the next strategy epoch. The queue owner or strategy manager processes the current strategy bucket while ordinary deposits are open between epochs. Before processing subscriptions, recheck the open-pool guard epochDuration() != 0. A successful full recall reaches the target epoch and can leave ordinary deposits unpaused at zero duration. The processor calls a vault deposit method with no duration check.

On healthy closure, leave the deposit bucket unprocessed. The requesting lender can recover the underlying with deleteRequest(originalEpoch). If the strategy advances past an unprocessed bucket in a continuing pool, use the same cancellation method and resubmit when the route opens.

After processing and pricing, the lender calls claimDepositRequest(epoch) on the same queue to receive tranche tokens. Read userDepositsEpochs(caller,epoch), epochPrice(epoch) and epochPendingDeposits(epoch) before simulating the claim.

Keep the request's queue address, caller, transaction hash, amount, and epoch in your application record. Confirm the final tranche transfer and reconcile it against on-chain balances. Continue with withdrawal integration, permissions, and the integration checklist.