@haven-fi/solauto-sdk 1.0.192 → 1.0.193

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 (331) hide show
  1. package/dist/clients/solautoClient.d.ts +1 -1
  2. package/dist/clients/solautoClient.d.ts.map +1 -1
  3. package/dist/clients/solautoMarginfiClient.d.ts +1 -1
  4. package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
  5. package/dist/clients/solautoMarginfiClient.js +1 -2
  6. package/dist/constants/solautoConstants.d.ts +0 -1
  7. package/dist/constants/solautoConstants.d.ts.map +1 -1
  8. package/dist/constants/solautoConstants.js +1 -2
  9. package/dist/generated/instructions/marginfiRebalance.d.ts +0 -2
  10. package/dist/generated/instructions/marginfiRebalance.d.ts.map +1 -1
  11. package/dist/generated/instructions/marginfiRebalance.js +0 -1
  12. package/dist/jupiter-sdk/accounts/index.d.ts +9 -0
  13. package/dist/jupiter-sdk/accounts/index.d.ts.map +1 -0
  14. package/dist/jupiter-sdk/accounts/index.js +24 -0
  15. package/dist/jupiter-sdk/accounts/tokenLedger.d.ts +32 -0
  16. package/dist/jupiter-sdk/accounts/tokenLedger.d.ts.map +1 -0
  17. package/dist/jupiter-sdk/accounts/tokenLedger.js +68 -0
  18. package/dist/jupiter-sdk/index.d.ts +4 -0
  19. package/dist/jupiter-sdk/index.d.ts.map +1 -1
  20. package/dist/jupiter-sdk/index.js +4 -0
  21. package/dist/jupiter-sdk/instructions/aldrinSwap.d.ts +29 -0
  22. package/dist/jupiter-sdk/instructions/aldrinSwap.d.ts.map +1 -0
  23. package/dist/jupiter-sdk/instructions/aldrinSwap.js +95 -0
  24. package/dist/jupiter-sdk/instructions/aldrinV2Swap.d.ts +30 -0
  25. package/dist/jupiter-sdk/instructions/aldrinV2Swap.d.ts.map +1 -0
  26. package/dist/jupiter-sdk/instructions/aldrinV2Swap.js +100 -0
  27. package/dist/jupiter-sdk/instructions/balansolSwap.d.ts +34 -0
  28. package/dist/jupiter-sdk/instructions/balansolSwap.d.ts.map +1 -0
  29. package/dist/jupiter-sdk/instructions/balansolSwap.js +130 -0
  30. package/dist/jupiter-sdk/instructions/claim.d.ts +25 -0
  31. package/dist/jupiter-sdk/instructions/claim.d.ts.map +1 -0
  32. package/dist/jupiter-sdk/instructions/claim.js +64 -0
  33. package/dist/jupiter-sdk/instructions/claimToken.d.ts +31 -0
  34. package/dist/jupiter-sdk/instructions/claimToken.d.ts.map +1 -0
  35. package/dist/jupiter-sdk/instructions/claimToken.js +93 -0
  36. package/dist/jupiter-sdk/instructions/cloneSwap.d.ts +34 -0
  37. package/dist/jupiter-sdk/instructions/cloneSwap.d.ts.map +1 -0
  38. package/dist/jupiter-sdk/instructions/cloneSwap.js +120 -0
  39. package/dist/jupiter-sdk/instructions/createOpenOrders.d.ts +24 -0
  40. package/dist/jupiter-sdk/instructions/createOpenOrders.d.ts.map +1 -0
  41. package/dist/jupiter-sdk/instructions/createOpenOrders.js +76 -0
  42. package/dist/jupiter-sdk/instructions/createProgramOpenOrders.d.ts +29 -0
  43. package/dist/jupiter-sdk/instructions/createProgramOpenOrders.d.ts.map +1 -0
  44. package/dist/jupiter-sdk/instructions/createProgramOpenOrders.js +86 -0
  45. package/dist/jupiter-sdk/instructions/createTokenAccount.d.ts +27 -0
  46. package/dist/jupiter-sdk/instructions/createTokenAccount.d.ts.map +1 -0
  47. package/dist/jupiter-sdk/instructions/createTokenAccount.js +70 -0
  48. package/dist/jupiter-sdk/instructions/createTokenLedger.d.ts +21 -0
  49. package/dist/jupiter-sdk/instructions/createTokenLedger.d.ts.map +1 -0
  50. package/dist/jupiter-sdk/instructions/createTokenLedger.js +62 -0
  51. package/dist/jupiter-sdk/instructions/cremaSwap.d.ts +33 -0
  52. package/dist/jupiter-sdk/instructions/cremaSwap.d.ts.map +1 -0
  53. package/dist/jupiter-sdk/instructions/cremaSwap.js +119 -0
  54. package/dist/jupiter-sdk/instructions/cropperSwap.d.ts +30 -0
  55. package/dist/jupiter-sdk/instructions/cropperSwap.d.ts.map +1 -0
  56. package/dist/jupiter-sdk/instructions/cropperSwap.js +103 -0
  57. package/dist/jupiter-sdk/instructions/cykuraSwap.d.ts +29 -0
  58. package/dist/jupiter-sdk/instructions/cykuraSwap.d.ts.map +1 -0
  59. package/dist/jupiter-sdk/instructions/cykuraSwap.js +99 -0
  60. package/dist/jupiter-sdk/instructions/deltafiSwap.d.ts +31 -0
  61. package/dist/jupiter-sdk/instructions/deltafiSwap.d.ts.map +1 -0
  62. package/dist/jupiter-sdk/instructions/deltafiSwap.js +109 -0
  63. package/dist/jupiter-sdk/instructions/dradexSwap.d.ts +35 -0
  64. package/dist/jupiter-sdk/instructions/dradexSwap.d.ts.map +1 -0
  65. package/dist/jupiter-sdk/instructions/dradexSwap.js +121 -0
  66. package/dist/jupiter-sdk/instructions/exactOutRoute.d.ts +42 -0
  67. package/dist/jupiter-sdk/instructions/exactOutRoute.d.ts.map +1 -0
  68. package/dist/jupiter-sdk/instructions/exactOutRoute.js +109 -0
  69. package/dist/jupiter-sdk/instructions/goosefxSwap.d.ts +33 -0
  70. package/dist/jupiter-sdk/instructions/goosefxSwap.d.ts.map +1 -0
  71. package/dist/jupiter-sdk/instructions/goosefxSwap.js +115 -0
  72. package/dist/jupiter-sdk/instructions/goosefxV2Swap.d.ts +38 -0
  73. package/dist/jupiter-sdk/instructions/goosefxV2Swap.d.ts.map +1 -0
  74. package/dist/jupiter-sdk/instructions/goosefxV2Swap.js +140 -0
  75. package/dist/jupiter-sdk/instructions/heliumTreasuryManagementRedeemV0.d.ts +29 -0
  76. package/dist/jupiter-sdk/instructions/heliumTreasuryManagementRedeemV0.d.ts.map +1 -0
  77. package/dist/jupiter-sdk/instructions/heliumTreasuryManagementRedeemV0.js +91 -0
  78. package/dist/jupiter-sdk/instructions/index.d.ts +72 -0
  79. package/dist/jupiter-sdk/instructions/index.d.ts.map +1 -0
  80. package/dist/jupiter-sdk/instructions/index.js +87 -0
  81. package/dist/jupiter-sdk/instructions/invariantSwap.d.ts +29 -0
  82. package/dist/jupiter-sdk/instructions/invariantSwap.d.ts.map +1 -0
  83. package/dist/jupiter-sdk/instructions/invariantSwap.js +95 -0
  84. package/dist/jupiter-sdk/instructions/lifinitySwap.d.ts +32 -0
  85. package/dist/jupiter-sdk/instructions/lifinitySwap.d.ts.map +1 -0
  86. package/dist/jupiter-sdk/instructions/lifinitySwap.js +113 -0
  87. package/dist/jupiter-sdk/instructions/lifinityV2Swap.d.ts +32 -0
  88. package/dist/jupiter-sdk/instructions/lifinityV2Swap.d.ts.map +1 -0
  89. package/dist/jupiter-sdk/instructions/lifinityV2Swap.js +113 -0
  90. package/dist/jupiter-sdk/instructions/marcoPoloSwap.d.ts +36 -0
  91. package/dist/jupiter-sdk/instructions/marcoPoloSwap.d.ts.map +1 -0
  92. package/dist/jupiter-sdk/instructions/marcoPoloSwap.js +137 -0
  93. package/dist/jupiter-sdk/instructions/marinadeDeposit.d.ts +36 -0
  94. package/dist/jupiter-sdk/instructions/marinadeDeposit.d.ts.map +1 -0
  95. package/dist/jupiter-sdk/instructions/marinadeDeposit.js +144 -0
  96. package/dist/jupiter-sdk/instructions/marinadeUnstake.d.ts +30 -0
  97. package/dist/jupiter-sdk/instructions/marinadeUnstake.d.ts.map +1 -0
  98. package/dist/jupiter-sdk/instructions/marinadeUnstake.js +105 -0
  99. package/dist/jupiter-sdk/instructions/mercurialSwap.d.ts +25 -0
  100. package/dist/jupiter-sdk/instructions/mercurialSwap.d.ts.map +1 -0
  101. package/dist/jupiter-sdk/instructions/mercurialSwap.js +76 -0
  102. package/dist/jupiter-sdk/instructions/meteoraDlmmSwap.d.ts +34 -0
  103. package/dist/jupiter-sdk/instructions/meteoraDlmmSwap.d.ts.map +1 -0
  104. package/dist/jupiter-sdk/instructions/meteoraDlmmSwap.js +119 -0
  105. package/dist/jupiter-sdk/instructions/meteoraSwap.d.ts +34 -0
  106. package/dist/jupiter-sdk/instructions/meteoraSwap.d.ts.map +1 -0
  107. package/dist/jupiter-sdk/instructions/meteoraSwap.js +120 -0
  108. package/dist/jupiter-sdk/instructions/moonshotWrappedBuy.d.ts +33 -0
  109. package/dist/jupiter-sdk/instructions/moonshotWrappedBuy.d.ts.map +1 -0
  110. package/dist/jupiter-sdk/instructions/moonshotWrappedBuy.js +119 -0
  111. package/dist/jupiter-sdk/instructions/moonshotWrappedSell.d.ts +31 -0
  112. package/dist/jupiter-sdk/instructions/moonshotWrappedSell.d.ts.map +1 -0
  113. package/dist/jupiter-sdk/instructions/moonshotWrappedSell.js +106 -0
  114. package/dist/jupiter-sdk/instructions/obricSwap.d.ts +31 -0
  115. package/dist/jupiter-sdk/instructions/obricSwap.d.ts.map +1 -0
  116. package/dist/jupiter-sdk/instructions/obricSwap.js +106 -0
  117. package/dist/jupiter-sdk/instructions/oneIntroSwap.d.ts +30 -0
  118. package/dist/jupiter-sdk/instructions/oneIntroSwap.d.ts.map +1 -0
  119. package/dist/jupiter-sdk/instructions/oneIntroSwap.js +100 -0
  120. package/dist/jupiter-sdk/instructions/openBookV2Swap.d.ts +35 -0
  121. package/dist/jupiter-sdk/instructions/openBookV2Swap.d.ts.map +1 -0
  122. package/dist/jupiter-sdk/instructions/openBookV2Swap.js +125 -0
  123. package/dist/jupiter-sdk/instructions/perpsAddLiquidity.d.ts +32 -0
  124. package/dist/jupiter-sdk/instructions/perpsAddLiquidity.d.ts.map +1 -0
  125. package/dist/jupiter-sdk/instructions/perpsAddLiquidity.js +110 -0
  126. package/dist/jupiter-sdk/instructions/perpsRemoveLiquidity.d.ts +32 -0
  127. package/dist/jupiter-sdk/instructions/perpsRemoveLiquidity.d.ts.map +1 -0
  128. package/dist/jupiter-sdk/instructions/perpsRemoveLiquidity.js +110 -0
  129. package/dist/jupiter-sdk/instructions/perpsSwap.d.ts +34 -0
  130. package/dist/jupiter-sdk/instructions/perpsSwap.d.ts.map +1 -0
  131. package/dist/jupiter-sdk/instructions/perpsSwap.js +120 -0
  132. package/dist/jupiter-sdk/instructions/perpsV2AddLiquidity.d.ts +33 -0
  133. package/dist/jupiter-sdk/instructions/perpsV2AddLiquidity.d.ts.map +1 -0
  134. package/dist/jupiter-sdk/instructions/perpsV2AddLiquidity.js +115 -0
  135. package/dist/jupiter-sdk/instructions/perpsV2RemoveLiquidity.d.ts +33 -0
  136. package/dist/jupiter-sdk/instructions/perpsV2RemoveLiquidity.d.ts.map +1 -0
  137. package/dist/jupiter-sdk/instructions/perpsV2RemoveLiquidity.js +112 -0
  138. package/dist/jupiter-sdk/instructions/perpsV2Swap.d.ts +36 -0
  139. package/dist/jupiter-sdk/instructions/perpsV2Swap.d.ts.map +1 -0
  140. package/dist/jupiter-sdk/instructions/perpsV2Swap.js +130 -0
  141. package/dist/jupiter-sdk/instructions/phoenixSwap.d.ts +27 -0
  142. package/dist/jupiter-sdk/instructions/phoenixSwap.d.ts.map +1 -0
  143. package/dist/jupiter-sdk/instructions/phoenixSwap.js +89 -0
  144. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedBuy.d.ts +34 -0
  145. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedBuy.d.ts.map +1 -0
  146. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedBuy.js +123 -0
  147. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedSell.d.ts +32 -0
  148. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedSell.d.ts.map +1 -0
  149. package/dist/jupiter-sdk/instructions/pumpdotfunWrappedSell.js +107 -0
  150. package/dist/jupiter-sdk/instructions/raydiumClmmSwap.d.ts +29 -0
  151. package/dist/jupiter-sdk/instructions/raydiumClmmSwap.d.ts.map +1 -0
  152. package/dist/jupiter-sdk/instructions/raydiumClmmSwap.js +102 -0
  153. package/dist/jupiter-sdk/instructions/raydiumClmmSwapV2.d.ts +32 -0
  154. package/dist/jupiter-sdk/instructions/raydiumClmmSwapV2.d.ts.map +1 -0
  155. package/dist/jupiter-sdk/instructions/raydiumClmmSwapV2.js +117 -0
  156. package/dist/jupiter-sdk/instructions/raydiumCpSwap.d.ts +32 -0
  157. package/dist/jupiter-sdk/instructions/raydiumCpSwap.d.ts.map +1 -0
  158. package/dist/jupiter-sdk/instructions/raydiumCpSwap.js +116 -0
  159. package/dist/jupiter-sdk/instructions/raydiumSwap.d.ts +36 -0
  160. package/dist/jupiter-sdk/instructions/raydiumSwap.d.ts.map +1 -0
  161. package/dist/jupiter-sdk/instructions/raydiumSwap.js +134 -0
  162. package/dist/jupiter-sdk/instructions/route.d.ts +40 -0
  163. package/dist/jupiter-sdk/instructions/route.d.ts.map +1 -0
  164. package/dist/jupiter-sdk/instructions/route.js +99 -0
  165. package/dist/jupiter-sdk/instructions/routeWithTokenLedger.d.ts +39 -0
  166. package/dist/jupiter-sdk/instructions/routeWithTokenLedger.d.ts.map +1 -0
  167. package/dist/jupiter-sdk/instructions/routeWithTokenLedger.js +103 -0
  168. package/dist/jupiter-sdk/instructions/saberAddDecimals.d.ts +26 -0
  169. package/dist/jupiter-sdk/instructions/saberAddDecimals.d.ts.map +1 -0
  170. package/dist/jupiter-sdk/instructions/saberAddDecimals.js +81 -0
  171. package/dist/jupiter-sdk/instructions/saberSwap.d.ts +28 -0
  172. package/dist/jupiter-sdk/instructions/saberSwap.d.ts.map +1 -0
  173. package/dist/jupiter-sdk/instructions/saberSwap.js +87 -0
  174. package/dist/jupiter-sdk/instructions/senchaSwap.d.ts +28 -0
  175. package/dist/jupiter-sdk/instructions/senchaSwap.d.ts.map +1 -0
  176. package/dist/jupiter-sdk/instructions/senchaSwap.js +90 -0
  177. package/dist/jupiter-sdk/instructions/serumSwap.d.ts +34 -0
  178. package/dist/jupiter-sdk/instructions/serumSwap.d.ts.map +1 -0
  179. package/dist/jupiter-sdk/instructions/serumSwap.js +122 -0
  180. package/dist/jupiter-sdk/instructions/setTokenLedger.d.ts +20 -0
  181. package/dist/jupiter-sdk/instructions/setTokenLedger.d.ts.map +1 -0
  182. package/dist/jupiter-sdk/instructions/setTokenLedger.js +46 -0
  183. package/dist/jupiter-sdk/instructions/sharedAccountsExactOutRoute.d.ts +46 -0
  184. package/dist/jupiter-sdk/instructions/sharedAccountsExactOutRoute.d.ts.map +1 -0
  185. package/dist/jupiter-sdk/instructions/sharedAccountsExactOutRoute.js +120 -0
  186. package/dist/jupiter-sdk/instructions/sharedAccountsRoute.d.ts +46 -0
  187. package/dist/jupiter-sdk/instructions/sharedAccountsRoute.d.ts.map +1 -0
  188. package/dist/jupiter-sdk/instructions/sharedAccountsRoute.js +120 -0
  189. package/dist/jupiter-sdk/instructions/sharedAccountsRouteWithTokenLedger.d.ts +45 -0
  190. package/dist/jupiter-sdk/instructions/sharedAccountsRouteWithTokenLedger.d.ts.map +1 -0
  191. package/dist/jupiter-sdk/instructions/sharedAccountsRouteWithTokenLedger.js +126 -0
  192. package/dist/jupiter-sdk/instructions/stabbleStableSwap.d.ts +31 -0
  193. package/dist/jupiter-sdk/instructions/stabbleStableSwap.d.ts.map +1 -0
  194. package/dist/jupiter-sdk/instructions/stabbleStableSwap.js +101 -0
  195. package/dist/jupiter-sdk/instructions/stabbleWeightedSwap.d.ts +31 -0
  196. package/dist/jupiter-sdk/instructions/stabbleWeightedSwap.d.ts.map +1 -0
  197. package/dist/jupiter-sdk/instructions/stabbleWeightedSwap.js +101 -0
  198. package/dist/jupiter-sdk/instructions/stepSwap.d.ts +29 -0
  199. package/dist/jupiter-sdk/instructions/stepSwap.d.ts.map +1 -0
  200. package/dist/jupiter-sdk/instructions/stepSwap.js +98 -0
  201. package/dist/jupiter-sdk/instructions/symmetrySwap.d.ts +32 -0
  202. package/dist/jupiter-sdk/instructions/symmetrySwap.d.ts.map +1 -0
  203. package/dist/jupiter-sdk/instructions/symmetrySwap.js +114 -0
  204. package/dist/jupiter-sdk/instructions/tokenSwap.d.ts +29 -0
  205. package/dist/jupiter-sdk/instructions/tokenSwap.d.ts.map +1 -0
  206. package/dist/jupiter-sdk/instructions/tokenSwap.js +98 -0
  207. package/dist/jupiter-sdk/instructions/tokenSwapV2.d.ts +33 -0
  208. package/dist/jupiter-sdk/instructions/tokenSwapV2.d.ts.map +1 -0
  209. package/dist/jupiter-sdk/instructions/tokenSwapV2.js +114 -0
  210. package/dist/jupiter-sdk/instructions/whirlpoolSwap.d.ts +31 -0
  211. package/dist/jupiter-sdk/instructions/whirlpoolSwap.d.ts.map +1 -0
  212. package/dist/jupiter-sdk/instructions/whirlpoolSwap.js +104 -0
  213. package/dist/jupiter-sdk/instructions/whirlpoolSwapV2.d.ts +35 -0
  214. package/dist/jupiter-sdk/instructions/whirlpoolSwapV2.d.ts.map +1 -0
  215. package/dist/jupiter-sdk/instructions/whirlpoolSwapV2.js +119 -0
  216. package/dist/jupiter-sdk/shared/index.d.ts +54 -0
  217. package/dist/jupiter-sdk/shared/index.d.ts.map +1 -0
  218. package/dist/jupiter-sdk/shared/index.js +69 -0
  219. package/dist/jupiter-sdk/types/accountsType.d.ts +15 -0
  220. package/dist/jupiter-sdk/types/accountsType.d.ts.map +1 -0
  221. package/dist/jupiter-sdk/types/accountsType.js +22 -0
  222. package/dist/jupiter-sdk/types/amountWithSlippage.d.ts +18 -0
  223. package/dist/jupiter-sdk/types/amountWithSlippage.d.ts.map +1 -0
  224. package/dist/jupiter-sdk/types/amountWithSlippage.js +17 -0
  225. package/dist/jupiter-sdk/types/index.d.ts +15 -0
  226. package/dist/jupiter-sdk/types/index.d.ts.map +1 -0
  227. package/dist/jupiter-sdk/types/index.js +30 -0
  228. package/dist/jupiter-sdk/types/remainingAccountsInfo.d.ts +17 -0
  229. package/dist/jupiter-sdk/types/remainingAccountsInfo.d.ts.map +1 -0
  230. package/dist/jupiter-sdk/types/remainingAccountsInfo.js +15 -0
  231. package/dist/jupiter-sdk/types/remainingAccountsSlice.d.ts +19 -0
  232. package/dist/jupiter-sdk/types/remainingAccountsSlice.d.ts.map +1 -0
  233. package/dist/jupiter-sdk/types/remainingAccountsSlice.js +18 -0
  234. package/dist/jupiter-sdk/types/routePlanStep.d.ts +23 -0
  235. package/dist/jupiter-sdk/types/routePlanStep.d.ts.map +1 -0
  236. package/dist/jupiter-sdk/types/routePlanStep.js +20 -0
  237. package/dist/jupiter-sdk/types/side.d.ts +15 -0
  238. package/dist/jupiter-sdk/types/side.d.ts.map +1 -0
  239. package/dist/jupiter-sdk/types/side.js +20 -0
  240. package/dist/jupiter-sdk/types/swap.d.ts +372 -0
  241. package/dist/jupiter-sdk/types/swap.d.ts.map +1 -0
  242. package/dist/jupiter-sdk/types/swap.js +188 -0
  243. package/dist/transactions/transactionUtils.d.ts.map +1 -1
  244. package/dist/transactions/transactionUtils.js +0 -1
  245. package/dist/utils/solauto/rebalanceUtils.d.ts +1 -1
  246. package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
  247. package/dist/utils/solauto/rebalanceUtils.js +2 -16
  248. package/package.json +1 -1
  249. package/src/clients/solautoClient.ts +0 -1
  250. package/src/clients/solautoMarginfiClient.ts +0 -2
  251. package/src/constants/solautoConstants.ts +0 -1
  252. package/src/generated/instructions/marginfiRebalance.ts +0 -3
  253. package/src/jupiter-sdk/accounts/index.ts +9 -0
  254. package/src/jupiter-sdk/accounts/tokenLedger.ts +146 -0
  255. package/src/jupiter-sdk/index.ts +4 -0
  256. package/src/jupiter-sdk/instructions/aldrinSwap.ts +165 -0
  257. package/src/jupiter-sdk/instructions/aldrinV2Swap.ts +171 -0
  258. package/src/jupiter-sdk/instructions/balansolSwap.ts +211 -0
  259. package/src/jupiter-sdk/instructions/claim.ts +128 -0
  260. package/src/jupiter-sdk/instructions/claimToken.ts +171 -0
  261. package/src/jupiter-sdk/instructions/cloneSwap.ts +195 -0
  262. package/src/jupiter-sdk/instructions/createOpenOrders.ts +148 -0
  263. package/src/jupiter-sdk/instructions/createProgramOpenOrders.ts +170 -0
  264. package/src/jupiter-sdk/instructions/createTokenAccount.ts +152 -0
  265. package/src/jupiter-sdk/instructions/createTokenLedger.ts +128 -0
  266. package/src/jupiter-sdk/instructions/cremaSwap.ts +193 -0
  267. package/src/jupiter-sdk/instructions/cropperSwap.ts +174 -0
  268. package/src/jupiter-sdk/instructions/cykuraSwap.ts +169 -0
  269. package/src/jupiter-sdk/instructions/deltafiSwap.ts +181 -0
  270. package/src/jupiter-sdk/instructions/dradexSwap.ts +200 -0
  271. package/src/jupiter-sdk/instructions/exactOutRoute.ts +208 -0
  272. package/src/jupiter-sdk/instructions/goosefxSwap.ts +189 -0
  273. package/src/jupiter-sdk/instructions/goosefxV2Swap.ts +222 -0
  274. package/src/jupiter-sdk/instructions/heliumTreasuryManagementRedeemV0.ts +169 -0
  275. package/src/jupiter-sdk/instructions/index.ts +72 -0
  276. package/src/jupiter-sdk/instructions/invariantSwap.ts +168 -0
  277. package/src/jupiter-sdk/instructions/lifinitySwap.ts +186 -0
  278. package/src/jupiter-sdk/instructions/lifinityV2Swap.ts +189 -0
  279. package/src/jupiter-sdk/instructions/marcoPoloSwap.ts +223 -0
  280. package/src/jupiter-sdk/instructions/marinadeDeposit.ts +230 -0
  281. package/src/jupiter-sdk/instructions/marinadeUnstake.ts +182 -0
  282. package/src/jupiter-sdk/instructions/mercurialSwap.ts +145 -0
  283. package/src/jupiter-sdk/instructions/meteoraDlmmSwap.ts +193 -0
  284. package/src/jupiter-sdk/instructions/meteoraSwap.ts +195 -0
  285. package/src/jupiter-sdk/instructions/moonshotWrappedBuy.ts +201 -0
  286. package/src/jupiter-sdk/instructions/moonshotWrappedSell.ts +186 -0
  287. package/src/jupiter-sdk/instructions/obricSwap.ts +178 -0
  288. package/src/jupiter-sdk/instructions/oneIntroSwap.ts +171 -0
  289. package/src/jupiter-sdk/instructions/openBookV2Swap.ts +207 -0
  290. package/src/jupiter-sdk/instructions/perpsAddLiquidity.ts +186 -0
  291. package/src/jupiter-sdk/instructions/perpsRemoveLiquidity.ts +188 -0
  292. package/src/jupiter-sdk/instructions/perpsSwap.ts +195 -0
  293. package/src/jupiter-sdk/instructions/perpsV2AddLiquidity.ts +194 -0
  294. package/src/jupiter-sdk/instructions/perpsV2RemoveLiquidity.ts +193 -0
  295. package/src/jupiter-sdk/instructions/perpsV2Swap.ts +207 -0
  296. package/src/jupiter-sdk/instructions/phoenixSwap.ts +157 -0
  297. package/src/jupiter-sdk/instructions/pumpdotfunWrappedBuy.ts +209 -0
  298. package/src/jupiter-sdk/instructions/pumpdotfunWrappedSell.ts +190 -0
  299. package/src/jupiter-sdk/instructions/raydiumClmmSwap.ts +175 -0
  300. package/src/jupiter-sdk/instructions/raydiumClmmSwapV2.ts +193 -0
  301. package/src/jupiter-sdk/instructions/raydiumCpSwap.ts +189 -0
  302. package/src/jupiter-sdk/instructions/raydiumSwap.ts +211 -0
  303. package/src/jupiter-sdk/instructions/route.ts +189 -0
  304. package/src/jupiter-sdk/instructions/routeWithTokenLedger.ts +201 -0
  305. package/src/jupiter-sdk/instructions/saberAddDecimals.ts +151 -0
  306. package/src/jupiter-sdk/instructions/saberSwap.ts +156 -0
  307. package/src/jupiter-sdk/instructions/senchaSwap.ts +159 -0
  308. package/src/jupiter-sdk/instructions/serumSwap.ts +200 -0
  309. package/src/jupiter-sdk/instructions/setTokenLedger.ts +106 -0
  310. package/src/jupiter-sdk/instructions/sharedAccountsExactOutRoute.ts +226 -0
  311. package/src/jupiter-sdk/instructions/sharedAccountsRoute.ts +225 -0
  312. package/src/jupiter-sdk/instructions/sharedAccountsRouteWithTokenLedger.ts +231 -0
  313. package/src/jupiter-sdk/instructions/stabbleStableSwap.ts +176 -0
  314. package/src/jupiter-sdk/instructions/stabbleWeightedSwap.ts +178 -0
  315. package/src/jupiter-sdk/instructions/stepSwap.ts +168 -0
  316. package/src/jupiter-sdk/instructions/symmetrySwap.ts +187 -0
  317. package/src/jupiter-sdk/instructions/tokenSwap.ts +168 -0
  318. package/src/jupiter-sdk/instructions/tokenSwapV2.ts +185 -0
  319. package/src/jupiter-sdk/instructions/whirlpoolSwap.ts +179 -0
  320. package/src/jupiter-sdk/instructions/whirlpoolSwapV2.ts +194 -0
  321. package/src/jupiter-sdk/shared/index.ts +117 -0
  322. package/src/jupiter-sdk/types/accountsType.ts +25 -0
  323. package/src/jupiter-sdk/types/amountWithSlippage.ts +34 -0
  324. package/src/jupiter-sdk/types/index.ts +15 -0
  325. package/src/jupiter-sdk/types/remainingAccountsInfo.ts +34 -0
  326. package/src/jupiter-sdk/types/remainingAccountsSlice.ts +33 -0
  327. package/src/jupiter-sdk/types/routePlanStep.ts +39 -0
  328. package/src/jupiter-sdk/types/side.ts +23 -0
  329. package/src/jupiter-sdk/types/swap.ts +566 -0
  330. package/src/transactions/transactionUtils.ts +0 -1
  331. package/src/utils/solauto/rebalanceUtils.ts +3 -24
@@ -0,0 +1,195 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import {
10
+ Context,
11
+ Pda,
12
+ PublicKey,
13
+ TransactionBuilder,
14
+ transactionBuilder,
15
+ } from '@metaplex-foundation/umi';
16
+ import {
17
+ Serializer,
18
+ array,
19
+ mapSerializer,
20
+ struct,
21
+ u8,
22
+ } from '@metaplex-foundation/umi/serializers';
23
+ import {
24
+ ResolvedAccount,
25
+ ResolvedAccountsWithIndices,
26
+ getAccountMetasAndSigners,
27
+ } from '../shared';
28
+
29
+ // Accounts.
30
+ export type CloneSwapInstructionAccounts = {
31
+ swapProgram: PublicKey | Pda;
32
+ user: PublicKey | Pda;
33
+ clone: PublicKey | Pda;
34
+ pools: PublicKey | Pda;
35
+ oracles: PublicKey | Pda;
36
+ userCollateralTokenAccount: PublicKey | Pda;
37
+ userOnassetTokenAccount: PublicKey | Pda;
38
+ onassetMint: PublicKey | Pda;
39
+ collateralMint: PublicKey | Pda;
40
+ collateralVault: PublicKey | Pda;
41
+ treasuryOnassetTokenAccount: PublicKey | Pda;
42
+ treasuryCollateralTokenAccount: PublicKey | Pda;
43
+ tokenProgram?: PublicKey | Pda;
44
+ cloneStaking: PublicKey | Pda;
45
+ userStakingAccount: PublicKey | Pda;
46
+ cloneStakingProgram: PublicKey | Pda;
47
+ };
48
+
49
+ // Data.
50
+ export type CloneSwapInstructionData = { discriminator: Array<number> };
51
+
52
+ export type CloneSwapInstructionDataArgs = {};
53
+
54
+ export function getCloneSwapInstructionDataSerializer(): Serializer<
55
+ CloneSwapInstructionDataArgs,
56
+ CloneSwapInstructionData
57
+ > {
58
+ return mapSerializer<
59
+ CloneSwapInstructionDataArgs,
60
+ any,
61
+ CloneSwapInstructionData
62
+ >(
63
+ struct<CloneSwapInstructionData>(
64
+ [['discriminator', array(u8(), { size: 8 })]],
65
+ { description: 'CloneSwapInstructionData' }
66
+ ),
67
+ (value) => ({
68
+ ...value,
69
+ discriminator: [85, 201, 154, 92, 133, 31, 142, 85],
70
+ })
71
+ ) as Serializer<CloneSwapInstructionDataArgs, CloneSwapInstructionData>;
72
+ }
73
+
74
+ // Instruction.
75
+ export function cloneSwap(
76
+ context: Pick<Context, 'programs'>,
77
+ input: CloneSwapInstructionAccounts
78
+ ): TransactionBuilder {
79
+ // Program ID.
80
+ const programId = context.programs.getPublicKey(
81
+ 'jupiter',
82
+ 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
83
+ );
84
+
85
+ // Accounts.
86
+ const resolvedAccounts = {
87
+ swapProgram: {
88
+ index: 0,
89
+ isWritable: false as boolean,
90
+ value: input.swapProgram ?? null,
91
+ },
92
+ user: { index: 1, isWritable: false as boolean, value: input.user ?? null },
93
+ clone: {
94
+ index: 2,
95
+ isWritable: true as boolean,
96
+ value: input.clone ?? null,
97
+ },
98
+ pools: {
99
+ index: 3,
100
+ isWritable: true as boolean,
101
+ value: input.pools ?? null,
102
+ },
103
+ oracles: {
104
+ index: 4,
105
+ isWritable: true as boolean,
106
+ value: input.oracles ?? null,
107
+ },
108
+ userCollateralTokenAccount: {
109
+ index: 5,
110
+ isWritable: true as boolean,
111
+ value: input.userCollateralTokenAccount ?? null,
112
+ },
113
+ userOnassetTokenAccount: {
114
+ index: 6,
115
+ isWritable: true as boolean,
116
+ value: input.userOnassetTokenAccount ?? null,
117
+ },
118
+ onassetMint: {
119
+ index: 7,
120
+ isWritable: true as boolean,
121
+ value: input.onassetMint ?? null,
122
+ },
123
+ collateralMint: {
124
+ index: 8,
125
+ isWritable: false as boolean,
126
+ value: input.collateralMint ?? null,
127
+ },
128
+ collateralVault: {
129
+ index: 9,
130
+ isWritable: true as boolean,
131
+ value: input.collateralVault ?? null,
132
+ },
133
+ treasuryOnassetTokenAccount: {
134
+ index: 10,
135
+ isWritable: true as boolean,
136
+ value: input.treasuryOnassetTokenAccount ?? null,
137
+ },
138
+ treasuryCollateralTokenAccount: {
139
+ index: 11,
140
+ isWritable: true as boolean,
141
+ value: input.treasuryCollateralTokenAccount ?? null,
142
+ },
143
+ tokenProgram: {
144
+ index: 12,
145
+ isWritable: false as boolean,
146
+ value: input.tokenProgram ?? null,
147
+ },
148
+ cloneStaking: {
149
+ index: 13,
150
+ isWritable: false as boolean,
151
+ value: input.cloneStaking ?? null,
152
+ },
153
+ userStakingAccount: {
154
+ index: 14,
155
+ isWritable: false as boolean,
156
+ value: input.userStakingAccount ?? null,
157
+ },
158
+ cloneStakingProgram: {
159
+ index: 15,
160
+ isWritable: false as boolean,
161
+ value: input.cloneStakingProgram ?? null,
162
+ },
163
+ } satisfies ResolvedAccountsWithIndices;
164
+
165
+ // Default values.
166
+ if (!resolvedAccounts.tokenProgram.value) {
167
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
168
+ 'splToken',
169
+ 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
170
+ );
171
+ resolvedAccounts.tokenProgram.isWritable = false;
172
+ }
173
+
174
+ // Accounts in order.
175
+ const orderedAccounts: ResolvedAccount[] = Object.values(
176
+ resolvedAccounts
177
+ ).sort((a, b) => a.index - b.index);
178
+
179
+ // Keys and Signers.
180
+ const [keys, signers] = getAccountMetasAndSigners(
181
+ orderedAccounts,
182
+ 'programId',
183
+ programId
184
+ );
185
+
186
+ // Data.
187
+ const data = getCloneSwapInstructionDataSerializer().serialize({});
188
+
189
+ // Bytes Created On Chain.
190
+ const bytesCreatedOnChain = 0;
191
+
192
+ return transactionBuilder([
193
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
194
+ ]);
195
+ }
@@ -0,0 +1,148 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import {
10
+ Context,
11
+ Pda,
12
+ PublicKey,
13
+ Signer,
14
+ TransactionBuilder,
15
+ publicKey,
16
+ transactionBuilder,
17
+ } from '@metaplex-foundation/umi';
18
+ import {
19
+ Serializer,
20
+ array,
21
+ mapSerializer,
22
+ struct,
23
+ u8,
24
+ } from '@metaplex-foundation/umi/serializers';
25
+ import {
26
+ ResolvedAccount,
27
+ ResolvedAccountsWithIndices,
28
+ getAccountMetasAndSigners,
29
+ } from '../shared';
30
+
31
+ // Accounts.
32
+ export type CreateOpenOrdersInstructionAccounts = {
33
+ openOrders: PublicKey | Pda;
34
+ payer?: Signer;
35
+ dexProgram: PublicKey | Pda;
36
+ systemProgram?: PublicKey | Pda;
37
+ rent?: PublicKey | Pda;
38
+ market: PublicKey | Pda;
39
+ };
40
+
41
+ // Data.
42
+ export type CreateOpenOrdersInstructionData = { discriminator: Array<number> };
43
+
44
+ export type CreateOpenOrdersInstructionDataArgs = {};
45
+
46
+ export function getCreateOpenOrdersInstructionDataSerializer(): Serializer<
47
+ CreateOpenOrdersInstructionDataArgs,
48
+ CreateOpenOrdersInstructionData
49
+ > {
50
+ return mapSerializer<
51
+ CreateOpenOrdersInstructionDataArgs,
52
+ any,
53
+ CreateOpenOrdersInstructionData
54
+ >(
55
+ struct<CreateOpenOrdersInstructionData>(
56
+ [['discriminator', array(u8(), { size: 8 })]],
57
+ { description: 'CreateOpenOrdersInstructionData' }
58
+ ),
59
+ (value) => ({
60
+ ...value,
61
+ discriminator: [229, 194, 212, 172, 8, 10, 134, 147],
62
+ })
63
+ ) as Serializer<
64
+ CreateOpenOrdersInstructionDataArgs,
65
+ CreateOpenOrdersInstructionData
66
+ >;
67
+ }
68
+
69
+ // Instruction.
70
+ export function createOpenOrders(
71
+ context: Pick<Context, 'payer' | 'programs'>,
72
+ input: CreateOpenOrdersInstructionAccounts
73
+ ): TransactionBuilder {
74
+ // Program ID.
75
+ const programId = context.programs.getPublicKey(
76
+ 'jupiter',
77
+ 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
78
+ );
79
+
80
+ // Accounts.
81
+ const resolvedAccounts = {
82
+ openOrders: {
83
+ index: 0,
84
+ isWritable: true as boolean,
85
+ value: input.openOrders ?? null,
86
+ },
87
+ payer: {
88
+ index: 1,
89
+ isWritable: true as boolean,
90
+ value: input.payer ?? null,
91
+ },
92
+ dexProgram: {
93
+ index: 2,
94
+ isWritable: false as boolean,
95
+ value: input.dexProgram ?? null,
96
+ },
97
+ systemProgram: {
98
+ index: 3,
99
+ isWritable: false as boolean,
100
+ value: input.systemProgram ?? null,
101
+ },
102
+ rent: { index: 4, isWritable: false as boolean, value: input.rent ?? null },
103
+ market: {
104
+ index: 5,
105
+ isWritable: false as boolean,
106
+ value: input.market ?? null,
107
+ },
108
+ } satisfies ResolvedAccountsWithIndices;
109
+
110
+ // Default values.
111
+ if (!resolvedAccounts.payer.value) {
112
+ resolvedAccounts.payer.value = context.payer;
113
+ }
114
+ if (!resolvedAccounts.systemProgram.value) {
115
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
116
+ 'splSystem',
117
+ '11111111111111111111111111111111'
118
+ );
119
+ resolvedAccounts.systemProgram.isWritable = false;
120
+ }
121
+ if (!resolvedAccounts.rent.value) {
122
+ resolvedAccounts.rent.value = publicKey(
123
+ 'SysvarRent111111111111111111111111111111111'
124
+ );
125
+ }
126
+
127
+ // Accounts in order.
128
+ const orderedAccounts: ResolvedAccount[] = Object.values(
129
+ resolvedAccounts
130
+ ).sort((a, b) => a.index - b.index);
131
+
132
+ // Keys and Signers.
133
+ const [keys, signers] = getAccountMetasAndSigners(
134
+ orderedAccounts,
135
+ 'programId',
136
+ programId
137
+ );
138
+
139
+ // Data.
140
+ const data = getCreateOpenOrdersInstructionDataSerializer().serialize({});
141
+
142
+ // Bytes Created On Chain.
143
+ const bytesCreatedOnChain = 0;
144
+
145
+ return transactionBuilder([
146
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
147
+ ]);
148
+ }
@@ -0,0 +1,170 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import {
10
+ Context,
11
+ Pda,
12
+ PublicKey,
13
+ Signer,
14
+ TransactionBuilder,
15
+ publicKey,
16
+ transactionBuilder,
17
+ } from '@metaplex-foundation/umi';
18
+ import {
19
+ Serializer,
20
+ array,
21
+ mapSerializer,
22
+ struct,
23
+ u8,
24
+ } from '@metaplex-foundation/umi/serializers';
25
+ import {
26
+ ResolvedAccount,
27
+ ResolvedAccountsWithIndices,
28
+ getAccountMetasAndSigners,
29
+ } from '../shared';
30
+
31
+ // Accounts.
32
+ export type CreateProgramOpenOrdersInstructionAccounts = {
33
+ openOrders: PublicKey | Pda;
34
+ payer?: Signer;
35
+ programAuthority: PublicKey | Pda;
36
+ dexProgram: PublicKey | Pda;
37
+ systemProgram?: PublicKey | Pda;
38
+ rent?: PublicKey | Pda;
39
+ market: PublicKey | Pda;
40
+ };
41
+
42
+ // Data.
43
+ export type CreateProgramOpenOrdersInstructionData = {
44
+ discriminator: Array<number>;
45
+ id: number;
46
+ };
47
+
48
+ export type CreateProgramOpenOrdersInstructionDataArgs = { id: number };
49
+
50
+ export function getCreateProgramOpenOrdersInstructionDataSerializer(): Serializer<
51
+ CreateProgramOpenOrdersInstructionDataArgs,
52
+ CreateProgramOpenOrdersInstructionData
53
+ > {
54
+ return mapSerializer<
55
+ CreateProgramOpenOrdersInstructionDataArgs,
56
+ any,
57
+ CreateProgramOpenOrdersInstructionData
58
+ >(
59
+ struct<CreateProgramOpenOrdersInstructionData>(
60
+ [
61
+ ['discriminator', array(u8(), { size: 8 })],
62
+ ['id', u8()],
63
+ ],
64
+ { description: 'CreateProgramOpenOrdersInstructionData' }
65
+ ),
66
+ (value) => ({
67
+ ...value,
68
+ discriminator: [28, 226, 32, 148, 188, 136, 113, 171],
69
+ })
70
+ ) as Serializer<
71
+ CreateProgramOpenOrdersInstructionDataArgs,
72
+ CreateProgramOpenOrdersInstructionData
73
+ >;
74
+ }
75
+
76
+ // Args.
77
+ export type CreateProgramOpenOrdersInstructionArgs =
78
+ CreateProgramOpenOrdersInstructionDataArgs;
79
+
80
+ // Instruction.
81
+ export function createProgramOpenOrders(
82
+ context: Pick<Context, 'payer' | 'programs'>,
83
+ input: CreateProgramOpenOrdersInstructionAccounts &
84
+ CreateProgramOpenOrdersInstructionArgs
85
+ ): TransactionBuilder {
86
+ // Program ID.
87
+ const programId = context.programs.getPublicKey(
88
+ 'jupiter',
89
+ 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
90
+ );
91
+
92
+ // Accounts.
93
+ const resolvedAccounts = {
94
+ openOrders: {
95
+ index: 0,
96
+ isWritable: true as boolean,
97
+ value: input.openOrders ?? null,
98
+ },
99
+ payer: {
100
+ index: 1,
101
+ isWritable: true as boolean,
102
+ value: input.payer ?? null,
103
+ },
104
+ programAuthority: {
105
+ index: 2,
106
+ isWritable: false as boolean,
107
+ value: input.programAuthority ?? null,
108
+ },
109
+ dexProgram: {
110
+ index: 3,
111
+ isWritable: false as boolean,
112
+ value: input.dexProgram ?? null,
113
+ },
114
+ systemProgram: {
115
+ index: 4,
116
+ isWritable: false as boolean,
117
+ value: input.systemProgram ?? null,
118
+ },
119
+ rent: { index: 5, isWritable: false as boolean, value: input.rent ?? null },
120
+ market: {
121
+ index: 6,
122
+ isWritable: false as boolean,
123
+ value: input.market ?? null,
124
+ },
125
+ } satisfies ResolvedAccountsWithIndices;
126
+
127
+ // Arguments.
128
+ const resolvedArgs: CreateProgramOpenOrdersInstructionArgs = { ...input };
129
+
130
+ // Default values.
131
+ if (!resolvedAccounts.payer.value) {
132
+ resolvedAccounts.payer.value = context.payer;
133
+ }
134
+ if (!resolvedAccounts.systemProgram.value) {
135
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
136
+ 'splSystem',
137
+ '11111111111111111111111111111111'
138
+ );
139
+ resolvedAccounts.systemProgram.isWritable = false;
140
+ }
141
+ if (!resolvedAccounts.rent.value) {
142
+ resolvedAccounts.rent.value = publicKey(
143
+ 'SysvarRent111111111111111111111111111111111'
144
+ );
145
+ }
146
+
147
+ // Accounts in order.
148
+ const orderedAccounts: ResolvedAccount[] = Object.values(
149
+ resolvedAccounts
150
+ ).sort((a, b) => a.index - b.index);
151
+
152
+ // Keys and Signers.
153
+ const [keys, signers] = getAccountMetasAndSigners(
154
+ orderedAccounts,
155
+ 'programId',
156
+ programId
157
+ );
158
+
159
+ // Data.
160
+ const data = getCreateProgramOpenOrdersInstructionDataSerializer().serialize(
161
+ resolvedArgs as CreateProgramOpenOrdersInstructionDataArgs
162
+ );
163
+
164
+ // Bytes Created On Chain.
165
+ const bytesCreatedOnChain = 0;
166
+
167
+ return transactionBuilder([
168
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
169
+ ]);
170
+ }
@@ -0,0 +1,152 @@
1
+ /**
2
+ * This code was AUTOGENERATED using the kinobi library.
3
+ * Please DO NOT EDIT THIS FILE, instead use visitors
4
+ * to add features, then rerun kinobi to update it.
5
+ *
6
+ * @see https://github.com/metaplex-foundation/kinobi
7
+ */
8
+
9
+ import {
10
+ Context,
11
+ Pda,
12
+ PublicKey,
13
+ Signer,
14
+ TransactionBuilder,
15
+ transactionBuilder,
16
+ } from '@metaplex-foundation/umi';
17
+ import {
18
+ Serializer,
19
+ array,
20
+ mapSerializer,
21
+ struct,
22
+ u8,
23
+ } from '@metaplex-foundation/umi/serializers';
24
+ import {
25
+ ResolvedAccount,
26
+ ResolvedAccountsWithIndices,
27
+ getAccountMetasAndSigners,
28
+ } from '../shared';
29
+
30
+ // Accounts.
31
+ export type CreateTokenAccountInstructionAccounts = {
32
+ tokenAccount: PublicKey | Pda;
33
+ user: Signer;
34
+ mint: PublicKey | Pda;
35
+ tokenProgram?: PublicKey | Pda;
36
+ systemProgram?: PublicKey | Pda;
37
+ };
38
+
39
+ // Data.
40
+ export type CreateTokenAccountInstructionData = {
41
+ discriminator: Array<number>;
42
+ bump: number;
43
+ };
44
+
45
+ export type CreateTokenAccountInstructionDataArgs = { bump: number };
46
+
47
+ export function getCreateTokenAccountInstructionDataSerializer(): Serializer<
48
+ CreateTokenAccountInstructionDataArgs,
49
+ CreateTokenAccountInstructionData
50
+ > {
51
+ return mapSerializer<
52
+ CreateTokenAccountInstructionDataArgs,
53
+ any,
54
+ CreateTokenAccountInstructionData
55
+ >(
56
+ struct<CreateTokenAccountInstructionData>(
57
+ [
58
+ ['discriminator', array(u8(), { size: 8 })],
59
+ ['bump', u8()],
60
+ ],
61
+ { description: 'CreateTokenAccountInstructionData' }
62
+ ),
63
+ (value) => ({
64
+ ...value,
65
+ discriminator: [147, 241, 123, 100, 244, 132, 174, 118],
66
+ })
67
+ ) as Serializer<
68
+ CreateTokenAccountInstructionDataArgs,
69
+ CreateTokenAccountInstructionData
70
+ >;
71
+ }
72
+
73
+ // Args.
74
+ export type CreateTokenAccountInstructionArgs =
75
+ CreateTokenAccountInstructionDataArgs;
76
+
77
+ // Instruction.
78
+ export function createTokenAccount(
79
+ context: Pick<Context, 'programs'>,
80
+ input: CreateTokenAccountInstructionAccounts &
81
+ CreateTokenAccountInstructionArgs
82
+ ): TransactionBuilder {
83
+ // Program ID.
84
+ const programId = context.programs.getPublicKey(
85
+ 'jupiter',
86
+ 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4'
87
+ );
88
+
89
+ // Accounts.
90
+ const resolvedAccounts = {
91
+ tokenAccount: {
92
+ index: 0,
93
+ isWritable: true as boolean,
94
+ value: input.tokenAccount ?? null,
95
+ },
96
+ user: { index: 1, isWritable: true as boolean, value: input.user ?? null },
97
+ mint: { index: 2, isWritable: false as boolean, value: input.mint ?? null },
98
+ tokenProgram: {
99
+ index: 3,
100
+ isWritable: false as boolean,
101
+ value: input.tokenProgram ?? null,
102
+ },
103
+ systemProgram: {
104
+ index: 4,
105
+ isWritable: false as boolean,
106
+ value: input.systemProgram ?? null,
107
+ },
108
+ } satisfies ResolvedAccountsWithIndices;
109
+
110
+ // Arguments.
111
+ const resolvedArgs: CreateTokenAccountInstructionArgs = { ...input };
112
+
113
+ // Default values.
114
+ if (!resolvedAccounts.tokenProgram.value) {
115
+ resolvedAccounts.tokenProgram.value = context.programs.getPublicKey(
116
+ 'splToken',
117
+ 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
118
+ );
119
+ resolvedAccounts.tokenProgram.isWritable = false;
120
+ }
121
+ if (!resolvedAccounts.systemProgram.value) {
122
+ resolvedAccounts.systemProgram.value = context.programs.getPublicKey(
123
+ 'splSystem',
124
+ '11111111111111111111111111111111'
125
+ );
126
+ resolvedAccounts.systemProgram.isWritable = false;
127
+ }
128
+
129
+ // Accounts in order.
130
+ const orderedAccounts: ResolvedAccount[] = Object.values(
131
+ resolvedAccounts
132
+ ).sort((a, b) => a.index - b.index);
133
+
134
+ // Keys and Signers.
135
+ const [keys, signers] = getAccountMetasAndSigners(
136
+ orderedAccounts,
137
+ 'programId',
138
+ programId
139
+ );
140
+
141
+ // Data.
142
+ const data = getCreateTokenAccountInstructionDataSerializer().serialize(
143
+ resolvedArgs as CreateTokenAccountInstructionDataArgs
144
+ );
145
+
146
+ // Bytes Created On Chain.
147
+ const bytesCreatedOnChain = 0;
148
+
149
+ return transactionBuilder([
150
+ { instruction: { keys, programId, data }, signers, bytesCreatedOnChain },
151
+ ]);
152
+ }