-
Notifications
You must be signed in to change notification settings - Fork 198
feat: yield.xyz POC #11578
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
feat: yield.xyz POC #11578
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
- Add Phase 1.0 TypeScript types with full API enums (TransactionType, ActionType, YieldNetwork, etc.) - Add Phase 1.0.1 network/chainId mapping utilities (CAIP-2 <-> Yield.xyz network) - Document all API response structures from actual testing - Include parsing utilities for JSON string fields (unsignedTransaction, gasEstimate) - Define request/response types for all endpoints
- Add VITE_YIELD_XYZ_API_KEY, VITE_YIELD_XYZ_BASE_URL, VITE_FEATURE_YIELD_XYZ env vars - Add YieldXyz feature flag to preferencesSlice and test mocks - Add CSP for api.yield.xyz and assets.stakek.it - Create types.ts with API response types (no derived types) - Create constants.ts with CHAIN_ID_TO_YIELD_NETWORK mapping - Create utils.ts with parsing and conversion utilities - Create api.ts with all Yield.xyz API endpoints - Create React Query hooks (useYields, useYield, useYieldBalances, useEnterYield, useExitYield, useSubmitYieldTransaction)
- Filter out SKIPPED and CREATED transactions in YieldActionModal before building steps array and execution loop, preventing phantom approval steps - Update YieldStats to use AugmentedYieldDto instead of YieldDto for type safety - Fix YieldEnterExit dependency arrays (use exitBalance instead of withdrawableBalance) - Switch YieldYourInfo formatters to use shared formatLargeNumber helper - Remove unused inputTokenBalance variable from YieldYourInfo - Fix invalid bgOpacity prop in YieldPositionCard (use bg='color.900' pattern) - Remove unused Button import from YieldCard - Add formatLargeNumber utility for consistent number formatting
The yield-xyz provider logoURI from the API returns 403, so we override it with a locally hosted PNG using react-query's select option.
- Add YieldFilters component with network/provider filtering and sort options - Add transaction confirmation polling before marking tx as success - Remove redundant tags display from YieldCard and table - Add pagination params to getProviders API - Show ResultsEmptyNoWallet for positions tab when disconnected
The wip commits broke AssetIcon's discriminated union types and added a proxy asset creation that caused double icon rendering. Reverted to original and updated Yields components to use only src prop.
|
Ok maybe that is a bit more than an exploration PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can revert already, fixed
docs/yield_xyz_asset_section.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert, now useless
docs/yield_xyz_fees_plan.md
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert, captured as an issue, all done thru dashboard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sanity-check no useless ones here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triple-check this is feature-flag gated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Triple-check this one, seems flaky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm yeah no
src/lib/yieldxyz/api.ts
Outdated
| 'Content-Type': 'application/json', | ||
| } | ||
|
|
||
| const handleResponse = async <T>(response: Response): Promise<T> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems sloppy - should be handled by axios
src/lib/yieldxyz/api.ts
Outdated
| if (params?.limit) searchParams.set('limit', String(params.limit)) | ||
| if (params?.offset) searchParams.set('offset', String(params.offset)) | ||
|
|
||
| const response = await fetch(`${BASE_URL}/yields?${searchParams}`, { headers }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
axios vs. fetch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Augments pure response with bits we need - clear separation between server response and our augmented DTOs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also:
- few squirly braces we can remove here
tokenToAssetIdseems flaky, clean it up- bnOrZero vs.
Numberthings - no
eip155:${evmChainId} as ChainId- usetoChainId() - naming
| import { assertGetSuiChainAdapter } from '@/lib/utils/sui' | ||
| import { isStakingChainAdapter } from '@/plugins/cosmos/components/modals/Staking/StakingCommon' | ||
|
|
||
| type ParsedEvmTransaction = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
types should live in a types.ts
| * Parse the JSON string unsignedTransaction from Yield.xyz API | ||
| */ | ||
| export const parseUnsignedTransaction = (tx: TransactionDto): ParsedUnsignedTransaction => { | ||
| if (typeof tx.unsignedTransaction === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems... flaky.
| /** | ||
| * Yield.xyz API Types | ||
| * These types are derived from actual API responses. | ||
| * DO NOT add derived/composite types - only what the API returns. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe worth a diff naming for this one then, so other types can live in types.ts
| } from './constants' | ||
| import type { TransactionDto, YieldDto, YieldNetwork } from './types' | ||
|
|
||
| export const chainIdToYieldNetwork = (chainId: ChainId): YieldNetwork | undefined => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a constant but should probably be colocated in constants.ts, ditto below
src/lib/yieldxyz/utils.ts
Outdated
| export const filterSupportedYields = (yields: YieldDto[]): YieldDto[] => | ||
| yields.filter(y => isSupportedYieldNetwork(y.network)) | ||
|
|
||
| export type ParsedUnsignedTransaction = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto types.ts
src/lib/yieldxyz/utils.ts
Outdated
| } | ||
|
|
||
| export const parseUnsignedTransaction = (tx: TransactionDto): ParsedUnsignedTransaction => { | ||
| if (typeof tx.unsignedTransaction === 'string') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto flaky
- Add CHAIN_NAMESPACE.Solana case to executeTransaction switch - Implement executeSolanaTransaction that decompiles yield.xyz transactions, filters compute budget instructions, and rebuilds with fresh blockhash - Fix amount format for Solana - yield.xyz expects human-readable SOL, not lamports - Add minimum compute unit buffer (50k) for staking operations
…e types - Show YieldActivePositions on account page (was only on asset page) - Sum all balance types (active, entering, exiting, withdrawable) for total value display instead of just active balance
Query Key Fixes: - useEnterYield: invalidate ['yieldxyz', 'balances', yieldId, address] + allBalances - useExitYield: invalidate ['yieldxyz', 'balances', yieldId, address] + allBalances - useSubmitYieldTransactionHash: accept optional yieldId/address params, invalidate properly - YieldActionModal: remove inline invalidations, pass yieldId/address to mutation The original code had incorrect query key patterns that caused cache invalidation to fail. Mutations were invalidating partial keys that didn't match the actual query keys, leading to stale data after transactions. Bug Fixes: - useYieldOpportunities: add guardrail throw when multiAccountEnabled without accountId - Header: gate Yields nav item behind YieldXyz feature flag Chores: - augment.ts: rename evmChainIdFromString → parseEvmNetworkId, use toChainId() validation - types.ts: rename evmChainId → evmNetworkId for clarity - Remove unused useQueryClient from YieldActionModal
jk, disregard the below this is a PoC
Just digging around and starting exploration with minimax/opus here. Implementation plan really isn't one, more like references of sorts, augmented by actual curls with test API key:Master plan:
Macro plan: