# Backend Types

<details>

<summary>TradeContainerBackend</summary>

```typescript
type TradeContainerBackend {
  trade: TradeBackend;
  tradeInfo: TradeInfoBackend;
  initialAccFees: TradeInitialAccFeesBackend;
  liquidationParams: LiquidationParamsBackend;
}
```

</details>

<details>

<summary>TradeBackend</summary>

```typescript
type TradeBackend {
  user: string;
  index: string;
  pairIndex: string;
  leverage: string; // 1e3
  long: boolean;
  isOpen: boolean;
  collateralIndex: string;
  tradeType: string;
  collateralAmount: string; // collat decimals
  openPrice: string; // 1e10
  tp: string; // 1e10
  sl: string; // 1e10
}
```

</details>

<details>

<summary>TradeInfoBackend</summary>

```typescript
type TradeInfoBackend {
  createdBlock: string;
  tpLastUpdatedBlock: string;
  slLastUpdatedBlock: string;
  maxSlippageP: string; // 1e3
  lastOiUpdateTs: number;
  collateralPriceUsd: string; // 1e8
  contractsVersion: string;
  lastPosIncreaseBlock: string;
}
```

</details>

<details>

<summary>TradeInitialAccFeesBackend</summary>

```typescript
type TradeInitialAccFeesBackend {
  accPairFee: string; // 1e10
  accGroupFee: string; // 1e10
  block: string;
}
```

</details>

<details>

<summary>LiquidationParamsBackend</summary>

```typescript
type LiquidationParamsBackend {
  maxLiqSpreadP: string; // 1e12
  startLiqThresholdP: string; // 1e12
  endLiqThresholdP: string; // 1e12
  startLeverage: string; // 1e3
  endLeverage: string; // 1e3
}
```

</details>

<details>

<summary>TradingGroupBackend</summary>

```typescript
type TradingGroupBackend {
  name: string;
  minLeverage: string;
  maxLeverage: string;
}
```

</details>

<details>

<summary>FeeBackend</summary>

```typescript
type FeeBackend {
  totalPositionSizeFeeP: string; // 1e12
  totalLiqCollateralFeeP: string; // 1e12
  oraclePositionSizeFeeP: string; // 1e12
  minPositionSizeUsd: string; // 1e3
}
```

</details>

<details>

<summary>PairDepthBackend</summary>

```typescript
type PairDepthBackend {
  onePercentDepthAboveUsd: string;
  onePercentDepthBelowUsd: string;
}
```

</details>

<details>

<summary>PairParamsBorrowingFeesBackend</summary>

```typescript
type PairParamsBorrowingFeesBackend {
  pairs: PairBorrowingFeesBackendPair[];
  groups: PairBorrowingFeesBackendGroup[];
}
```

</details>

<details>

<summary>PairBackend</summary>

```typescript
type PairBackend {
  from: string;
  to: string;
  spreadP: string; // 1e12
  groupIndex: string;
  feeIndex: string;
}
```

</details>

<details>

<summary>GlobalTradingVariablesBackend</summary>

```typescript
type GlobalTradingVariablesBackend {
  lastRefreshed: string;
  refreshId: number;
  tradingState: number;
  maxGainP: number;
  marketOrdersTimeoutBlocks: number;
  pairs: PairBackend[];
  groups: TradingGroupBackend[];
  fees: FeeBackend[];
  pairInfos: PairInfosBackend;
  collaterals: CollateralBackend[];
  sssTokenBalance: string;
  sssLegacyTokenBalance: string;
  sssRewardTokens: string[];
  vaultClosingFeeP: string;
  maxNegativePnlOnOpenP: number;
  blockConfirmations: number;
  oiWindowsSettings: OiWindowsSettingsBackend;
  oiWindows: OiWindowsBackend[];
  feeTiers: FeeTiersBackend;
  allTrades: TradeContainerBackend[];
  currentBlock: number;
  currentL1Block: number;
  isForexOpen: boolean;
  isStocksOpen: boolean;
  isIndicesOpen: boolean;
  isCommoditiesOpen: boolean;
  liquidationParams: {
    groups: LiquidationParamsBackend[];
    pairs: LiquidationParamsBackend[];
  };
}
```

</details>

<details>

<summary>PairInfosBackend</summary>

```typescript
type PairInfosBackend {
  maxLeverages: number[];
  pairDepths: PairDepthBackend[];
  pairFactors: PairFactorBackend[];
}
```

</details>

<details>

<summary>TraderInfoBackend</summary>

```typescript
type TraderInfoBackend = {
  lastDayUpdated: number;
  trailingPoints: string;
}
```

</details>

<details>

<summary>UserTradingVariablesBackend</summary>

```typescript
type UserTradingVariablesBackend {
  pendingMarketOrdersIds: number[];
  pendingMarketOrders: number[];
  feeTiers: TraderFeeTiersBackend;
  collaterals: Array<{ balance: string; allowance: string; decimals: number }>;
}
```

</details>

<details>

<summary>PairOiBackend</summary>

```typescript
type PairOiBackend = {
  oiLongUsd: string; // 1e18
  oiShortUsd: string; // 1e18
}
```

</details>

<details>

<summary>OiWindowsBackend</summary>

```typescript
type OiWindowsBackend = {
  [key: string]: PairOiBackend;
}
```

</details>

<details>

<summary>OiWindowsSettingsBackend</summary>

```typescript
type OiWindowsSettingsBackend = {
  startTs: number;
  windowsDuration: number;
  windowsCount: number;
}
```

</details>

<details>

<summary>CollateralConfigBackend</summary>

```typescript
type CollateralConfigBackend = {
  precision: string;
  precisionDelta: string;
  decimals: number;
}
```

</details>

<details>

<summary>FeeTiersBackend</summary>

```typescript
type FeeTiersBackend = {
  tiers: Array<{ feeMultiplier: string; pointsThreshold: string }>; // 1e3, 1
  multipliers: string[]; // 1e3
  currentDay: number;
}
```

</details>

<details>

<summary>TraderFeeTiersBackend</summary>

```typescript
type TraderFeeTiersBackend = {
  traderInfo: TraderInfoBackend;
  lastDayUpdatedPoints: string;
  inboundPoints: string; // 1e18
  outboundPoints: string; // 1e18
  expiredPoints: string[]; // 1e18
}
```

</details>

<details>

<summary>PairFactorBackend</summary>

```typescript
type PairFactorBackend = {
  cumulativeFactor: string; // 1e10
  protectionCloseFactor: string; // 1e10
  protectionCloseFactorBlocks: string;
}
```

</details>

<details>

<summary>OpenInterestBackend</summary>

```typescript
type OpenInterestBackend {
  long: string; // 1e10
  short: string; // 1e10
  max: string; // 1e10
}
```

</details>

<details>

<summary>CollateralBackend</summary>

```typescript
type CollateralBackend {
  collateralIndex: number;
  collateral: string;
  symbol: string;
  isActive: boolean;
  prices: TokenPrices;
  collateralConfig: CollateralConfigBackend;
  gToken: {
    address: string;
    currentBalanceCollateral: string;
    maxBalanceCollateral: string;
    marketCap: string;
  };
  borrowingFees: PairParamsBorrowingFeesBackend;
}
```

</details>

<details>

<summary>CollateralConfigBackend</summary>

```typescript
type CollateralConfigBackend = {
  precision: string;
  precisionDelta: string;
  decimals: number;
}
```

</details>

<details>

<summary>PairBorrowingFeesBackendPair</summary>

```typescript
type PairBorrowingFeesBackendPair {
  oi: OpenInterestBackend;
  feePerBlock: string; // 1e10
  accFeeLong: string; // 1e10
  accFeeShort: string; // 1e10
  accLastUpdatedBlock: string;
  feeExponent: string;
  groups: PairBorrowingFeesBackendPairGroup[];
}
```

</details>

<details>

<summary>PairBorrowingFeesBackendPairGroup</summary>

```typescript
type PairBorrowingFeesBackendPairGroup {
  groupIndex: string;
  block: string;
  initialAccFeeLong: string; // 1e10
  initialAccFeeShort: string; // 1e10
  prevGroupAccFeeLong: string; // 1e10
  prevGroupAccFeeShort: string; // 1e10
  pairAccFeeLong: string; // 1e10
  pairAccFeeShort: string; // 1e10
}
```

</details>

<details>

<summary>PairBorrowingFeesBackendGroup</summary>

```typescript
type PairBorrowingFeesBackendGroup {
  oi: OpenInterestBackend;
  feePerBlock: string; // 1e10
  accFeeLong: string; // 1e10
  accFeeShort: string; // 1e10
  accLastUpdatedBlock: string;
  feeExponent: string;
}
```

</details>


---

# 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.gains.trade/developer/technical-reference/backend/backend-types.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.
