@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,86 @@
1
+ import { type Address, type TransactionSigner, AccountRole } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, getSwapInstruction } from "../../generated";
3
+ import { processAssociatedTokenAccountPair, findPoolTokenVaults } from "../../utils/ata";
4
+ import { buildTransactionMessage, type TransactionMessageOptions, type Rpc } from "./build_transaction_message";
5
+
6
+ // Pure tx builder: every account is already resolved by the caller (`swap`, or `quote`'s
7
+ // returned closure reusing the accounts its own quote was computed against) — no RPC calls,
8
+ // no derivation beyond ATA/vault lookups, no fallbacks.
9
+ //
10
+ // The bin arrays are Anchor `remaining_accounts`, not part of the typed account list, so
11
+ // they're appended manually here — writable, since swap mutates bins via `load_mut` (unlike
12
+ // sync_pool's read-only remaining accounts). `binArrayAddresses` is caller-resolved.
13
+ export async function buildSwapTransactionMessage(
14
+ rpc: Rpc,
15
+ {
16
+ user,
17
+ pool,
18
+ xToY,
19
+ amountIn,
20
+ minAmountOut,
21
+ tokenMintX,
22
+ tokenMintY,
23
+ tokenProgramX,
24
+ tokenProgramY,
25
+ binArrayAddresses,
26
+ }: {
27
+ user: TransactionSigner,
28
+ pool: Address,
29
+ xToY: boolean,
30
+ amountIn: bigint,
31
+ minAmountOut: bigint,
32
+ tokenMintX: Address,
33
+ tokenMintY: Address,
34
+ tokenProgramX: Address,
35
+ tokenProgramY: Address,
36
+ binArrayAddresses: Address[],
37
+ },
38
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
39
+ options: TransactionMessageOptions = {},
40
+ ) {
41
+ const { tokenVaultX, tokenVaultY } = await findPoolTokenVaults({ pool, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY });
42
+
43
+ // Only the input side needs `amount` (to actually wrap/transfer in); the output side is
44
+ // receive-only, same as claim_fee/withdraw's ATAs.
45
+ const {
46
+ ataX: tokenUserAccountX,
47
+ ataY: tokenUserAccountY,
48
+ preInstructions: preInstructionsAta,
49
+ postInstructions: postInstructionsAta,
50
+ } = await processAssociatedTokenAccountPair({
51
+ owner: user,
52
+ tokenMintX,
53
+ tokenMintY,
54
+ tokenProgramX,
55
+ tokenProgramY,
56
+ amountX: xToY ? amountIn : undefined,
57
+ amountY: xToY ? undefined : amountIn,
58
+ });
59
+
60
+ const swapIx = getSwapInstruction({
61
+ user,
62
+ pool,
63
+ tokenMintX,
64
+ tokenMintY,
65
+ tokenUserAccountX,
66
+ tokenUserAccountY,
67
+ tokenVaultX,
68
+ tokenVaultY,
69
+ tokenProgramX,
70
+ tokenProgramY,
71
+ amountIn,
72
+ minAmountOut,
73
+ xToY,
74
+ }, { programAddress });
75
+ const remainingAccounts = binArrayAddresses.map(address => ({
76
+ address,
77
+ role: AccountRole.WRITABLE,
78
+ }));
79
+
80
+ const instructions = [
81
+ ...preInstructionsAta,
82
+ { ...swapIx, accounts: [...swapIx.accounts, ...remainingAccounts] },
83
+ ...postInstructionsAta,
84
+ ];
85
+ return await buildTransactionMessage(rpc, { feePayer: user, instructions }, options);
86
+ }
@@ -0,0 +1,45 @@
1
+ import {
2
+ pipe,
3
+ createTransactionMessage,
4
+ setTransactionMessageFeePayerSigner,
5
+ appendTransactionMessageInstructions,
6
+ setTransactionMessageLifetimeUsingBlockhash,
7
+ type Slot,
8
+ type Commitment,
9
+ type Instruction,
10
+ type TransactionSigner,
11
+ type createSolanaRpc,
12
+ type BlockhashLifetimeConstraint,
13
+ } from "@solana/kit";
14
+
15
+ export type Rpc = ReturnType<typeof createSolanaRpc>;
16
+
17
+ // Also accepted by every read-only action (fetches/reads) — matches @solana/kit's own
18
+ // `FetchAccountConfig` shape, so it forwards straight into the generated `fetchX` calls.
19
+ export interface TransactionMessageOptions {
20
+ commitment?: Commitment;
21
+ minContextSlot?: Slot;
22
+ abortSignal?: AbortSignal;
23
+ }
24
+
25
+ export async function buildTransactionMessage(
26
+ rpc: Rpc,
27
+ {
28
+ feePayer,
29
+ instructions,
30
+ latestBlockhash,
31
+ }: {
32
+ feePayer: TransactionSigner,
33
+ instructions: Instruction[],
34
+ latestBlockhash?: BlockhashLifetimeConstraint,
35
+ },
36
+ { commitment, minContextSlot, abortSignal }: TransactionMessageOptions = {},
37
+ ) {
38
+ latestBlockhash ??= (await rpc.getLatestBlockhash({ commitment, minContextSlot }).send({ abortSignal })).value;
39
+ return pipe(
40
+ createTransactionMessage({ version: 0 }),
41
+ msg => appendTransactionMessageInstructions(instructions, msg),
42
+ msg => setTransactionMessageFeePayerSigner(feePayer, msg),
43
+ msg => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, msg),
44
+ );
45
+ }
@@ -0,0 +1,7 @@
1
+ export { buildTransactionMessage, type TransactionMessageOptions, type Rpc } from "./build_transaction_message";
2
+ export { buildSwapTransactionMessage } from "./build_swap_transaction_message";
3
+ export { resolveTokenMintsAndPrograms } from "./resolve_token_mints_and_programs";
4
+ export { resolveActiveBinAndMints } from "./resolve_active_bin_and_mints";
5
+ export { resolveMintInfo } from "./resolve_mint_info";
6
+ export { resolvePositionRange } from "./resolve_position_range";
7
+ export { resolveAdminConfigAddress } from "./resolve_admin_config_address";
@@ -0,0 +1,21 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { getPool } from "../get_pool";
3
+ import { isUndefined } from "../../utils/type_guards";
4
+ import type { Rpc, TransactionMessageOptions } from "./build_transaction_message";
5
+
6
+ // No programAddress here — this only ever reads an already-known pool account by its explicit
7
+ // address (getPool), no PDA derivation, so there's nothing for it to affect.
8
+ export async function resolveActiveBinAndMints(
9
+ rpc: Rpc,
10
+ pool: Address,
11
+ { activeBinId, tokenMintX, tokenMintY }: { activeBinId?: number, tokenMintX?: Address, tokenMintY?: Address },
12
+ options: TransactionMessageOptions = {},
13
+ ): Promise<{ activeBinId: number, tokenMintX: Address, tokenMintY: Address }> {
14
+ if (isUndefined(activeBinId) || isUndefined(tokenMintX) || isUndefined(tokenMintY)) {
15
+ const poolData = await getPool(rpc, pool, options);
16
+ activeBinId ??= poolData.activeBinId;
17
+ tokenMintX ??= poolData.tokenMintX;
18
+ tokenMintY ??= poolData.tokenMintY;
19
+ }
20
+ return { activeBinId, tokenMintX, tokenMintY };
21
+ }
@@ -0,0 +1,11 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { findAdminConfigPda } from "../../generated";
3
+
4
+ // The generated instruction builders' own default resolution for the `adminConfig` account
5
+ // (every instruction that touches it) always derives against the mainnet
6
+ // PICON_DLMM_PROGRAM_ADDRESS baked in at codegen time, ignoring that call's own `programAddress`
7
+ // argument — so every action passes this explicitly instead of relying on the generated default.
8
+ export async function resolveAdminConfigAddress(programAddress: Address): Promise<Address> {
9
+ const [adminConfig] = await findAdminConfigPda({ programAddress });
10
+ return adminConfig;
11
+ }
@@ -0,0 +1,36 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { fetchAllMaybeMint } from "@solana-program/token-2022";
3
+ import { resolveTransferFee } from "../../utils/transfer_fee";
4
+ import type { TransferFee } from "../../quote";
5
+ import type { Rpc, TransactionMessageOptions } from "./build_transaction_message";
6
+
7
+ export async function resolveMintInfo(
8
+ rpc: Rpc,
9
+ tokenMintX: Address,
10
+ tokenMintY: Address,
11
+ { commitment, minContextSlot, abortSignal }: TransactionMessageOptions = {},
12
+ ): Promise<{
13
+ transferFeeX?: TransferFee,
14
+ transferFeeY?: TransferFee,
15
+ tokenProgramX: Address,
16
+ tokenProgramY: Address,
17
+ }> {
18
+ const [{ epoch }, [maybeMintX, maybeMintY]] = await Promise.all([
19
+ rpc.getEpochInfo({ commitment, minContextSlot }).send({ abortSignal }),
20
+ fetchAllMaybeMint(rpc, [tokenMintX, tokenMintY], { commitment, minContextSlot, abortSignal }),
21
+ ]);
22
+
23
+ if (!maybeMintX.exists) {
24
+ throw new Error(`Mint account not found: ${tokenMintX}`);
25
+ }
26
+ if (!maybeMintY.exists) {
27
+ throw new Error(`Mint account not found: ${tokenMintY}`);
28
+ }
29
+
30
+ return {
31
+ transferFeeX: resolveTransferFee(maybeMintX.data, epoch),
32
+ transferFeeY: resolveTransferFee(maybeMintY.data, epoch),
33
+ tokenProgramX: maybeMintX.programAddress,
34
+ tokenProgramY: maybeMintY.programAddress,
35
+ };
36
+ }
@@ -0,0 +1,21 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS } from "../../generated";
3
+ import { getPositionByPositionMint } from "../get_position_by_position_mint";
4
+ import { isUndefined } from "../../utils/type_guards";
5
+ import type { Rpc, TransactionMessageOptions } from "./build_transaction_message";
6
+
7
+ export async function resolvePositionRange(
8
+ rpc: Rpc,
9
+ positionMint: Address,
10
+ { pool, lowerBinId, upperBinId }: { pool?: Address, lowerBinId?: number, upperBinId?: number },
11
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
12
+ options: TransactionMessageOptions = {},
13
+ ): Promise<{ pool: Address, lowerBinId: number, upperBinId: number }> {
14
+ if (isUndefined(pool) || isUndefined(lowerBinId) || isUndefined(upperBinId)) {
15
+ const positionData = await getPositionByPositionMint(rpc, positionMint, programAddress, options);
16
+ pool ??= positionData.pool;
17
+ lowerBinId ??= positionData.lowerBinId;
18
+ upperBinId ??= positionData.upperBinId;
19
+ }
20
+ return { pool, lowerBinId, upperBinId };
21
+ }
@@ -0,0 +1,56 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { fetchAllMaybeMint } from "@solana-program/token-2022";
3
+ import { getPool } from "../get_pool";
4
+ import { isUndefined } from "../../utils/type_guards";
5
+ import type { Rpc, TransactionMessageOptions } from "./build_transaction_message";
6
+
7
+ // No programAddress here — this only ever reads an already-known pool account by its explicit
8
+ // address (getPool), no PDA derivation, so there's nothing for it to affect.
9
+ export async function resolveTokenMintsAndPrograms(
10
+ rpc: Rpc,
11
+ {
12
+ pool,
13
+ tokenMintX,
14
+ tokenMintY,
15
+ tokenProgramX,
16
+ tokenProgramY,
17
+ }: {
18
+ pool: Address,
19
+ tokenMintX?: Address,
20
+ tokenMintY?: Address,
21
+ tokenProgramX?: Address,
22
+ tokenProgramY?: Address,
23
+ },
24
+ options: TransactionMessageOptions = {},
25
+ ): Promise<{
26
+ tokenMintX: Address,
27
+ tokenMintY: Address,
28
+ tokenProgramX: Address,
29
+ tokenProgramY: Address,
30
+ }> {
31
+ if (isUndefined(tokenMintX) || isUndefined(tokenMintY)) {
32
+ const poolData = await getPool(rpc, pool, options);
33
+ tokenMintX ??= poolData.tokenMintX;
34
+ tokenMintY ??= poolData.tokenMintY;
35
+ }
36
+
37
+ if (tokenProgramX !== undefined && tokenProgramY !== undefined) {
38
+ return { tokenMintX, tokenMintY, tokenProgramX, tokenProgramY };
39
+ }
40
+
41
+ // One batched getMultipleAccounts instead of up to two separate getAccountInfo requests.
42
+ const [maybeMintX, maybeMintY] = await fetchAllMaybeMint(rpc, [tokenMintX, tokenMintY], options);
43
+ if (!maybeMintX.exists) {
44
+ throw new Error(`Mint account not found: ${tokenMintX}`);
45
+ }
46
+ if (!maybeMintY.exists) {
47
+ throw new Error(`Mint account not found: ${tokenMintY}`);
48
+ }
49
+
50
+ return {
51
+ tokenMintX,
52
+ tokenMintY,
53
+ tokenProgramX: tokenProgramX ?? maybeMintX.programAddress,
54
+ tokenProgramY: tokenProgramY ?? maybeMintY.programAddress,
55
+ };
56
+ }
@@ -0,0 +1,34 @@
1
+ export { type TransactionMessageOptions, type Rpc } from "./helpers";
2
+ export type { QuoteInput, QuoteOutput, PoolState, TransferFee } from "../quote";
3
+
4
+ export { getPool } from "./get_pool";
5
+ export { getAdminConfig } from "./get_admin_config";
6
+ export { isAdminConfigActive } from "./is_admin_config_active";
7
+ export { getPosition } from "./get_position";
8
+ export { getPositionByPositionMint } from "./get_position_by_position_mint";
9
+ export { getPositionsByPositionMints } from "./get_positions_by_position_mints";
10
+ export { getBinArraysByIndices } from "./get_bin_arrays_by_indices";
11
+ export { getPositionsByOwner } from "./get_positions_by_owner";
12
+
13
+ export { createPool } from "./create_pool";
14
+ export { syncPool } from "./sync_pool";
15
+ export { openPosition } from "./open_position";
16
+ export { closePosition } from "./close_position";
17
+ export { withdraw } from "./withdraw";
18
+ export { claimFee } from "./claim_fee";
19
+ export { claimMultipleFees } from "./claim_multiple_fees";
20
+ export { depositByWeight } from "./deposit_by_weight";
21
+ export { swap } from "./swap";
22
+ export { quote } from "./quote";
23
+
24
+ export { createAdminConfig } from "./create_admin_config";
25
+ export { transferAdminAuthority } from "./transfer_admin_authority";
26
+ export { acceptAdminAuthority } from "./accept_admin_authority";
27
+ export { setMetadataUpdateAuthority } from "./set_metadata_update_authority";
28
+ export { claimProtocolFee } from "./claim_protocol_fee";
29
+ export { setPoolDynamicFeeConfig } from "./set_pool_dynamic_fee_config";
30
+ export { setPoolProtocolShare } from "./set_pool_protocol_share";
31
+ export { createBinArray } from "./create_bin_array";
32
+ export { deleteBinArray } from "./delete_bin_array";
33
+
34
+ export { onEvent } from "./on_event";
@@ -0,0 +1,14 @@
1
+ import type { Address } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, fetchMaybeAdminConfig, findAdminConfigPda } from "../generated";
3
+ import { isAdminConfigActive as checkAdminConfigActive } from "../utils/admin_config";
4
+ import type { Rpc, TransactionMessageOptions } from "./helpers";
5
+
6
+ export async function isAdminConfigActive(
7
+ rpc: Rpc,
8
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
9
+ options: TransactionMessageOptions = {},
10
+ ): Promise<boolean> {
11
+ const [adminConfig] = await findAdminConfigPda({ programAddress });
12
+ const maybeAdminConfig = await fetchMaybeAdminConfig(rpc, adminConfig, options);
13
+ return maybeAdminConfig.exists && checkAdminConfigActive(maybeAdminConfig.data);
14
+ }
@@ -0,0 +1,78 @@
1
+ import { type Address, type Commitment, type createSolanaRpcSubscriptions } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS } from "../generated";
3
+ import { decodeEventsFromLogs, type DlmmEvent } from "../events";
4
+
5
+ type RpcSubscriptions = ReturnType<typeof createSolanaRpcSubscriptions>;
6
+
7
+ // `address` defaults to `programAddress` (every pool the program touches); pass a pool
8
+ // address to scope it. `programAddress` also scopes CPI-log filtering (see events.ts), so it
9
+ // should match whatever cluster's program this subscription is watching — defaults to mainnet.
10
+ // Resolves once the subscription is active, with an unsubscribe function. Errors — from the
11
+ // stream itself (e.g. a dropped websocket) or thrown by `handler` — are reported to `onError`
12
+ // instead of rejecting an unheld promise; a `handler` throw only drops that one event, the
13
+ // subscription keeps running.
14
+ export async function onEvent(
15
+ rpcSubscriptions: RpcSubscriptions,
16
+ handler: (event: DlmmEvent) => void,
17
+ {
18
+ address,
19
+ programAddress = PICON_DLMM_PROGRAM_ADDRESS,
20
+ commitment,
21
+ onError,
22
+ }: { address?: Address, programAddress?: Address, commitment?: Commitment, onError?: (error: unknown) => void } = {},
23
+ ): Promise<() => void> {
24
+ const abortController = new AbortController();
25
+ const eventStream = await subscribeToEvents(rpcSubscriptions, {
26
+ address: address ?? programAddress,
27
+ programAddress,
28
+ commitment,
29
+ abortSignal: abortController.signal,
30
+ });
31
+
32
+ (async () => {
33
+ try {
34
+ for await (const event of eventStream) {
35
+ try {
36
+ handler(event);
37
+ } catch (error) {
38
+ onError?.(error);
39
+ }
40
+ }
41
+ } catch (error) {
42
+ if (!abortController.signal.aborted) {
43
+ onError?.(error);
44
+ }
45
+ }
46
+ })();
47
+
48
+ return () => abortController.abort();
49
+ }
50
+
51
+ // Resolves once the subscription is active, so callers know they won't miss anything.
52
+ async function subscribeToEvents(
53
+ rpcSubscriptions: RpcSubscriptions,
54
+ {
55
+ address,
56
+ programAddress,
57
+ commitment = "confirmed",
58
+ abortSignal,
59
+ }: {
60
+ address: Address,
61
+ programAddress: Address,
62
+ commitment?: Commitment,
63
+ abortSignal: AbortSignal,
64
+ },
65
+ ): Promise<AsyncIterable<DlmmEvent>> {
66
+ const notifications = await rpcSubscriptions
67
+ .logsNotifications({ mentions: [address] }, { commitment })
68
+ .subscribe({ abortSignal });
69
+
70
+ return (async function* () {
71
+ for await (const notification of notifications) {
72
+ if (notification.value.err != null) {
73
+ continue;
74
+ }
75
+ yield* decodeEventsFromLogs(notification.value.logs, programAddress);
76
+ }
77
+ })();
78
+ }
@@ -0,0 +1,66 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import {
3
+ PICON_DLMM_PROGRAM_ADDRESS,
4
+ fetchAdminConfig,
5
+ findBinArrayPda,
6
+ findPositionPda,
7
+ getOpenPositionInstructionAsync,
8
+ getCreateBinArrayInstructionAsync,
9
+ } from "../generated";
10
+ import { getPositionBinArrayIndices } from "../utils/bin_location";
11
+ import { isUndefined } from "../utils/type_guards";
12
+ import { buildTransactionMessage, resolveAdminConfigAddress, type TransactionMessageOptions, type Rpc } from "./helpers";
13
+
14
+ export async function openPosition(
15
+ rpc: Rpc,
16
+ {
17
+ owner,
18
+ positionMint,
19
+ pool,
20
+ lowerBinId,
21
+ upperBinId,
22
+ }: {
23
+ owner: TransactionSigner,
24
+ positionMint: TransactionSigner,
25
+ pool: Address,
26
+ lowerBinId: number,
27
+ upperBinId: number,
28
+ },
29
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
30
+ options: TransactionMessageOptions = {},
31
+ ) {
32
+ const [adminConfig, [position]] = await Promise.all([
33
+ resolveAdminConfigAddress(programAddress),
34
+ findPositionPda({ positionMint: positionMint.address }, { programAddress }),
35
+ ]);
36
+ const { metadataUpdateAuthority } = (await fetchAdminConfig(rpc, adminConfig, options)).data;
37
+
38
+ const { lowerBinArrayIndex, upperBinArrayIndex } = getPositionBinArrayIndices(lowerBinId, upperBinId);
39
+ const binArrayIndices = isUndefined(upperBinArrayIndex) ? [lowerBinArrayIndex] : [lowerBinArrayIndex, upperBinArrayIndex];
40
+
41
+ // Always idempotent, so no RPC existence check is needed first — the on-chain instruction
42
+ // is itself a harmless no-op when the bin array already exists (create_bin_array.rs).
43
+ const createBinArraysIxs = await Promise.all(
44
+ binArrayIndices.map(async index => {
45
+ const [binArray] = await findBinArrayPda({ pool, index }, { programAddress });
46
+ return getCreateBinArrayInstructionAsync(
47
+ { payer: owner, pool, index, idempotent: true, binArray },
48
+ { programAddress },
49
+ );
50
+ }),
51
+ );
52
+
53
+ const openPositionIx = await getOpenPositionInstructionAsync({
54
+ pool,
55
+ lowerBinId,
56
+ upperBinId,
57
+ owner,
58
+ positionMint,
59
+ position,
60
+ adminConfig,
61
+ metadataUpdateAuthority,
62
+ }, { programAddress });
63
+
64
+ const instructions = [...createBinArraysIxs, openPositionIx];
65
+ return await buildTransactionMessage(rpc, { feePayer: owner, instructions }, options);
66
+ }
@@ -0,0 +1,70 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, fetchAllMaybeBinArray } from "../generated";
3
+ import { quote as computeQuote, type QuoteOutput } from "../quote";
4
+ import { findSwapBinArrayAddresses } from "../utils/bin_array";
5
+ import { getPool } from "./get_pool";
6
+ import {
7
+ resolveMintInfo,
8
+ buildSwapTransactionMessage,
9
+ type TransactionMessageOptions,
10
+ type Rpc,
11
+ } from "./helpers";
12
+
13
+ export async function quote(
14
+ rpc: Rpc,
15
+ {
16
+ pool,
17
+ xToY,
18
+ amountIn,
19
+ slippageToleranceBps,
20
+ }: {
21
+ pool: Address,
22
+ amountIn: bigint,
23
+ xToY: boolean,
24
+ slippageToleranceBps: number,
25
+ },
26
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
27
+ options: TransactionMessageOptions = {},
28
+ ): Promise<{
29
+ quoteOutput: QuoteOutput,
30
+ swap: (user: TransactionSigner, options?: TransactionMessageOptions) => ReturnType<typeof buildSwapTransactionMessage>,
31
+ }> {
32
+ const poolData = await getPool(rpc, pool, options);
33
+ const { activeBinId, tokenMintX, tokenMintY } = poolData;
34
+ const binArrayAddresses = await findSwapBinArrayAddresses(pool, activeBinId, xToY, programAddress);
35
+ const [maybeBinArrays, { transferFeeX, transferFeeY, tokenProgramX, tokenProgramY }] = await Promise.all([
36
+ fetchAllMaybeBinArray(rpc, binArrayAddresses, options),
37
+ resolveMintInfo(rpc, tokenMintX, tokenMintY, options),
38
+ ]);
39
+ const binArrays = maybeBinArrays.map(maybeBinArray => maybeBinArray.exists ? maybeBinArray.data : undefined);
40
+
41
+ const quoteOutput = await computeQuote({
42
+ amountIn,
43
+ xToY,
44
+ slippageToleranceBps,
45
+ now: BigInt(Math.floor(Date.now() / 1000)),
46
+ poolState: poolData,
47
+ inputTransferFee: xToY ? transferFeeX : transferFeeY,
48
+ outputTransferFee: xToY ? transferFeeY : transferFeeX,
49
+ binArrays,
50
+ });
51
+
52
+ return {
53
+ quoteOutput,
54
+ // Reuses the exact accounts (activeBinId, mints, bin arrays) this quote was computed
55
+ // against, so the built swap tx can't drift from what the caller inspected the quote
56
+ // against — and never re-resolves anything `buildSwapTransactionMessage` doesn't ask for.
57
+ swap: (user, options = {}) => buildSwapTransactionMessage(rpc, {
58
+ user,
59
+ pool,
60
+ xToY,
61
+ amountIn,
62
+ minAmountOut: quoteOutput.minAmountOut,
63
+ tokenMintX,
64
+ tokenMintY,
65
+ tokenProgramX,
66
+ tokenProgramY,
67
+ binArrayAddresses,
68
+ }, programAddress, options),
69
+ };
70
+ }
@@ -0,0 +1,17 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, getSetMetadataUpdateAuthorityInstructionAsync } from "../generated";
3
+ import { buildTransactionMessage, resolveAdminConfigAddress, type TransactionMessageOptions, type Rpc } from "./helpers";
4
+
5
+ export async function setMetadataUpdateAuthority(
6
+ rpc: Rpc,
7
+ { authority, metadataUpdateAuthority }: { authority: TransactionSigner, metadataUpdateAuthority: Address },
8
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
9
+ options: TransactionMessageOptions = {},
10
+ ) {
11
+ const adminConfig = await resolveAdminConfigAddress(programAddress);
12
+ const instruction = await getSetMetadataUpdateAuthorityInstructionAsync(
13
+ { authority, metadataUpdateAuthority, adminConfig },
14
+ { programAddress },
15
+ );
16
+ return await buildTransactionMessage(rpc, { feePayer: authority, instructions: [instruction] }, options);
17
+ }
@@ -0,0 +1,17 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, type DynamicFeeConfig, getSetPoolDynamicFeeConfigInstructionAsync } from "../generated";
3
+ import { buildTransactionMessage, resolveAdminConfigAddress, type TransactionMessageOptions, type Rpc } from "./helpers";
4
+
5
+ export async function setPoolDynamicFeeConfig(
6
+ rpc: Rpc,
7
+ { authority, pool, config }: { authority: TransactionSigner, pool: Address, config: DynamicFeeConfig },
8
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
9
+ options: TransactionMessageOptions = {},
10
+ ) {
11
+ const adminConfig = await resolveAdminConfigAddress(programAddress);
12
+ const instruction = await getSetPoolDynamicFeeConfigInstructionAsync(
13
+ { authority, pool, config, adminConfig },
14
+ { programAddress },
15
+ );
16
+ return await buildTransactionMessage(rpc, { feePayer: authority, instructions: [instruction] }, options);
17
+ }
@@ -0,0 +1,17 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS, getSetPoolProtocolShareInstructionAsync } from "../generated";
3
+ import { buildTransactionMessage, resolveAdminConfigAddress, type TransactionMessageOptions, type Rpc } from "./helpers";
4
+
5
+ export async function setPoolProtocolShare(
6
+ rpc: Rpc,
7
+ { authority, pool, protocolShare }: { authority: TransactionSigner, pool: Address, protocolShare: number },
8
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
9
+ options: TransactionMessageOptions = {},
10
+ ) {
11
+ const adminConfig = await resolveAdminConfigAddress(programAddress);
12
+ const instruction = await getSetPoolProtocolShareInstructionAsync(
13
+ { authority, pool, protocolShare, adminConfig },
14
+ { programAddress },
15
+ );
16
+ return await buildTransactionMessage(rpc, { feePayer: authority, instructions: [instruction] }, options);
17
+ }
@@ -0,0 +1,56 @@
1
+ import type { Address, TransactionSigner } from "@solana/kit";
2
+ import { PICON_DLMM_PROGRAM_ADDRESS } from "../generated";
3
+ import { findSwapBinArrayAddresses } from "../utils/bin_array";
4
+ import {
5
+ resolveActiveBinAndMints,
6
+ resolveTokenMintsAndPrograms,
7
+ buildSwapTransactionMessage,
8
+ type TransactionMessageOptions,
9
+ type Rpc,
10
+ } from "./helpers";
11
+
12
+ export async function swap(
13
+ rpc: Rpc,
14
+ {
15
+ user,
16
+ pool,
17
+ activeBinId,
18
+ xToY,
19
+ amountIn,
20
+ minAmountOut,
21
+ tokenMintX,
22
+ tokenMintY,
23
+ tokenProgramX,
24
+ tokenProgramY,
25
+ }: {
26
+ user: TransactionSigner,
27
+ pool: Address,
28
+ activeBinId?: number,
29
+ xToY: boolean,
30
+ amountIn: bigint,
31
+ minAmountOut: bigint,
32
+ tokenMintX?: Address,
33
+ tokenMintY?: Address,
34
+ tokenProgramX?: Address,
35
+ tokenProgramY?: Address,
36
+ },
37
+ programAddress: Address = PICON_DLMM_PROGRAM_ADDRESS,
38
+ options: TransactionMessageOptions = {},
39
+ ) {
40
+ ({ activeBinId, tokenMintX, tokenMintY } = await resolveActiveBinAndMints(rpc, pool, { activeBinId, tokenMintX, tokenMintY }, options));
41
+
42
+ const [binArrayAddresses, tokenMintsAndPrograms] = await Promise.all([
43
+ findSwapBinArrayAddresses(pool, activeBinId, xToY, programAddress),
44
+ resolveTokenMintsAndPrograms(rpc, { pool, tokenMintX, tokenMintY, tokenProgramX, tokenProgramY }, options),
45
+ ]);
46
+
47
+ return await buildSwapTransactionMessage(rpc, {
48
+ user,
49
+ pool,
50
+ xToY,
51
+ amountIn,
52
+ minAmountOut,
53
+ binArrayAddresses,
54
+ ...tokenMintsAndPrograms,
55
+ }, programAddress, options);
56
+ }