0x0x230x

Untitled

Feb 11th, 2026
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.01 KB | None | 0 0
  1.  
  2. ## 1) approveMax / maxUint256
  3.  
  4. In `approveMax`, we hardcode `2n ** 256n - 1n`:
  5.  
  6. ``` ts
  7. export async function approveMax(...): Promise<ApproveResult> {
  8. return approve(walletClient, publicClient, {
  9. token,
  10. spender,
  11. amount: 2n ** 256n - 1n, // I think viem exposes maxUint256 / some constant we can reuse?
  12. })
  13. }
  14. ```
  15.  
  16. Maybe we should use a shared constant (from viem or our own) so we don’t
  17. repeat this / avoid magic numbers.
  18.  
  19. ------------------------------------------------------------------------
  20.  
  21. ## 2) Safe math utils for share/slippage math
  22.  
  23. In `packages/core/src/actions/deposit.ts`:
  24.  
  25. ``` ts
  26. const minShares = expectedShares - (expectedShares * BigInt(slippageBps)) / 10000n
  27. ```
  28.  
  29. Can we add a `safeMath` util (we already have something similar in
  30. backend/dapp) and use it consistently for these calculations?
  31. Mainly to avoid edge cases (underflow, rounding surprises, etc.) and
  32. keep it uniform.
  33.  
  34. ------------------------------------------------------------------------
  35.  
  36. ## 3) Missing input validation
  37.  
  38. Right now it looks like we don’t validate some basics:
  39.  
  40. - No validation that vault addresses are supported on the current
  41. chain
  42. - No validation that amounts are `> 0`
  43. - No address format validation
  44.  
  45. At minimum we should validate addresses + amounts.
  46.  
  47. Also: do we already have a helper/util that exports `yoVaultsAddresses`
  48. (or supported vaults) for easy access? If not, might be worth adding.
  49.  
  50. ------------------------------------------------------------------------
  51.  
  52. ## 4) Vault address validation (invalid / unsupported vaults)
  53.  
  54. How do we prevent invalid vault addresses or addresses that are not part
  55. of our supported contracts?
  56.  
  57. Right now it looks like we rely on the contract call reverting, but
  58. maybe we should:
  59.  
  60. - Validate address format (basic checksum / `isAddress` check)
  61. - Check that the vault exists in our supported `yoVaultsAddresses`
  62. list for the current chain
  63.  
  64. This would prevent accidental misuse and improve DX.
  65.  
  66. ------------------------------------------------------------------------
  67.  
  68. ## 5) Checking if vault is paused
  69.  
  70. Do we expose a way to check if a vault is paused?
  71.  
  72. Technically the transaction will revert if it’s paused, but from a UI/UX
  73. perspective it might be better if we:
  74.  
  75. - Export an `isPaused` (or similar) call
  76. - Let integrators check this before attempting deposit/withdraw
  77.  
  78. That way frontends can disable actions instead of relying on a revert.
  79.  
  80. ------------------------------------------------------------------------
  81.  
  82. ## 6) Idle balance / available liquidity
  83.  
  84. We might also want to export available idle balance from yoContracts.
  85.  
  86. For example for yoUSD: - What is the available idle balance? - How much
  87. USDC is currently in the contract?
  88.  
  89. This is important because if `withdraw amount > idle balance`, the
  90. withdraw might take up to 24h.
  91.  
  92. Having this exposed in the SDK would allow better UX (e.g. warning users
  93. before they withdraw).
  94.  
  95. ------------------------------------------------------------------------
  96.  
  97. ## 7) Fragile string matching for errors
  98.  
  99. In `packages/core/src/api/user.ts`:
  100.  
  101. ``` ts
  102. catch (error) {
  103. if (error instanceof Error && error.message.includes('404')) {
  104. return null
  105. }
  106. throw error
  107. }
  108. ```
  109.  
  110. This is pretty fragile (string matching on `"404"`).
  111. Better to check status codes in a structured way if possible.
  112.  
  113. ------------------------------------------------------------------------
  114.  
  115. ## 8) Generic errors + unclear error surface
  116.  
  117. Currently we throw generic `Error`s, e.g.:
  118.  
  119. ``` ts
  120. throw new Error('Wallet client must have an account')
  121. ```
  122.  
  123. No error codes, no custom types.
  124. From a dev UX perspective it’s hard to know what actually happened /
  125. what to handle.
  126.  
  127. Related: in `packages/core/src/api/vault.ts` we bypass Zod validation:
  128.  
  129. ``` ts
  130. if (!parsed.success) {
  131. return response as VaultSnapshot // returns unvalidated data
  132. }
  133. ```
  134.  
  135. That can silently pass bad data forward.
  136.  
  137. I’d suggest structured errors (codes + context), e.g.:
  138.  
  139. ``` ts
  140. class YoError extends Error {
  141. constructor(
  142. public code: string,
  143. message: string,
  144. public context?: Record<string, any>
  145. ) {
  146. super(message)
  147. }
  148. }
  149.  
  150. class VaultNotFoundError extends YoError {}
  151. class InsufficientBalanceError extends YoError {}
  152. class SlippageExceededError extends YoError {}
  153. ```
  154.  
  155. Main point: make it obvious to SDK users what error they hit and how to
  156. react.
  157.  
  158. ------------------------------------------------------------------------
  159.  
  160. ## 9) useYoKit vs useYoClient
  161.  
  162. `useYoKit` and `useYoClient` look very similar — both seem to create a
  163. client.
  164. Is there a real difference intended here, or can we merge / clarify
  165. naming?
  166.  
  167. ------------------------------------------------------------------------
  168.  
  169. ## 10) previewDeposit vs quotePreviewDeposit
  170.  
  171. client.previewDeposit()
  172. client.quotePreviewDeposit()
  173.  
  174. Are these doing different things, or are they basically the same?
  175. If they’re meant to differ, maybe we should document the difference or
  176. rename for clarity.
  177.  
Advertisement
Add Comment
Please, Sign In to add comment