@send-fun/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 (172) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/dist/index.cjs +12808 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +4406 -0
  6. package/dist/index.d.cts.map +1 -0
  7. package/dist/index.d.mts +4405 -0
  8. package/dist/index.d.mts.map +1 -0
  9. package/dist/index.mjs +12749 -0
  10. package/dist/index.mjs.map +1 -0
  11. package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
  12. package/package.json +72 -0
  13. package/src/constants.ts +38 -0
  14. package/src/dex/generated/accounts/globalConfig.ts +189 -0
  15. package/src/dex/generated/accounts/index.ts +12 -0
  16. package/src/dex/generated/accounts/pool.ts +244 -0
  17. package/src/dex/generated/accounts/rewardAccrual.ts +191 -0
  18. package/src/dex/generated/accounts/sendDex.accounts.ts +47 -0
  19. package/src/dex/generated/errors/index.ts +9 -0
  20. package/src/dex/generated/errors/sendDex.ts +161 -0
  21. package/src/dex/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  22. package/src/dex/generated/events/creatorClaimEvent.ts +119 -0
  23. package/src/dex/generated/events/depositQuoteEvent.ts +115 -0
  24. package/src/dex/generated/events/index.ts +16 -0
  25. package/src/dex/generated/events/poolCreateEvent.ts +128 -0
  26. package/src/dex/generated/events/protocolClaimEvent.ts +111 -0
  27. package/src/dex/generated/events/sendDex.events.ts +184 -0
  28. package/src/dex/generated/events/tokenCreateEvent.ts +143 -0
  29. package/src/dex/generated/events/tradeEvent.ts +143 -0
  30. package/src/dex/generated/index.ts +16 -0
  31. package/src/dex/generated/instructions/buyExactIn.ts +815 -0
  32. package/src/dex/generated/instructions/buyExactOut.ts +815 -0
  33. package/src/dex/generated/instructions/claimCreatorFees.ts +648 -0
  34. package/src/dex/generated/instructions/claimProtocolFees.ts +640 -0
  35. package/src/dex/generated/instructions/index.ts +15 -0
  36. package/src/dex/generated/instructions/sellExactIn.ts +815 -0
  37. package/src/dex/generated/instructions/sellExactOut.ts +815 -0
  38. package/src/dex/generated/instructions/sendDex.instructions.ts +173 -0
  39. package/src/dex/generated/pdas/eventAuthority.ts +20 -0
  40. package/src/dex/generated/pdas/globalConfig.ts +20 -0
  41. package/src/dex/generated/pdas/index.ts +14 -0
  42. package/src/dex/generated/pdas/lpMint.ts +36 -0
  43. package/src/dex/generated/pdas/pool.ts +34 -0
  44. package/src/dex/generated/pdas/rewardAccrual.ts +37 -0
  45. package/src/dex/generated/pdas/wsolRewardAccrual.ts +20 -0
  46. package/src/dex/generated/plugins/index.ts +9 -0
  47. package/src/dex/generated/plugins/sendDex.ts +282 -0
  48. package/src/dex/generated/programs/index.ts +9 -0
  49. package/src/dex/generated/programs/sendDex.ts +12 -0
  50. package/src/dex/generated/types/index.ts +10 -0
  51. package/src/dex/generated/types/poolStatus.ts +38 -0
  52. package/src/dex/generated/types/tradeDirection.ts +38 -0
  53. package/src/dex/index.ts +8 -0
  54. package/src/dex/trade.ts +215 -0
  55. package/src/index.ts +8 -0
  56. package/src/launchpad/create.ts +116 -0
  57. package/src/launchpad/generated/accounts/bondingCurve.ts +273 -0
  58. package/src/launchpad/generated/accounts/globalConfig.ts +211 -0
  59. package/src/launchpad/generated/accounts/index.ts +12 -0
  60. package/src/launchpad/generated/accounts/rewardAccrual.ts +191 -0
  61. package/src/launchpad/generated/accounts/sendLaunchpad.accounts.ts +50 -0
  62. package/src/launchpad/generated/errors/index.ts +9 -0
  63. package/src/launchpad/generated/errors/sendLaunchpad.ts +175 -0
  64. package/src/launchpad/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  65. package/src/launchpad/generated/events/completeEvent.ts +120 -0
  66. package/src/launchpad/generated/events/creatorClaimEvent.ts +122 -0
  67. package/src/launchpad/generated/events/index.ts +17 -0
  68. package/src/launchpad/generated/events/migrateEvent.ts +121 -0
  69. package/src/launchpad/generated/events/protocolClaimEvent.ts +114 -0
  70. package/src/launchpad/generated/events/recycleEvent.ts +113 -0
  71. package/src/launchpad/generated/events/sendLaunchpad.events.ts +207 -0
  72. package/src/launchpad/generated/events/tokenCreateEvent.ts +156 -0
  73. package/src/launchpad/generated/events/tradeEvent.ts +148 -0
  74. package/src/launchpad/generated/index.ts +16 -0
  75. package/src/launchpad/generated/instructions/buyExactIn.ts +818 -0
  76. package/src/launchpad/generated/instructions/buyExactOut.ts +818 -0
  77. package/src/launchpad/generated/instructions/claimCreatorFees.ts +651 -0
  78. package/src/launchpad/generated/instructions/claimProtocolFees.ts +640 -0
  79. package/src/launchpad/generated/instructions/createToken.ts +1150 -0
  80. package/src/launchpad/generated/instructions/index.ts +17 -0
  81. package/src/launchpad/generated/instructions/migrate.ts +840 -0
  82. package/src/launchpad/generated/instructions/sellExactIn.ts +818 -0
  83. package/src/launchpad/generated/instructions/sellExactOut.ts +818 -0
  84. package/src/launchpad/generated/instructions/sendLaunchpad.instructions.ts +210 -0
  85. package/src/launchpad/generated/pdas/bondingCurve.ts +39 -0
  86. package/src/launchpad/generated/pdas/eventAuthority.ts +20 -0
  87. package/src/launchpad/generated/pdas/globalConfig.ts +20 -0
  88. package/src/launchpad/generated/pdas/index.ts +14 -0
  89. package/src/launchpad/generated/pdas/migrationAuthority.ts +20 -0
  90. package/src/launchpad/generated/pdas/rewardAccrual.ts +37 -0
  91. package/src/launchpad/generated/pdas/wsolRewardAccrual.ts +20 -0
  92. package/src/launchpad/generated/plugins/index.ts +9 -0
  93. package/src/launchpad/generated/plugins/sendLaunchpad.ts +315 -0
  94. package/src/launchpad/generated/programs/index.ts +9 -0
  95. package/src/launchpad/generated/programs/sendLaunchpad.ts +12 -0
  96. package/src/launchpad/generated/types/bondingCurveStatus.ts +43 -0
  97. package/src/launchpad/generated/types/index.ts +10 -0
  98. package/src/launchpad/generated/types/tradeDirection.ts +38 -0
  99. package/src/launchpad/index.ts +10 -0
  100. package/src/launchpad/migrate.ts +54 -0
  101. package/src/launchpad/trade.ts +247 -0
  102. package/src/math/amm.ts +511 -0
  103. package/src/math/fee-decay.ts +49 -0
  104. package/src/math/fees.ts +75 -0
  105. package/src/math/index.ts +3 -0
  106. package/src/math/internal.ts +16 -0
  107. package/src/nexus/fee-helpers.ts +49 -0
  108. package/src/nexus/generated/accounts/altRegistry.ts +177 -0
  109. package/src/nexus/generated/accounts/creatorFeeConfig.ts +200 -0
  110. package/src/nexus/generated/accounts/feePreset.ts +196 -0
  111. package/src/nexus/generated/accounts/globalConfig.ts +188 -0
  112. package/src/nexus/generated/accounts/index.ts +19 -0
  113. package/src/nexus/generated/accounts/partnerConfig.ts +209 -0
  114. package/src/nexus/generated/accounts/partnerMetadata.ts +216 -0
  115. package/src/nexus/generated/accounts/rewardState.ts +209 -0
  116. package/src/nexus/generated/accounts/sendNexus.accounts.ts +85 -0
  117. package/src/nexus/generated/accounts/stakingConfig.ts +197 -0
  118. package/src/nexus/generated/accounts/userRewardDebt.ts +221 -0
  119. package/src/nexus/generated/accounts/userStakePosition.ts +218 -0
  120. package/src/nexus/generated/constants/index.ts +9 -0
  121. package/src/nexus/generated/constants/sendNexus.ts +13 -0
  122. package/src/nexus/generated/errors/index.ts +9 -0
  123. package/src/nexus/generated/errors/sendNexus.ts +229 -0
  124. package/src/nexus/generated/events/anchorEventCpiDiscriminator.framing.ts +28 -0
  125. package/src/nexus/generated/events/claimEvent.ts +106 -0
  126. package/src/nexus/generated/events/index.ts +13 -0
  127. package/src/nexus/generated/events/sendNexus.events.ts +121 -0
  128. package/src/nexus/generated/events/stakeEvent.ts +106 -0
  129. package/src/nexus/generated/events/unstakeEvent.ts +106 -0
  130. package/src/nexus/generated/index.ts +17 -0
  131. package/src/nexus/generated/instructions/claim.ts +740 -0
  132. package/src/nexus/generated/instructions/createUserRewardDebt.ts +498 -0
  133. package/src/nexus/generated/instructions/index.ts +14 -0
  134. package/src/nexus/generated/instructions/sendNexus.instructions.ts +146 -0
  135. package/src/nexus/generated/instructions/settle.ts +517 -0
  136. package/src/nexus/generated/instructions/stake.ts +615 -0
  137. package/src/nexus/generated/instructions/unstake.ts +593 -0
  138. package/src/nexus/generated/pdas/altRegistry.ts +20 -0
  139. package/src/nexus/generated/pdas/creatorFeeConfig.ts +39 -0
  140. package/src/nexus/generated/pdas/defaultFeePreset.ts +37 -0
  141. package/src/nexus/generated/pdas/defaultPartner.ts +40 -0
  142. package/src/nexus/generated/pdas/defaultPartnerMetadata.ts +42 -0
  143. package/src/nexus/generated/pdas/eventAuthority.ts +20 -0
  144. package/src/nexus/generated/pdas/feePreset.ts +39 -0
  145. package/src/nexus/generated/pdas/globalConfig.ts +20 -0
  146. package/src/nexus/generated/pdas/index.ts +22 -0
  147. package/src/nexus/generated/pdas/partnerConfig.ts +36 -0
  148. package/src/nexus/generated/pdas/partnerMetadata.ts +38 -0
  149. package/src/nexus/generated/pdas/rewardState.ts +36 -0
  150. package/src/nexus/generated/pdas/stakingConfig.ts +20 -0
  151. package/src/nexus/generated/pdas/userRewardDebt.ts +41 -0
  152. package/src/nexus/generated/pdas/userStakePosition.ts +39 -0
  153. package/src/nexus/generated/plugins/index.ts +9 -0
  154. package/src/nexus/generated/plugins/sendNexus.ts +494 -0
  155. package/src/nexus/generated/programs/index.ts +9 -0
  156. package/src/nexus/generated/programs/sendNexus.ts +12 -0
  157. package/src/nexus/generated/types/authPlatformEntry.ts +52 -0
  158. package/src/nexus/generated/types/callerType.ts +38 -0
  159. package/src/nexus/generated/types/dexFees.ts +64 -0
  160. package/src/nexus/generated/types/feeConfig.ts +73 -0
  161. package/src/nexus/generated/types/index.ts +13 -0
  162. package/src/nexus/generated/types/launchpadFees.ts +63 -0
  163. package/src/nexus/index.ts +9 -0
  164. package/src/nexus/staking.ts +581 -0
  165. package/src/platform.ts +19 -0
  166. package/src/transfer-fee.ts +216 -0
  167. package/src/utils/chunk.ts +21 -0
  168. package/src/utils/creator-hash.ts +57 -0
  169. package/src/utils/index.ts +9 -0
  170. package/src/utils/mint-info.ts +102 -0
  171. package/src/utils/partner.ts +5 -0
  172. package/src/utils/pda.ts +24 -0
@@ -0,0 +1,315 @@
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
+ extendClient,
11
+ type ClientWithPayer,
12
+ type ClientWithRpc,
13
+ type ClientWithTransactionPlanning,
14
+ type ClientWithTransactionSending,
15
+ type ExtendedClient,
16
+ type GetAccountInfoApi,
17
+ type GetMultipleAccountsApi,
18
+ } from '@solana/kit';
19
+ import {
20
+ addSelfPlanAndSendFunctions,
21
+ type SelfFetchFunctions,
22
+ type SelfPlanAndSendFunctions,
23
+ } from '@solana/program-client-core';
24
+ import {
25
+ fetchAllBondingCurve,
26
+ fetchAllGlobalConfig,
27
+ fetchAllMaybeBondingCurve,
28
+ fetchAllMaybeGlobalConfig,
29
+ fetchAllMaybeRewardAccrual,
30
+ fetchAllRewardAccrual,
31
+ fetchBondingCurve,
32
+ fetchGlobalConfig,
33
+ fetchMaybeBondingCurve,
34
+ fetchMaybeGlobalConfig,
35
+ fetchMaybeRewardAccrual,
36
+ fetchRewardAccrual,
37
+ getBondingCurveCodec,
38
+ getGlobalConfigCodec,
39
+ getRewardAccrualCodec,
40
+ identifySendLaunchpadAccount,
41
+ type BondingCurve,
42
+ type BondingCurveArgs,
43
+ type GlobalConfig,
44
+ type GlobalConfigArgs,
45
+ type RewardAccrual,
46
+ type RewardAccrualArgs,
47
+ } from '../accounts/index.js';
48
+ import {
49
+ getCompleteEventDecoder,
50
+ getCreatorClaimEventDecoder,
51
+ getMigrateEventDecoder,
52
+ getProtocolClaimEventDecoder,
53
+ getRecycleEventDecoder,
54
+ getTokenCreateEventDecoder,
55
+ getTradeEventDecoder,
56
+ } from '../events/index.js';
57
+ import {
58
+ getBuyExactInInstructionAsync,
59
+ getBuyExactOutInstructionAsync,
60
+ getClaimCreatorFeesInstructionAsync,
61
+ getClaimProtocolFeesInstructionAsync,
62
+ getCreateTokenInstructionAsync,
63
+ getMigrateInstructionAsync,
64
+ getSellExactInInstructionAsync,
65
+ getSellExactOutInstructionAsync,
66
+ identifySendLaunchpadInstruction,
67
+ parseSendLaunchpadInstruction,
68
+ type BuyExactInAsyncInput,
69
+ type BuyExactOutAsyncInput,
70
+ type ClaimCreatorFeesAsyncInput,
71
+ type ClaimProtocolFeesAsyncInput,
72
+ type CreateTokenAsyncInput,
73
+ type MigrateAsyncInput,
74
+ type SellExactInAsyncInput,
75
+ type SellExactOutAsyncInput,
76
+ } from '../instructions/index.js';
77
+ import {
78
+ findBondingCurvePda,
79
+ findEventAuthorityPda,
80
+ findGlobalConfigPda,
81
+ findMigrationAuthorityPda,
82
+ findRewardAccrualPda,
83
+ findWsolRewardAccrualPda,
84
+ } from '../pdas/index.js';
85
+
86
+ export type SendLaunchpadPlugin = {
87
+ accounts: SendLaunchpadPluginAccounts;
88
+ events: SendLaunchpadPluginEvents;
89
+ instructions: SendLaunchpadPluginInstructions;
90
+ pdas: SendLaunchpadPluginPdas;
91
+ identifyAccount: typeof identifySendLaunchpadAccount;
92
+ identifyInstruction: typeof identifySendLaunchpadInstruction;
93
+ parseInstruction: typeof parseSendLaunchpadInstruction;
94
+ };
95
+
96
+ export type SendLaunchpadPluginAccounts = {
97
+ bondingCurve: ReturnType<typeof getBondingCurveCodec> &
98
+ SelfFetchFunctions<BondingCurveArgs, BondingCurve>;
99
+ globalConfig: ReturnType<typeof getGlobalConfigCodec> &
100
+ SelfFetchFunctions<GlobalConfigArgs, GlobalConfig>;
101
+ rewardAccrual: ReturnType<typeof getRewardAccrualCodec> &
102
+ SelfFetchFunctions<RewardAccrualArgs, RewardAccrual>;
103
+ };
104
+
105
+ export type SendLaunchpadPluginEvents = {
106
+ completeEvent: ReturnType<typeof getCompleteEventDecoder>;
107
+ creatorClaimEvent: ReturnType<typeof getCreatorClaimEventDecoder>;
108
+ migrateEvent: ReturnType<typeof getMigrateEventDecoder>;
109
+ protocolClaimEvent: ReturnType<typeof getProtocolClaimEventDecoder>;
110
+ recycleEvent: ReturnType<typeof getRecycleEventDecoder>;
111
+ tokenCreateEvent: ReturnType<typeof getTokenCreateEventDecoder>;
112
+ tradeEvent: ReturnType<typeof getTradeEventDecoder>;
113
+ };
114
+
115
+ export type SendLaunchpadPluginInstructions = {
116
+ buyExactIn: (
117
+ input: MakeOptional<BuyExactInAsyncInput, 'payer'>,
118
+ ) => ReturnType<typeof getBuyExactInInstructionAsync> &
119
+ SelfPlanAndSendFunctions;
120
+ buyExactOut: (
121
+ input: MakeOptional<BuyExactOutAsyncInput, 'payer'>,
122
+ ) => ReturnType<typeof getBuyExactOutInstructionAsync> &
123
+ SelfPlanAndSendFunctions;
124
+ claimCreatorFees: (
125
+ input: MakeOptional<ClaimCreatorFeesAsyncInput, 'payer'>,
126
+ ) => ReturnType<typeof getClaimCreatorFeesInstructionAsync> &
127
+ SelfPlanAndSendFunctions;
128
+ claimProtocolFees: (
129
+ input: MakeOptional<ClaimProtocolFeesAsyncInput, 'payer'>,
130
+ ) => ReturnType<typeof getClaimProtocolFeesInstructionAsync> &
131
+ SelfPlanAndSendFunctions;
132
+ createToken: (
133
+ input: MakeOptional<CreateTokenAsyncInput, 'payer'>,
134
+ ) => ReturnType<typeof getCreateTokenInstructionAsync> &
135
+ SelfPlanAndSendFunctions;
136
+ migrate: (
137
+ input: MigrateAsyncInput,
138
+ ) => ReturnType<typeof getMigrateInstructionAsync> &
139
+ SelfPlanAndSendFunctions;
140
+ sellExactIn: (
141
+ input: MakeOptional<SellExactInAsyncInput, 'payer'>,
142
+ ) => ReturnType<typeof getSellExactInInstructionAsync> &
143
+ SelfPlanAndSendFunctions;
144
+ sellExactOut: (
145
+ input: MakeOptional<SellExactOutAsyncInput, 'payer'>,
146
+ ) => ReturnType<typeof getSellExactOutInstructionAsync> &
147
+ SelfPlanAndSendFunctions;
148
+ };
149
+
150
+ export type SendLaunchpadPluginPdas = {
151
+ bondingCurve: typeof findBondingCurvePda;
152
+ eventAuthority: typeof findEventAuthorityPda;
153
+ rewardAccrual: typeof findRewardAccrualPda;
154
+ globalConfig: typeof findGlobalConfigPda;
155
+ wsolRewardAccrual: typeof findWsolRewardAccrualPda;
156
+ migrationAuthority: typeof findMigrationAuthorityPda;
157
+ };
158
+
159
+ export type SendLaunchpadPluginRequirements = ClientWithRpc<
160
+ GetAccountInfoApi & GetMultipleAccountsApi
161
+ > &
162
+ ClientWithPayer &
163
+ ClientWithTransactionPlanning &
164
+ ClientWithTransactionSending;
165
+
166
+ export function sendLaunchpadProgram() {
167
+ return <T extends SendLaunchpadPluginRequirements>(
168
+ client: T,
169
+ ): ExtendedClient<T, { sendLaunchpad: SendLaunchpadPlugin }> => {
170
+ return extendClient(client, {
171
+ sendLaunchpad: <SendLaunchpadPlugin>{
172
+ accounts: {
173
+ bondingCurve: Object.freeze({
174
+ ...getBondingCurveCodec(),
175
+ fetch: (address, config) =>
176
+ fetchBondingCurve(client.rpc, address, config),
177
+ fetchAll: (addresses, config) =>
178
+ fetchAllBondingCurve(client.rpc, addresses, config),
179
+ fetchAllMaybe: (addresses, config) =>
180
+ fetchAllMaybeBondingCurve(
181
+ client.rpc,
182
+ addresses,
183
+ config,
184
+ ),
185
+ fetchMaybe: (address, config) =>
186
+ fetchMaybeBondingCurve(client.rpc, address, config),
187
+ }),
188
+ globalConfig: Object.freeze({
189
+ ...getGlobalConfigCodec(),
190
+ fetch: (address, config) =>
191
+ fetchGlobalConfig(client.rpc, address, config),
192
+ fetchAll: (addresses, config) =>
193
+ fetchAllGlobalConfig(client.rpc, addresses, config),
194
+ fetchAllMaybe: (addresses, config) =>
195
+ fetchAllMaybeGlobalConfig(
196
+ client.rpc,
197
+ addresses,
198
+ config,
199
+ ),
200
+ fetchMaybe: (address, config) =>
201
+ fetchMaybeGlobalConfig(client.rpc, address, config),
202
+ }),
203
+ rewardAccrual: Object.freeze({
204
+ ...getRewardAccrualCodec(),
205
+ fetch: (address, config) =>
206
+ fetchRewardAccrual(client.rpc, address, config),
207
+ fetchAll: (addresses, config) =>
208
+ fetchAllRewardAccrual(
209
+ client.rpc,
210
+ addresses,
211
+ config,
212
+ ),
213
+ fetchAllMaybe: (addresses, config) =>
214
+ fetchAllMaybeRewardAccrual(
215
+ client.rpc,
216
+ addresses,
217
+ config,
218
+ ),
219
+ fetchMaybe: (address, config) =>
220
+ fetchMaybeRewardAccrual(
221
+ client.rpc,
222
+ address,
223
+ config,
224
+ ),
225
+ }),
226
+ },
227
+ events: {
228
+ completeEvent: getCompleteEventDecoder(),
229
+ creatorClaimEvent: getCreatorClaimEventDecoder(),
230
+ migrateEvent: getMigrateEventDecoder(),
231
+ protocolClaimEvent: getProtocolClaimEventDecoder(),
232
+ recycleEvent: getRecycleEventDecoder(),
233
+ tokenCreateEvent: getTokenCreateEventDecoder(),
234
+ tradeEvent: getTradeEventDecoder(),
235
+ },
236
+ instructions: {
237
+ buyExactIn: (input) =>
238
+ addSelfPlanAndSendFunctions(
239
+ client,
240
+ getBuyExactInInstructionAsync({
241
+ ...input,
242
+ payer: input.payer ?? client.payer,
243
+ }),
244
+ ),
245
+ buyExactOut: (input) =>
246
+ addSelfPlanAndSendFunctions(
247
+ client,
248
+ getBuyExactOutInstructionAsync({
249
+ ...input,
250
+ payer: input.payer ?? client.payer,
251
+ }),
252
+ ),
253
+ claimCreatorFees: (input) =>
254
+ addSelfPlanAndSendFunctions(
255
+ client,
256
+ getClaimCreatorFeesInstructionAsync({
257
+ ...input,
258
+ payer: input.payer ?? client.payer,
259
+ }),
260
+ ),
261
+ claimProtocolFees: (input) =>
262
+ addSelfPlanAndSendFunctions(
263
+ client,
264
+ getClaimProtocolFeesInstructionAsync({
265
+ ...input,
266
+ payer: input.payer ?? client.payer,
267
+ }),
268
+ ),
269
+ createToken: (input) =>
270
+ addSelfPlanAndSendFunctions(
271
+ client,
272
+ getCreateTokenInstructionAsync({
273
+ ...input,
274
+ payer: input.payer ?? client.payer,
275
+ }),
276
+ ),
277
+ migrate: (input) =>
278
+ addSelfPlanAndSendFunctions(
279
+ client,
280
+ getMigrateInstructionAsync(input),
281
+ ),
282
+ sellExactIn: (input) =>
283
+ addSelfPlanAndSendFunctions(
284
+ client,
285
+ getSellExactInInstructionAsync({
286
+ ...input,
287
+ payer: input.payer ?? client.payer,
288
+ }),
289
+ ),
290
+ sellExactOut: (input) =>
291
+ addSelfPlanAndSendFunctions(
292
+ client,
293
+ getSellExactOutInstructionAsync({
294
+ ...input,
295
+ payer: input.payer ?? client.payer,
296
+ }),
297
+ ),
298
+ },
299
+ pdas: {
300
+ bondingCurve: findBondingCurvePda,
301
+ eventAuthority: findEventAuthorityPda,
302
+ rewardAccrual: findRewardAccrualPda,
303
+ globalConfig: findGlobalConfigPda,
304
+ wsolRewardAccrual: findWsolRewardAccrualPda,
305
+ migrationAuthority: findMigrationAuthorityPda,
306
+ },
307
+ identifyAccount: identifySendLaunchpadAccount,
308
+ identifyInstruction: identifySendLaunchpadInstruction,
309
+ parseInstruction: parseSendLaunchpadInstruction,
310
+ },
311
+ });
312
+ };
313
+ }
314
+
315
+ type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
@@ -0,0 +1,9 @@
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
+ export * from './sendLaunchpad.js';
@@ -0,0 +1,12 @@
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 type { Address } from '@solana/kit';
10
+
11
+ export const SEND_LAUNCHPAD_PROGRAM_ADDRESS =
12
+ '5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP' as Address<'5R1uFyEE4oxqkm7hJDqHq6gXaLVF9dxeF3LF4yz1sfLP'>;
@@ -0,0 +1,43 @@
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
+ combineCodec,
11
+ getEnumDecoder,
12
+ getEnumEncoder,
13
+ type FixedSizeCodec,
14
+ type FixedSizeDecoder,
15
+ type FixedSizeEncoder,
16
+ } from '@solana/kit';
17
+
18
+ export enum BondingCurveStatus {
19
+ Funding,
20
+ Completed,
21
+ Migrated,
22
+ Paused,
23
+ }
24
+
25
+ export type BondingCurveStatusArgs = BondingCurveStatus;
26
+
27
+ export function getBondingCurveStatusEncoder(): FixedSizeEncoder<BondingCurveStatusArgs> {
28
+ return getEnumEncoder(BondingCurveStatus);
29
+ }
30
+
31
+ export function getBondingCurveStatusDecoder(): FixedSizeDecoder<BondingCurveStatus> {
32
+ return getEnumDecoder(BondingCurveStatus);
33
+ }
34
+
35
+ export function getBondingCurveStatusCodec(): FixedSizeCodec<
36
+ BondingCurveStatusArgs,
37
+ BondingCurveStatus
38
+ > {
39
+ return combineCodec(
40
+ getBondingCurveStatusEncoder(),
41
+ getBondingCurveStatusDecoder(),
42
+ );
43
+ }
@@ -0,0 +1,10 @@
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
+ export * from './bondingCurveStatus.js';
10
+ export * from './tradeDirection.js';
@@ -0,0 +1,38 @@
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
+ combineCodec,
11
+ getEnumDecoder,
12
+ getEnumEncoder,
13
+ type FixedSizeCodec,
14
+ type FixedSizeDecoder,
15
+ type FixedSizeEncoder,
16
+ } from '@solana/kit';
17
+
18
+ export enum TradeDirection {
19
+ Buy,
20
+ Sell,
21
+ }
22
+
23
+ export type TradeDirectionArgs = TradeDirection;
24
+
25
+ export function getTradeDirectionEncoder(): FixedSizeEncoder<TradeDirectionArgs> {
26
+ return getEnumEncoder(TradeDirection);
27
+ }
28
+
29
+ export function getTradeDirectionDecoder(): FixedSizeDecoder<TradeDirection> {
30
+ return getEnumDecoder(TradeDirection);
31
+ }
32
+
33
+ export function getTradeDirectionCodec(): FixedSizeCodec<
34
+ TradeDirectionArgs,
35
+ TradeDirection
36
+ > {
37
+ return combineCodec(getTradeDirectionEncoder(), getTradeDirectionDecoder());
38
+ }
@@ -0,0 +1,10 @@
1
+ export * as accounts from './generated/accounts/index.js';
2
+ export * as types from './generated/types/index.js';
3
+ export * as errors from './generated/errors/index.js';
4
+ export * as pda from './generated/pdas/index.js';
5
+ export * as create from './create.js';
6
+ export * as events from './generated/events/index.js';
7
+ export * as instructions from './generated/instructions/index.js';
8
+ export * as plugins from './generated/plugins/index.js';
9
+ export * as migrate from './migrate.js';
10
+ export * as trade from './trade.js';
@@ -0,0 +1,54 @@
1
+ import type { Address, Instruction, TransactionSigner } from '@solana/kit';
2
+ import { TOKEN_2022_PROGRAM_ADDRESS } from '../constants.js';
3
+ import { findAssociatedTokenPda } from '../utils/pda.js';
4
+ import { findPoolPda } from '../dex/generated/pdas/pool.js';
5
+ import { findLpMintPda } from '../dex/generated/pdas/lpMint.js';
6
+ import { getMigrateInstructionAsync } from './generated/instructions/migrate.js';
7
+
8
+ export interface MigrateParams {
9
+ caller: TransactionSigner;
10
+ baseMint: Address;
11
+ quoteMint: Address;
12
+ /** `bondingCurve.creatorFeeConfig`; `migrate` rejects any other address. */
13
+ creatorFeeConfig: Address;
14
+ quoteTokenProgram: Address;
15
+ }
16
+
17
+ export async function buildMigrateInstruction(
18
+ params: MigrateParams,
19
+ ): Promise<Instruction> {
20
+ const { quoteTokenProgram } = params;
21
+
22
+ const [[pool], [lpMint]] = await Promise.all([
23
+ findPoolPda({
24
+ baseMint: params.baseMint,
25
+ quoteMint: params.quoteMint,
26
+ }),
27
+ findLpMintPda({
28
+ baseMint: params.baseMint,
29
+ quoteMint: params.quoteMint,
30
+ }),
31
+ ]);
32
+
33
+ const [[poolBaseVault], [poolQuoteVault], [poolLpAccount]] =
34
+ await Promise.all([
35
+ findAssociatedTokenPda(
36
+ pool,
37
+ params.baseMint,
38
+ TOKEN_2022_PROGRAM_ADDRESS,
39
+ ),
40
+ findAssociatedTokenPda(pool, params.quoteMint, quoteTokenProgram),
41
+ findAssociatedTokenPda(pool, lpMint, TOKEN_2022_PROGRAM_ADDRESS),
42
+ ]);
43
+
44
+ return getMigrateInstructionAsync({
45
+ caller: params.caller,
46
+ baseMint: params.baseMint,
47
+ quoteMint: params.quoteMint,
48
+ creatorFeeConfig: params.creatorFeeConfig,
49
+ poolBaseVault,
50
+ poolQuoteVault,
51
+ poolLpAccount,
52
+ quoteTokenProgram,
53
+ });
54
+ }