# IUpdatePositionSizeUtils

*Interface for position size updates*

## PositionSizeUpdateInitiated

```solidity
event PositionSizeUpdateInitiated(struct ITradingStorage.Id orderId, address trader, uint256 pairIndex, uint256 index, bool isIncrease, uint256 collateralDelta, uint256 leverageDelta)
```

### Parameters

| Name            | Type                      | Description                                       |
| --------------- | ------------------------- | ------------------------------------------------- |
| orderId         | struct ITradingStorage.Id | request order id                                  |
| trader          | address                   | address of the trader                             |
| pairIndex       | uint256                   | index of the pair                                 |
| index           | uint256                   | index of user trades                              |
| isIncrease      | bool                      | true if increase position size, false if decrease |
| collateralDelta | uint256                   | collateral delta (collateral precision)           |
| leverageDelta   | uint256                   | leverage delta (1e3)                              |

## PositionSizeIncreaseExecuted

```solidity
event PositionSizeIncreaseExecuted(struct ITradingStorage.Id orderId, enum ITradingCallbacks.CancelReason cancelReason, uint8 collateralIndex, address trader, uint256 pairIndex, uint256 index, bool long, uint256 oraclePrice, uint256 collateralPriceUsd, uint256 collateralDelta, uint256 leverageDelta, struct IUpdatePositionSize.IncreasePositionSizeValues values)
```

### Parameters

| Name               | Type                                                  | Description                                                           |
| ------------------ | ----------------------------------------------------- | --------------------------------------------------------------------- |
| orderId            | struct ITradingStorage.Id                             | request order id                                                      |
| cancelReason       | enum ITradingCallbacks.CancelReason                   | cancel reason if canceled or none if executed                         |
| collateralIndex    | uint8                                                 | collateral index                                                      |
| trader             | address                                               | address of trader                                                     |
| pairIndex          | uint256                                               | index of pair                                                         |
| index              | uint256                                               | index of trade                                                        |
| long               | bool                                                  | true for long, false for short                                        |
| oraclePrice        | uint256                                               | oracle price (1e10)                                                   |
| collateralPriceUsd | uint256                                               | collateral price in USD (1e8)                                         |
| collateralDelta    | uint256                                               | collateral delta (collateral precision)                               |
| leverageDelta      | uint256                                               | leverage delta (1e3)                                                  |
| values             | struct IUpdatePositionSize.IncreasePositionSizeValues | important values (new open price, new leverage, new collateral, etc.) |

## PositionSizeDecreaseExecuted

```solidity
event PositionSizeDecreaseExecuted(struct ITradingStorage.Id orderId, enum ITradingCallbacks.CancelReason cancelReason, uint8 collateralIndex, address trader, uint256 pairIndex, uint256 index, bool long, uint256 oraclePrice, uint256 collateralPriceUsd, uint256 collateralDelta, uint256 leverageDelta, struct IUpdatePositionSize.DecreasePositionSizeValues values)
```

### Parameters

| Name               | Type                                                  | Description                                                |
| ------------------ | ----------------------------------------------------- | ---------------------------------------------------------- |
| orderId            | struct ITradingStorage.Id                             | request order id                                           |
| cancelReason       | enum ITradingCallbacks.CancelReason                   | cancel reason if canceled or none if executed              |
| collateralIndex    | uint8                                                 | collateral index                                           |
| trader             | address                                               | address of trader                                          |
| pairIndex          | uint256                                               | index of pair                                              |
| index              | uint256                                               | index of trade                                             |
| long               | bool                                                  | true for long, false for short                             |
| oraclePrice        | uint256                                               | oracle price (1e10)                                        |
| collateralPriceUsd | uint256                                               | collateral price in USD (1e8)                              |
| collateralDelta    | uint256                                               | collateral delta (collateral precision)                    |
| leverageDelta      | uint256                                               | leverage delta (1e3)                                       |
| values             | struct IUpdatePositionSize.DecreasePositionSizeValues | important values (pnl, new leverage, new collateral, etc.) |

## InvalidIncreasePositionSizeInput

```solidity
error InvalidIncreasePositionSizeInput()
```

## InvalidDecreasePositionSizeInput

```solidity
error InvalidDecreasePositionSizeInput()
```

## NewPositionSizeSmaller

```solidity
error NewPositionSizeSmaller()
```


---

# 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/contracts/interfaces/libraries/iupdatepositionsizeutils.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.
