Mirra
BuildEvents

Crypto Events

Crypto events fire when cryptocurrency price alerts trigger or transactions occur. These events provide token information, price data, and transaction details for both EVM and Solana chains.


Event Types

crypto.price_alert

The crypto.price_alert event fires when a cryptocurrency price alert is triggered based on your configured thresholds.

Event Type:

type: 'crypto.price_alert'
source: 'crypto'

Fields:

content.text (string)

Human-readable alert message.

crypto.tokenAddress (string)

Token contract address.

crypto.chain ('evm' | 'svm')

Blockchain network: 'evm' for Ethereum/EVM chains, 'svm' for Solana.

crypto.priceUsd (number)

Current token price in USD.

crypto.alertType ('above' | 'below' | 'change')

Type of alert that was triggered.

crypto.targetPrice (number)

Alert threshold price that triggered this event.

Example - Price Alert Notification:

export async function handler(event, context) {
  // Send Telegram notification
  const priceChange = ((event.crypto.priceUsd - event.crypto.targetPrice) / event.crypto.targetPrice * 100).toFixed(2);
  
  await mirra.telegram.sendMessage({
    chatId: 'your-chat-id',
    text: `🚨 Price Alert!\n\nToken: ${event.crypto.tokenAddress}\nChain: ${event.crypto.chain.toUpperCase()}\nCurrent: $${event.crypto.priceUsd}\nTarget: $${event.crypto.targetPrice}\nChange: ${priceChange}%`
  });
  
  return { success: true };
}

Example - Price Logger:

export async function handler(event, context) {
  // Log price alerts to spreadsheet
  await mirra.google.sheets.appendRow({
    spreadsheetId: 'your-sheet-id',
    sheetName: 'Price Alerts',
    values: [
      new Date().toISOString(),
      event.crypto.tokenAddress,
      event.crypto.chain,
      event.crypto.priceUsd,
      event.crypto.alertType,
      event.crypto.targetPrice
    ]
  });
  
  return { success: true };
}

Subscription Examples:

// All price alerts
{
  "eventType": "crypto.price_alert"
}
 
// Only alerts above threshold
{
  "eventType": "crypto.price_alert",
  "conditions": [
    {
      "field": "crypto.alertType",
      "operator": "equals",
      "value": "above"
    }
  ]
}
 
// High-value alerts only
{
  "eventType": "crypto.price_alert",
  "conditions": [
    {
      "field": "crypto.priceUsd",
      "operator": "greater_than",
      "value": 1000
    }
  ]
}

crypto.send_token

The crypto.send_token event fires when a token transfer is initiated.

Event Type:

type: 'crypto.send_token'
source: 'crypto'

Fields:

crypto.tokenAddress (string)

Token contract address being transferred.

crypto.chain ('evm' | 'svm')

Blockchain network.

crypto.amount (number)

Amount of tokens being transferred.

crypto.recipientAddress (string)

Recipient wallet address.

crypto.senderAddress (string)

Sender wallet address.

Example - Transfer Logger:

export async function handler(event, context) {
  // Log all token transfers
  await mirra.memory.create({
    type: 'token_transfer',
    content: `Sent ${event.crypto.amount} tokens to ${event.crypto.recipientAddress}`,
    metadata: {
      tokenAddress: event.crypto.tokenAddress,
      chain: event.crypto.chain,
      amount: event.crypto.amount,
      recipient: event.crypto.recipientAddress,
      timestamp: event.timestamp
    }
  });
  
  return { success: true };
}

jupiter.swap_token

The jupiter.swap_token event fires when a Jupiter swap is executed on Solana.

Event Type:

type: 'jupiter.swap_token'
source: 'crypto'

Fields:

crypto.inputMint (string)

Input token mint address (Solana).

crypto.outputMint (string)

Output token mint address (Solana).

crypto.inputAmount (number)

Amount of input tokens.

crypto.outputAmount (number)

Amount of output tokens received.

crypto.slippageBps (number)

Slippage tolerance in basis points.

Example - Swap Tracker:

export async function handler(event, context) {
  // Calculate effective price
  const rate = event.crypto.outputAmount / event.crypto.inputAmount;
  
  // Log swap
  await mirra.google.sheets.appendRow({
    spreadsheetId: 'swap-tracking-sheet',
    sheetName: 'Swaps',
    values: [
      new Date().toISOString(),
      event.crypto.inputMint,
      event.crypto.outputMint,
      event.crypto.inputAmount,
      event.crypto.outputAmount,
      rate.toFixed(6),
      event.crypto.slippageBps
    ]
  });
  
  return { success: true };
}

See Also

On this page