Skip to main content

Memo Strings

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.
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.

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
ParameterTypeDescription
PAIRstringTrading pair (e.g., “BTC-USDC”)
LEVERAGEnumberLeverage multiplier (2-100)
STOP_LOSSnumberStop-loss price (0 for none)
TAKE_PROFITnumberTake-profit price (0 for none)
Example:
OPEN_LONG:BTC-USDC:10:45000:60000
Opens a 10x long BTC position with stop-loss at 45,000andtakeprofitat45,000 and take-profit at 60,000.

Open Short Position

OPEN_SHORT:PAIR:LEVERAGE:STOP_LOSS:TAKE_PROFIT
ParameterTypeDescription
PAIRstringTrading pair (e.g., “ETH-USDC”)
LEVERAGEnumberLeverage multiplier (2-100)
STOP_LOSSnumberStop-loss price (0 for none)
TAKE_PROFITnumberTake-profit price (0 for none)
Example:
OPEN_SHORT:ETH-USDC:5:3500:2800
Opens a 5x short ETH position with stop-loss at 3,500andtakeprofitat3,500 and take-profit at 2,800.

Close Position

CLOSE_TRADE:TRADE_ID
ParameterTypeDescription
TRADE_IDstringUnique identifier of the trade to close
Example:
CLOSE_TRADE:0x1234567890abcdef

Cancel Pending Trade

CANCEL_TRADE:TRADE_ID
ParameterTypeDescription
TRADE_IDstringUnique identifier of the pending trade
Example:
CANCEL_TRADE:0xabcdef1234567890

Matching Operations

Deposit to Match Pool

DEPOSIT_MATCH:TOKEN
ParameterTypeDescription
TOKENstringToken symbol to deposit (e.g., “USDC”)
Example:
DEPOSIT_MATCH:USDC

Match a Trade

MATCH_TRADE:TRADE_ID
ParameterTypeDescription
TRADE_IDstringUnique identifier of the trade to match
Example:
MATCH_TRADE:0x1234567890abcdef

Withdraw from Match Pool

WITHDRAW_MATCH:TOKEN:AMOUNT
ParameterTypeDescription
TOKENstringToken symbol to withdraw
AMOUNTnumberAmount to withdraw (use “MAX” for full balance)
Example:
WITHDRAW_MATCH:USDC:1000

Balance Operations

Deposit Collateral

DEPOSIT:TOKEN
ParameterTypeDescription
TOKENstringToken symbol being deposited
Example:
DEPOSIT:USDC

Withdraw Collateral

WITHDRAW:TOKEN:AMOUNT
ParameterTypeDescription
TOKENstringToken symbol to withdraw
AMOUNTnumberAmount 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

ValueMeaning
0Disabled (for optional parameters)
MAXMaximum available amount
MARKETCurrent market price

Error Handling

Invalid memo strings will cause transaction rejection. Common errors:
ErrorCause
INVALID_OPERATIONUnknown operation type
MISSING_PARAMRequired parameter not provided
INVALID_PARAMParameter value out of range
INVALID_PAIRTrading pair not supported
INSUFFICIENT_BALANCENot enough funds for operation

Code Examples

JavaScript/TypeScript

// 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

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.

API Reference

See the full API documentation for programmatic access.