# UpdateGlobalVar

This transaction is used to update the global variable settings.

<table><thead><tr><th width="20">Name</th><th width="20">Type</th><th width="10">Required</th><th width="250">Description</th></tr></thead><tbody><tr><td>type</td><td>String</td><td>yes</td><td>The value is "UpdateGlovalVar "</td></tr><tr><td>fromChainId</td><td><a href="/pages/9wsGjTwfpfc2nyUJWAzS#chainid">ChainId</a></td><td>yes</td><td>The layer3 chain id</td></tr><tr><td>subAccountId</td><td><a href="/pages/9wsGjTwfpfc2nyUJWAzS#subaccountid">SubAccountId</a></td><td>yes</td><td>The subaccount id</td></tr><tr><td>parameter</td><td><a href="/pages/fzxZg2TYd0M956BdFhGy">Parameter</a></td><td>yes</td><td>Different operation has different variable</td></tr><tr><td>seriaId</td><td>u64</td><td>yes</td><td>The serial id</td></tr></tbody></table>

There are 5 parameters, different operations correspond to different parameters:

{% tabs %}
{% tab title="feeAccount" %}
Modify the collect-fee account.

| Name       | Type                                                         | Required | Description        |
| ---------- | ------------------------------------------------------------ | -------- | ------------------ |
| feeAccount | [AccountId](/developer/api-and-sdk/basic-types.md#accountid) | yes      | The fee account id |

For example:

```json
{
  "type": "UpdateGlobalVar",
  "fromChainId": 1,
  "subAccountId": 1,
  "parameter": {
    "feeAccount": {
      "accountId": 10
    }
  },
  "serialId": 100
}
```

{% endtab %}

{% tab title="insuranceFundAccount" %}
Modify the insurance fund account

| Name      | Type                                                         | Required | Description                            |
| --------- | ------------------------------------------------------------ | -------- | -------------------------------------- |
| accountId | [AccountId](/developer/api-and-sdk/basic-types.md#accountid) | yes      | The account id of insuranceFundAccount |

For Example:

```json
{
  "type": "UpdateGlobalVar",
  "fromChainId": 1,
  "subAccountId": 1,
  "parameter": {
    "insuranceFundAccount": {
      "accountId": 9
    }
  },
  "serialId": 100
}
```

{% endtab %}

{% tab title="marginInfo" %}
Modify the margin info in the specified index.

| Name     | Type                                                       | Required | Description               |
| -------- | ---------------------------------------------------------- | -------- | ------------------------- |
| marginId | [MarginId](/developer/api-and-sdk/basic-types.md#marginid) | yes      | The margin id             |
| tokenId  | [TokenId](/developer/api-and-sdk/basic-types.md#tokenid)   | yes      | The Token id              |
| ratio    | u8                                                         | yes      | the ratio, 100 means 1.0% |

For example

```json
{
  "type": "UpdateGlobalVar",
  "fromChainId": 1,
  "subAccountId": 1,
  "parameter": {
    "marginInfo": {
      "marginId": 1,
      "tokenId": 9,
      "ratio": 0
    }
  },
  "serialId": 100
}
```

{% endtab %}

{% tab title="contractInfo" %}
Modify the info of every perpetual contract pair.

| Name                  | Type                                                   | Required | Description                                             |
| --------------------- | ------------------------------------------------------ | -------- | ------------------------------------------------------- |
| pairId                | [PairId](/developer/api-and-sdk/basic-types.md#pairid) | yes      | The pair id                                             |
| symbol                | String                                                 | yes      | The symbol of the contract                              |
| initialMarginRate     | u16                                                    | yes      | The initial margin rate of the contract, 100 means 0.1% |
| maintenanceMarginRate | u16                                                    | yes      | The maintenance margin rate, 100 means 0.1%             |

```json
{
  "type": "UpdateGlobalVar",
  "fromChainId": 1,
  "subAccountId": 1,
  "parameter": {
    "contractInfo": {
      "pairId": 2,
      "symbol": "BTCUSDC",
      "initialMarginRate": 6,
      "maintenanceMarginRate": 8
    }
  },
  "serialId": 100
}
```

{% endtab %}

{% tab title="fundingInfos" %}
Update the funding rates to accumulated funding rates of the Global Vars for all position(contract pair) in this period

| Name          | Type                                                   | Required | Description                                                           |
| ------------- | ------------------------------------------------------ | -------- | --------------------------------------------------------------------- |
| infos         | array                                                  | yes      | funding info list                                                     |
| > pairId      | [PairId](/developer/api-and-sdk/basic-types.md#pairid) | yes      | The pair id                                                           |
| > price       | [BigUint](/developer/api-and-sdk/basic-types.md#price) | yes      | the mark price of the trade pair                                      |
| > fundingRate | i16                                                    | yes      | the fee funding rate, the actual result needs to be divided by `10^6` |

For example:

```json
{
  "type": "UpdateGlobalVar",
  "fromChainId": 1,
  "subAccountId": 1,
  "parameter": {
    "fundingInfos": {
      "infos": [
        {
          "pairId": 0,
          "price": "1000000000000000000",
          "fundingRate": 32767
        },
        {
          "pairId": 1,
          "price": "1000000000000000",
          "fundingRate": 0
        }
      ]
    }
  },
  "serialId": 100
}
```

{% endtab %}
{% endtabs %}


---

# 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.zk.link/developer/api-and-sdk/transaction/update_global_var.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.
