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 identifierstatus— 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
Quark Intent
When an activity was created from a plan, thequark_intent field contains the original intent:
| Field | Description |
|---|---|
id | Intent identifier |
mercator_version | Version of the Mercator engine used |
intent_type | The type of intent (e.g., "transfer") |
intent | The full intent parameters |
Activity lifecycle
failedif any execution revertedpendingif any execution is still pendingcompletedonly when all executions have succeeded
Executions
Each execution represents a single on-chain transaction within the activity:| Field | Description |
|---|---|
execution_type | "transaction" (quark execution) or "external" (exogenous execution) |
chain_id | The chain this execution occurred on |
transaction_hash | Hex-encoded transaction hash |
status | "pending", "executed", or "failed" |
executed_at | When the execution was confirmed |
reverted_at | When the execution reverted (if applicable) |
actions | List 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 timeobserved_values— What actually happened on-chain (populated after execution)
expected_values to observed_values lets you verify that the execution matched the plan.
Action Types
Each action’sexpected_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.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount supplied (in token base units) |
asset_symbol | string | Symbol of the asset (e.g., "USDC") |
chain_id | integer | Chain ID |
aave_pool | hex | Aave pool address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
AAVE_WITHDRAW
Withdraw assets from an Aave pool.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount withdrawn |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
aave_pool | hex | Aave pool address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
COMET_SUPPLY
Supply assets to a Compound Comet market.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount supplied |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
comet | address | Comet market address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
COMET_WITHDRAW
Withdraw assets from a Compound Comet market.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount withdrawn |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
comet | address | Comet market address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
COMET_BORROW
Borrow assets from a Compound Comet market.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount borrowed |
asset_symbol | string | Symbol of the borrowed asset |
chain_id | integer | Chain ID |
collateral_amounts | integer[] | Amounts of each collateral asset |
collateral_asset_symbols | string[] | Symbols of each collateral asset |
collateral_token_prices | decimal[] | Price of each collateral asset |
collateral_tokens | address[] | Contract address of each collateral asset |
comet | address | Comet market address |
price | decimal | Borrowed asset price |
token | address | Borrowed token contract address |
COMET_REPAY
Repay a Compound Comet borrow position.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount repaid |
asset_symbol | string | Symbol of the repaid asset |
chain_id | integer | Chain ID |
collateral_amounts | integer[] | Amounts of each collateral asset |
collateral_asset_symbols | string[] | Symbols of each collateral asset |
collateral_token_prices | decimal[] | Price of each collateral asset |
collateral_tokens | address[] | Contract address of each collateral asset |
comet | address | Comet market address |
price | decimal | Repaid asset price |
token | address | Repaid token contract address |
COMET_CLAIM_REWARDS
Claim Compound Comet rewards.
| Field | Type | Description |
|---|---|---|
amounts | integer[] | Amount of each reward token claimed |
asset_symbols | string[] | Symbol of each reward token |
chain_id | integer | Chain ID |
prices | decimal[] | Price of each reward token |
tokens | address[] | Contract address of each reward token |
MORPHO_BORROW
Borrow assets from a Morpho market.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount borrowed |
asset_symbol | string | Symbol of the borrowed asset |
chain_id | integer | Chain ID |
collateral_amount | integer | Amount of collateral |
collateral_asset_symbol | string | Symbol of the collateral asset |
collateral_token_price | decimal | Price of the collateral asset |
collateral_token | address | Collateral token contract address |
morpho | address | Morpho contract address |
morpho_market_id | hex | Morpho market identifier |
price | decimal | Borrowed asset price |
token | address | Borrowed token contract address |
MORPHO_REPAY
Repay a Morpho borrow position.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount repaid |
asset_symbol | string | Symbol of the repaid asset |
chain_id | integer | Chain ID |
collateral_amount | integer | Amount of collateral |
collateral_asset_symbol | string | Symbol of the collateral asset |
collateral_token_price | decimal | Price of the collateral asset |
collateral_token | address | Collateral token contract address |
morpho | address | Morpho contract address |
morpho_market_id | hex | Morpho market identifier |
price | decimal | Repaid asset price |
token | address | Repaid token contract address |
MORPHO_VAULT_SUPPLY
Supply assets to a Morpho vault.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount supplied |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
morpho_vault | address | Morpho vault address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
MORPHO_VAULT_WITHDRAW
Withdraw assets from a Morpho vault.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount withdrawn |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
morpho_vault | address | Morpho vault address |
price | decimal | Asset price at time of action |
token | address | Token contract address |
MORPHO_CLAIM_REWARDS
Claim Morpho rewards.
| Field | Type | Description |
|---|---|---|
amounts | integer[] | Amount of each reward token claimed |
asset_symbols | string[] | Symbol of each reward token |
chain_id | integer | Chain ID |
prices | decimal[] | Price of each reward token |
tokens | address[] | Contract address of each reward token |
Swapping
SWAP
Swap one token for another.
| Field | Type | Description |
|---|---|---|
chain_id | integer | Chain ID |
input_amount | integer | Amount of input token |
input_asset_symbol | string | Symbol of input asset |
input_token | address | Input token contract address |
input_token_price | decimal | Input token price |
output_amount | integer | Amount of output token |
output_asset_symbol | string | Symbol of output asset |
output_token | address | Output token contract address |
output_token_price | decimal | Output token price |
is_exact_out | boolean | Whether the output amount is exact |
fee_amount | integer? | Fee amount (if applicable) |
fee_asset_symbol | string? | Fee asset symbol |
fee_token | address? | Fee token address |
fee_token_price | decimal? | Fee token price |
fee_amounts | integer[]? | Multiple fee amounts |
fee_asset_symbols | string[]? | Multiple fee asset symbols |
fee_tokens | address[]? | Multiple fee token addresses |
fee_token_prices | decimal[]? | Multiple fee token prices |
fee_descriptions | string[]? | Descriptions for each fee |
is_buy | boolean? | Whether this is a buy order |
is_capped_max | boolean? | Whether input is capped at max balance |
use_filler | boolean? | Whether a filler is used for execution |
RECURRING_SWAP
Execute a recurring swap.
| Field | Type | Description |
|---|---|---|
chain_id | integer | Chain ID |
input_amount | integer | Amount of input token per swap |
input_asset_symbol | string | Symbol of input asset |
input_token | address | Input token contract address |
input_token_price | decimal | Input token price |
interval | integer | Time interval between swaps (seconds) |
is_exact_out | boolean | Whether the output amount is exact |
output_amount | integer | Amount of output token per swap |
output_asset_symbol | string | Symbol of output asset |
output_token | address | Output token contract address |
output_token_price | decimal | Output token price |
use_chainlink_data_stream | boolean? | Whether to use Chainlink data stream |
use_filler | boolean? | Whether a filler is used for execution |
QUOTE_PAY
Pay for a quoted price.
| Field | Type | Description |
|---|---|---|
amount | integer | Payment amount |
asset_symbol | string | Symbol of the payment asset |
chain_id | integer | Chain ID |
payee | address | Recipient address |
price | decimal | Asset price |
quote_id | hex | Quote identifier |
token | address | Payment token contract address |
Transfers & Bridging
TRANSFER
Transfer tokens to a recipient.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount transferred |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
price | decimal | Asset price at time of transfer |
recipient | address | Recipient address |
token | address | Token contract address |
INBOUND_TRANSFER
Receive tokens from a sender.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount received |
asset_symbol | string | Symbol of the asset |
chain_id | integer | Chain ID |
price | decimal | Asset price at time of transfer |
sender | address | Sender address |
recipient | address | Recipient address |
token | address | Token contract address |
BRIDGE
Initiate a cross-chain bridge.
| Field | Type | Description |
|---|---|---|
asset_symbol | string | Symbol of the bridged asset |
bridge_type | string | Bridge protocol used |
chain_id | integer | Source chain ID |
destination_chain_id | integer | Destination chain ID |
destination_asset_symbol | string | Symbol of the asset on the destination chain |
input_amount | integer | Amount sent |
output_amount | integer | Amount received on destination |
price | decimal | Asset price |
recipient | address | Recipient address on destination chain |
token | address | Source token contract address |
BRIDGE_MINT
Mint bridged tokens on the destination chain.
| Field | Type | Description |
|---|---|---|
asset_symbol | string | Symbol of the minted asset |
bridge_type | string | Bridge protocol used |
chain_id | integer | Destination chain ID |
source_chain_id | integer | Source chain ID |
input_amount | integer | Amount sent from source |
output_amount | integer | Amount minted |
max_fee | integer | Maximum bridge fee |
recipient | address | Recipient address |
token | address | Minted token contract address |
Leveraged Positions
LOOP_LONG
Open or increase a leveraged long position.
| Field | Type | Description |
|---|---|---|
backing_asset_symbol | string | Symbol of the backing (collateral) asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
max_swap_backing_amount | integer | Maximum backing amount to swap |
max_provided_backing_amount | integer | Maximum backing amount provided by user |
chain_id | integer | Chain ID |
is_increase | boolean | Whether this increases an existing position |
exposure_amount | integer | Amount of exposure asset |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
swap_venue | string | DEX used for the swap leg |
borrow_venue | string | Lending protocol used for the borrow leg |
borrow_market_id | hex | Market identifier for the borrow |
fee_amount | integer? | Fee amount |
fee_asset_symbol | string? | Fee asset symbol |
fee_token | address? | Fee token address |
fee_token_price | decimal? | Fee token price |
LOOP_SHORT
Open or increase a leveraged short position.
| Field | Type | Description |
|---|---|---|
backing_asset_symbol | string | Symbol of the backing asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
min_swap_backing_amount | integer | Minimum backing amount from swap |
provided_backing_amount | integer | Backing amount provided by user |
chain_id | integer | Chain ID |
is_increase | boolean | Whether this increases an existing position |
exposure_amount | integer | Amount of exposure asset |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
swap_venue | string | DEX used for the swap leg |
borrow_venue | string | Lending protocol used for the borrow leg |
borrow_market_id | hex | Market identifier for the borrow |
fee_amount | integer? | Fee amount |
fee_asset_symbol | string? | Fee asset symbol |
fee_token | address? | Fee token address |
fee_token_price | decimal? | Fee token price |
UNLOOP_LONG
Close or decrease a leveraged long position.
| Field | Type | Description |
|---|---|---|
backing_asset_symbol | string | Symbol of the backing asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
min_swap_backing_amount | integer | Minimum backing amount from swap |
backing_amount_to_exit | integer | Amount of backing to exit |
chain_id | integer | Chain ID |
exposure_amount | integer | Amount of exposure asset |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
swap_venue | string | DEX used for the swap leg |
borrow_venue | string | Lending protocol used for the repay leg |
borrow_market_id | hex | Market identifier for the borrow |
fee_amount | integer? | Fee amount |
fee_asset_symbol | string? | Fee asset symbol |
fee_token | address? | Fee token address |
fee_token_price | decimal? | Fee token price |
UNLOOP_SHORT
Close or decrease a leveraged short position.
| Field | Type | Description |
|---|---|---|
backing_asset_symbol | string | Symbol of the backing asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
max_swap_backing_amount | integer | Maximum backing amount to swap |
backing_amount_to_exit | integer | Amount of backing to exit |
chain_id | integer | Chain ID |
exposure_amount | integer | Amount of exposure asset |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
swap_venue | string | DEX used for the swap leg |
borrow_venue | string | Lending protocol used for the repay leg |
borrow_market_id | hex | Market identifier for the borrow |
fee_amount | integer? | Fee amount |
fee_asset_symbol | string? | Fee asset symbol |
fee_token | address? | Fee token address |
fee_token_price | decimal? | Fee token price |
ADD_BACKING_TOKEN
Add backing collateral to a leveraged position.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount of backing token added |
backing_asset_symbol | string | Symbol of the backing asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
chain_id | integer | Chain ID |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
borrow_venue | string | Lending protocol used |
borrow_market_id | hex | Market identifier |
is_short | boolean | Whether this is a short position |
WITHDRAW_BACKING_TOKEN
Withdraw backing collateral from a leveraged position.
| Field | Type | Description |
|---|---|---|
amount | integer | Amount of backing token withdrawn |
backing_asset_symbol | string | Symbol of the backing asset |
backing_token | address | Backing token contract address |
backing_token_price | decimal | Backing token price |
chain_id | integer | Chain ID |
exposure_asset_symbol | string | Symbol of the exposure asset |
exposure_token | address | Exposure token contract address |
exposure_token_price | decimal | Exposure token price |
borrow_venue | string | Lending protocol used |
borrow_market_id | hex | Market identifier |
is_short | boolean | Whether this is a short position |
WITHDRAW_AND_BORROW
Withdraw collateral and borrow in a single Compound Comet operation.
| Field | Type | Description |
|---|---|---|
borrow_amount | integer | Amount borrowed |
chain_id | integer | Chain ID |
collateral_amounts | integer[] | Amounts of each collateral asset |
collateral_asset_symbols | string[] | Symbols of each collateral asset |
collateral_token_prices | decimal[] | Price of each collateral asset |
collateral_tokens | address[] | Contract address of each collateral asset |
comet | address | Comet market address |
price | decimal | Borrowed asset price |
token | address | Borrowed token contract address |
withdraw_amount | integer | Amount of collateral withdrawn |
Token Operations
WRAP
Wrap a token (e.g., ETH to WETH).
| Field | Type | Description |
|---|---|---|
amount | integer | Amount wrapped |
chain_id | integer | Chain ID |
token | address | Wrapped token contract address |
from_asset_symbol | string | Symbol of the unwrapped asset |
to_asset_symbol | string | Symbol of the wrapped asset |
UNWRAP
Unwrap a token (e.g., WETH to ETH).
| Field | Type | Description |
|---|---|---|
amount | integer | Amount unwrapped |
chain_id | integer | Chain ID |
token | address | Wrapped token contract address |
from_asset_symbol | string | Symbol of the wrapped asset |
to_asset_symbol | string | Symbol 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
cursorvalue
Long-polling
Passpoll=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.
When to use which
| Use case | Recommended |
|---|---|
| Show transaction history | Activities |
| Wait for a specific transaction to confirm | Events (long-poll) |
| Build a real-time dashboard | Events (long-poll loop) |
| Debug a failed transaction | Activity (by ID) |
| Verify execution matched the plan | Activity actions (expected vs observed) |