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

# Backend Types

> Gains' backend return types

<Accordion title="TradeContainerBackend">
  ```typescript theme={null}
  type TradeContainerBackend {
    trade: TradeBackend;
    tradeInfo: TradeInfoBackend;
    initialAccFees: TradeInitialAccFeesBackend;
    liquidationParams: LiquidationParamsBackend;
  }
  ```
</Accordion>

<Accordion title="TradeBackend">
  ```typescript theme={null}
  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
  }
  ```
</Accordion>

<Accordion title="TradeInfoBackend">
  ```typescript theme={null}
  type TradeInfoBackend {
    createdBlock: string;
    tpLastUpdatedBlock: string;
    slLastUpdatedBlock: string;
    maxSlippageP: string; // 1e3
    lastOiUpdateTs: number;
    collateralPriceUsd: string; // 1e8
    contractsVersion: string;
    lastPosIncreaseBlock: string;
  }
  ```
</Accordion>

<Accordion title="TradeInitialAccFeesBackend">
  ```typescript theme={null}
  type TradeInitialAccFeesBackend {
    accPairFee: string; // 1e10
    accGroupFee: string; // 1e10
    block: string;
  }
  ```
</Accordion>

<Accordion title="LiquidationParamsBackend">
  ```typescript theme={null}
  type LiquidationParamsBackend {
    maxLiqSpreadP: string; // 1e12
    startLiqThresholdP: string; // 1e12
    endLiqThresholdP: string; // 1e12
    startLeverage: string; // 1e3
    endLeverage: string; // 1e3
  }
  ```
</Accordion>

<Accordion title="TradingGroupBackend">
  ```typescript theme={null}
  type TradingGroupBackend {
    name: string;
    minLeverage: string;
    maxLeverage: string;
  }
  ```
</Accordion>

<Accordion title="FeeBackend">
  ```typescript theme={null}
  type FeeBackend {
    totalPositionSizeFeeP: string; // 1e12
    totalLiqCollateralFeeP: string; // 1e12
    oraclePositionSizeFeeP: string; // 1e12
    minPositionSizeUsd: string; // 1e3, fee floor position size
  }
  ```
</Accordion>

<Accordion title="PairDepthBackend">
  ```typescript theme={null}
  type PairDepthBackend {
    onePercentDepthAboveUsd: string;
    onePercentDepthBelowUsd: string;
  }
  ```
</Accordion>

<Accordion title="PairParamsBorrowingFeesBackend">
  ```typescript theme={null}
  type PairParamsBorrowingFeesBackend {
    pairs: PairBorrowingFeesBackendPair[];
    groups: PairBorrowingFeesBackendGroup[];
  }
  ```
</Accordion>

<Accordion title="PairBackend">
  ```typescript theme={null}
  type PairBackend {
    from: string;
    to: string;
    spreadP: string; // 1e12
    groupIndex: string;
    feeIndex: string;
  }
  ```
</Accordion>

<Accordion title="GlobalTradingVariablesBackend">
  ```typescript theme={null}
  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[];
    };
  }
  ```
</Accordion>

<Accordion title="PairInfosBackend">
  ```typescript theme={null}
  type PairInfosBackend {
    maxLeverages: number[];
    pairDepths: PairDepthBackend[];
    pairFactors: PairFactorBackend[];
  }
  ```
</Accordion>

<Accordion title="TraderInfoBackend">
  ```typescript theme={null}
  type TraderInfoBackend = {
    lastDayUpdated: number;
    trailingPoints: string;
  }
  ```
</Accordion>

<Accordion title="UserTradingVariablesBackend">
  ```typescript theme={null}
  type UserTradingVariablesBackend {
    pendingMarketOrdersIds: number[];
    pendingMarketOrders: number[];
    feeTiers: TraderFeeTiersBackend;
    collaterals: Array<{ balance: string; allowance: string; decimals: number }>;
  }
  ```
</Accordion>

<Accordion title="PairOiBackend">
  ```typescript theme={null}
  type PairOiBackend = {
    oiLongUsd: string; // 1e18
    oiShortUsd: string; // 1e18
  }
  ```
</Accordion>

<Accordion title="OiWindowsBackend">
  ```typescript theme={null}
  type OiWindowsBackend = {
    [key: string]: PairOiBackend;
  }
  ```
</Accordion>

<Accordion title="OiWindowsSettingsBackend">
  ```typescript theme={null}
  type OiWindowsSettingsBackend = {
    startTs: number;
    windowsDuration: number;
    windowsCount: number;
  }
  ```
</Accordion>

<Accordion title="CollateralConfigBackend">
  ```typescript theme={null}
  type CollateralConfigBackend = {
    precision: string;
    precisionDelta: string;
    decimals: number;
  }
  ```
</Accordion>

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

<Accordion title="TraderFeeTiersBackend">
  ```typescript theme={null}
  type TraderFeeTiersBackend = {
    traderInfo: TraderInfoBackend;
    lastDayUpdatedPoints: string;
    inboundPoints: string; // 1e18
    outboundPoints: string; // 1e18
    expiredPoints: string[]; // 1e18
  }
  ```
</Accordion>

<Accordion title="PairFactorBackend">
  ```typescript theme={null}
  type PairFactorBackend = {
    cumulativeFactor: string; // 1e10
    protectionCloseFactor: string; // 1e10
    protectionCloseFactorBlocks: string;
  }
  ```
</Accordion>

<Accordion title="OpenInterestBackend">
  ```typescript theme={null}
  type OpenInterestBackend {
    long: string; // 1e10
    short: string; // 1e10
    max: string; // 1e10
  }
  ```
</Accordion>

<Accordion title="CollateralBackend">
  ```typescript theme={null}
  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;
  }
  ```
</Accordion>

<Accordion title="CollateralConfigBackend">
  ```typescript theme={null}
  type CollateralConfigBackend = {
    precision: string;
    precisionDelta: string;
    decimals: number;
  }
  ```
</Accordion>

<Accordion title="PairBorrowingFeesBackendPair">
  ```typescript theme={null}
  type PairBorrowingFeesBackendPair {
    oi: OpenInterestBackend;
    feePerBlock: string; // 1e10
    accFeeLong: string; // 1e10
    accFeeShort: string; // 1e10
    accLastUpdatedBlock: string;
    feeExponent: string;
    groups: PairBorrowingFeesBackendPairGroup[];
  }
  ```
</Accordion>

<Accordion title="PairBorrowingFeesBackendPairGroup">
  ```typescript theme={null}
  type PairBorrowingFeesBackendPairGroup {
    groupIndex: string;
    block: string;
    initialAccFeeLong: string; // 1e10
    initialAccFeeShort: string; // 1e10
    prevGroupAccFeeLong: string; // 1e10
    prevGroupAccFeeShort: string; // 1e10
    pairAccFeeLong: string; // 1e10
    pairAccFeeShort: string; // 1e10
  }
  ```
</Accordion>

<Accordion title="PairBorrowingFeesBackendGroup">
  ```typescript theme={null}
  type PairBorrowingFeesBackendGroup {
    oi: OpenInterestBackend;
    feePerBlock: string; // 1e10
    accFeeLong: string; // 1e10
    accFeeShort: string; // 1e10
    accLastUpdatedBlock: string;
    feeExponent: string;
  }
  ```
</Accordion>
