> ## Documentation Index
> Fetch the complete documentation index at: https://docs.convexia.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Flow of Funds

## At a high-level

<img src="https://mintcdn.com/convexia-3aabd027/tS1nN2fGXO5eQ7Jy/images/download.png?fit=max&auto=format&n=tS1nN2fGXO5eQ7Jy&q=85&s=14d438aef2d3c0a6b82525caa4b22559" alt="Download" width="2225" height="943" data-path="images/download.png" />

## Step 0: Prerequisits (one-time)

1. **Client onboarding / KYB** completed.
2. **Client wallets whitelisted** (source + destination).
3. Client receives **API key** + allowed chains/assets.

## Step 1: Create Intent

**Goal:** Tell Convexia what you want to move.

**API**

* `POST /v1/intents`

**Request**

* `from_asset` (e.g., `USDC`)
* `from_chain` (e.g., `base`)
* `to_asset` (e.g., `USDT`)
* `to_chain` (e.g., `tron`)
* `amount`
* `destination_address` (on destination chain)

**What happens**

* Convexia validates:
  * client auth + whitelist
  * asset/chain support
  * basic compliance eligibility checks (policy gates)

**Returns**

* `intent_id`
* `expires_at`

## Step 2: Get Aggregated Quote

**Goal:** Return best executable route from **resting inventory**.

**API**

* `GET /v1/intents/{intent_id}/quote`

**What happens**

* Convexia’s matching engine:
  * broadcasts the intent to **whitelisted makers**
  * pulls:
    * maker quotes (RFQ)
    * any available **resting liquidity** pricing updates
  * aggregates into a single executable outcome

**Returns**

* `quote_id`
* `all_in_rate` / `spread_bps`
* `to_amount_estimate`
* `settlement_instructions` (where to deposit on source chain)
* `expiry`

## Step 3: Accept Quote

**Goal:** Lock the route and generate a deposit escrow on the source chain.

**API**

* `POST /v1/quotes/{quote_id}/accept`

**What happens**

* Convexia locks:
  * the makers + allocations
  * the settlement parameters
  * the escrow address / contract state (HTLC-style)

**Returns**

* `trade_id`
* `source_deposit_address` (or program-derived escrow)
* `deposit_amount`
* `deposit_deadline`
* `onchain_reference`

## Step 4: Client Deposits Source Funds

**Goal:** Move client funds into a controlled escrow on the **source chain**.

**On-chain**

* Client sends `deposit_amount` of `from_asset` to `source_deposit_address`

**What happens**

* Funds are now:
  * on-chain
  * time/condition locked
  * earmarked to this `trade_id`

**State transition**

* `trade_status: AWAITING_DEPOSIT → DEPOSIT_CONFIRMED`

## Step 5: Makers Fund / Reserve Destination Liquidity

**Goal:** Ensure destination delivery is backed by **pre-positioned inventory**.

**What happens**

* Makers either:
  * already have sufficient **resting inventory** in the sandbox on destination chain, or
  * top up / reserve inventory tied to this `trade_id`

**State transition**

* `trade_status: DEPOSIT_CONFIRMED → MAKER_READY`

## Step 6: Execute Settlement

**Goal:** Settlement of funds across chains

**On-chain actions**

1. **Destination leg:** Convexia releases `to_asset` from sandbox inventory to the client’s `destination_address`.
2. **Source leg:** Once destination delivery is confirmed, escrow releases `from_asset` to maker settlement addresses (per allocations).

**State transition**

* `trade_status: MAKER_READY → SETTLING → SETTLED`

## Step 7: Client Receives Funds (Destination chain)

**Goal:** Client gets final funds, with traceability.

**Result**

* `destination_address` receives `to_asset` on `to_chain`
* API returns settlement receipt with:
  * tx hashes (source + destination)
  * makers involved (if permitted)
  * provenance/attestation references (issuer lineage / compliance metadata)

**API**

* `GET /v1/trades/{trade_id}`

## Step 8: Post-Trade Receipt & Reporting

**Goal:** Provide auditable records for compliance and ops.

**API**

* `GET /v1/trades/{trade_id}/receipt`

**Includes**

* route summary
* net amounts
* fees
* tx hashes
* timestamps
* policy checks passed
* provenance references (issuer lineage / whitelisted maker inventory)
