Skip to main content
This guide builds a server-side flow where you discover a yield, enter it, track the position and exit, with every transaction signed by a Turnkey key. Yield.xyz builds ready-to-sign transactions and never signs or holds funds; Turnkey signs them under policies that restrict the key to the exact contracts and functions the flow needs.

Resources

Prerequisites

  • A Yield.xyz API key. See Onboarding.
  • A Turnkey organization set up with the quickstart:
    • Organization ID: the grouping for your users, wallets and policies.
    • Root quorum user: a root user with an API key pair.
    • Non-root user: a second user with its own API key, outside the root quorum. This user signs yield transactions.
    • Wallet: an HD wallet with at least one Ethereum account, funded with ETH and USDC on Base for this example.
After you create the non-root user, remove it from the root quorum, from the Turnkey dashboard or the API, so its key can only act within the policies below.

Restrict the signing key with policies

The non-root user should only be able to approve USDC and deposit into or withdraw from the vault you offer. Create the policies with the root user. Each one matches the target contract (eth.tx.to) and the function selector, the first four bytes of eth.tx.data: 0x095ea7b3 for approve, 0x6e553f65 for ERC-4626 deposit and 0xba087652 for ERC-4626 redeem.
You don’t need to look up addresses or selectors by hand. Build the enter and exit actions once, then read to and the first four bytes of data from each unsignedTransaction and add one policy per pair. Do the same for every yield you offer: RWA issuers, for example, use their own contracts and functions such as subscribe or depositInstant, not the ERC-4626 selectors above.

How Yield.xyz fits

Yield.xyz gives you one API across 4,000+ yields on 85+ networks:
  • Discover: GET /v1/yields returns yields with their metadata.
  • Act: POST /v1/actions/enter, /exit and /manage return an ordered list of unsigned transactions.
  • Track: POST /v1/yields/{yieldId}/balances and POST /v1/yields/balances return lifecycle-aware balances.
This guide uses EVM networks. Non-EVM networks follow the same flow with a different signer; see Transaction signing.

Discover a yield

Discovery is a plain read and Turnkey doesn’t change it. Run it on your server so your API key stays private.
Every field on a yield is described in Yield metadata.

Find yields to offer

Rather than hardcoding yield IDs, which change as yields are added and retired, query the catalog for what you want to offer:
Add prime=true to return only yields that meet the Prime quality bar. For staking, default users to preferred validators. For DeFi, wrap yields in an OAV to charge fees and auto-compound incentives (see Monetization).

Enter a yield

Build the enter action, then sign and broadcast each transaction with the non-root Turnkey user, in order.
For a vault deposit, the first transaction approves the vault to spend USDC and the second deposits. Yield.xyz works out those steps, so you never encode the calls or look up ABIs yourself. Build the arguments from mechanics.arguments.enter.fields rather than hardcoding { amount }, so the same code works for yields that also need a validatorAddress or another field; see Enter and exit flows.

KYC-gated RWA yields

Tokenized real-world assets, such as US Treasuries, money market funds and private credit, use the same enter and exit flow, so no new signing code is needed. Some issuers require the wallet to be allowlisted first, shown by mechanics.requirements.kycRequired: true on the yield. Check the wallet before you show a deposit button:
Send the user to authorizeUrl when the status is not_started or rejected, and enter once it is approved. If you call enter for a wallet that is not cleared, the API returns 412 with RwaKycError, and the message includes the issuer’s KYC URL.
RWA enter and exit transactions call the issuer’s own contracts, so add a matching Turnkey policy for each to and selector they use. Issuer minimums and eligibility are in RWA KYC and on each issuer’s page under RWAs.

Read the position balance

Balances are lifecycle-aware: each one has a type that says whether funds are active, entering, exiting, withdrawable, claimable or locked.
For many yields or wallets at once, use POST /v1/yields/balances with { "queries": [{ "address", "network" }] }. See Tracking balances.

Handle pending actions

A balance can carry pendingActions, such as CLAIM_REWARDS or CLAIM_UNSTAKED. Pass one back to POST /v1/actions/manage unchanged:

Exit a yield

Exiting is the same pattern as entering:
Some exits need more than one transaction, for example withdraw and unwrap; signAndTrack sends them in order. Not every exit settles at once. Staking unbonds wait out the network’s cooldown, and many RWA redemptions settle on a NAV strike or over several days. While that happens the position shows as an exiting balance. When it settles it becomes withdrawable with a CLAIM_UNSTAKED pending action, which you complete through POST /v1/actions/manage as above.

Track transaction status

After each broadcast, report the hash with PUT /v1/transactions/{transactionId}/submit-hash, then poll GET /v1/transactions/{transactionId} (or GET /v1/actions/{actionId}) until it reaches a terminal status. See Monitoring and alerting.

Integration tips

  • Send transactions in stepIndex order and skip any already at a terminal status.
  • Never change unsignedTransaction before signing; use its chainId.
  • Build arguments from mechanics.arguments.* for the right fields and units.
  • Scope Turnkey policies to the exact to and selector pairs your yields use, and add new ones when you add a yield.
  • Keep your Yield.xyz API key on the server.

Monetization

How you earn depends on the yield type. Each yield’s mechanics.possibleFeeTakingMechanisms says which fees you can configure on it.
  • Staking: deposit fees, deducted atomically in the same transaction, and a share of validator revenue through Yield.xyz’s validator agreements. See Preferred validators.
  • DeFi: revenue share from some protocols and curators, and user-facing deposit, performance and management fees through OAVs.
  • RWAs: issuer fees are set by the issuer and passed through. Where an RWA is wrapped in an OAV, you can add your own fees on top.
OAVs also improve the user experience: incentive tokens are sold into the deposit asset and reinvested automatically, wrapping and swapping are handled for the user, and users only ever see their deposit token. See Earn monetization for fee configuration, and Plans for commercial terms.

Next steps

Enter and exit flows

The full request, sign and poll loop.

Yield metadata

Every field returned on a yield.

Shield

Verify each transaction before Turnkey signs it.

Embedded wallets

The same flow with other wallet providers.