Overview
Portal integrates with Yield.xyz Perps so your users can open and close leveraged long and short positions, manage risk with stop-loss and take-profit orders, and fund and withdraw a trading account on leading perpetual-futures venues (starting with Hyperliquid) with their Portal wallets. Portal proxies the Perps API server-side using the API key you store in the Portal Dashboard, so the key never ships in your app.Perps uses the same Yield.xyz API key and the same Portal integration as Yield.xyz and Yield.xyz Borrow. If you have already enabled Yield.xyz in the Portal Dashboard, the Perps endpoints below work right away; there is no separate card or key to add.
How perpetual-futures trading works
A perpetual future (“perp”) is a leveraged derivative that tracks the price of an asset without ever expiring. A trader posts collateral (margin) and takes a position that is larger than that margin by a chosen leverage: at 10× leverage, $100 of margin controls a $1,000 position. A position is either a long (profits when the price rises) or a short (profits when the price falls). The definitions below are the terms that appear as API fields, so your UI can render them directly.- Venue (
provider) vs. market. A provider is a trading venue (for examplehyperliquid); a market is one tradable instrument on it (for example ETH-USDC), carrying aleverageRange([min, max]),markPrice,oraclePrice,fundingRate,makerFee/takerFeeandminSize. Discover venues withGET /providersand instruments withGET /markets. - Collateral and margin. A user first funds a trading account with collateral (typically USDC).
POST /balancesreturns the account’saccountValue,usedMarginandavailableBalance. Each position reservesmargin;marginModeis eitherisolated(margin is fixed per position) orcross(positions share the account’s collateral). - Mark price and liquidation.
markPriceis the price the venue uses to value an open position and compute PnL (unrealizedPnl). If the price moves against the position far enough that its margin can no longer cover the loss, the venue liquidates it at itsliquidationPrice, closing the position and taking the margin. Higher leverage movesliquidationPricecloser to the entry price. - Funding rate. Perps have no expiry, so venues use a periodic funding payment between longs and shorts to keep the perp price near the spot price.
fundingRateandfundingRateIntervalHoursdescribe it; it is a recurring cost or credit of holding a position, not a one-time fee. - Orders. A position can be opened at the current price (a
marketorder) or at a chosen price (alimitorder).stop_lossandtake_profitorders close a position automatically when the price hits atriggerPrice, which is how a user caps a loss or locks in a gain. Orders can bereduceOnly(they only shrink an existing position). - Venue approvals. Some venues execute trades through an agent wallet that the user authorizes once (
approveAgent), and may require a one-time builder-fee approval (approveBuilderFee). On Hyperliquid, orders are then signed as EIP-712 typed data rather than as on-chain transactions — see the guide for the signing flow.
Why offer it
- Leveraged trading without leaving your product. Users who want to trade perps otherwise withdraw to an external venue. With this, positions and collateral live in the wallet you already manage, and the trading activity stays in your product.
- A new revenue and engagement surface. Perps trading is active and recurring, unlike a one-time swap or a passive yield position.
- Same integration as earning and borrowing. Yield.xyz’s perps venues are enabled with the same account, the same API key and the same Portal Dashboard toggle you already use for yield and lending.
Steps to enable perps
Perps runs through the same Yield.xyz account, API key and Portal integration as yield and lending. If you have already enabled Yield.xyz, you are done — skip to Endpoints. Otherwise, follow the one-time setup on the Yield.xyz integration page:- Create or access your Yield.xyz account and generate an API key per Portal environment (
DevelopmentandProduction). The same key covers Yield, Borrow and Perps. - In the Portal Dashboard, open
Integrations, findYield.xyzunderYield, add it, and paste your API key for the selected Portal environment.
Endpoints
All endpoints live underhttps://api.portalhq.io/api/v3/clients/me/integrations/yield-xyz-perps and accept a Client API Key or Client Session Token as a bearer token. Every success response is wrapped as { "data": ... }.
Discovery
Portfolio
Actions
History
Transactions & health
Typical flow
hyperliquid is used as the example venue throughout this page. The venues available to you are whatever GET /providers returns — start there and use those providerId values rather than hard-coding one, so a venue Yield.xyz adds later works with no change on your side.GET /providers, thenGET /markets?providerId={providerId}(for examplehyperliquid) to discover what your user can trade.- Fund the trading account and complete any one-time venue approvals the venue requires (on Hyperliquid, approve the agent wallet). Both are
POST /actionsactions (fund,approveAgent). Afundaction reachesSUCCESSon source-chain confirmation, not when the collateral credits on the venue — see the guide’s note on pollingPOST /balancesbefore showing a funded state. POST /actionswith the venue, the action (for exampleopen) and itsargs(marketId,side,size,leverage,marginMode). The response contains one or moretransactions, each with asignablePayloadand asigningFormat.- Sign each transaction with the Portal SDK or Enclave MPC API, then
POST /transactions/{transactionId}/submitwith thesignedPayload(or thetransactionHashif you broadcast it yourself). POST /positions,POST /ordersandPOST /balancesto show the resulting position, resting orders and account balance.
Alert Webhooks fire only for the on-chain legs of perps: the source-chain approval and fund transactions, and the Arbitrum withdrawal arrival — all delivered as
EVM Wallet Transactions events. Hyperliquid L1 actions (open, close, agent and builder-fee approvals) are off-chain EIP-712 messages, not on-chain transactions, so they produce no webhook. Track those with GET /activity and GET /events instead.Chain identifiers
Perps is venue-centric, not chain-centric, so identifiers work differently than in the rest of Portal:providerIdis a venue slug (for examplehyperliquid), not a CAIP-2 chain id. It is passed through unchanged in both directions. A venue is not a blockchain, so do not treat it like one.- A real chain appears only where funds settle — for example a funding source (
args.fromToken.network) or an on-chain approval/funding transaction’snetwork. There, Portal uses CAIP-2: passnetworkas CAIP-2 (eip155:42161for Arbitrum) and Portal translates it to the Yield.xyz network name;networkvalues in responses are translated back to CAIP-2. A request naming a chain Portal does not support is rejected with a400before it reaches Yield.xyz. - Each transaction also carries a
chainIdstring, kept as the venue returns it because it is load-bearing for EIP-712 signature verification. Do not confuse it with the CAIP-2network.
Funding sources and limits
Funding, withdrawals and orders 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 them with400 EXECUTE_INVALID_ARGUMENT. - Withdrawals return USDC on Arbitrum only, to the signing address, with a flat $1 fee and a 2 USDC minimum. See Hyperliquid’s docs.
bridge2deposits below 5 USDC are not credited and are lost. Enforce the 5 USDC floor in your UI before funding.- Orders have a $10 minimum notional. An order below it is rejected by the venue.
GET /providers.
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, or a Yield.xyz API key that is missing or was rejected. When the venue returns a machine-readable code, Portal surfaces it asdetails.codeso your SDK can branch on it programmatically. The venue’s free-text reason is logged server-side only and is not returned to the caller.404: 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
Guides
- Trade perps with Yield.xyz using the Enclave MPC API
API reference
Yield.xyz Perps API Reference
Open the interactive Yield.xyz Perps endpoints reference.