@picon-finance/dlmm-sdk 1.0.0

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 (386) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -0
  3. package/dist/actions/accept_admin_authority.d.ts +13 -0
  4. package/dist/actions/accept_admin_authority.d.ts.map +1 -0
  5. package/dist/actions/accept_admin_authority.js +7 -0
  6. package/dist/actions/claim_fee.d.ts +21 -0
  7. package/dist/actions/claim_fee.d.ts.map +1 -0
  8. package/dist/actions/claim_fee.js +40 -0
  9. package/dist/actions/claim_multiple_fees.d.ts +19 -0
  10. package/dist/actions/claim_multiple_fees.d.ts.map +1 -0
  11. package/dist/actions/claim_multiple_fees.js +81 -0
  12. package/dist/actions/claim_protocol_fee.d.ts +18 -0
  13. package/dist/actions/claim_protocol_fee.d.ts.map +1 -0
  14. package/dist/actions/claim_protocol_fee.js +33 -0
  15. package/dist/actions/close_position.d.ts +14 -0
  16. package/dist/actions/close_position.d.ts.map +1 -0
  17. package/dist/actions/close_position.js +14 -0
  18. package/dist/actions/create_admin_config.d.ts +15 -0
  19. package/dist/actions/create_admin_config.d.ts.map +1 -0
  20. package/dist/actions/create_admin_config.js +30 -0
  21. package/dist/actions/create_bin_array.d.ts +16 -0
  22. package/dist/actions/create_bin_array.d.ts.map +1 -0
  23. package/dist/actions/create_bin_array.js +10 -0
  24. package/dist/actions/create_pool.d.ts +21 -0
  25. package/dist/actions/create_pool.d.ts.map +1 -0
  26. package/dist/actions/create_pool.js +22 -0
  27. package/dist/actions/delete_bin_array.d.ts +16 -0
  28. package/dist/actions/delete_bin_array.d.ts.map +1 -0
  29. package/dist/actions/delete_bin_array.js +13 -0
  30. package/dist/actions/deposit_by_weight.d.ts +27 -0
  31. package/dist/actions/deposit_by_weight.d.ts.map +1 -0
  32. package/dist/actions/deposit_by_weight.js +52 -0
  33. package/dist/actions/get_admin_config.d.ts +4 -0
  34. package/dist/actions/get_admin_config.d.ts.map +1 -0
  35. package/dist/actions/get_admin_config.js +7 -0
  36. package/dist/actions/get_bin_arrays_by_indices.d.ts +5 -0
  37. package/dist/actions/get_bin_arrays_by_indices.d.ts.map +1 -0
  38. package/dist/actions/get_bin_arrays_by_indices.js +6 -0
  39. package/dist/actions/get_pool.d.ts +4 -0
  40. package/dist/actions/get_pool.d.ts.map +1 -0
  41. package/dist/actions/get_pool.js +5 -0
  42. package/dist/actions/get_position.d.ts +4 -0
  43. package/dist/actions/get_position.d.ts.map +1 -0
  44. package/dist/actions/get_position.js +5 -0
  45. package/dist/actions/get_position_by_position_mint.d.ts +4 -0
  46. package/dist/actions/get_position_by_position_mint.d.ts.map +1 -0
  47. package/dist/actions/get_position_by_position_mint.js +6 -0
  48. package/dist/actions/get_positions_by_owner.d.ts +5 -0
  49. package/dist/actions/get_positions_by_owner.d.ts.map +1 -0
  50. package/dist/actions/get_positions_by_owner.js +33 -0
  51. package/dist/actions/get_positions_by_position_mints.d.ts +5 -0
  52. package/dist/actions/get_positions_by_position_mints.d.ts.map +1 -0
  53. package/dist/actions/get_positions_by_position_mints.js +9 -0
  54. package/dist/actions/helpers/build_swap_transaction_message.d.ts +22 -0
  55. package/dist/actions/helpers/build_swap_transaction_message.d.ts.map +1 -0
  56. package/dist/actions/helpers/build_swap_transaction_message.js +50 -0
  57. package/dist/actions/helpers/build_transaction_message.d.ts +20 -0
  58. package/dist/actions/helpers/build_transaction_message.d.ts.map +1 -0
  59. package/dist/actions/helpers/build_transaction_message.js +5 -0
  60. package/dist/actions/helpers/index.d.ts +8 -0
  61. package/dist/actions/helpers/index.d.ts.map +1 -0
  62. package/dist/actions/helpers/index.js +7 -0
  63. package/dist/actions/helpers/resolve_active_bin_and_mints.d.ts +12 -0
  64. package/dist/actions/helpers/resolve_active_bin_and_mints.d.ts.map +1 -0
  65. package/dist/actions/helpers/resolve_active_bin_and_mints.js +13 -0
  66. package/dist/actions/helpers/resolve_admin_config_address.d.ts +3 -0
  67. package/dist/actions/helpers/resolve_admin_config_address.d.ts.map +1 -0
  68. package/dist/actions/helpers/resolve_admin_config_address.js +9 -0
  69. package/dist/actions/helpers/resolve_mint_info.d.ts +10 -0
  70. package/dist/actions/helpers/resolve_mint_info.d.ts.map +1 -0
  71. package/dist/actions/helpers/resolve_mint_info.js +20 -0
  72. package/dist/actions/helpers/resolve_position_range.d.ts +12 -0
  73. package/dist/actions/helpers/resolve_position_range.d.ts.map +1 -0
  74. package/dist/actions/helpers/resolve_position_range.js +12 -0
  75. package/dist/actions/helpers/resolve_token_mints_and_programs.d.ts +15 -0
  76. package/dist/actions/helpers/resolve_token_mints_and_programs.d.ts.map +1 -0
  77. package/dist/actions/helpers/resolve_token_mints_and_programs.js +29 -0
  78. package/dist/actions/index.d.ts +31 -0
  79. package/dist/actions/index.d.ts.map +1 -0
  80. package/dist/actions/index.js +28 -0
  81. package/dist/actions/is_admin_config_active.d.ts +4 -0
  82. package/dist/actions/is_admin_config_active.d.ts.map +1 -0
  83. package/dist/actions/is_admin_config_active.js +7 -0
  84. package/dist/actions/on_event.d.ts +11 -0
  85. package/dist/actions/on_event.d.ts.map +1 -0
  86. package/dist/actions/on_event.js +50 -0
  87. package/dist/actions/open_position.d.ts +17 -0
  88. package/dist/actions/open_position.d.ts.map +1 -0
  89. package/dist/actions/open_position.js +31 -0
  90. package/dist/actions/quote.d.ts +13 -0
  91. package/dist/actions/quote.d.ts.map +1 -0
  92. package/dist/actions/quote.js +43 -0
  93. package/dist/actions/set_metadata_update_authority.d.ts +14 -0
  94. package/dist/actions/set_metadata_update_authority.d.ts.map +1 -0
  95. package/dist/actions/set_metadata_update_authority.js +7 -0
  96. package/dist/actions/set_pool_dynamic_fee_config.d.ts +16 -0
  97. package/dist/actions/set_pool_dynamic_fee_config.d.ts.map +1 -0
  98. package/dist/actions/set_pool_dynamic_fee_config.js +7 -0
  99. package/dist/actions/set_pool_protocol_share.d.ts +15 -0
  100. package/dist/actions/set_pool_protocol_share.d.ts.map +1 -0
  101. package/dist/actions/set_pool_protocol_share.js +7 -0
  102. package/dist/actions/swap.d.ts +22 -0
  103. package/dist/actions/swap.d.ts.map +1 -0
  104. package/dist/actions/swap.js +19 -0
  105. package/dist/actions/sync_pool.d.ts +15 -0
  106. package/dist/actions/sync_pool.d.ts.map +1 -0
  107. package/dist/actions/sync_pool.js +26 -0
  108. package/dist/actions/transfer_admin_authority.d.ts +14 -0
  109. package/dist/actions/transfer_admin_authority.d.ts.map +1 -0
  110. package/dist/actions/transfer_admin_authority.js +7 -0
  111. package/dist/actions/withdraw.d.ts +22 -0
  112. package/dist/actions/withdraw.d.ts.map +1 -0
  113. package/dist/actions/withdraw.js +41 -0
  114. package/dist/events.d.ts +93 -0
  115. package/dist/events.d.ts.map +1 -0
  116. package/dist/events.js +166 -0
  117. package/dist/generated/accounts/adminConfig.d.ts +35 -0
  118. package/dist/generated/accounts/adminConfig.d.ts.map +1 -0
  119. package/dist/generated/accounts/adminConfig.js +60 -0
  120. package/dist/generated/accounts/binArray.d.ts +40 -0
  121. package/dist/generated/accounts/binArray.d.ts.map +1 -0
  122. package/dist/generated/accounts/binArray.js +65 -0
  123. package/dist/generated/accounts/index.d.ts +12 -0
  124. package/dist/generated/accounts/index.d.ts.map +1 -0
  125. package/dist/generated/accounts/index.js +11 -0
  126. package/dist/generated/accounts/pool.d.ts +54 -0
  127. package/dist/generated/accounts/pool.d.ts.map +1 -0
  128. package/dist/generated/accounts/pool.js +79 -0
  129. package/dist/generated/accounts/position.d.ts +42 -0
  130. package/dist/generated/accounts/position.d.ts.map +1 -0
  131. package/dist/generated/accounts/position.js +67 -0
  132. package/dist/generated/errors/index.d.ts +9 -0
  133. package/dist/generated/errors/index.d.ts.map +1 -0
  134. package/dist/generated/errors/index.js +8 -0
  135. package/dist/generated/errors/piconDlmm.d.ts +58 -0
  136. package/dist/generated/errors/piconDlmm.d.ts.map +1 -0
  137. package/dist/generated/errors/piconDlmm.js +80 -0
  138. package/dist/generated/index.d.ts +14 -0
  139. package/dist/generated/index.d.ts.map +1 -0
  140. package/dist/generated/index.js +13 -0
  141. package/dist/generated/instructions/acceptAdminAuthority.d.ts +47 -0
  142. package/dist/generated/instructions/acceptAdminAuthority.d.ts.map +1 -0
  143. package/dist/generated/instructions/acceptAdminAuthority.js +99 -0
  144. package/dist/generated/instructions/claimFee.d.ts +83 -0
  145. package/dist/generated/instructions/claimFee.d.ts.map +1 -0
  146. package/dist/generated/instructions/claimFee.js +127 -0
  147. package/dist/generated/instructions/claimProtocolFee.d.ts +83 -0
  148. package/dist/generated/instructions/claimProtocolFee.d.ts.map +1 -0
  149. package/dist/generated/instructions/claimProtocolFee.js +147 -0
  150. package/dist/generated/instructions/closePosition.d.ts +59 -0
  151. package/dist/generated/instructions/closePosition.d.ts.map +1 -0
  152. package/dist/generated/instructions/closePosition.js +124 -0
  153. package/dist/generated/instructions/createAdminConfig.d.ts +68 -0
  154. package/dist/generated/instructions/createAdminConfig.d.ts.map +1 -0
  155. package/dist/generated/instructions/createAdminConfig.js +132 -0
  156. package/dist/generated/instructions/createBinArray.d.ts +64 -0
  157. package/dist/generated/instructions/createBinArray.d.ts.map +1 -0
  158. package/dist/generated/instructions/createBinArray.js +122 -0
  159. package/dist/generated/instructions/createPool.d.ts +100 -0
  160. package/dist/generated/instructions/createPool.d.ts.map +1 -0
  161. package/dist/generated/instructions/createPool.js +202 -0
  162. package/dist/generated/instructions/deleteBinArray.d.ts +68 -0
  163. package/dist/generated/instructions/deleteBinArray.d.ts.map +1 -0
  164. package/dist/generated/instructions/deleteBinArray.js +130 -0
  165. package/dist/generated/instructions/depositByWeight.d.ts +99 -0
  166. package/dist/generated/instructions/depositByWeight.d.ts.map +1 -0
  167. package/dist/generated/instructions/depositByWeight.js +136 -0
  168. package/dist/generated/instructions/index.d.ts +25 -0
  169. package/dist/generated/instructions/index.d.ts.map +1 -0
  170. package/dist/generated/instructions/index.js +24 -0
  171. package/dist/generated/instructions/openPosition.d.ts +88 -0
  172. package/dist/generated/instructions/openPosition.d.ts.map +1 -0
  173. package/dist/generated/instructions/openPosition.js +200 -0
  174. package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts +52 -0
  175. package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts.map +1 -0
  176. package/dist/generated/instructions/setMetadataUpdateAuthority.js +98 -0
  177. package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts +57 -0
  178. package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts.map +1 -0
  179. package/dist/generated/instructions/setPoolDynamicFeeConfig.js +107 -0
  180. package/dist/generated/instructions/setPoolProtocolShare.d.ts +56 -0
  181. package/dist/generated/instructions/setPoolProtocolShare.d.ts.map +1 -0
  182. package/dist/generated/instructions/setPoolProtocolShare.js +106 -0
  183. package/dist/generated/instructions/swap.d.ts +74 -0
  184. package/dist/generated/instructions/swap.d.ts.map +1 -0
  185. package/dist/generated/instructions/swap.js +108 -0
  186. package/dist/generated/instructions/syncPool.d.ts +44 -0
  187. package/dist/generated/instructions/syncPool.d.ts.map +1 -0
  188. package/dist/generated/instructions/syncPool.js +71 -0
  189. package/dist/generated/instructions/transferAdminAuthority.d.ts +52 -0
  190. package/dist/generated/instructions/transferAdminAuthority.d.ts.map +1 -0
  191. package/dist/generated/instructions/transferAdminAuthority.js +98 -0
  192. package/dist/generated/instructions/withdraw.d.ts +86 -0
  193. package/dist/generated/instructions/withdraw.d.ts.map +1 -0
  194. package/dist/generated/instructions/withdraw.js +129 -0
  195. package/dist/generated/pdas/adminConfig.d.ts +12 -0
  196. package/dist/generated/pdas/adminConfig.d.ts.map +1 -0
  197. package/dist/generated/pdas/adminConfig.js +19 -0
  198. package/dist/generated/pdas/binArray.d.ts +16 -0
  199. package/dist/generated/pdas/binArray.d.ts.map +1 -0
  200. package/dist/generated/pdas/binArray.js +19 -0
  201. package/dist/generated/pdas/index.d.ts +12 -0
  202. package/dist/generated/pdas/index.d.ts.map +1 -0
  203. package/dist/generated/pdas/index.js +11 -0
  204. package/dist/generated/pdas/pool.d.ts +18 -0
  205. package/dist/generated/pdas/pool.d.ts.map +1 -0
  206. package/dist/generated/pdas/pool.js +21 -0
  207. package/dist/generated/pdas/position.d.ts +15 -0
  208. package/dist/generated/pdas/position.d.ts.map +1 -0
  209. package/dist/generated/pdas/position.js +18 -0
  210. package/dist/generated/programs/index.d.ts +9 -0
  211. package/dist/generated/programs/index.d.ts.map +1 -0
  212. package/dist/generated/programs/index.js +8 -0
  213. package/dist/generated/programs/piconDlmm.d.ts +126 -0
  214. package/dist/generated/programs/piconDlmm.d.ts.map +1 -0
  215. package/dist/generated/programs/piconDlmm.js +285 -0
  216. package/dist/generated/types/bin.d.ts +28 -0
  217. package/dist/generated/types/bin.d.ts.map +1 -0
  218. package/dist/generated/types/bin.js +31 -0
  219. package/dist/generated/types/distributionMode.d.ts +19 -0
  220. package/dist/generated/types/distributionMode.d.ts.map +1 -0
  221. package/dist/generated/types/distributionMode.js +24 -0
  222. package/dist/generated/types/dynamicFeeConfig.d.ts +29 -0
  223. package/dist/generated/types/dynamicFeeConfig.d.ts.map +1 -0
  224. package/dist/generated/types/dynamicFeeConfig.js +29 -0
  225. package/dist/generated/types/dynamicFeeState.d.ts +27 -0
  226. package/dist/generated/types/dynamicFeeState.d.ts.map +1 -0
  227. package/dist/generated/types/dynamicFeeState.js +30 -0
  228. package/dist/generated/types/feeState.d.ts +26 -0
  229. package/dist/generated/types/feeState.d.ts.map +1 -0
  230. package/dist/generated/types/feeState.js +29 -0
  231. package/dist/generated/types/index.d.ts +13 -0
  232. package/dist/generated/types/index.d.ts.map +1 -0
  233. package/dist/generated/types/index.js +12 -0
  234. package/dist/index.d.ts +5 -0
  235. package/dist/index.d.ts.map +1 -0
  236. package/dist/index.js +4 -0
  237. package/dist/picon_dlmm.json +2378 -0
  238. package/dist/program_addresses.d.ts +4 -0
  239. package/dist/program_addresses.d.ts.map +1 -0
  240. package/dist/program_addresses.js +8 -0
  241. package/dist/quote/index.d.ts +4 -0
  242. package/dist/quote/index.d.ts.map +1 -0
  243. package/dist/quote/index.js +5 -0
  244. package/dist/quote/wasm-node/picon_dlmm_quote.d.ts +6 -0
  245. package/dist/quote/wasm-node/picon_dlmm_quote.d.ts.map +1 -0
  246. package/dist/quote/wasm-node/picon_dlmm_quote.js +398 -0
  247. package/dist/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
  248. package/dist/quote/wasm-node-loader.d.ts +4 -0
  249. package/dist/quote/wasm-node-loader.d.ts.map +1 -0
  250. package/dist/quote/wasm-node-loader.js +7 -0
  251. package/dist/quote/wasm-web/picon_dlmm_quote.d.ts +9 -0
  252. package/dist/quote/wasm-web/picon_dlmm_quote.d.ts.map +1 -0
  253. package/dist/quote/wasm-web/picon_dlmm_quote.js +486 -0
  254. package/dist/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
  255. package/dist/quote/wasm-web-loader.d.ts +4 -0
  256. package/dist/quote/wasm-web-loader.d.ts.map +1 -0
  257. package/dist/quote/wasm-web-loader.js +12 -0
  258. package/dist/utils/admin_config.d.ts +3 -0
  259. package/dist/utils/admin_config.d.ts.map +1 -0
  260. package/dist/utils/admin_config.js +4 -0
  261. package/dist/utils/ata.d.ts +49 -0
  262. package/dist/utils/ata.d.ts.map +1 -0
  263. package/dist/utils/ata.js +113 -0
  264. package/dist/utils/bin_array.d.ts +8 -0
  265. package/dist/utils/bin_array.d.ts.map +1 -0
  266. package/dist/utils/bin_array.js +29 -0
  267. package/dist/utils/bin_location.d.ts +11 -0
  268. package/dist/utils/bin_location.d.ts.map +1 -0
  269. package/dist/utils/bin_location.js +55 -0
  270. package/dist/utils/chunk.d.ts +2 -0
  271. package/dist/utils/chunk.d.ts.map +1 -0
  272. package/dist/utils/chunk.js +7 -0
  273. package/dist/utils/compute_budget.d.ts +11 -0
  274. package/dist/utils/compute_budget.d.ts.map +1 -0
  275. package/dist/utils/compute_budget.js +22 -0
  276. package/dist/utils/constants.d.ts +12 -0
  277. package/dist/utils/constants.d.ts.map +1 -0
  278. package/dist/utils/constants.js +20 -0
  279. package/dist/utils/transfer_fee.d.ts +4 -0
  280. package/dist/utils/transfer_fee.d.ts.map +1 -0
  281. package/dist/utils/transfer_fee.js +21 -0
  282. package/dist/utils/type_guards.d.ts +2 -0
  283. package/dist/utils/type_guards.d.ts.map +1 -0
  284. package/dist/utils/type_guards.js +3 -0
  285. package/package.json +59 -0
  286. package/src/actions/accept_admin_authority.ts +17 -0
  287. package/src/actions/claim_fee.ts +84 -0
  288. package/src/actions/claim_multiple_fees.ts +123 -0
  289. package/src/actions/claim_protocol_fee.ts +68 -0
  290. package/src/actions/close_position.ts +21 -0
  291. package/src/actions/create_admin_config.ts +50 -0
  292. package/src/actions/create_bin_array.ts +30 -0
  293. package/src/actions/create_pool.ts +49 -0
  294. package/src/actions/delete_bin_array.ts +33 -0
  295. package/src/actions/deposit_by_weight.ts +107 -0
  296. package/src/actions/get_admin_config.ts +13 -0
  297. package/src/actions/get_bin_arrays_by_indices.ts +15 -0
  298. package/src/actions/get_pool.ts +8 -0
  299. package/src/actions/get_position.ts +8 -0
  300. package/src/actions/get_position_by_position_mint.ts +14 -0
  301. package/src/actions/get_positions_by_owner.ts +48 -0
  302. package/src/actions/get_positions_by_position_mints.ts +21 -0
  303. package/src/actions/helpers/build_swap_transaction_message.ts +86 -0
  304. package/src/actions/helpers/build_transaction_message.ts +45 -0
  305. package/src/actions/helpers/index.ts +7 -0
  306. package/src/actions/helpers/resolve_active_bin_and_mints.ts +21 -0
  307. package/src/actions/helpers/resolve_admin_config_address.ts +11 -0
  308. package/src/actions/helpers/resolve_mint_info.ts +36 -0
  309. package/src/actions/helpers/resolve_position_range.ts +21 -0
  310. package/src/actions/helpers/resolve_token_mints_and_programs.ts +56 -0
  311. package/src/actions/index.ts +34 -0
  312. package/src/actions/is_admin_config_active.ts +14 -0
  313. package/src/actions/on_event.ts +78 -0
  314. package/src/actions/open_position.ts +66 -0
  315. package/src/actions/quote.ts +70 -0
  316. package/src/actions/set_metadata_update_authority.ts +17 -0
  317. package/src/actions/set_pool_dynamic_fee_config.ts +17 -0
  318. package/src/actions/set_pool_protocol_share.ts +17 -0
  319. package/src/actions/swap.ts +56 -0
  320. package/src/actions/sync_pool.ts +35 -0
  321. package/src/actions/transfer_admin_authority.ts +17 -0
  322. package/src/actions/withdraw.ts +87 -0
  323. package/src/events.ts +279 -0
  324. package/src/generated/accounts/adminConfig.ts +147 -0
  325. package/src/generated/accounts/binArray.ts +155 -0
  326. package/src/generated/accounts/index.ts +12 -0
  327. package/src/generated/accounts/pool.ts +192 -0
  328. package/src/generated/accounts/position.ts +164 -0
  329. package/src/generated/errors/index.ts +9 -0
  330. package/src/generated/errors/piconDlmm.ts +124 -0
  331. package/src/generated/index.ts +14 -0
  332. package/src/generated/instructions/acceptAdminAuthority.ts +262 -0
  333. package/src/generated/instructions/claimFee.ts +395 -0
  334. package/src/generated/instructions/claimProtocolFee.ts +462 -0
  335. package/src/generated/instructions/closePosition.ts +342 -0
  336. package/src/generated/instructions/createAdminConfig.ts +369 -0
  337. package/src/generated/instructions/createBinArray.ts +344 -0
  338. package/src/generated/instructions/createPool.ts +582 -0
  339. package/src/generated/instructions/deleteBinArray.ts +365 -0
  340. package/src/generated/instructions/depositByWeight.ts +435 -0
  341. package/src/generated/instructions/index.ts +25 -0
  342. package/src/generated/instructions/openPosition.ts +547 -0
  343. package/src/generated/instructions/setMetadataUpdateAuthority.ts +274 -0
  344. package/src/generated/instructions/setPoolDynamicFeeConfig.ts +304 -0
  345. package/src/generated/instructions/setPoolProtocolShare.ts +298 -0
  346. package/src/generated/instructions/swap.ts +336 -0
  347. package/src/generated/instructions/syncPool.ts +189 -0
  348. package/src/generated/instructions/transferAdminAuthority.ts +271 -0
  349. package/src/generated/instructions/withdraw.ts +402 -0
  350. package/src/generated/pdas/adminConfig.ts +32 -0
  351. package/src/generated/pdas/binArray.ts +40 -0
  352. package/src/generated/pdas/index.ts +12 -0
  353. package/src/generated/pdas/pool.ts +43 -0
  354. package/src/generated/pdas/position.ts +37 -0
  355. package/src/generated/programs/index.ts +9 -0
  356. package/src/generated/programs/piconDlmm.ts +803 -0
  357. package/src/generated/types/bin.ts +64 -0
  358. package/src/generated/types/distributionMode.ts +43 -0
  359. package/src/generated/types/dynamicFeeConfig.ts +69 -0
  360. package/src/generated/types/dynamicFeeState.ts +71 -0
  361. package/src/generated/types/feeState.ts +60 -0
  362. package/src/generated/types/index.ts +13 -0
  363. package/src/index.ts +4 -0
  364. package/src/picon_dlmm.json +2378 -0
  365. package/src/program_addresses.ts +10 -0
  366. package/src/quote/index.ts +14 -0
  367. package/src/quote/wasm-node/package.json +4 -0
  368. package/src/quote/wasm-node/picon_dlmm_quote.d.ts +64 -0
  369. package/src/quote/wasm-node/picon_dlmm_quote.js +407 -0
  370. package/src/quote/wasm-node/picon_dlmm_quote_bg.wasm +0 -0
  371. package/src/quote/wasm-node/picon_dlmm_quote_bg.wasm.d.ts +11 -0
  372. package/src/quote/wasm-node-loader.ts +11 -0
  373. package/src/quote/wasm-web/picon_dlmm_quote.d.ts +100 -0
  374. package/src/quote/wasm-web/picon_dlmm_quote.js +500 -0
  375. package/src/quote/wasm-web/picon_dlmm_quote_bg.wasm +0 -0
  376. package/src/quote/wasm-web/picon_dlmm_quote_bg.wasm.d.ts +11 -0
  377. package/src/quote/wasm-web-loader.ts +17 -0
  378. package/src/utils/admin_config.ts +6 -0
  379. package/src/utils/ata.ts +213 -0
  380. package/src/utils/bin_array.ts +45 -0
  381. package/src/utils/bin_location.ts +79 -0
  382. package/src/utils/chunk.ts +7 -0
  383. package/src/utils/compute_budget.ts +58 -0
  384. package/src/utils/constants.ts +24 -0
  385. package/src/utils/transfer_fee.ts +29 -0
  386. package/src/utils/type_guards.ts +3 -0
@@ -0,0 +1,803 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the Codama library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun Codama to update it.
5
+ *
6
+ * @see https://github.com/codama-idl/codama
7
+ */
8
+
9
+ import {
10
+ assertIsInstructionWithAccounts,
11
+ containsBytes,
12
+ extendClient,
13
+ fixEncoderSize,
14
+ getBytesEncoder,
15
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
16
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
17
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
18
+ SolanaError,
19
+ type Address,
20
+ type ClientWithPayer,
21
+ type ClientWithRpc,
22
+ type ClientWithTransactionPlanning,
23
+ type ClientWithTransactionSending,
24
+ type ExtendedClient,
25
+ type GetAccountInfoApi,
26
+ type GetMultipleAccountsApi,
27
+ type Instruction,
28
+ type InstructionWithData,
29
+ type ReadonlyUint8Array,
30
+ } from "@solana/kit";
31
+ import {
32
+ addSelfFetchFunctions,
33
+ addSelfPlanAndSendFunctions,
34
+ type SelfFetchFunctions,
35
+ type SelfPlanAndSendFunctions,
36
+ } from "@solana/program-client-core";
37
+ import {
38
+ getAdminConfigCodec,
39
+ getBinArrayCodec,
40
+ getPoolCodec,
41
+ getPositionCodec,
42
+ type AdminConfig,
43
+ type AdminConfigArgs,
44
+ type BinArray,
45
+ type BinArrayArgs,
46
+ type Pool,
47
+ type PoolArgs,
48
+ type Position,
49
+ type PositionArgs,
50
+ } from "../accounts";
51
+ import {
52
+ getAcceptAdminAuthorityInstructionAsync,
53
+ getClaimFeeInstruction,
54
+ getClaimProtocolFeeInstructionAsync,
55
+ getClosePositionInstructionAsync,
56
+ getCreateAdminConfigInstructionAsync,
57
+ getCreateBinArrayInstructionAsync,
58
+ getCreatePoolInstructionAsync,
59
+ getDeleteBinArrayInstructionAsync,
60
+ getDepositByWeightInstruction,
61
+ getOpenPositionInstructionAsync,
62
+ getSetMetadataUpdateAuthorityInstructionAsync,
63
+ getSetPoolDynamicFeeConfigInstructionAsync,
64
+ getSetPoolProtocolShareInstructionAsync,
65
+ getSwapInstruction,
66
+ getSyncPoolInstruction,
67
+ getTransferAdminAuthorityInstructionAsync,
68
+ getWithdrawInstruction,
69
+ parseAcceptAdminAuthorityInstruction,
70
+ parseClaimFeeInstruction,
71
+ parseClaimProtocolFeeInstruction,
72
+ parseClosePositionInstruction,
73
+ parseCreateAdminConfigInstruction,
74
+ parseCreateBinArrayInstruction,
75
+ parseCreatePoolInstruction,
76
+ parseDeleteBinArrayInstruction,
77
+ parseDepositByWeightInstruction,
78
+ parseOpenPositionInstruction,
79
+ parseSetMetadataUpdateAuthorityInstruction,
80
+ parseSetPoolDynamicFeeConfigInstruction,
81
+ parseSetPoolProtocolShareInstruction,
82
+ parseSwapInstruction,
83
+ parseSyncPoolInstruction,
84
+ parseTransferAdminAuthorityInstruction,
85
+ parseWithdrawInstruction,
86
+ type AcceptAdminAuthorityAsyncInput,
87
+ type ClaimFeeInput,
88
+ type ClaimProtocolFeeAsyncInput,
89
+ type ClosePositionAsyncInput,
90
+ type CreateAdminConfigAsyncInput,
91
+ type CreateBinArrayAsyncInput,
92
+ type CreatePoolAsyncInput,
93
+ type DeleteBinArrayAsyncInput,
94
+ type DepositByWeightInput,
95
+ type OpenPositionAsyncInput,
96
+ type ParsedAcceptAdminAuthorityInstruction,
97
+ type ParsedClaimFeeInstruction,
98
+ type ParsedClaimProtocolFeeInstruction,
99
+ type ParsedClosePositionInstruction,
100
+ type ParsedCreateAdminConfigInstruction,
101
+ type ParsedCreateBinArrayInstruction,
102
+ type ParsedCreatePoolInstruction,
103
+ type ParsedDeleteBinArrayInstruction,
104
+ type ParsedDepositByWeightInstruction,
105
+ type ParsedOpenPositionInstruction,
106
+ type ParsedSetMetadataUpdateAuthorityInstruction,
107
+ type ParsedSetPoolDynamicFeeConfigInstruction,
108
+ type ParsedSetPoolProtocolShareInstruction,
109
+ type ParsedSwapInstruction,
110
+ type ParsedSyncPoolInstruction,
111
+ type ParsedTransferAdminAuthorityInstruction,
112
+ type ParsedWithdrawInstruction,
113
+ type SetMetadataUpdateAuthorityAsyncInput,
114
+ type SetPoolDynamicFeeConfigAsyncInput,
115
+ type SetPoolProtocolShareAsyncInput,
116
+ type SwapInput,
117
+ type SyncPoolInput,
118
+ type TransferAdminAuthorityAsyncInput,
119
+ type WithdrawInput,
120
+ } from "../instructions";
121
+ import {
122
+ findAdminConfigPda,
123
+ findBinArrayPda,
124
+ findPoolPda,
125
+ findPositionPda,
126
+ } from "../pdas";
127
+
128
+ export const PICON_DLMM_PROGRAM_ADDRESS =
129
+ "pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC" as Address<"pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC">;
130
+
131
+ export enum PiconDlmmAccount {
132
+ AdminConfig,
133
+ BinArray,
134
+ Pool,
135
+ Position,
136
+ }
137
+
138
+ export function identifyPiconDlmmAccount(
139
+ account: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
140
+ ): PiconDlmmAccount {
141
+ const data = "data" in account ? account.data : account;
142
+ if (
143
+ containsBytes(
144
+ data,
145
+ fixEncoderSize(getBytesEncoder(), 8).encode(
146
+ new Uint8Array([156, 10, 79, 161, 71, 9, 62, 77]),
147
+ ),
148
+ 0,
149
+ )
150
+ ) {
151
+ return PiconDlmmAccount.AdminConfig;
152
+ }
153
+ if (
154
+ containsBytes(
155
+ data,
156
+ fixEncoderSize(getBytesEncoder(), 8).encode(
157
+ new Uint8Array([92, 142, 92, 220, 5, 148, 70, 181]),
158
+ ),
159
+ 0,
160
+ )
161
+ ) {
162
+ return PiconDlmmAccount.BinArray;
163
+ }
164
+ if (
165
+ containsBytes(
166
+ data,
167
+ fixEncoderSize(getBytesEncoder(), 8).encode(
168
+ new Uint8Array([241, 154, 109, 4, 17, 177, 109, 188]),
169
+ ),
170
+ 0,
171
+ )
172
+ ) {
173
+ return PiconDlmmAccount.Pool;
174
+ }
175
+ if (
176
+ containsBytes(
177
+ data,
178
+ fixEncoderSize(getBytesEncoder(), 8).encode(
179
+ new Uint8Array([170, 188, 143, 228, 122, 64, 247, 208]),
180
+ ),
181
+ 0,
182
+ )
183
+ ) {
184
+ return PiconDlmmAccount.Position;
185
+ }
186
+ throw new SolanaError(
187
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_ACCOUNT,
188
+ { accountData: data, programName: "piconDlmm" },
189
+ );
190
+ }
191
+
192
+ export enum PiconDlmmInstruction {
193
+ AcceptAdminAuthority,
194
+ ClaimFee,
195
+ ClaimProtocolFee,
196
+ ClosePosition,
197
+ CreateAdminConfig,
198
+ CreateBinArray,
199
+ CreatePool,
200
+ DeleteBinArray,
201
+ DepositByWeight,
202
+ OpenPosition,
203
+ SetMetadataUpdateAuthority,
204
+ SetPoolDynamicFeeConfig,
205
+ SetPoolProtocolShare,
206
+ Swap,
207
+ SyncPool,
208
+ TransferAdminAuthority,
209
+ Withdraw,
210
+ }
211
+
212
+ export function identifyPiconDlmmInstruction(
213
+ instruction: { data: ReadonlyUint8Array } | ReadonlyUint8Array,
214
+ ): PiconDlmmInstruction {
215
+ const data = "data" in instruction ? instruction.data : instruction;
216
+ if (
217
+ containsBytes(
218
+ data,
219
+ fixEncoderSize(getBytesEncoder(), 8).encode(
220
+ new Uint8Array([109, 115, 12, 245, 11, 10, 16, 209]),
221
+ ),
222
+ 0,
223
+ )
224
+ ) {
225
+ return PiconDlmmInstruction.AcceptAdminAuthority;
226
+ }
227
+ if (
228
+ containsBytes(
229
+ data,
230
+ fixEncoderSize(getBytesEncoder(), 8).encode(
231
+ new Uint8Array([169, 32, 79, 137, 136, 232, 70, 137]),
232
+ ),
233
+ 0,
234
+ )
235
+ ) {
236
+ return PiconDlmmInstruction.ClaimFee;
237
+ }
238
+ if (
239
+ containsBytes(
240
+ data,
241
+ fixEncoderSize(getBytesEncoder(), 8).encode(
242
+ new Uint8Array([165, 228, 133, 48, 99, 249, 255, 33]),
243
+ ),
244
+ 0,
245
+ )
246
+ ) {
247
+ return PiconDlmmInstruction.ClaimProtocolFee;
248
+ }
249
+ if (
250
+ containsBytes(
251
+ data,
252
+ fixEncoderSize(getBytesEncoder(), 8).encode(
253
+ new Uint8Array([123, 134, 81, 0, 49, 68, 98, 98]),
254
+ ),
255
+ 0,
256
+ )
257
+ ) {
258
+ return PiconDlmmInstruction.ClosePosition;
259
+ }
260
+ if (
261
+ containsBytes(
262
+ data,
263
+ fixEncoderSize(getBytesEncoder(), 8).encode(
264
+ new Uint8Array([19, 140, 214, 88, 151, 236, 89, 5]),
265
+ ),
266
+ 0,
267
+ )
268
+ ) {
269
+ return PiconDlmmInstruction.CreateAdminConfig;
270
+ }
271
+ if (
272
+ containsBytes(
273
+ data,
274
+ fixEncoderSize(getBytesEncoder(), 8).encode(
275
+ new Uint8Array([107, 26, 23, 62, 137, 213, 131, 235]),
276
+ ),
277
+ 0,
278
+ )
279
+ ) {
280
+ return PiconDlmmInstruction.CreateBinArray;
281
+ }
282
+ if (
283
+ containsBytes(
284
+ data,
285
+ fixEncoderSize(getBytesEncoder(), 8).encode(
286
+ new Uint8Array([233, 146, 209, 142, 207, 104, 64, 188]),
287
+ ),
288
+ 0,
289
+ )
290
+ ) {
291
+ return PiconDlmmInstruction.CreatePool;
292
+ }
293
+ if (
294
+ containsBytes(
295
+ data,
296
+ fixEncoderSize(getBytesEncoder(), 8).encode(
297
+ new Uint8Array([158, 86, 142, 160, 52, 53, 194, 51]),
298
+ ),
299
+ 0,
300
+ )
301
+ ) {
302
+ return PiconDlmmInstruction.DeleteBinArray;
303
+ }
304
+ if (
305
+ containsBytes(
306
+ data,
307
+ fixEncoderSize(getBytesEncoder(), 8).encode(
308
+ new Uint8Array([121, 187, 132, 201, 131, 190, 200, 124]),
309
+ ),
310
+ 0,
311
+ )
312
+ ) {
313
+ return PiconDlmmInstruction.DepositByWeight;
314
+ }
315
+ if (
316
+ containsBytes(
317
+ data,
318
+ fixEncoderSize(getBytesEncoder(), 8).encode(
319
+ new Uint8Array([135, 128, 47, 77, 15, 152, 240, 49]),
320
+ ),
321
+ 0,
322
+ )
323
+ ) {
324
+ return PiconDlmmInstruction.OpenPosition;
325
+ }
326
+ if (
327
+ containsBytes(
328
+ data,
329
+ fixEncoderSize(getBytesEncoder(), 8).encode(
330
+ new Uint8Array([82, 181, 7, 62, 133, 40, 2, 109]),
331
+ ),
332
+ 0,
333
+ )
334
+ ) {
335
+ return PiconDlmmInstruction.SetMetadataUpdateAuthority;
336
+ }
337
+ if (
338
+ containsBytes(
339
+ data,
340
+ fixEncoderSize(getBytesEncoder(), 8).encode(
341
+ new Uint8Array([44, 189, 119, 222, 246, 2, 137, 85]),
342
+ ),
343
+ 0,
344
+ )
345
+ ) {
346
+ return PiconDlmmInstruction.SetPoolDynamicFeeConfig;
347
+ }
348
+ if (
349
+ containsBytes(
350
+ data,
351
+ fixEncoderSize(getBytesEncoder(), 8).encode(
352
+ new Uint8Array([16, 138, 62, 186, 255, 137, 75, 193]),
353
+ ),
354
+ 0,
355
+ )
356
+ ) {
357
+ return PiconDlmmInstruction.SetPoolProtocolShare;
358
+ }
359
+ if (
360
+ containsBytes(
361
+ data,
362
+ fixEncoderSize(getBytesEncoder(), 8).encode(
363
+ new Uint8Array([248, 198, 158, 145, 225, 117, 135, 200]),
364
+ ),
365
+ 0,
366
+ )
367
+ ) {
368
+ return PiconDlmmInstruction.Swap;
369
+ }
370
+ if (
371
+ containsBytes(
372
+ data,
373
+ fixEncoderSize(getBytesEncoder(), 8).encode(
374
+ new Uint8Array([219, 251, 215, 251, 44, 37, 108, 102]),
375
+ ),
376
+ 0,
377
+ )
378
+ ) {
379
+ return PiconDlmmInstruction.SyncPool;
380
+ }
381
+ if (
382
+ containsBytes(
383
+ data,
384
+ fixEncoderSize(getBytesEncoder(), 8).encode(
385
+ new Uint8Array([198, 11, 182, 207, 145, 11, 135, 215]),
386
+ ),
387
+ 0,
388
+ )
389
+ ) {
390
+ return PiconDlmmInstruction.TransferAdminAuthority;
391
+ }
392
+ if (
393
+ containsBytes(
394
+ data,
395
+ fixEncoderSize(getBytesEncoder(), 8).encode(
396
+ new Uint8Array([183, 18, 70, 156, 148, 109, 161, 34]),
397
+ ),
398
+ 0,
399
+ )
400
+ ) {
401
+ return PiconDlmmInstruction.Withdraw;
402
+ }
403
+ throw new SolanaError(
404
+ SOLANA_ERROR__PROGRAM_CLIENTS__FAILED_TO_IDENTIFY_INSTRUCTION,
405
+ { instructionData: data, programName: "piconDlmm" },
406
+ );
407
+ }
408
+
409
+ export type ParsedPiconDlmmInstruction<
410
+ TProgram extends string = "pDLMMk3KW3CUSxE1Wgjhx3jSmm2spe6Ry7Mq2HT26rC",
411
+ > =
412
+ | ({
413
+ instructionType: PiconDlmmInstruction.AcceptAdminAuthority;
414
+ } & ParsedAcceptAdminAuthorityInstruction<TProgram>)
415
+ | ({
416
+ instructionType: PiconDlmmInstruction.ClaimFee;
417
+ } & ParsedClaimFeeInstruction<TProgram>)
418
+ | ({
419
+ instructionType: PiconDlmmInstruction.ClaimProtocolFee;
420
+ } & ParsedClaimProtocolFeeInstruction<TProgram>)
421
+ | ({
422
+ instructionType: PiconDlmmInstruction.ClosePosition;
423
+ } & ParsedClosePositionInstruction<TProgram>)
424
+ | ({
425
+ instructionType: PiconDlmmInstruction.CreateAdminConfig;
426
+ } & ParsedCreateAdminConfigInstruction<TProgram>)
427
+ | ({
428
+ instructionType: PiconDlmmInstruction.CreateBinArray;
429
+ } & ParsedCreateBinArrayInstruction<TProgram>)
430
+ | ({
431
+ instructionType: PiconDlmmInstruction.CreatePool;
432
+ } & ParsedCreatePoolInstruction<TProgram>)
433
+ | ({
434
+ instructionType: PiconDlmmInstruction.DeleteBinArray;
435
+ } & ParsedDeleteBinArrayInstruction<TProgram>)
436
+ | ({
437
+ instructionType: PiconDlmmInstruction.DepositByWeight;
438
+ } & ParsedDepositByWeightInstruction<TProgram>)
439
+ | ({
440
+ instructionType: PiconDlmmInstruction.OpenPosition;
441
+ } & ParsedOpenPositionInstruction<TProgram>)
442
+ | ({
443
+ instructionType: PiconDlmmInstruction.SetMetadataUpdateAuthority;
444
+ } & ParsedSetMetadataUpdateAuthorityInstruction<TProgram>)
445
+ | ({
446
+ instructionType: PiconDlmmInstruction.SetPoolDynamicFeeConfig;
447
+ } & ParsedSetPoolDynamicFeeConfigInstruction<TProgram>)
448
+ | ({
449
+ instructionType: PiconDlmmInstruction.SetPoolProtocolShare;
450
+ } & ParsedSetPoolProtocolShareInstruction<TProgram>)
451
+ | ({
452
+ instructionType: PiconDlmmInstruction.Swap;
453
+ } & ParsedSwapInstruction<TProgram>)
454
+ | ({
455
+ instructionType: PiconDlmmInstruction.SyncPool;
456
+ } & ParsedSyncPoolInstruction<TProgram>)
457
+ | ({
458
+ instructionType: PiconDlmmInstruction.TransferAdminAuthority;
459
+ } & ParsedTransferAdminAuthorityInstruction<TProgram>)
460
+ | ({
461
+ instructionType: PiconDlmmInstruction.Withdraw;
462
+ } & ParsedWithdrawInstruction<TProgram>);
463
+
464
+ export function parsePiconDlmmInstruction<TProgram extends string>(
465
+ instruction: Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array>,
466
+ ): ParsedPiconDlmmInstruction<TProgram> {
467
+ const instructionType = identifyPiconDlmmInstruction(instruction);
468
+ switch (instructionType) {
469
+ case PiconDlmmInstruction.AcceptAdminAuthority: {
470
+ assertIsInstructionWithAccounts(instruction);
471
+ return {
472
+ instructionType: PiconDlmmInstruction.AcceptAdminAuthority,
473
+ ...parseAcceptAdminAuthorityInstruction(instruction),
474
+ };
475
+ }
476
+ case PiconDlmmInstruction.ClaimFee: {
477
+ assertIsInstructionWithAccounts(instruction);
478
+ return {
479
+ instructionType: PiconDlmmInstruction.ClaimFee,
480
+ ...parseClaimFeeInstruction(instruction),
481
+ };
482
+ }
483
+ case PiconDlmmInstruction.ClaimProtocolFee: {
484
+ assertIsInstructionWithAccounts(instruction);
485
+ return {
486
+ instructionType: PiconDlmmInstruction.ClaimProtocolFee,
487
+ ...parseClaimProtocolFeeInstruction(instruction),
488
+ };
489
+ }
490
+ case PiconDlmmInstruction.ClosePosition: {
491
+ assertIsInstructionWithAccounts(instruction);
492
+ return {
493
+ instructionType: PiconDlmmInstruction.ClosePosition,
494
+ ...parseClosePositionInstruction(instruction),
495
+ };
496
+ }
497
+ case PiconDlmmInstruction.CreateAdminConfig: {
498
+ assertIsInstructionWithAccounts(instruction);
499
+ return {
500
+ instructionType: PiconDlmmInstruction.CreateAdminConfig,
501
+ ...parseCreateAdminConfigInstruction(instruction),
502
+ };
503
+ }
504
+ case PiconDlmmInstruction.CreateBinArray: {
505
+ assertIsInstructionWithAccounts(instruction);
506
+ return {
507
+ instructionType: PiconDlmmInstruction.CreateBinArray,
508
+ ...parseCreateBinArrayInstruction(instruction),
509
+ };
510
+ }
511
+ case PiconDlmmInstruction.CreatePool: {
512
+ assertIsInstructionWithAccounts(instruction);
513
+ return {
514
+ instructionType: PiconDlmmInstruction.CreatePool,
515
+ ...parseCreatePoolInstruction(instruction),
516
+ };
517
+ }
518
+ case PiconDlmmInstruction.DeleteBinArray: {
519
+ assertIsInstructionWithAccounts(instruction);
520
+ return {
521
+ instructionType: PiconDlmmInstruction.DeleteBinArray,
522
+ ...parseDeleteBinArrayInstruction(instruction),
523
+ };
524
+ }
525
+ case PiconDlmmInstruction.DepositByWeight: {
526
+ assertIsInstructionWithAccounts(instruction);
527
+ return {
528
+ instructionType: PiconDlmmInstruction.DepositByWeight,
529
+ ...parseDepositByWeightInstruction(instruction),
530
+ };
531
+ }
532
+ case PiconDlmmInstruction.OpenPosition: {
533
+ assertIsInstructionWithAccounts(instruction);
534
+ return {
535
+ instructionType: PiconDlmmInstruction.OpenPosition,
536
+ ...parseOpenPositionInstruction(instruction),
537
+ };
538
+ }
539
+ case PiconDlmmInstruction.SetMetadataUpdateAuthority: {
540
+ assertIsInstructionWithAccounts(instruction);
541
+ return {
542
+ instructionType: PiconDlmmInstruction.SetMetadataUpdateAuthority,
543
+ ...parseSetMetadataUpdateAuthorityInstruction(instruction),
544
+ };
545
+ }
546
+ case PiconDlmmInstruction.SetPoolDynamicFeeConfig: {
547
+ assertIsInstructionWithAccounts(instruction);
548
+ return {
549
+ instructionType: PiconDlmmInstruction.SetPoolDynamicFeeConfig,
550
+ ...parseSetPoolDynamicFeeConfigInstruction(instruction),
551
+ };
552
+ }
553
+ case PiconDlmmInstruction.SetPoolProtocolShare: {
554
+ assertIsInstructionWithAccounts(instruction);
555
+ return {
556
+ instructionType: PiconDlmmInstruction.SetPoolProtocolShare,
557
+ ...parseSetPoolProtocolShareInstruction(instruction),
558
+ };
559
+ }
560
+ case PiconDlmmInstruction.Swap: {
561
+ assertIsInstructionWithAccounts(instruction);
562
+ return {
563
+ instructionType: PiconDlmmInstruction.Swap,
564
+ ...parseSwapInstruction(instruction),
565
+ };
566
+ }
567
+ case PiconDlmmInstruction.SyncPool: {
568
+ assertIsInstructionWithAccounts(instruction);
569
+ return {
570
+ instructionType: PiconDlmmInstruction.SyncPool,
571
+ ...parseSyncPoolInstruction(instruction),
572
+ };
573
+ }
574
+ case PiconDlmmInstruction.TransferAdminAuthority: {
575
+ assertIsInstructionWithAccounts(instruction);
576
+ return {
577
+ instructionType: PiconDlmmInstruction.TransferAdminAuthority,
578
+ ...parseTransferAdminAuthorityInstruction(instruction),
579
+ };
580
+ }
581
+ case PiconDlmmInstruction.Withdraw: {
582
+ assertIsInstructionWithAccounts(instruction);
583
+ return {
584
+ instructionType: PiconDlmmInstruction.Withdraw,
585
+ ...parseWithdrawInstruction(instruction),
586
+ };
587
+ }
588
+ default:
589
+ throw new SolanaError(
590
+ SOLANA_ERROR__PROGRAM_CLIENTS__UNRECOGNIZED_INSTRUCTION_TYPE,
591
+ {
592
+ instructionType: instructionType as string,
593
+ programName: "piconDlmm",
594
+ },
595
+ );
596
+ }
597
+ }
598
+
599
+ export type PiconDlmmPlugin = {
600
+ accounts: PiconDlmmPluginAccounts;
601
+ instructions: PiconDlmmPluginInstructions;
602
+ pdas: PiconDlmmPluginPdas;
603
+ identifyAccount: typeof identifyPiconDlmmAccount;
604
+ identifyInstruction: typeof identifyPiconDlmmInstruction;
605
+ parseInstruction: typeof parsePiconDlmmInstruction;
606
+ };
607
+
608
+ export type PiconDlmmPluginAccounts = {
609
+ adminConfig: ReturnType<typeof getAdminConfigCodec> &
610
+ SelfFetchFunctions<AdminConfigArgs, AdminConfig>;
611
+ binArray: ReturnType<typeof getBinArrayCodec> &
612
+ SelfFetchFunctions<BinArrayArgs, BinArray>;
613
+ pool: ReturnType<typeof getPoolCodec> & SelfFetchFunctions<PoolArgs, Pool>;
614
+ position: ReturnType<typeof getPositionCodec> &
615
+ SelfFetchFunctions<PositionArgs, Position>;
616
+ };
617
+
618
+ export type PiconDlmmPluginInstructions = {
619
+ acceptAdminAuthority: (
620
+ input: AcceptAdminAuthorityAsyncInput,
621
+ ) => ReturnType<typeof getAcceptAdminAuthorityInstructionAsync> &
622
+ SelfPlanAndSendFunctions;
623
+ claimFee: (
624
+ input: ClaimFeeInput,
625
+ ) => ReturnType<typeof getClaimFeeInstruction> & SelfPlanAndSendFunctions;
626
+ claimProtocolFee: (
627
+ input: ClaimProtocolFeeAsyncInput,
628
+ ) => ReturnType<typeof getClaimProtocolFeeInstructionAsync> &
629
+ SelfPlanAndSendFunctions;
630
+ closePosition: (
631
+ input: ClosePositionAsyncInput,
632
+ ) => ReturnType<typeof getClosePositionInstructionAsync> &
633
+ SelfPlanAndSendFunctions;
634
+ createAdminConfig: (
635
+ input: CreateAdminConfigAsyncInput,
636
+ ) => ReturnType<typeof getCreateAdminConfigInstructionAsync> &
637
+ SelfPlanAndSendFunctions;
638
+ createBinArray: (
639
+ input: MakeOptional<CreateBinArrayAsyncInput, "payer">,
640
+ ) => ReturnType<typeof getCreateBinArrayInstructionAsync> &
641
+ SelfPlanAndSendFunctions;
642
+ createPool: (
643
+ input: CreatePoolAsyncInput,
644
+ ) => ReturnType<typeof getCreatePoolInstructionAsync> &
645
+ SelfPlanAndSendFunctions;
646
+ deleteBinArray: (
647
+ input: DeleteBinArrayAsyncInput,
648
+ ) => ReturnType<typeof getDeleteBinArrayInstructionAsync> &
649
+ SelfPlanAndSendFunctions;
650
+ depositByWeight: (
651
+ input: DepositByWeightInput,
652
+ ) => ReturnType<typeof getDepositByWeightInstruction> &
653
+ SelfPlanAndSendFunctions;
654
+ openPosition: (
655
+ input: OpenPositionAsyncInput,
656
+ ) => ReturnType<typeof getOpenPositionInstructionAsync> &
657
+ SelfPlanAndSendFunctions;
658
+ setMetadataUpdateAuthority: (
659
+ input: SetMetadataUpdateAuthorityAsyncInput,
660
+ ) => ReturnType<typeof getSetMetadataUpdateAuthorityInstructionAsync> &
661
+ SelfPlanAndSendFunctions;
662
+ setPoolDynamicFeeConfig: (
663
+ input: SetPoolDynamicFeeConfigAsyncInput,
664
+ ) => ReturnType<typeof getSetPoolDynamicFeeConfigInstructionAsync> &
665
+ SelfPlanAndSendFunctions;
666
+ setPoolProtocolShare: (
667
+ input: SetPoolProtocolShareAsyncInput,
668
+ ) => ReturnType<typeof getSetPoolProtocolShareInstructionAsync> &
669
+ SelfPlanAndSendFunctions;
670
+ swap: (
671
+ input: SwapInput,
672
+ ) => ReturnType<typeof getSwapInstruction> & SelfPlanAndSendFunctions;
673
+ syncPool: (
674
+ input: SyncPoolInput,
675
+ ) => ReturnType<typeof getSyncPoolInstruction> & SelfPlanAndSendFunctions;
676
+ transferAdminAuthority: (
677
+ input: TransferAdminAuthorityAsyncInput,
678
+ ) => ReturnType<typeof getTransferAdminAuthorityInstructionAsync> &
679
+ SelfPlanAndSendFunctions;
680
+ withdraw: (
681
+ input: WithdrawInput,
682
+ ) => ReturnType<typeof getWithdrawInstruction> & SelfPlanAndSendFunctions;
683
+ };
684
+
685
+ export type PiconDlmmPluginPdas = {
686
+ adminConfig: typeof findAdminConfigPda;
687
+ position: typeof findPositionPda;
688
+ binArray: typeof findBinArrayPda;
689
+ pool: typeof findPoolPda;
690
+ };
691
+
692
+ export type PiconDlmmPluginRequirements = ClientWithRpc<
693
+ GetAccountInfoApi & GetMultipleAccountsApi
694
+ > &
695
+ ClientWithPayer &
696
+ ClientWithTransactionPlanning &
697
+ ClientWithTransactionSending;
698
+
699
+ export function piconDlmmProgram() {
700
+ return <T extends PiconDlmmPluginRequirements>(
701
+ client: T,
702
+ ): ExtendedClient<T, { piconDlmm: PiconDlmmPlugin }> => {
703
+ return extendClient(client, {
704
+ piconDlmm: <PiconDlmmPlugin>{
705
+ accounts: {
706
+ adminConfig: addSelfFetchFunctions(client, getAdminConfigCodec()),
707
+ binArray: addSelfFetchFunctions(client, getBinArrayCodec()),
708
+ pool: addSelfFetchFunctions(client, getPoolCodec()),
709
+ position: addSelfFetchFunctions(client, getPositionCodec()),
710
+ },
711
+ instructions: {
712
+ acceptAdminAuthority: (input) =>
713
+ addSelfPlanAndSendFunctions(
714
+ client,
715
+ getAcceptAdminAuthorityInstructionAsync(input),
716
+ ),
717
+ claimFee: (input) =>
718
+ addSelfPlanAndSendFunctions(client, getClaimFeeInstruction(input)),
719
+ claimProtocolFee: (input) =>
720
+ addSelfPlanAndSendFunctions(
721
+ client,
722
+ getClaimProtocolFeeInstructionAsync(input),
723
+ ),
724
+ closePosition: (input) =>
725
+ addSelfPlanAndSendFunctions(
726
+ client,
727
+ getClosePositionInstructionAsync(input),
728
+ ),
729
+ createAdminConfig: (input) =>
730
+ addSelfPlanAndSendFunctions(
731
+ client,
732
+ getCreateAdminConfigInstructionAsync(input),
733
+ ),
734
+ createBinArray: (input) =>
735
+ addSelfPlanAndSendFunctions(
736
+ client,
737
+ getCreateBinArrayInstructionAsync({
738
+ ...input,
739
+ payer: input.payer ?? client.payer,
740
+ }),
741
+ ),
742
+ createPool: (input) =>
743
+ addSelfPlanAndSendFunctions(
744
+ client,
745
+ getCreatePoolInstructionAsync(input),
746
+ ),
747
+ deleteBinArray: (input) =>
748
+ addSelfPlanAndSendFunctions(
749
+ client,
750
+ getDeleteBinArrayInstructionAsync(input),
751
+ ),
752
+ depositByWeight: (input) =>
753
+ addSelfPlanAndSendFunctions(
754
+ client,
755
+ getDepositByWeightInstruction(input),
756
+ ),
757
+ openPosition: (input) =>
758
+ addSelfPlanAndSendFunctions(
759
+ client,
760
+ getOpenPositionInstructionAsync(input),
761
+ ),
762
+ setMetadataUpdateAuthority: (input) =>
763
+ addSelfPlanAndSendFunctions(
764
+ client,
765
+ getSetMetadataUpdateAuthorityInstructionAsync(input),
766
+ ),
767
+ setPoolDynamicFeeConfig: (input) =>
768
+ addSelfPlanAndSendFunctions(
769
+ client,
770
+ getSetPoolDynamicFeeConfigInstructionAsync(input),
771
+ ),
772
+ setPoolProtocolShare: (input) =>
773
+ addSelfPlanAndSendFunctions(
774
+ client,
775
+ getSetPoolProtocolShareInstructionAsync(input),
776
+ ),
777
+ swap: (input) =>
778
+ addSelfPlanAndSendFunctions(client, getSwapInstruction(input)),
779
+ syncPool: (input) =>
780
+ addSelfPlanAndSendFunctions(client, getSyncPoolInstruction(input)),
781
+ transferAdminAuthority: (input) =>
782
+ addSelfPlanAndSendFunctions(
783
+ client,
784
+ getTransferAdminAuthorityInstructionAsync(input),
785
+ ),
786
+ withdraw: (input) =>
787
+ addSelfPlanAndSendFunctions(client, getWithdrawInstruction(input)),
788
+ },
789
+ pdas: {
790
+ adminConfig: findAdminConfigPda,
791
+ position: findPositionPda,
792
+ binArray: findBinArrayPda,
793
+ pool: findPoolPda,
794
+ },
795
+ identifyAccount: identifyPiconDlmmAccount,
796
+ identifyInstruction: identifyPiconDlmmInstruction,
797
+ parseInstruction: parsePiconDlmmInstruction,
798
+ },
799
+ });
800
+ };
801
+ }
802
+
803
+ type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;