# Write

<details>

<summary>closeAllPositions</summary>

```solidity
closeAllPositions()
```

When called, all the existing positions of the `msg.sender` will be closed.

```solidity
emit PositionReduced
```

</details>

<details>

<summary>closePosition</summary>

```solidity
closePosition(uint32 positionIndex)
```

Closes the position at `positionIndex` in user's positions.

```solidity
emit PositionReduced
```

</details>

<details>

<summary>deposit</summary>

```solidity
deposit(LonsShort longShort, uint128 amount, Terms term)
```

Users can deposit Token (or native tokens) into a pool. Deposits will be added on the Long or Short side, for the specified `term`.

User is charged a `minimumFee` which corresponds to the daily fee accrued over 50% of the position term. User's position is therefore equal to: `amount - minimumFee`&#x20;

```solidity
emit Deposit
```

**Note**: if the deposit is executed after mid update interval time (e.g. if fixings are updated every 5 minutes, the mid update interval time is 2.5 minutes), the deposit will be added to the next fixing period ⇔ amounts will be pending until the current fixing period ends. This methodology has been implemented to avoid users passing orders at near period ends.

</details>

<details>

<summary>reducePosition</summary>

```solidity
reducePosition(uint32 positionIndex, uint128 amount) returns(bool hasBeenClosed)
```

Reduces the user's position at `positionIndex`, by the `amount` value.

If the `amount` is equal to position size, the position will be closed; method will return `hasBeenClosed = true`.

```solidity
emit PositionReduced
```

**Note**: if a user reduces a position before the minimum holding period, user will be subject to a penalty fee. Furthermore, if position is generating a profit, user will receive pro-rated profit only. These processes have been implemented to force users to remain in their positions until the agreed term(s); nevertheless, any user is free to close / reduce a position whenever he wants.

**Note 2**: the penalty fees and non-distributed profits remain on the pool for other users to benefit from. For example, if a Long user decides to reduce (or close) a position before the agreed term, the position remainder will be left on the Long side for Short users to benefit from it. *<mark style="color:red;">**1xMM is not earning penalty fees or non-distributed profits**</mark>*.

</details>
