# Integration Cookbook

This page provides walkthroughs for various integration scenarios to suit your needs.

1. [Parking Your Users' Idle Funds in Curvance](/app/developer-docs/quick-start-guides/integration-cookbook.md#parking-your-users-idle-funds-in-curvance)
2. [Include a Curvance Market in Your Vault](/app/developer-docs/quick-start-guides/integration-cookbook.md#include-a-curvance-market-in-your-vault)
3. More coming soon

{% hint style="danger" %}
To minimize the risk of bad debt and potential loss of funds, deposit user funds exclusively into conservative markets with low-risk profiles.
{% endhint %}

***

### 🅿️ Parking Your Users' Idle Funds in Curvance

**Objectives:**

* Safely park user idle funds in Curvance markets.

#### One time setup (per cToken market)

The user calls [`cUSDC.setDelegateApproval(<yourPlatformAddress>, true)`](/app/developer-docs/plugin-and-delegation-system/delegable-actions.md#setdelegateapproval), delegating your platform's address as the delegate.

**Optionally:** To reduce the total amount of transactions even further, from your app, call `approve` in the idle asset to allow the Curvance cToken to spend.

{% hint style="info" %}
Note: Users can mass-revoke all delegates anytime via the [approval index](/app/developer-docs/plugin-and-delegation-system/delegable-actions.md#incrementapprovalindex).
{% endhint %}

#### **Depositing idle funds**

**From your platform:** source USDC (e.g., transferred to you by the user) and call [`cUSDC.deposit(assets, <userAddress>)`](/app/developer-docs/lending-protocol/ctoken.md#deposit).

{% hint style="info" %}
Note: deposits pull USDC from the caller (msg.sender), not the `receiver`.
{% endhint %}

#### Retrieving funds on demand

Call [`cUSDC.redeemFor(shares, <yourPlatformAddress>, <userAddress>)`](/app/developer-docs/lending-protocol/ctoken.md#redeemfor) to redeem the user's cUSDC shares and receive USDC.

{% hint style="info" %}
Redeeming cTokens does not require ERC20 approval.
{% endhint %}

***

### 🧺 Include a Curvance Market in Your Vault

**Objectives:**

* Mint cTokens to your vault.
* Redeem cTokens to rebalance/withdraw

#### Mint cTokens when users mint vault shares

1. Approve cToken to spend the underlying ERC20 from your vault.&#x20;
2. Call [`cToken.deposit()`](/app/developer-docs/lending-protocol/ctoken.md#deposit) from your contract, with its address as the recipient.

#### Redeem cTokens to rebalance (if applicable) / or withdraw user funds

Call [`cToken.redeem()`](/app/developer-docs/lending-protocol/ctoken.md#redeem) if redeeming in shares, or [`cToken.withdraw()`](/app/developer-docs/lending-protocol/ctoken.md#withdraw) if redeeming in underlying.

{% hint style="info" %}
Redeeming cTokens does not require ERC20 approval.
{% endhint %}

***

#### Practical tips

* Use previews ([`previewDeposit()`, `previewWithdraw()`, `previewMint()`, `previewRedeem()`](/app/developer-docs/lending-protocol/ctoken.md#share-assets)) client-side for UX estimates.
* Pauses/caps may limit deposits/redemptions; handle errors gracefully.
* Security: delegation lets your platform act for users; encourage users to delegate only trusted contracts and remind them they can revoke instantly via approval index.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.curvance.com/app/developer-docs/quick-start-guides/integration-cookbook.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
