Skip to content

Jupiter Limit Orders (Solana) #172

@premiumjibles

Description

@premiumjibles

Summary

Extend limit order functionality to Solana using Jupiter's Limit Order API. EOA compatible.

Background

SS-5290 implemented limit orders for EVM chains via CoW Protocol. This ticket adds Solana support via Jupiter, completing multi-chain limit order coverage.

Jupiter's limit order system works differently from CoW:

  • Orders are on-chain (not off-chain like CoW)
  • Requires transaction to create/cancel (small SOL fee)
  • Executed by Jupiter's keeper network

Third-Party API

User Flow

User: "Set a limit order to buy SOL at $180 on Solana"

Agent: "I'll create a limit order on Jupiter:

📋 Limit Order (Solana)
• Buy: SOL
• Price: $180 or below
• Spend: USDC
• Amount: How much USDC?"

User: "$500"

Agent: [Creates Jupiter limit order]

"✅ Limit order created on Solana!

Buy SOL at $180
Spending: 500 USDC
Expected: ~2.78 SOL

Track your order: [Jupiter Link]

Note: Creating this order cost ~0.01 SOL in fees."

Tool Schema

// Extend existing limit order schema to support Solana
const createLimitOrderSchema = z.object({
  sellAsset: assetInputSchema,
  buyAsset: assetInputSchema,
  sellAmount: z.string(),
  limitPrice: z.string(),
  expirationHours: z.number().optional().default(168),
  // Provider auto-selected based on network
})

// Jupiter-specific create order
interface JupiterLimitOrderParams {
  inputMint: string      // Token to sell
  outputMint: string     // Token to buy
  inAmount: string       // Amount in base units
  outAmount: string      // Minimum output amount
  expiredAt: number | null  // Unix timestamp or null for no expiry
}

Tool Output

interface CreateLimitOrderOutput {
  success: boolean
  orderId: string
  orderUrl: string
  provider: 'cow' | 'jupiter'  // Now includes jupiter
  summary: {
    sellAsset: { symbol: string; amount: string; network: string }
    buyAsset: { symbol: string; estimatedAmount: string; network: string }
    limitPrice: string
    expiresAt: string
  }
  // Jupiter-specific
  createOrderTx?: TransactionData  // Jupiter requires on-chain tx
}

Implementation Notes

  1. Provider Selection: Auto-select based on network

    • EVM chains → CoW Protocol
    • Solana → Jupiter
  2. Key Differences from CoW:

    • Jupiter orders are on-chain (require tx to create)
    • Cancellation also requires tx
    • No EIP-712 signing, just regular Solana transaction
  3. Jupiter API Flow:

    // 1. Create order
    POST https://api.jup.ag/limit/v2/createOrder
    
    // 2. Get orders for user
    GET https://api.jup.ag/limit/v2/openOrders?wallet={address}
    
    // 3. Cancel order
    POST https://api.jup.ag/limit/v2/cancelOrders

Acceptance Criteria

  • User can create limit orders on Solana via Jupiter
  • Orders appear in "get limit orders" alongside CoW orders
  • User can cancel Jupiter orders
  • Provider auto-selected based on asset network
  • UI shows appropriate status for Jupiter orders
  • Fees displayed clearly (Jupiter charges small SOL fee)

Dependencies

  • SS-5290: Limit Order Tool (extend existing implementation)
  • Solana wallet connection (already exists)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions