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

# Memo Strings

> Transaction memo format and encoding for Limora operations

Limora uses structured memo strings to encode transaction intent and parameters. This page documents the memo format for various operations.

***

## Overview

Memo strings are included in transaction data to specify the intended operation and its parameters. The protocol parses these memos to execute the correct logic.

<Note>
  Most users interact with Limora through the web interface, which automatically
  constructs the correct memo strings. This documentation is primarily for
  developers and advanced users building integrations.
</Note>

***

## Memo Format

All memo strings follow a structured format:

```
OPERATION:PARAM1:PARAM2:...:PARAMN
```

* **OPERATION**: The action to perform
* **PARAMS**: Colon-separated parameters specific to the operation

***

## Trade Operations

### Open Long Position

```
OPEN_LONG:PAIR:LEVERAGE:STOP_LOSS:TAKE_PROFIT
```

| Parameter    | Type   | Description                     |
| ------------ | ------ | ------------------------------- |
| PAIR         | string | Trading pair (e.g., "BTC-USDC") |
| LEVERAGE     | number | Leverage multiplier (2-50)      |
| STOP\_LOSS   | number | Stop-loss price (0 for none)    |
| TAKE\_PROFIT | number | Take-profit price (0 for none)  |

**Example:**

```
OPEN_LONG:BTC-USDC:10:45000:60000
```

Opens a 10x long BTC position with stop-loss at $45,000 and take-profit at $60,000.

***

### Open Short Position

```
OPEN_SHORT:PAIR:LEVERAGE:STOP_LOSS:TAKE_PROFIT
```

| Parameter    | Type   | Description                     |
| ------------ | ------ | ------------------------------- |
| PAIR         | string | Trading pair (e.g., "ETH-USDC") |
| LEVERAGE     | number | Leverage multiplier (2-50)      |
| STOP\_LOSS   | number | Stop-loss price (0 for none)    |
| TAKE\_PROFIT | number | Take-profit price (0 for none)  |

**Example:**

```
OPEN_SHORT:ETH-USDC:5:3500:2800
```

Opens a 5x short ETH position with stop-loss at $3,500 and take-profit at $2,800.

***

### Close Position

```
CLOSE_TRADE:TRADE_ID
```

| Parameter | Type   | Description                             |
| --------- | ------ | --------------------------------------- |
| TRADE\_ID | string | Unique identifier of the trade to close |

**Example:**

```
CLOSE_TRADE:0x1234567890abcdef
```

***

### Cancel Pending Trade

```
CANCEL_TRADE:TRADE_ID
```

| Parameter | Type   | Description                            |
| --------- | ------ | -------------------------------------- |
| TRADE\_ID | string | Unique identifier of the pending trade |

**Example:**

```
CANCEL_TRADE:0xabcdef1234567890
```

***

## Matching Operations

### Deposit to Match Pool

```
DEPOSIT_MATCH:TOKEN
```

| Parameter | Type   | Description                            |
| --------- | ------ | -------------------------------------- |
| TOKEN     | string | Token symbol to deposit (e.g., "USDC") |

**Example:**

```
DEPOSIT_MATCH:USDC
```

***

### Match a Trade

```
MATCH_TRADE:TRADE_ID
```

| Parameter | Type   | Description                             |
| --------- | ------ | --------------------------------------- |
| TRADE\_ID | string | Unique identifier of the trade to match |

**Example:**

```
MATCH_TRADE:0x1234567890abcdef
```

***

### Withdraw from Match Pool

```
WITHDRAW_MATCH:TOKEN:AMOUNT
```

| Parameter | Type   | Description                                     |
| --------- | ------ | ----------------------------------------------- |
| TOKEN     | string | Token symbol to withdraw                        |
| AMOUNT    | number | Amount to withdraw (use "MAX" for full balance) |

**Example:**

```
WITHDRAW_MATCH:USDC:1000
```

***

## Balance Operations

### Deposit Collateral

```
DEPOSIT:TOKEN
```

| Parameter | Type   | Description                  |
| --------- | ------ | ---------------------------- |
| TOKEN     | string | Token symbol being deposited |

**Example:**

```
DEPOSIT:USDC
```

***

### Withdraw Collateral

```
WITHDRAW:TOKEN:AMOUNT
```

| Parameter | Type   | Description              |
| --------- | ------ | ------------------------ |
| TOKEN     | string | Token symbol to withdraw |
| AMOUNT    | number | Amount to withdraw       |

**Example:**

```
WITHDRAW:USDC:500
```

***

## Encoding Rules

### Number Formatting

* Use decimal notation without thousands separators
* Maximum 18 decimal places for precision
* Use "0" for optional parameters that should be disabled

```
# Good
OPEN_LONG:BTC-USDC:10:45000.50:60000

# Bad
OPEN_LONG:BTC-USDC:10:45,000.50:$60,000
```

### String Formatting

* Use uppercase for operation names
* Use uppercase for token symbols
* Trading pairs use hyphen separator (e.g., "BTC-USDC")

### Special Values

| Value  | Meaning                            |
| ------ | ---------------------------------- |
| 0      | Disabled (for optional parameters) |
| MAX    | Maximum available amount           |
| MARKET | Current market price               |

***

## Error Handling

Invalid memo strings will cause transaction rejection. Common errors:

| Error                 | Cause                           |
| --------------------- | ------------------------------- |
| INVALID\_OPERATION    | Unknown operation type          |
| MISSING\_PARAM        | Required parameter not provided |
| INVALID\_PARAM        | Parameter value out of range    |
| INVALID\_PAIR         | Trading pair not supported      |
| INSUFFICIENT\_BALANCE | Not enough funds for operation  |

***

## Code Examples

### JavaScript/TypeScript

```typescript theme={null}
// Construct a memo for opening a long position
function buildOpenLongMemo(
  pair: string,
  leverage: number,
  stopLoss: number = 0,
  takeProfit: number = 0
): string {
  return `OPEN_LONG:${pair}:${leverage}:${stopLoss}:${takeProfit}`
}

// Example usage
const memo = buildOpenLongMemo('BTC-USDC', 10, 45000, 60000)
// Result: "OPEN_LONG:BTC-USDC:10:45000:60000"
```

### Python

```python theme={null}
def build_open_long_memo(
    pair: str,
    leverage: int,
    stop_loss: float = 0,
    take_profit: float = 0
) -> str:
    return f"OPEN_LONG:{pair}:{leverage}:{stop_loss}:{take_profit}"

# Example usage
memo = build_open_long_memo("BTC-USDC", 10, 45000, 60000)
# Result: "OPEN_LONG:BTC-USDC:10:45000:60000"
```

***

## Versioning

The memo format may be updated as the protocol evolves. Current version: **v1.0**

Future versions will maintain backward compatibility where possible. Breaking changes will be announced in advance through official channels.

***

<Card title="API Reference" icon="book" href="/api/reference">
  See the full API documentation for programmatic access.
</Card>
