Blog

Why we built Swaps and Earn: Onchain revenue without the engineering burden

Building at Turnkey
·
·
Michael Lewellen
Head of Solutions Engineering at Turnkey

About: Learn why Turnkey built Swaps and Earn, how each product works, and how applications can turn onchain trading and yield into revenue.

Audience: Wallet teams, crypto applications, fintech builders, and infrastructure teams looking to add non-custodial swaps, yield, and monetization to their products.

What you’ll learn:
  • Why Turnkey built Swaps and Earn
  • How Swaps routes same-chain and cross-chain trades
  • How Earn connects wallets to ERC-4626 yield vaults
  • How teams configure and collect fees from swaps and yield
  • How policy controls keep automated activity non-custodial
  • How quickly existing Turnkey customers can integrate both products

Reading time: ~8 minutes

Turnkey’s first episode of Builder’s Room, a recurring live stream for builder conversations and product demos, went live on Thursday, September 17th. In it, Brian Brown, Product Marketing Manager and Michael Lewellen, Head of Solutions Engineering at Turnkey sat down for a deep dive into our new Swaps and Earn products. In this article, Michael summarizes the highlights of that interview. 

I lead Solutions Engineering at Turnkey, which means I spend most of my time helping teams build on our infrastructure. A lot of what shaped these two products came from watching customers solve the same problems over and over again.

Application providers had been building swaps on Turnkey for a long time, but they had to do most of the wiring themselves. That meant sourcing swap or earn providers, handling transaction management, exposing the flow to users, and building the APIs to make it all robust.

We built Swaps and Earn so builders can easily add onchain trading and yield directly to the products already built on Turnkey’s wallet infrastructure. Both let you set your own fee on the activity your users generate, which turns routine swaps and deposits into a revenue stream.

I think of the shift like this: instead of just handing you a pile of Lego pieces, we hand you a finished kit. Swaps and Earn package the parts teams kept rebuilding, and leave configurable the pieces that should stay in your hands, like the user experience and what fees you charge.

Creating Turnkey’s Swaps and Earn for real-world applications

We started with private key management, the most sensitive operation in crypto, and built outward from there. 

That foundation matters a lot: Users keep control of their keys, your existing policies stay enforced, and every swap and deposit signs inside the same secure enclaves that protect the rest of the wallet.

Designing Swaps for easy integration and fee configuration

On Swaps, the piece customers spent the most time on was integrating providers, so instead of  building another aggregator and potentially limiting their choices, we built an aggregator of other aggregators. 

We chose that design for a few reasons. It lets us negotiate competitive rates on the volume our customers bring, it gives us redundancy if a provider has an issue, and it gives you access to routes that any single aggregator might not offer. 

We also added a common fee interface, so you configure your fee once no matter which provider ends up routing the trade. You set a standard rate and a separate stablecoin rate in basis points, and we settle your fees onchain in USDC to a wallet you control. That last detail came straight from customer pain: a lot of setups pay fees in whatever asset was traded, which leaves you holding a meme coin you then have to reconcile.

Designing Earn for automating deposits, fee generation, and non-custodial wallets

Earn was a harder problem because the tricky part is charging a fee and automating deposits without breaking the non-custodial guarantee. Your users deposit into ERC-4626 yield vaults that independent protocols operate, so we needed a way to sit alongside those vaults rather than take custody. We extended the ERC-4626 wrapper pattern Morpho already uses: your users deposit into a fee wrapper, which is a smart contract that holds the position in the underlying vault.

What we added on top is automation. When you enable a vault, we deploy that wrapper for you with your fee parameters, and we pay the deployment gas. Fees come out of yield only, never principal, and your users never sign a separate fee transaction, which is the whole point: this gives you a clean way to earn on the activity without adding steps for your user.

Underneath all of this is our policy engine, which evaluates signing rules inside the enclave on every request. For Earn, that means you can scope a wallet to only the specific vault contracts it should touch. It is also what makes safe automation possible, so you can let an agent move funds between vaults or act on a user's behalf to make swaps while the user keeps the ability to revoke access.

Important features of Swaps

Swaps lets wallets in your organization exchange tokens through DEX aggregators in a single Turnkey activity, with the usual audit trail and policy controls. We support same-chain swaps on EVM chains and Solana, plus cross-chain swaps between EVM networks.

Because the swap runs from a Turnkey wallet, it stays non-custodial. Your user signs an intent that carries the full trade parameters, and we construct the transaction, handle token approvals, and broadcast it. 

To generate revenue, you set your fee once on your parent organization and choose a wallet to receive it. You can set one rate for standard swaps and a separate, typically lower rate for stablecoin-to-stablecoin swaps, both expressed in basis points.

In the demo below, I run same-chain and cross-chain swaps on Base, set my fee in basis points, and watch fees accrue to a fee receiver wallet from the Turnkey dashboard. Swap status normalizes to a simple pending, completed, or failed model, and webhooks tell your app the moment a transaction lands.

Important features of Earn

Earn lets wallets deposit into DeFi yield vaults, track positions, and withdraw, all through Turnkey activities with an audit trail and policy controls. It connects your wallets to ERC-4626 yield vaults operated by independent protocols, so we provide the infrastructure to interact with them rather than running the vaults ourselves.

We support Morpho and Aave vaults today, with more support coming soon. Earn is EVM-only in its first version, covering Ethereum, Base, Arbitrum, and Polygon, and the vault catalog only lists vaults with at least $100,000 in TVL.

You have wide latitude in how you present yield. You can offer a single vault, a menu of vaults across conservative and higher-yield strategies, or a more active setup that moves funds between vaults as rates change. That last option uses delegated access, where a user grants you permission to manage positions on their behalf while keeping the ability to revoke it.

Fees come out of yield and users never sign a separate fee transaction. You set your fee in basis points at deploy time and choose a payout wallet. The wrapper accrues fees as yield builds, and you claim them onchain whenever you want.

In this demo, I work from a catalog of USDC vaults on Base, deploy wrappers for vaults from curators like Steakhouse and Gauntlet, set a 1% fee on yield, then deposit and withdraw positions in a few clicks. 

The benefits of both Swaps and Earn

Swaps and Earn help teams improve the user experience, create new revenue streams, and ship onchain trading and yield without building the underlying infrastructure from scratch.

Keeping users in your app

A big part of this is the user experience. When swaps and yield live inside the wallet your user already trusts, they don't have to hop to external interfaces, hunt for the best rate across sites, or risk navigating to a lookalike scam URL.

One user experience I’ve found to be really valuable: automatically route idle wallet balances into an earn strategy, then withdraw and send funds in a single batched transaction when the user needs the funds. To the user, it feels like a savings account that never gets in the way.

A new revenue stream

The throughline across both products is monetization. Every swap can carry your fee, and every yield position can take a cut of the yield it generates, all configurable from the Turnkey dashboard.

For Earn specifically, we only charge when your users earn. We take a small platform fee, resolved automatically when a wrapper is deployed, and you set your own fee on top. Both are drawn from yield rather than principal.

The incentives line up: We make it very easy for you to generate reventure while still offering competitive rates to your users. If you are building a crypto product that needs durable revenue, that is a meaningful addition. 

Ship both fast

Setup is quick, especially if you are already on Turnkey. For a straightforward wallet app with swaps and yield, you can launch in under a week.

My own demo app shown above took about an hour to reach a working first pass, then a bit of iteration to make it robust and presentable. Most of that time went into design, not function.

Inside Turnkey, the main step is enabling the features. Swaps is available on our Pay As You Go plan and Earn is available on Enterprise. Once enabled, everything runs through the API and the dashboard.

What's next for Turnkey’s transaction management stack

On swaps, our near-term focus is broader coverage, including cross-chain routes to Solana. We also plan to add more vault strategies and protocols as customers ask for them.

Honestly, I am most interested in what I haven't anticipated, especially combinations of Swaps and Earn with our newer agentic features. Those pairings are where I think the more novel use cases will show up.

Turnkey: Transaction solutions for onchain builders 

To enable Swaps and Earn, or to get hands-on help, the fastest path is to talk to our team. We’ll walk through the best way to build each flow and even help you stand up a proof of concept.

Our documentation for Swaps and Earn covers the full lifecycle, from setting your fee to executing a swap or deploying a vault wrapper.

Get started with Turnkey today. 

Michael Lewellen
Head of Solutions Engineering at Turnkey

Related articles

Here’s how (and why) we built native MFA and Scoped Sessions at Turnkey

Why authentication gets harder to enforce at scale and how Turnkey’s MFA and Scoped Sessions bring these controls directly into the API.

Building at Turnkey
September 9, 2026

Trusted Execution Environments are secure. Here’s how we design systems to keep them that way.

Learn TEEs are only as secure as the systems around them and how Turnkey Verifiable Cloud makes it easier to operate TEEs correctly.

Building at Turnkey
August 31, 2026