Skip to main content

Activities & Events

After executing a plan, you’ll want to track its progress. Legend provides two complementary mechanisms.

Activities

Activities represent completed or in-progress on-chain operations. Each activity contains:
  • id — Unique activity identifier
  • status — Current state: "pending", "completed", or "failed"
  • quark_intent — The original intent that created this activity (if applicable)
  • executions — A list of on-chain executions that make up the activity
{
  "id": 42,
  "status": "completed",
  "quark_intent": {
    "id": 7,
    "mercator_version": "1.2.0",
    "intent_type": "transfer",
    "intent": {
      "amount": "1000000",
      "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "recipient": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
      "chain_id": 8453
    }
  },
  "executions": [
    {
      "execution_type": "transaction",
      "chain_id": 8453,
      "transaction_hash": "0xabc123...def456",
      "status": "executed",
      "executed_at": "2025-06-15T14:30:00Z",
      "reverted_at": null,
      "actions": [
        {
          "action_type": "TRANSFER",
          "expected_values": {
            "amount": 1000000,
            "asset_symbol": "USDC",
            "chain_id": 8453,
            "price": "0.9998",
            "recipient": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
            "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
          },
          "observed_values": {
            "amount": 1000000,
            "asset_symbol": "USDC",
            "chain_id": 8453,
            "price": "0.9998",
            "recipient": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
            "token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
          }
        }
      ]
    }
  ]
}
Use List Activities to see all activities, or Get Activity for a specific one.

Quark Intent

When an activity was created from a plan, the quark_intent field contains the original intent:
FieldDescription
idIntent identifier
mercator_versionVersion of the Mercator engine used
intent_typeThe type of intent (e.g., "transfer")
intentThe full intent parameters

Activity lifecycle

pending → completed    (all executions confirmed on-chain)
pending → failed       (any execution reverted)
An activity’s status is derived from its executions:
  • failed if any execution reverted
  • pending if any execution is still pending
  • completed only when all executions have succeeded

Executions

Each execution represents a single on-chain transaction within the activity:
FieldDescription
execution_type"transaction" (quark execution) or "external" (exogenous execution)
chain_idThe chain this execution occurred on
transaction_hashHex-encoded transaction hash
status"pending", "executed", or "failed"
executed_atWhen the execution was confirmed
reverted_atWhen the execution reverted (if applicable)
actionsList of expected and observed actions

Actions

Each execution contains a list of actions. Every action has:
  • action_type — The type of on-chain action (see below)
  • expected_values — What was intended at plan time
  • observed_values — What actually happened on-chain (populated after execution)
Comparing expected_values to observed_values lets you verify that the execution matched the plan.

Action Types

Each action’s expected_values and observed_values follow a schema determined by the action_type. The fields below describe the body for each type.

Lending & Borrowing

AAVE_SUPPLY

Supply assets to an Aave pool.
FieldTypeDescription
amountintegerAmount supplied (in token base units)
asset_symbolstringSymbol of the asset (e.g., "USDC")
chain_idintegerChain ID
aave_poolhexAave pool address
pricedecimalAsset price at time of action
tokenaddressToken contract address

AAVE_WITHDRAW

Withdraw assets from an Aave pool.
FieldTypeDescription
amountintegerAmount withdrawn
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
aave_poolhexAave pool address
pricedecimalAsset price at time of action
tokenaddressToken contract address

COMET_SUPPLY

Supply assets to a Compound Comet market.
FieldTypeDescription
amountintegerAmount supplied
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
cometaddressComet market address
pricedecimalAsset price at time of action
tokenaddressToken contract address

COMET_WITHDRAW

Withdraw assets from a Compound Comet market.
FieldTypeDescription
amountintegerAmount withdrawn
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
cometaddressComet market address
pricedecimalAsset price at time of action
tokenaddressToken contract address

COMET_BORROW

Borrow assets from a Compound Comet market.
FieldTypeDescription
amountintegerAmount borrowed
asset_symbolstringSymbol of the borrowed asset
chain_idintegerChain ID
collateral_amountsinteger[]Amounts of each collateral asset
collateral_asset_symbolsstring[]Symbols of each collateral asset
collateral_token_pricesdecimal[]Price of each collateral asset
collateral_tokensaddress[]Contract address of each collateral asset
cometaddressComet market address
pricedecimalBorrowed asset price
tokenaddressBorrowed token contract address

COMET_REPAY

Repay a Compound Comet borrow position.
FieldTypeDescription
amountintegerAmount repaid
asset_symbolstringSymbol of the repaid asset
chain_idintegerChain ID
collateral_amountsinteger[]Amounts of each collateral asset
collateral_asset_symbolsstring[]Symbols of each collateral asset
collateral_token_pricesdecimal[]Price of each collateral asset
collateral_tokensaddress[]Contract address of each collateral asset
cometaddressComet market address
pricedecimalRepaid asset price
tokenaddressRepaid token contract address

COMET_CLAIM_REWARDS

Claim Compound Comet rewards.
FieldTypeDescription
amountsinteger[]Amount of each reward token claimed
asset_symbolsstring[]Symbol of each reward token
chain_idintegerChain ID
pricesdecimal[]Price of each reward token
tokensaddress[]Contract address of each reward token

MORPHO_BORROW

Borrow assets from a Morpho market.
FieldTypeDescription
amountintegerAmount borrowed
asset_symbolstringSymbol of the borrowed asset
chain_idintegerChain ID
collateral_amountintegerAmount of collateral
collateral_asset_symbolstringSymbol of the collateral asset
collateral_token_pricedecimalPrice of the collateral asset
collateral_tokenaddressCollateral token contract address
morphoaddressMorpho contract address
morpho_market_idhexMorpho market identifier
pricedecimalBorrowed asset price
tokenaddressBorrowed token contract address

MORPHO_REPAY

Repay a Morpho borrow position.
FieldTypeDescription
amountintegerAmount repaid
asset_symbolstringSymbol of the repaid asset
chain_idintegerChain ID
collateral_amountintegerAmount of collateral
collateral_asset_symbolstringSymbol of the collateral asset
collateral_token_pricedecimalPrice of the collateral asset
collateral_tokenaddressCollateral token contract address
morphoaddressMorpho contract address
morpho_market_idhexMorpho market identifier
pricedecimalRepaid asset price
tokenaddressRepaid token contract address

MORPHO_VAULT_SUPPLY

Supply assets to a Morpho vault.
FieldTypeDescription
amountintegerAmount supplied
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
morpho_vaultaddressMorpho vault address
pricedecimalAsset price at time of action
tokenaddressToken contract address

MORPHO_VAULT_WITHDRAW

Withdraw assets from a Morpho vault.
FieldTypeDescription
amountintegerAmount withdrawn
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
morpho_vaultaddressMorpho vault address
pricedecimalAsset price at time of action
tokenaddressToken contract address

MORPHO_CLAIM_REWARDS

Claim Morpho rewards.
FieldTypeDescription
amountsinteger[]Amount of each reward token claimed
asset_symbolsstring[]Symbol of each reward token
chain_idintegerChain ID
pricesdecimal[]Price of each reward token
tokensaddress[]Contract address of each reward token

Swapping

SWAP

Swap one token for another.
FieldTypeDescription
chain_idintegerChain ID
input_amountintegerAmount of input token
input_asset_symbolstringSymbol of input asset
input_tokenaddressInput token contract address
input_token_pricedecimalInput token price
output_amountintegerAmount of output token
output_asset_symbolstringSymbol of output asset
output_tokenaddressOutput token contract address
output_token_pricedecimalOutput token price
is_exact_outbooleanWhether the output amount is exact
fee_amountinteger?Fee amount (if applicable)
fee_asset_symbolstring?Fee asset symbol
fee_tokenaddress?Fee token address
fee_token_pricedecimal?Fee token price
fee_amountsinteger[]?Multiple fee amounts
fee_asset_symbolsstring[]?Multiple fee asset symbols
fee_tokensaddress[]?Multiple fee token addresses
fee_token_pricesdecimal[]?Multiple fee token prices
fee_descriptionsstring[]?Descriptions for each fee
is_buyboolean?Whether this is a buy order
is_capped_maxboolean?Whether input is capped at max balance
use_fillerboolean?Whether a filler is used for execution

RECURRING_SWAP

Execute a recurring swap.
FieldTypeDescription
chain_idintegerChain ID
input_amountintegerAmount of input token per swap
input_asset_symbolstringSymbol of input asset
input_tokenaddressInput token contract address
input_token_pricedecimalInput token price
intervalintegerTime interval between swaps (seconds)
is_exact_outbooleanWhether the output amount is exact
output_amountintegerAmount of output token per swap
output_asset_symbolstringSymbol of output asset
output_tokenaddressOutput token contract address
output_token_pricedecimalOutput token price
use_chainlink_data_streamboolean?Whether to use Chainlink data stream
use_fillerboolean?Whether a filler is used for execution

QUOTE_PAY

Pay for a quoted price.
FieldTypeDescription
amountintegerPayment amount
asset_symbolstringSymbol of the payment asset
chain_idintegerChain ID
payeeaddressRecipient address
pricedecimalAsset price
quote_idhexQuote identifier
tokenaddressPayment token contract address

Transfers & Bridging

TRANSFER

Transfer tokens to a recipient.
FieldTypeDescription
amountintegerAmount transferred
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
pricedecimalAsset price at time of transfer
recipientaddressRecipient address
tokenaddressToken contract address

INBOUND_TRANSFER

Receive tokens from a sender.
FieldTypeDescription
amountintegerAmount received
asset_symbolstringSymbol of the asset
chain_idintegerChain ID
pricedecimalAsset price at time of transfer
senderaddressSender address
recipientaddressRecipient address
tokenaddressToken contract address

BRIDGE

Initiate a cross-chain bridge.
FieldTypeDescription
asset_symbolstringSymbol of the bridged asset
bridge_typestringBridge protocol used
chain_idintegerSource chain ID
destination_chain_idintegerDestination chain ID
destination_asset_symbolstringSymbol of the asset on the destination chain
input_amountintegerAmount sent
output_amountintegerAmount received on destination
pricedecimalAsset price
recipientaddressRecipient address on destination chain
tokenaddressSource token contract address

BRIDGE_MINT

Mint bridged tokens on the destination chain.
FieldTypeDescription
asset_symbolstringSymbol of the minted asset
bridge_typestringBridge protocol used
chain_idintegerDestination chain ID
source_chain_idintegerSource chain ID
input_amountintegerAmount sent from source
output_amountintegerAmount minted
max_feeintegerMaximum bridge fee
recipientaddressRecipient address
tokenaddressMinted token contract address

Leveraged Positions

LOOP_LONG

Open or increase a leveraged long position.
FieldTypeDescription
backing_asset_symbolstringSymbol of the backing (collateral) asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
max_swap_backing_amountintegerMaximum backing amount to swap
max_provided_backing_amountintegerMaximum backing amount provided by user
chain_idintegerChain ID
is_increasebooleanWhether this increases an existing position
exposure_amountintegerAmount of exposure asset
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
swap_venuestringDEX used for the swap leg
borrow_venuestringLending protocol used for the borrow leg
borrow_market_idhexMarket identifier for the borrow
fee_amountinteger?Fee amount
fee_asset_symbolstring?Fee asset symbol
fee_tokenaddress?Fee token address
fee_token_pricedecimal?Fee token price

LOOP_SHORT

Open or increase a leveraged short position.
FieldTypeDescription
backing_asset_symbolstringSymbol of the backing asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
min_swap_backing_amountintegerMinimum backing amount from swap
provided_backing_amountintegerBacking amount provided by user
chain_idintegerChain ID
is_increasebooleanWhether this increases an existing position
exposure_amountintegerAmount of exposure asset
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
swap_venuestringDEX used for the swap leg
borrow_venuestringLending protocol used for the borrow leg
borrow_market_idhexMarket identifier for the borrow
fee_amountinteger?Fee amount
fee_asset_symbolstring?Fee asset symbol
fee_tokenaddress?Fee token address
fee_token_pricedecimal?Fee token price

UNLOOP_LONG

Close or decrease a leveraged long position.
FieldTypeDescription
backing_asset_symbolstringSymbol of the backing asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
min_swap_backing_amountintegerMinimum backing amount from swap
backing_amount_to_exitintegerAmount of backing to exit
chain_idintegerChain ID
exposure_amountintegerAmount of exposure asset
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
swap_venuestringDEX used for the swap leg
borrow_venuestringLending protocol used for the repay leg
borrow_market_idhexMarket identifier for the borrow
fee_amountinteger?Fee amount
fee_asset_symbolstring?Fee asset symbol
fee_tokenaddress?Fee token address
fee_token_pricedecimal?Fee token price

UNLOOP_SHORT

Close or decrease a leveraged short position.
FieldTypeDescription
backing_asset_symbolstringSymbol of the backing asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
max_swap_backing_amountintegerMaximum backing amount to swap
backing_amount_to_exitintegerAmount of backing to exit
chain_idintegerChain ID
exposure_amountintegerAmount of exposure asset
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
swap_venuestringDEX used for the swap leg
borrow_venuestringLending protocol used for the repay leg
borrow_market_idhexMarket identifier for the borrow
fee_amountinteger?Fee amount
fee_asset_symbolstring?Fee asset symbol
fee_tokenaddress?Fee token address
fee_token_pricedecimal?Fee token price

ADD_BACKING_TOKEN

Add backing collateral to a leveraged position.
FieldTypeDescription
amountintegerAmount of backing token added
backing_asset_symbolstringSymbol of the backing asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
chain_idintegerChain ID
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
borrow_venuestringLending protocol used
borrow_market_idhexMarket identifier
is_shortbooleanWhether this is a short position

WITHDRAW_BACKING_TOKEN

Withdraw backing collateral from a leveraged position.
FieldTypeDescription
amountintegerAmount of backing token withdrawn
backing_asset_symbolstringSymbol of the backing asset
backing_tokenaddressBacking token contract address
backing_token_pricedecimalBacking token price
chain_idintegerChain ID
exposure_asset_symbolstringSymbol of the exposure asset
exposure_tokenaddressExposure token contract address
exposure_token_pricedecimalExposure token price
borrow_venuestringLending protocol used
borrow_market_idhexMarket identifier
is_shortbooleanWhether this is a short position

WITHDRAW_AND_BORROW

Withdraw collateral and borrow in a single Compound Comet operation.
FieldTypeDescription
borrow_amountintegerAmount borrowed
chain_idintegerChain ID
collateral_amountsinteger[]Amounts of each collateral asset
collateral_asset_symbolsstring[]Symbols of each collateral asset
collateral_token_pricesdecimal[]Price of each collateral asset
collateral_tokensaddress[]Contract address of each collateral asset
cometaddressComet market address
pricedecimalBorrowed asset price
tokenaddressBorrowed token contract address
withdraw_amountintegerAmount of collateral withdrawn

Token Operations

WRAP

Wrap a token (e.g., ETH to WETH).
FieldTypeDescription
amountintegerAmount wrapped
chain_idintegerChain ID
tokenaddressWrapped token contract address
from_asset_symbolstringSymbol of the unwrapped asset
to_asset_symbolstringSymbol of the wrapped asset

UNWRAP

Unwrap a token (e.g., WETH to ETH).
FieldTypeDescription
amountintegerAmount unwrapped
chain_idintegerChain ID
tokenaddressWrapped token contract address
from_asset_symbolstringSymbol of the wrapped asset
to_asset_symbolstringSymbol of the unwrapped asset

Events

Events provide a real-time stream of changes to a sub-account. Use them for:
  • Webhooks-style monitoring — Long-poll for updates instead of repeatedly fetching activities
  • Cursor-based pagination — Track where you left off with the cursor value

Long-polling

Pass poll=true to the Events endpoint and the request will hang until new events arrive (up to ~30 seconds). This is more efficient than polling activities on a timer.
GET /accounts/acc_xxx/events?since=0&poll=true
→ hangs until an event occurs
→ returns events + new cursor

When to use which

Use caseRecommended
Show transaction historyActivities
Wait for a specific transaction to confirmEvents (long-poll)
Build a real-time dashboardEvents (long-poll loop)
Debug a failed transactionActivity (by ID)
Verify execution matched the planActivity actions (expected vs observed)