# 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()
```
