Skip to content

Add with-vaultsfyi example#1297

Closed
ryanrodenbaugh wants to merge 1 commit into
tkhq:mainfrom
ryanrodenbaugh:feat/with-vaultsfyi-example
Closed

Add with-vaultsfyi example#1297
ryanrodenbaugh wants to merge 1 commit into
tkhq:mainfrom
ryanrodenbaugh:feat/with-vaultsfyi-example

Conversation

@ryanrodenbaugh

Copy link
Copy Markdown

Summary

Adds a new examples/with-vaultsfyi companion example for the vaults.fyi cookbook recipe (tkhq/docs#652). vaults.fyi is one API for DeFi yield discovery, ready-to-sign transaction payloads, and position tracking across 80+ protocols.

The example mirrors with-morpho's structure (CLI scripts, @turnkey/viem + @turnkey/sdk-server workspace deps, viem 2.x, dotenv) and adds @vaultsfyi/sdk as a third-party dep, matching the SDK calls used in the cookbook.

Scripts

  • discover.ts — list top vaults vaults.fyi recommends for the user's wallet, ranked by APY across every supported protocol
  • createPolicy.ts — dry-run deposit + redeem against vaults.fyi, extract the actual tx.to addresses, and build one Turnkey policy from them. Works for ERC-4626 vaults that target the vault directly (Morpho, Aave, Euler) and for protocols that route through intermediary contracts (Veda Boring Vaults via a Teller, queue-based redemptions, etc.)
  • deposit.ts — sign the ordered transactions vaults.fyi returns for a deposit (typically approve + deposit), waiting for confirmations between steps
  • balance.ts — list every vault position the user holds across every supported network and protocol
  • redeem.ts — redeem the full position with all=true
  • claimRewards.ts — two-step rewards/contextrewards/claim flow

Why one address allowlist

vaults.fyi handles all protocol-specific encoding internally, so an address allowlist is sufficient. The dry-run pattern in createPolicy.ts discovers the right addresses for any vault without hardcoding them.

Notes

  • Uses lib: ["es2022"] in tsconfig.json because @vaultsfyi/sdk transitively pulls in ox@0.11.3 which uses Error.cause and override modifiers.
  • @vaultsfyi/sdk v2.3.1 is the published version; SDK method names (getActions, getDepositOptions, getPositions, getRewardsTransactionsContext, getRewardsClaimActions) are all verified against @vaultsfyi/sdk's client.d.ts.

Test plan

  • pnpm install -r — clean
  • pnpm build-all — clean
  • pnpm typecheck — clean (in examples/with-vaultsfyi/)
  • End-to-end run on Base mainnet with a real Turnkey wallet and vaults.fyi API key (pending)

🤖 Generated with Claude Code

Adds a new example showing how to use Turnkey to sign vaults.fyi
transactions on Base mainnet under a policy auto-discovered from the
SDK's transaction payloads. Mirrors with-morpho's structure.

Scripts:
- discover.ts        list top vaults vaults.fyi recommends for the user's wallet
- createPolicy.ts    dry-run deposit + redeem, build a policy from the actual
                     tx.to addresses (handles ERC-4626 vaults, Veda Boring
                     Vaults via a Teller, queue-based redemptions, etc.)
- deposit.ts         deposit DEPOSIT_AMOUNT of ASSET_ADDRESS into VAULT_ID
- balance.ts         list all positions across every supported protocol
- redeem.ts          redeem the full position
- claimRewards.ts    two-step rewards/context -> rewards/claim flow

Companion to the cookbook recipe at tkhq/docs#652.
@socket-security

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vaultsfyi/​sdk@​2.3.1791009598100

View full report

@codesandbox-ci

codesandbox-ci Bot commented May 8, 2026

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 17e3928:

Sandbox Source
@turnkey/example-react-components Configuration

@ryanrodenbaugh ryanrodenbaugh marked this pull request as draft May 8, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant