Overview
The perps functionality allows you to:- Discover the trading venues (providers) and the markets each offers, with live mark and oracle prices, funding rates, leverage ranges and fees
- Fund a trading account with collateral and complete any one-time venue approvals the API requires
- Open leveraged long or short positions and close them to realize PnL
- Manage risk with stop-loss / take-profit orders, and adjust leverage, margin and resting orders
- Track positions, orders and account balances, and a unified feed of trading activity and lifecycle events
https://api.portalhq.io/api/v3/clients/me/integrations/yield-xyz-perps and return { "data": ... }. Venues are identified by an opaque providerId (for example hyperliquid); real chains, where they appear, use CAIP-2 (eip155:42161 for Arbitrum).
This guide uses Hyperliquid as the example venue, since it is the launch venue. Everything here is driven by the Yield.xyz Perps API, not hard-coded to Hyperliquid: a venue’s supported actions, required approvals and per-action
args come from GET /providers (supportedActions and argumentSchemas), and how you sign each transaction is dictated by the signingFormat the API returns on that transaction — not by which venue it is. Discover a venue’s capabilities from the API and drive your integration from that, so a venue Yield.xyz adds later works with no code change.Prerequisites
Before using perps operations, ensure you have:- A properly initialized Portal client (see Create a client)
- An active wallet with gas on the funding chain (see Create a wallet)
- Yield.xyz integration enabled in your Portal Dashboard (see Yield.xyz Perps)
- Collateral (USDC) to fund the trading account — see Funding a trading account below
Discovering venues
Use theGET /providers endpoint to list the trading venues, the actions each supports, and the argument schema for each action.
id (a venue slug such as hyperliquid, used unchanged as providerId everywhere else), a supportedActions list, and argumentSchemas — a JSON Schema per action describing the exact args that action accepts. Treat argumentSchemas as the source of truth for what each action needs on a given venue. Use GET /providers/{providerId} for one venue.
Discovering markets
Use theGET /markets endpoint to list tradable instruments. Filter by providerId, and sort with sortBy (volume24h, markPrice or priceChangePercent24h) and order (asc / desc).
baseAsset / quoteAsset, leverageRange ([min, max]), supportedMarginModes (isolated / cross), markPrice, oraclePrice, priceChangePercent24h, fundingRate with fundingRateIntervalHours, makerFee / takerFee, openInterest and minSize. Treat market ids as opaque values returned by GET /markets (for example hyperliquid-eth-usdc); do not build them yourself. Use GET /markets/{marketId} for one market.
For a price chart, GET /markets/{marketId}/candles returns OHLCV candles. It requires an interval (for example 1h) and a from timestamp (unix milliseconds), with an optional to:
Funding a trading account and approving the venue
A perps venue holds collateral in a trading account that is separate from the user’s on-chain wallet balance. Before a user can open a position, you fund that account and complete any one-time approvals the venue requires. Both arePOST /actions actions that follow the same build → sign → submit flow as any other action; which approvals a venue needs is declared in its supportedActions from GET /providers.
Fund the account
Thefund action moves collateral into the trading account. fundingMethod selects how the venue routes the deposit — the values a venue accepts come from its argumentSchemas; the example below uses bridge2 (bridging USDC from Arbitrum), and lifi routes from another token or chain. args.fromToken.network is a real chain, so it uses CAIP-2.
fund action returns an on-chain EVM_TRANSACTION (its network is CAIP-2). Sign it with the EVM transaction flow below.
A
fund action reaches SUCCESS when the source-chain transaction confirms — not when the collateral lands on the venue. The bridge leg settles afterward, so the deposit can credit minutes later. Poll POST /balances until availableBalance reflects the deposit before you show a funded state. Indicative latencies: Arbitrum USDC via bridge2 under a minute; Ethereum via lifi seconds; Base, Polygon, Avalanche, Optimism and Monad via lifi about 20 minutes. These are indicative, not guarantees.Complete venue approvals
A venue declares any one-time approvals it needs in itssupportedActions. Hyperliquid, for example, places orders through an agent wallet that the user authorizes once with approveAgent, and may require a one-time approveBuilderFee. Build whichever approval actions the venue you are integrating lists, using the args from its argumentSchemas.
Funding and venue approvals are one-time prerequisites, not part of every trade. Once the account is funded and any required approvals complete, subsequent
open / close actions do not repeat them. Read the account’s collateral back at any time with POST /balances.Funding sources and limits
Funding, withdrawals and order sizes route through the venue, so their supported chains and minimums are the venue’s, not Portal’s. On Hyperliquid:- Fund sources are EVM chains only. USDC on Arbitrum funds via
bridge2; other EVM chains and native tokens route vialifi. Solana and Tron are not supported fund sources — Hyperliquid has no USDC deposit route from them, so the Yield.xyz Perps API rejects afundfrom either with400 EXECUTE_INVALID_ARGUMENT. - Withdrawals return USDC on Arbitrum only, to the signing address, with a flat $1 fee and a 2 USDC minimum.
bridge2deposits below 5 USDC are not credited and are lost. Enforce the 5 USDC floor before you build afundaction.- Orders have a $10 minimum notional; a smaller
openis rejected by the venue.
GET /providers rather than hard-coding them.
Opening a position
Opening a position usesPOST /actions with "action": "open". You’ll then sign each transaction it returns and submit it back.
Step 1: Create the open action
Take note of
data.id (the action id) and each transaction’s id, and show summary (direction, size, leverage, collateral, estimatedLiquidationPrice) to the user before they sign. An action can contain several transactions, which you sign and submit in order. Perps adds no trading guardrails, so any confirmation or liquidation warning is your UI’s responsibility.Step 2: Sign the transaction
How you sign a transaction is dictated by itssigningFormat, not by the venue — always sign by the format the API returns on the transaction. Hyperliquid, for example, returns EIP712_TYPED_DATA for orders and EVM_TRANSACTION for on-chain legs (funding, withdrawals, some approvals). See Signing by format for the full mapping.
Signing EIP-712 typed data
AnEIP712_TYPED_DATA transaction is signed off-chain, not broadcast on-chain. It carries:
signablePayload— the EIP-712 typed-data structure (domain,primaryType,message) to hash and signrawPayload— the venue order the signature authorizeschainId— the EIP-712 domain chain id, kept exactly as returned
-
Compute the EIP-712 digest of
signablePayloadusing any standard EIP-712 implementation. Portal returnssignablePayloadandrawPayloadbyte-for-byte, so you can independently recompute the venue’sconnectionIdfrom them and verify the order before signing. -
Raw-sign the digest with the Enclave MPC API.
POST /v1/raw/sign/SECP256K1signs a raw hex digest (without the leading0x) and returns the signature.The response is{ "data": "[signatureHexWithout0x]" }. -
Submit the signature with Step 3, as
signedPayload. Yield.xyz combines it with the order and forwards it to the venue.
Signing EVM transactions
AnEVM_TRANSACTION (funding, withdrawal, on-chain approval) works like any Ethereum transaction. signablePayload is a JSON string of the unsigned transaction; parse it and pass the fields to the Enclave MPC API eth_sendTransaction method, which signs and broadcasts, returning the transaction hash.
Step 3: Submit the signed transaction
Report the result to Yield.xyz withPOST /transactions/{transactionId}/submit. Submit the signedPayload (for EIP-712 orders and for transactions you signed but did not broadcast), or the transactionHash (for EVM_TRANSACTION legs you broadcast with eth_sendTransaction). A signedPayload submission must include actionId (the data.id from Step 1); a transactionHash submission does not. For an EIP-712 order, Portal uses it to verify the signature recovers to the account the action was built for before forwarding, and rejects a mismatched (PERPS_SIGNATURE_ADDRESS_MISMATCH), unrecoverable (PERPS_SIGNATURE_INVALID), or unhashable (PERPS_SIGNATURE_UNVERIFIABLE) signature instead of letting the venue silently strand it.
status, an explorer link, and — on some venues — a details object with venue-specific fill information.
Step 4: Track the action
Sign and submit every transaction in the action’stransactions array, in order, waiting for each to confirm. There is no separate step endpoint: poll GET /actions/{id} to watch progress and to pick up any further transactions the venue adds. A status of WAITING_FOR_NEXT means the action is waiting on a submitted transaction before it can continue; the action is complete when status is SUCCESS.
Checking positions, orders and balances
Read a user’s portfolio with the threePOST endpoints. Each takes a body with an address and at least one of providerId or providerIds (balances accepts a single venue only).
POST /orders returns resting limit and trigger orders; POST /balances returns the trading account’s accountValue, usedMargin, availableBalance and unrealizedPnl. Each position and order lists pendingActions — the actions currently available for it, with pre-filled args you can pass straight to POST /actions.
Managing a position
Every management action follows the same build → sign → submit → track flow asopen. The core walkthrough above applies unchanged; only action and args differ. The exact args per action are described by each venue’s argumentSchemas from GET /providers/{providerId}.
Closing a position and withdrawing
Close a position with"action": "close", then withdraw collateral from the trading account with "action": "withdraw". Both follow the same sign → submit → track flow.
Activity and events
List a user’s past actions withGET /actions?address=0xYourAddress (filter by providerId, marketId, type or status).
For venue-side outcomes that are not actions your user initiated — order fills, liquidations, stop-loss / take-profit triggers — use the events feed:
eventType (order_filled, liquidation, stop_loss_triggered, take_profit_triggered), an occurredAt timestamp and the order it concerns. Filter with eventType(s), marketId, perpActionId or fromDate / toDate. GET /activity returns a single unified feed interleaving your user’s actions and these events, newest first — convenient for a combined trade-history view.
Transaction processing
A perps action can require one or more transactions, and different venues sign in different formats. Sign each transaction by itssigningFormat:
Signing by format
EIP712_TYPED_DATA and EVM_TRANSACTION cover Hyperliquid (orders and on-chain funding legs respectively). The other formats appear only on venues that use those chains; the principle is the same — sign by the declared format and submit the signature or the broadcast hash.
Handling errors
Yield.xyz Perps errors are returned as Portal errors:400: invalid request (the message names the field), an unsupported chain id, a precondition the venue rejected (for example insufficient margin), a request Yield.xyz rejected (its message is passed through), or a Yield.xyz API key that is missing or was rejected. When the venue returns a machine-readable code, Portal surfaces it asdetails.code404: unknown market, venue, action, event or transaction id429: Yield.xyz rate limit hit; back off and retry503: Yield.xyz is unreachable or failed upstream500withid: INTEGRATION_RESPONSE_SCHEMA_DRIFT: Yield.xyz changed a response shape and Portal did not forward it. Treat it as a temporary outage of that feature; see Error codes
Best practices
- Show the
summary(direction,size,leverage,collateral,estimatedLiquidationPrice) before the user signs — Portal adds no trading guardrails - Fund and approve first: a position cannot open until the trading account has collateral and any venue-required approvals are complete (on Hyperliquid, the agent wallet)
- Sign each transaction by its
signingFormatand submit the signature or broadcast hash it expects - Process transactions sequentially and poll
GET /actions/{id}until the action reachesSUCCESS - Verify EIP-712 orders by recomputing the venue
connectionIdfrom the byte-for-bytesignablePayloadbefore signing - Handle
INTEGRATION_RESPONSE_SCHEMA_DRIFTas a feature outage rather than a user error - Keep gas on the wallet for the on-chain funding and withdrawal legs
Supported venues
Perps launches on Hyperliquid; the exact list of live venues is returned byGET /providers. Use the providerId values that endpoint returns rather than a fixed list — a venue Yield.xyz adds later needs no code change on your side. On-chain funding and withdrawal legs settle on real chains (for example Arbitrum, eip155:42161), addressed in CAIP-2.
Next Steps
- Set up the integration: Yield.xyz Perps
- Browse the Yield.xyz Perps API reference
- Learn about signing Ethereum transactions
- Review the account-abstraction requirement — perps require a non-AA (
isAccountAbstracted: false) client