@polyester/sdk 0.36.0-devnet-20261117035807 → 0.36.0-devnet-20261118141710

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (345) hide show
  1. package/CHANGELOG.md +66 -8
  2. package/dist/catalogs/index.d.ts +2 -2
  3. package/dist/catalogs/snapshot-validation.js +10 -1
  4. package/dist/catalogs/snapshot-validation.js.map +1 -1
  5. package/dist/catalogs/zipper-catalog.d.ts +2 -0
  6. package/dist/catalogs/zipper-catalog.d.ts.map +1 -1
  7. package/dist/catalogs/zipper-catalog.js.map +1 -1
  8. package/dist/catalogs/zipper-supply.d.ts +2 -0
  9. package/dist/catalogs/zipper-supply.d.ts.map +1 -1
  10. package/dist/catalogs/zipper-supply.js +7 -5
  11. package/dist/catalogs/zipper-supply.js.map +1 -1
  12. package/dist/client.d.ts +2 -0
  13. package/dist/client.d.ts.map +1 -1
  14. package/dist/client.js +2 -0
  15. package/dist/client.js.map +1 -1
  16. package/dist/gen/ai/v1/assistant_pb.d.ts +679 -13
  17. package/dist/gen/ai/v1/assistant_pb.d.ts.map +1 -1
  18. package/dist/gen/ai/v1/assistant_pb.js +355 -97
  19. package/dist/gen/ai/v1/assistant_pb.js.map +1 -1
  20. package/dist/gen/alerts/v1/price_alerts_pb.d.ts +33 -4
  21. package/dist/gen/alerts/v1/price_alerts_pb.d.ts.map +1 -1
  22. package/dist/gen/alerts/v1/price_alerts_pb.js +23 -2
  23. package/dist/gen/alerts/v1/price_alerts_pb.js.map +1 -1
  24. package/dist/gen/auth/v1/activity_pb.d.ts +148 -0
  25. package/dist/gen/auth/v1/activity_pb.d.ts.map +1 -0
  26. package/dist/gen/auth/v1/activity_pb.js +40 -0
  27. package/dist/gen/auth/v1/activity_pb.js.map +1 -0
  28. package/dist/gen/auth/v1/api_keys_pb.d.ts +10 -4
  29. package/dist/gen/auth/v1/api_keys_pb.d.ts.map +1 -1
  30. package/dist/gen/auth/v1/api_keys_pb.js +3 -1
  31. package/dist/gen/auth/v1/api_keys_pb.js.map +1 -1
  32. package/dist/gen/auth/v1/auth_pb.d.ts +61 -5
  33. package/dist/gen/auth/v1/auth_pb.d.ts.map +1 -1
  34. package/dist/gen/auth/v1/auth_pb.js +23 -6
  35. package/dist/gen/auth/v1/auth_pb.js.map +1 -1
  36. package/dist/gen/auth/v1/mfa_pb.d.ts +140 -2
  37. package/dist/gen/auth/v1/mfa_pb.d.ts.map +1 -1
  38. package/dist/gen/auth/v1/mfa_pb.js +80 -8
  39. package/dist/gen/auth/v1/mfa_pb.js.map +1 -1
  40. package/dist/gen/auth/v1/policies_pb.d.ts +18 -3
  41. package/dist/gen/auth/v1/policies_pb.d.ts.map +1 -1
  42. package/dist/gen/auth/v1/policies_pb.js +18 -3
  43. package/dist/gen/auth/v1/policies_pb.js.map +1 -1
  44. package/dist/gen/auth/v1/social_verification_pb.d.ts +36 -15
  45. package/dist/gen/auth/v1/social_verification_pb.d.ts.map +1 -1
  46. package/dist/gen/auth/v1/social_verification_pb.js +1 -1
  47. package/dist/gen/auth/v1/social_verification_pb.js.map +1 -1
  48. package/dist/gen/auth/v1/subaccounts_pb.d.ts +15 -1
  49. package/dist/gen/auth/v1/subaccounts_pb.d.ts.map +1 -1
  50. package/dist/gen/auth/v1/subaccounts_pb.js +1 -1
  51. package/dist/gen/auth/v1/subaccounts_pb.js.map +1 -1
  52. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts +6 -2
  53. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.d.ts.map +1 -1
  54. package/dist/gen/chain/withdraw/v1/auto_withdraw_pb.js.map +1 -1
  55. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts +104 -6
  56. package/dist/gen/chain/withdraw/v1/withdraw_pb.d.ts.map +1 -1
  57. package/dist/gen/chain/withdraw/v1/withdraw_pb.js +49 -3
  58. package/dist/gen/chain/withdraw/v1/withdraw_pb.js.map +1 -1
  59. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts +76 -3
  60. package/dist/gen/chain/zipper/v1/zipper_pb.d.ts.map +1 -1
  61. package/dist/gen/chain/zipper/v1/zipper_pb.js +46 -2
  62. package/dist/gen/chain/zipper/v1/zipper_pb.js.map +1 -1
  63. package/dist/gen/index.d.ts +3 -1
  64. package/dist/gen/index.js +4 -2
  65. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts +21 -139
  66. package/dist/gen/ledger/read/v1/ledger_read_pb.d.ts.map +1 -1
  67. package/dist/gen/ledger/read/v1/ledger_read_pb.js +16 -17
  68. package/dist/gen/ledger/read/v1/ledger_read_pb.js.map +1 -1
  69. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts +236 -20
  70. package/dist/gen/ledger/read/v1/statement_export_pb.d.ts.map +1 -1
  71. package/dist/gen/ledger/read/v1/statement_export_pb.js +44 -10
  72. package/dist/gen/ledger/read/v1/statement_export_pb.js.map +1 -1
  73. package/dist/gen/ledger/v1/catalog_pb.d.ts +9 -1
  74. package/dist/gen/ledger/v1/catalog_pb.d.ts.map +1 -1
  75. package/dist/gen/ledger/v1/catalog_pb.js +9 -1
  76. package/dist/gen/ledger/v1/catalog_pb.js.map +1 -1
  77. package/dist/gen/marketdata/v1/asset_info_pb.d.ts +158 -7
  78. package/dist/gen/marketdata/v1/asset_info_pb.d.ts.map +1 -1
  79. package/dist/gen/marketdata/v1/asset_info_pb.js +56 -6
  80. package/dist/gen/marketdata/v1/asset_info_pb.js.map +1 -1
  81. package/dist/gen/notifications/v1/notifications_pb.d.ts +45 -6
  82. package/dist/gen/notifications/v1/notifications_pb.d.ts.map +1 -1
  83. package/dist/gen/notifications/v1/notifications_pb.js +23 -5
  84. package/dist/gen/notifications/v1/notifications_pb.js.map +1 -1
  85. package/dist/gen/orders/v1/orders_pb.d.ts +105 -29
  86. package/dist/gen/orders/v1/orders_pb.d.ts.map +1 -1
  87. package/dist/gen/orders/v1/orders_pb.js +14 -2
  88. package/dist/gen/orders/v1/orders_pb.js.map +1 -1
  89. package/dist/gen/orders/v1/orders_read_pb.d.ts +50 -20
  90. package/dist/gen/orders/v1/orders_read_pb.d.ts.map +1 -1
  91. package/dist/gen/orders/v1/orders_read_pb.js +1 -1
  92. package/dist/gen/orders/v1/orders_read_pb.js.map +1 -1
  93. package/dist/gen/polyester/api/options_pb.d.ts +11 -2
  94. package/dist/gen/polyester/api/options_pb.d.ts.map +1 -1
  95. package/dist/gen/polyester/api/options_pb.js +13 -3
  96. package/dist/gen/polyester/api/options_pb.js.map +1 -1
  97. package/dist/gen/privatews/v1/private_ws_pb.d.ts +13 -3
  98. package/dist/gen/privatews/v1/private_ws_pb.d.ts.map +1 -1
  99. package/dist/gen/privatews/v1/private_ws_pb.js.map +1 -1
  100. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts +126 -10
  101. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.d.ts.map +1 -1
  102. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js +14 -6
  103. package/dist/gen/swap/quickswap/v1/quickswap_broker_pb.js.map +1 -1
  104. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts +665 -0
  105. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.d.ts.map +1 -0
  106. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js +216 -0
  107. package/dist/gen/swap/quickswap/v1/quickswap_explorer_pb.js.map +1 -0
  108. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts +166 -52
  109. package/dist/gen/swap/quickswap/v1/quickswap_pb.d.ts.map +1 -1
  110. package/dist/gen/swap/quickswap/v1/quickswap_pb.js +50 -12
  111. package/dist/gen/swap/quickswap/v1/quickswap_pb.js.map +1 -1
  112. package/dist/gen/system/v1/system_pb.d.ts +49 -2
  113. package/dist/gen/system/v1/system_pb.d.ts.map +1 -1
  114. package/dist/gen/system/v1/system_pb.js +18 -6
  115. package/dist/gen/system/v1/system_pb.js.map +1 -1
  116. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts +150 -71
  117. package/dist/gen/transfer/v1/internal_transfer_pb.d.ts.map +1 -1
  118. package/dist/gen/transfer/v1/internal_transfer_pb.js +56 -34
  119. package/dist/gen/transfer/v1/internal_transfer_pb.js.map +1 -1
  120. package/dist/gen/triggers/v1/triggers_pb.d.ts +117 -16
  121. package/dist/gen/triggers/v1/triggers_pb.d.ts.map +1 -1
  122. package/dist/gen/triggers/v1/triggers_pb.js +45 -2
  123. package/dist/gen/triggers/v1/triggers_pb.js.map +1 -1
  124. package/dist/index.d.ts +13 -9
  125. package/dist/realtime/client.js +5 -1
  126. package/dist/realtime/client.js.map +1 -1
  127. package/dist/realtime/snapshot-then-stream.js +5 -3
  128. package/dist/realtime/snapshot-then-stream.js.map +1 -1
  129. package/dist/services/account-activity/account-activity.d.ts +22 -0
  130. package/dist/services/account-activity/account-activity.d.ts.map +1 -0
  131. package/dist/services/account-activity/account-activity.js +32 -0
  132. package/dist/services/account-activity/account-activity.js.map +1 -0
  133. package/dist/services/account-activity/account-activity.schemas.d.ts +78 -0
  134. package/dist/services/account-activity/account-activity.schemas.d.ts.map +1 -0
  135. package/dist/services/account-activity/account-activity.schemas.js +44 -0
  136. package/dist/services/account-activity/account-activity.schemas.js.map +1 -0
  137. package/dist/services/account-activity/account-activity.types.d.ts +2 -0
  138. package/dist/services/account-activity/service.d.ts +8 -0
  139. package/dist/services/account-activity/service.d.ts.map +1 -0
  140. package/dist/services/account-activity/service.js +9 -0
  141. package/dist/services/account-activity/service.js.map +1 -0
  142. package/dist/services/address-book/address-book.schemas.js +2 -2
  143. package/dist/services/api-keys/api-keys.schemas.js +2 -2
  144. package/dist/services/assistant/assistant-events.schemas.d.ts +81 -81
  145. package/dist/services/assistant/assistant.codecs.d.ts +7 -2
  146. package/dist/services/assistant/assistant.codecs.d.ts.map +1 -1
  147. package/dist/services/assistant/assistant.codecs.js +18 -2
  148. package/dist/services/assistant/assistant.codecs.js.map +1 -1
  149. package/dist/services/assistant/assistant.d.ts +29 -2
  150. package/dist/services/assistant/assistant.d.ts.map +1 -1
  151. package/dist/services/assistant/assistant.js +44 -2
  152. package/dist/services/assistant/assistant.js.map +1 -1
  153. package/dist/services/assistant/assistant.schemas.d.ts +111 -6
  154. package/dist/services/assistant/assistant.schemas.d.ts.map +1 -1
  155. package/dist/services/assistant/assistant.schemas.js +74 -6
  156. package/dist/services/assistant/assistant.schemas.js.map +1 -1
  157. package/dist/services/assistant/assistant.types.d.ts +3 -3
  158. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts +3 -1
  159. package/dist/services/auto-withdraw/auto-withdraw.codecs.d.ts.map +1 -1
  160. package/dist/services/auto-withdraw/auto-withdraw.codecs.js.map +1 -1
  161. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts +15 -13
  162. package/dist/services/auto-withdraw/auto-withdraw.schemas.d.ts.map +1 -1
  163. package/dist/services/auto-withdraw/auto-withdraw.schemas.js +1 -0
  164. package/dist/services/auto-withdraw/auto-withdraw.schemas.js.map +1 -1
  165. package/dist/services/balances/balances.d.ts +1 -13
  166. package/dist/services/balances/balances.d.ts.map +1 -1
  167. package/dist/services/balances/balances.js +1 -45
  168. package/dist/services/balances/balances.js.map +1 -1
  169. package/dist/services/balances/balances.schemas.d.ts +1 -67
  170. package/dist/services/balances/balances.schemas.d.ts.map +1 -1
  171. package/dist/services/balances/balances.schemas.js +1 -22
  172. package/dist/services/balances/balances.schemas.js.map +1 -1
  173. package/dist/services/balances/balances.types.d.ts +2 -2
  174. package/dist/services/candles/candles.schemas.d.ts +10 -10
  175. package/dist/services/changelog/changelog.schemas.d.ts +38 -38
  176. package/dist/services/checkpoints/checkpoints.schemas.d.ts +3 -3
  177. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts +11 -11
  178. package/dist/services/dust-conversion/dust-conversion.schemas.d.ts.map +1 -1
  179. package/dist/services/dust-conversion/dust-conversion.schemas.js +1 -1
  180. package/dist/services/dust-conversion/dust-conversion.schemas.js.map +1 -1
  181. package/dist/services/heatmap/heatmap.schemas.d.ts +4 -4
  182. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts +11 -6
  183. package/dist/services/internal-transfers/internal-transfers.codecs.d.ts.map +1 -1
  184. package/dist/services/internal-transfers/internal-transfers.codecs.js +6 -6
  185. package/dist/services/internal-transfers/internal-transfers.codecs.js.map +1 -1
  186. package/dist/services/internal-transfers/internal-transfers.d.ts +17 -10
  187. package/dist/services/internal-transfers/internal-transfers.d.ts.map +1 -1
  188. package/dist/services/internal-transfers/internal-transfers.js +21 -10
  189. package/dist/services/internal-transfers/internal-transfers.js.map +1 -1
  190. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts +43 -31
  191. package/dist/services/internal-transfers/internal-transfers.schemas.d.ts.map +1 -1
  192. package/dist/services/internal-transfers/internal-transfers.schemas.js +23 -12
  193. package/dist/services/internal-transfers/internal-transfers.schemas.js.map +1 -1
  194. package/dist/services/internal-transfers/internal-transfers.types.d.ts +2 -2
  195. package/dist/services/lifecycle/lifecycle.d.ts +1 -1
  196. package/dist/services/lifecycle/lifecycle.js +2 -3
  197. package/dist/services/lifecycle/lifecycle.js.map +1 -1
  198. package/dist/services/lifecycle/lifecycle.schemas.d.ts +40 -40
  199. package/dist/services/market-data/market-data.codecs.d.ts +8 -0
  200. package/dist/services/market-data/market-data.codecs.d.ts.map +1 -0
  201. package/dist/services/market-data/market-data.codecs.js +7 -1
  202. package/dist/services/market-data/market-data.codecs.js.map +1 -1
  203. package/dist/services/market-data/market-data.d.ts +3 -2
  204. package/dist/services/market-data/market-data.d.ts.map +1 -1
  205. package/dist/services/market-data/market-data.js +3 -2
  206. package/dist/services/market-data/market-data.js.map +1 -1
  207. package/dist/services/market-data/market-data.schemas.d.ts +332 -4
  208. package/dist/services/market-data/market-data.schemas.d.ts.map +1 -1
  209. package/dist/services/market-data/market-data.schemas.js +56 -8
  210. package/dist/services/market-data/market-data.schemas.js.map +1 -1
  211. package/dist/services/market-data/market-data.types.d.ts +3 -2
  212. package/dist/services/notifications/notifications.codecs.d.ts +1 -1
  213. package/dist/services/notifications/notifications.codecs.d.ts.map +1 -1
  214. package/dist/services/notifications/notifications.codecs.js +2 -1
  215. package/dist/services/notifications/notifications.codecs.js.map +1 -1
  216. package/dist/services/notifications/notifications.d.ts +4 -2
  217. package/dist/services/notifications/notifications.d.ts.map +1 -1
  218. package/dist/services/notifications/notifications.js +4 -2
  219. package/dist/services/notifications/notifications.js.map +1 -1
  220. package/dist/services/notifications/notifications.schemas.d.ts +63 -7
  221. package/dist/services/notifications/notifications.schemas.d.ts.map +1 -1
  222. package/dist/services/notifications/notifications.schemas.js +5 -0
  223. package/dist/services/notifications/notifications.schemas.js.map +1 -1
  224. package/dist/services/orderbook/orderbook.js +3 -2
  225. package/dist/services/orderbook/orderbook.js.map +1 -1
  226. package/dist/services/orders/order-enums.codecs.d.ts +2 -0
  227. package/dist/services/orders/order-errors.schemas.d.ts +50 -5
  228. package/dist/services/orders/order-errors.schemas.d.ts.map +1 -1
  229. package/dist/services/orders/order-errors.schemas.js +13 -3
  230. package/dist/services/orders/order-errors.schemas.js.map +1 -1
  231. package/dist/services/orders/orders-batch.schemas.d.ts +310 -70
  232. package/dist/services/orders/orders-batch.schemas.d.ts.map +1 -1
  233. package/dist/services/orders/orders-input.schemas.d.ts +58 -11
  234. package/dist/services/orders/orders-input.schemas.d.ts.map +1 -1
  235. package/dist/services/orders/orders-input.schemas.js +1 -1
  236. package/dist/services/orders/orders-output.schemas.d.ts +13 -13
  237. package/dist/services/policies/api-key-policies/api-key-policies.schemas.d.ts +15 -15
  238. package/dist/services/policies/api-key-policies/api-key-policies.schemas.js +1 -1
  239. package/dist/services/policies/shared.codecs.js +12 -6
  240. package/dist/services/policies/shared.codecs.js.map +1 -1
  241. package/dist/services/policies/shared.d.ts +1 -1
  242. package/dist/services/policies/shared.js +1 -1
  243. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.d.ts +9 -9
  244. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js +4 -30
  245. package/dist/services/policies/subaccount-policies/subaccount-policies.schemas.js.map +1 -1
  246. package/dist/services/price-alerts/price-alerts.d.ts +5 -2
  247. package/dist/services/price-alerts/price-alerts.d.ts.map +1 -1
  248. package/dist/services/price-alerts/price-alerts.js +5 -2
  249. package/dist/services/price-alerts/price-alerts.js.map +1 -1
  250. package/dist/services/price-alerts/price-alerts.schemas.js +1 -1
  251. package/dist/services/rewards/rewards.schemas.d.ts +4 -4
  252. package/dist/services/social-verification/social-verification.schemas.d.ts +9 -0
  253. package/dist/services/social-verification/social-verification.schemas.d.ts.map +1 -1
  254. package/dist/services/social-verification/social-verification.schemas.js +9 -2
  255. package/dist/services/social-verification/social-verification.schemas.js.map +1 -1
  256. package/dist/services/statement-exports/statement-exports.codecs.d.ts +3 -2
  257. package/dist/services/statement-exports/statement-exports.codecs.d.ts.map +1 -1
  258. package/dist/services/statement-exports/statement-exports.codecs.js +2 -1
  259. package/dist/services/statement-exports/statement-exports.codecs.js.map +1 -1
  260. package/dist/services/statement-exports/statement-exports.d.ts +25 -10
  261. package/dist/services/statement-exports/statement-exports.d.ts.map +1 -1
  262. package/dist/services/statement-exports/statement-exports.js +33 -10
  263. package/dist/services/statement-exports/statement-exports.js.map +1 -1
  264. package/dist/services/statement-exports/statement-exports.schemas.d.ts +38 -10
  265. package/dist/services/statement-exports/statement-exports.schemas.d.ts.map +1 -1
  266. package/dist/services/statement-exports/statement-exports.schemas.js +25 -6
  267. package/dist/services/statement-exports/statement-exports.schemas.js.map +1 -1
  268. package/dist/services/statement-exports/statement-exports.types.d.ts +2 -2
  269. package/dist/services/subaccounts/subaccounts.codecs.js +112 -38
  270. package/dist/services/subaccounts/subaccounts.codecs.js.map +1 -1
  271. package/dist/services/subaccounts/subaccounts.d.ts +2 -1
  272. package/dist/services/subaccounts/subaccounts.d.ts.map +1 -1
  273. package/dist/services/subaccounts/subaccounts.js +3 -3
  274. package/dist/services/subaccounts/subaccounts.js.map +1 -1
  275. package/dist/services/subaccounts/subaccounts.schemas.d.ts +12 -5
  276. package/dist/services/subaccounts/subaccounts.schemas.d.ts.map +1 -1
  277. package/dist/services/subaccounts/subaccounts.schemas.js +10 -3
  278. package/dist/services/subaccounts/subaccounts.schemas.js.map +1 -1
  279. package/dist/services/system/system.d.ts +12 -1
  280. package/dist/services/system/system.d.ts.map +1 -1
  281. package/dist/services/system/system.js +5 -0
  282. package/dist/services/system/system.js.map +1 -1
  283. package/dist/services/system/system.schemas.d.ts +13 -13
  284. package/dist/services/system/system.types.d.ts +2 -2
  285. package/dist/services/trades/trades.schemas.d.ts +2 -2
  286. package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts +8 -0
  287. package/dist/services/trading-withdraws/trading-withdraws.codecs.d.ts.map +1 -0
  288. package/dist/services/trading-withdraws/trading-withdraws.codecs.js +7 -1
  289. package/dist/services/trading-withdraws/trading-withdraws.codecs.js.map +1 -1
  290. package/dist/services/trading-withdraws/trading-withdraws.d.ts +2 -1
  291. package/dist/services/trading-withdraws/trading-withdraws.d.ts.map +1 -1
  292. package/dist/services/trading-withdraws/trading-withdraws.js +2 -1
  293. package/dist/services/trading-withdraws/trading-withdraws.js.map +1 -1
  294. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts +15 -0
  295. package/dist/services/trading-withdraws/trading-withdraws.schemas.d.ts.map +1 -1
  296. package/dist/services/trading-withdraws/trading-withdraws.schemas.js +16 -2
  297. package/dist/services/trading-withdraws/trading-withdraws.schemas.js.map +1 -1
  298. package/dist/services/trading-withdraws/trading-withdraws.types.d.ts +2 -1
  299. package/dist/services/transfers/transfers.schemas.d.ts +4 -4
  300. package/dist/services/triggers/trigger-child-order.schemas.js +1 -1
  301. package/dist/services/triggers/trigger-child-order.schemas.js.map +1 -1
  302. package/dist/services/triggers/trigger-input.schemas.d.ts +10 -10
  303. package/dist/services/triggers/triggers-output.schemas.d.ts +170 -52
  304. package/dist/services/triggers/triggers-output.schemas.d.ts.map +1 -1
  305. package/dist/services/triggers/triggers-output.schemas.js +13 -3
  306. package/dist/services/triggers/triggers-output.schemas.js.map +1 -1
  307. package/dist/services/triggers/triggers.codecs.d.ts +10 -0
  308. package/dist/services/triggers/triggers.codecs.d.ts.map +1 -0
  309. package/dist/services/triggers/triggers.codecs.js +7 -1
  310. package/dist/services/triggers/triggers.codecs.js.map +1 -1
  311. package/dist/services/triggers/triggers.d.ts +2 -2
  312. package/dist/services/triggers/triggers.js +2 -2
  313. package/dist/services/triggers/triggers.js.map +1 -1
  314. package/dist/services/zipper/zipper.d.ts.map +1 -1
  315. package/dist/services/zipper/zipper.js +13 -7
  316. package/dist/services/zipper/zipper.js.map +1 -1
  317. package/dist/services/zipper/zipper.schemas.d.ts +7 -2
  318. package/dist/services/zipper/zipper.schemas.d.ts.map +1 -1
  319. package/dist/services/zipper/zipper.schemas.js +29 -9
  320. package/dist/services/zipper/zipper.schemas.js.map +1 -1
  321. package/dist/services/zipper/zipper.types.d.ts +2 -2
  322. package/dist/shared/catalog-config.d.ts +16 -2
  323. package/dist/shared/catalog-config.d.ts.map +1 -1
  324. package/dist/shared/catalog-config.js.map +1 -1
  325. package/dist/shared/connect-error-mapping.d.ts.map +1 -1
  326. package/dist/shared/connect-error-mapping.js +27 -4
  327. package/dist/shared/connect-error-mapping.js.map +1 -1
  328. package/dist/shared/error-detail.d.ts +10 -0
  329. package/dist/shared/error-detail.d.ts.map +1 -1
  330. package/dist/shared/error-detail.js.map +1 -1
  331. package/dist/shared/error-details/auth.js +6 -0
  332. package/dist/shared/error-details/auth.js.map +1 -1
  333. package/dist/shared/errors.d.ts +5 -1
  334. package/dist/shared/errors.d.ts.map +1 -1
  335. package/dist/shared/errors.js +3 -0
  336. package/dist/shared/errors.js.map +1 -1
  337. package/dist/shared/ledger-codes.d.ts +3 -1
  338. package/dist/shared/ledger-codes.d.ts.map +1 -1
  339. package/dist/shared/ledger-codes.js +6 -3
  340. package/dist/shared/ledger-codes.js.map +1 -1
  341. package/dist/shared/rate-limit.schemas.d.ts +1 -1
  342. package/dist/wired-services.d.ts.map +1 -1
  343. package/dist/wired-services.js +3 -1
  344. package/dist/wired-services.js.map +1 -1
  345. package/package.json +1 -1
@@ -50,7 +50,8 @@ declare class TradingWithdrawsService {
50
50
  /**
51
51
  * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a
52
52
  * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there
53
- * until moved. API keys need `read-balances`.
53
+ * until moved. Balances that could not be read are listed in `unavailableAssets`, not
54
+ * reported as zero. API keys need `read-balances`.
54
55
  */
55
56
  getWalletBalances(input?: GetWalletBalancesInput, options?: PolyesterRequestOptions): Promise<GetWalletBalancesResult>;
56
57
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"mappings":";;;;;;;;KA8CY;EACR;EACA;;;;;EAKA,cAAc,oBAAoB,QAAQ;;KAGlC;EACR;EACA,uBAAuB;;KAGf,6CAA6C;EACrD,eAAe;;KAGP,mDACR;EACI,eAAe;;KAGX,0BAA0B;;EAElC,UAAU;;;;;;EAMV;;;;;;EAMA,SAAS,UAAU,6BAA6B,QAAQ;;;;;cAoG/C;;EAaL,YAAA,YAAY,mBACZ,UAAU,gCACV,eAAe,8BACf,QAAQ,WACR,UAAU,eACV,OAAO,kBAAkB;;;;;;EAkBvB,kBACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;;;EAeL,oBACF,OAAO,kCACP,UAAU,0BACX,QAAQ;;;;EAYL,gBACF,OAAO,4CACP,UAAU,2BACX,QAAQ;;;;;EASL,iBACF,OAAO,6CACR,QAAQ;;;;EAWL,sBACF,OAAO,kDACP,UAAU,2BACX,QAAQ;;;;;EASL,uBACF,OAAO,mDACR,QAAQ"}
1
+ {"version":3,"file":"trading-withdraws.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"mappings":";;;;;;;;KA8CY;EACR;EACA;;;;;EAKA,cAAc,oBAAoB,QAAQ;;KAGlC;EACR;EACA,uBAAuB;;KAGf,6CAA6C;EACrD,eAAe;;KAGP,mDACR;EACI,eAAe;;KAGX,0BAA0B;;EAElC,UAAU;;;;;;EAMV;;;;;;EAMA,SAAS,UAAU,6BAA6B,QAAQ;;;;;cAoG/C;;EAaL,YAAA,YAAY,mBACZ,UAAU,gCACV,eAAe,8BACf,QAAQ,WACR,UAAU,eACV,OAAO,kBAAkB;;;;;;;EAmBvB,kBACF,QAAO,wBACP,UAAU,0BACX,QAAQ;;;;EAeL,oBACF,OAAO,kCACP,UAAU,0BACX,QAAQ;;;;EAYL,gBACF,OAAO,4CACP,UAAU,2BACX,QAAQ;;;;;EASL,iBACF,OAAO,6CACR,QAAQ;;;;EAWL,sBACF,OAAO,kDACP,UAAU,2BACX,QAAQ;;;;;EASL,uBACF,OAAO,mDACR,QAAQ"}
@@ -89,7 +89,8 @@ var TradingWithdrawsService = class {
89
89
  /**
90
90
  * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a
91
91
  * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there
92
- * until moved. API keys need `read-balances`.
92
+ * until moved. Balances that could not be read are listed in `unavailableAssets`, not
93
+ * reported as zero. API keys need `read-balances`.
93
94
  */
94
95
  async getWalletBalances(input = {}, options) {
95
96
  const request = parse(GetWalletBalancesInputSchema, resolveAccountScopedInput(input, this.#resolver));
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#auth","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","#prepareWithdraw","Proto.TradingWithdrawIntentPayloadSchema"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ConfigurationError, ValidationError } from \"../../shared/errors.js\";\nimport { create, toBinary } from \"@bufbuild/protobuf\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport { checksumEvmAddress, evmHexToBytes } from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n signApiKeyEd25519Payload,\n type ApiKeyEd25519AuthProvider,\n type AuthApiTransports,\n type JwtAuthProvider,\n} from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n GetWalletBalancesInputSchema,\n GetWalletBalancesResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n renewTradingWithdrawPayload,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type GetWalletBalancesInput,\n type GetWalletBalancesResult,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\nimport { buildTradingWithdrawWalletMessage } from \"./wallet-message.js\";\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n /**\n * Signs the UTF-8 message directly using EIP-191 personal_sign, without pre-hashing or switching chains.\n * For a viem account, use `(message) => account.signMessage({ message })`.\n */\n signMessage: (message: string) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /** When the backend stops accepting the currently signed request. */\n deadline: Date;\n /**\n * True once the deadline is less than a minute away. The withdraw signs again on\n * `submit` from then on, so callers can keep resubmitting the same prepared withdraw,\n * e.g. after a slow MFA step-up.\n */\n isExpired: () => boolean;\n /**\n * Submits the payload and signature produced during preparation. Repeated calls only\n * change transport options such as the step-up token, unless the deadline is near: the\n * withdraw then signs a fresh deadline and nonce with the same idempotency key.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype SignedTradingWithdraw = {\n payload: TradingWithdrawIntentPayloadRequest;\n send: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n};\n\n// Leaves room for the request to reach the backend and for modest clock skew.\nconst PREPARED_WITHDRAW_EXPIRY_MARGIN_MS = 60_000;\n\nfunction deadlineMs(payload: TradingWithdrawIntentPayloadRequest): number {\n return Number(payload.deadlineTsSec) * 1000;\n}\n\nfunction preparedWithdraw(\n signed: SignedTradingWithdraw,\n resign: (payload: TradingWithdrawIntentPayloadRequest) => Promise<SignedTradingWithdraw>,\n): PreparedTradingWithdraw {\n let current = signed;\n const isExpired = () =>\n Date.now() >= deadlineMs(current.payload) - PREPARED_WITHDRAW_EXPIRY_MARGIN_MS;\n return {\n get deadline() {\n return new Date(deadlineMs(current.payload));\n },\n isExpired,\n submit: async (options) => {\n if (isExpired()) {\n current = await resign(renewTradingWithdrawPayload(current.payload));\n }\n return current.send(options);\n },\n };\n}\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim().toLowerCase();\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signMessage(\n buildTradingWithdrawWalletMessage({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n if (!/^0x[0-9a-fA-F]{128}(?:00|01|1[bBcC])$/.test(signature)) {\n throw new ValidationError(\n \"Trading withdraw wallet signature must be 65 bytes with recovery byte 0, 1, 27, or 28.\",\n );\n }\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents, signed by the client's API key or a wallet (EIP-191).\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transports: AuthApiTransports,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider,\n ) {\n this.#client = createClient(Proto.WithdrawService, transports.authApi);\n this.#auth = auth;\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a\n * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there\n * until moved. API keys need `read-balances`.\n */\n async getWalletBalances(\n input: GetWalletBalancesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<GetWalletBalancesResult> {\n const request = parse(\n GetWalletBalancesInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.getWalletBalances(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetWalletBalancesResultSchema, response);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one. API keys need `read-withdraw-validation`.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise the client's API key signs the payload for the API-key endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise the client's API key signs the payload for the API-key endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n\n const auth = this.#auth;\n if (auth?.kind !== \"api-key-ed25519\") {\n throw new ConfigurationError(\n \"Trading withdraw requires a wallet signer or API-key auth.\",\n );\n }\n // CreateTradingWithdrawRequest has no subaccount field: the API key decides the account.\n if (validated.subaccountId !== undefined) {\n throw new ValidationError(\n 'API-key trading withdraws cannot target a subaccount. Use `account: \"main\"` or a wallet signer.',\n );\n }\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n // The backend verifies the signature over the payload's protobuf encoding.\n const payloadSignature = await signApiKeyEd25519Payload(\n auth,\n toBinary(\n Proto.TradingWithdrawIntentPayloadSchema,\n create(Proto.TradingWithdrawIntentPayloadSchema, payload),\n ),\n );\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n { payload, payloadSignature },\n toConnectCallOptions(options),\n );\n return parse(CreateTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6FA,MAAM,qCAAqC;AAE3C,SAAS,WAAW,SAAsD;CACtE,OAAO,OAAO,QAAQ,aAAa,IAAI;AAC3C;AAEA,SAAS,iBACL,QACA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AC5D;GACJ;EACJ;EACA,OAAO,iBAAiB,MAAM,KAAK,UAAU,OAAO,GAAG,IAAI;CAC/D;AACJ"}
1
+ {"version":3,"file":"trading-withdraws.js","names":["#client","Proto.WithdrawService","#auth","#resolver","#signingConfig","#catalog","#scales","#toFundingInputSchema","#toExternalChainInputSchema","#prepareWithdraw","Proto.TradingWithdrawIntentPayloadSchema"],"sources":["../../../src/services/trading-withdraws/trading-withdraws.ts"],"sourcesContent":["import { ConfigurationError, ValidationError } from \"../../shared/errors.js\";\nimport { create, toBinary } from \"@bufbuild/protobuf\";\nimport { createClient, type Client } from \"@connectrpc/connect\";\nimport type { Address, Hex } from \"viem\";\nimport { checksumEvmAddress, evmHexToBytes } from \"../../utils/evm.js\";\nimport type { ClientCatalog } from \"../../catalogs/types.js\";\nimport * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { idToBigInt } from \"../../utils/base58-id.js\";\nimport { removeUndefined } from \"../../utils/remove-undefined.js\";\nimport {\n toConnectCallOptions,\n type PolyesterMutationOptions,\n type PolyesterRequestOptions,\n} from \"../../shared/request-options.js\";\nimport { type SubaccountResolver, resolveAccountScopedInput } from \"../subaccount-resolver.js\";\nimport type { SdkScales } from \"../../shared/decimal-surface.js\";\nimport {\n signApiKeyEd25519Payload,\n type ApiKeyEd25519AuthProvider,\n type AuthApiTransports,\n type JwtAuthProvider,\n} from \"../../shared/transports.js\";\nimport { parse } from \"../../shared/validation.js\";\nimport {\n createCreateTradingWithdrawToExternalChainInputSchema,\n createCreateTradingWithdrawToFundingInputSchema,\n CreateTradingWithdrawResultSchema,\n CreateWalletTradingWithdrawResultSchema,\n GetWalletBalancesInputSchema,\n GetWalletBalancesResultSchema,\n ValidateWithdrawDestinationInputSchema,\n ValidateWithdrawDestinationResultSchema,\n renewTradingWithdrawPayload,\n type CreateTradingWithdrawResult,\n type CreateTradingWithdrawToExternalChainInput,\n type CreateTradingWithdrawToExternalChainRequest,\n type CreateTradingWithdrawToFundingInput,\n type CreateTradingWithdrawToFundingRequest,\n type GetWalletBalancesInput,\n type GetWalletBalancesResult,\n type TradingWithdrawIntentPayloadRequest,\n type ValidateWithdrawDestinationInput,\n type ValidateWithdrawDestinationResult,\n} from \"./trading-withdraws.schemas.js\";\nimport { buildTradingWithdrawWalletMessage } from \"./wallet-message.js\";\n\nexport type TradingWithdrawWalletSigner = {\n signerWallet: string;\n accountId: string;\n /**\n * Signs the UTF-8 message directly using EIP-191 personal_sign, without pre-hashing or switching chains.\n * For a viem account, use `(message) => account.signMessage({ message })`.\n */\n signMessage: (message: string) => Promise<Hex>;\n};\n\nexport type TradingWithdrawSigningConfig = {\n chainId: number;\n tradingGatewayAddress: Address;\n};\n\nexport type CreateTradingWithdrawToFundingServiceInput = CreateTradingWithdrawToFundingInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n};\n\nexport type CreateTradingWithdrawToExternalChainServiceInput =\n CreateTradingWithdrawToExternalChainInput & {\n walletSigner?: TradingWithdrawWalletSigner;\n };\n\nexport type PreparedTradingWithdraw = Readonly<{\n /** When the backend stops accepting the currently signed request. */\n deadline: Date;\n /**\n * True once the deadline is less than a minute away. The withdraw signs again on\n * `submit` from then on, so callers can keep resubmitting the same prepared withdraw,\n * e.g. after a slow MFA step-up.\n */\n isExpired: () => boolean;\n /**\n * Submits the payload and signature produced during preparation. Repeated calls only\n * change transport options such as the step-up token, unless the deadline is near: the\n * withdraw then signs a fresh deadline and nonce with the same idempotency key.\n */\n submit: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n}>;\n\ntype SignedTradingWithdraw = {\n payload: TradingWithdrawIntentPayloadRequest;\n send: (options?: PolyesterMutationOptions) => Promise<CreateTradingWithdrawResult>;\n};\n\n// Leaves room for the request to reach the backend and for modest clock skew.\nconst PREPARED_WITHDRAW_EXPIRY_MARGIN_MS = 60_000;\n\nfunction deadlineMs(payload: TradingWithdrawIntentPayloadRequest): number {\n return Number(payload.deadlineTsSec) * 1000;\n}\n\nfunction preparedWithdraw(\n signed: SignedTradingWithdraw,\n resign: (payload: TradingWithdrawIntentPayloadRequest) => Promise<SignedTradingWithdraw>,\n): PreparedTradingWithdraw {\n let current = signed;\n const isExpired = () =>\n Date.now() >= deadlineMs(current.payload) - PREPARED_WITHDRAW_EXPIRY_MARGIN_MS;\n return {\n get deadline() {\n return new Date(deadlineMs(current.payload));\n },\n isExpired,\n submit: async (options) => {\n if (isExpired()) {\n current = await resign(renewTradingWithdrawPayload(current.payload));\n }\n return current.send(options);\n },\n };\n}\n\ntype TradingWithdrawRequest =\n | CreateTradingWithdrawToFundingRequest\n | CreateTradingWithdrawToExternalChainRequest;\n\nfunction resolveTradingWithdrawTargetAccountId(params: {\n subaccountId: bigint | undefined;\n rootAccountId: string;\n}): bigint {\n if (params.subaccountId !== undefined) return params.subaccountId;\n return idToBigInt(params.rootAccountId, \"targetAccountId\");\n}\n\nasync function resolveTradingWithdrawSigningConfig(params: {\n fallback: TradingWithdrawSigningConfig;\n catalog?: ClientCatalog;\n}): Promise<TradingWithdrawSigningConfig> {\n if (!params.catalog) return params.fallback;\n\n try {\n await params.catalog.ensureReady();\n const gateway = params.catalog.zipper.getContractByName(\"tradingGateway\");\n const address = gateway?.address?.trim();\n if (!address?.startsWith(\"0x\")) return params.fallback;\n\n return {\n chainId: params.fallback.chainId,\n tradingGatewayAddress: checksumEvmAddress(address),\n };\n } catch {\n return params.fallback;\n }\n}\n\nasync function resolveWalletSignature(params: {\n signingConfig: TradingWithdrawSigningConfig;\n payload: TradingWithdrawIntentPayloadRequest;\n walletSigner: TradingWithdrawWalletSigner;\n targetAccountId: bigint;\n}): Promise<{ signerWallet: string; payloadSignature: Uint8Array }> {\n const signerWallet = params.walletSigner.signerWallet.trim().toLowerCase();\n const accountId = idToBigInt(params.walletSigner.accountId, \"accountId\");\n const signature = await params.walletSigner.signMessage(\n buildTradingWithdrawWalletMessage({\n signingConfig: params.signingConfig,\n payload: params.payload,\n signerWallet,\n accountId,\n targetAccountId: params.targetAccountId,\n }),\n );\n if (!/^0x[0-9a-fA-F]{128}(?:00|01|1[bBcC])$/.test(signature)) {\n throw new ValidationError(\n \"Trading withdraw wallet signature must be 65 bytes with recovery byte 0, 1, 27, or 28.\",\n );\n }\n return {\n signerWallet,\n payloadSignature: evmHexToBytes(signature),\n };\n}\n\n/**\n * Creates durable Trading withdrawal intents, signed by the client's API key or a wallet (EIP-191).\n */\nexport class TradingWithdrawsService {\n #client: Client<typeof Proto.WithdrawService>;\n #resolver?: SubaccountResolver;\n #signingConfig: TradingWithdrawSigningConfig;\n #catalog?: ClientCatalog;\n #scales: SdkScales;\n #auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider;\n #toFundingInputSchema: ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>;\n #toExternalChainInputSchema: ReturnType<\n typeof createCreateTradingWithdrawToExternalChainInputSchema\n >;\n\n constructor(\n transports: AuthApiTransports,\n resolver: SubaccountResolver | undefined,\n signingConfig: TradingWithdrawSigningConfig,\n scales: SdkScales,\n catalog?: ClientCatalog,\n auth?: JwtAuthProvider | ApiKeyEd25519AuthProvider,\n ) {\n this.#client = createClient(Proto.WithdrawService, transports.authApi);\n this.#auth = auth;\n this.#resolver = resolver;\n this.#signingConfig = signingConfig;\n this.#catalog = catalog;\n this.#scales = scales;\n this.#toFundingInputSchema = createCreateTradingWithdrawToFundingInputSchema(scales);\n this.#toExternalChainInputSchema =\n createCreateTradingWithdrawToExternalChainInputSchema(scales);\n }\n\n /**\n * Reads the zTokens the account's smart account wallet holds on Polyester Chain, such as a\n * rejected withdrawal's refund (see the lifecycle step's `refundAddress`), which stays there\n * until moved. Balances that could not be read are listed in `unavailableAssets`, not\n * reported as zero. API keys need `read-balances`.\n */\n async getWalletBalances(\n input: GetWalletBalancesInput = {},\n options?: PolyesterRequestOptions,\n ): Promise<GetWalletBalancesResult> {\n const request = parse(\n GetWalletBalancesInputSchema,\n resolveAccountScopedInput(input, this.#resolver),\n );\n const response = await this.#client.getWalletBalances(\n removeUndefined(request),\n toConnectCallOptions(options),\n );\n return parse(GetWalletBalancesResultSchema, response);\n }\n\n /**\n * Checks whether an external-chain destination can receive a withdrawal without creating, signing, or reserving one. API keys need `read-withdraw-validation`.\n */\n async validateDestination(\n input: ValidateWithdrawDestinationInput,\n options?: PolyesterRequestOptions,\n ): Promise<ValidateWithdrawDestinationResult> {\n const request = parse(ValidateWithdrawDestinationInputSchema, input);\n const response = await this.#client.validateWithdrawDestination(\n request,\n toConnectCallOptions(options),\n );\n return parse(ValidateWithdrawDestinationResultSchema, response);\n }\n\n /**\n * Builds a Trading-to-Funding withdraw intent payload with asset id, decimal amount, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise the client's API key signs the payload for the API-key endpoint.\n */\n async createToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToFunding(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-Funding withdrawal once so the exact request can be\n * resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToFunding(\n input: CreateTradingWithdrawToFundingServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toFundingInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n /**\n * Builds a Trading-to-external-chain withdraw intent payload with asset id, decimal gross amount, destination network, destination address, five-minute deadline, nonce, and idempotency key. If a wallet signer is provided, it signs the canonical EIP-191 message and calls the wallet endpoint; otherwise the client's API key signs the payload for the API-key endpoint.\n */\n async createToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n options?: PolyesterMutationOptions,\n ): Promise<CreateTradingWithdrawResult> {\n const prepared = await this.prepareToExternalChain(input);\n return prepared.submit(options);\n }\n\n /**\n * Builds and signs a Trading-to-external-chain withdrawal once so the exact request can\n * be resubmitted after backend-directed authorization such as MFA step-up.\n */\n async prepareToExternalChain(\n input: CreateTradingWithdrawToExternalChainServiceInput,\n ): Promise<PreparedTradingWithdraw> {\n await this.#scales.ready();\n const { walletSigner, ...inputForValidation } = input;\n const resolvedInput = resolveAccountScopedInput(inputForValidation, this.#resolver);\n const validated = parse(this.#toExternalChainInputSchema, resolvedInput);\n return this.#prepareWithdraw(validated, walletSigner);\n }\n\n async #prepareWithdraw(\n validated: TradingWithdrawRequest,\n walletSigner: TradingWithdrawWalletSigner | undefined,\n ): Promise<PreparedTradingWithdraw> {\n if (walletSigner) {\n const signingConfig = await resolveTradingWithdrawSigningConfig({\n fallback: this.#signingConfig,\n catalog: this.#catalog,\n });\n const targetAccountId = resolveTradingWithdrawTargetAccountId({\n subaccountId: validated.subaccountId,\n rootAccountId: walletSigner.accountId,\n });\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n const walletSignature = await resolveWalletSignature({\n signingConfig,\n payload,\n walletSigner,\n targetAccountId,\n });\n const request = removeUndefined({\n payload,\n subaccountId: validated.subaccountId,\n signerWallet: walletSignature.signerWallet,\n payloadSignature: walletSignature.payloadSignature,\n });\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createWalletTradingWithdraw(\n request,\n toConnectCallOptions(options),\n );\n return parse(CreateWalletTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n\n const auth = this.#auth;\n if (auth?.kind !== \"api-key-ed25519\") {\n throw new ConfigurationError(\n \"Trading withdraw requires a wallet signer or API-key auth.\",\n );\n }\n // CreateTradingWithdrawRequest has no subaccount field: the API key decides the account.\n if (validated.subaccountId !== undefined) {\n throw new ValidationError(\n 'API-key trading withdraws cannot target a subaccount. Use `account: \"main\"` or a wallet signer.',\n );\n }\n const sign = async (\n payload: TradingWithdrawIntentPayloadRequest,\n ): Promise<SignedTradingWithdraw> => {\n // The backend verifies the signature over the payload's protobuf encoding.\n const payloadSignature = await signApiKeyEd25519Payload(\n auth,\n toBinary(\n Proto.TradingWithdrawIntentPayloadSchema,\n create(Proto.TradingWithdrawIntentPayloadSchema, payload),\n ),\n );\n return {\n payload,\n send: async (options) => {\n const response = await this.#client.createTradingWithdraw(\n { payload, payloadSignature },\n toConnectCallOptions(options),\n );\n return parse(CreateTradingWithdrawResultSchema, response);\n },\n };\n };\n return preparedWithdraw(await sign(validated.payload), sign);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AA6FA,MAAM,qCAAqC;AAE3C,SAAS,WAAW,SAAsD;CACtE,OAAO,OAAO,QAAQ,aAAa,IAAI;AAC3C;AAEA,SAAS,iBACL,QACA,QACuB;CACvB,IAAI,UAAU;CACd,MAAM,kBACF,KAAK,IAAI,KAAK,WAAW,QAAQ,OAAO,IAAI;CAChD,OAAO;EACH,IAAI,WAAW;GACX,OAAO,IAAI,KAAK,WAAW,QAAQ,OAAO,CAAC;EAC/C;EACA;EACA,QAAQ,OAAO,YAAY;GACvB,IAAI,UAAU,GACV,UAAU,MAAM,OAAO,4BAA4B,QAAQ,OAAO,CAAC;GAEvE,OAAO,QAAQ,KAAK,OAAO;EAC/B;CACJ;AACJ;AAMA,SAAS,sCAAsC,QAGpC;CACP,IAAI,OAAO,iBAAiB,KAAA,GAAW,OAAO,OAAO;CACrD,OAAO,WAAW,OAAO,eAAe,iBAAiB;AAC7D;AAEA,eAAe,oCAAoC,QAGT;CACtC,IAAI,CAAC,OAAO,SAAS,OAAO,OAAO;CAEnC,IAAI;EACA,MAAM,OAAO,QAAQ,YAAY;EAEjC,MAAM,UADU,OAAO,QAAQ,OAAO,kBAAkB,gBAClC,CAAC,EAAE,SAAS,KAAK;EACvC,IAAI,CAAC,SAAS,WAAW,IAAI,GAAG,OAAO,OAAO;EAE9C,OAAO;GACH,SAAS,OAAO,SAAS;GACzB,uBAAuB,mBAAmB,OAAO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O,iBAAiB,MAAM,KAAK,UAAU,OAAO,GAAG,IAAI;EAC/D;EAEA,MAAM,OAAO,KAAKE;EAClB,IAAI,MAAM,SAAS,mBACf,MAAM,IAAI,mBACN,4DACJ;EAGJ,IAAI,UAAU,iBAAiB,KAAA,GAC3B,MAAM,IAAI,gBACN,mGACJ;EAEJ,MAAM,OAAO,OACT,YACiC;GAEjC,MAAM,mBAAmB,MAAM,yBAC3B,MACA,SACIQ,oCACA,OAAOA,oCAA0C,OAAO,CAC5D,CACJ;GACA,OAAO;IACH;IACA,MAAM,OAAO,YAAY;KACrB,MAAM,WAAW,MAAM,KAAKV,QAAQ,sBAChC;MAAE;MAAS;KAAiB,GAC5B,qBAAqB,OAAO,CAChC;KACA,OAAO,MAAM,mCAAmC,QAAQ;IAC5D;GACJ;EACJ;EACA,OAAO,iBAAiB,MAAM,KAAK,UAAU,OAAO,GAAG,IAAI;CAC/D;AACJ"}
@@ -45,6 +45,7 @@ declare function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScal
45
45
  declare function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales): v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
46
46
  readonly assetId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
47
47
  readonly quantity: v.StringSchema<undefined>;
48
+ /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */
48
49
  readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
49
50
  readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
50
51
  readonly idempotencyKey: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
@@ -76,6 +77,7 @@ declare const CreateTradingWithdrawResultSchema: v.ObjectSchema<{
76
77
  }, undefined>;
77
78
  type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;
78
79
  declare const ValidateWithdrawDestinationInputSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{
80
+ /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */
79
81
  readonly destinationChainId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>]>;
80
82
  readonly destinationAddress: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
81
83
  }, undefined>, v.TransformAction<{
@@ -151,12 +153,25 @@ declare const GetWalletBalancesResultSchema: v.ObjectSchema<{
151
153
  chainId: number;
152
154
  ztokenAddress: string;
153
155
  }>]>, undefined>;
156
+ /**
157
+ * zTokens whose balance could not be read: unknown, not zero. Read again later; the read is
158
+ * complete only when this is empty.
159
+ */
160
+ readonly unavailableAssets: v.ArraySchema<v.ObjectSchema<{
161
+ readonly zippedAssetId: v.NumberSchema<undefined>;
162
+ readonly unifiedAssetId: v.NumberSchema<undefined>;
163
+ readonly chainId: v.NumberSchema<undefined>;
164
+ readonly ztokenAddress: v.StringSchema<undefined>;
165
+ readonly reason: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.TransformAction<number, "unspecified" | "no_contract" | "read_failed" | "invalid_balance">]>, 0>;
166
+ }, undefined>, undefined>;
154
167
  }, undefined>;
155
168
  /**
156
169
  * zTokens the account's smart account wallet holds on Polyester Chain, read live from the
157
170
  * chain: for example a rejected withdrawal's refund, which stays there until moved. `amount`
158
171
  * is a decimal string (zTokens have 18 decimals); `chainId` is a `GetDepositWithdrawConfig`
159
172
  * chain. `balances` lists nonzero balances by `zippedAssetId` and is empty when there are none.
173
+ * An asset whose balance could not be read is in `unavailableAssets` instead, never in `balances`
174
+ * as zero.
160
175
  */
161
176
  type GetWalletBalancesResult = v.InferOutput<typeof GetWalletBalancesResultSchema>;
162
177
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KAwBY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;;iBAmDG,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAmChF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;KAgBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC;cAGL,iCAA+B,EAAA;;;;;KAOzB,yBAAyB,EAAE,kBAAkB;cAE5C,+BAA6B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyB9B,0BAA0B,EAAE,mBAAmB"}
1
+ {"version":3,"file":"trading-withdraws.schemas.d.ts","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"mappings":";;;;;KA0BY;EACR,QAAQ;EACR;EACA;EACA,WAAW;EACX;EACA,OAAO;EACP;EACA;;KAGC;EACD;EACA,SAAS;;iBAmDG,gDAAgD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;GAmChF;iBAEe,sDAAsD,QAAQ,YAAS,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CtF;KAEW,sCAAsC,EAAE,WAChD,kBAAkB;KAOV,4CAA4C,EAAE,WACtD,kBAAkB;cAOT,mCAAiC,EAAA;;;KAIlC,8BAA8B,EAAE,mBAAmB;cAOlD,wCAAsC,EAAA,yBAAA,EAAA;;;;;;;;;;;KAiBvC,mCAAmC,EAAE,kBACtC;cA4CE,yCAAuC,EAAA,aAAA,EAAA,yBAAA,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAKxC,oCAAoC,EAAE,mBACvC;cAGL,iCAA+B,EAAA;;;;;KAOzB,yBAAyB,EAAE,kBAAkB;cAE5C,+BAA6B,EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwC9B,0BAA0B,EAAE,mBAAmB"}
@@ -1,11 +1,12 @@
1
1
  import { ConfigurationError } from "../../shared/errors.js";
2
2
  import { U128Schema } from "../../shared/schemas.js";
3
+ import { enumLabelSchema } from "../../shared/proto-enum-codec.js";
3
4
  import { fromU128, toU128 } from "../../utils/u128.js";
4
5
  import { quantityInputToE18, scaledToDecimalOutput } from "../../shared/decimal-surface.js";
5
6
  import { PositiveUint32InputSchema } from "../shared.js";
6
7
  import { AccountScopeInputEntries, accountScopeToSubaccountId } from "../../shared/account-scope.js";
7
8
  import "../../gen/chain/withdraw/v1/withdraw_pb.js";
8
- import { TradingWithdrawActionCodec, WithdrawDestinationValidationCodeCodec } from "./trading-withdraws.codecs.js";
9
+ import { TradingWithdrawActionCodec, WalletAssetUnavailableReasonCodec, WithdrawDestinationValidationCodeCodec } from "./trading-withdraws.codecs.js";
9
10
  import * as v from "valibot";
10
11
  //#region src/services/trading-withdraws/trading-withdraws.schemas.ts
11
12
  const DEFAULT_DEADLINE_SECONDS = 300;
@@ -75,6 +76,7 @@ function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
75
76
  ...AccountScopeInputEntries,
76
77
  assetId: PositiveUint32InputSchema,
77
78
  quantity: v.string(),
79
+ /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */
78
80
  destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
79
81
  destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),
80
82
  idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),
@@ -107,6 +109,7 @@ function createCreateTradingWithdrawToExternalChainInputSchema(scales) {
107
109
  const CreateTradingWithdrawResultSchema = v.object({ intentId: v.pipe(v.string(), v.trim(), v.minLength(1)) });
108
110
  const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;
109
111
  const ValidateWithdrawDestinationInputSchema = v.pipe(v.strictObject({
112
+ /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */
110
113
  destinationChainId: v.pipe(v.number(), v.integer(), v.gtValue(0), v.maxValue(Number.MAX_SAFE_INTEGER)),
111
114
  destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1))
112
115
  }), v.transform((input) => ({
@@ -153,7 +156,18 @@ const GetWalletBalancesResultSchema = v.object({
153
156
  }), v.transform(({ amountE18, ...balance }) => ({
154
157
  ...balance,
155
158
  amount: scaledToDecimalOutput(fromU128(amountE18), 18)
156
- }))))
159
+ })))),
160
+ /**
161
+ * zTokens whose balance could not be read: unknown, not zero. Read again later; the read is
162
+ * complete only when this is empty.
163
+ */
164
+ unavailableAssets: v.array(v.object({
165
+ zippedAssetId: v.number(),
166
+ unifiedAssetId: v.number(),
167
+ chainId: v.number(),
168
+ ztokenAddress: v.string(),
169
+ reason: v.optional(enumLabelSchema(WalletAssetUnavailableReasonCodec.protoToOutput), 0)
170
+ }))
157
171
  });
158
172
  //#endregion
159
173
  export { CreateTradingWithdrawResultSchema, CreateWalletTradingWithdrawResultSchema, GetWalletBalancesInputSchema, GetWalletBalancesResultSchema, ValidateWithdrawDestinationInputSchema, ValidateWithdrawDestinationResultSchema, createCreateTradingWithdrawToExternalChainInputSchema, createCreateTradingWithdrawToFundingInputSchema, renewTradingWithdrawPayload };
@@ -1 +1 @@
1
- {"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport {\n E18_SCALE,\n quantityInputToE18,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { fromU128, toU128, type U128Value } from \"../../utils/u128.js\";\nimport { U128Schema } from \"../../shared/schemas.js\";\nimport { ConfigurationError } from \"../../shared/errors.js\";\nimport {\n TradingWithdrawActionCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n throw new ConfigurationError(\"Secure nonce generation requires crypto.getRandomValues.\");\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0]!;\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n deadline: Date | undefined;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(\n input.deadline\n ? Math.floor(input.deadline.getTime() / 1000)\n : Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS,\n ),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\n/** The same withdraw with a fresh default deadline and nonce, for signing again. */\nexport function renewTradingWithdrawPayload(\n payload: TradingWithdrawIntentPayloadRequest,\n): TradingWithdrawIntentPayloadRequest {\n return {\n ...payload,\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n /**\n * When the signed authorization lapses. Defaults to five minutes from now\n * on the device clock.\n */\n deadline: v.optional(v.date()),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n deadline: input.deadline,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n /**\n * When the signed authorization lapses. Defaults to five minutes from now\n * on the device clock.\n */\n deadline: v.optional(v.date()),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n deadline: input.deadline,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n\nconst WalletBalancesInputObjectSchema = v.strictObject({ ...AccountScopeInputEntries });\n\nexport const GetWalletBalancesInputSchema = v.pipe(\n WalletBalancesInputObjectSchema,\n v.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })),\n);\n\nexport type GetWalletBalancesInput = v.InferInput<typeof WalletBalancesInputObjectSchema>;\n\nexport const GetWalletBalancesResultSchema = v.object({\n smartAccountAddress: v.string(),\n balances: v.array(\n v.pipe(\n v.object({\n zippedAssetId: v.number(),\n unifiedAssetId: v.number(),\n chainId: v.number(),\n ztokenAddress: v.string(),\n amountE18: v.optional(U128Schema),\n }),\n v.transform(({ amountE18, ...balance }) => ({\n ...balance,\n amount: scaledToDecimalOutput(fromU128(amountE18), E18_SCALE),\n })),\n ),\n ),\n});\n\n/**\n * zTokens the account's smart account wallet holds on Polyester Chain, read live from the\n * chain: for example a rejected withdrawal's refund, which stays there until moved. `amount`\n * is a decimal string (zTokens have 18 decimals); `chainId` is a `GetDepositWithdrawConfig`\n * chain. `balances` lists nonzero balances by `zippedAssetId` and is empty when there are none.\n */\nexport type GetWalletBalancesResult = v.InferOutput<typeof GetWalletBalancesResultSchema>;\n"],"mappings":";;;;;;;;;;AAsBA,MAAM,2BAA2B;AAkBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QACD,MAAM,IAAI,mBAAmB,0DAA0D;CAG3F,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM;CACpB,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAQE;CACpC,OAAO;EAC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,SAAS,UAAU;CACpC,CAAC,GACD,EAAE,WAAW,EAAE,WAAW,GAAG,eAAe;EACxC,GAAG;EACH,QAAQ,sBAAsB,SAAS,SAAS,GAAA,EAAY;CAChE,EAAE,CACN,CACJ;AACJ,CAAC"}
1
+ {"version":3,"file":"trading-withdraws.schemas.js","names":[],"sources":["../../../src/services/trading-withdraws/trading-withdraws.schemas.ts"],"sourcesContent":["import * as v from \"valibot\";\nimport { PositiveUint32InputSchema } from \"../shared.js\";\nimport {\n E18_SCALE,\n quantityInputToE18,\n scaledToDecimalOutput,\n type SdkScales,\n} from \"../../shared/decimal-surface.js\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport type * as Proto from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { WithdrawDestinationValidationCode } from \"../../gen/chain/withdraw/v1/withdraw_pb.js\";\nimport { fromU128, toU128, type U128Value } from \"../../utils/u128.js\";\nimport { U128Schema } from \"../../shared/schemas.js\";\nimport { ConfigurationError } from \"../../shared/errors.js\";\nimport { enumLabelSchema } from \"../../shared/proto-enum-codec.js\";\nimport {\n TradingWithdrawActionCodec,\n WalletAssetUnavailableReasonCodec,\n WithdrawDestinationValidationCodeCodec,\n} from \"./trading-withdraws.codecs.js\";\n\nconst DEFAULT_DEADLINE_SECONDS = 5 * 60;\n\nexport type TradingWithdrawIntentPayloadRequest = {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n amountE18: U128Value;\n deadlineTsSec: bigint;\n nonce: U128Value;\n destinationAddress: string;\n idempotencyKey: string;\n};\n\ntype CreateTradingWithdrawRequestBase = {\n subaccountId: bigint | undefined;\n payload: TradingWithdrawIntentPayloadRequest;\n};\n\nfunction createNonce(): bigint {\n const random = globalThis.crypto?.getRandomValues?.bind(globalThis.crypto);\n if (!random) {\n throw new ConfigurationError(\"Secure nonce generation requires crypto.getRandomValues.\");\n }\n\n const bytes = new BigUint64Array(1);\n random(bytes);\n const nonce = bytes[0]!;\n return nonce === 0n ? 1n : nonce;\n}\n\nfunction createTradingWithdrawPayload(input: {\n action: Proto.TradingWithdrawAction;\n assetId: number;\n destinationChainId: bigint;\n quantityScaled: bigint;\n destinationAddress: string;\n idempotencyKey: string;\n deadline: Date | undefined;\n}): TradingWithdrawIntentPayloadRequest {\n return {\n action: input.action,\n assetId: input.assetId,\n destinationChainId: input.destinationChainId,\n amountE18: toU128(input.quantityScaled),\n deadlineTsSec: BigInt(\n input.deadline\n ? Math.floor(input.deadline.getTime() / 1000)\n : Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS,\n ),\n nonce: toU128(createNonce()),\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n };\n}\n\n/** The same withdraw with a fresh default deadline and nonce, for signing again. */\nexport function renewTradingWithdrawPayload(\n payload: TradingWithdrawIntentPayloadRequest,\n): TradingWithdrawIntentPayloadRequest {\n return {\n ...payload,\n deadlineTsSec: BigInt(Math.floor(Date.now() / 1000) + DEFAULT_DEADLINE_SECONDS),\n nonce: toU128(createNonce()),\n };\n}\n\nexport function createCreateTradingWithdrawToFundingInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n destinationAddress: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n /**\n * When the signed authorization lapses. Defaults to five minutes from now\n * on the device clock.\n */\n deadline: v.optional(v.date()),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_funding,\n assetId: input.assetId,\n destinationChainId: 0n,\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n deadline: input.deadline,\n }),\n };\n }),\n );\n}\n\nexport function createCreateTradingWithdrawToExternalChainInputSchema(scales: SdkScales) {\n return v.pipe(\n v.strictObject({\n ...AccountScopeInputEntries,\n assetId: PositiveUint32InputSchema,\n quantity: v.string(),\n /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n idempotencyKey: v.pipe(v.string(), v.trim(), v.minLength(1)),\n signerWallet: v.optional(v.pipe(v.string(), v.trim()), \"\"),\n /**\n * When the signed authorization lapses. Defaults to five minutes from now\n * on the device clock.\n */\n deadline: v.optional(v.date()),\n }),\n v.transform((input): CreateTradingWithdrawRequestBase => {\n const quantityScaled = quantityInputToE18({\n scales,\n assetId: input.assetId,\n quantity: input.quantity,\n });\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n payload: createTradingWithdrawPayload({\n action: TradingWithdrawActionCodec.inputToProto.to_external_chain,\n assetId: input.assetId,\n destinationChainId: BigInt(input.destinationChainId),\n quantityScaled,\n destinationAddress: input.destinationAddress,\n idempotencyKey: input.idempotencyKey,\n deadline: input.deadline,\n }),\n };\n }),\n );\n}\n\nexport type CreateTradingWithdrawToFundingInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToFundingRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToFundingInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainInput = v.InferInput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport type CreateTradingWithdrawToExternalChainRequest = v.InferOutput<\n ReturnType<typeof createCreateTradingWithdrawToExternalChainInputSchema>\n>;\n\nexport const CreateTradingWithdrawResultSchema = v.object({\n intentId: v.pipe(v.string(), v.trim(), v.minLength(1)),\n});\n\nexport type CreateTradingWithdrawResult = v.InferOutput<typeof CreateTradingWithdrawResultSchema>;\n\nexport const CreateWalletTradingWithdrawResultSchema = CreateTradingWithdrawResultSchema;\nexport type CreateWalletTradingWithdrawResult = v.InferOutput<\n typeof CreateWalletTradingWithdrawResultSchema\n>;\n\nexport const ValidateWithdrawDestinationInputSchema = v.pipe(\n v.strictObject({\n /** Polyester chain ID of the network: a Zipper chain's `chainId`, not its `nativeChainId`. */\n destinationChainId: v.pipe(\n v.number(),\n v.integer(),\n v.gtValue(0),\n v.maxValue(Number.MAX_SAFE_INTEGER),\n ),\n destinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((input) => ({\n destinationChainId: BigInt(input.destinationChainId),\n destinationAddress: input.destinationAddress,\n })),\n);\n\nexport type ValidateWithdrawDestinationInput = v.InferInput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\nexport type ValidateWithdrawDestinationRequest = v.InferOutput<\n typeof ValidateWithdrawDestinationInputSchema\n>;\n\nconst ValidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(true),\n code: v.literal(WithdrawDestinationValidationCode.VALID),\n message: v.string(),\n canonicalDestinationAddress: v.pipe(v.string(), v.trim(), v.minLength(1)),\n }),\n v.transform((result) => ({\n ...result,\n code: WithdrawDestinationValidationCodeCodec.protoToOutput[result.code],\n })),\n);\n\nconst {\n [WithdrawDestinationValidationCode.VALID]: _validWithdrawDestinationCode,\n ...InvalidWithdrawDestinationCodeCodec\n} = WithdrawDestinationValidationCodeCodec.protoToOutput;\n\nconst InvalidWithdrawDestinationResultSchema = v.pipe(\n v.object({\n valid: v.literal(false),\n code: v.picklist([\n WithdrawDestinationValidationCode.RESULT_UNSPECIFIED,\n WithdrawDestinationValidationCode.INVALID_ADDRESS,\n WithdrawDestinationValidationCode.UNSUPPORTED_CHAIN,\n WithdrawDestinationValidationCode.POLYESTER_SMART_ACCOUNT,\n WithdrawDestinationValidationCode.TOKEN_CONTRACT,\n WithdrawDestinationValidationCode.DENYLISTED_ADDRESS,\n ]),\n message: v.string(),\n canonicalDestinationAddress: v.string(),\n }),\n v.transform((result) => ({\n ...result,\n code: InvalidWithdrawDestinationCodeCodec[result.code],\n })),\n);\n\nexport const ValidateWithdrawDestinationResultSchema = v.union([\n ValidWithdrawDestinationResultSchema,\n InvalidWithdrawDestinationResultSchema,\n]);\n\nexport type ValidateWithdrawDestinationResult = v.InferOutput<\n typeof ValidateWithdrawDestinationResultSchema\n>;\n\nconst WalletBalancesInputObjectSchema = v.strictObject({ ...AccountScopeInputEntries });\n\nexport const GetWalletBalancesInputSchema = v.pipe(\n WalletBalancesInputObjectSchema,\n v.transform(({ account }) => ({ subaccountId: accountScopeToSubaccountId(account) })),\n);\n\nexport type GetWalletBalancesInput = v.InferInput<typeof WalletBalancesInputObjectSchema>;\n\nexport const GetWalletBalancesResultSchema = v.object({\n smartAccountAddress: v.string(),\n balances: v.array(\n v.pipe(\n v.object({\n zippedAssetId: v.number(),\n unifiedAssetId: v.number(),\n chainId: v.number(),\n ztokenAddress: v.string(),\n amountE18: v.optional(U128Schema),\n }),\n v.transform(({ amountE18, ...balance }) => ({\n ...balance,\n amount: scaledToDecimalOutput(fromU128(amountE18), E18_SCALE),\n })),\n ),\n ),\n /**\n * zTokens whose balance could not be read: unknown, not zero. Read again later; the read is\n * complete only when this is empty.\n */\n unavailableAssets: v.array(\n v.object({\n zippedAssetId: v.number(),\n unifiedAssetId: v.number(),\n chainId: v.number(),\n ztokenAddress: v.string(),\n reason: v.optional(enumLabelSchema(WalletAssetUnavailableReasonCodec.protoToOutput), 0),\n }),\n ),\n});\n\n/**\n * zTokens the account's smart account wallet holds on Polyester Chain, read live from the\n * chain: for example a rejected withdrawal's refund, which stays there until moved. `amount`\n * is a decimal string (zTokens have 18 decimals); `chainId` is a `GetDepositWithdrawConfig`\n * chain. `balances` lists nonzero balances by `zippedAssetId` and is empty when there are none.\n * An asset whose balance could not be read is in `unavailableAssets` instead, never in `balances`\n * as zero.\n */\nexport type GetWalletBalancesResult = v.InferOutput<typeof GetWalletBalancesResultSchema>;\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM,2BAA2B;AAkBjC,SAAS,cAAsB;CAC3B,MAAM,SAAS,WAAW,QAAQ,iBAAiB,KAAK,WAAW,MAAM;CACzE,IAAI,CAAC,QACD,MAAM,IAAI,mBAAmB,0DAA0D;CAG3F,MAAM,wBAAQ,IAAI,eAAe,CAAC;CAClC,OAAO,KAAK;CACZ,MAAM,QAAQ,MAAM;CACpB,OAAO,UAAU,KAAK,KAAK;AAC/B;AAEA,SAAS,6BAA6B,OAQE;CACpC,OAAO;EACH,QAAQ,MAAM;EACd,SAAS,MAAM;EACf,oBAAoB,MAAM;EAC1B,WAAW,OAAO,MAAM,cAAc;EACtC,eAAe,OACX,MAAM,WACA,KAAK,MAAM,MAAM,SAAS,QAAQ,IAAI,GAAI,IAC1C,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,wBAC1C;EACA,OAAO,OAAO,YAAY,CAAC;EAC3B,oBAAoB,MAAM;EAC1B,gBAAgB,MAAM;CAC1B;AACJ;;AAGA,SAAgB,4BACZ,SACmC;CACnC,OAAO;EACH,GAAG;EACH,eAAe,OAAO,KAAK,MAAM,KAAK,IAAI,IAAI,GAAI,IAAI,wBAAwB;EAC9E,OAAO,OAAO,YAAY,CAAC;CAC/B;AACJ;AAEA,SAAgB,gDAAgD,QAAmB;CAC/E,OAAO,EAAE,KACL,EAAE,aAAa;EACX,GAAG;EACH,SAAS;EACT,UAAU,EAAE,OAAO;EACnB,gBAAgB,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;EAC3D,oBAAoB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE;EAC/D,cAAc,EA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CAAoC,OAAO;AACrD,EAAE,CACN;AAEA,MAAa,0CAA0C,EAAE,MAAM,CAC3D,sCACA,sCACJ,CAAC;AAMD,MAAM,kCAAkC,EAAE,aAAa,EAAE,GAAG,yBAAyB,CAAC;AAEtF,MAAa,+BAA+B,EAAE,KAC1C,iCACA,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,2BAA2B,OAAO,EAAE,EAAE,CACxF;AAIA,MAAa,gCAAgC,EAAE,OAAO;CAClD,qBAAqB,EAAE,OAAO;CAC9B,UAAU,EAAE,MACR,EAAE,KACE,EAAE,OAAO;EACL,eAAe,EAAE,OAAO;EACxB,gBAAgB,EAAE,OAAO;EACzB,SAAS,EAAE,OAAO;EAClB,eAAe,EAAE,OAAO;EACxB,WAAW,EAAE,SAAS,UAAU;CACpC,CAAC,GACD,EAAE,WAAW,EAAE,WAAW,GAAG,eAAe;EACxC,GAAG;EACH,QAAQ,sBAAsB,SAAS,SAAS,GAAA,EAAY;CAChE,EAAE,CACN,CACJ;;;;;CAKA,mBAAmB,EAAE,MACjB,EAAE,OAAO;EACL,eAAe,EAAE,OAAO;EACxB,gBAAgB,EAAE,OAAO;EACzB,SAAS,EAAE,OAAO;EAClB,eAAe,EAAE,OAAO;EACxB,QAAQ,EAAE,SAAS,gBAAgB,kCAAkC,aAAa,GAAG,CAAC;CAC1F,CAAC,CACL;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
1
  import { CreateTradingWithdrawResult, CreateTradingWithdrawToExternalChainInput, CreateTradingWithdrawToFundingInput, GetWalletBalancesInput, GetWalletBalancesResult, ValidateWithdrawDestinationInput, ValidateWithdrawDestinationResult } from "./trading-withdraws.schemas.js";
2
2
  import { CreateTradingWithdrawToExternalChainServiceInput, CreateTradingWithdrawToFundingServiceInput, PreparedTradingWithdraw, TradingWithdrawSigningConfig, TradingWithdrawWalletSigner } from "./trading-withdraws.js";
3
- export type { CreateTradingWithdrawResult, CreateTradingWithdrawToExternalChainInput, CreateTradingWithdrawToExternalChainServiceInput, CreateTradingWithdrawToFundingInput, CreateTradingWithdrawToFundingServiceInput, GetWalletBalancesInput, GetWalletBalancesResult, PreparedTradingWithdraw, TradingWithdrawSigningConfig, TradingWithdrawWalletSigner, ValidateWithdrawDestinationInput, ValidateWithdrawDestinationResult };
3
+ import { WalletAssetUnavailableReasonValue } from "./trading-withdraws.codecs.js";
4
+ export type { CreateTradingWithdrawResult, CreateTradingWithdrawToExternalChainInput, CreateTradingWithdrawToExternalChainServiceInput, CreateTradingWithdrawToFundingInput, CreateTradingWithdrawToFundingServiceInput, GetWalletBalancesInput, GetWalletBalancesResult, PreparedTradingWithdraw, TradingWithdrawSigningConfig, TradingWithdrawWalletSigner, ValidateWithdrawDestinationInput, ValidateWithdrawDestinationResult, WalletAssetUnavailableReasonValue };
@@ -84,7 +84,7 @@ declare const LedgerTransferSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
84
84
  assetId: number;
85
85
  amount: string;
86
86
  balanceAfter: string | undefined;
87
- type: "unspecified" | "internal_transfer" | "deposit" | "withdraw" | "maker_fee" | "taker_fee" | "trade_base" | "trade_quote" | "rebate" | "funding_to_trading" | "trading_to_funding" | "trading_withdraw_reserve" | "funding_user_transfer" | "trading_withdraw_request_fee" | "trading_withdraw_fee_leg" | "quickswap_polyester_fee" | "quickswap_broker_fee" | "quickswap_affiliate_fee" | "fee_sweep" | "fee_refill" | "system_adjustment" | "withdraw_failed";
87
+ type: "unspecified" | "internal_transfer" | "deposit" | "withdraw" | "maker_fee" | "taker_fee" | "trade_base" | "trade_quote" | "rebate" | "funding_to_trading" | "trading_to_funding" | "trading_withdraw_reserve" | "funding_user_transfer" | "trading_withdraw_request_fee" | "trading_withdraw_fee_leg" | "quickswap_polyester_fee" | "quickswap_broker_fee" | "quickswap_affiliate_fee" | "fee_sweep" | "fee_refill" | "system_adjustment" | "withdraw_failed" | "internal_batch";
88
88
  accountCode: "unspecified" | "trading" | "funding";
89
89
  timestamp: number;
90
90
  isDebit: boolean;
@@ -98,7 +98,7 @@ declare const ListTransfersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjec
98
98
  readonly reversed: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
99
99
  readonly timestampMin: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
100
100
  readonly timestampMax: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>, v.MaxValueAction<number, number, undefined>, v.TransformAction<number, bigint>]>, undefined>;
101
- readonly transferCode: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["deposit", "withdraw", "maker_fee", "taker_fee", "internal_transfer", "trade_base", "trade_quote", "rebate", "funding_to_trading", "trading_to_funding", "trading_withdraw_reserve", "funding_user_transfer", "trading_withdraw_request_fee", "trading_withdraw_fee_leg", "quickswap_polyester_fee", "quickswap_broker_fee", "quickswap_affiliate_fee", "fee_sweep", "fee_refill", "system_adjustment", "withdraw_failed"], undefined>, v.TransformAction<"internal_transfer" | "deposit" | "withdraw" | "maker_fee" | "taker_fee" | "trade_base" | "trade_quote" | "rebate" | "funding_to_trading" | "trading_to_funding" | "trading_withdraw_reserve" | "funding_user_transfer" | "trading_withdraw_request_fee" | "trading_withdraw_fee_leg" | "quickswap_polyester_fee" | "quickswap_broker_fee" | "quickswap_affiliate_fee" | "fee_sweep" | "fee_refill" | "system_adjustment" | "withdraw_failed", TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED>]>, undefined>;
101
+ readonly transferCode: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<readonly ["deposit", "withdraw", "maker_fee", "taker_fee", "internal_transfer", "trade_base", "trade_quote", "rebate", "funding_to_trading", "trading_to_funding", "trading_withdraw_reserve", "funding_user_transfer", "trading_withdraw_request_fee", "trading_withdraw_fee_leg", "quickswap_polyester_fee", "quickswap_broker_fee", "quickswap_affiliate_fee", "fee_sweep", "fee_refill", "system_adjustment", "withdraw_failed", "internal_batch"], undefined>, v.TransformAction<"internal_transfer" | "deposit" | "withdraw" | "maker_fee" | "taker_fee" | "trade_base" | "trade_quote" | "rebate" | "funding_to_trading" | "trading_to_funding" | "trading_withdraw_reserve" | "funding_user_transfer" | "trading_withdraw_request_fee" | "trading_withdraw_fee_leg" | "quickswap_polyester_fee" | "quickswap_broker_fee" | "quickswap_affiliate_fee" | "fee_sweep" | "fee_refill" | "system_adjustment" | "withdraw_failed" | "internal_batch", TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED | TransferCode.INTERNAL_BATCH>]>, undefined>;
102
102
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
103
103
  readonly account: v.OptionalSchema<v.UnionSchema<[v.PicklistSchema<["active", "main"], undefined>, v.StrictObjectSchema<{
104
104
  readonly subaccountId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
@@ -109,7 +109,7 @@ declare const ListTransfersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjec
109
109
  reversed: boolean;
110
110
  timestampMin?: bigint | undefined;
111
111
  timestampMax?: bigint | undefined;
112
- transferCode?: TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED | undefined;
112
+ transferCode?: TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED | TransferCode.INTERNAL_BATCH | undefined;
113
113
  pageToken: string;
114
114
  account?: "active" | "main" | {
115
115
  subaccountId: string;
@@ -121,7 +121,7 @@ declare const ListTransfersInputSchema: v.SchemaWithPipe<readonly [v.StrictObjec
121
121
  ledger: number;
122
122
  limit?: number | undefined;
123
123
  reversed: boolean;
124
- transferCode?: TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED | undefined;
124
+ transferCode?: TransferCode.DEPOSIT | TransferCode.WITHDRAW | TransferCode.MAKER_FEE | TransferCode.TAKER_FEE | TransferCode.INTERNAL_TRANSFER | TransferCode.TRADE_BASE | TransferCode.TRADE_QUOTE | TransferCode.REBATE | TransferCode.FUNDING_TO_TRADING | TransferCode.TRADING_TO_FUNDING | TransferCode.TRADING_WITHDRAW_RESERVE | TransferCode.FUNDING_USER_TRANSFER | TransferCode.TRADING_WITHDRAW_REQUEST_FEE | TransferCode.TRADING_WITHDRAW_FEE_LEG | TransferCode.QUICKSWAP_POLYESTER_FEE | TransferCode.QUICKSWAP_BROKER_FEE | TransferCode.QUICKSWAP_AFFILIATE_FEE | TransferCode.FEE_SWEEP | TransferCode.FEE_REFILL | TransferCode.SYSTEM_ADJUSTMENT | TransferCode.WITHDRAW_FAILED | TransferCode.INTERNAL_BATCH | undefined;
125
125
  pageToken: string;
126
126
  }>]>;
127
127
  type ListTransfersInput = v.InferInput<typeof ListTransfersInputSchema>;
@@ -16,7 +16,7 @@ const DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));
16
16
  const BaseTriggerFieldsSchema = v.object({
17
17
  ...AccountScopeInputEntries,
18
18
  symbolId: SymbolIdInputSchema,
19
- clientTriggerId: v.optional(v.pipe(v.string(), v.trim()), () => crypto.randomUUID()),
19
+ clientTriggerId: v.optional(v.pipe(v.string(), v.minLength(1)), () => crypto.randomUUID()),
20
20
  qty: DecimalInputStringSchema,
21
21
  feeAsset: v.pipe(v.optional(FeeAssetSchema, "quote"), v.transform((value) => FeeAssetCodec.inputToProto[value])),
22
22
  selfTradePreventionMode: v.pipe(v.optional(SelfTradePreventionModeSchema, "expire_maker"), v.transform((value) => SelfTradePreventionModeCodec.inputToProto[value]))
@@ -1 +1 @@
1
- {"version":3,"file":"trigger-child-order.schemas.js","names":["TRIGGER_SIDE_VALUES","TriggerSideCodec","Proto.TriggerMarketIocSchema","Proto.TriggerLimitGtcSchema","Proto.TriggerLimitIocSchema","Proto.TriggerLimitFokSchema","Proto.TwapMarketIocSchema","Proto.TwapLimitGtcSchema"],"sources":["../../../src/services/triggers/trigger-child-order.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n MAX_SELLING_SLIPPAGE_BPS,\n MAX_SLIPPAGE_BPS,\n parseSlippageInput,\n} from \"../trailing-oneof-inputs.js\";\nimport {\n FEE_ASSET_VALUES,\n FeeAssetCodec,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n SelfTradePreventionModeCodec,\n TRIGGER_SIDE_VALUES,\n TriggerSideCodec,\n} from \"./triggers.codecs.js\";\n\nconst FeeAssetSchema = v.picklist(FEE_ASSET_VALUES);\nconst SelfTradePreventionModeSchema = v.picklist(SELF_TRADE_PREVENTION_MODE_VALUES);\nconst SideInputSchema = v.picklist(TRIGGER_SIDE_VALUES);\nexport const DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport type TrailingDistanceOneof = Proto.ModifyTriggerRequest[\"trailingDistance\"];\nexport type MaxSlippageOneof = Proto.ModifyTriggerRequest[\"maxSlippage\"];\n\n/** Shared public fields for creating a trigger intent. */\nexport const BaseTriggerFieldsSchema = v.object({\n ...AccountScopeInputEntries,\n symbolId: SymbolIdInputSchema,\n clientTriggerId: v.optional(v.pipe(v.string(), v.trim()), () => crypto.randomUUID()),\n qty: DecimalInputStringSchema,\n feeAsset: v.pipe(\n v.optional(FeeAssetSchema, \"quote\"),\n v.transform((value) => FeeAssetCodec.inputToProto[value]),\n ),\n selfTradePreventionMode: v.pipe(\n v.optional(SelfTradePreventionModeSchema, \"expire_maker\"),\n v.transform((value) => SelfTradePreventionModeCodec.inputToProto[value]),\n ),\n});\n\nexport const TriggerSideInputSchema = v.pipe(\n SideInputSchema,\n v.transform((value) => TriggerSideCodec.inputToProto[value]),\n);\n\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nexport const MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\n/** Omit `maxSlippage` to use the pair's default market slippage for the child's side. */\nexport const MarketIocConditionalExecutionInputSchema = v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n});\n\nexport const ConditionalExecutionInputSchema = v.variant(\"type\", [\n MarketIocConditionalExecutionInputSchema,\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n postOnly: v.optional(v.boolean(), false),\n }),\n v.strictObject({\n type: v.literal(\"limit_ioc\"),\n price: DecimalInputStringSchema,\n }),\n v.strictObject({\n type: v.literal(\"limit_fok\"),\n price: DecimalInputStringSchema,\n }),\n]);\n\nexport const TwapExecutionInputSchema = v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n }),\n]);\n\ntype BaseTriggerInput = v.InferOutput<typeof BaseTriggerFieldsSchema>;\ntype ConditionalExecutionInput = v.InferOutput<typeof ConditionalExecutionInputSchema>;\ntype TwapExecutionInput = v.InferOutput<typeof TwapExecutionInputSchema>;\n\nexport function parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n maxBps = MAX_SLIPPAGE_BPS,\n): MaxSlippageOneof {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps,\n });\n}\n\nexport function buildTriggerIntentBase(input: BaseTriggerInput, scales: SdkScales) {\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n intent: {\n symbolId: input.symbolId,\n qtyScaled: positiveDecimalInputToScaled(\n \"qty\",\n input.qty,\n scales.baseQty(input.symbolId),\n ),\n feeAsset: input.feeAsset,\n selfTradePreventionMode: input.selfTradePreventionMode,\n clientTriggerId: input.clientTriggerId ?? crypto.randomUUID(),\n },\n };\n}\n\nexport function buildConditionalExecution(\n input: ConditionalExecutionInput,\n scales: SdkScales,\n side: ProtoOrders.Side,\n) {\n switch (input.type) {\n case \"market_ioc\":\n return {\n execution: {\n case: \"marketIoc\",\n value: create(Proto.TriggerMarketIocSchema, {\n maxSlippage: parseMaxSlippage(\n scales,\n input.maxSlippage,\n side === ProtoOrders.Side.SELL\n ? MAX_SELLING_SLIPPAGE_BPS\n : MAX_SLIPPAGE_BPS,\n ),\n }),\n },\n } as const;\n case \"limit_gtc\":\n return {\n execution: {\n case: \"limitGtc\",\n value: create(Proto.TriggerLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n postOnly: input.postOnly,\n }),\n },\n } as const;\n case \"limit_ioc\":\n return {\n execution: {\n case: \"limitIoc\",\n value: create(Proto.TriggerLimitIocSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n },\n } as const;\n case \"limit_fok\":\n return {\n execution: {\n case: \"limitFok\",\n value: create(Proto.TriggerLimitFokSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n },\n } as const;\n }\n}\n\nexport function buildTwapExecution(input: TwapExecutionInput, scales: SdkScales) {\n return input.type === \"market_ioc\"\n ? ({\n case: \"marketIoc\",\n value: create(Proto.TwapMarketIocSchema, {\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n }),\n } as const)\n : ({\n case: \"limitGtc\",\n value: create(Proto.TwapLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n } as const);\n}\n"],"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GACN,OAAO,OAAOC,uBAA6B,EACvC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB,EACJ,CAAC;EACL,EACJ;CACR;AACJ;AAEA,SAAgB,mBAAmB,OAA2B,QAAmB;CAC7E,OAAO,MAAM,SAAS,eACf;EACG,MAAM;EACN,OAAO,OAAOC,qBAA2B,EACrC,aAAa,iBAAiB,QAAQ,MAAM,WAAW,EAC3D,CAAC;CACL,IACC;EACG,MAAM;EACN,OAAO,OAAOC,oBAA0B,EACpC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB,EACJ,CAAC;CACL;AACV"}
1
+ {"version":3,"file":"trigger-child-order.schemas.js","names":["TRIGGER_SIDE_VALUES","TriggerSideCodec","Proto.TriggerMarketIocSchema","Proto.TriggerLimitGtcSchema","Proto.TriggerLimitIocSchema","Proto.TriggerLimitFokSchema","Proto.TwapMarketIocSchema","Proto.TwapLimitGtcSchema"],"sources":["../../../src/services/triggers/trigger-child-order.schemas.ts"],"sourcesContent":["import * as Proto from \"../../gen/triggers/v1/triggers_pb.js\";\nimport * as ProtoOrders from \"../../gen/orders/v1/orders_pb.js\";\nimport * as v from \"valibot\";\nimport { create } from \"@bufbuild/protobuf\";\nimport {\n AccountScopeInputEntries,\n accountScopeToSubaccountId,\n} from \"../../shared/account-scope.js\";\nimport { positiveDecimalInputToScaled, type SdkScales } from \"../../shared/decimal-surface.js\";\nimport { BpsStringOrNumberInputSchema, NoneInputSchema, SymbolIdInputSchema } from \"../shared.js\";\nimport {\n MAX_SELLING_SLIPPAGE_BPS,\n MAX_SLIPPAGE_BPS,\n parseSlippageInput,\n} from \"../trailing-oneof-inputs.js\";\nimport {\n FEE_ASSET_VALUES,\n FeeAssetCodec,\n SELF_TRADE_PREVENTION_MODE_VALUES,\n SelfTradePreventionModeCodec,\n TRIGGER_SIDE_VALUES,\n TriggerSideCodec,\n} from \"./triggers.codecs.js\";\n\nconst FeeAssetSchema = v.picklist(FEE_ASSET_VALUES);\nconst SelfTradePreventionModeSchema = v.picklist(SELF_TRADE_PREVENTION_MODE_VALUES);\nconst SideInputSchema = v.picklist(TRIGGER_SIDE_VALUES);\nexport const DecimalInputStringSchema = v.pipe(v.string(), v.trim(), v.minLength(1));\n\nexport type TrailingDistanceOneof = Proto.ModifyTriggerRequest[\"trailingDistance\"];\nexport type MaxSlippageOneof = Proto.ModifyTriggerRequest[\"maxSlippage\"];\n\n/** Shared public fields for creating a trigger intent. */\nexport const BaseTriggerFieldsSchema = v.object({\n ...AccountScopeInputEntries,\n symbolId: SymbolIdInputSchema,\n // Sent as given. \"\" is refused here: proto3 sends it as no ID, so the server cannot.\n clientTriggerId: v.optional(v.pipe(v.string(), v.minLength(1)), () => crypto.randomUUID()),\n qty: DecimalInputStringSchema,\n feeAsset: v.pipe(\n v.optional(FeeAssetSchema, \"quote\"),\n v.transform((value) => FeeAssetCodec.inputToProto[value]),\n ),\n selfTradePreventionMode: v.pipe(\n v.optional(SelfTradePreventionModeSchema, \"expire_maker\"),\n v.transform((value) => SelfTradePreventionModeCodec.inputToProto[value]),\n ),\n});\n\nexport const TriggerSideInputSchema = v.pipe(\n SideInputSchema,\n v.transform((value) => TriggerSideCodec.inputToProto[value]),\n);\n\nconst PriceSlippageInputSchema = v.strictObject({\n kind: v.literal(\"slippage\"),\n slippage: DecimalInputStringSchema,\n});\n\nexport const MaxSlippageInputSchema = v.union([\n PriceSlippageInputSchema,\n BpsStringOrNumberInputSchema,\n NoneInputSchema,\n]);\n\n/** Omit `maxSlippage` to use the pair's default market slippage for the child's side. */\nexport const MarketIocConditionalExecutionInputSchema = v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n});\n\nexport const ConditionalExecutionInputSchema = v.variant(\"type\", [\n MarketIocConditionalExecutionInputSchema,\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n postOnly: v.optional(v.boolean(), false),\n }),\n v.strictObject({\n type: v.literal(\"limit_ioc\"),\n price: DecimalInputStringSchema,\n }),\n v.strictObject({\n type: v.literal(\"limit_fok\"),\n price: DecimalInputStringSchema,\n }),\n]);\n\nexport const TwapExecutionInputSchema = v.variant(\"type\", [\n v.strictObject({\n type: v.literal(\"market_ioc\"),\n maxSlippage: v.optional(MaxSlippageInputSchema),\n }),\n v.strictObject({\n type: v.literal(\"limit_gtc\"),\n price: DecimalInputStringSchema,\n }),\n]);\n\ntype BaseTriggerInput = v.InferOutput<typeof BaseTriggerFieldsSchema>;\ntype ConditionalExecutionInput = v.InferOutput<typeof ConditionalExecutionInputSchema>;\ntype TwapExecutionInput = v.InferOutput<typeof TwapExecutionInputSchema>;\n\nexport function parseMaxSlippage(\n scales: SdkScales,\n slippage: v.InferOutput<typeof MaxSlippageInputSchema> | undefined,\n maxBps = MAX_SLIPPAGE_BPS,\n): MaxSlippageOneof {\n return parseSlippageInput(scales, slippage, {\n fieldName: \"maxSlippage\",\n ticksCase: \"maxSlippageTicks\",\n bpsCase: \"maxSlippageBps\",\n maxBps,\n });\n}\n\nexport function buildTriggerIntentBase(input: BaseTriggerInput, scales: SdkScales) {\n return {\n subaccountId: accountScopeToSubaccountId(input.account),\n intent: {\n symbolId: input.symbolId,\n qtyScaled: positiveDecimalInputToScaled(\n \"qty\",\n input.qty,\n scales.baseQty(input.symbolId),\n ),\n feeAsset: input.feeAsset,\n selfTradePreventionMode: input.selfTradePreventionMode,\n clientTriggerId: input.clientTriggerId ?? crypto.randomUUID(),\n },\n };\n}\n\nexport function buildConditionalExecution(\n input: ConditionalExecutionInput,\n scales: SdkScales,\n side: ProtoOrders.Side,\n) {\n switch (input.type) {\n case \"market_ioc\":\n return {\n execution: {\n case: \"marketIoc\",\n value: create(Proto.TriggerMarketIocSchema, {\n maxSlippage: parseMaxSlippage(\n scales,\n input.maxSlippage,\n side === ProtoOrders.Side.SELL\n ? MAX_SELLING_SLIPPAGE_BPS\n : MAX_SLIPPAGE_BPS,\n ),\n }),\n },\n } as const;\n case \"limit_gtc\":\n return {\n execution: {\n case: \"limitGtc\",\n value: create(Proto.TriggerLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n postOnly: input.postOnly,\n }),\n },\n } as const;\n case \"limit_ioc\":\n return {\n execution: {\n case: \"limitIoc\",\n value: create(Proto.TriggerLimitIocSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n },\n } as const;\n case \"limit_fok\":\n return {\n execution: {\n case: \"limitFok\",\n value: create(Proto.TriggerLimitFokSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n },\n } as const;\n }\n}\n\nexport function buildTwapExecution(input: TwapExecutionInput, scales: SdkScales) {\n return input.type === \"market_ioc\"\n ? ({\n case: \"marketIoc\",\n value: create(Proto.TwapMarketIocSchema, {\n maxSlippage: parseMaxSlippage(scales, input.maxSlippage),\n }),\n } as const)\n : ({\n case: \"limitGtc\",\n value: create(Proto.TwapLimitGtcSchema, {\n priceTicks: positiveDecimalInputToScaled(\n \"execution.price\",\n input.price,\n scales.price(),\n ),\n }),\n } as const);\n}\n"],"mappings":";;;;;;;;;;AAwBA,MAAM,iBAAiB,EAAE,SAAS,gBAAgB;AAClD,MAAM,gCAAgC,EAAE,SAAS,iCAAiC;AAClF,MAAM,kBAAkB,EAAE,SAASA,iBAAmB;AACtD,MAAa,2BAA2B,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,KAAK,GAAG,EAAE,UAAU,CAAC,CAAC;;AAMnF,MAAa,0BAA0B,EAAE,OAAO;CAC5C,GAAG;CACH,UAAU;CAEV,iBAAiB,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,GAAG,EAAE,UAAU,CAAC,CAAC,SAAS,OAAO,WAAW,CAAC;CACzF,KAAK;CACL,UAAU,EAAE,KACR,EAAE,SAAS,gBAAgB,OAAO,GAClC,EAA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B,MAAM,OAAO;EACtD,QAAQ;GACJ,UAAU,MAAM;GAChB,WAAW,6BACP,OACA,MAAM,KACN,OAAO,QAAQ,MAAM,QAAQ,CACjC;GACA,UAAU,MAAM;GAChB,yBAAyB,MAAM;GAC/B,iBAAiB,MAAM,mBAAmB,OAAO,WAAW;EAChE;CACJ;AACJ;AAEA,SAAgB,0BACZ,OACA,QACA,MACF;CACE,QAAQ,MAAM,MAAd;EACI,KAAK,cACD,OAAO,EACH,WAAW;GACP,MAAM;GACN,OAAO,OAAOC,wBAA8B,EACxC,aAAa,iBACT,QACA,MAAM,aACN,SAAA,IACM,2BACA,gBACV,EACJ,CAAC;EACL,EACJ;EACJ,KAAK,aACD,OAAO,EACH,WAAW;GACP,MAAM;GACN,OAAO,OAAOC,uBAA6B;IACvC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB;IACA,UAAU,MAAM;GACpB,CAAC;EACL,EACJ;EACJ,KAAK,aACD,OAAO,EACH,WAAW;GACP,MAAM;GACN,OAAO,OAAOC,uBAA6B,EACvC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB,EACJ,CAAC;EACL,EACJ;EACJ,KAAK,aACD,OAAO,EACH,WAAW;GACP,MAAM;GACN,OAAO,OAAOC,uBAA6B,EACvC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB,EACJ,CAAC;EACL,EACJ;CACR;AACJ;AAEA,SAAgB,mBAAmB,OAA2B,QAAmB;CAC7E,OAAO,MAAM,SAAS,eACf;EACG,MAAM;EACN,OAAO,OAAOC,qBAA2B,EACrC,aAAa,iBAAiB,QAAQ,MAAM,WAAW,EAC3D,CAAC;CACL,IACC;EACG,MAAM;EACN,OAAO,OAAOC,oBAA0B,EACpC,YAAY,6BACR,mBACA,MAAM,OACN,OAAO,MAAM,CACjB,EACJ,CAAC;CACL;AACV"}
@@ -38,7 +38,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
38
38
  readonly triggerPrice: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
39
39
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
40
40
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
41
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
41
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
42
42
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
43
43
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
44
44
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -209,7 +209,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
209
209
  readonly triggerPrice: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
210
210
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
211
211
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
212
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
212
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
213
213
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
214
214
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
215
215
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -345,7 +345,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
345
345
  readonly triggerPrice: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
346
346
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
347
347
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
348
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
348
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
349
349
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
350
350
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
351
351
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -516,7 +516,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
516
516
  readonly triggerPrice: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
517
517
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
518
518
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
519
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
519
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
520
520
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
521
521
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
522
522
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -647,7 +647,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
647
647
  }, undefined>], undefined>, undefined>;
648
648
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
649
649
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
650
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
650
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
651
651
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
652
652
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
653
653
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -775,7 +775,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
775
775
  }, undefined>], undefined>, undefined>;
776
776
  readonly triggerPriceSource: v.OptionalSchema<v.SchemaWithPipe<readonly [v.PicklistSchema<["last", "index"], undefined>, v.TransformAction<"last" | "index", TriggerPriceSource.LAST_PRICE | TriggerPriceSource.INDEX_PRICE>]>, undefined>;
777
777
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
778
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
778
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
779
779
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
780
780
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
781
781
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -909,7 +909,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
909
909
  readonly price: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
910
910
  }, undefined>], undefined>;
911
911
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
912
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
912
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
913
913
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
914
914
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
915
915
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -1032,7 +1032,7 @@ declare function createCreateTriggerInputSchema(scales: SdkScales): v.LazySchema
1032
1032
  readonly levels: v.SchemaWithPipe<readonly [v.UnionSchema<[v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>]>], undefined>, v.TransformAction<string | number, number>]>;
1033
1033
  readonly postOnly: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
1034
1034
  readonly symbolId: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>;
1035
- readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, () => `${string}-${string}-${string}-${string}-${string}`>;
1035
+ readonly clientTriggerId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, () => `${string}-${string}-${string}-${string}-${string}`>;
1036
1036
  readonly qty: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>;
1037
1037
  readonly feeAsset: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["quote", "base"], undefined>, "quote">, v.TransformAction<"quote" | "base", FeeAsset.QUOTE | FeeAsset.BASE>]>;
1038
1038
  readonly selfTradePreventionMode: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["expire_taker", "expire_maker", "expire_both", "decrement"], undefined>, "expire_maker">, v.TransformAction<"expire_taker" | "expire_maker" | "expire_both" | "decrement", SelfTradePreventionMode.EXPIRE_MAKER | SelfTradePreventionMode.EXPIRE_TAKER | SelfTradePreventionMode.EXPIRE_BOTH | SelfTradePreventionMode.DECREMENT>]>;
@@ -1118,7 +1118,7 @@ declare const ListTriggersInputSchema: v.SchemaWithPipe<readonly [v.StrictObject
1118
1118
  /** Both legs of the OCO created with this client list ID. */
1119
1119
  readonly clientListId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 36, undefined>, v.RegexAction<string, "clientListId has an invalid format">]>, undefined>;
1120
1120
  readonly symbolId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 4294967295, undefined>]>, undefined>;
1121
- readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "canceled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("failed" | "canceled" | "created" | "armed" | "running" | "completed" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
1121
+ readonly status: v.SchemaWithPipe<readonly [v.OptionalSchema<v.ArraySchema<v.PicklistSchema<readonly ["created", "armed", "running", "completed", "canceled", "failed", "paused"], undefined>, undefined>, undefined>, v.TransformAction<("created" | "failed" | "canceled" | "completed" | "armed" | "running" | "paused")[] | undefined, (TriggerStatus.STATUS_CREATED | TriggerStatus.STATUS_ARMED | TriggerStatus.STATUS_RUNNING | TriggerStatus.STATUS_COMPLETED | TriggerStatus.STATUS_CANCELED | TriggerStatus.STATUS_FAILED | TriggerStatus.STATUS_PAUSED)[]>]>;
1122
1122
  readonly triggerType: v.SchemaWithPipe<readonly [v.OptionalSchema<v.PicklistSchema<readonly ["stop_loss", "take_profit", "trailing_stop", "twap", "ladder"], undefined>, undefined>, v.TransformAction<"twap" | "ladder" | "stop_loss" | "take_profit" | "trailing_stop" | undefined, TriggerType>]>;
1123
1123
  readonly limit: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.GtValueAction<number, 0, undefined>, v.MaxValueAction<number, 1000, undefined>]>, 50>;
1124
1124
  readonly pageToken: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction]>, "">;
@@ -1565,7 +1565,7 @@ declare const ListTriggerEventsInputSchema: v.SchemaWithPipe<readonly [v.StrictO
1565
1565
  readonly triggerId: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.TransformAction<string, bigint>]>, v.CheckAction<bigint, `${string} must be greater than zero`>]>;
1566
1566
  }, undefined>, v.TransformAction<{
1567
1567
  limit?: number | undefined;
1568
- eventType?: "failed" | "canceled" | "armed" | "updated" | "fired" | "activated" | "fire_refused" | undefined;
1568
+ eventType?: "updated" | "failed" | "canceled" | "armed" | "fired" | "activated" | "fire_refused" | undefined;
1569
1569
  pageToken: string;
1570
1570
  account?: "active" | "main" | {
1571
1571
  subaccountId: string;