0x0x230x

Untitled

Feb 11th, 2026
30
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1.  
  2. 1) approveMax / maxUint256
  3.  
  4. In approveMax, we hardcode 2n ** 256n - 1n:
  5.  
  6. export async function approveMax(…): Promise { return
  7. approve(walletClient, publicClient, { token, spender, amount: 2n **
  8. 256n - 1n, // I think viem exposes maxUint256 / some constant we can
  9. reuse? }) }
  10.  
  11. Maybe we should use a shared constant (from viem or our own) so we don’t
  12. repeat this / avoid magic numbers.
  13.  
  14. 2) Safe math utils for share/slippage math
  15.  
  16. In packages/core/src/actions/deposit.ts:
  17.  
  18. const minShares = expectedShares - (expectedShares *
  19. BigInt(slippageBps)) / 10000n
  20.  
  21. Can we add a safeMath util (we already have something similar in
  22. backend/dapp) and use it consistently for these calculations? Mainly to
  23. avoid edge cases (underflow, rounding surprises, etc.) and keep it
  24. uniform.
  25.  
  26. 3) Missing input validation
  27.  
  28. Right now it looks like we don’t validate some basics:
  29.  
  30. - No validation that vault addresses are supported on the current
  31. chain
  32. - No validation that amounts are > 0
  33. - No address format validation
  34.  
  35. At minimum we should validate addresses + amounts. Also: do we already
  36. have a helper/util that exports yoVaultsAddresses (or supported vaults)
  37. for easy access? If not, might be worth adding.
  38.  
  39. 4) Fragile string matching for errors
  40.  
  41. In packages/core/src/api/user.ts:
  42.  
  43. catch (error) { if (error instanceof Error &&
  44. error.message.includes(‘404’)) { return null } throw error }
  45.  
  46. This is pretty fragile (string matching on “404”). Better to check
  47. status codes in a structured way if possible.
  48.  
  49. 5) Generic errors + unclear error surface
  50.  
  51. Currently we throw generic Errors, e.g.:
  52.  
  53. throw new Error(‘Wallet client must have an account’)
  54.  
  55. No error codes, no custom types. From a dev UX perspective it’s hard to
  56. know what actually happened / what to handle.
  57.  
  58. Related: in packages/core/src/api/vault.ts we bypass Zod validation:
  59.  
  60. if (!parsed.success) { return response as VaultSnapshot // returns
  61. unvalidated data }
  62.  
  63. That can silently pass bad data forward.
  64.  
  65. I’d suggest structured errors (codes + context), e.g.:
  66.  
  67. class YoError extends Error { constructor( public code: string, message:
  68. string, public context?: Record<string, any> ) { super(message) } }
  69.  
  70. class VaultNotFoundError extends YoError {} class
  71. InsufficientBalanceError extends YoError {} class SlippageExceededError
  72. extends YoError {}
  73.  
  74. Main point: make it obvious to SDK users what error they hit and how to
  75. react.
  76.  
  77. 6) useYoKit vs useYoClient
  78.  
  79. useYoKit and useYoClient look very similar — both seem to create a
  80. client. Is there a real difference intended here, or can we merge /
  81. clarify naming?
  82.  
  83. 7) previewDeposit vs quotePreviewDeposit
  84.  
  85. client.previewDeposit() client.quotePreviewDeposit()
  86.  
  87. Are these doing different things, or are they basically the same? If
  88. they’re meant to differ, maybe we should document the difference or
  89. rename for clarity.
  90.  
Advertisement
Add Comment
Please, Sign In to add comment