Add with-vaultsfyi example#1297
Closed
ryanrodenbaugh wants to merge 1 commit into
Closed
Conversation
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.
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
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:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
examples/with-vaultsfyicompanion 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-serverworkspace deps, viem 2.x, dotenv) and adds@vaultsfyi/sdkas 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 protocolcreatePolicy.ts— dry-run deposit + redeem against vaults.fyi, extract the actualtx.toaddresses, 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 stepsbalance.ts— list every vault position the user holds across every supported network and protocolredeem.ts— redeem the full position withall=trueclaimRewards.ts— two-steprewards/context→rewards/claimflowWhy one address allowlist
vaults.fyi handles all protocol-specific encoding internally, so an address allowlist is sufficient. The dry-run pattern in
createPolicy.tsdiscovers the right addresses for any vault without hardcoding them.Notes
lib: ["es2022"]intsconfig.jsonbecause@vaultsfyi/sdktransitively pulls inox@0.11.3which usesError.causeandoverridemodifiers.@vaultsfyi/sdkv2.3.1 is the published version; SDK method names (getActions,getDepositOptions,getPositions,getRewardsTransactionsContext,getRewardsClaimActions) are all verified against@vaultsfyi/sdk'sclient.d.ts.Test plan
pnpm install -r— cleanpnpm build-all— cleanpnpm typecheck— clean (inexamples/with-vaultsfyi/)🤖 Generated with Claude Code