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

# lockIntoShareGroup: Deposit Chain Funds into a Share Group

> Move funds from your chain-level balance into a share group margin pool directly, bypassing the per-market-deployer step for PORTFOLIO mode trading.

Rather than routing funds through a market deployer first, `lockIntoShareGroup` lets you move collateral directly from your chain-level balance into a share group's shared margin pool in a single step. This is the most direct way to fund PORTFOLIO mode trading when you already have chain-level funds available and want to skip the intermediate per-MD allocation.

<Note>
  Your account must be in **PORTFOLIO mode** before you can fund share groups. Switch modes first with [`setMarginShareType`](/exchange/set-margin-share-type) using `marginShareType: 1`.
</Note>

## Endpoint

```
POST https://dev.upsidemax.xyz/exchange
```

## Request

Every request must carry an ECDSA signature and a nonce to prevent replay attacks.

```json theme={"system"}
{
  "action": {
    "type": "lockIntoShareGroup",
    "groupId": 3,
    "coinId": 1,
    "amount": "1000"
  },
  "signature": { "r": "0x...", "s": "0x...", "v": 28 },
  "nonce": 1778859400000
}
```

### Action parameters

<ParamField body="groupId" type="int32" required>
  The ID of the target share group. Funds are credited directly to this group's shared margin pool.
</ParamField>

<ParamField body="coinId" type="int32" required>
  The coin or currency ID to transfer from your chain-level balance into the share group.
</ParamField>

<ParamField body="amount" type="string" required>
  The amount to transfer, expressed as a raw integer string (e.g. `"1000"`). Must be greater than zero and must not exceed your available chain-level balance for the given coin. Decimals are not accepted — use the coin's smallest unit.
</ParamField>

## Response

A successful transfer returns the updated balances for both the source (your chain-level ledger, represented as `fromBalanceAfter`) and the destination share group. The response type is `shareGroupFund`, consistent with other share group fund operations.

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "shareGroupFund",
    "data": {
      "coinId": 1,
      "amount": 1000,
      "fromBalanceAfter": 4000,
      "toBalanceAfter": 1000
    }
  }
}
```

<ResponseField name="coinId" type="int32">
  The coin ID that was transferred.
</ResponseField>

<ResponseField name="amount" type="int64">
  The amount moved from your chain-level balance into the share group.
</ResponseField>

<ResponseField name="fromBalanceAfter" type="int64">
  Your chain-level balance for this coin after the transfer.
</ResponseField>

<ResponseField name="toBalanceAfter" type="int64">
  The share group's margin pool balance after the transfer.
</ResponseField>

## Errors

If the request cannot be fulfilled, the exchange still returns **HTTP 200** with `status: "ok"` — the rejection is reported inside `response.data`, where a server-assigned integer `errorCode` and a human-readable `errorMessage` are populated while the numeric amount and balance fields are set to `0`. Common causes include:

* **Insufficient chain-level balance** — the requested `amount` exceeds your available chain-level funds for the given coin.
* **Account not in PORTFOLIO mode** — share groups are only active when your margin share type is `1`.
* **Invalid `groupId`** — the specified share group must exist and be accessible to your account.
* **Amount ≤ 0** — the `amount` field must be a positive integer string.

```json theme={"system"}
{
  "status": "ok",
  "response": {
    "type": "shareGroupFund",
    "data": {
      "coinId": 0,
      "amount": 0,
      "fromBalanceAfter": 0,
      "toBalanceAfter": 0,
      "errorCode": 1,
      "errorMessage": "insufficient chain-level balance"
    }
  }
}
```

<Tip>
  To withdraw funds from a share group back to your chain-level balance, use [`unlockFromShareGroup`](/exchange/unlock-from-share-group). To move funds between a share group and a market deployer, use [`transferMdToShareGroup`](/exchange/transfer-md-to-share-group) or [`transferShareGroupToMd`](/exchange/transfer-share-group-to-md).
</Tip>
